@sodax/wallet-sdk-react 2.0.0-rc.3 → 2.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/dist/{chunk-BKJB527E.mjs → chunk-3QETHO6P.mjs} +1 -3
- package/dist/{chunk-PJLEJVAU.mjs → chunk-42LTUHMZ.mjs} +1 -3
- package/dist/{chunk-NY7U7OJW.mjs → chunk-7V7O3Q7Y.mjs} +0 -2
- package/dist/{chunk-BXJLBR4G.mjs → chunk-C6M34IVL.mjs} +2 -4
- package/dist/{chunk-XZ7CHO2S.mjs → chunk-FSOGMSJH.mjs} +2 -4
- package/dist/{chunk-X2MHIWXO.mjs → chunk-IFXZQW4C.mjs} +0 -2
- package/dist/{chunk-7ULB6DW4.mjs → chunk-JQ4H4GJ5.mjs} +3 -5
- package/dist/{chunk-N5A2TMF6.mjs → chunk-LKSSME2J.mjs} +2 -4
- package/dist/{chunk-PLCA4ZDJ.mjs → chunk-LUKR7YKV.mjs} +54 -30
- package/dist/{chunk-MXZVF5HR.mjs → chunk-NAKCAL2M.mjs} +0 -2
- package/dist/chunk-QMXBY3UI.mjs +1 -0
- package/dist/{chunk-MAQ47Q52.mjs → chunk-TACW7Z4D.mjs} +0 -2
- package/dist/{chunk-2BOUGCJ7.mjs → chunk-WPZOLGVB.mjs} +4 -6
- package/dist/{chunk-66BAUK56.mjs → chunk-X7BHR7WS.mjs} +2 -4
- package/dist/{chunk-E5IAZ7E6.mjs → chunk-Z5GXDHGL.mjs} +9 -5
- package/dist/{config-OlnzyEUE.d.ts → config-GVKK8IfY.d.ts} +6 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +20 -31
- package/dist/xchains/bitcoin/index.mjs +14 -16
- package/dist/xchains/evm/index.d.ts +1 -1
- package/dist/xchains/evm/index.mjs +3 -5
- package/dist/xchains/icon/index.mjs +5 -7
- package/dist/xchains/injective/index.mjs +3 -5
- package/dist/xchains/near/index.mjs +4 -6
- package/dist/xchains/solana/index.mjs +5 -7
- package/dist/xchains/stacks/index.mjs +3 -5
- package/dist/xchains/stellar/index.mjs +4 -6
- package/dist/xchains/sui/index.mjs +5 -7
- package/docs/ADDING_A_NEW_CHAIN.md +1 -1
- package/docs/SUB_PATH_EXPORTS.md +14 -42
- package/package.json +32 -24
- package/ai-exported/AGENTS.md +0 -122
- package/ai-exported/integration/README.md +0 -102
- package/ai-exported/integration/ai-rules.md +0 -136
- package/ai-exported/integration/architecture.md +0 -181
- package/ai-exported/integration/examples/01-minimal-evm.tsx +0 -75
- package/ai-exported/integration/examples/02-multi-chain-modal.tsx +0 -169
- package/ai-exported/integration/examples/03-nextjs-app-router.tsx +0 -99
- package/ai-exported/integration/examples/04-walletconnect-setup.tsx +0 -89
- package/ai-exported/integration/examples/README.md +0 -29
- package/ai-exported/integration/recipes/batch-operations.md +0 -223
- package/ai-exported/integration/recipes/bridge-to-sdk.md +0 -164
- package/ai-exported/integration/recipes/chain-detection.md +0 -254
- package/ai-exported/integration/recipes/connect-button.md +0 -156
- package/ai-exported/integration/recipes/multi-chain-modal.md +0 -199
- package/ai-exported/integration/recipes/setup.md +0 -160
- package/ai-exported/integration/recipes/sign-message.md +0 -137
- package/ai-exported/integration/recipes/sub-path-imports.md +0 -95
- package/ai-exported/integration/recipes/switch-chain.md +0 -141
- package/ai-exported/integration/recipes/walletconnect-setup.md +0 -139
- package/ai-exported/integration/reference/api-surface.md +0 -175
- package/ai-exported/integration/reference/chain-support.md +0 -78
- package/ai-exported/integration/reference/connectors.md +0 -74
- package/ai-exported/integration/reference/hooks.md +0 -204
- package/ai-exported/integration/reference/wallet-brands.md +0 -106
- package/ai-exported/migration/README.md +0 -49
- package/ai-exported/migration/ai-rules.md +0 -144
- package/ai-exported/migration/breaking-changes.md +0 -305
- package/ai-exported/migration/checklist.md +0 -159
- package/ai-exported/migration/recipes/connect-button.md +0 -166
- package/ai-exported/migration/recipes/multi-chain-modal.md +0 -244
- package/ai-exported/migration/recipes/ssr-setup.md +0 -164
- package/ai-exported/migration/recipes/walletconnect-migration.md +0 -168
- package/ai-exported/migration/reference/components.md +0 -73
- package/ai-exported/migration/reference/config.md +0 -325
- package/ai-exported/migration/reference/hooks.md +0 -323
- package/ai-exported/migration/reference/imports.md +0 -157
- package/dist/chunk-2BOUGCJ7.mjs.map +0 -1
- package/dist/chunk-66BAUK56.mjs.map +0 -1
- package/dist/chunk-7ULB6DW4.mjs.map +0 -1
- package/dist/chunk-BKJB527E.mjs.map +0 -1
- package/dist/chunk-BXJLBR4G.mjs.map +0 -1
- package/dist/chunk-E5IAZ7E6.mjs.map +0 -1
- package/dist/chunk-MAQ47Q52.mjs.map +0 -1
- package/dist/chunk-MXZVF5HR.mjs.map +0 -1
- package/dist/chunk-N5A2TMF6.mjs.map +0 -1
- package/dist/chunk-NY7U7OJW.mjs.map +0 -1
- package/dist/chunk-PJLEJVAU.mjs.map +0 -1
- package/dist/chunk-PLCA4ZDJ.mjs.map +0 -1
- package/dist/chunk-TZMKDXFA.mjs +0 -3
- package/dist/chunk-TZMKDXFA.mjs.map +0 -1
- package/dist/chunk-X2MHIWXO.mjs.map +0 -1
- package/dist/chunk-XZ7CHO2S.mjs.map +0 -1
- package/dist/index.cjs +0 -3337
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/xchains/bitcoin/index.cjs +0 -1927
- package/dist/xchains/bitcoin/index.cjs.map +0 -1
- package/dist/xchains/bitcoin/index.mjs.map +0 -1
- package/dist/xchains/evm/index.cjs +0 -316
- package/dist/xchains/evm/index.cjs.map +0 -1
- package/dist/xchains/evm/index.mjs.map +0 -1
- package/dist/xchains/icon/index.cjs +0 -311
- package/dist/xchains/icon/index.cjs.map +0 -1
- package/dist/xchains/icon/index.mjs.map +0 -1
- package/dist/xchains/injective/index.cjs +0 -223
- package/dist/xchains/injective/index.cjs.map +0 -1
- package/dist/xchains/injective/index.mjs.map +0 -1
- package/dist/xchains/near/index.cjs +0 -190
- package/dist/xchains/near/index.cjs.map +0 -1
- package/dist/xchains/near/index.mjs.map +0 -1
- package/dist/xchains/solana/index.cjs +0 -186
- package/dist/xchains/solana/index.cjs.map +0 -1
- package/dist/xchains/solana/index.mjs.map +0 -1
- package/dist/xchains/stacks/index.cjs +0 -240
- package/dist/xchains/stacks/index.cjs.map +0 -1
- package/dist/xchains/stacks/index.mjs.map +0 -1
- package/dist/xchains/stellar/index.cjs +0 -322
- package/dist/xchains/stellar/index.cjs.map +0 -1
- package/dist/xchains/stellar/index.mjs.map +0 -1
- package/dist/xchains/sui/index.cjs +0 -248
- package/dist/xchains/sui/index.cjs.map +0 -1
- package/dist/xchains/sui/index.mjs.map +0 -1
- package/skills/SKILLS.md +0 -84
- package/skills/bridge-to-sdk.md +0 -148
- package/skills/connect-button.md +0 -116
- package/skills/evm-only-walletconnect.md +0 -111
- package/skills/multi-chain-modal.md +0 -178
- package/skills/setup.md +0 -107
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/XService.ts","../../../src/utils/index.ts","../../../src/shared/guards.ts","../../../src/xchains/sui/SuiXService.ts","../../../src/core/XConnector.ts","../../../src/xchains/sui/SuiXConnector.ts"],"names":["address","SuiWalletProvider"],"mappings":";;;;;;AAoBO,IAAe,WAAf,MAAiD;AAAA;AAAA,EAEtC,UAAA;AAAA;AAAA,EAGR,cAA6B,EAAC;AAAA,EAEtC,YAAY,UAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAa,UAAA,CAAW,OAAA,EAA6B,MAAA,EAAiC;AACpF,IAAA,OAAO,EAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAa,WAAA,CAAY,OAAA,EAA6B,OAAA,EAA6D;AACjH,IAAA,IAAI,CAAC,OAAA,EAAS,OAAO,EAAC;AAEtB,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IAAA,KAAA,CAAM,KAAA,EAAO,MAAA,CAAO,IAAA,EAAM,EAAE,CAAA;AAC5B,IAAA,IAAA,CAAK,MAAA,GAAS,EAAE,EAAA,EAAI,IAAA,EAAM,OAAO,IAAA,EAAM,IAAA,EAAM,OAAO,IAAA,EAAK;AAAA,EAC3D;AAAA,EAEA,WAAA,GAA2B;AACzB,IAAA,OAAO,YAAY,WAAA,EAAY;AAAA,EACjC;AAAA,EAEA,MAAM,OAAA,GAAyC;AAC7C,IAAA;AAAA,EACF;AAAA,EAEA,MAAM,UAAA,GAA4B;AAAA,EAAC;AAAA,EAEnC,IAAoB,IAAA,GAA2B;AAC7C,IAAA,OAAO,KAAK,MAAA,CAAO,IAAA;AAAA,EACrB;AACF","file":"index.cjs","sourcesContent":["import type { ChainType, IXServiceBase, XToken } from '@sodax/types';\nimport type { IXConnector } from '@/types/interfaces.js';\n\n/**\n * Abstract base class for blockchain service implementations.\n *\n * The XService class serves as a foundation for implementing blockchain-specific services\n * in a multi-chain environment. It provides a standardized interface for:\n * 1. Managing wallet connectors for different blockchain types\n * 2. Querying token balances across different chains\n *\n * Each blockchain implementation (e.g., Solana, EVM chains) extends this class\n * to provide chain-specific functionality while maintaining a consistent interface.\n *\n * @abstract\n * @class XService\n * @property {ChainType} xChainType - The blockchain type this service handles (e.g., 'SOLANA', 'EVM')\n * @property {XConnector[]} xConnectors - Available wallet connectors for this chain\n *\n */\nexport abstract class XService implements IXServiceBase {\n /** The blockchain type this service handles */\n public readonly xChainType: ChainType;\n\n /** Available wallet connectors for this chain */\n private xConnectors: IXConnector[] = [];\n\n constructor(xChainType: ChainType) {\n this.xChainType = xChainType;\n }\n\n /**\n * Gets the balance of a specific token for an address\n * @param address The wallet address to check\n * @param xToken The token to get the balance for\n * @returns Promise resolving to the token balance as a bigint\n */\n public async getBalance(address: string | undefined, xToken: XToken): Promise<bigint> {\n return 0n;\n }\n\n /**\n * Gets balances for multiple tokens for an address\n * @param address The wallet address to check\n * @param xTokens Array of tokens to get balances for\n * @returns Promise resolving to object mapping token addresses to balances\n */\n public async getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>> {\n if (!address) return {};\n\n const balancePromises = xTokens.map(async xToken => {\n const balance = await this.getBalance(address, xToken);\n return { address: xToken.address, balance };\n });\n\n const balances = await Promise.all(balancePromises);\n return balances.reduce<Record<string, bigint>>((acc, { address, balance }) => {\n acc[address] = balance;\n return acc;\n }, {});\n }\n\n /**\n * Gets all available connectors for this chain\n */\n public getXConnectors(): IXConnector[] {\n return this.xConnectors;\n }\n\n /**\n * Sets the available connectors for this chain\n */\n public setXConnectors(xConnectors: IXConnector[]): void {\n this.xConnectors = xConnectors;\n }\n\n /**\n * Gets a specific connector by its ID\n * @param xConnectorId The connector ID to look up\n * @returns The matching connector or undefined if not found\n */\n public getXConnectorById(xConnectorId: string): IXConnector | undefined {\n return this.getXConnectors().find(xConnector => xConnector.id === xConnectorId);\n }\n}\n","import { baseChainInfo, type SpokeChainKey, type XToken } from '@sodax/types';\n\nexport { sortConnectors, type SortConnectorsOptions } from './sortConnectors.js';\nexport {\n getEntryDefaults,\n getRpcUrl,\n resolveEvmDefaults,\n type WalletDefaultsByKey,\n} from './walletRpcConfig.js';\n\nexport const isNativeToken = (xToken: XToken): boolean => {\n const nativeAddresses = [\n 'cx0000000000000000000000000000000000000000',\n '0x0000000000000000000000000000000000000000',\n 'inj',\n '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI',\n 'hx0000000000000000000000000000000000000000',\n '11111111111111111111111111111111', // solana\n 'CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA', // stellar\n 'ST000000000000000000002AMW42H.nativetoken', // stacks\n '0:0', // bitcoin\n ];\n\n return nativeAddresses.includes(xToken.address);\n};\n\nexport const getWagmiChainId = (xChainId: SpokeChainKey): number => {\n const chainId = baseChainInfo[xChainId].chainId;\n if (typeof chainId !== 'number') {\n throw new Error(`[wallet-sdk-react] getWagmiChainId: expected numeric chainId, got ${typeof chainId}`);\n }\n return chainId;\n};\n","// packages/wallet-sdk-react/src/shared/guards.ts\n\n/**\n * Tiny runtime type guards used to safely narrow `unknown` values.\n *\n * Why this exists:\n * - In wallets land, many values come from outside TypeScript (window injections, 3rd-party SDKs, serialized state).\n * - Writing `as SomeType` skips checks and can crash later in confusing places.\n * - Guards + `assert(...)` let us fail fast with a clear error message at the boundary.\n */\n\nexport type UnknownRecord = Record<string, unknown>;\n\n/** True if value is a non-null object (Record-like). */\nexport function isRecord(value: unknown): value is UnknownRecord {\n return typeof value === 'object' && value !== null;\n}\n\n/** True if the object has a string property at `key`. */\nexport function hasStringProperty<Key extends string>(\n value: unknown,\n key: Key,\n): value is UnknownRecord & Record<Key, string> {\n return isRecord(value) && typeof value[key] === 'string';\n}\n\n/** True if the object has an optional string property at `key`. */\nexport function hasOptionalStringProperty<Key extends string>(\n value: unknown,\n key: Key,\n): value is UnknownRecord & Partial<Record<Key, string>> {\n return isRecord(value) && (value[key] === undefined || typeof value[key] === 'string');\n}\n\n/** True if the object has a boolean property at `key`. */\nexport function hasBooleanProperty<Key extends string>(\n value: unknown,\n key: Key,\n): value is UnknownRecord & Record<Key, boolean> {\n return isRecord(value) && typeof value[key] === 'boolean';\n}\n\n/** True if the object has a function property at `key`. */\nexport function hasFunctionProperty<Key extends string>(\n value: unknown,\n key: Key,\n): value is UnknownRecord & Record<Key, (...args: unknown[]) => unknown> {\n return isRecord(value) && typeof value[key] === 'function';\n}\n\n/**\n * Throws if condition is false.\n * Use this after guards to stop execution early with an actionable error message.\n */\nexport function assert(condition: unknown, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n\n/**\n * Validates the runtime shape of Sui provider dependencies before passing them to wallet-sdk-core.\n * Used by both SuiHydrator (render path) and SuiXService.createWalletProvider (imperative path).\n */\nexport function assertSuiProviderShape(caller: string, client: unknown, wallet: unknown, account: unknown): void {\n const clientOk =\n isRecord(client) &&\n hasFunctionProperty(client, 'executeTransactionBlock') &&\n hasFunctionProperty(client, 'devInspectTransactionBlock') &&\n hasFunctionProperty(client, 'getCoins');\n assert(clientOk, `[${caller}] invalid Sui client shape`);\n\n const walletOk = isRecord(wallet) && hasStringProperty(wallet, 'name');\n assert(walletOk, `[${caller}] invalid Sui wallet shape`);\n\n const accountOk = isRecord(account) && hasStringProperty(account, 'address');\n assert(accountOk, `[${caller}] invalid Sui account shape`);\n}\n","import { XService } from '@/core/XService.js';\nimport type { XToken, ISuiWalletProvider } from '@sodax/types';\nimport { SuiWalletProvider } from '@sodax/wallet-sdk-core';\nimport { isNativeToken } from '@/utils/index.js';\nimport { assertSuiProviderShape } from '@/shared/guards.js';\n\n// These fields are hydrated by SuiHydrator from @mysten/dapp-kit hooks.\n// We use structural interfaces instead of importing nominal types from @mysten/wallet-standard\n// because dapp-kit may resolve a different version than wallet-sdk-core, causing nominal mismatch.\n// The `getBalance` method is the only field we call directly — the rest are passed through.\ninterface SuiClientLike {\n getBalance(input: { owner: string; coinType: string }): Promise<{ totalBalance: string }>;\n}\n\nexport class SuiXService extends XService {\n private static instance: SuiXService;\n\n // Hydrated by SuiHydrator. Start undefined because wallet may not be connected yet.\n // suiClient is typed structurally for the methods we call directly.\n // suiWallet/suiAccount are opaque — stored and passed through to SuiWalletProvider.\n public suiClient: SuiClientLike | undefined;\n public suiWallet: unknown;\n public suiAccount: unknown;\n\n private constructor() {\n super('SUI');\n }\n\n public static getInstance(): SuiXService {\n if (!SuiXService.instance) {\n SuiXService.instance = new SuiXService();\n }\n return SuiXService.instance;\n }\n\n createWalletProvider(): ISuiWalletProvider | undefined {\n if (!this.suiClient || !this.suiWallet || !this.suiAccount) {\n console.warn(\n '[SuiXService] createWalletProvider: missing dependencies — wallet not connected yet',\n { hasClient: !!this.suiClient, hasWallet: !!this.suiWallet, hasAccount: !!this.suiAccount },\n );\n return undefined;\n }\n\n // Runtime validation before passing data to wallet-sdk-core. This avoids \"trust me bro\" casting.\n // Note: we validate the minimum shape we rely on; the exact nominal types may differ by package version.\n assertSuiProviderShape('SuiXService', this.suiClient, this.suiWallet, this.suiAccount);\n\n // Version mismatch cast: dapp-kit hooks return types from their bundled @mysten/wallet-standard,\n // which differs nominally from wallet-sdk-core's version. Structurally identical at runtime.\n type SuiWalletProviderConfig = ConstructorParameters<typeof SuiWalletProvider>[0];\n return new SuiWalletProvider({\n client: this.suiClient,\n wallet: this.suiWallet,\n account: this.suiAccount,\n } as unknown as SuiWalletProviderConfig);\n }\n\n // getBalance is not used because getBalances uses getAllBalances which returns all balances\n\n override async getBalances(address: string | undefined, xTokens: readonly XToken[]): Promise<Record<string, bigint>> {\n if (!address || !this.suiClient) return {};\n // Capture in local so the closure sees a narrowed (non-undefined) reference.\n const client = this.suiClient;\n try {\n const balancePromises = xTokens.map(async xToken => {\n let coinType = isNativeToken(xToken) ? '0x2::sui::SUI' : xToken.address;\n\n // TODO: hard coded for getting legacy bnUSD balance\n if (\n coinType ===\n '0x03917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR'\n ) {\n coinType =\n '0x3917a812fe4a6d6bc779c5ab53f8a80ba741f8af04121193fc44e0f662e2ceb::balanced_dollar::BALANCED_DOLLAR';\n }\n\n const balance = await client.getBalance({\n owner: address,\n coinType: coinType,\n });\n\n return {\n address: xToken.address,\n balance: balance ? BigInt(balance.totalBalance) : undefined,\n };\n });\n\n const results = await Promise.all(balancePromises);\n\n const tokenMap: Record<string, bigint> = {};\n results.forEach(result => {\n if (result.balance !== undefined) {\n tokenMap[result.address] = result.balance;\n }\n });\n\n return tokenMap;\n } catch (error) {\n console.error('[wallet-sdk-react] SUI getBalances failed:', error);\n return {};\n }\n }\n}\n","import type { ChainType } from '@sodax/types';\nimport type { XAccount } from '@/types/index.js';\nimport type { IXConnector } from '@/types/interfaces.js';\n\n/**\n * Base class for wallet provider connectors that handles connection management and wallet interactions\n *\n * @abstract\n * @class XConnector\n * @property {ChainType} xChainType - The blockchain type this connector supports\n * @property {string} name - Display name of the wallet provider\n * @property {string} _id - Unique identifier for the connector\n * @property {string | undefined} _icon - Optional icon URL for the wallet provider\n */\n\nexport abstract class XConnector implements IXConnector {\n /** The blockchain type this connector supports */\n public readonly xChainType: ChainType;\n\n /** Display name of the wallet provider */\n public readonly name: string;\n\n /** Unique identifier for the connector */\n public readonly _id: string;\n\n /** Optional icon URL for the wallet provider */\n public readonly _icon?: string;\n\n constructor(xChainType: ChainType, name: string, id: string) {\n this.xChainType = xChainType;\n this.name = name;\n this._id = id;\n }\n\n /**\n * Connects to the wallet provider\n * @returns Promise resolving to the connected account, or undefined if connection fails\n */\n abstract connect(): Promise<XAccount | undefined>;\n\n /**\n * Disconnects from the wallet provider\n */\n abstract disconnect(): Promise<void>;\n\n /** Get the unique identifier for this connector */\n public get id(): string {\n return this._id;\n }\n\n /** Get the optional icon URL for this wallet provider */\n public get icon(): string | undefined {\n return this._icon;\n }\n\n /**\n * True when the wallet extension backing this connector is installed.\n * Default: true (for provider-managed chains where connector presence already\n * implies install — EVM via EIP-6963, Solana/Sui via adapter discovery).\n * Subclasses backed by extension injection (Bitcoin, ICON, Stacks) override\n * this with a window probe.\n */\n public get isInstalled(): boolean {\n return true;\n }\n\n /** URL to install the wallet extension when missing. Subclasses override. */\n public get installUrl(): string | undefined {\n return undefined;\n }\n}\n","import type { XAccount } from '@/types/index.js';\n\nimport { XConnector } from '@/core/index.js';\nimport { SuiXService } from './SuiXService.js';\nimport { assert, hasOptionalStringProperty, hasStringProperty, isRecord } from '@/shared/guards.js';\n\n// Structural interface for what we actually use from a Sui wallet.\n// We don't import the nominal type from @mysten/wallet-standard because\n// @mysten/dapp-kit may resolve a different version, causing nominal mismatch.\n// Structural typing avoids this: as long as the object has these fields, it works.\ninterface SuiWalletInfo {\n id?: string;\n name: string;\n icon?: string;\n}\n\nconst isSuiWalletInfo = (value: unknown): value is SuiWalletInfo => {\n return (\n isRecord(value) &&\n hasStringProperty(value, 'name') &&\n // Some wallets may not expose `id` — in that case we fall back to `name` for stability.\n // We still validate if it exists.\n hasOptionalStringProperty(value, 'id') &&\n hasOptionalStringProperty(value, 'icon')\n );\n};\n\nexport class SuiXConnector extends XConnector {\n public readonly wallet: SuiWalletInfo;\n\n constructor(wallet: unknown) {\n assert(isSuiWalletInfo(wallet), '[SuiXConnector] invalid wallet object');\n\n const id = wallet.id ?? wallet.name;\n // After the fallback, `id` is always defined.\n assert(typeof id === 'string' && id.length > 0, '[SuiXConnector] invalid wallet id');\n\n super('SUI', wallet.name, id);\n this.wallet = { id, name: wallet.name, icon: wallet.icon };\n }\n\n getXService(): SuiXService {\n return SuiXService.getInstance();\n }\n\n async connect(): Promise<XAccount | undefined> {\n return;\n }\n\n async disconnect(): Promise<void> {}\n\n public override get icon(): string | undefined {\n return this.wallet.icon;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
package/skills/SKILLS.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# @sodax/wallet-sdk-react Skills
|
|
2
|
-
|
|
3
|
-
Scaffolding guides that let you wire SODAX wallet connectivity into a React app in one prompt. Built for and tested with [Claude Code](https://docs.anthropic.com/en/docs/claude-code) — point it at a skill file and it generates the correct providers, hooks, and types.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
Skills ship with the npm package. After installing `@sodax/wallet-sdk-react`:
|
|
8
|
-
|
|
9
|
-
**1. Set up providers** (do this first)
|
|
10
|
-
|
|
11
|
-
> Read `node_modules/@sodax/wallet-sdk-react/skills/setup.md` and wire `SodaxWalletProvider` into my app.
|
|
12
|
-
|
|
13
|
-
**2. Pick a connect UX**
|
|
14
|
-
|
|
15
|
-
> Read `node_modules/@sodax/wallet-sdk-react/skills/connect-button.md` and add a single-chain connect button.
|
|
16
|
-
|
|
17
|
-
> Read `node_modules/@sodax/wallet-sdk-react/skills/multi-chain-modal.md` and add a multi-chain wallet modal.
|
|
18
|
-
|
|
19
|
-
**3. Add advanced features as needed**
|
|
20
|
-
|
|
21
|
-
> Read `node_modules/@sodax/wallet-sdk-react/skills/evm-only-walletconnect.md` and enable WalletConnect for enterprise custody (Fireblocks, etc.).
|
|
22
|
-
|
|
23
|
-
> Read `node_modules/@sodax/wallet-sdk-react/skills/bridge-to-sdk.md` and pass the connected wallet provider to a `@sodax/sdk` swap call.
|
|
24
|
-
|
|
25
|
-
The pattern is always: `Read node_modules/@sodax/wallet-sdk-react/skills/<skill>.md` + what you want to build.
|
|
26
|
-
|
|
27
|
-
### Tips
|
|
28
|
-
|
|
29
|
-
- One skill per prompt gets better results than asking for everything at once.
|
|
30
|
-
- Always do setup before any other skill.
|
|
31
|
-
- Pair `connect-button.md` (one chain at a time) OR `multi-chain-modal.md` (chain picker + connector picker) — they're alternatives, not additive.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
*Internal devs working in this monorepo: use `skills/<skill>.md` instead of the `node_modules` path, and reference sibling docs in `docs/` for the underlying API.*
|
|
36
|
-
|
|
37
|
-
## Dependency Graph
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
setup
|
|
41
|
-
├── connect-button (single-chain connect/disconnect)
|
|
42
|
-
├── multi-chain-modal (modal-driven multi-chain UX)
|
|
43
|
-
├── evm-only-walletconnect (Fireblocks / custody opt-in)
|
|
44
|
-
└── bridge-to-sdk (pass walletProvider to @sodax/sdk calls)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Skill Index
|
|
48
|
-
|
|
49
|
-
| Skill | File | Description | Depends On |
|
|
50
|
-
|-------|------|-------------|------------|
|
|
51
|
-
| Setup | [setup.md](setup.md) | Install + wire `SodaxWalletProvider` with chain-type slots | None |
|
|
52
|
-
| Connect Button | [connect-button.md](connect-button.md) | `useXConnectors` + `useXConnect` + `useXDisconnect` for one chain | `setup` |
|
|
53
|
-
| Multi-chain Modal | [multi-chain-modal.md](multi-chain-modal.md) | `useWalletModal` headless state machine + `useChainGroups` | `setup` |
|
|
54
|
-
| EVM-only WalletConnect | [evm-only-walletconnect.md](evm-only-walletconnect.md) | Enable WalletConnect for Fireblocks / Ledger / mobile-only wallets | `setup` |
|
|
55
|
-
| Bridge to SDK | [bridge-to-sdk.md](bridge-to-sdk.md) | `useWalletProvider` → typed `IXxxWalletProvider` for `@sodax/sdk` calls | `setup`, one of `connect-button` / `multi-chain-modal` |
|
|
56
|
-
|
|
57
|
-
## Conventions
|
|
58
|
-
|
|
59
|
-
### Single object parameter
|
|
60
|
-
|
|
61
|
-
Every hook in `@sodax/wallet-sdk-react` accepts one options object:
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
useXConnectors({ xChainType: 'EVM' });
|
|
65
|
-
useXAccount({ xChainId: ChainKeys.BSC_MAINNET });
|
|
66
|
-
useWalletProvider({ xChainType: 'EVM' });
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
`useXAccount` / `useWalletProvider` accept either `xChainId` (chain key) **or** `xChainType` (family) — never both.
|
|
70
|
-
|
|
71
|
-
### Mutation pattern (`useXConnect`)
|
|
72
|
-
|
|
73
|
-
`useXConnect` is a React Query mutation. Pass an `IXConnector` to `mutate` / `mutateAsync`:
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
const { mutateAsync: connect } = useXConnect();
|
|
77
|
-
await connect(connector);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
For provider-managed chains (EVM/Solana/Sui), the resolved value is `undefined` — read the connected account via `useXAccount` after the mutation lands. See [Connect Flow caveat](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECT_FLOW.md#provider-managed-chains-caveat).
|
|
81
|
-
|
|
82
|
-
### Persisted connections
|
|
83
|
-
|
|
84
|
-
Connections survive page reloads via `localStorage` (key `xwagmi-store`). Gate UI on hydration to avoid flicker — `useConnectedChains().status === 'ready'` is the official signal.
|
package/skills/bridge-to-sdk.md
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# Skill: Bridge to SDK
|
|
2
|
-
|
|
3
|
-
Pass the user's connected wallet to `@sodax/sdk` calls — `useWalletProvider` returns a typed `IXxxWalletProvider` ready to plug into any SDK method.
|
|
4
|
-
|
|
5
|
-
**Depends on:** [setup.md](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/skills/setup.md), one of [connect-button.md](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/skills/connect-button.md) / [multi-chain-modal.md](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/skills/multi-chain-modal.md)
|
|
6
|
-
|
|
7
|
-
## Hooks
|
|
8
|
-
|
|
9
|
-
| Hook | Purpose |
|
|
10
|
-
|------|---------|
|
|
11
|
-
| `useWalletProvider({ xChainId })` | Typed `IXxxWalletProvider` (chain-narrowed by chain id) |
|
|
12
|
-
| `useWalletProvider({ xChainType })` | Family-level provider (same shape for every chain id in family) |
|
|
13
|
-
| `useXAccount({ xChainId })` | Read connected address |
|
|
14
|
-
| `useXService({ xChainType })` | Lower-level — chain `XService` instance for advanced reads |
|
|
15
|
-
|
|
16
|
-
Pass either `xChainId` (a `SpokeChainKey`) or `xChainType` (a `ChainType`), never both.
|
|
17
|
-
|
|
18
|
-
## Pattern — drive an SDK swap from a connected wallet
|
|
19
|
-
|
|
20
|
-
```tsx
|
|
21
|
-
import { useWalletProvider, useXAccount } from '@sodax/wallet-sdk-react';
|
|
22
|
-
import { Sodax, ChainKeys } from '@sodax/sdk';
|
|
23
|
-
import type { CreateIntentParams } from '@sodax/sdk';
|
|
24
|
-
|
|
25
|
-
const sodax = new Sodax(); // or hold one in context / pass via @sodax/dapp-kit
|
|
26
|
-
|
|
27
|
-
export function SwapButton({ params }: { params: CreateIntentParams<typeof ChainKeys.BSC_MAINNET> }) {
|
|
28
|
-
const walletProvider = useWalletProvider({ xChainId: ChainKeys.BSC_MAINNET });
|
|
29
|
-
const account = useXAccount({ xChainId: ChainKeys.BSC_MAINNET });
|
|
30
|
-
|
|
31
|
-
const handleSwap = async () => {
|
|
32
|
-
if (!walletProvider) return;
|
|
33
|
-
const result = await sodax.swaps.swap({
|
|
34
|
-
params,
|
|
35
|
-
walletProvider, // typed as IEvmWalletProvider — must match BSC src chain
|
|
36
|
-
});
|
|
37
|
-
if (!result.ok) {
|
|
38
|
-
console.error('swap failed:', result.error);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
console.log('swap submitted:', result.value);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<button onClick={handleSwap} disabled={!walletProvider || !account.address}>
|
|
46
|
-
Swap
|
|
47
|
-
</button>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
The pattern works for every SDK feature service:
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
sodax.swaps.swap({ params, walletProvider });
|
|
56
|
-
sodax.bridge.bridge({ params, walletProvider });
|
|
57
|
-
sodax.moneyMarket.supply({ params, walletProvider });
|
|
58
|
-
sodax.staking.stake({ params, walletProvider });
|
|
59
|
-
sodax.dex.deposit({ params, walletProvider });
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
See [`packages/sdk/docs/`](https://github.com/icon-project/sodax-sdks/blob/main/packages/sdk/docs/) for per-feature method signatures.
|
|
63
|
-
|
|
64
|
-
## TypeScript narrowing
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
import { useWalletProvider } from '@sodax/wallet-sdk-react';
|
|
68
|
-
import { ChainKeys } from '@sodax/types';
|
|
69
|
-
|
|
70
|
-
// By chain id — narrowest typing
|
|
71
|
-
const evm = useWalletProvider({ xChainId: ChainKeys.BSC_MAINNET });
|
|
72
|
-
// evm: IEvmWalletProvider | undefined
|
|
73
|
-
|
|
74
|
-
const sol = useWalletProvider({ xChainId: ChainKeys.SOLANA_MAINNET });
|
|
75
|
-
// sol: ISolanaWalletProvider | undefined
|
|
76
|
-
|
|
77
|
-
// By chain type — family-level (one wagmi connection covers all EVM chains)
|
|
78
|
-
const evmFamily = useWalletProvider({ xChainType: 'EVM' });
|
|
79
|
-
// evmFamily: IEvmWalletProvider | undefined
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
The chain-narrowing is automatic — passing the wrong wallet provider type to an SDK call (e.g. `ISolanaWalletProvider` to a `srcChainKey: BSC_MAINNET` swap) is a **compile error**.
|
|
83
|
-
|
|
84
|
-
## EVM — single connection across all networks
|
|
85
|
-
|
|
86
|
-
`useWalletProvider({ xChainId: ChainKeys.BSC_MAINNET })` and `useWalletProvider({ xChainId: ChainKeys.ARBITRUM_MAINNET })` return the **same** `EvmWalletProvider` instance — wagmi maintains one connection across all configured EVM networks. To switch the **active** EVM network, see [`useEvmSwitchChain`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/EVM_SWITCH_CHAIN.md):
|
|
87
|
-
|
|
88
|
-
```tsx
|
|
89
|
-
import { useEvmSwitchChain } from '@sodax/wallet-sdk-react';
|
|
90
|
-
|
|
91
|
-
const { isWrongChain, handleSwitchChain } = useEvmSwitchChain({
|
|
92
|
-
xChainId: ChainKeys.BSC_MAINNET,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
if (isWrongChain) {
|
|
96
|
-
return <button onClick={handleSwitchChain}>Switch to BSC</button>;
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Disabled chains return `undefined`
|
|
101
|
-
|
|
102
|
-
If `xChainType` resolves to a chain not enabled in `SodaxWalletProvider` config, `useWalletProvider` returns `undefined` and logs a one-time warning:
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
[useWalletProvider] chain "BITCOIN" is not enabled in SodaxWalletProvider config.chains — returning undefined
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Always null-check before passing to an SDK call.
|
|
109
|
-
|
|
110
|
-
## Raw transactions — skip the bridge
|
|
111
|
-
|
|
112
|
-
If you only need unsigned transaction data (manual relay, gas estimation, external signing), pass `raw: true` to the SDK and skip `walletProvider`:
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
const result = await sodax.swaps.createIntent({
|
|
116
|
-
params,
|
|
117
|
-
raw: true, // walletProvider must be absent — compile error if passed
|
|
118
|
-
});
|
|
119
|
-
// result.value.tx is an EvmRawTransaction
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
See [`packages/sdk/docs/SWAPS.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/sdk/docs/SWAPS.md) for the full raw-vs-signed matrix per method.
|
|
123
|
-
|
|
124
|
-
## Server / scripts — use `@sodax/wallet-sdk-core` directly
|
|
125
|
-
|
|
126
|
-
For Node.js scripts / bots, skip wallet-sdk-react entirely:
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
import { Sodax } from '@sodax/sdk';
|
|
130
|
-
import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
|
|
131
|
-
import { ChainKeys } from '@sodax/types';
|
|
132
|
-
|
|
133
|
-
const sodax = new Sodax();
|
|
134
|
-
const walletProvider = new EvmWalletProvider({
|
|
135
|
-
privateKey: process.env.PRIVATE_KEY!,
|
|
136
|
-
chainId: ChainKeys.BSC_MAINNET,
|
|
137
|
-
rpcUrl: 'https://bsc-dataseed.binance.org',
|
|
138
|
-
});
|
|
139
|
-
const result = await sodax.swaps.swap({ params, walletProvider });
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Reference docs
|
|
143
|
-
|
|
144
|
-
- [Wallet Provider Bridge](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/WALLET_PROVIDER_BRIDGE.md) — `useWalletProvider` + `useXService` reference
|
|
145
|
-
- [SDK Wallet Providers Reference](https://github.com/icon-project/sodax-sdks/blob/main/packages/sdk/docs/WALLET_PROVIDERS.md) — per-chain `IXxxWalletProvider` interfaces
|
|
146
|
-
- [SDK Swaps](https://github.com/icon-project/sodax-sdks/blob/main/packages/sdk/docs/SWAPS.md) — example consumer of a wallet provider
|
|
147
|
-
- [EVM Switch Chain](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/EVM_SWITCH_CHAIN.md) — switch active EVM network
|
|
148
|
-
- [`packages/dapp-kit`](https://github.com/icon-project/sodax-sdks/blob/main/packages/dapp-kit/README.md) — higher-level React hooks that wrap SDK calls + `useWalletProvider`
|
package/skills/connect-button.md
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# Skill: Connect Button
|
|
2
|
-
|
|
3
|
-
Single-chain connect/disconnect button — pick a connector, connect, read the account, disconnect.
|
|
4
|
-
|
|
5
|
-
**Depends on:** [setup.md](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/skills/setup.md)
|
|
6
|
-
|
|
7
|
-
## Hooks
|
|
8
|
-
|
|
9
|
-
| Hook | Purpose |
|
|
10
|
-
|------|---------|
|
|
11
|
-
| `useXConnectors({ xChainType })` | List available connectors for the chain family |
|
|
12
|
-
| `useXConnect()` | React Query mutation — `mutate(connector)` |
|
|
13
|
-
| `useXAccount({ xChainType })` | Read connected account (always returns object — `address` is `undefined` when disconnected) |
|
|
14
|
-
| `useXDisconnect()` | Returns `(args) => Promise<void>` |
|
|
15
|
-
| `sortConnectors(list, { preferred })` | Optional — rank installed/preferred wallets first |
|
|
16
|
-
|
|
17
|
-
## Connect button
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
import {
|
|
21
|
-
useXConnectors,
|
|
22
|
-
useXConnect,
|
|
23
|
-
useXAccount,
|
|
24
|
-
useXDisconnect,
|
|
25
|
-
sortConnectors,
|
|
26
|
-
type IXConnector,
|
|
27
|
-
} from '@sodax/wallet-sdk-react';
|
|
28
|
-
|
|
29
|
-
const PREFERRED = ['hana', 'metamask'] as const;
|
|
30
|
-
|
|
31
|
-
export function EvmConnectButton() {
|
|
32
|
-
const raw = useXConnectors({ xChainType: 'EVM' });
|
|
33
|
-
const connectors = sortConnectors(raw, { preferred: PREFERRED });
|
|
34
|
-
const { mutateAsync: connect, isPending, error } = useXConnect();
|
|
35
|
-
const account = useXAccount({ xChainType: 'EVM' });
|
|
36
|
-
const disconnect = useXDisconnect();
|
|
37
|
-
|
|
38
|
-
if (account.address) {
|
|
39
|
-
return (
|
|
40
|
-
<div>
|
|
41
|
-
<code>{account.address}</code>
|
|
42
|
-
<button onClick={() => disconnect({ xChainType: 'EVM' })}>Disconnect</button>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div>
|
|
49
|
-
{connectors.map((connector) => (
|
|
50
|
-
<button
|
|
51
|
-
key={connector.id}
|
|
52
|
-
onClick={() => connect(connector).catch(() => {})}
|
|
53
|
-
disabled={isPending}
|
|
54
|
-
>
|
|
55
|
-
{connector.icon && <img src={connector.icon} alt="" width={20} height={20} />}
|
|
56
|
-
{connector.name}
|
|
57
|
-
{!connector.isInstalled && ' (not installed)'}
|
|
58
|
-
</button>
|
|
59
|
-
))}
|
|
60
|
-
{error && <p style={{ color: 'red' }}>{error.message}</p>}
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Install CTA for missing wallets
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
{connectors.map((connector) =>
|
|
70
|
-
connector.isInstalled ? (
|
|
71
|
-
<button key={connector.id} onClick={() => connect(connector)}>
|
|
72
|
-
{connector.name}
|
|
73
|
-
</button>
|
|
74
|
-
) : (
|
|
75
|
-
<a key={connector.id} href={connector.installUrl} target="_blank" rel="noreferrer">
|
|
76
|
-
Install {connector.name}
|
|
77
|
-
</a>
|
|
78
|
-
),
|
|
79
|
-
)}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
`isInstalled` reads `window.*` at render time (no extra subscription). For batch install detection across wallet brands, use [`useIsWalletInstalled`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CHAIN_DETECTION.md#useiswalletinstalled--install-detection).
|
|
83
|
-
|
|
84
|
-
## Caveat — provider-managed chains resolve with `undefined`
|
|
85
|
-
|
|
86
|
-
For EVM, Solana, and Sui, `connect(connector)` resolves with `undefined` because connection state is set by the chain's Hydrator after the native SDK reports `connected`. Always read the account via `useXAccount`, not the mutation's return value:
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
const { mutateAsync: connect } = useXConnect();
|
|
90
|
-
const account = useXAccount({ xChainType: 'EVM' });
|
|
91
|
-
|
|
92
|
-
await connect(connector); // resolves with undefined for EVM
|
|
93
|
-
// account.address is populated on the next render
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Non-provider chains (Bitcoin, ICON, Injective, Stellar, NEAR, Stacks) return the resolved `XAccount` from `connect()` — but reading via `useXAccount` works for both, so default to it.
|
|
97
|
-
|
|
98
|
-
## Multiple chains, one button
|
|
99
|
-
|
|
100
|
-
For a "connect EVM + Solana + Bitcoin in one click" pattern, use [`useBatchConnect`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/BATCH_OPERATIONS.md):
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
import { useBatchConnect } from '@sodax/wallet-sdk-react';
|
|
104
|
-
|
|
105
|
-
const { run, status } = useBatchConnect({ connectors: ['hana'] });
|
|
106
|
-
// Connects every chain Hana supports — sequential, errors collected.
|
|
107
|
-
<button onClick={run} disabled={status === 'running'}>
|
|
108
|
-
Connect Hana on all chains
|
|
109
|
-
</button>;
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Reference docs
|
|
113
|
-
|
|
114
|
-
- [Connect Flow](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECT_FLOW.md) — full lifecycle reference + error handling
|
|
115
|
-
- [Connectors](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECTORS.md) — `IXConnector` shape, deep imports for concrete classes
|
|
116
|
-
- [Batch Operations](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/BATCH_OPERATIONS.md) — multi-chain connect by wallet identifier
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# Skill: EVM-only WalletConnect
|
|
2
|
-
|
|
3
|
-
Enable WalletConnect protocol on the EVM slot for partners using enterprise custody (Fireblocks, Ledger Live, mobile-only wallets). Default EVM discovery (EIP-6963) only finds browser-extension wallets — WalletConnect lets users pair via QR/deep-link.
|
|
4
|
-
|
|
5
|
-
**Depends on:** [setup.md](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/skills/setup.md)
|
|
6
|
-
|
|
7
|
-
## When to use
|
|
8
|
-
|
|
9
|
-
| Scenario | Need WalletConnect? |
|
|
10
|
-
|----------|---------------------|
|
|
11
|
-
| MetaMask / Hana / Rabby browser extension | ❌ — EIP-6963 covers them |
|
|
12
|
-
| Fireblocks workspace | ✅ |
|
|
13
|
-
| Ledger Live | ✅ |
|
|
14
|
-
| MetaMask Mobile / Trust / Rainbow (paired via QR) | ✅ |
|
|
15
|
-
| Coinbase Smart Wallet | ✅ (fallback path) |
|
|
16
|
-
|
|
17
|
-
If your dApp only targets desktop browser-extension wallets, omit `walletConnect` entirely.
|
|
18
|
-
|
|
19
|
-
## 1. Get a WalletConnect Cloud project id
|
|
20
|
-
|
|
21
|
-
Sign up at [https://cloud.walletconnect.com](https://cloud.walletconnect.com) and copy your project id. Add it to `.env`:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
NEXT_PUBLIC_WC_PROJECT_ID=your-project-id
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## 2. Add `walletConnect` to the `EVM` slot
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { type SodaxWalletConfig } from '@sodax/wallet-sdk-react';
|
|
31
|
-
import { ChainKeys } from '@sodax/types';
|
|
32
|
-
|
|
33
|
-
const walletConfig: SodaxWalletConfig = {
|
|
34
|
-
EVM: {
|
|
35
|
-
ssr: true,
|
|
36
|
-
chains: {
|
|
37
|
-
[ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://rpc.soniclabs.com' },
|
|
38
|
-
[ChainKeys.ARBITRUM_MAINNET]: { rpcUrl: 'https://arb1.arbitrum.io/rpc' },
|
|
39
|
-
},
|
|
40
|
-
walletConnect: {
|
|
41
|
-
projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID!,
|
|
42
|
-
// showQrModal: true is the default — wagmi/WalletConnect own the QR display
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
A WalletConnect connector now surfaces alongside EIP-6963 wallets. `useXConnectors({ xChainType: 'EVM' })` returns it with `id === 'walletConnect'`. **No UI changes required** — the existing connect-button or modal already handles it.
|
|
49
|
-
|
|
50
|
-
## 3. Restrict the QR modal — Fireblocks-only
|
|
51
|
-
|
|
52
|
-
To show **only** Fireblocks (no Trust / Rainbow / etc. clutter), filter the WalletConnect Explorer list:
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
const walletConfig: SodaxWalletConfig = {
|
|
56
|
-
EVM: {
|
|
57
|
-
walletConnect: {
|
|
58
|
-
projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID!,
|
|
59
|
-
qrModalOptions: {
|
|
60
|
-
explorerRecommendedWalletIds: [
|
|
61
|
-
'225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f', // Fireblocks
|
|
62
|
-
],
|
|
63
|
-
explorerExcludedWalletIds: 'ALL', // hide everything except recommended
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Find wallet IDs at the [WalletConnect Explorer](https://walletconnect.com/explorer) — they're the long hex strings in URLs, not the human names.
|
|
71
|
-
|
|
72
|
-
## 4. Hide the Sodax modal during WalletConnect QR
|
|
73
|
-
|
|
74
|
-
When the user picks the WalletConnect connector, wagmi opens its own QR modal — two dialogs would stack. Detect WC by connector id and render `null`:
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
import { useWalletModal } from '@sodax/wallet-sdk-react';
|
|
78
|
-
|
|
79
|
-
const modal = useWalletModal();
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
modal.state.kind === 'connecting' &&
|
|
83
|
-
modal.state.connector.id === 'walletConnect'
|
|
84
|
-
) {
|
|
85
|
-
return null; // wagmi's QR modal owns the screen
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
The `useWalletModal` state machine handles the `connecting → success | error` transition normally — only the rendering is conditionally blanked.
|
|
90
|
-
|
|
91
|
-
## Missing `projectId` — silent skip
|
|
92
|
-
|
|
93
|
-
Setting `walletConnect: {}` without a `projectId` (or with an empty string) **silently skips** the WalletConnect connector and logs a warning:
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
[wallet-sdk-react] walletConnect.projectId is required — WalletConnect connector skipped.
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
EIP-6963 wallets continue to work normally — the dApp degrades gracefully. This intentionally avoids forcing local-dev environments to plumb the env var.
|
|
100
|
-
|
|
101
|
-
## EVM-only
|
|
102
|
-
|
|
103
|
-
The `walletConnect` field only exists on the `EVM` slot. Solana, Bitcoin, etc. use their own native wallet adapters and don't share the WalletConnect protocol layer. Don't attempt `SOLANA: { walletConnect: ... }` — TypeScript will reject it.
|
|
104
|
-
|
|
105
|
-
## Reference docs
|
|
106
|
-
|
|
107
|
-
- [WalletConnect](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/WALLETCONNECT.md) — full integration reference
|
|
108
|
-
- [Configure SodaxWalletProvider](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONFIGURE_PROVIDER.md#walletconnect-evm-only) — per-chain config
|
|
109
|
-
- [Wallet Modal QR caveat](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/WALLET_MODAL.md#walletconnect-qr-modal-caveat) — modal stacking handling
|
|
110
|
-
- [wagmi `WalletConnectParameters`](https://wagmi.sh/core/api/connectors/walletConnect) — full options reference
|
|
111
|
-
- [WalletConnect Cloud](https://cloud.walletconnect.com) — get a `projectId`
|