Skip to content

Commit

Permalink
chore: add check for suported networks on blockchain api controller (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Jan 21, 2025
1 parent 4075214 commit 1ea9f7d
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 19 deletions.
23 changes: 23 additions & 0 deletions .changeset/plenty-colts-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit': patch
'@reown/appkit-common': patch
'@reown/appkit-core': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Prevents calls to Blockchain Api that would fail due to lack of support. Initialize supported list on AppKit initialization'
19 changes: 16 additions & 3 deletions apps/laboratory/src/pages/library/multichain-basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mainnet } from '@reown/appkit/networks'
import { type AppKitNetwork, defineChain, mainnet } from '@reown/appkit/networks'
import { createAppKit } from '@reown/appkit/react'

import { AppKitButtons } from '../../components/AppKitButtons'
Expand All @@ -7,10 +7,23 @@ import { UpaTests } from '../../components/UPA/UpaTests'
import { ConstantsUtil } from '../../utils/ConstantsUtil'
import { ThemeStore } from '../../utils/StoreUtil'

const networks = ConstantsUtil.AllNetworks
const networks = [
...ConstantsUtil.AllNetworks,
defineChain({
id: '91b171bb158e2d3848fa23a9f1c25182',
name: 'Polkadot',
network: 'polkadot',
nativeCurrency: { name: 'Polkadot', symbol: 'DOT', decimals: 18 },
rpcUrls: {
default: { http: ['https://rpc.polkadot.io'] }
},
chainNamespace: 'polkadot',
caipNetworkId: 'polkadot:mainnet'
})
]

const modal = createAppKit({
networks,
networks: networks as [AppKitNetwork, ...AppKitNetwork[]],
defaultNetwork: mainnet,
projectId: ConstantsUtil.ProjectId,
metadata: ConstantsUtil.Metadata
Expand Down
7 changes: 7 additions & 0 deletions packages/appkit/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,17 @@ export class AppKit {
}
}

private async initializeBlockchainApiController(options: AppKitOptions) {
await BlockchainApiController.getSupportedNetworks({
projectId: options.projectId
})
}

private initControllers(options: AppKitOptionsWithSdk) {
this.initializeOptionsController(options)
this.initializeChainController(options)
this.initializeThemeController(options)
this.initializeBlockchainApiController(options)

if (options.excludeWalletIds) {
ApiController.initializeExcludedWalletRdns({ ids: options.excludeWalletIds })
Expand Down
Loading

0 comments on commit 1ea9f7d

Please sign in to comment.