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.
This commit is contained in:
odiinnn committed 2025-09-30 18:38:11 +03:00
1 parent f46a4418c9
commit 158eb100fa
3 files changed
+6 -2

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ export type WalletStorage = Storage;
export type InjectionConfig = { export type InjectionConfig = {
callbackUrl: string; callbackUrl: string;
connectTimeout?: number; connectTimeout?: number;
closeAppOnActions?: boolean;
} }
export type WebApp = typeof WebAppConst; export type WebApp = typeof WebAppConst;
+1
View File
@@ -4,6 +4,7 @@ import { Wallet } from './wallet';
const defaultInjectionConfig: Required<InjectionConfig> = { const defaultInjectionConfig: Required<InjectionConfig> = {
callbackUrl: '', callbackUrl: '',
connectTimeout: 30_000, connectTimeout: 30_000,
closeAppOnActions: true,
} }
const injectVaranWallet = (webApp: WebApp, config: InjectionConfig = defaultInjectionConfig): void => { const injectVaranWallet = (webApp: WebApp, config: InjectionConfig = defaultInjectionConfig): void => {
+4 -2
View File
@@ -13,15 +13,17 @@ export class Wallet implements InjectedWindowProvider {
private readonly name = 'Varan Wallet'; private readonly name = 'Varan Wallet';
private readonly callbackUrl: string; private readonly callbackUrl: string;
private readonly connectTimeout: number; private readonly connectTimeout: number;
private readonly closeAppOnActions: boolean;
constructor( constructor(
private readonly webApp: WebApp, private readonly webApp: WebApp,
{ callbackUrl, connectTimeout }: Required<InjectionConfig>, { callbackUrl, connectTimeout, closeAppOnActions }: Required<InjectionConfig>,
) { ) {
this.varanWalletUrl = 'https://t.me/varanwalletbot?startapp='; this.varanWalletUrl = 'https://t.me/varanwalletbot?startapp=';
this.store = new WalletStore(); this.store = new WalletStore();
this.callbackUrl = callbackUrl; this.callbackUrl = callbackUrl;
this.connectTimeout = connectTimeout; this.connectTimeout = connectTimeout;
this.closeAppOnActions = closeAppOnActions;
void this._startParamsCheck(); void this._startParamsCheck();
} }
@@ -72,7 +74,7 @@ export class Wallet implements InjectedWindowProvider {
} }
if (actions) { if (actions && this.closeAppOnActions) {
this.webApp.close(); this.webApp.close();
} }
} }