Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.1.1",
"version": "2.1.2-alpha.1",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ export interface Chain {
color?: string
icon?: string // svg string
providerConnectionInfo?: ConnectionInfo
publicRpcUrl?: string
blockExplorerUrl?: string
}

export type TokenSymbol = string // eg ETH
Expand Down
2 changes: 2 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Chain = {
token: TokenSymbol // 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
blockExplorerUrl?: string // also used when adding a new config to the wallet
}
```

Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/core",
"version": "2.2.12",
"version": "2.2.13-alpha.1",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down Expand Up @@ -41,7 +41,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/common": "^2.1.1",
"@web3-onboard/common": "^2.1.2",
"bowser": "^2.11.0",
"ethers": "5.5.3",
"eventemitter3": "^4.0.7",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ export function addNewChain(
symbol: chain.token,
decimals: 18
},
rpcUrls: [chain.rpcUrl]
rpcUrls: [chain.publicRpcUrl || chain.rpcUrl],
blockExplorerUrls: chain.blockExplorerUrl ? [chain.blockExplorerUrl] : undefined
}
]
})
Expand Down
14 changes: 9 additions & 5 deletions packages/core/src/validation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Joi from 'joi'
import type { ChainId, WalletInit, WalletModule } from '@web3-onboard/common'
import Joi, { ObjectSchema, Schema } from 'joi'
import type { Chain, ChainId, WalletInit, WalletModule } from '@web3-onboard/common'

import type {
InitOptions,
Expand Down Expand Up @@ -28,16 +28,19 @@ const providerConnectionInfo = Joi.object({
timeout: Joi.number()
})

const chain = Joi.object({
const chainValidationParams: Record<keyof Chain, Schema | ObjectSchema> = {
namespace: chainNamespace,
id: chainId.required(),
rpcUrl: Joi.string().required(),
label: Joi.string().required(),
token: Joi.string().required(),
icon: Joi.string(),
color: Joi.string(),
providerConnectionInfo: providerConnectionInfo
})
publicRpcUrl: Joi.string(),
blockExplorerUrl: Joi.string(),
providerConnectionInfo
}
const chain = Joi.object(chainValidationParams)

const connectedChain = Joi.object({
namespace: chainNamespace.required(),
Expand Down Expand Up @@ -207,6 +210,7 @@ export function validateString(str: string): ValidateReturn {

export function validateSetChainOptions(data: {
chainId: ChainId
chainNamespace?: string
wallet?: WalletState['label']
}): ValidateReturn {
return validate(setChainOptions, data)
Expand Down
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/react",
"version": "2.1.9",
"version": "2.1.10-alpha.1",
"description": "Collection of React Hooks for web3-onboard",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand All @@ -23,8 +23,8 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/core": "^2.2.12",
"@web3-onboard/common": "^2.1.1",
"@web3-onboard/core": "^2.2.13-alpha.1",
"@web3-onboard/common": "^2.1.2-alpha.1",
"use-sync-external-store": "1.0.0"
},
"peerDependencies": {
Expand Down