Skip to content

Commit

Permalink
add wallet connect to solana defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Sep 24, 2024
1 parent f26db82 commit 8ba99e0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/adapters/default-solana-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"pre-commit": "lint-staged --cwd ."
},
"dependencies": {
"@web3auth/wallet-connect-v2-adapter": "^9.1.0",
"@solana/wallet-standard-features": "^1.2.0",
"@solana/web3.js": "^1.95.3",
"@wallet-standard/app": "^1.0.1",
Expand Down
26 changes: 24 additions & 2 deletions packages/adapters/default-solana-adapter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import { IAdapter, IWeb3AuthCoreOptions } from "@web3auth/base";
import { CHAIN_NAMESPACES, CustomChainConfig, getChainConfig, IAdapter, IWeb3AuthCoreOptions, WalletInitializationError } from "@web3auth/base";
import { WalletConnectV2Adapter } from "@web3auth/wallet-connect-v2-adapter";

import { getInjectedAdapters } from "./injectedAdapters";

export const getDefaultExternalAdapters = (params: { options: IWeb3AuthCoreOptions }): IAdapter<unknown>[] => {
return getInjectedAdapters(params);
const { options } = params;
const { clientId, chainConfig, sessionTime, web3AuthNetwork, useCoreKitKey } = options;
if (!Object.values(CHAIN_NAMESPACES).includes(chainConfig.chainNamespace))
throw WalletInitializationError.invalidParams(`Invalid chainNamespace: ${chainConfig.chainNamespace}`);
const finalChainConfig = {
...(getChainConfig(chainConfig.chainNamespace, chainConfig?.chainId) as CustomChainConfig),
...(chainConfig || {}),
};

const wcv2Adapter = new WalletConnectV2Adapter({
chainConfig: finalChainConfig,
clientId,
sessionTime,
web3AuthNetwork,
useCoreKitKey,
adapterSettings: {
walletConnectInitOptions: {},
},
});
const injectedProviders = getInjectedAdapters({ options });

return [...injectedProviders, wcv2Adapter];
};

export { getInjectedAdapters };

0 comments on commit 8ba99e0

Please sign in to comment.