Skip to content

Commit

Permalink
add try-catch when updating balance and add Arbitrum One options in demo
Browse files Browse the repository at this point in the history
  • Loading branch information
johnson86tw committed Oct 16, 2022
1 parent dcf0c9a commit 7dd5d5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions demo/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ app.use(VueDapp, {
symbol: 'MATIC',
},
},
42161: {
chainId: ethers.utils.hexValue(42161),
blockExplorerUrls: ['https://arbiscan.io'],
chainName: 'Arbitrum One',
rpcUrls: ['https://arb1.arbitrum.io/rpc'],
nativeCurrency: {
name: 'Arbitrum',
symbol: 'ETH',
decimals: 18,
},
},
})

app.mount('#app')
8 changes: 6 additions & 2 deletions src/composables/useEthers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ async function activate(externalProvider: ExternalProvider) {
const updateBalance = async (interval: number = 10000) => {
updateBalanceInterval = setInterval(async () => {
if (!signer.value) return
const _balance = await signer?.value.getBalance()
balance.value = _balance.toBigInt()
try {
const _balance = await signer?.value.getBalance()
balance.value = _balance.toBigInt()
} catch (e) {
console.error(e)
}
}, interval)
}

Expand Down

0 comments on commit 7dd5d5d

Please sign in to comment.