Skip to content

Commit 1a3358c

Browse files
authored
Merge pull request #1051 from blocknative/release/06-08
Release 06-08 (main)
2 parents 108ce02 + e760b13 commit 1a3358c

33 files changed

+719
-139
lines changed

.circleci/config.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ aliases:
7373
echo "$FILE exist"
7474
circleci step halt
7575
fi
76-
76+
7777
- &generate-lock-file
7878
run:
7979
name: Generate lock file
@@ -267,6 +267,12 @@ jobs:
267267
working_directory: ~/web3-onboard-monorepo/packages/coinbase
268268
steps:
269269
- node-build-steps
270+
build-dcent:
271+
docker:
272+
- image: cimg/node:16.13.1
273+
working_directory: ~/web3-onboard-monorepo/packages/dcent
274+
steps:
275+
- node-build-steps
270276
build-vue:
271277
docker:
272278
- image: cimg/node:16.13.1
@@ -377,6 +383,12 @@ jobs:
377383
working_directory: ~/web3-onboard-monorepo/packages/coinbase
378384
steps:
379385
- node-staging-build-steps
386+
build-staging-dcent:
387+
docker:
388+
- image: cimg/node:16.13.1
389+
working_directory: ~/web3-onboard-monorepo/packages/dcent
390+
steps:
391+
- node-staging-build-steps
380392
build-staging-vue:
381393
docker:
382394
- image: cimg/node:16.13.1
@@ -489,6 +501,12 @@ workflows:
489501
<<: *deploy_production_filters
490502
- build-staging-coinbase:
491503
<<: *deploy_staging_filters
504+
dcent:
505+
jobs:
506+
- build-dcent:
507+
<<: *deploy_production_filters
508+
- build-staging-dcent:
509+
<<: *deploy_staging_filters
492510
vue:
493511
jobs:
494512
- build-vue:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ For full documentation, check out the README.md for each package:
7777
- [Ledger](packages/ledger/README.md)
7878
- [Trezor](packages/trezor/README.md)
7979
- [Keystone](packages/keystone/README.md)
80-
80+
- [D'CENT](packages/dcent/README.md)
8181
**Frameworks**
8282

8383
- [React](packages/react/README.md)

packages/@types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
declare module '*.png'
22
declare module 'window'
33
declare module '@keystonehq/eth-keyring'
4+
declare module 'eth-dcent-keyring'
45
declare module 'hdkey'
56
declare const global: typeof globalThis & { window: CustomWindow }

packages/core/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,18 @@ const onboard = Onboard({
416416
onboard.state.actions.setWalletModules([ledger, trezor])
417417
```
418418

419+
**updatedBalances**
420+
You may decide to get updated balances for connected wallets after a user action by calling the `updatedBalances` function, which expects a conditional array of addresses.
421+
422+
```
423+
onboard.state.actions.updateBalances() // update all balances for all connected addresses
424+
onboard.state.actions.updateBalances(['0xfdadfadsadsadsadasdsa']) // update balance for one address
425+
onboard.state.actions.updateBalances([
426+
'0xfdadfadsadsadsadasdsa',
427+
'0xfdsafdsfdsfdsfds'
428+
]) // update balance for two addresses
429+
```
430+
419431
## Setting the User's Chain/Network
420432

421433
When initializing Onboard you define a list of chains/networks that your app supports. If you would like to prompt the user to switch to one of those chains, you can use the `setChain` method on an initialized instance of Onboard:

packages/core/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/core",
3-
"version": "2.2.10",
3+
"version": "2.2.11",
44
"scripts": {
55
"build": "rollup -c",
66
"dev": "rollup -c -w",

packages/core/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import App from './views/Index.svelte'
1717
import type { InitOptions, OnboardAPI } from './types'
1818
import { APP_INITIAL_STATE } from './constants'
1919
import { internalState } from './internals'
20+
import updateBalances from './updateBalances'
2021

2122
const API = {
2223
connectWallet,
@@ -27,7 +28,8 @@ const API = {
2728
select: state.select,
2829
actions: {
2930
setWalletModules,
30-
setLocale
31+
setLocale,
32+
updateBalances
3133
}
3234
}
3335
}
@@ -224,4 +226,4 @@ function mountApp() {
224226
return app
225227
}
226228

227-
export default init
229+
export default init

packages/core/src/store/actions.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ import type {
1313
UpdateAccountAction,
1414
UpdateAccountCenterAction,
1515
UpdateWalletAction,
16-
WalletState
16+
WalletState,
17+
UpdateAllWalletsAction
1718
} from '../types'
1819

1920
import {
2021
validateAccountCenterUpdate,
2122
validateLocale,
2223
validateString,
2324
validateWallet,
24-
validateWalletInit
25+
validateWalletInit,
26+
validateUpdateBalances
2527
} from '../validation'
2628

2729
import {
@@ -33,7 +35,8 @@ import {
3335
UPDATE_ACCOUNT,
3436
UPDATE_ACCOUNT_CENTER,
3537
SET_WALLET_MODULES,
36-
SET_LOCALE
38+
SET_LOCALE,
39+
UPDATE_ALL_WALLETS
3740
} from './constants'
3841
import { internalState } from '../internals'
3942

@@ -177,6 +180,21 @@ export function setLocale(locale: string): void {
177180
dispatch(action as SetLocaleAction)
178181
}
179182

183+
export function updateAllWallets(wallets: WalletState[]): void {
184+
const error = validateUpdateBalances(wallets)
185+
186+
if (error) {
187+
throw error
188+
}
189+
190+
const action = {
191+
type: UPDATE_ALL_WALLETS,
192+
payload: wallets
193+
}
194+
195+
dispatch(action as UpdateAllWalletsAction)
196+
}
197+
180198
// ==== HELPERS ==== //
181199
export function initializeWalletModules(modules: WalletInit[]): WalletModule[] {
182200
const { device } = internalState

packages/core/src/store/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export const UPDATE_ACCOUNT = 'update_account'
77
export const UPDATE_ACCOUNT_CENTER = 'update_account_center'
88
export const SET_WALLET_MODULES = 'set_wallet_modules'
99
export const SET_LOCALE= 'set_locale'
10+
export const UPDATE_ALL_WALLETS = 'update_balance'

packages/core/src/store/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import type {
1414
AddWalletAction,
1515
UpdateAccountAction,
1616
UpdateAccountCenterAction,
17-
Locale
17+
Locale,
18+
UpdateAllWalletsAction
1819
} from '../types'
1920

2021
import {
@@ -26,7 +27,8 @@ import {
2627
UPDATE_ACCOUNT,
2728
UPDATE_ACCOUNT_CENTER,
2829
SET_WALLET_MODULES,
29-
SET_LOCALE
30+
SET_LOCALE,
31+
UPDATE_ALL_WALLETS
3032
} from './constants'
3133

3234
function reducer(state: AppState, action: Action): AppState {
@@ -102,6 +104,14 @@ function reducer(state: AppState, action: Action): AppState {
102104
}
103105
}
104106

107+
case UPDATE_ALL_WALLETS : {
108+
const updatedWallets = payload as UpdateAllWalletsAction['payload']
109+
return {
110+
...state,
111+
wallets: updatedWallets
112+
}
113+
}
114+
105115
case UPDATE_ACCOUNT_CENTER: {
106116
const update = payload as UpdateAccountCenterAction['payload']
107117
return {
@@ -112,6 +122,7 @@ function reducer(state: AppState, action: Action): AppState {
112122
}
113123
}
114124
}
125+
115126
case SET_WALLET_MODULES: {
116127
return {
117128
...state,
@@ -175,4 +186,4 @@ function get(): AppState {
175186
export const state = {
176187
select,
177188
get
178-
}
189+
}

packages/core/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export type Action =
136136
| UpdateAccountCenterAction
137137
| SetWalletModulesAction
138138
| SetLocaleAction
139+
| UpdateAllWalletsAction
139140

140141
export type AddChainsAction = { type: 'add_chains'; payload: Chain[] }
141142
export type AddWalletAction = { type: 'add_wallet'; payload: WalletState }
@@ -175,6 +176,11 @@ export type SetLocaleAction = {
175176
payload: string
176177
}
177178

179+
export type UpdateAllWalletsAction = {
180+
type: 'update_balance'
181+
payload: WalletState[]
182+
}
183+
178184
// ==== MISC ==== //
179185
export type ChainStyle = {
180186
icon: string

0 commit comments

Comments
 (0)