|
1 | | -import Joi from 'joi' |
2 | | -import type { ChainId, WalletInit, WalletModule } from '@web3-onboard/common' |
| 1 | +import Joi, { ObjectSchema, Schema } from 'joi' |
| 2 | +import type { Chain, ChainId, WalletInit, WalletModule } from '@web3-onboard/common' |
3 | 3 |
|
4 | 4 | import type { |
5 | 5 | InitOptions, |
@@ -28,16 +28,19 @@ const providerConnectionInfo = Joi.object({ |
28 | 28 | timeout: Joi.number() |
29 | 29 | }) |
30 | 30 |
|
31 | | -const chain = Joi.object({ |
| 31 | +const chainValidationParams: Record<keyof Chain, Schema | ObjectSchema> = { |
32 | 32 | namespace: chainNamespace, |
33 | 33 | id: chainId.required(), |
34 | 34 | rpcUrl: Joi.string().required(), |
35 | 35 | label: Joi.string().required(), |
36 | 36 | token: Joi.string().required(), |
37 | 37 | icon: Joi.string(), |
38 | 38 | color: Joi.string(), |
39 | | - providerConnectionInfo: providerConnectionInfo |
40 | | -}) |
| 39 | + publicRpcUrl: Joi.string(), |
| 40 | + blockExplorerUrl: Joi.string(), |
| 41 | + providerConnectionInfo |
| 42 | +} |
| 43 | +const chain = Joi.object(chainValidationParams) |
41 | 44 |
|
42 | 45 | const connectedChain = Joi.object({ |
43 | 46 | namespace: chainNamespace.required(), |
@@ -207,6 +210,7 @@ export function validateString(str: string): ValidateReturn { |
207 | 210 |
|
208 | 211 | export function validateSetChainOptions(data: { |
209 | 212 | chainId: ChainId |
| 213 | + chainNamespace?: string |
210 | 214 | wallet?: WalletState['label'] |
211 | 215 | }): ValidateReturn { |
212 | 216 | return validate(setChainOptions, data) |
|
0 commit comments