Skip to content

Commit 838eb87

Browse files
Fixes misc validation and types. (#988)
* Fixes outdate validtion and types for injected wallets. * Fix missing account validation
1 parent df43c67 commit 838eb87

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/common",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"scripts": {
55
"build": "rollup -c",
66
"dev": "rollup -c -w",

packages/common/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export interface WalletModule {
225225
/**
226226
* @returns the wallet interface associated with the module
227227
*/
228-
getInterface: (helpers: GetInterfaceHelpers) => Promise<WalletInterface>
228+
getInterface: (helpers?: GetInterfaceHelpers) => Promise<WalletInterface>
229229
}
230230

231231
export type GetInterfaceHelpers = {

packages/core/src/validation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ const balance = Joi.any().allow(
4747
null
4848
)
4949

50-
const account = {
50+
const account = Joi.object({
5151
address: Joi.string().required(),
5252
ens,
5353
balance
54-
}
54+
})
5555

5656
const chains = Joi.array().items(chain)
5757
const accounts = Joi.array().items(account)

packages/injected/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,15 @@ const equal = {
111111
// The property on the window where the injected provider is defined
112112
// Example: window.ethereum
113113
injectedNamespace: 'ethereum',
114-
// A unique property on the provider that is used to identify the provider
114+
// A function that returns a bool indicating whether or not the provider is
115+
// of a certain identity. In this case, a unique property on the provider
116+
// is used to identify the provider.
115117
// In most cases this is in the format: `is<provider-name>`.
116-
// Example: window.ethereum.isEQLWallet
117-
providerIdentityFlag: 'isEQLWallet',
118+
// You may also include custom logic here if checking for the property
119+
// isn't sufficient.
120+
checkProviderIdentity: ({ provider }) =>
121+
!!provider && !!provider[ProviderIdentityFlag.MetaMask],
122+
118123
// A method that returns a string of the wallet icon which will be displayed
119124
getIcon: async () => (await import('<PATH_TO_ICON>')).default,
120125
// Returns a valid EIP1193 provider. In some cases the provider will need to be patched to satisfy the EIP1193 Provider interface

packages/injected/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/injected-wallets",
3-
"version": "2.0.5",
3+
"version": "2.0.6",
44
"description": "Injected wallets module for web3-onboard",
55
"module": "dist/index.js",
66
"browser": "dist/index.js",

packages/injected/src/validation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import Joi from 'joi'
44

55
const walletModule = Joi.object({
66
label: Joi.string().required(),
7-
getIcon: Joi.function().arity(1).required(),
8-
getInterface: Joi.function().arity(1).required(),
7+
getIcon: Joi.function().arity(0).required(),
8+
getInterface: Joi.function().maxArity(1).required(),
99
injectedNamespace: Joi.string().required(),
10-
checkProviderIdentity: Joi.function().arity(1).required().required(),
10+
checkProviderIdentity: Joi.function().arity(1).required(),
1111
platforms: Joi.array().items(Joi.string())
1212
})
1313

0 commit comments

Comments
 (0)