Skip to content

Commit 9dd5130

Browse files
mahmud-bnlnbc1QWFyb24Adamj1232
authored
[core-v2.7.0-alpha.3, common-v2.1.8-alpha.1, hw-common-v1.0.0-alpha.1, demo-v2.0.8]: Feature -hw common (#1203)
* Initialization * bump version * circleci build * build * comments updates * Fixes dependency and versioning issues * Pin ethereumjs common version to fix type mismatch * Change to serial build to ensure build order * Version bumps * Move more hw specific code * Update yarn.lock * Fix svelte build issues * Fix hw imports * Format rollup config * Extract common validation logic * Update yarn.lock * Revert big number as ethers cannot handle it * Update package.json files * Import validation functions for gas module * Update lock file * Fix versions * Update packages/vue/package.json Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> * Update packages/react/package.json Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> Co-authored-by: Aaron Barnard <abarnard@protonmail.com> Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
1 parent b8a05e9 commit 9dd5130

Some content is hidden

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

65 files changed

+621
-391
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ jobs:
291291
working_directory: ~/web3-onboard-monorepo/packages/gas
292292
steps:
293293
- node-build-steps
294+
build-hw-common:
295+
docker:
296+
- image: cimg/node:16.13.1
297+
working_directory: ~/web3-onboard-monorepo/packages/hw-common
298+
steps:
299+
- node-build-steps
294300

295301
# Build staging/Alpha releases
296302
build-staging-core:
@@ -419,6 +425,12 @@ jobs:
419425
working_directory: ~/web3-onboard-monorepo/packages/gas
420426
steps:
421427
- node-staging-build-steps
428+
build-staging-hw-common:
429+
docker:
430+
- image: cimg/node:16.13.1
431+
working_directory: ~/web3-onboard-monorepo/packages/hw-common
432+
steps:
433+
- node-staging-build-steps
422434

423435
workflows:
424436
version: 2
@@ -549,3 +561,9 @@ workflows:
549561
<<: *deploy_production_filters
550562
- build-staging-gas:
551563
<<: *deploy_staging_filters
564+
hw-common:
565+
jobs:
566+
- build-common:
567+
<<: *deploy_production_filters
568+
- build-staging-common:
569+
<<: *deploy_staging_filters

examples/with-vuejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"dependencies": {
1111
"@web3-onboard/injected-wallets": "^2.0.15",
12-
"@web3-onboard/vue": "file:.yalc/@web3-onboard/vue",
12+
"@web3-onboard/vue": "^2.1.6",
1313
"pinia": "^2.0.16",
1414
"vue": "^3.2.37",
1515
"vue-router": "^4.1.2"

examples/with-vuejs/yarn.lock

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@
939939
dependencies:
940940
vue-demi "*"
941941

942-
"@web3-onboard/common@^2.1.7", "@web3-onboard/common@^2.1.7-alpha.4":
942+
"@web3-onboard/common@^2.1.7":
943943
version "2.1.7"
944944
resolved "https://registry.yarnpkg.com/@web3-onboard/common/-/common-2.1.7.tgz#62c74726ed9dd6e8baadab1e6aec6462d62e7d2d"
945945
integrity sha512-4nJvfNl0t5D17B1jD8H9BNBtUOVDDHxyxmRyQxnv1u1D5dgdd2I/mUVGhee0xWIHgMy9ORjuJCApraYCwZfgJA==
@@ -950,12 +950,23 @@
950950
joi "^17.4.2"
951951
rxjs "^7.5.2"
952952

953-
"@web3-onboard/core@^2.6.0-alpha.7":
954-
version "2.6.0"
955-
resolved "https://registry.yarnpkg.com/@web3-onboard/core/-/core-2.6.0.tgz#978b41211780189d9f5fb2f8f3259659bf6022e2"
956-
integrity sha512-mxX4kMKetSqp/kDWYEZYqpIeDx7s3Q2i+XgS9FAaNDv+Rbv95CC/AC5zxpxiUy2zsixe8avTZtKoPXRV7y0Wag==
953+
"@web3-onboard/common@^2.1.8":
954+
version "2.1.8"
955+
resolved "https://registry.yarnpkg.com/@web3-onboard/common/-/common-2.1.8.tgz#e20e027eaa597846b4ff178423de13d5ca597a5b"
956+
integrity sha512-3kmJi0FKUw0rPXrbVe/BL+K13JSEzZ2QndnzpmHtKt4xFyRN+JgboAaAvJqfuk9t4hAZe45PqEWraSnYUCgDaA==
957957
dependencies:
958-
"@web3-onboard/common" "^2.1.7"
958+
"@ethereumjs/common" "2.6.2"
959+
bignumber.js "^9.0.0"
960+
ethers "5.5.4"
961+
joi "^17.4.2"
962+
rxjs "^7.5.2"
963+
964+
"@web3-onboard/core@^2.7.0":
965+
version "2.7.0"
966+
resolved "https://registry.yarnpkg.com/@web3-onboard/core/-/core-2.7.0.tgz#20acb5ae430cc5d0b2a7513e4e83f3182cff19eb"
967+
integrity sha512-wxlUheuqgW8C5W2W4bpQdfjV9fXwmWxQx82IKem5kEnDhU8NPjVYEO/Xg4+kUwPlzYg0Uj/SPuGGjk+tNIrn9g==
968+
dependencies:
969+
"@web3-onboard/common" "^2.1.8"
959970
bignumber.js "^9.0.0"
960971
bnc-sdk "^4.4.1"
961972
bowser "^2.11.0"
@@ -966,7 +977,7 @@
966977
lodash.partition "^4.6.0"
967978
nanoid "^4.0.0"
968979
rxjs "^7.5.2"
969-
svelte "^3.46.4"
980+
svelte "^3.49.0"
970981
svelte-i18n "^3.3.13"
971982

972983
"@web3-onboard/injected-wallets@^2.0.15":
@@ -978,13 +989,15 @@
978989
joi "^17.4.2"
979990
lodash.uniqby "^4.7.0"
980991

981-
"@web3-onboard/vue@file:.yalc/@web3-onboard/vue":
982-
version "2.1.5-alpha.6"
992+
"@web3-onboard/vue@^2.1.6":
993+
version "2.1.6"
994+
resolved "https://registry.yarnpkg.com/@web3-onboard/vue/-/vue-2.1.6.tgz#c634aff42932cc51e97bc40dc8669af1396d4485"
995+
integrity sha512-RWWpZdTYLiwjUoem2+Lppdxtj0qPycrw44Dls83PjOp+9mO9/dvLO+FXSwmMJcPJiOH9WYPuejqAGOF89LQAUQ==
983996
dependencies:
984997
"@vueuse/core" "^8.4.2"
985998
"@vueuse/rxjs" "^8.2.0"
986-
"@web3-onboard/common" "^2.1.7-alpha.4"
987-
"@web3-onboard/core" "^2.6.0-alpha.7"
999+
"@web3-onboard/common" "^2.1.8"
1000+
"@web3-onboard/core" "^2.7.0"
9881001
vue-demi "^0.12.4"
9891002

9901003
acorn-jsx@^5.3.2:
@@ -2453,7 +2466,7 @@ svelte-i18n@^3.3.13:
24532466
sade "^1.7.4"
24542467
tiny-glob "^0.2.6"
24552468

2456-
svelte@^3.46.4:
2469+
svelte@^3.49.0:
24572470
version "3.49.0"
24582471
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.49.0.tgz#5baee3c672306de1070c3b7888fc2204e36a4029"
24592472
integrity sha512-+lmjic1pApJWDfPCpUUTc1m8azDqYCG1JN9YEngrx/hUyIcFJo6VZhj0A1Ai0wqoHcEIuQy+e9tk+4uDgdtsFA==

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"install-m1-mac": "yarn install --ignore-optional",
5050
"format": "prettier --write 'packages/**/*.ts'",
5151
"dev": "yarn wsrun dev",
52-
"build": "yarn wsrun --stages build",
52+
"build": "yarn wsrun --serial build",
5353
"type-check": "yarn wsrun type-check"
5454
},
5555
"devDependencies": {

packages/coinbase/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/coinbase",
3-
"version": "2.0.11",
3+
"version": "2.1.0-alpha.1",
44
"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.",
55
"keywords": [
66
"Ethereum",
@@ -36,7 +36,7 @@
3636
"repository": {
3737
"type": "git",
3838
"url": "https://github.com/blocknative/web3-onboard.git",
39-
"directory": "packages/core"
39+
"directory": "packages/coinbase"
4040
},
4141
"homepage": "https://www.blocknative.com/onboard",
4242
"bugs": "https://github.com/blocknative/web3-onboard/issues",
@@ -59,6 +59,6 @@
5959
},
6060
"dependencies": {
6161
"@coinbase/wallet-sdk": "^3.0.5",
62-
"@web3-onboard/common": "^2.1.8"
62+
"@web3-onboard/common": "^2.2.0-alpha.1"
6363
}
6464
}

packages/common/package.json

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/common",
3-
"version": "2.1.8",
3+
"version": "2.2.0-alpha.1",
44
"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.",
55
"keywords": [
66
"Ethereum",
@@ -36,15 +36,14 @@
3636
"repository": {
3737
"type": "git",
3838
"url": "https://github.com/blocknative/web3-onboard.git",
39-
"directory": "packages/core"
39+
"directory": "packages/common"
4040
},
4141
"homepage": "https://www.blocknative.com/onboard",
4242
"bugs": "https://github.com/blocknative/web3-onboard/issues",
4343
"scripts": {
44-
"build": "rollup -c",
45-
"dev": "rollup -c -w",
46-
"start": "sirv public --no-clear",
47-
"type-check": "svelte-check --tsconfig ./tsconfig.json",
44+
"build": "tsc",
45+
"dev": "tsc -w",
46+
"type-check": "tsc --noEmit",
4847
"lint": "eslint -c './.eslintrc.cjs' './src' && prettier --check './src/**/*'"
4948
},
5049
"module": "dist/index.js",
@@ -57,33 +56,25 @@
5756
],
5857
"license": "MIT",
5958
"devDependencies": {
60-
"@rollup/plugin-json": "^4.1.0",
61-
"@rollup/plugin-node-resolve": "^11.0.0",
62-
"@rollup/plugin-replace": "^3.0.0",
63-
"@rollup/plugin-typescript": "^8.0.0",
64-
"@tsconfig/svelte": "^2.0.0",
6559
"@typescript-eslint/eslint-plugin": "^4.31.1",
6660
"@typescript-eslint/parser": "^4.31.1",
6761
"eip-712": "^0.4.3",
6862
"eslint": "^7.32.0",
6963
"eslint-config-prettier": "^8.3.0",
70-
"eslint-plugin-svelte3": "^3.2.1",
7164
"eventemitter3": "^4.0.7",
7265
"prettier": "^2.4.0",
7366
"prettier-plugin-svelte": "^2.4.0",
7467
"rollup": "^2.3.4",
7568
"rollup-plugin-svelte": "^7.0.0",
76-
"svelte": "^3.49.0",
69+
"svelte": "^3.42.5",
7770
"svelte-check": "^2.2.6",
7871
"svelte-preprocess": "^4.9.4",
7972
"tslib": "^2.0.0",
8073
"typescript": "^4.5.5"
8174
},
8275
"dependencies": {
83-
"@ethereumjs/common": "2.6.2",
84-
"bignumber.js": "^9.0.0",
76+
"bignumber.js": "^9.1.0",
8577
"ethers": "5.5.4",
86-
"joi": "^17.4.2",
87-
"rxjs": "^7.5.2"
78+
"joi": "^17.4.2"
8879
}
8980
}

