@sodax/wallet-sdk-react 2.0.0-rc.1 → 2.0.0-rc.11
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/{XConnector-B9YQTVJ4.d.ts → XConnector-12q0OVe5.d.ts} +1 -1
- package/dist/{chunk-NY7U7OJW.mjs → chunk-7V7O3Q7Y.mjs} +0 -2
- package/dist/{chunk-BXJLBR4G.mjs → chunk-C6M34IVL.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-PLCA4ZDJ.mjs → chunk-MAFHQGRP.mjs} +54 -30
- package/dist/{chunk-BKJB527E.mjs → chunk-MWWVB7TD.mjs} +2 -4
- package/dist/{chunk-MXZVF5HR.mjs → chunk-NAKCAL2M.mjs} +0 -2
- package/dist/{chunk-PJLEJVAU.mjs → chunk-OPYSVPRW.mjs} +10 -6
- package/dist/chunk-QMXBY3UI.mjs +1 -0
- package/dist/{chunk-MAQ47Q52.mjs → chunk-TACW7Z4D.mjs} +0 -2
- package/dist/chunk-VPNYFVP6.mjs +53 -0
- package/dist/{chunk-2BOUGCJ7.mjs → chunk-WPZOLGVB.mjs} +4 -6
- package/dist/{chunk-66BAUK56.mjs → chunk-X7BHR7WS.mjs} +4 -6
- package/dist/{chunk-N5A2TMF6.mjs → chunk-XJA2MJMG.mjs} +2 -4
- package/dist/{chunk-E5IAZ7E6.mjs → chunk-Z5GXDHGL.mjs} +11 -7
- package/dist/{config-OlnzyEUE.d.ts → config-DEsqgrG1.d.ts} +10 -5
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +20 -31
- package/dist/xchains/bitcoin/index.d.ts +1 -1
- package/dist/xchains/bitcoin/index.mjs +14 -16
- package/dist/xchains/evm/index.d.ts +3 -3
- package/dist/xchains/evm/index.mjs +3 -5
- package/dist/xchains/icon/index.d.ts +1 -1
- package/dist/xchains/icon/index.mjs +5 -7
- package/dist/xchains/injective/index.d.ts +2 -2
- package/dist/xchains/injective/index.mjs +3 -5
- package/dist/xchains/near/index.d.ts +1 -1
- package/dist/xchains/near/index.mjs +4 -6
- package/dist/xchains/solana/index.d.ts +1 -1
- package/dist/xchains/solana/index.mjs +5 -7
- package/dist/xchains/stacks/index.d.ts +10 -4
- package/dist/xchains/stacks/index.mjs +3 -5
- package/dist/xchains/stellar/index.d.ts +1 -1
- package/dist/xchains/stellar/index.mjs +4 -6
- package/dist/xchains/sui/index.d.ts +1 -1
- package/dist/xchains/sui/index.mjs +5 -7
- package/package.json +39 -31
- 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 -158
- 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 -162
- 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 -307
- package/ai-exported/migration/reference/hooks.md +0 -278
- 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 +0 -41
- 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/docs/ADDING_A_NEW_CHAIN.md +0 -440
- package/docs/ARCHITECTURE.md +0 -291
- package/docs/BATCH_OPERATIONS.md +0 -267
- package/docs/CHAIN_DETECTION.md +0 -216
- package/docs/CONFIGURE_PROVIDER.md +0 -360
- package/docs/CONNECTORS.md +0 -247
- package/docs/CONNECT_FLOW.md +0 -276
- package/docs/EVM_SWITCH_CHAIN.md +0 -161
- package/docs/SIGN_MESSAGE.md +0 -213
- package/docs/SUB_PATH_EXPORTS.md +0 -246
- package/docs/WALLETCONNECT.md +0 -154
- package/docs/WALLET_MODAL.md +0 -331
- package/docs/WALLET_PROVIDER_BRIDGE.md +0 -226
- 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,IAAA,MAAM,eAAA,GAAkB,OAAA,CAAQ,GAAA,CAAI,OAAM,MAAA,KAAU;AAClD,MAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,UAAA,CAAW,SAAS,MAAM,CAAA;AACrD,MAAA,OAAO,EAAE,OAAA,EAAS,MAAA,CAAO,OAAA,EAAS,OAAA,EAAQ;AAAA,IAC5C,CAAC,CAAA;AAED,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,GAAA,CAAI,eAAe,CAAA;AAClD,IAAA,OAAO,QAAA,CAAS,OAA+B,CAAC,GAAA,EAAK,EAAE,OAAA,EAAAA,QAAAA,EAAS,SAAQ,KAAM;AAC5E,MAAA,GAAA,CAAIA,QAAO,CAAA,GAAI,OAAA;AACf,MAAA,OAAO,GAAA;AAAA,IACT,CAAA,EAAG,EAAE,CAAA;AAAA,EACP;AAAA;AAAA;AAAA;AAAA,EAKO,cAAA,GA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;AAAA,EAGA,IAAW,UAAA,GAAiC;AAC1C,IAAA,OAAO,MAAA;AAAA,EACT;AACF,CAAA;;;ACtDA,IAAM,eAAA,GAAkB,CAAC,KAAA,KAA2C;AAClE,EAAA,OACE,QAAA,CAAS,KAAK,CAAA,IACd,iBAAA,CAAkB,OAAO,MAAM,CAAA;AAAA;AAAA,EAG/B,0BAA0B,KAAA,EAAO,IAAI,CAAA,IACrC,yBAAA,CAA0B,OAAO,MAAM,CAAA;AAE3C,CAAA;AAEO,IAAM,aAAA,GAAN,cAA4B,UAAA,CAAW;AAAA,EAC5B,MAAA;AAAA,EAEhB,YAAY,MAAA,EAAiB;AAC3B,IAAA,MAAA,CAAO,eAAA,CAAgB,MAAM,CAAA,EAAG,uCAAuC,CAAA;AAEvE,IAAA,MAAM,EAAA,GAAK,MAAA,CAAO,EAAA,IAAM,MAAA,CAAO,IAAA;AAE/B,IAAA,MAAA,CAAO,OAAO,EAAA,KAAO,QAAA,IAAY,EAAA,CAAG,MAAA,GAAS,GAAG,mCAAmC,CAAA;AAEnF,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"}
|
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
# Adding a New Chain
|
|
2
|
-
|
|
3
|
-
This document is the contributor workflow for onboarding a new chain family (e.g. Aptos, Cosmos, …) into `@sodax/wallet-sdk-react`. Most steps are mechanical because the central abstractions (`ChainMeta`, `chainRegistry`, sub-path exports) auto-derive downstream types — adding a chain is mostly **filling in entries**, not rewriting hooks.
|
|
4
|
-
|
|
5
|
-
Prerequisite: read [`ARCHITECTURE.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/ARCHITECTURE.md) first, especially the [Provider-managed vs non-provider](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/ARCHITECTURE.md#provider-managed-vs-non-provider-chains) split — that decision drives the rest of this guide.
|
|
6
|
-
|
|
7
|
-
## Table of contents
|
|
8
|
-
|
|
9
|
-
1. [Decision tree — provider-managed or not?](#decision-tree--provider-managed-or-not)
|
|
10
|
-
2. [Step 1 — types in `@sodax/types`](#step-1--types-in-sodaxtypes)
|
|
11
|
-
3. [Step 2 — wallet provider in `@sodax/wallet-sdk-core`](#step-2--wallet-provider-in-sodaxwallet-sdk-core)
|
|
12
|
-
4. [Step 3 — `XService` + `XConnector` in `xchains/<chain>/`](#step-3--xservice--xconnector-in-xchainschain)
|
|
13
|
-
5. [Step 4 — `xchains/<chain>/index.ts` barrel for sub-path export](#step-4--xchainschainindexts-barrel-for-sub-path-export)
|
|
14
|
-
6. [Step 5 — `ChainMeta` entry in `types/config.ts`](#step-5--chainmeta-entry-in-typesconfigts)
|
|
15
|
-
7. [Step 6 — register in `chainRegistry`](#step-6--register-in-chainregistry)
|
|
16
|
-
8. [Step 7 — provider-managed only — Provider/Hydrator/Actions trio](#step-7--provider-managed-only--providerhydratoractions-trio)
|
|
17
|
-
9. [Step 8 — barrel surface (`src/index.ts`)](#step-8--barrel-surface-srcindexts)
|
|
18
|
-
10. [Step 9 — tests](#step-9--tests)
|
|
19
|
-
11. [Verification checklist](#verification-checklist)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Decision tree — provider-managed or not?
|
|
24
|
-
|
|
25
|
-
Set `providerManaged: true` if **any** of these is true:
|
|
26
|
-
|
|
27
|
-
- The chain ships a React adapter library (wagmi, `@solana/wallet-adapter-react`, `@mysten/dapp-kit`, etc.) that you want to use.
|
|
28
|
-
- The wallet-side SDK requires a long-lived React context to register handlers and survive component re-renders.
|
|
29
|
-
- Wallet discovery is reactive (EIP-6963 announcements, dynamic adapter registration) and you want components to re-render automatically.
|
|
30
|
-
|
|
31
|
-
Set `providerManaged: false` if:
|
|
32
|
-
|
|
33
|
-
- You can probe `window.<wallet>` synchronously per-call.
|
|
34
|
-
- Connection lifecycle is short-lived (call `connect()`, get an account back, no React context needed).
|
|
35
|
-
- The native SDK is plain TS classes/functions with no React glue (e.g. `sats-connect`, `icon-sdk-js`).
|
|
36
|
-
|
|
37
|
-
**Mixing** — you can have a non-provider chain whose `discoverConnectors` is async (Stellar). That's still `providerManaged: false` because the connectors are static after discovery; the React adapter pattern isn't used.
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Step 1 — types in `@sodax/types`
|
|
42
|
-
|
|
43
|
-
Add the chain's identity and types to `packages/types/src/`:
|
|
44
|
-
|
|
45
|
-
1. **Chain key** in [`packages/types/src/chains/chain-keys.ts`](https://github.com/icon-project/sodax-sdks/blob/main/packages/types/src/chains/chain-keys.ts):
|
|
46
|
-
```typescript
|
|
47
|
-
export const ChainKeys = {
|
|
48
|
-
...
|
|
49
|
-
APTOS_MAINNET: 'aptos',
|
|
50
|
-
};
|
|
51
|
-
```
|
|
52
|
-
2. **Chain type** in `ChainTypeArr`:
|
|
53
|
-
```typescript
|
|
54
|
-
export const ChainTypeArr = [..., 'APTOS'] as const;
|
|
55
|
-
```
|
|
56
|
-
3. **Chain key type alias**:
|
|
57
|
-
```typescript
|
|
58
|
-
export type AptosChainKey = typeof ChainKeys.APTOS_MAINNET;
|
|
59
|
-
```
|
|
60
|
-
4. **Chain info entry** in [`packages/types/src/chains/chains.ts`](https://github.com/icon-project/sodax-sdks/blob/main/packages/types/src/chains/chains.ts) (`baseChainInfo`):
|
|
61
|
-
```typescript
|
|
62
|
-
[ChainKeys.APTOS_MAINNET]: { type: 'APTOS', chainId: '0x1' /* or numeric */, displayName: 'Aptos' }
|
|
63
|
-
```
|
|
64
|
-
5. **Wallet provider interface** in `packages/types/src/aptos.ts`:
|
|
65
|
-
```typescript
|
|
66
|
-
export interface IAptosWalletProvider extends WalletAddressProvider {
|
|
67
|
-
readonly chainType: 'APTOS';
|
|
68
|
-
// chain-specific methods: signAndSubmitTransaction, signMessage, ...
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
6. **Add to root barrel** if you want it re-exported from `@sodax/types`, or leave as a sub-package export per [`packages/types/CLAUDE.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/types/CLAUDE.md).
|
|
72
|
-
|
|
73
|
-
The `ChainKey` and `ChainType` unions auto-derive — once these entries land, downstream code in `@sodax/sdk` and `@sodax/wallet-sdk-react` sees the new chain at the type level.
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Step 2 — wallet provider in `@sodax/wallet-sdk-core`
|
|
78
|
-
|
|
79
|
-
Add `packages/wallet-sdk-core/src/wallet-providers/aptos/`:
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
aptos/
|
|
83
|
-
├── AptosWalletProvider.ts
|
|
84
|
-
├── AptosWalletProvider.test.ts
|
|
85
|
-
├── types.ts # PrivateKey<chain>WalletConfig + BrowserExtension<chain>WalletConfig + AptosWalletDefaults
|
|
86
|
-
└── index.ts # Barrel re-export
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
`AptosWalletProvider` extends `BaseWalletProvider<AptosWalletDefaults>` and implements `IAptosWalletProvider`. Discriminated config — pick a discriminant pattern:
|
|
90
|
-
|
|
91
|
-
- **Field presence** (no `type` field): `privateKey` field present vs. absent. Most chains use this.
|
|
92
|
-
- **Explicit `type`**: `'PRIVATE_KEY'` | `'BROWSER_EXTENSION'`. Use when both modes share fields that would clash without a discriminant (Bitcoin, Stellar).
|
|
93
|
-
|
|
94
|
-
See [`packages/wallet-sdk-core/CLAUDE.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-core/CLAUDE.md#config-variants-discriminants) for the canonical patterns.
|
|
95
|
-
|
|
96
|
-
Re-export from `packages/wallet-sdk-core/src/wallet-providers/index.ts`:
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
export * from './aptos/index.js';
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## Step 3 — `XService` + `XConnector` in `xchains/<chain>/`
|
|
105
|
-
|
|
106
|
-
Create `packages/wallet-sdk-react/src/xchains/aptos/`:
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
aptos/
|
|
110
|
-
├── AptosXService.ts
|
|
111
|
-
├── AptosXConnector.ts
|
|
112
|
-
├── AptosXConnector.test.ts
|
|
113
|
-
└── index.ts
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### `AptosXService`
|
|
117
|
-
|
|
118
|
-
Singleton that owns the connector list and exposes balance reads. Extend the abstract `XService`:
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
import type { XToken } from '@sodax/types';
|
|
122
|
-
import { XService } from '@/core/index.js';
|
|
123
|
-
|
|
124
|
-
export class AptosXService extends XService {
|
|
125
|
-
private static instance: AptosXService | undefined;
|
|
126
|
-
|
|
127
|
-
static getInstance(rpcConfig?: { rpcUrl?: string }): AptosXService {
|
|
128
|
-
if (!AptosXService.instance) AptosXService.instance = new AptosXService(rpcConfig);
|
|
129
|
-
return AptosXService.instance;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// chain-specific state (RPC client, etc.)
|
|
133
|
-
|
|
134
|
-
async getBalance(address: string, xToken: XToken): Promise<bigint> {
|
|
135
|
-
// …
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### `AptosXConnector`
|
|
141
|
-
|
|
142
|
-
Extend `XConnector`. The base class provides `id`, `icon`, `isInstalled = true` defaults; override `isInstalled` / `installUrl` for browser-extension-backed connectors:
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { XConnector } from '@/core/index.js';
|
|
146
|
-
import type { XAccount } from '@/types/index.js';
|
|
147
|
-
|
|
148
|
-
export class AptosWalletXConnector extends XConnector {
|
|
149
|
-
constructor() {
|
|
150
|
-
super('APTOS', 'Aptos Wallet', 'aptos.wallet');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
override get isInstalled(): boolean {
|
|
154
|
-
return typeof window !== 'undefined' && 'aptos' in window;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
override get installUrl(): string {
|
|
158
|
-
return 'https://chrome.google.com/webstore/detail/...';
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async connect(): Promise<XAccount | undefined> {
|
|
162
|
-
const account = await window.aptos.connect();
|
|
163
|
-
return account ? { address: account.address, xChainType: 'APTOS', publicKey: account.publicKey } : undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async disconnect(): Promise<void> {
|
|
167
|
-
await window.aptos.disconnect();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
For chains with multiple wallets (Bitcoin: Unisat / Xverse / OKX; Injective: MetaMask / Keplr / Leap), create one `XConnector` subclass per wallet and have an abstract intermediate base if shared logic exists (Bitcoin uses `BitcoinXConnector` abstract).
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## Step 4 — `xchains/<chain>/index.ts` barrel for sub-path export
|
|
177
|
-
|
|
178
|
-
Create the barrel that powers `@sodax/wallet-sdk-react/xchains/aptos`:
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
// src/xchains/aptos/index.ts
|
|
182
|
-
export { AptosXService } from './AptosXService.js';
|
|
183
|
-
export { AptosWalletXConnector } from './AptosXConnector.js';
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
`tsup.config.ts` already picks up `src/xchains/*/index.ts` via glob — **no config edit needed**. The sub-path export will resolve as `@sodax/wallet-sdk-react/xchains/aptos`.
|
|
187
|
-
|
|
188
|
-
See [`SUB_PATH_EXPORTS.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/SUB_PATH_EXPORTS.md) for the export plumbing.
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## Step 5 — `ChainMeta` entry in `types/config.ts`
|
|
193
|
-
|
|
194
|
-
[`ChainMeta`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/src/types/config.ts) is the **single source of truth** for per-chain-type metadata. `SodaxWalletConfig`, `ChainTypeConfig<T>`, `ChainEntry<K>`, `WalletDefaultsByKey<K>` all derive from it automatically.
|
|
195
|
-
|
|
196
|
-
Add **one entry**:
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
export type AptosChainEntry = SimpleChainEntry<AptosWalletDefaults>;
|
|
200
|
-
|
|
201
|
-
export type ChainMeta = {
|
|
202
|
-
EVM: { ... };
|
|
203
|
-
// ...
|
|
204
|
-
APTOS: {
|
|
205
|
-
keys: AptosChainKey; // from @sodax/types
|
|
206
|
-
entry: AptosChainEntry; // { rpcUrl?, defaults? } (or richer if chain has multi-field RPC)
|
|
207
|
-
defaults: AptosWalletDefaults;
|
|
208
|
-
adapter: {}; // {} for non-provider chains; AptosAdapterFields if provider-managed
|
|
209
|
-
};
|
|
210
|
-
};
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
If the chain has multi-field RPC (Stellar's horizon + soroban, Bitcoin's RPC + Radfi), define a custom entry shape that extends `*RpcConfig` from `@sodax/types`:
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
export type AptosChainEntry = AptosRpcConfig & { defaults?: AptosWalletDefaults };
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
If provider-managed, define `AptosAdapterFields` (one value per React provider — wagmi-config-level settings, not per-chain):
|
|
220
|
-
|
|
221
|
-
```typescript
|
|
222
|
-
export type AptosAdapterFields = {
|
|
223
|
-
network?: 'mainnet' | 'testnet' | 'devnet';
|
|
224
|
-
autoConnect?: boolean;
|
|
225
|
-
};
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
Add the per-chain-type alias for external typing convenience:
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
export type AptosTypeConfig = ChainTypeConfig<'APTOS'>;
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
## Step 6 — register in `chainRegistry`
|
|
237
|
-
|
|
238
|
-
Add an entry to [`chainRegistry`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/src/chainRegistry.ts):
|
|
239
|
-
|
|
240
|
-
### Non-provider chain
|
|
241
|
-
|
|
242
|
-
```typescript
|
|
243
|
-
APTOS: defineChain({
|
|
244
|
-
createService: walletConfig =>
|
|
245
|
-
AptosXService.getInstance({ rpcUrl: getRpcUrl(walletConfig?.APTOS?.chains?.[ChainKeys.APTOS_MAINNET]) }),
|
|
246
|
-
displayName: 'Aptos',
|
|
247
|
-
defaultConnectors: () => [new AptosWalletXConnector()],
|
|
248
|
-
providerManaged: false,
|
|
249
|
-
// Optional — provide createActions if signMessage needs custom dispatch (Bitcoin's BIP-322/ECDSA)
|
|
250
|
-
createActions: (service, getStore) => ({
|
|
251
|
-
...createDefaultActions('APTOS', service, getStore),
|
|
252
|
-
signMessage: async (message: string) => {
|
|
253
|
-
// chain-specific signing logic
|
|
254
|
-
},
|
|
255
|
-
}),
|
|
256
|
-
// Optional — provide createWalletProvider if the chain needs a wallet provider in `walletProviders` map
|
|
257
|
-
createWalletProvider: (service, getStore) => {
|
|
258
|
-
const connection = getStore().xConnections.APTOS;
|
|
259
|
-
if (!connection?.xConnectorId) return undefined;
|
|
260
|
-
const defaults = getEntryDefaults<typeof ChainKeys.APTOS_MAINNET>(
|
|
261
|
-
getStore().walletConfig?.APTOS?.chains?.[ChainKeys.APTOS_MAINNET],
|
|
262
|
-
);
|
|
263
|
-
return new AptosWalletProvider({ /* ... */, defaults });
|
|
264
|
-
},
|
|
265
|
-
// Optional — provide discoverConnectors if connectors require async detection
|
|
266
|
-
discoverConnectors: async (service, getStore) => {
|
|
267
|
-
const wallets = await detectInstalledAptosWallets();
|
|
268
|
-
const connectors = wallets.map(w => new AptosWalletXConnector(w));
|
|
269
|
-
service.setXConnectors(connectors);
|
|
270
|
-
getStore().setXConnectors('APTOS', connectors);
|
|
271
|
-
},
|
|
272
|
-
}),
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### Provider-managed chain
|
|
276
|
-
|
|
277
|
-
```typescript
|
|
278
|
-
APTOS: defineChain({
|
|
279
|
-
createService: () => AptosXService.getInstance(),
|
|
280
|
-
displayName: 'Aptos',
|
|
281
|
-
defaultConnectors: () => [], // ignored — connectors come from the React adapter
|
|
282
|
-
providerManaged: true,
|
|
283
|
-
// No createActions / createWalletProvider — the Hydrator handles both.
|
|
284
|
-
}),
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## Step 7 — provider-managed only — Provider/Hydrator/Actions trio
|
|
290
|
-
|
|
291
|
-
Skip this step for `providerManaged: false`.
|
|
292
|
-
|
|
293
|
-
Create `packages/wallet-sdk-react/src/providers/aptos/`:
|
|
294
|
-
|
|
295
|
-
```
|
|
296
|
-
aptos/
|
|
297
|
-
├── AptosProvider.tsx # Wraps native React adapter
|
|
298
|
-
├── AptosHydrator.tsx # Sole writer of connection state + walletProviders
|
|
299
|
-
├── AptosActions.tsx # Registers ChainActions (connect/disconnect/signMessage)
|
|
300
|
-
├── AptosHydrator.test.tsx
|
|
301
|
-
└── index.ts
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### `<AptosProvider>`
|
|
305
|
-
|
|
306
|
-
Wraps the chain's native React provider:
|
|
307
|
-
|
|
308
|
-
```tsx
|
|
309
|
-
import { type ReactNode } from 'react';
|
|
310
|
-
import { AptosProvider as NativeProvider } from 'aptos-adapter-react';
|
|
311
|
-
import { AptosHydrator } from './AptosHydrator.js';
|
|
312
|
-
import { AptosActions } from './AptosActions.js';
|
|
313
|
-
import type { AptosTypeConfig } from '@/types/config.js';
|
|
314
|
-
|
|
315
|
-
type AptosProviderProps = {
|
|
316
|
-
children: ReactNode;
|
|
317
|
-
config: AptosTypeConfig;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
export const AptosProvider = ({ children, config }: AptosProviderProps) => (
|
|
321
|
-
<NativeProvider network={config.network ?? 'mainnet'} autoConnect={config.autoConnect ?? true}>
|
|
322
|
-
<AptosHydrator />
|
|
323
|
-
<AptosActions />
|
|
324
|
-
{children}
|
|
325
|
-
</NativeProvider>
|
|
326
|
-
);
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
### `<AptosHydrator>`
|
|
330
|
-
|
|
331
|
-
Sole writer. Subscribes to native SDK hooks; writes through `setXConnection` / `setWalletProvider`. **Never** writes inside an event handler — only inside `useEffect` reactions to native state.
|
|
332
|
-
|
|
333
|
-
```typescript
|
|
334
|
-
import { useAccount } from 'aptos-adapter-react';
|
|
335
|
-
|
|
336
|
-
export const AptosHydrator = () => {
|
|
337
|
-
const { address, status, connector } = useAccount();
|
|
338
|
-
const setXConnection = useXWalletStore(s => s.setXConnection);
|
|
339
|
-
const unsetXConnection = useXWalletStore(s => s.unsetXConnection);
|
|
340
|
-
|
|
341
|
-
useEffect(() => {
|
|
342
|
-
if (status === 'connected' && address) {
|
|
343
|
-
setXConnection('APTOS', { xAccount: { address, xChainType: 'APTOS' }, xConnectorId: connector.id });
|
|
344
|
-
} else if (status === 'disconnected') {
|
|
345
|
-
unsetXConnection('APTOS');
|
|
346
|
-
}
|
|
347
|
-
}, [address, status, connector]);
|
|
348
|
-
|
|
349
|
-
// ... build wallet provider similarly via useMemo + setWalletProvider
|
|
350
|
-
|
|
351
|
-
return null;
|
|
352
|
-
};
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
### `<AptosActions>`
|
|
356
|
-
|
|
357
|
-
Registers `ChainActions` using **refs** to native SDK functions, so the registered closures always call the latest function without re-registering:
|
|
358
|
-
|
|
359
|
-
```typescript
|
|
360
|
-
const connectRef = useRef(connectAsync);
|
|
361
|
-
useEffect(() => { connectRef.current = connectAsync; }, [connectAsync]);
|
|
362
|
-
|
|
363
|
-
useEffect(() => {
|
|
364
|
-
registerChainActions('APTOS', {
|
|
365
|
-
connect: async (id) => connectRef.current({ connector: id }),
|
|
366
|
-
disconnect: async () => disconnectRef.current(),
|
|
367
|
-
// ...
|
|
368
|
-
});
|
|
369
|
-
}, []); // empty deps — register once
|
|
370
|
-
|
|
371
|
-
return null;
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
### Mount in `SodaxWalletProvider.tsx`
|
|
375
|
-
|
|
376
|
-
```tsx
|
|
377
|
-
{frozen.APTOS && (
|
|
378
|
-
<AptosProvider config={frozen.APTOS}>
|
|
379
|
-
{content}
|
|
380
|
-
</AptosProvider>
|
|
381
|
-
)}
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
---
|
|
385
|
-
|
|
386
|
-
## Step 8 — barrel surface (`src/index.ts`)
|
|
387
|
-
|
|
388
|
-
**Do NOT** add `export * from './xchains/aptos'` to the root `src/index.ts`. Concrete classes stay behind sub-path imports.
|
|
389
|
-
|
|
390
|
-
If consumers need a **type** from the barrel for type-only ergonomics, add an explicit `export type` line:
|
|
391
|
-
|
|
392
|
-
```typescript
|
|
393
|
-
// src/index.ts
|
|
394
|
-
export type { AptosWalletAddressType } from './xchains/aptos/index.js';
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
This keeps runtime classes off the barrel but lets consumers `import type { AptosWalletAddressType } from '@sodax/wallet-sdk-react'` without going through the deep import for a type-only reference.
|
|
398
|
-
|
|
399
|
-
See [`SUB_PATH_EXPORTS.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/SUB_PATH_EXPORTS.md) for why concrete classes are deep-imported.
|
|
400
|
-
|
|
401
|
-
---
|
|
402
|
-
|
|
403
|
-
## Step 9 — tests
|
|
404
|
-
|
|
405
|
-
Required test surface per `vitest.config.ts`:
|
|
406
|
-
|
|
407
|
-
- `AptosXConnector.test.ts` — connector constructor, `connect/disconnect`, `isInstalled`/`installUrl` window probes
|
|
408
|
-
- `AptosXService.test.ts` (or co-located) — singleton behavior, balance reads
|
|
409
|
-
- `AptosWalletProvider.test.ts` (in wallet-sdk-core) — config variants, defaults merge, core method dispatch
|
|
410
|
-
- `AptosHydrator.test.tsx` (provider-managed only) — fake adapter state → assert store writes
|
|
411
|
-
|
|
412
|
-
Pattern reference: [`EvmHydrator.test.tsx`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/src/providers/evm/EvmHydrator.test.tsx).
|
|
413
|
-
|
|
414
|
-
---
|
|
415
|
-
|
|
416
|
-
## Verification checklist
|
|
417
|
-
|
|
418
|
-
Before opening a PR, walk through each item:
|
|
419
|
-
|
|
420
|
-
- [ ] `pnpm checkTs` passes — `SodaxWalletConfig.APTOS` is recognized; `useWalletProvider({ xChainType: 'APTOS' })` returns the right type.
|
|
421
|
-
- [ ] `pnpm test` passes for new files.
|
|
422
|
-
- [ ] `pnpm build:packages` produces `dist/xchains/aptos/index.{mjs,cjs,d.ts}`.
|
|
423
|
-
- [ ] `import { AptosXService } from '@sodax/wallet-sdk-react/xchains/aptos'` resolves in a consumer app.
|
|
424
|
-
- [ ] `import { AptosXService } from '@sodax/wallet-sdk-react'` is **not** available (intentional — concrete classes stay behind deep imports).
|
|
425
|
-
- [ ] Adding `APTOS: {}` to `SodaxWalletConfig` mounts the chain; omitting the slot skips it.
|
|
426
|
-
- [ ] `useEnabledChains()` includes `'APTOS'` only when the slot is present.
|
|
427
|
-
- [ ] Connect → disconnect cycle updates `xConnections.APTOS` correctly; `localStorage` persists.
|
|
428
|
-
- [ ] On reload, `cleanupDisabledConnections` removes `xConnections.APTOS` if the slot is later removed.
|
|
429
|
-
- [ ] Documentation: add an entry to the connector reference in [`CONNECTORS.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECTORS.md) and the chain-type tables in [`CONFIGURE_PROVIDER.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONFIGURE_PROVIDER.md).
|
|
430
|
-
|
|
431
|
-
---
|
|
432
|
-
|
|
433
|
-
## Related docs
|
|
434
|
-
|
|
435
|
-
- [Architecture](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/ARCHITECTURE.md) — store + registry + Hydrator pattern
|
|
436
|
-
- [Sub-path Exports](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/SUB_PATH_EXPORTS.md) — barrel vs deep-import boundary
|
|
437
|
-
- [Configure SodaxWalletProvider](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONFIGURE_PROVIDER.md) — config schema (auto-extends from `ChainMeta`)
|
|
438
|
-
- [Connectors](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-react/docs/CONNECTORS.md) — IXConnector contract + sub-path map
|
|
439
|
-
- [`packages/wallet-sdk-core/CLAUDE.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/wallet-sdk-core/CLAUDE.md) — wallet provider class patterns
|
|
440
|
-
- [`packages/types/CLAUDE.md`](https://github.com/icon-project/sodax-sdks/blob/main/packages/types/CLAUDE.md) — interface conventions
|