From ac1845e022072e8e2d03449c28229d3576b2dd28 Mon Sep 17 00:00:00 2001 From: Felipe Mendes Date: Wed, 20 Nov 2024 18:48:19 -0300 Subject: [PATCH] fix: wrong case checking for deprecated chain id on solanaDevnet (#3290) --- .changeset/lovely-cougars-count.md | 24 +++++++++++++++++ .../src/tests/utils/HelpersUtil.test.ts | 27 ++++++++++++++++--- packages/appkit/src/utils/HelpersUtil.ts | 2 +- 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .changeset/lovely-cougars-count.md diff --git a/.changeset/lovely-cougars-count.md b/.changeset/lovely-cougars-count.md new file mode 100644 index 0000000000..c1507fa6f0 --- /dev/null +++ b/.changeset/lovely-cougars-count.md @@ -0,0 +1,24 @@ +--- +'@reown/appkit': patch +'@apps/demo': patch +'@apps/gallery': patch +'@apps/laboratory': patch +'@reown/appkit-adapter-ethers': patch +'@reown/appkit-adapter-ethers5': patch +'@reown/appkit-adapter-polkadot': patch +'@reown/appkit-adapter-solana': patch +'@reown/appkit-adapter-wagmi': patch +'@reown/appkit-utils': patch +'@reown/appkit-cdn': patch +'@reown/appkit-common': patch +'@reown/appkit-core': patch +'@reown/appkit-experimental': patch +'@reown/appkit-polyfills': patch +'@reown/appkit-scaffold-ui': patch +'@reown/appkit-siwe': patch +'@reown/appkit-siwx': patch +'@reown/appkit-ui': patch +'@reown/appkit-wallet': patch +--- + +Fix for wrong checking on Solana devnet id diff --git a/packages/appkit/src/tests/utils/HelpersUtil.test.ts b/packages/appkit/src/tests/utils/HelpersUtil.test.ts index 1677bd14d7..b490a443fa 100644 --- a/packages/appkit/src/tests/utils/HelpersUtil.test.ts +++ b/packages/appkit/src/tests/utils/HelpersUtil.test.ts @@ -54,6 +54,23 @@ const mockSolanaNetwork = { } } as const +const mockSolanaDevnetNetwork = { + id: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1', + chainNamespace: ConstantsUtil.CHAIN.SOLANA, + caipNetworkId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1', + name: 'Solana', + nativeCurrency: { + name: 'Solana', + decimals: 9, + symbol: 'SOL' + }, + rpcUrls: { + default: { + http: ['https://api.mainnet-beta.solana.com'] + } + } +} as const + describe('WcHelpersUtil', () => { describe('getMethodsByChainNamespace', () => { test('returns correct methods for solana', () => { @@ -100,7 +117,8 @@ describe('WcHelpersUtil', () => { const caipNetworks: CaipNetwork[] = [ mockEthereumNetwork, mockPolygonNetwork, - mockSolanaNetwork + mockSolanaNetwork, + mockSolanaDevnetNetwork ] const namespaces = WcHelpersUtil.createNamespaces(caipNetworks) @@ -141,10 +159,13 @@ describe('WcHelpersUtil', () => { events: ['accountsChanged', 'chainChanged'], chains: [ 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', - 'solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ' + 'solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ', + 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1', + 'solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K' ], rpcMap: { - '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'https://api.mainnet-beta.solana.com' + '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'https://api.mainnet-beta.solana.com', + EtWTRABZaYq6iMfeYKouRu166VU2xqa1: 'https://api.mainnet-beta.solana.com' } } }) diff --git a/packages/appkit/src/utils/HelpersUtil.ts b/packages/appkit/src/utils/HelpersUtil.ts index 327fc91263..e6a427ae87 100644 --- a/packages/appkit/src/utils/HelpersUtil.ts +++ b/packages/appkit/src/utils/HelpersUtil.ts @@ -67,7 +67,7 @@ export const WcHelpersUtil = { case solana.caipNetworkId: namespace.chains.push(solana.deprecatedCaipNetworkId) break - case solanaDevnet.deprecatedCaipNetworkId: + case solanaDevnet.caipNetworkId: namespace.chains.push(solanaDevnet.deprecatedCaipNetworkId) break default: