From 867f893ab99d28af7c9da40332be46895cb2276c Mon Sep 17 00:00:00 2001 From: BrodyHughes <41711440+BrodyHughes@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:13:03 -0500 Subject: [PATCH 1/5] init --- lavamoat/build-webpack/policy.json | 172 +++++++++--------- src/core/utils/numbers.ts | 61 ++++++- .../swap/SwapReviewSheet/SwapAssetCard.tsx | 7 +- 3 files changed, 150 insertions(+), 90 deletions(-) diff --git a/lavamoat/build-webpack/policy.json b/lavamoat/build-webpack/policy.json index e2a8f44a30..75eb27fe32 100644 --- a/lavamoat/build-webpack/policy.json +++ b/lavamoat/build-webpack/policy.json @@ -1099,13 +1099,13 @@ "eslint>debug": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-environment-visitor": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/parser": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-environment-visitor": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": true + "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": { @@ -1114,8 +1114,36 @@ "process.emitWarning": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true, - "lavamoat>@babel/highlight": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": { + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>@babel/helper-validator-identifier": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": true, + "react>loose-envify>js-tokens": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": { + "globals": { + "process.env.TERM": true, + "process.platform": true + }, + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>escape-string-regexp": true, + "supports-color": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": { + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": { + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": { @@ -1167,141 +1195,113 @@ "define": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { - "globals": { - "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "jest>@jest/core>jest-snapshot>@babel/types": { - "globals": { - "console.trace": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "lavamoat>@babel/highlight": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { + "globals": { + "console.warn": true, + "process.emitWarning": true + }, "packages": { - "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, - "lavamoat>@babel/highlight>chalk": true, - "react>loose-envify>js-tokens": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true } }, - "lavamoat>@babel/highlight>chalk": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { "globals": { "process.env.TERM": true, "process.platform": true }, "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles": true, - "lavamoat>@babel/highlight>chalk>escape-string-regexp": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, "supports-color": true } }, - "lavamoat>@babel/highlight>chalk>ansi-styles": { - "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": true - } - }, - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": { - "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true - } - }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": { "globals": { "console.warn": true, - "process.emitWarning": true - }, - "packages": { - "lavamoat>@babel/highlight": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true - } - }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { - "globals": { - "process.env.TERM": true, - "process.platform": true + "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, - "supports-color": true - } - }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { - "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { + "jest>@jest/core>jest-snapshot>@babel/types": { "globals": { - "console.warn": true, + "console.trace": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, "lint-staged>execa>merge-stream": { diff --git a/src/core/utils/numbers.ts b/src/core/utils/numbers.ts index f426b15c69..626d3f4aac 100644 --- a/src/core/utils/numbers.ts +++ b/src/core/utils/numbers.ts @@ -228,13 +228,68 @@ export const lessOrEqualThan = ( new BigNumber(numberOne).lt(numberTwo) || new BigNumber(numberOne).eq(numberTwo); +// returns decimal within threshold and trims excess 0's export const handleSignificantDecimalsWithThreshold = ( value: BigNumberish, decimals: number, threshold = '0.0001', -) => { - const result = toFixedDecimals(value, decimals); - return lessThan(result, threshold) ? `< ${threshold}` : result; +): string => { + const cleanValue = value.toString().replace(/,/g, ''); + const bnValue = new BigNumber(cleanValue); + const result = bnValue.toFixed(decimals).replace(/\.?0+$/, ''); + return new BigNumber(result).lt(threshold) ? `< ${threshold}` : result; +}; + +// abbreviate numbers and return abbreivated values +export const abbreviateNumber = (value: BigNumberish): string => { + console.log('abbreviateNumber value: ', value); + + // Remove commas from the input value + const cleanValue = value.toString().replace(/,/g, ''); + const bnValue = new BigNumber(cleanValue); + console.log('abbreviateNumber bnValue: ', bnValue); + + if (bnValue.isNaN()) return 'NaN'; + if (bnValue.isZero()) return '0'; + const absValue = bnValue.abs(); + console.log('abbreviateNumber absValue: ', absValue); + + const suffixes = [ + { value: 1e27, symbol: 'No' }, + { value: 1e24, symbol: 'Oc' }, + { value: 1e21, symbol: 'Sp' }, + { value: 1e18, symbol: 'Sx' }, + { value: 1e15, symbol: 'Qi' }, + { value: 1e12, symbol: 'Qa' }, + { value: 1e9, symbol: 'B' }, + { value: 1e6, symbol: 'M' }, + { value: 1e3, symbol: 'K' }, + ]; + + for (let i = 0; i < suffixes.length; i++) { + if (absValue.gte(suffixes[i].value)) { + const newValue = `${bnValue.dividedBy(suffixes[i].value).toFixed(2)}${ + suffixes[i].symbol + }`; + console.log('abbreviateNumber newValue: ', newValue); + return newValue; + } + } + + // Handle small numbers and decimals + if (absValue.lt(0.000001)) { + return `< 0.000001`; + } else if (absValue.lt(1)) { + // Ensure up to 8 significant digits + let significantValue = bnValue.toPrecision(8); + // Trim to ensure maximum 6 characters, considering decimal point + if (significantValue.length > 8) { + significantValue = significantValue.slice(0, 8); + } + return significantValue.replace(/\.?0+$/, ''); + } + + return bnValue.toFixed(2); }; export const handleSignificantDecimals = ( diff --git a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx index 24e3a62c71..52ee596839 100644 --- a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx +++ b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx @@ -3,6 +3,7 @@ import { useMemo } from 'react'; import { useCurrentCurrencyStore } from '~/core/state'; import { ParsedSearchAsset } from '~/core/types/assets'; import { + abbreviateNumber, convertRawAmountToBalance, convertRawAmountToNativeDisplay, } from '~/core/utils/numbers'; @@ -50,6 +51,10 @@ export const SwapAssetCard = ({ [asset.decimals, asset.price?.value, assetAmount, currentCurrency], ); + const amountWithAbbreviation = abbreviateNumber(amount); + + console.log('amountWIthAbbreviation: ', amountWithAbbreviation); + return ( - {`${amount}`} + {`${amountWithAbbreviation}`} From 0ce1ee154c1423b9c5ec4d115235b8941ff602c6 Mon Sep 17 00:00:00 2001 From: BrodyHughes <41711440+BrodyHughes@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:37:33 -0500 Subject: [PATCH 2/5] clean up --- lavamoat/build-webpack/policy.json | 172 +++++++++--------- src/core/utils/numbers.ts | 13 +- .../swap/SwapReviewSheet/SwapAssetCard.tsx | 2 - 3 files changed, 88 insertions(+), 99 deletions(-) diff --git a/lavamoat/build-webpack/policy.json b/lavamoat/build-webpack/policy.json index 75eb27fe32..e2a8f44a30 100644 --- a/lavamoat/build-webpack/policy.json +++ b/lavamoat/build-webpack/policy.json @@ -1099,13 +1099,13 @@ "eslint>debug": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-environment-visitor": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/parser": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true + "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-environment-visitor": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": { @@ -1114,36 +1114,8 @@ "process.emitWarning": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": { - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>@babel/helper-validator-identifier": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": true, - "react>loose-envify>js-tokens": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": { - "globals": { - "process.env.TERM": true, - "process.platform": true - }, - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>escape-string-regexp": true, - "supports-color": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": { - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": { - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true, + "lavamoat>@babel/highlight": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": { @@ -1195,113 +1167,141 @@ "define": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": { + "jest>@jest/core>jest-snapshot>@babel/types": { + "globals": { + "console.trace": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { - "globals": { - "console.warn": true, - "process.emitWarning": true - }, + "lavamoat>@babel/highlight": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true + "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, + "lavamoat>@babel/highlight>chalk": true, + "react>loose-envify>js-tokens": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { + "lavamoat>@babel/highlight>chalk": { "globals": { "process.env.TERM": true, "process.platform": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, + "lavamoat>@babel/highlight>chalk>ansi-styles": true, + "lavamoat>@babel/highlight>chalk>escape-string-regexp": true, "supports-color": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { + "lavamoat>@babel/highlight>chalk>ansi-styles": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": { - "globals": { - "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { "globals": { "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true + "process.emitWarning": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>@babel/highlight": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { + "globals": { + "process.env.TERM": true, + "process.platform": true + }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, + "supports-color": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true } }, - "jest>@jest/core>jest-snapshot>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { "globals": { - "console.trace": true, + "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true } }, "lint-staged>execa>merge-stream": { diff --git a/src/core/utils/numbers.ts b/src/core/utils/numbers.ts index 626d3f4aac..8cd6e83358 100644 --- a/src/core/utils/numbers.ts +++ b/src/core/utils/numbers.ts @@ -228,31 +228,24 @@ export const lessOrEqualThan = ( new BigNumber(numberOne).lt(numberTwo) || new BigNumber(numberOne).eq(numberTwo); -// returns decimal within threshold and trims excess 0's export const handleSignificantDecimalsWithThreshold = ( value: BigNumberish, decimals: number, threshold = '0.0001', ): string => { - const cleanValue = value.toString().replace(/,/g, ''); - const bnValue = new BigNumber(cleanValue); - const result = bnValue.toFixed(decimals).replace(/\.?0+$/, ''); - return new BigNumber(result).lt(threshold) ? `< ${threshold}` : result; + const result = toFixedDecimals(value, decimals); + return lessThan(result, threshold) ? `< ${threshold}` : result; }; // abbreviate numbers and return abbreivated values export const abbreviateNumber = (value: BigNumberish): string => { - console.log('abbreviateNumber value: ', value); - // Remove commas from the input value const cleanValue = value.toString().replace(/,/g, ''); const bnValue = new BigNumber(cleanValue); - console.log('abbreviateNumber bnValue: ', bnValue); if (bnValue.isNaN()) return 'NaN'; if (bnValue.isZero()) return '0'; const absValue = bnValue.abs(); - console.log('abbreviateNumber absValue: ', absValue); const suffixes = [ { value: 1e27, symbol: 'No' }, @@ -280,9 +273,7 @@ export const abbreviateNumber = (value: BigNumberish): string => { if (absValue.lt(0.000001)) { return `< 0.000001`; } else if (absValue.lt(1)) { - // Ensure up to 8 significant digits let significantValue = bnValue.toPrecision(8); - // Trim to ensure maximum 6 characters, considering decimal point if (significantValue.length > 8) { significantValue = significantValue.slice(0, 8); } diff --git a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx index 52ee596839..4202979fd9 100644 --- a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx +++ b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx @@ -53,8 +53,6 @@ export const SwapAssetCard = ({ const amountWithAbbreviation = abbreviateNumber(amount); - console.log('amountWIthAbbreviation: ', amountWithAbbreviation); - return ( Date: Tue, 9 Jul 2024 15:50:02 -0500 Subject: [PATCH 3/5] use existing function --- src/core/utils/numbers.ts | 48 +------------------ .../swap/SwapReviewSheet/SwapAssetCard.tsx | 16 +++++-- .../swap/SwapReviewSheet/SwapReviewSheet.tsx | 30 +++++++++++- 3 files changed, 43 insertions(+), 51 deletions(-) diff --git a/src/core/utils/numbers.ts b/src/core/utils/numbers.ts index 8cd6e83358..f426b15c69 100644 --- a/src/core/utils/numbers.ts +++ b/src/core/utils/numbers.ts @@ -232,57 +232,11 @@ export const handleSignificantDecimalsWithThreshold = ( value: BigNumberish, decimals: number, threshold = '0.0001', -): string => { +) => { const result = toFixedDecimals(value, decimals); return lessThan(result, threshold) ? `< ${threshold}` : result; }; -// abbreviate numbers and return abbreivated values -export const abbreviateNumber = (value: BigNumberish): string => { - // Remove commas from the input value - const cleanValue = value.toString().replace(/,/g, ''); - const bnValue = new BigNumber(cleanValue); - - if (bnValue.isNaN()) return 'NaN'; - if (bnValue.isZero()) return '0'; - const absValue = bnValue.abs(); - - const suffixes = [ - { value: 1e27, symbol: 'No' }, - { value: 1e24, symbol: 'Oc' }, - { value: 1e21, symbol: 'Sp' }, - { value: 1e18, symbol: 'Sx' }, - { value: 1e15, symbol: 'Qi' }, - { value: 1e12, symbol: 'Qa' }, - { value: 1e9, symbol: 'B' }, - { value: 1e6, symbol: 'M' }, - { value: 1e3, symbol: 'K' }, - ]; - - for (let i = 0; i < suffixes.length; i++) { - if (absValue.gte(suffixes[i].value)) { - const newValue = `${bnValue.dividedBy(suffixes[i].value).toFixed(2)}${ - suffixes[i].symbol - }`; - console.log('abbreviateNumber newValue: ', newValue); - return newValue; - } - } - - // Handle small numbers and decimals - if (absValue.lt(0.000001)) { - return `< 0.000001`; - } else if (absValue.lt(1)) { - let significantValue = bnValue.toPrecision(8); - if (significantValue.length > 8) { - significantValue = significantValue.slice(0, 8); - } - return significantValue.replace(/\.?0+$/, ''); - } - - return bnValue.toFixed(2); -}; - export const handleSignificantDecimals = ( value: BigNumberish, decimals: number, diff --git a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx index 4202979fd9..148cc8ccce 100644 --- a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx +++ b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx @@ -2,8 +2,8 @@ import { useMemo } from 'react'; import { useCurrentCurrencyStore } from '~/core/state'; import { ParsedSearchAsset } from '~/core/types/assets'; +import { formatCurrency } from '~/core/utils/formatNumber'; import { - abbreviateNumber, convertRawAmountToBalance, convertRawAmountToNativeDisplay, } from '~/core/utils/numbers'; @@ -50,8 +50,18 @@ export const SwapAssetCard = ({ ).display, [asset.decimals, asset.price?.value, assetAmount, currentCurrency], ); + const cleanNumber = (n: number | string | null | undefined): number => { + if (typeof n === 'string') { + return parseFloat(n.replace(/,/g, '')); + } + return n || 0; + }; - const amountWithAbbreviation = abbreviateNumber(amount); + const formatNumber = (n?: number | string | null) => + formatCurrency(cleanNumber(n), { + notation: 'compact', + maximumSignificantDigits: 4, + }); return ( - {`${amountWithAbbreviation}`} + {`${formatNumber(amount)}`} diff --git a/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx b/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx index 384d3b7841..ca09e548c4 100644 --- a/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx +++ b/src/entries/popup/pages/swap/SwapReviewSheet/SwapReviewSheet.tsx @@ -20,6 +20,7 @@ import { useSwapAssetsToRefreshStore } from '~/core/state/swapAssetsToRefresh'; import { ParsedSearchAsset } from '~/core/types/assets'; import { ChainId } from '~/core/types/chains'; import { truncateAddress } from '~/core/utils/address'; +import { formatCurrency } from '~/core/utils/formatNumber'; import { isLowerCaseMatch } from '~/core/utils/strings'; import { isUnwrapEth, isWrapEth } from '~/core/utils/swaps'; import { @@ -243,6 +244,33 @@ const SwapReviewSheetWithQuote = ({ const { minimumReceived, swappingRoute, includedFee, exchangeRate } = useSwapReviewDetails({ quote, assetToBuy, assetToSell }); + const cleanNumber = (n: string): number => { + return parseFloat(n.replace(/,/g, '')); + }; + + const formatNumber = (n: string) => + formatCurrency(cleanNumber(n), { + notation: 'compact', + maximumSignificantDigits: 4, + }); + + const processArray = (arr: string[]): string[] => { + return arr.map((item) => { + const parts = item.split(' '); + if (parts.length === 5) { + const formattedAmount = formatNumber(parts[3]); + return `${parts[0]} ${parts[1]} ${parts[2]} ${formattedAmount} ${parts[4]}`; + } + return item; + }); + }; + + const formattedExchangeRate = useMemo( + () => processArray(exchangeRate), + // eslint-disable-next-line react-hooks/exhaustive-deps + [exchangeRate], + ); + const { explainerSheetParams, showExplainerSheet, hideExplainerSheet } = useExplainerSheetParams(); @@ -615,7 +643,7 @@ const SwapReviewSheetWithQuote = ({ {!assetToSell.isNativeAsset && ( From 9c95d506c16d94b64e0ffdcd4822a6ff8d556b2e Mon Sep 17 00:00:00 2001 From: BrodyHughes <41711440+BrodyHughes@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:27:43 -0500 Subject: [PATCH 4/5] fix chris / daniel concerns --- lavamoat/build-webpack/policy.json | 172 +++++++++--------- src/core/utils/numbers.ts | 30 +++ .../swap/SwapReviewSheet/SwapAssetCard.tsx | 14 +- .../swap/SwapReviewSheet/SwapReviewSheet.tsx | 25 +-- 4 files changed, 119 insertions(+), 122 deletions(-) diff --git a/lavamoat/build-webpack/policy.json b/lavamoat/build-webpack/policy.json index e2a8f44a30..75eb27fe32 100644 --- a/lavamoat/build-webpack/policy.json +++ b/lavamoat/build-webpack/policy.json @@ -1099,13 +1099,13 @@ "eslint>debug": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-environment-visitor": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/parser": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-environment-visitor": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": true + "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": { @@ -1114,8 +1114,36 @@ "process.emitWarning": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true, - "lavamoat>@babel/highlight": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": { + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>@babel/helper-validator-identifier": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": true, + "react>loose-envify>js-tokens": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": { + "globals": { + "process.env.TERM": true, + "process.platform": true + }, + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>escape-string-regexp": true, + "supports-color": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": { + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": true + } + }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": { + "packages": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": { @@ -1167,141 +1195,113 @@ "define": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { - "globals": { - "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "jest>@jest/core>jest-snapshot>@babel/types": { - "globals": { - "console.trace": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "lavamoat>@babel/highlight": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { + "globals": { + "console.warn": true, + "process.emitWarning": true + }, "packages": { - "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, - "lavamoat>@babel/highlight>chalk": true, - "react>loose-envify>js-tokens": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true } }, - "lavamoat>@babel/highlight>chalk": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { "globals": { "process.env.TERM": true, "process.platform": true }, "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles": true, - "lavamoat>@babel/highlight>chalk>escape-string-regexp": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, "supports-color": true } }, - "lavamoat>@babel/highlight>chalk>ansi-styles": { - "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": true - } - }, - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": { - "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true - } - }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": { "globals": { "console.warn": true, - "process.emitWarning": true - }, - "packages": { - "lavamoat>@babel/highlight": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true - } - }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { - "globals": { - "process.env.TERM": true, - "process.platform": true + "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, - "supports-color": true - } - }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { - "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": { "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { + "jest>@jest/core>jest-snapshot>@babel/types": { "globals": { - "console.warn": true, + "console.trace": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, - "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, "lint-staged>execa>merge-stream": { diff --git a/src/core/utils/numbers.ts b/src/core/utils/numbers.ts index f426b15c69..282a470d84 100644 --- a/src/core/utils/numbers.ts +++ b/src/core/utils/numbers.ts @@ -5,6 +5,7 @@ import { isNil } from 'lodash'; import { supportedCurrencies } from '~/core/references'; +import { formatCurrency } from './formatNumber'; import { BigNumberish } from './hex'; type nativeCurrencyType = typeof supportedCurrencies; @@ -473,3 +474,32 @@ export const convertDecimalFormatToRawAmount = ( export const fromWei = (number: BigNumberish): string => convertRawAmountToDecimalFormat(number, 18); + +const cleanNumber = (n: number | string | null | undefined): number => { + if (typeof n === 'string') { + return parseFloat(n.replace(/,/g, '')); + } + return n || 0; +}; + +export const formatNumber = (n?: number | string | null) => { + let value = formatCurrency(cleanNumber(n), { + notation: 'compact', + maximumSignificantDigits: 4, + }); + while (value.charAt(0) === '$') { + value = value.substring(1); + } + return value; +}; + +export const processExchangeRateArray = (arr: string[]): string[] => { + return arr.map((item) => { + const parts = item.split(' '); + if (parts.length === 5) { + const formattedAmount = formatNumber(parts[3]); + return `${parts[0]} ${parts[1]} ${parts[2]} ${formattedAmount} ${parts[4]}`; + } + return item; + }); +}; diff --git a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx index 148cc8ccce..23c4ef263b 100644 --- a/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx +++ b/src/entries/popup/pages/swap/SwapReviewSheet/SwapAssetCard.tsx @@ -2,10 +2,10 @@ import { useMemo } from 'react'; import { useCurrentCurrencyStore } from '~/core/state'; import { ParsedSearchAsset } from '~/core/types/assets'; -import { formatCurrency } from '~/core/utils/formatNumber'; import { convertRawAmountToBalance, convertRawAmountToNativeDisplay, + formatNumber, } from '~/core/utils/numbers'; import { Box, @@ -50,18 +50,6 @@ export const SwapAssetCard = ({ ).display, [asset.decimals, asset.price?.value, assetAmount, currentCurrency], ); - const cleanNumber = (n: number | string | null | undefined): number => { - if (typeof n === 'string') { - return parseFloat(n.replace(/,/g, '')); - } - return n || 0; - }; - - const formatNumber = (n?: number | string | null) => - formatCurrency(cleanNumber(n), { - notation: 'compact', - maximumSignificantDigits: 4, - }); return ( { - return parseFloat(n.replace(/,/g, '')); - }; - - const formatNumber = (n: string) => - formatCurrency(cleanNumber(n), { - notation: 'compact', - maximumSignificantDigits: 4, - }); - - const processArray = (arr: string[]): string[] => { - return arr.map((item) => { - const parts = item.split(' '); - if (parts.length === 5) { - const formattedAmount = formatNumber(parts[3]); - return `${parts[0]} ${parts[1]} ${parts[2]} ${formattedAmount} ${parts[4]}`; - } - return item; - }); - }; - const formattedExchangeRate = useMemo( - () => processArray(exchangeRate), + () => processExchangeRateArray(exchangeRate), // eslint-disable-next-line react-hooks/exhaustive-deps [exchangeRate], ); From cadc3e1e70487506087aae5eab3516e87e44baa7 Mon Sep 17 00:00:00 2001 From: BrodyHughes <41711440+BrodyHughes@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:28:09 -0500 Subject: [PATCH 5/5] oops --- lavamoat/build-webpack/policy.json | 172 ++++++++++++++--------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/lavamoat/build-webpack/policy.json b/lavamoat/build-webpack/policy.json index 75eb27fe32..e2a8f44a30 100644 --- a/lavamoat/build-webpack/policy.json +++ b/lavamoat/build-webpack/policy.json @@ -1099,13 +1099,13 @@ "eslint>debug": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-environment-visitor": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/parser": true, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true + "jest>@jest/core>jest-snapshot>@babel/traverse>globals": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-environment-visitor": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame": { @@ -1114,36 +1114,8 @@ "process.emitWarning": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": { - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>@babel/helper-validator-identifier": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": true, - "react>loose-envify>js-tokens": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk": { - "globals": { - "process.env.TERM": true, - "process.platform": true - }, - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>escape-string-regexp": true, - "supports-color": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles": { - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": true - } - }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": { - "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": true, + "lavamoat>@babel/highlight": true } }, "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>chalk": { @@ -1195,113 +1167,141 @@ "define": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name": { + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template": { + "jest>@jest/core>jest-snapshot>@babel/types": { + "globals": { + "console.trace": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": true + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, + "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { - "globals": { - "console.warn": true, - "process.emitWarning": true - }, + "lavamoat>@babel/highlight": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/code-frame>@babel/highlight": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true + "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, + "lavamoat>@babel/highlight>chalk": true, + "react>loose-envify>js-tokens": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { + "lavamoat>@babel/highlight>chalk": { "globals": { "process.env.TERM": true, "process.platform": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, + "lavamoat>@babel/highlight>chalk>ansi-styles": true, + "lavamoat>@babel/highlight>chalk>escape-string-regexp": true, "supports-color": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { + "lavamoat>@babel/highlight>chalk>ansi-styles": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true + "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types": { - "globals": { - "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true - }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template": { "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame": { "globals": { "console.warn": true, - "process.env.BABEL_TYPES_8_BREAKING": true + "process.emitWarning": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>@babel/highlight": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk": { + "globals": { + "process.env.TERM": true, + "process.platform": true + }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>escape-string-regexp": true, + "supports-color": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/template>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-string-parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name>@babel/types>@babel/helper-validator-identifier": true } }, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types": { "globals": { "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-string-parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables>@babel/types>@babel/helper-validator-identifier": true } }, - "jest>@jest/core>jest-snapshot>@babel/types": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": { + "packages": { + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types": { "globals": { - "console.trace": true, + "console.warn": true, "process.env.BABEL_TYPES_8_BREAKING": true }, "packages": { - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-string-parser": true, - "jest>@jest/core>jest-snapshot>@babel/types>@babel/helper-validator-identifier": true, - "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true + "lavamoat>lavamoat-core>@babel/types>to-fast-properties": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-string-parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration>@babel/types>@babel/helper-validator-identifier": true } }, "lint-staged>execa>merge-stream": {