Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d0f4277
allow instantiation with only chainid
leightkt Mar 13, 2023
5bb32e8
update docs
leightkt Mar 14, 2023
6d3cd23
Merge branch 'develop' into allow-instantiation-with-only-chainid
leightkt Mar 14, 2023
49d4f60
update common and core package references
leightkt Mar 14, 2023
cbc69de
update all packages that use core and common
leightkt Mar 14, 2023
dc8e823
update related package versions, add rpcUrl label and token to setChain
leightkt Mar 15, 2023
8e308f0
update keepkey
leightkt Mar 15, 2023
cdc6618
Merge branch 'develop' into allow-instantiation-with-only-chainid
leightkt Mar 15, 2023
a760fd4
Merge branch 'develop' into allow-instantiation-with-only-chainid
leightkt Mar 15, 2023
3cd269c
update vue package with correct versioning
leightkt Mar 15, 2023
80ea016
Merge branch 'allow-instantiation-with-only-chainid' of github.com:bl…
leightkt Mar 15, 2023
102e4ee
update chain in state when new values passed to setChain
leightkt Mar 16, 2023
8f09d3a
add chain validation to update chain
leightkt Mar 16, 2023
ec18242
Update packages/core/src/chain.ts
leightkt Mar 17, 2023
fa6b744
add conditional check for rpcUrl, label, and token
leightkt Mar 17, 2023
ca5cc3c
correct package versions
leightkt Mar 20, 2023
dc0d18c
Merge branch 'develop' into allow-instantiation-with-only-chainid
leightkt Mar 20, 2023
a67d86c
versioning update, prettier cleanup
leightkt Mar 20, 2023
fe1f369
add type notes for improved devEx
leightkt Mar 20, 2023
e66b6c0
keep react package readme in line with docs
leightkt Mar 20, 2023
8e0d903
add other type comments
leightkt Mar 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,31 @@
"type": "module",
"dependencies": {
"bnc-sdk": "^4.6.6",
"@web3-onboard/coinbase": "^2.1.4",
"@web3-onboard/core": "^2.15.6-alpha.2",
"@web3-onboard/dcent": "^2.2.3",
"@web3-onboard/enkrypt": "^2.0.0",
"@web3-onboard/fortmatic": "^2.0.14",
"@web3-onboard/gas": "^2.1.4",
"@web3-onboard/gnosis": "^2.1.6",
"@web3-onboard/infinity-wallet": "^2.0.0",
"@web3-onboard/injected-wallets": "^2.8.1",
"@web3-onboard/keepkey": "^2.3.3",
"@web3-onboard/keystone": "^2.3.3",
"@web3-onboard/ledger": "^2.4.2",
"@web3-onboard/magic": "^2.1.3",
"@web3-onboard/coinbase": "^2.2.1-alpha.1",
"@web3-onboard/core": "^2.15.6-alpha.3",
"@web3-onboard/dcent": "^2.2.4-alpha.1",
"@web3-onboard/enkrypt": "^2.0.1-alpha.1",
"@web3-onboard/fortmatic": "^2.0.16-alpha.1",
"@web3-onboard/gas": "^2.1.5-alpha.1",
"@web3-onboard/gnosis": "^2.1.7-alpha.1",
"@web3-onboard/infinity-wallet": "^2.0.1-alpha.1",
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
"@web3-onboard/keepkey": "^2.3.4-alpha.1",
"@web3-onboard/keystone": "^2.3.4-alpha.1",
"@web3-onboard/ledger": "^2.4.3-alpha.1",
"@web3-onboard/magic": "^2.1.4-alpha.1",
"@web3-onboard/mew-wallet": "^2.0.0",
"@web3-onboard/portis": "^2.1.3",
"@web3-onboard/sequence": "^2.0.4",
"@web3-onboard/taho": "^2.0.0",
"@web3-onboard/torus": "^2.2.0",
"@web3-onboard/transaction-preview": "^2.0.4",
"@web3-onboard/trezor": "^2.3.3",
"@web3-onboard/trust": "^2.0.0",
"@web3-onboard/uauth": "^2.0.1",
"@web3-onboard/walletconnect": "^2.3.2",
"@web3-onboard/web3auth": "^2.1.4",
"@web3-onboard/xdefi": "^2.0.0",
"@web3-onboard/portis": "^2.1.4-alpha.1",
"@web3-onboard/sequence": "^2.0.5-alpha.1",
"@web3-onboard/taho": "^2.0.1-alpha.1",
"@web3-onboard/torus": "^2.2.2-alpha.1",
"@web3-onboard/transaction-preview": "^2.0.5-alpha.1",
"@web3-onboard/trezor": "^2.3.4-alpha.1",
"@web3-onboard/trust": "^2.0.1-alpha.1",
"@web3-onboard/uauth": "^2.0.2-alpha.1",
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
"@web3-onboard/web3auth": "^2.1.5-alpha.1",
"@web3-onboard/xdefi": "^2.0.1-alpha.1",
"animejs": "^3.2.1",
"ethers": "^5.7.0"
}
Expand Down
15 changes: 10 additions & 5 deletions docs/src/routes/docs/[...3]modules/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ An array of Chains that your app supports:
```ts
type Chain = {
id: ChainId // hex encoded string, eg '0x1' for Ethereum Mainnet
namespace?: 'evm' // string indicating chain namespace. Defaults to 'evm' but will allow other chain namespaces in the future
rpcUrl: string // used for network requests
label: string // used for display, eg Ethereum Mainnet
token: TokenSymbol // the native token symbol, eg ETH, BNB, MATIC
namespace?: 'evm' // string indicating chain namespace. Defaults to 'evm' but will allow other chain namespaces in the future
// PLEASE NOTE: Some wallets require an rpcUrl, label, and token for actions such as adding a new chain.
// It is recommended to include rpcUrl, label, and token for full functionality.
rpcUrl?: string // Recommended to include. Used for network requests.
label?: string // Recommended to include. Used for display, eg Ethereum Mainnet.
token?: TokenSymbol // Recommended to include. The native token symbol, eg ETH, BNB, MATIC.
color?: string // the color used to represent the chain and will be used as a background for the icon
icon?: string // the icon to represent the chain
publicRpcUrl?: string // an optional public RPC used when adding a new chain config to the wallet
Expand Down Expand Up @@ -967,12 +969,15 @@ type SetChainOptions = {
chainId: string // hex encoded string
chainNamespace?: 'evm' // defaults to 'evm' (currently the only valid value, but will add more in future updates)
wallet?: string // the wallet.label of the wallet to set chain
rpcUrl?: string // if chain was instantiated without rpcUrl, include here. Used for network requests
token?: string // if chain was instantiated without token, include here. Used for display, eg Ethereum Mainnet
label?: string // if chain was instantiated without label, include here. The native token symbol, eg ETH, BNB, MATIC
}

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

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.
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.

## Custom Styling

Expand Down
10 changes: 8 additions & 2 deletions docs/src/routes/docs/[...3]modules/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ setPrimaryWallet(wallets[1], wallets[1].accounts[2].address)

## `useSetChain`

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.
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.

```typescript
import { useSetChain } from '@web3-onboard/react'
Expand All @@ -196,7 +196,13 @@ type UseSetChain = (
type SetChainOptions = {
chainId: string
chainNamespace?: string
wallet?: WalletState['label']
wallet?: WalletState['label'],
// if chain was instantiated without rpcUrl, include here. Used for network requests
rpcUrl?: string,
// if chain was instantiated without token, include here. Used for display, eg Ethereum Mainnet
label?: string,
// if chain was instantiated without label, include here. The native token symbol, eg ETH, BNB, MATIC
token?: string,
}

const [
Expand Down
4 changes: 2 additions & 2 deletions examples/with-ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@web3-onboard/ledger": "^2.1.6",
"@web3-onboard/react": "^2.6.7-alpha.2",
"@web3-onboard/ledger": "^2.4.3-alpha.1",
"@web3-onboard/react": "^2.6.7-alpha.3",
"next": "12.2.4",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand Down
32 changes: 16 additions & 16 deletions examples/with-nextjs-13/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
"@types/node": "18.11.11",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"@web3-onboard/coinbase": "^2.1.3",
"@web3-onboard/dcent": "^2.2.1",
"@web3-onboard/fortmatic": "^2.0.14",
"@web3-onboard/gnosis": "^2.1.3",
"@web3-onboard/injected-wallets": "^2.6.2",
"@web3-onboard/keepkey": "^2.3.1",
"@web3-onboard/keystone": "^2.3.1",
"@web3-onboard/ledger": "^2.3.1",
"@web3-onboard/magic": "^2.1.3",
"@web3-onboard/coinbase": "^2.2.1-alpha.1",
"@web3-onboard/dcent": "^2.2.4-alpha.1",
"@web3-onboard/fortmatic": "^2.0.16-alpha.1",
"@web3-onboard/gnosis": "^2.1.7-alpha.1",
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
"@web3-onboard/keepkey": "^2.3.4-alpha.1",
"@web3-onboard/keystone": "^2.3.4-alpha.1",
"@web3-onboard/ledger": "^2.4.3-alpha.1",
"@web3-onboard/magic": "^2.1.4-alpha.1",
"@web3-onboard/mew-wallet": "^2.0.0",
"@web3-onboard/portis": "^2.1.3",
"@web3-onboard/react": "^2.6.7-alpha.2",
"@web3-onboard/sequence": "^2.0.3",
"@web3-onboard/taho": "^2.0.0",
"@web3-onboard/torus": "^2.1.3",
"@web3-onboard/trezor": "^2.3.1",
"@web3-onboard/walletconnect": "^2.1.3",
"@web3-onboard/portis": "^2.1.4-alpha.1",
"@web3-onboard/react": "^2.6.7-alpha.3",
"@web3-onboard/sequence": "^2.0.5-alpha.1",
"@web3-onboard/taho": "^2.0.1-alpha.1",
"@web3-onboard/torus": "^2.2.2-alpha.1",
"@web3-onboard/trezor": "^2.3.4-alpha.1",
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
"ethers": "^5.7.2",
"next": "13.1.6",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@web3-onboard/react": "2.6.7-alpha.2",
"@web3-onboard/react": "2.6.7-alpha.3",
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/with-sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"type": "module",
"dependencies": {
"@fontsource/fira-mono": "^4.5.10",
"@web3-onboard/core": "^2.15.4",
"@web3-onboard/injected-wallets": "^2.8.1",
"@web3-onboard/walletconnect": "^2.3.1",
"@web3-onboard/core": "^2.15.6-alpha.3",
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
"buffer": "^6.0.3"
}
}
30 changes: 15 additions & 15 deletions examples/with-vite-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
"preview": "vite preview"
},
"dependencies": {
"@web3-onboard/coinbase": "^2.1.3",
"@web3-onboard/dcent": "^2.2.1",
"@web3-onboard/fortmatic": "^2.0.14",
"@web3-onboard/gnosis": "^2.1.5",
"@web3-onboard/injected-wallets": "^2.6.2",
"@web3-onboard/keepkey": "^2.3.1",
"@web3-onboard/keystone": "^2.3.1",
"@web3-onboard/ledger": "^2.3.1",
"@web3-onboard/magic": "^2.1.3",
"@web3-onboard/coinbase": "^2.2.1-alpha.1",
"@web3-onboard/dcent": "^2.2.4-alpha.1",
"@web3-onboard/fortmatic": "^2.0.16-alpha.1",
"@web3-onboard/gnosis": "^2.1.7-alpha.1",
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
"@web3-onboard/keepkey": "^2.3.4-alpha.1",
"@web3-onboard/keystone": "^2.3.4-alpha.1",
"@web3-onboard/ledger": "^2.4.3-alpha.1",
"@web3-onboard/magic": "^2.1.4-alpha.1",
"@web3-onboard/mew": "^2.1.3",
"@web3-onboard/portis": "^2.1.3",
"@web3-onboard/react": "^2.6.7-alpha.2",
"@web3-onboard/sequence": "^2.0.3",
"@web3-onboard/portis": "^2.1.4-alpha.1",
"@web3-onboard/react": "^2.6.7-alpha.3",
"@web3-onboard/sequence": "^2.0.5-alpha.1",
"@web3-onboard/tallyho": "^2.0.1",
"@web3-onboard/torus": "^2.1.3",
"@web3-onboard/trezor": "^2.3.1",
"@web3-onboard/walletconnect": "^2.2.0",
"@web3-onboard/torus": "^2.2.2-alpha.1",
"@web3-onboard/trezor": "^2.3.4-alpha.1",
"@web3-onboard/walletconnect": "^2.3.3-alpha.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/with-vuejs-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"serve": "vite preview"
},
"dependencies": {
"@web3-onboard/injected-wallets": "^2.6.2",
"@web3-onboard/vue": "^2.5.7-alpha.2",
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
"@web3-onboard/vue": "^2.5.7-alpha.3",
"vue": "^2.7.14",
"vue-template-compiler": "2.7.14"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/with-vuejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
},
"dependencies": {
"@web3-onboard/injected-wallets": "^2.6.2",
"@web3-onboard/vue": "^2.5.7-alpha.2",
"@web3-onboard/injected-wallets": "^2.8.3-alpha.1",
"@web3-onboard/vue": "^2.5.7-alpha.3",
"pinia": "^2.0.29",
"vue": "^3.2.45",
"vue-router": "^4.1.6"
Expand Down
4 changes: 2 additions & 2 deletions packages/coinbase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/coinbase",
"version": "2.2.0",
"version": "2.2.1-alpha.1",
"description": "Coinbase SDK wallet 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 Expand Up @@ -59,6 +59,6 @@
},
"dependencies": {
"@coinbase/wallet-sdk": "^3.6.0",
"@web3-onboard/common": "^2.2.3"
"@web3-onboard/common": "^2.2.4-alpha.1"
}
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/common",
"version": "2.2.3",
"version": "2.2.4-alpha.1",
"description": "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
31 changes: 27 additions & 4 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,38 @@ export enum ProviderRpcErrorCode {
}

