Skip to content

Commit 9e01c83

Browse files
authored
[common-v2.1.7-alpha.5, core-v2.6.0-alpha.8, react-v2.2.5-alpha.7]fix: weifix (#1180)
* weifix * merge develop
1 parent 5fecc21 commit 9e01c83

File tree

11 files changed

+22
-24
lines changed

11 files changed

+22
-24
lines changed

packages/common/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/common",
3-
"version": "2.1.7-alpha.5",
3+
"version": "2.1.7-alpha.6",
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",

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/validation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const basePaths = Joi.array().items(basePath)
99

1010
const chain = Joi.object({
1111
namespace: Joi.string(),
12-
id: Joi.alternatives()
13-
.try(Joi.string().pattern(/^0x[0-9a-fA-F]+$/),
14-
Joi.number().positive()).required,
12+
id: Joi.string()
13+
.pattern(/^0x[0-9a-fA-F]+$/)
14+
.required(),
1515
rpcUrl: Joi.string().required(),
1616
label: Joi.string().required(),
1717
token: Joi.string().required(),

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/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/core",
3-
"version": "2.6.0-alpha.8",
3+
"version": "2.6.0-alpha.9",
44
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized 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",
@@ -83,7 +83,7 @@
8383
"typescript": "^4.5.5"
8484
},
8585
"dependencies": {
86-
"@web3-onboard/common": "^2.1.7-alpha.5",
86+
"@web3-onboard/common": "^2.1.7-alpha.6",
8787
"bignumber.js": "^9.0.0",
8888
"bnc-sdk": "^4.4.1",
8989
"bowser": "^2.11.0",

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: 2 additions & 2 deletions
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",
@@ -23,7 +23,7 @@
2323
},
2424
"dependencies": {
2525
"@web3-onboard/coinbase": "^2.0.8",
26-
"@web3-onboard/core": "^2.6.0-alpha.8",
26+
"@web3-onboard/core": "^2.6.0-alpha.9",
2727
"@web3-onboard/dcent": "^2.0.5",
2828
"@web3-onboard/fortmatic": "^2.0.6",
2929
"@web3-onboard/gnosis": "^2.0.5",

packages/react/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/react",
3-
"version": "2.2.5-alpha.6",
3+
"version": "2.2.5-alpha.7",
44
"description": "A collection of React hooks for integrating Web3-Onboard in to React and Next.js projects. 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, 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",
@@ -62,8 +62,8 @@
6262
"typescript": "^4.5.5"
6363
},
6464
"dependencies": {
65-
"@web3-onboard/core": "^2.6.0-alpha.7",
66-
"@web3-onboard/common": "^2.1.7-alpha.4",
65+
"@web3-onboard/core": "^2.6.0-alpha.9",
66+
"@web3-onboard/common": "^2.1.7-alpha.6",
6767
"use-sync-external-store": "1.0.0"
6868
},
6969
"peerDependencies": {

0 commit comments

Comments
 (0)