Skip to content

Commit

Permalink
fix usage of core kit key
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jan 25, 2024
1 parent 9a736ce commit 55a147d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 8 additions & 5 deletions packages/modal/src/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export const getDefaultAdapterModule = async (params: {
sessionTime?: number;
web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE;
uiConfig?: Omit<UIConfig, "adapterListener">;
useCoreKitKey?: boolean;
}): Promise<IAdapter<unknown>> => {
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 = {
Expand All @@ -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");
Expand All @@ -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
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion packages/modal/src/modalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)])];

Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 55a147d

Please sign in to comment.