packages/common/src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
export { ProviderRpcErrorCode } from './types'
21
export { ProviderRpcError } from './errors'
32
export { createEIP1193Provider } from './eip-1193'
4-
export { default as accountSelect } from './account-select'
5-
export { entryModal } from './entry-modal'
63
export { SofiaProLight, SofiaProRegular, SofiaProSemiBold } from './fonts'
7-
export {
8-
getCommon,
9-
bigNumberFieldsToStrings,
10-
getHardwareWalletProvider
11-
} from './hdwallets'
124
export { weiToEth } from './utils'
135

146
export * from './types'
7+
export * from './validation'

packages/common/src/types.ts

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -75,56 +75,6 @@ export type RequestPatch = {
7575
}) => Promise<null>)
7676
| null
7777
}
78-
79-
// eslint-disable-next-line max-len
80-
export type AccountSelectAPI = (
81-
options: SelectAccountOptions
82-
) => Promise<Account>
83-
84-
export type SelectAccountOptions = {
85-
basePaths: BasePath[] // the paths to display in the base path selector
86-
assets: Asset[] // the selectable assets to scan for a balance
87-
chains: Chain[] // the selectable chains/networks to scan for balance
88-
scanAccounts: ScanAccounts
89-
supportsCustomPath?: boolean
90-
}
91-
92-
export type BasePath = {
93-
label: string // eg - Ethereum Ledger Live
94-
value: DerivationPath
95-
}
96-
97-
export type DerivationPath = string // eg - m/44'/60'
98-
99-
export type Asset = {
100-
label: string // eg - ETH
101-
address?: string // if is a token, address to query contract
102-
}
103-
104-
export type ScanAccounts = (options: ScanAccountsOptions) => Promise<Account[]>
105-
106-
export type ScanAccountsOptions = {
107-
derivationPath: DerivationPath
108-
chainId: Chain['id']
109-
asset: Asset
110-
}
111-
112-
export type AccountAddress = string
113-
114-
export type Account = {
115-
address: AccountAddress
116-
derivationPath: DerivationPath
117-
balance: {
118-
asset: Asset['label']
119-
value: ethers.BigNumber
120-
}
121-
}
122-
123-
export type AccountsList = {
124-
all: Account[]
125-
filtered: Account[]
126-
}
127-
12878
export interface AppMetadata {
12979
/* App name */
13080
name: string
@@ -262,6 +212,8 @@ export interface ProviderInfo {
262212
chainId: ChainId
263213
}
264214

215+
export type AccountAddress = string
216+
265217
/**
266218
* An array of addresses
267219
*/

packages/common/src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import BigNumber from 'bignumber.js'
1+
import Bignumber from 'bignumber.js'
22

33
export function weiToEth(wei: string): string {
4-
return new BigNumber(wei).div(1e18).toString(10)
5-
}
4+
return new Bignumber(wei).div(1e18).toString(10)
5+
}

