From 55a147d92d6e7355b2df723e9b8f8c5cb6c0b2e3 Mon Sep 17 00:00:00 2001 From: Chaitanya Potti Date: Thu, 25 Jan 2024 15:51:03 +0800 Subject: [PATCH] fix usage of core kit key --- packages/modal/src/default.ts | 13 ++++++++----- packages/modal/src/modalManager.ts | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/modal/src/default.ts b/packages/modal/src/default.ts index eaffb100c..30a23be65 100644 --- a/packages/modal/src/default.ts +++ b/packages/modal/src/default.ts @@ -26,8 +26,9 @@ export const getDefaultAdapterModule = async (params: { sessionTime?: number; web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE; uiConfig?: Omit; + useCoreKitKey?: boolean; }): Promise> => { - const { name, customChainConfig, clientId, sessionTime, web3AuthNetwork, uiConfig } = params; + const { name, customChainConfig, clientId, sessionTime, web3AuthNetwork, uiConfig, useCoreKitKey } = params; if (!Object.values(CHAIN_NAMESPACES).includes(customChainConfig.chainNamespace)) throw new Error(`Invalid chainNamespace: ${customChainConfig.chainNamespace}`); const finalChainConfig = { @@ -36,19 +37,19 @@ export const getDefaultAdapterModule = async (params: { }; if (name === WALLET_ADAPTERS.TORUS_EVM) { const { TorusWalletAdapter } = await import("@web3auth/torus-evm-adapter"); - const adapter = new TorusWalletAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork }); + const adapter = new TorusWalletAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork, useCoreKitKey }); return adapter; } else if (name === WALLET_ADAPTERS.TORUS_SOLANA) { const { SolanaWalletAdapter } = await import("@web3auth/torus-solana-adapter"); - const adapter = new SolanaWalletAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork }); + const adapter = new SolanaWalletAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork, useCoreKitKey }); return adapter; } else if (name === WALLET_ADAPTERS.METAMASK) { const { MetamaskAdapter } = await import("@web3auth/metamask-adapter"); - const adapter = new MetamaskAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork }); + const adapter = new MetamaskAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork, useCoreKitKey }); return adapter; } else if (name === WALLET_ADAPTERS.PHANTOM) { const { PhantomAdapter } = await import("@web3auth/phantom-adapter"); - const adapter = new PhantomAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork }); + const adapter = new PhantomAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork, useCoreKitKey }); return adapter; } else if (name === WALLET_ADAPTERS.WALLET_CONNECT_V2) { const { WalletConnectV2Adapter } = await import("@web3auth/wallet-connect-v2-adapter"); @@ -57,6 +58,7 @@ export const getDefaultAdapterModule = async (params: { clientId, sessionTime, web3AuthNetwork, + useCoreKitKey, adapterSettings: { walletConnectInitOptions: { // Using a default wallet connect project id for web3auth modal integration @@ -74,6 +76,7 @@ export const getDefaultAdapterModule = async (params: { const adapter = new OpenloginAdapter({ ...defaultOptions, clientId, + useCoreKitKey, chainConfig: { ...finalChainConfig }, adapterSettings: { ...(defaultOptions.adapterSettings as OpenLoginOptions), clientId, network: web3AuthNetwork, whiteLabel: uiConfig }, sessionTime, diff --git a/packages/modal/src/modalManager.ts b/packages/modal/src/modalManager.ts index 3d5356933..a124f6d7b 100644 --- a/packages/modal/src/modalManager.ts +++ b/packages/modal/src/modalManager.ts @@ -91,7 +91,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { super.checkInitRequirements(); await this.loginModal.initModal(); const providedChainConfig = this.options.chainConfig; - + // TODO: get stuff from dashboard here // merge default adapters with the custom configured adapters. const allAdapters = [...new Set([...Object.keys(this.modalConfig.adapters || {}), ...Object.keys(this.walletAdapters)])]; @@ -125,6 +125,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { sessionTime: this.options.sessionTime, web3AuthNetwork: this.options.web3AuthNetwork, uiConfig: this.options.uiConfig, + useCoreKitKey: this.coreOptions.useCoreKitKey, }); this.walletAdapters[adapterName] = ad; @@ -137,6 +138,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { clientId: this.options.clientId, sessionTime: this.options.sessionTime, web3AuthNetwork: this.options.web3AuthNetwork, + useCoreKitKey: this.coreOptions.useCoreKitKey, }); // if adapter doesn't have any chainConfig then we will set the chainConfig based of passed chainNamespace