diff --git a/packages/common/package.json b/packages/common/package.json index dd4f9ce79..1187c1a4b 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/common", - "version": "2.1.7-alpha.5", + "version": "2.1.7-alpha.6", "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.", "keywords": [ "Ethereum", diff --git a/packages/common/src/elements/AddressTable.svelte b/packages/common/src/elements/AddressTable.svelte index 8aa8c3e0c..99cacce03 100644 --- a/packages/common/src/elements/AddressTable.svelte +++ b/packages/common/src/elements/AddressTable.svelte @@ -120,7 +120,7 @@ > {account.derivationPath} {weiToEth(account.balance.value)} + >{weiToEth(account.balance.value.toString())} {account.balance.asset} diff --git a/packages/common/src/types.ts b/packages/common/src/types.ts index 18b483ca0..3ad1c2518 100644 --- a/packages/common/src/types.ts +++ b/packages/common/src/types.ts @@ -1,7 +1,7 @@ import type { ConnectionInfo } from 'ethers/lib/utils' import type EventEmitter from 'eventemitter3' import type { TypedData as EIP712TypedData } from 'eip-712' -import type BigNumber from 'bignumber.js' +import type { ethers } from 'ethers' export type { TypedData as EIP712TypedData } from 'eip-712' /** @@ -116,7 +116,7 @@ export type Account = { derivationPath: DerivationPath balance: { asset: Asset['label'] - value: BigNumber + value: ethers.BigNumber } } @@ -232,7 +232,7 @@ export interface WalletModule { export type GetInterfaceHelpers = { chains: Chain[] appMetadata: AppMetadata | null - BigNumber: typeof BigNumber + BigNumber: typeof ethers.BigNumber EventEmitter: typeof EventEmitter } diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts index 57c94eec4..caf1e5b60 100644 --- a/packages/common/src/utils.ts +++ b/packages/common/src/utils.ts @@ -1,5 +1,5 @@ -import type BigNumber from 'bignumber.js' +import BigNumber from 'bignumber.js' -export function weiToEth(wei: BigNumber): string { - return wei.div(1e18).toString(10) +export function weiToEth(wei: string): string { + return new BigNumber(wei).div(1e18).toString(10) } \ No newline at end of file diff --git a/packages/common/src/validation.ts b/packages/common/src/validation.ts index 6294d7b51..904ffb3d4 100644 --- a/packages/common/src/validation.ts +++ b/packages/common/src/validation.ts @@ -9,9 +9,9 @@ const basePaths = Joi.array().items(basePath) const chain = Joi.object({ namespace: Joi.string(), - id: Joi.alternatives() - .try(Joi.string().pattern(/^0x[0-9a-fA-F]+$/), - Joi.number().positive()).required, + id: Joi.string() + .pattern(/^0x[0-9a-fA-F]+$/) + .required(), rpcUrl: Joi.string().required(), label: Joi.string().required(), token: Joi.string().required(), diff --git a/packages/common/src/views/AccountSelect.svelte b/packages/common/src/views/AccountSelect.svelte index c893a3c62..e3fa29733 100644 --- a/packages/common/src/views/AccountSelect.svelte +++ b/packages/common/src/views/AccountSelect.svelte @@ -60,7 +60,7 @@ accountsListObject = { all: allAccounts, filtered: allAccounts.filter(account => { - return parseFloat(weiToEth(account.balance.value)) > 0 + return parseFloat(weiToEth(account.balance.value.toString())) > 0 }) } loadingAccounts = false diff --git a/packages/core/package.json b/packages/core/package.json index 3e7b500c2..574edc21c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/core", - "version": "2.6.0-alpha.8", + "version": "2.6.0-alpha.9", "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.", "keywords": [ "Ethereum", @@ -83,7 +83,7 @@ "typescript": "^4.5.5" }, "dependencies": { - "@web3-onboard/common": "^2.1.7-alpha.5", + "@web3-onboard/common": "^2.1.7-alpha.6", "bignumber.js": "^9.0.0", "bnc-sdk": "^4.4.1", "bowser": "^2.11.0", diff --git a/packages/core/src/provider.ts b/packages/core/src/provider.ts index 95a9dc007..05f4acf2d 100644 --- a/packages/core/src/provider.ts +++ b/packages/core/src/provider.ts @@ -22,7 +22,6 @@ import { validEnsChain } from './utils' import disconnect from './disconnect' import { state } from './store' import { getBlocknativeSdk } from './services' -import BigNumber from 'bignumber.js' export const ethersProviders: { [key: string]: providers.StaticJsonRpcProvider @@ -348,9 +347,8 @@ export async function getBalance( const wallet = wallets.find(wallet => !!wallet.provider) const provider = wallet.provider const balanceHex = await provider.request({ method: 'eth_getBalance', params:[address,'latest'] }) - const balanceWei = new BigNumber(parseInt(balanceHex, 16)) - return balanceWei - ? { [chain.token || 'eth']: weiToEth(balanceWei) } + return balanceHex + ? { [chain.token || 'eth']: weiToEth(balanceHex) } : null } catch (error) { console.error(error) diff --git a/packages/core/src/views/connect/Index.svelte b/packages/core/src/views/connect/Index.svelte index 84a90e5f8..4328664bf 100644 --- a/packages/core/src/views/connect/Index.svelte +++ b/packages/core/src/views/connect/Index.svelte @@ -19,7 +19,7 @@ import Sidebar from './Sidebar.svelte' import { configuration } from '../../configuration' import { getBlocknativeSdk } from '../../services' - import BigNumber from 'bignumber.js' + import { BigNumber } from 'ethers' import { getChainId, requestAccounts, diff --git a/packages/demo/package.json b/packages/demo/package.json index e69b5c340..c9bbc585c 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -1,6 +1,6 @@ { "name": "demo", - "version": "2.0.7", + "version": "2.0.8", "devDependencies": { "assert": "^2.0.0", "buffer": "^6.0.3", @@ -23,7 +23,7 @@ }, "dependencies": { "@web3-onboard/coinbase": "^2.0.8", - "@web3-onboard/core": "^2.6.0-alpha.8", + "@web3-onboard/core": "^2.6.0-alpha.9", "@web3-onboard/dcent": "^2.0.5", "@web3-onboard/fortmatic": "^2.0.6", "@web3-onboard/gnosis": "^2.0.5", diff --git a/packages/react/package.json b/packages/react/package.json index 35ef5111d..48b64c03c 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/react", - "version": "2.2.5-alpha.6", + "version": "2.2.5-alpha.7", "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.", "keywords": [ "Ethereum", @@ -62,8 +62,8 @@ "typescript": "^4.5.5" }, "dependencies": { - "@web3-onboard/core": "^2.6.0-alpha.7", - "@web3-onboard/common": "^2.1.7-alpha.4", + "@web3-onboard/core": "^2.6.0-alpha.9", + "@web3-onboard/common": "^2.1.7-alpha.6", "use-sync-external-store": "1.0.0" }, "peerDependencies": {