From 158eb100faf6c1367dea2b52dbbd92ff17bc891d Mon Sep 17 00:00:00 2001 From: odiinnn <38395645+odiinnn@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:38:11 +0300 Subject: [PATCH] Add closeAppOnActions option to InjectionConfig and Wallet class - Introduced closeAppOnActions property in InjectionConfig to control app closure behavior. - Updated defaultInjectionConfig to set closeAppOnActions to true. - Modified Wallet class to utilize closeAppOnActions when handling actions, ensuring the app closes as intended based on this configuration. --- src/types.ts | 1 + src/varan-wallet.ts | 1 + src/wallet.ts | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/types.ts b/src/types.ts index 95a411f..028fb33 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,6 +10,7 @@ export type WalletStorage = Storage; export type InjectionConfig = { callbackUrl: string; connectTimeout?: number; + closeAppOnActions?: boolean; } export type WebApp = typeof WebAppConst; diff --git a/src/varan-wallet.ts b/src/varan-wallet.ts index 781f103..c18cf21 100644 --- a/src/varan-wallet.ts +++ b/src/varan-wallet.ts @@ -4,6 +4,7 @@ import { Wallet } from './wallet'; const defaultInjectionConfig: Required = { callbackUrl: '', connectTimeout: 30_000, + closeAppOnActions: true, } const injectVaranWallet = (webApp: WebApp, config: InjectionConfig = defaultInjectionConfig): void => { diff --git a/src/wallet.ts b/src/wallet.ts index 6470676..af16f42 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -13,15 +13,17 @@ export class Wallet implements InjectedWindowProvider { private readonly name = 'Varan Wallet'; private readonly callbackUrl: string; private readonly connectTimeout: number; + private readonly closeAppOnActions: boolean; constructor( private readonly webApp: WebApp, - { callbackUrl, connectTimeout }: Required, + { callbackUrl, connectTimeout, closeAppOnActions }: Required, ) { this.varanWalletUrl = 'https://t.me/varanwalletbot?startapp='; this.store = new WalletStore(); this.callbackUrl = callbackUrl; this.connectTimeout = connectTimeout; + this.closeAppOnActions = closeAppOnActions; void this._startParamsCheck(); } @@ -72,7 +74,7 @@ export class Wallet implements InjectedWindowProvider { } - if (actions) { + if (actions && this.closeAppOnActions) { this.webApp.close(); } }