Skip to content

Commit

Permalink
Fix: Walletconnet - wallet switching chains and handling int and hex …
Browse files Browse the repository at this point in the history
…chainIds (#1682)

* Wallet switching chains now working properly and setting required chains to the config chains in w3o

* Fix web3auth ci build
  • Loading branch information
Adamj1232 authored May 8, 2023
1 parent 5153729 commit 2a0b2b3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ jobs:
- node-build-steps
build-web3auth:
docker:
- image: cimg/node:16.13.1
- image: cimg/node:16.18.1
working_directory: ~/web3-onboard-monorepo/packages/web3auth
steps:
- node-build-steps
Expand Down Expand Up @@ -511,7 +511,7 @@ jobs:
- node-staging-build-steps
build-staging-web3auth:
docker:
- image: cimg/node:16.13.1
- image: cimg/node:16.18.1
working_directory: ~/web3-onboard-monorepo/packages/web3auth
steps:
- node-staging-build-steps
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@web3-onboard/torus": "^2.2.4-alpha.1",
"@web3-onboard/taho": "^2.0.3-alpha.1",
"@web3-onboard/web3auth": "^2.2.2-alpha.1",
"@web3-onboard/walletconnect": "^2.3.7-alpha.1",
"@web3-onboard/walletconnect": "^2.3.7-alpha.2",
"@web3-onboard/enkrypt": "^2.0.3-alpha.1",
"@web3-onboard/mew-wallet": "^2.0.2-alpha.1",
"@web3-onboard/xdefi": "^2.0.3-alpha.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/walletconnect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/walletconnect",
"version": "2.3.7-alpha.1",
"version": "2.3.7-alpha.2",
"description": "WalletConnect SDK module for connecting to Web3-Onboard. 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, 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",
Expand Down
6 changes: 4 additions & 2 deletions packages/walletconnect/src/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function walletConnect(options?: WalletConnectOptions): WalletInit {
? // @ts-ignore
// Required as WC package does not support hex numbers
requiredChains.map(chainID => parseInt(chainID))
: [1]
: [...chains.map(({ id }) => parseInt(id, 16))]

const connector = await EthereumProvider.init({
projectId,
Expand Down Expand Up @@ -136,7 +136,9 @@ function walletConnect(options?: WalletConnectOptions): WalletInit {
.pipe(takeUntil(this.disconnected$))
.subscribe({
next: chainId => {
const hexChainId = `0x${chainId.toString(16)}`
const hexChainId = isHexString(chainId)
? chainId
: `0x${chainId.toString(16)}`
this.emit('chainChanged', hexChainId)
},
error: console.warn
Expand Down

0 comments on commit 2a0b2b3

Please sign in to comment.