Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/elements/AddressTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
>
<td>{account.derivationPath}</td>
<td class="asset-td"
>{weiToEth(account.balance.value)}
>{weiToEth(account.balance.value.toString())}
{account.balance.asset}</td
>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
@@ -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'

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ export type Account = {
derivationPath: DerivationPath
balance: {
asset: Asset['label']
value: BigNumber
value: ethers.BigNumber
}
}

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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)
}
6 changes: 3 additions & 3 deletions packages/common/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to change this validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was related to the validation error fix for hardware wallets chain added to the main release:

There is another Joi.alternatives- string or number validation included in the previous PR core chainID which .

I guess placing chains: Chain[] | ChainWithDecimalId[] will allow for such validation but I'm not sure that's needed since the GetInterfaceHelpers used by Ledger works with the internal hex string.

Copy link
Contributor

@Adamj1232 Adamj1232 Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seem correct if we are using Hex chain IDs internally(converting number chain ids to hex after initialization) it doesn't seem we would need positive number validation within the common package although I may be misunderstanding the possible flows of potential chainId

rpcUrl: Joi.string().required(),
label: Joi.string().required(),
token: Joi.string().required(),
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/views/AccountSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/views/connect/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo",
"version": "2.0.7",
"version": "2.0.8",
"devDependencies": {
"assert": "^2.0.0",
"buffer": "^6.0.3",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down