From 3723431b679565f58e3542234c813e359a228747 Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Fri, 31 May 2024 10:49:36 -0600 Subject: [PATCH 1/2] Fix upstream handling of number chain Ids by adding a check to the chainChanged listener --- packages/core/package.json | 2 +- packages/core/src/provider.ts | 11 +++++++++-- packages/demo/package.json | 4 ++-- packages/demo/src/App.svelte | 4 ++-- packages/injected/package.json | 3 ++- packages/react/package.json | 4 ++-- packages/solid/package.json | 4 ++-- packages/vue/package.json | 4 ++-- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 58fc4919d..0be516a7e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/core", - "version": "2.22.0-alpha.7", + "version": "2.22.0-alpha.8", "description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", "keywords": [ "Ethereum", diff --git a/packages/core/src/provider.ts b/packages/core/src/provider.ts index 57b07e07a..5fde010ef 100644 --- a/packages/core/src/provider.ts +++ b/packages/core/src/provider.ts @@ -12,7 +12,12 @@ import { configuration } from './configuration.js' import { updateSecondaryTokens } from './update-balances' import type { Uns } from '@web3-onboard/unstoppable-resolution' -import type { PublicClient, GetEnsTextReturnType } from 'viem' +import { + type PublicClient, + type GetEnsTextReturnType, + isHex, + toHex +} from 'viem' import type { Address, ChainId, @@ -260,7 +265,9 @@ export function trackWallet( if (!wallet) return // Add null check for wallet const { chains, accounts } = wallet const [connectedWalletChain] = chains - + if (!isHex(chainId)) { + chainId = toHex(chainId) + } if (chainId === connectedWalletChain.id) return if (state.get().notify.enabled) { diff --git a/packages/demo/package.json b/packages/demo/package.json index ebe25710a..64c238811 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -32,7 +32,7 @@ "@web3-onboard/blocto": "^2.1.0-alpha.2", "@web3-onboard/capsule": "2.1.0-alpha.2", "@web3-onboard/cede-store": "^2.3.0-alpha.2", - "@web3-onboard/core": "2.22.0-alpha.7", + "@web3-onboard/core": "2.22.0-alpha.8", "@web3-onboard/coinbase": "^2.3.0-alpha.2", "@web3-onboard/dcent": "^2.2.7", "@web3-onboard/enkrypt": "^2.1.0-alpha.2", @@ -43,7 +43,7 @@ "@web3-onboard/wagmi": "^2.0.0-alpha.6", "@web3-onboard/gnosis": "^2.3.0-alpha.2", "@web3-onboard/infinity-wallet": "^2.1.0-alpha.2", - "@web3-onboard/injected-wallets": "^2.11.0-alpha.2", + "@web3-onboard/injected-wallets": "2.11.0-alpha.2", "@web3-onboard/keepkey": "^2.3.8", "@web3-onboard/keystone": "^2.3.8", "@web3-onboard/ledger": "^2.7.0-alpha.2", diff --git a/packages/demo/src/App.svelte b/packages/demo/src/App.svelte index 611d47e61..e1835b70c 100644 --- a/packages/demo/src/App.svelte +++ b/packages/demo/src/App.svelte @@ -260,8 +260,8 @@ const onboard = Onboard({ wallets: [ - metamaskSDKWallet, - coinbaseWallet, + // metamaskSDKWallet, + // coinbaseWallet, injected, ledger, trezor, diff --git a/packages/injected/package.json b/packages/injected/package.json index 31ac7bb60..e3ecbe704 100644 --- a/packages/injected/package.json +++ b/packages/injected/package.json @@ -70,6 +70,7 @@ "dependencies": { "@web3-onboard/common": "^2.4.0-alpha.2", "joi": "17.9.1", - "lodash.uniqby": "^4.7.0" + "lodash.uniqby": "^4.7.0", + "viem": "2.12.0" } } \ No newline at end of file diff --git a/packages/react/package.json b/packages/react/package.json index 22c7d6ee4..8ce3fb242 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/react", - "version": "2.9.0-alpha.8", + "version": "2.9.0-alpha.9", "description": "A collection of React hooks for integrating Web3-Onboard in to React and Next.js projects. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", "keywords": [ "Ethereum", @@ -61,7 +61,7 @@ "typescript": "^5.4.5" }, "dependencies": { - "@web3-onboard/core": "2.22.0-alpha.7", + "@web3-onboard/core": "2.22.0-alpha.8", "@web3-onboard/common": "^2.4.0-alpha.2", "use-sync-external-store": "1.0.0" }, diff --git a/packages/solid/package.json b/packages/solid/package.json index 142fb9c0c..aa53c86a3 100644 --- a/packages/solid/package.json +++ b/packages/solid/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/solid", - "version": "2.1.0-alpha.6", + "version": "2.1.0-alpha.7", "description": "A collection of solid Composables for integrating Web3-Onboard in to a Solid project. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", "keywords": [ "Ethereum", @@ -63,7 +63,7 @@ }, "dependencies": { "@web3-onboard/common": "^2.4.0-alpha.2", - "@web3-onboard/core": "2.22.0-alpha.7", + "@web3-onboard/core": "2.22.0-alpha.8", "solid-js": "^1.8.1" } } diff --git a/packages/vue/package.json b/packages/vue/package.json index bc0858eaf..92b93af64 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/vue", - "version": "2.8.0-alpha.6", + "version": "2.8.0-alpha.7", "description": "A collection of Vue Composables for integrating Web3-Onboard in to a Vue or Nuxt project. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", "keywords": [ "Ethereum", @@ -62,7 +62,7 @@ "@vueuse/core": "^8.4.2", "@vueuse/rxjs": "^8.2.0", "@web3-onboard/common": "^2.4.0-alpha.2", - "@web3-onboard/core": "2.22.0-alpha.7", + "@web3-onboard/core": "2.22.0-alpha.8", "vue-demi": "^0.12.4" }, "peerDependencies": { From c77687b38564f86381f41765381daf7790f02bf5 Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Fri, 31 May 2024 10:51:14 -0600 Subject: [PATCH 2/2] Add to ens checking block --- packages/core/src/provider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/provider.ts b/packages/core/src/provider.ts index 5fde010ef..83a07e758 100644 --- a/packages/core/src/provider.ts +++ b/packages/core/src/provider.ts @@ -328,7 +328,9 @@ export function trackWallet( const { wallets, chains } = state.get() const primaryWallet = wallets.find(wallet => wallet.label === label) const accounts = primaryWallet?.accounts || [] - + if (!isHex(chainId)) { + chainId = toHex(chainId) + } const chain = chains.find( ({ namespace, id }) => namespace === 'evm' && id === chainId )