Skip to content

Commit 7d14b34

Browse files
authored
[common, core] Update: allow instantiation with only chain id (#1589)
1 parent 0600dd8 commit 7d14b34

File tree

63 files changed

+347
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+347
-202
lines changed

docs/package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,31 @@
5555
"type": "module",
5656
"dependencies": {
5757
"bnc-sdk": "^4.6.6",
58-
"@web3-onboard/coinbase": "^2.1.4",
59-
"@web3-onboard/core": "^2.15.6-alpha.2",
60-
"@web3-onboard/dcent": "^2.2.3",
61-
"@web3-onboard/enkrypt": "^2.0.0",
62-
"@web3-onboard/fortmatic": "^2.0.14",
63-
"@web3-onboard/gas": "^2.1.4",
64-
"@web3-onboard/gnosis": "^2.1.6",
65-
"@web3-onboard/infinity-wallet": "^2.0.0",
66-
"@web3-onboard/injected-wallets": "^2.8.1",
67-
"@web3-onboard/keepkey": "^2.3.3",
68-
"@web3-onboard/keystone": "^2.3.3",
69-
"@web3-onboard/ledger": "^2.4.2",
70-
"@web3-onboard/magic": "^2.1.3",
58+
"@web3-onboard/coinbase": "^2.2.1-alpha.1",
59+
"@web3-onboard/core": "^2.15.6-alpha.3",
60+
"@web3-onboard/dcent": "^2.2.4-alpha.1",
61+
"@web3-onboard/enkrypt": "^2.0.1-alpha.1",
62+
"@web3-onboard/fortmatic": "^2.0.16-alpha.1",
63+
"@web3-onboard/gas": "^2.1.5-alpha.1",
64+
"@web3-onboard/gnosis": "^2.1.7-alpha.1",
65+
"@web3-onboard/infinity-wallet": "^2.0.1-alpha.1",
66+
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
67+
"@web3-onboard/keepkey": "^2.3.4-alpha.1",
68+
"@web3-onboard/keystone": "^2.3.4-alpha.1",
69+
"@web3-onboard/ledger": "^2.4.3-alpha.1",
70+
"@web3-onboard/magic": "^2.1.4-alpha.1",
7171
"@web3-onboard/mew-wallet": "^2.0.0",
72-
"@web3-onboard/portis": "^2.1.3",
73-
"@web3-onboard/sequence": "^2.0.4",
74-
"@web3-onboard/taho": "^2.0.0",
75-
"@web3-onboard/torus": "^2.2.0",
76-
"@web3-onboard/transaction-preview": "^2.0.4",
77-
"@web3-onboard/trezor": "^2.3.3",
78-
"@web3-onboard/trust": "^2.0.0",
79-
"@web3-onboard/uauth": "^2.0.1",
80-
"@web3-onboard/walletconnect": "^2.3.2",
81-
"@web3-onboard/web3auth": "^2.1.4",
82-
"@web3-onboard/xdefi": "^2.0.0",
72+
"@web3-onboard/portis": "^2.1.4-alpha.1",
73+
"@web3-onboard/sequence": "^2.0.5-alpha.1",
74+
"@web3-onboard/taho": "^2.0.1-alpha.1",
75+
"@web3-onboard/torus": "^2.2.2-alpha.1",
76+
"@web3-onboard/transaction-preview": "^2.0.5-alpha.1",
77+
"@web3-onboard/trezor": "^2.3.4-alpha.1",
78+
"@web3-onboard/trust": "^2.0.1-alpha.1",
79+
"@web3-onboard/uauth": "^2.0.2-alpha.1",
80+
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
81+
"@web3-onboard/web3auth": "^2.1.5-alpha.1",
82+
"@web3-onboard/xdefi": "^2.0.1-alpha.1",
8383
"animejs": "^3.2.1",
8484
"ethers": "^5.7.0"
8585
}

docs/src/routes/docs/[...3]modules/core.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ An array of Chains that your app supports:
113113
```ts
114114
type Chain = {
115115
id: ChainId // hex encoded string, eg '0x1' for Ethereum Mainnet
116-
namespace?: 'evm' // string indicating chain namespace. Defaults to 'evm' but will allow other chain namespaces in the future
117-
rpcUrl: string // used for network requests
118-
label: string // used for display, eg Ethereum Mainnet
119-
token: TokenSymbol // the native token symbol, eg ETH, BNB, MATIC
116+
namespace?: 'evm' // string indicating chain namespace. Defaults to 'evm' but will allow other chain namespaces in the future
117+
// PLEASE NOTE: Some wallets require an rpcUrl, label, and token for actions such as adding a new chain.
118+
// It is recommended to include rpcUrl, label, and token for full functionality.
119+
rpcUrl?: string // Recommended to include. Used for network requests.
120+
label?: string // Recommended to include. Used for display, eg Ethereum Mainnet.
121+
token?: TokenSymbol // Recommended to include. The native token symbol, eg ETH, BNB, MATIC.
120122
color?: string // the color used to represent the chain and will be used as a background for the icon
121123
icon?: string // the icon to represent the chain
122124
publicRpcUrl?: string // an optional public RPC used when adding a new chain config to the wallet
@@ -967,12 +969,15 @@ type SetChainOptions = {
967969
chainId: string // hex encoded string
968970
chainNamespace?: 'evm' // defaults to 'evm' (currently the only valid value, but will add more in future updates)
969971
wallet?: string // the wallet.label of the wallet to set chain
972+
rpcUrl?: string // if chain was instantiated without rpcUrl, include here. Used for network requests
973+
token?: string // if chain was instantiated without token, include here. Used for display, eg Ethereum Mainnet
974+
label?: string // if chain was instantiated without label, include here. The native token symbol, eg ETH, BNB, MATIC
970975
}
971976

972977
const success = await onboard.setChain({ chainId: '0x89' })
973978
```
974979

975-
The `setChain` methods takes an options object with a `chainId` property hex encoded string for the chain id to switch to. The chain id must be one of the chains that Onboard was initialized with. If the wallet supports programatically adding and switching the chain, then the user will be prompted to do so, if not, then a modal will be displayed indicating to the user that they need to switch chains to continue. The `setChain` method returns a promise that resolves when either the user has confirmed the chain switch, or has dismissed the modal and resolves with a boolean indicating if the switch network was successful or not. The `setChain` method will by default switch the first wallet (the most recently connected) in the `wallets` array. A specific wallet can be targeted by passing in the `wallet.label` in the options object as the `wallet` parameter.
980+
The `setChain` methods takes an options object with a `chainId` property hex encoded string for the chain id to switch to. The chain id must be one of the chains that Onboard was initialized with. If the wallet supports programatically adding and switching the chain, then the user will be prompted to do so, if not, then a modal will be displayed indicating to the user that they need to switch chains to continue. The `setChain` method returns a promise that resolves when either the user has confirmed the chain switch, or has dismissed the modal and resolves with a boolean indicating if the switch network was successful or not. The `setChain` method will by default switch the first wallet (the most recently connected) in the `wallets` array. A specific wallet can be targeted by passing in the `wallet.label` in the options object as the `wallet` parameter. If a chain was instantiated without an rpcUrl, token, or label, add these options for wallets that require this information for adding a new chain.
976981

977982
## Custom Styling
978983

docs/src/routes/docs/[...3]modules/react.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ setPrimaryWallet(wallets[1], wallets[1].accounts[2].address)
177177

178178
## `useSetChain`
179179

180-
This hook allows you to set the chain of a user's connected wallet, keep track of the current chain the user is connected to and the status of setting the chain. Passing in a wallet label will operate on that connected wallet, otherwise it will default to the last connected wallet.
180+
This hook allows you to set the chain of a user's connected wallet, keep track of the current chain the user is connected to and the status of setting the chain. Passing in a wallet label will operate on that connected wallet, otherwise it will default to the last connected wallet. If a chain was instantiated without an rpcUrl, token, or label, add these options for wallets that require this information for adding a new chain.
181181

182182
```typescript
183183
import { useSetChain } from '@web3-onboard/react'
@@ -196,7 +196,13 @@ type UseSetChain = (
196196
type SetChainOptions = {
197197
chainId: string
198198
chainNamespace?: string
199-
wallet?: WalletState['label']
199+
wallet?: WalletState['label'],
200+
// if chain was instantiated without rpcUrl, include here. Used for network requests
201+
rpcUrl?: string,
202+
// if chain was instantiated without token, include here. Used for display, eg Ethereum Mainnet
203+
label?: string,
204+
// if chain was instantiated without label, include here. The native token symbol, eg ETH, BNB, MATIC
205+
token?: string,
200206
}
201207

202208
const [

examples/with-ledger/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@web3-onboard/ledger": "^2.1.6",
13-
"@web3-onboard/react": "^2.6.7-alpha.2",
12+
"@web3-onboard/ledger": "^2.4.3-alpha.1",
13+
"@web3-onboard/react": "^2.6.7-alpha.3",
1414
"next": "12.2.4",
1515
"react": "18.2.0",
1616
"react-dom": "18.2.0"

examples/with-nextjs-13/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
"@types/node": "18.11.11",
1313
"@types/react": "18.0.26",
1414
"@types/react-dom": "18.0.9",
15-
"@web3-onboard/coinbase": "^2.1.3",
16-
"@web3-onboard/dcent": "^2.2.1",
17-
"@web3-onboard/fortmatic": "^2.0.14",
18-
"@web3-onboard/gnosis": "^2.1.3",
19-
"@web3-onboard/injected-wallets": "^2.6.2",
20-
"@web3-onboard/keepkey": "^2.3.1",
21-
"@web3-onboard/keystone": "^2.3.1",
22-
"@web3-onboard/ledger": "^2.3.1",
23-
"@web3-onboard/magic": "^2.1.3",
15+
"@web3-onboard/coinbase": "^2.2.1-alpha.1",
16+
"@web3-onboard/dcent": "^2.2.4-alpha.1",
17+
"@web3-onboard/fortmatic": "^2.0.16-alpha.1",
18+
"@web3-onboard/gnosis": "^2.1.7-alpha.1",
19+
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
20+
"@web3-onboard/keepkey": "^2.3.4-alpha.1",
21+
"@web3-onboard/keystone": "^2.3.4-alpha.1",
22+
"@web3-onboard/ledger": "^2.4.3-alpha.1",
23+
"@web3-onboard/magic": "^2.1.4-alpha.1",
2424
"@web3-onboard/mew-wallet": "^2.0.0",
25-
"@web3-onboard/portis": "^2.1.3",
26-
"@web3-onboard/react": "^2.6.7-alpha.2",
27-
"@web3-onboard/sequence": "^2.0.3",
28-
"@web3-onboard/taho": "^2.0.0",
29-
"@web3-onboard/torus": "^2.1.3",
30-
"@web3-onboard/trezor": "^2.3.1",
31-
"@web3-onboard/walletconnect": "^2.1.3",
25+
"@web3-onboard/portis": "^2.1.4-alpha.1",
26+
"@web3-onboard/react": "^2.6.7-alpha.3",
27+
"@web3-onboard/sequence": "^2.0.5-alpha.1",
28+
"@web3-onboard/taho": "^2.0.1-alpha.1",
29+
"@web3-onboard/torus": "^2.2.2-alpha.1",
30+
"@web3-onboard/trezor": "^2.3.4-alpha.1",
31+
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
3232
"ethers": "^5.7.2",
3333
"next": "13.1.6",
3434
"react": "18.2.0",

examples/with-nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@web3-onboard/react": "2.6.7-alpha.2",
12+
"@web3-onboard/react": "2.6.7-alpha.3",
1313
"next": "12.2.5",
1414
"react": "18.2.0",
1515
"react-dom": "18.2.0"

examples/with-sveltekit/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"type": "module",
3333
"dependencies": {
3434
"@fontsource/fira-mono": "^4.5.10",
35-
"@web3-onboard/core": "^2.15.4",
36-
"@web3-onboard/injected-wallets": "^2.8.1",
37-
"@web3-onboard/walletconnect": "^2.3.1",
35+
"@web3-onboard/core": "^2.15.6-alpha.3",
36+
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
37+
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
3838
"buffer": "^6.0.3"
3939
}
4040
}

examples/with-vite-react/package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"@web3-onboard/coinbase": "^2.1.3",
13-
"@web3-onboard/dcent": "^2.2.1",
14-
"@web3-onboard/fortmatic": "^2.0.14",
15-
"@web3-onboard/gnosis": "^2.1.5",
16-
"@web3-onboard/injected-wallets": "^2.6.2",
17-
"@web3-onboard/keepkey": "^2.3.1",
18-
"@web3-onboard/keystone": "^2.3.1",
19-
"@web3-onboard/ledger": "^2.3.1",
20-
"@web3-onboard/magic": "^2.1.3",
12+
"@web3-onboard/coinbase": "^2.2.1-alpha.1",
13+
"@web3-onboard/dcent": "^2.2.4-alpha.1",
14+
"@web3-onboard/fortmatic": "^2.0.16-alpha.1",
15+
"@web3-onboard/gnosis": "^2.1.7-alpha.1",
16+
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
17+
"@web3-onboard/keepkey": "^2.3.4-alpha.1",
18+
"@web3-onboard/keystone": "^2.3.4-alpha.1",
19+
"@web3-onboard/ledger": "^2.4.3-alpha.1",
20+
"@web3-onboard/magic": "^2.1.4-alpha.1",
2121
"@web3-onboard/mew": "^2.1.3",
22-
"@web3-onboard/portis": "^2.1.3",
23-
"@web3-onboard/react": "^2.6.7-alpha.2",
24-
"@web3-onboard/sequence": "^2.0.3",
22+
"@web3-onboard/portis": "^2.1.4-alpha.1",
23+
"@web3-onboard/react": "^2.6.7-alpha.3",
24+
"@web3-onboard/sequence": "^2.0.5-alpha.1",
2525
"@web3-onboard/tallyho": "^2.0.1",
26-
"@web3-onboard/torus": "^2.1.3",
27-
"@web3-onboard/trezor": "^2.3.1",
28-
"@web3-onboard/walletconnect": "^2.2.0",
26+
"@web3-onboard/torus": "^2.2.2-alpha.1",
27+
"@web3-onboard/trezor": "^2.3.4-alpha.1",
28+
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
2929
"react": "^18.2.0",
3030
"react-dom": "^18.2.0"
3131
},

examples/with-vuejs-v2/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"serve": "vite preview"
88
},
99
"dependencies": {
10-
"@web3-onboard/injected-wallets": "^2.6.2",
11-
"@web3-onboard/vue": "^2.5.7-alpha.2",
10+
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
11+
"@web3-onboard/vue": "^2.5.7-alpha.3",
1212
"vue": "^2.7.14",
1313
"vue-template-compiler": "2.7.14"
1414
},

examples/with-vuejs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
99
},
1010
"dependencies": {
11-
"@web3-onboard/injected-wallets": "^2.6.2",
12-
"@web3-onboard/vue": "^2.5.7-alpha.2",
11+
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
12+
"@web3-onboard/vue": "^2.5.7-alpha.3",
1313
"pinia": "^2.0.29",
1414
"vue": "^3.2.45",
1515
"vue-router": "^4.1.6"

0 commit comments

Comments
 (0)