packages/common/src/validation.ts

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,42 @@
11
import Joi from 'joi'
2-
import type { SelectAccountOptions } from './types'
32

4-
const basePath = Joi.object({
5-
label: Joi.string().required(),
6-
value: Joi.string().required()
3+
export type ValidateReturn = Joi.ValidationResult | null
4+
5+
export function validate(validator: Joi.Schema, data: unknown): ValidateReturn {
6+
const result = validator.validate(data)
7+
return result.error ? result : null
8+
}
9+
10+
export const chainIdValidation = Joi.alternatives().try(
11+
Joi.string().pattern(/^0x[0-9a-fA-F]+$/),
12+
Joi.number().positive()
13+
)
14+
15+
export const chainNamespaceValidation = Joi.string().valid('evm')
16+
17+
/** Related to ConnectionInfo from 'ethers/lib/utils' */
18+
export const providerConnectionInfoValidation = Joi.object({
19+
url: Joi.string().required(),
20+
headers: Joi.object(),
21+
user: Joi.string(),
22+
password: Joi.string(),
23+
allowInsecureAuthentication: Joi.boolean(),
24+
allowGzip: Joi.boolean(),
25+
throttleLimit: Joi.number(),
26+
throttleSlotInterval: Joi.number(),
27+
throttleCallback: Joi.function(),
28+
timeout: Joi.number()
729
})
8-
const basePaths = Joi.array().items(basePath)
930

10-
const chain = Joi.object({
11-
namespace: Joi.string(),
12-
id: Joi.string()
13-
.pattern(/^0x[0-9a-fA-F]+$/)
14-
.required(),
31+
export const chainValidation = Joi.object({
32+
namespace: chainNamespaceValidation,
33+
id: chainIdValidation.required(),
1534
rpcUrl: Joi.string().required(),
1635
label: Joi.string().required(),
1736
token: Joi.string().required(),
1837
icon: Joi.string(),
19-
color: Joi.string()
20-
})
21-
22-
const chains = Joi.array().items(chain)
23-
24-
const asset = Joi.object({
25-
label: Joi.string().required(),
26-
address: Joi.string()
38+
color: Joi.string(),
39+
publicRpcUrl: Joi.string(),
40+
blockExplorerUrl: Joi.string(),
41+
providerConnectionInfoValidation
2742
})
28-
const assets = Joi.array().items(asset)
29-
30-
const selectAccountOptions = Joi.object({
31-
basePaths: basePaths,
32-
assets: assets,
33-
chains: chains,
34-
scanAccounts: Joi.function().arity(1).required(),
35-
supportsCustomPath: Joi.bool()
36-
})
37-
38-
type ValidateReturn = Joi.ValidationResult | null
39-
40-
const validate = (validator: Joi.Schema, data: unknown): ValidateReturn => {
41-
const result = validator.validate(data)
42-
return result.error ? result : null
43-
}
44-
45-
export const validateSelectAccountOptions = (
46-
data: SelectAccountOptions
47-
): ValidateReturn => {
48-
return validate(selectAccountOptions, data)
49-
}

0 commit comments

Comments
 (0)