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 = {
callbackUrl: string;
connectTimeout?: number;
closeAppOnActions?: boolean;
}
export type WebApp = typeof WebAppConst;
+1
View File
@@ -4,6 +4,7 @@ import { Wallet } from './wallet';
const defaultInjectionConfig: Required<InjectionConfig> = {
callbackUrl: '',
connectTimeout: 30_000,
closeAppOnActions: true,
}
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 callbackUrl: string;
private readonly connectTimeout: number;
private readonly closeAppOnActions: boolean;
constructor(
private readonly webApp: WebApp,
{ callbackUrl, connectTimeout }: Required<InjectionConfig>,
{ callbackUrl, connectTimeout, closeAppOnActions }: Required<InjectionConfig>,
) {
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();
}
}