From 267d56cee19d02fc462865009b1e64d55c222979 Mon Sep 17 00:00:00 2001 From: odiinnn <38395645+odiinnn@users.noreply.github.com> Date: Mon, 1 Sep 2025 09:42:54 +0300 Subject: [PATCH] Refactor callback URL handling in injectVaranWallet function - Changed callbackUrl in defaultInjectionConfig to an empty string. - Updated injectVaranWallet to throw an error if callbackUrl is not provided in the config, ensuring proper error handling. --- src/varan-wallet.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/varan-wallet.ts b/src/varan-wallet.ts index 282bdf7..0ced4ce 100644 --- a/src/varan-wallet.ts +++ b/src/varan-wallet.ts @@ -2,9 +2,7 @@ import type { WebApp, InjectionConfig } from './types'; import { Wallet } from './wallet'; const defaultInjectionConfig: Required = { - get callbackUrl(): string { - throw new Error('Callback URL must be provided to injectVaranWallet'); - }, + callbackUrl: '', isDev: false, connectTimeout: 30_000, storage: { @@ -20,6 +18,12 @@ const injectVaranWallet = (webApp: WebApp, config: InjectionConfig = defaultInje if (!isInTelegram) return; + const callbackUrl = config.callbackUrl || defaultInjectionConfig.callbackUrl; + + if (!callbackUrl) { + throw new Error('Callback URL must be provided to injectVaranWallet'); + } + const wallet = new Wallet(webApp, { ...defaultInjectionConfig, ...config }); window.injectedWeb3 = {