Skip to content

Commit 78b317b

Browse files
committed
Merge in develop
2 parents 9288af0 + 9e01c83 commit 78b317b

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

packages/common/src/elements/AddressTable.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
>
121121
<td>{account.derivationPath}</td>
122122
<td class="asset-td"
123-
>{weiToEth(account.balance.value)}
123+
>{weiToEth(account.balance.value.toString())}
124124
{account.balance.asset}</td
125125
>
126126
</tr>

packages/common/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ConnectionInfo } from 'ethers/lib/utils'
22
import type EventEmitter from 'eventemitter3'
33
import type { TypedData as EIP712TypedData } from 'eip-712'
4-
import type BigNumber from 'bignumber.js'
4+
import type { ethers } from 'ethers'
55
export type { TypedData as EIP712TypedData } from 'eip-712'
66

77
/**
@@ -116,7 +116,7 @@ export type Account = {
116116
derivationPath: DerivationPath
117117
balance: {
118118
asset: Asset['label']
119-
value: BigNumber
119+
value: ethers.BigNumber
120120
}
121121
}
122122

@@ -232,7 +232,7 @@ export interface WalletModule {
232232
export type GetInterfaceHelpers = {
233233
chains: Chain[]
234234
appMetadata: AppMetadata | null
235-
BigNumber: typeof BigNumber
235+
BigNumber: typeof ethers.BigNumber
236236
EventEmitter: typeof EventEmitter
237237
}
238238

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 type BigNumber from 'bignumber.js'
1+
import BigNumber from 'bignumber.js'
22

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

packages/common/src/views/AccountSelect.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
accountsListObject = {
6161
all: allAccounts,
6262
filtered: allAccounts.filter(account => {
63-
return parseFloat(weiToEth(account.balance.value)) > 0
63+
return parseFloat(weiToEth(account.balance.value.toString())) > 0
6464
})
6565
}
6666
loadingAccounts = false

packages/core/src/provider.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { validEnsChain } from './utils'
2222
import disconnect from './disconnect'
2323
import { state } from './store'
2424
import { getBlocknativeSdk } from './services'
25-
import BigNumber from 'bignumber.js'
2625

2726
export const ethersProviders: {
2827
[key: string]: providers.StaticJsonRpcProvider
@@ -348,9 +347,8 @@ export async function getBalance(
348347
const wallet = wallets.find(wallet => !!wallet.provider)
349348
const provider = wallet.provider
350349
const balanceHex = await provider.request({ method: 'eth_getBalance', params:[address,'latest'] })
351-
const balanceWei = new BigNumber(parseInt(balanceHex, 16))
352-
return balanceWei
353-
? { [chain.token || 'eth']: weiToEth(balanceWei) }
350+
return balanceHex
351+
? { [chain.token || 'eth']: weiToEth(balanceHex) }
354352
: null
355353
} catch (error) {
356354
console.error(error)

packages/core/src/views/connect/Index.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import Sidebar from './Sidebar.svelte'
2020
import { configuration } from '../../configuration'
2121
import { getBlocknativeSdk } from '../../services'
22-
import BigNumber from 'bignumber.js'
22+
import { BigNumber } from 'ethers'
2323
import {
2424
getChainId,
2525
requestAccounts,

packages/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "demo",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"devDependencies": {
55
"assert": "^2.0.0",
66
"buffer": "^6.0.3",

0 commit comments

Comments
 (0)