From 01f620f9c4016ea86acd6f5b68c54834ef9b6d9d Mon Sep 17 00:00:00 2001 From: unclebill Date: Tue, 18 Jan 2022 17:35:22 +0800 Subject: [PATCH 1/2] fix: formatCurrency is different from toFixed --- packages/plugins/Flow/src/UI/Web3State/index.ts | 5 +++-- packages/plugins/Solana/src/UI/Web3State/index.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/plugins/Flow/src/UI/Web3State/index.ts b/packages/plugins/Flow/src/UI/Web3State/index.ts index 6e22d68f829c..a5567c62e7c4 100644 --- a/packages/plugins/Flow/src/UI/Web3State/index.ts +++ b/packages/plugins/Flow/src/UI/Web3State/index.ts @@ -7,10 +7,11 @@ import { resolveAddressLinkOnExplorer, } from '@masknet/web3-shared-flow' import { createConstantSubscription, mapSubscription } from '@masknet/shared-base' +import BigNumber from 'bignumber.js' +import { toFixed } from '@masknet/web3-shared-base' import { getStorage, StorageDefaultValue } from '../../storage' import { formatAddress } from '../../helpers' import { getFungibleAssets } from '../../apis' -import { toFixed } from '@masknet/web3-shared-base' function createSubscriptionFromChainId(getter: (value: typeof StorageDefaultValue.chainId) => T) { return mapSubscription(getStorage().chainId.subscription, getter) @@ -50,7 +51,7 @@ export function createWeb3State(signal: AbortSignal): Web3Plugin.ObjectCapabilit Utils: { formatAddress, formatBalance: toFixed, - formatCurrency: toFixed, + formatCurrency: (value) => new BigNumber(value).toFixed(), isChainIdValid: () => true, diff --git a/packages/plugins/Solana/src/UI/Web3State/index.ts b/packages/plugins/Solana/src/UI/Web3State/index.ts index bea02126b0bc..01341d5d8ffb 100644 --- a/packages/plugins/Solana/src/UI/Web3State/index.ts +++ b/packages/plugins/Solana/src/UI/Web3State/index.ts @@ -1,5 +1,6 @@ import type { Web3Plugin } from '@masknet/plugin-infra' import { createConstantSubscription, mapSubscription } from '@masknet/shared-base' +import BigNumber from 'bignumber.js' import { toFixed } from '@masknet/web3-shared-base' import { ChainId, @@ -50,7 +51,7 @@ export function createWeb3State(signal: AbortSignal): Web3Plugin.ObjectCapabilit Utils: { formatAddress, formatBalance: toFixed, - formatCurrency: toFixed, + formatCurrency: (value) => new BigNumber(value).toFixed(), isChainIdValid: () => true, From e20db9688d4993e1044deba03ee8abda942e0d14 Mon Sep 17 00:00:00 2001 From: unclebill Date: Tue, 18 Jan 2022 17:49:36 +0800 Subject: [PATCH 2/2] fixup! fix: formatCurrency is different from toFixed --- packages/plugins/Flow/src/UI/Web3State/index.ts | 3 +-- packages/plugins/Solana/src/UI/Web3State/index.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/plugins/Flow/src/UI/Web3State/index.ts b/packages/plugins/Flow/src/UI/Web3State/index.ts index a5567c62e7c4..4ecd62162222 100644 --- a/packages/plugins/Flow/src/UI/Web3State/index.ts +++ b/packages/plugins/Flow/src/UI/Web3State/index.ts @@ -7,7 +7,6 @@ import { resolveAddressLinkOnExplorer, } from '@masknet/web3-shared-flow' import { createConstantSubscription, mapSubscription } from '@masknet/shared-base' -import BigNumber from 'bignumber.js' import { toFixed } from '@masknet/web3-shared-base' import { getStorage, StorageDefaultValue } from '../../storage' import { formatAddress } from '../../helpers' @@ -51,7 +50,7 @@ export function createWeb3State(signal: AbortSignal): Web3Plugin.ObjectCapabilit Utils: { formatAddress, formatBalance: toFixed, - formatCurrency: (value) => new BigNumber(value).toFixed(), + formatCurrency: (value) => toFixed(value), isChainIdValid: () => true, diff --git a/packages/plugins/Solana/src/UI/Web3State/index.ts b/packages/plugins/Solana/src/UI/Web3State/index.ts index 01341d5d8ffb..6c537764db89 100644 --- a/packages/plugins/Solana/src/UI/Web3State/index.ts +++ b/packages/plugins/Solana/src/UI/Web3State/index.ts @@ -1,6 +1,5 @@ import type { Web3Plugin } from '@masknet/plugin-infra' import { createConstantSubscription, mapSubscription } from '@masknet/shared-base' -import BigNumber from 'bignumber.js' import { toFixed } from '@masknet/web3-shared-base' import { ChainId, @@ -51,7 +50,7 @@ export function createWeb3State(signal: AbortSignal): Web3Plugin.ObjectCapabilit Utils: { formatAddress, formatBalance: toFixed, - formatCurrency: (value) => new BigNumber(value).toFixed(), + formatCurrency: (value) => toFixed(value), isChainIdValid: () => true,