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.
This commit is contained in:
1 parent
06f4b5c82f
commit
267d56cee1
1 file changed
+7
-3
+7
-3
@@ -2,9 +2,7 @@ import type { WebApp, InjectionConfig } from './types';
|
|||||||
import { Wallet } from './wallet';
|
import { Wallet } from './wallet';
|
||||||
|
|
||||||
const defaultInjectionConfig: Required<InjectionConfig> = {
|
const defaultInjectionConfig: Required<InjectionConfig> = {
|
||||||
get callbackUrl(): string {
|
callbackUrl: '',
|
||||||
throw new Error('Callback URL must be provided to injectVaranWallet');
|
|
||||||
},
|
|
||||||
isDev: false,
|
isDev: false,
|
||||||
connectTimeout: 30_000,
|
connectTimeout: 30_000,
|
||||||
storage: {
|
storage: {
|
||||||
@@ -20,6 +18,12 @@ const injectVaranWallet = (webApp: WebApp, config: InjectionConfig = defaultInje
|
|||||||
|
|
||||||
if (!isInTelegram) return;
|
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 });
|
const wallet = new Wallet(webApp, { ...defaultInjectionConfig, ...config });
|
||||||
|
|
||||||
window.injectedWeb3 = {
|
window.injectedWeb3 = {
|
||||||
|
|||||||
Reference in new issue
Block a user