export interface Chain {
/**
* String indicating chain namespace.
* Defaults to 'evm' but will allow other chain namespaces in the future
*/
namespace?: 'evm'
/* Hex encoded string, eg '0x1' for Ethereum Mainnet */
id: ChainId
rpcUrl: string
label: string
token: TokenSymbol // eg ETH, BNB, MATIC
/**
* Recommended to include. Used for network requests
* (eg Alchemy or Infura end point).
* PLEASE NOTE: Some wallets require an rpcUrl, label,
* and token for actions such as adding a new chain.
* It is recommended to include rpcUrl, label,
* and token for full functionality.
*/
rpcUrl?: string
/* Recommended to include. Used for display, eg Ethereum Mainnet */
label?: string
/* Recommended to include. The native token symbol, eg ETH, BNB, MATIC */
token?: TokenSymbol
/**
* The color used to represent the chain and
* will be used as a background for the icon
*/
color?: string
icon?: string // svg string
/* Svg string. The icon to represent the chain */
icon?: string
/* Related to ConnectionInfo from 'ethers/lib/utils' */
providerConnectionInfo?: ConnectionInfo
/* An optional public RPC used when adding a new chain config to the wallet */
publicRpcUrl?: string
/* Also used when adding a new config to the wallet */
blockExplorerUrl?: string
}

Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const providerConnectionInfoValidation = Joi.object({
export const chainValidation = Joi.object({
namespace: chainNamespaceValidation,
id: chainIdValidation.required(),
rpcUrl: Joi.string().required(),
label: Joi.string().required(),
token: Joi.string().required(),
rpcUrl: Joi.string(),
label: Joi.string(),
token: Joi.string(),
icon: Joi.string(),
color: Joi.string(),
publicRpcUrl: Joi.string(),
Expand Down
13 changes: 9 additions & 4 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ An array of Chains that your app supports:
type Chain = {
id: ChainId // hex encoded string, eg '0x1' for Ethereum Mainnet
namespace?: 'evm' // string indicating chain namespace. Defaults to 'evm' but will allow other chain namespaces in the future
rpcUrl: string // used for network requests (eg Alchemy or Infura end point)
label: string // used for display, eg Ethereum Mainnet
token: TokenSymbol // the native token symbol, eg ETH, BNB, MATIC
// PLEASE NOTE: Some wallets require an rpcUrl, label, and token for actions such as adding a new chain.
// It is recommended to include rpcUrl, label, and token for full functionality.
rpcUrl?: string // Recommended to include. Used for network requests (eg Alchemy or Infura end point).
label?: string // Recommended to include. Used for display, eg Ethereum Mainnet.
token?: TokenSymbol // Recommended to include. The native token symbol, eg ETH, BNB, MATIC.
color?: string // the color used to represent the chain and will be used as a background for the icon
icon?: string // the icon to represent the chain
publicRpcUrl?: string // an optional public RPC used when adding a new chain config to the wallet
Expand Down Expand Up @@ -908,12 +910,15 @@ type SetChainOptions = {
chainId: string // hex encoded string
chainNamespace?: 'evm' // defaults to 'evm' (currently the only valid value, but will add more in future updates)
wallet?: string // the wallet.label of the wallet to set chain
rpcUrl?: string // if chain was instantiated without rpcUrl, include here. Used for network requests
token?: string // if chain was instantiated without token, include here. Used for display, eg Ethereum Mainnet
label?: string // if chain was instantiated without label, include here. The native token symbol, eg ETH, BNB, MATIC
}

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

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.
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.

## Custom Styling

Expand Down
Loading