Skip to content

Commit

Permalink
fix: gets chains from approved accounts (#2562)
Browse files Browse the repository at this point in the history
Co-authored-by: tomiir <[email protected]>
  • Loading branch information
ganchoradkov and tomiir authored Jul 23, 2024
1 parent 30acdfc commit 2f95f1a
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 102 deletions.
4 changes: 2 additions & 2 deletions apps/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"@tanstack/react-query": "5.24.8",
"@wagmi/core": "2.11.6",
"@wagmi/connectors": "5.0.21",
"@walletconnect/ethereum-provider": "2.13.0",
"@walletconnect/utils": "2.13.1",
"@walletconnect/ethereum-provider": "2.14.0",
"@walletconnect/utils": "2.14.0",
"@web3modal/ethers": "workspace:*",
"@web3modal/siwe": "workspace:*",
"@web3modal/solana": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@coinbase/wallet-sdk": "4.0.3",
"@walletconnect/ethereum-provider": "2.14.0",
"@walletconnect/utils": "2.14.0",
"@web3modal/common": "workspace:*",
"@web3modal/wallet": "workspace:*",
"@web3modal/polyfills": "workspace:*",
Expand Down
5 changes: 4 additions & 1 deletion packages/ethers/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Web3ModalScaffold } from '@web3modal/scaffold'
import { ConstantsUtil, PresetsUtil, HelpersUtil } from '@web3modal/scaffold-utils'
import { ConstantsUtil as CommonConstantsUtil } from '@web3modal/common'
import EthereumProvider, { OPTIONAL_METHODS } from '@walletconnect/ethereum-provider'
import { getChainsFromAccounts } from '@walletconnect/utils'
import type { Web3ModalSIWEClient } from '@web3modal/siwe'
import { ConstantsUtil as CommonConstants } from '@web3modal/common'
import type { Chain as AvailableChain } from '@web3modal/common'
Expand Down Expand Up @@ -171,7 +172,9 @@ export class Web3Modal extends Web3ModalScaffold {
}
const ns = provider.signer?.session?.namespaces
const nsMethods = ns?.[ConstantsUtil.EIP155]?.methods
const nsChains = ns?.[ConstantsUtil.EIP155]?.chains
const nsChains = getChainsFromAccounts(
ns?.[ConstantsUtil.EIP155]?.accounts || []
) as CaipNetworkId[]

const result = {
supportsAllNetworks: nsMethods?.includes(ConstantsUtil.ADD_CHAIN_METHOD) ?? false,
Expand Down
1 change: 1 addition & 0 deletions packages/ethers5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@coinbase/wallet-sdk": "4.0.3",
"@walletconnect/ethereum-provider": "2.14.0",
"@walletconnect/utils": "2.14.0",
"@web3modal/common": "workspace:*",
"@web3modal/polyfills": "workspace:*",
"@web3modal/scaffold": "workspace:*",
Expand Down
5 changes: 4 additions & 1 deletion packages/ethers5/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { Web3ModalSIWEClient } from '@web3modal/siwe'
import { ConstantsUtil, PresetsUtil, HelpersUtil } from '@web3modal/scaffold-utils'
import { ConstantsUtil as CommonConstantsUtil } from '@web3modal/common'
import EthereumProvider, { OPTIONAL_METHODS } from '@walletconnect/ethereum-provider'
import { getChainsFromAccounts } from '@walletconnect/utils'
import type {
Address,
Metadata,
Expand Down Expand Up @@ -146,7 +147,9 @@ export class Web3Modal extends Web3ModalScaffold {
}
const ns = provider.signer?.session?.namespaces
const nsMethods = ns?.[ConstantsUtil.EIP155]?.methods
const nsChains = ns?.[ConstantsUtil.EIP155]?.chains
const nsChains = getChainsFromAccounts(
ns?.[ConstantsUtil.EIP155]?.accounts || []
) as CaipNetworkId[]

const result = {
supportsAllNetworks: nsMethods?.includes(ConstantsUtil.ADD_CHAIN_METHOD) ?? false,
Expand Down
2 changes: 1 addition & 1 deletion packages/solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
"devDependencies": {
"@types/bn.js": "5.1.5",
"@walletconnect/types": "2.13.3"
"@walletconnect/types": "2.14.0"
},
"peerDependencies": {
"react": ">=17",
Expand Down
1 change: 1 addition & 0 deletions packages/wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
"dependencies": {
"@walletconnect/ethereum-provider": "2.14.0",
"@walletconnect/utils": "2.14.0",
"@web3modal/polyfills": "workspace:*",
"@web3modal/wallet": "workspace:*",
"@web3modal/common": "workspace:*",
Expand Down
5 changes: 4 additions & 1 deletion packages/wagmi/src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CoreHelperUtil } from '@web3modal/scaffold'
import { ConstantsUtil, PresetsUtil } from '@web3modal/scaffold-utils'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import { getChainsFromAccounts } from '@walletconnect/utils'
import { fallback, http } from 'viem'

import type { CaipNetwork, CaipNetworkId } from '@web3modal/scaffold'
Expand Down Expand Up @@ -28,7 +29,9 @@ export async function getWalletConnectCaipNetworks(connector?: Connector) {
>
const ns = provider?.signer?.session?.namespaces
const nsMethods = ns?.[ConstantsUtil.EIP155]?.methods
const nsChains = ns?.[ConstantsUtil.EIP155]?.chains as CaipNetworkId[]
const nsChains = getChainsFromAccounts(
ns?.[ConstantsUtil.EIP155]?.accounts || []
) as CaipNetworkId[]

return {
supportsAllNetworks: Boolean(nsMethods?.includes(ConstantsUtil.ADD_CHAIN_METHOD)),
Expand Down
112 changes: 16 additions & 96 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f95f1a

Please sign in to comment.