Skip to content

Commit 878bd9c

Browse files
authored
[core-v2.4.0-alpha.6, react-v2.2.3-alpha.4, vue v2.1.3-alpha.4] : Update - Refactor updateBalance within notification trigger (#1129)
* Refactor updateBalance within notification trigger * Rename update-balances file to conform to kebab case
1 parent 9afd6e5 commit 878bd9c

File tree

6 files changed

+11
-37
lines changed

6 files changed

+11
-37
lines changed

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.4.0-alpha.5",
3+
"version": "2.4.0-alpha.6",
44
"repository": "blocknative/web3-onboard",
55
"scripts": {
66
"build": "rollup -c",

packages/core/src/notify.ts

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
import { validateTransactionHandlerReturn } from './validation'
1414
import { state } from './store'
1515
import { addNotification } from './store/actions'
16-
import updateBalances from './updateBalances'
16+
import updateBalances from './update-balances'
1717

1818
export function handleTransactionUpdates(
1919
transaction: EthereumTransactionData
@@ -25,6 +25,10 @@ export function handleTransactionUpdates(
2525
throw invalid
2626
}
2727

28+
if (transaction.eventCode === 'txConfirmed') {
29+
updateBalances([transaction.watchedAddress, transaction.counterparty])
30+
}
31+
2832
const notification = transactionEventToNotification(transaction, customized)
2933

3034
addNotification(notification)
@@ -48,10 +52,6 @@ export function transactionEventToNotification(
4852

4953
const type: NotificationType = eventToType(eventCode)
5054

51-
if (type === 'success') {
52-
updateWalletBalance(transaction)
53-
}
54-
5555
const key = `${id || hash}-${
5656
(typeof customization === 'object' && customization.eventCode) || eventCode
5757
}`
@@ -167,29 +167,3 @@ export function typeToDismissTimeout(type: string): number {
167167
}
168168
}
169169

170-
const updateWalletBalance = (
171-
transaction: Pick<EthereumTransactionData, 'to' | 'from'>
172-
) => {
173-
let walletsToUpdate: string[] = []
174-
state.get().wallets.forEach(wallet => {
175-
if (
176-
wallet.accounts.some(
177-
e => e.address.toLowerCase() === transaction.to.toLowerCase()
178-
)
179-
) {
180-
walletsToUpdate = [...walletsToUpdate, transaction.to]
181-
}
182-
if (
183-
wallet.accounts.some(
184-
e => e.address.toLowerCase() === transaction.from.toLowerCase()
185-
)
186-
) {
187-
walletsToUpdate = [...walletsToUpdate, transaction.from]
188-
}
189-
})
190-
191-
// Pause to allow provider endpoint time to update
192-
setTimeout(() => {
193-
updateBalances(walletsToUpdate)
194-
}, 500)
195-
}

packages/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"dependencies": {
2525
"@web3-onboard/coinbase": "^2.0.7",
26-
"@web3-onboard/core": "^2.3.2",
26+
"@web3-onboard/core": "^2.4.0-alpha.6",
2727
"@web3-onboard/dcent": "^2.0.4",
2828
"@web3-onboard/fortmatic": "^2.0.6",
2929
"@web3-onboard/gnosis": "^2.0.5",

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/react",
3-
"version": "2.2.3-alpha.3",
3+
"version": "2.2.3-alpha.4",
44
"description": "Collection of React Hooks for web3-onboard",
55
"repository": "blocknative/web3-onboard",
66
"module": "dist/index.js",
@@ -24,7 +24,7 @@
2424
"typescript": "^4.5.5"
2525
},
2626
"dependencies": {
27-
"@web3-onboard/core": "^2.4.0-alpha.5",
27+
"@web3-onboard/core": "^2.4.0-alpha.6",
2828
"@web3-onboard/common": "^2.1.4",
2929
"use-sync-external-store": "1.0.0"
3030
},

packages/vue/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/vue",
3-
"version": "2.1.3-alpha.3",
3+
"version": "2.1.3-alpha.4",
44
"description": "Vue Composable for web3-onboard",
55
"repository": "blocknative/web3-onboard",
66
"module": "dist/index.js",
@@ -25,7 +25,7 @@
2525
"@vueuse/core": "^8.4.2",
2626
"@vueuse/rxjs": "^8.2.0",
2727
"@web3-onboard/common": "^2.1.4",
28-
"@web3-onboard/core": "^2.4.0-alpha.5",
28+
"@web3-onboard/core": "^2.4.0-alpha.6",
2929
"vue-demi": "^0.12.4"
3030
},
3131
"peerDependencies": {

0 commit comments

Comments
 (0)