From df9ff6438c9fe3fd15afd7003c4497c314bc6382 Mon Sep 17 00:00:00 2001
From: MetaMask Bot
Date: Thu, 19 Jan 2023 20:30:17 +0000
Subject: [PATCH 01/21] Version v10.24.1
---
CHANGELOG.md | 5 ++++-
package.json | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1def3a26453f..ea297b2f0289 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [10.24.1]
+
## [10.24.0]
### Added
- Add NFT setApprovalForAll warning popover when approving the NFT Colleciton ([#16195](https://github.com/MetaMask/metamask-extension/pull/16195))
@@ -3423,7 +3425,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Uncategorized
- Added the ability to restore accounts from seed words.
-[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.24.0...HEAD
+[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.24.1...HEAD
+[10.24.1]: https://github.com/MetaMask/metamask-extension/compare/v10.24.0...v10.24.1
[10.24.0]: https://github.com/MetaMask/metamask-extension/compare/v10.23.3...v10.24.0
[10.23.3]: https://github.com/MetaMask/metamask-extension/compare/v10.23.2...v10.23.3
[10.23.2]: https://github.com/MetaMask/metamask-extension/compare/v10.23.1...v10.23.2
diff --git a/package.json b/package.json
index a47fa7dec42d..366ac9999708 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "metamask-crx",
- "version": "10.24.0",
+ "version": "10.24.1",
"private": true,
"repository": {
"type": "git",
From 0a7f83172dc622490aa8a62628e37907b3ae49f2 Mon Sep 17 00:00:00 2001
From: Dan J Miller
Date: Thu, 19 Jan 2023 14:52:46 -0800
Subject: [PATCH 02/21] Add missing appName in the zh_TW language file (#17304)
* Add missing appName in the zh_TW language file
* Fix
---
app/_locales/zh_TW/messages.json | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json
index a1749a85b2ef..07812e647892 100644
--- a/app/_locales/zh_TW/messages.json
+++ b/app/_locales/zh_TW/messages.json
@@ -122,6 +122,18 @@
"message": "以太坊瀏覽器擴充插件",
"description": "The description of the application"
},
+ "appName": {
+ "message": "MetaMask",
+ "description": "The name of the application"
+ },
+ "appNameBeta": {
+ "message": "MetaMask Beta",
+ "description": "The name of the application (Beta)"
+ },
+ "appNameFlask": {
+ "message": "MetaMask Flask",
+ "description": "The name of the application (Flask)"
+ },
"approve": {
"message": "批准花費上限"
},
From ebd302b1c24c029014d252f341bf11cf99a6782c Mon Sep 17 00:00:00 2001
From: Dan Miller
Date: Fri, 20 Jan 2023 08:25:36 -0330
Subject: [PATCH 03/21] Update changelong for v10.24.1
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea297b2f0289..cd6d87dc9769 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [10.24.1]
+- Ensure app name appears for Taiwanese language speakers in the extension stores ([#17304](https://github.com/MetaMask/metamask-extension/pull/17304))
## [10.24.0]
### Added
From a1d5c1ad6e1057d85a21108fd6027f6c6252f89a Mon Sep 17 00:00:00 2001
From: PeterYinusa
Date: Fri, 20 Jan 2023 12:18:11 +0000
Subject: [PATCH 04/21] Update changelong for v10.24.1
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd6d87dc9769..8dd0763e3086 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [10.24.1]
+### Added
- Ensure app name appears for Taiwanese language speakers in the extension stores ([#17304](https://github.com/MetaMask/metamask-extension/pull/17304))
## [10.24.0]
From cf10b2a1a091662c6d3268110745267e753c3f69 Mon Sep 17 00:00:00 2001
From: David Walsh
Date: Mon, 23 Jan 2023 16:04:11 -0600
Subject: [PATCH 05/21] Fix #17300, #16843 - Use proper source for image of
IPFS NFTs (#17302)
---
.../app/collectible-details/collectible-details.js | 5 ++++-
.../confirm-page-container-summary.component.js | 10 ++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/ui/components/app/collectible-details/collectible-details.js b/ui/components/app/collectible-details/collectible-details.js
index 78dffbe0c766..0c198a58c970 100644
--- a/ui/components/app/collectible-details/collectible-details.js
+++ b/ui/components/app/collectible-details/collectible-details.js
@@ -175,7 +175,10 @@ export default function CollectibleDetails({ collectible }) {
className="collectible-details__card"
>
{image ? (
-
+
) : (
)}
diff --git a/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-summary/confirm-page-container-summary.component.js b/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-summary/confirm-page-container-summary.component.js
index ace2c3ff747c..ccb62846efd9 100644
--- a/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-summary/confirm-page-container-summary.component.js
+++ b/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-summary/confirm-page-container-summary.component.js
@@ -1,5 +1,7 @@
/* eslint-disable no-negated-condition */
import React, { useState } from 'react';
+import { useSelector } from 'react-redux';
+
import PropTypes from 'prop-types';
import classnames from 'classnames';
@@ -7,6 +9,7 @@ import { TransactionType } from '../../../../../../shared/constants/transaction'
import { toChecksumHexAddress } from '../../../../../../shared/modules/hexstring-utils';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import useAddressDetails from '../../../../../hooks/useAddressDetails';
+import { getIpfsGateway } from '../../../../../selectors';
import Identicon from '../../../../ui/identicon';
import InfoTooltip from '../../../../ui/info-tooltip';
@@ -15,6 +18,7 @@ import Typography from '../../../../ui/typography';
import { TYPOGRAPHY } from '../../../../../helpers/constants/design-system';
import { ORIGIN_METAMASK } from '../../../../../../shared/constants/app';
import SiteOrigin from '../../../../ui/site-origin';
+import { getAssetImageURL } from '../../../../../helpers/utils/util';
const ConfirmPageContainerSummary = (props) => {
const {
@@ -35,6 +39,7 @@ const ConfirmPageContainerSummary = (props) => {
const [showNicknamePopovers, setShowNicknamePopovers] = useState(false);
const t = useI18nContext();
+ const ipfsGateway = useSelector(getIpfsGateway);
const contractInitiatedTransactionType = [
TransactionType.contractInteraction,
@@ -62,12 +67,14 @@ const ConfirmPageContainerSummary = (props) => {
const checksummedAddress = toChecksumHexAddress(contractAddress);
const renderImage = () => {
+ const imagePath = getAssetImageURL(image, ipfsGateway);
+
if (image) {
return (
);
} else if (contractAddress) {
@@ -76,7 +83,6 @@ const ConfirmPageContainerSummary = (props) => {
className="confirm-page-container-summary__icon"
diameter={36}
address={contractAddress}
- image={image}
/>
);
}
From dd09245ff647581efe1de5b71158b77c8c4cdb6a Mon Sep 17 00:00:00 2001
From: amerkadicE <97883527+amerkadicE@users.noreply.github.com>
Date: Tue, 24 Jan 2023 15:10:36 +0100
Subject: [PATCH 06/21] Fix/use etherjs specific imports (#15461)
* replace ethers with submodules
Co-authored-by: Alex
---
app/scripts/controllers/ens/ens.js | 4 +-
app/scripts/controllers/preferences.js | 2 -
app/scripts/controllers/swaps.js | 13 +-
app/scripts/controllers/swaps.test.js | 20 +-
app/scripts/lib/account-tracker.js | 10 +-
lavamoat/browserify/beta/policy.json | 744 ++++++++++++-----------
lavamoat/browserify/flask/policy.json | 744 ++++++++++++-----------
lavamoat/browserify/main/policy.json | 744 ++++++++++++-----------
lavamoat/build-system/policy.json | 2 +
package.json | 4 +-
shared/modules/transaction.utils.js | 8 +-
test/e2e/seeder/ganache-seeder.js | 11 +-
ui/components/app/srp-input/srp-input.js | 4 +-
ui/ducks/domains.js | 15 +-
ui/ducks/send/helpers.test.js | 6 +-
ui/ducks/send/send.test.js | 4 +-
ui/pages/send/send.test.js | 15 +-
yarn.lock | 9 +-
18 files changed, 1177 insertions(+), 1182 deletions(-)
diff --git a/app/scripts/controllers/ens/ens.js b/app/scripts/controllers/ens/ens.js
index 2242a2b8cd00..4f8de4a12a1f 100644
--- a/app/scripts/controllers/ens/ens.js
+++ b/app/scripts/controllers/ens/ens.js
@@ -1,4 +1,4 @@
-import { ethers } from 'ethers';
+import { Web3Provider } from '@ethersproject/providers';
import ensNetworkMap from 'ethereum-ens-network-map';
import { NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP } from '../../../../shared/constants/network';
@@ -10,7 +10,7 @@ export default class Ens {
constructor({ network, provider } = {}) {
const networkName = NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP[network];
const ensAddress = ensNetworkMap[network];
- const ethProvider = new ethers.providers.Web3Provider(provider, {
+ const ethProvider = new Web3Provider(provider, {
chainId: parseInt(network, 10),
name: networkName,
ensAddress,
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 7f6eef8241dd..f2775bb7983f 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -1,6 +1,5 @@
import { ObservableStore } from '@metamask/obs-store';
import { normalize as normalizeAddress } from 'eth-sig-util';
-import { ethers } from 'ethers';
import { IPFS_DEFAULT_GATEWAY_URL } from '../../../shared/constants/network';
import { isPrefixedFormattedHexString } from '../../../shared/modules/network.utils';
import { LedgerTransportTypes } from '../../../shared/constants/hardware-wallets';
@@ -72,7 +71,6 @@ export default class PreferencesController {
};
this.network = opts.network;
- this.ethersProvider = new ethers.providers.Web3Provider(opts.provider);
this.store = new ObservableStore(initState);
this.store.setMaxListeners(12);
this.openPopup = opts.openPopup;
diff --git a/app/scripts/controllers/swaps.js b/app/scripts/controllers/swaps.js
index a048839ca7c1..78e6b03eef23 100644
--- a/app/scripts/controllers/swaps.js
+++ b/app/scripts/controllers/swaps.js
@@ -1,4 +1,5 @@
-import { ethers } from 'ethers';
+import { Web3Provider } from '@ethersproject/providers';
+import { Contract } from '@ethersproject/contracts';
import log from 'loglevel';
import BigNumber from 'bignumber.js';
import { ObservableStore } from '@metamask/obs-store';
@@ -134,12 +135,12 @@ export default class SwapsController {
this.indexOfNewestCallInFlight = 0;
- this.ethersProvider = new ethers.providers.Web3Provider(provider);
+ this.ethersProvider = new Web3Provider(provider);
this._currentNetwork = networkController.store.getState().network;
networkController.on(NETWORK_EVENTS.NETWORK_DID_CHANGE, (network) => {
if (network !== 'loading' && network !== this._currentNetwork) {
this._currentNetwork = network;
- this.ethersProvider = new ethers.providers.Web3Provider(provider);
+ this.ethersProvider = new Web3Provider(provider);
}
});
}
@@ -891,11 +892,7 @@ export default class SwapsController {
}
async _getERC20Allowance(contractAddress, walletAddress, chainId) {
- const contract = new ethers.Contract(
- contractAddress,
- abi,
- this.ethersProvider,
- );
+ const contract = new Contract(contractAddress, abi, this.ethersProvider);
return await contract.allowance(
walletAddress,
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[chainId],
diff --git a/app/scripts/controllers/swaps.test.js b/app/scripts/controllers/swaps.test.js
index 0768b9791570..7b953ba34c1e 100644
--- a/app/scripts/controllers/swaps.test.js
+++ b/app/scripts/controllers/swaps.test.js
@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import sinon from 'sinon';
-import { ethers } from 'ethers';
+import { BigNumber } from '@ethersproject/bignumber';
import { mapValues } from 'lodash';
-import BigNumber from 'bignumber.js';
+import BigNumberjs from 'bignumber.js';
import { CHAIN_IDS, NETWORK_IDS } from '../../../shared/constants/network';
import { ETH_SWAPS_TOKEN_OBJECT } from '../../../shared/constants/swaps';
import { createTestProviderTools } from '../../../test/stub/provider';
@@ -373,7 +373,7 @@ describe('SwapsController', function () {
assert.strictEqual(gasEstimate, bufferedGasLimit);
assert.strictEqual(
gasEstimateWithRefund,
- `0x${new BigNumber(maxGas, 10)
+ `0x${new BigNumberjs(maxGas, 10)
.minus(estimatedRefund, 10)
.toString(16)}`,
);
@@ -667,7 +667,7 @@ describe('SwapsController', function () {
// Make it so approval is not required
sandbox
.stub(swapsController, '_getERC20Allowance')
- .resolves(ethers.BigNumber.from(1));
+ .resolves(BigNumber.from(1));
const [newQuotes] = await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
@@ -711,7 +711,7 @@ describe('SwapsController', function () {
// Make it so approval is not required
const allowanceStub = sandbox
.stub(swapsController, '_getERC20Allowance')
- .resolves(ethers.BigNumber.from(1));
+ .resolves(BigNumber.from(1));
await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
@@ -734,7 +734,7 @@ describe('SwapsController', function () {
// Ensure approval is required
sandbox
.stub(swapsController, '_getERC20Allowance')
- .resolves(ethers.BigNumber.from(0));
+ .resolves(BigNumber.from(0));
const timedoutGasReturnResult = { gasLimit: 1000000 };
const timedoutGasReturnStub = sandbox
@@ -759,7 +759,7 @@ describe('SwapsController', function () {
// Make it so approval is not required
sandbox
.stub(swapsController, '_getERC20Allowance')
- .resolves(ethers.BigNumber.from(1));
+ .resolves(BigNumber.from(1));
const [newQuotes, topAggId] = await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
@@ -777,7 +777,7 @@ describe('SwapsController', function () {
const bestQuote = {
...getMockQuotes()[TEST_AGG_ID_1],
aggregator: bestAggId,
- destinationAmount: ethers.BigNumber.from(
+ destinationAmount: BigNumber.from(
getMockQuotes()[TEST_AGG_ID_1].destinationAmount,
)
.add((100e18).toString())
@@ -789,7 +789,7 @@ describe('SwapsController', function () {
// Make it so approval is not required
sandbox
.stub(swapsController, '_getERC20Allowance')
- .resolves(ethers.BigNumber.from(1));
+ .resolves(BigNumber.from(1));
const [newQuotes, topAggId] = await swapsController.fetchAndSetQuotes(
MOCK_FETCH_PARAMS,
@@ -806,7 +806,7 @@ describe('SwapsController', function () {
// Make it so approval is not required
sandbox
.stub(swapsController, '_getERC20Allowance')
- .resolves(ethers.BigNumber.from(1));
+ .resolves(BigNumber.from(1));
swapsController.getTokenRatesState = () => ({
contractExchangeRates: {},
diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js
index 6757dcf4a829..eed68abae502 100644
--- a/app/scripts/lib/account-tracker.js
+++ b/app/scripts/lib/account-tracker.js
@@ -12,7 +12,8 @@ import EthQuery from 'eth-query';
import { ObservableStore } from '@metamask/obs-store';
import log from 'loglevel';
import pify from 'pify';
-import { ethers } from 'ethers';
+import { Web3Provider } from '@ethersproject/providers';
+import { Contract } from '@ethersproject/contracts';
import SINGLE_CALL_BALANCES_ABI from 'single-call-balance-checker-abi';
import {
CHAIN_IDS,
@@ -82,8 +83,6 @@ export default class AccountTracker {
this.preferencesController = opts.preferencesController;
this.onboardingController = opts.onboardingController;
- this.ethersProvider = new ethers.providers.Web3Provider(this._provider);
-
this.onboardingController.store.subscribe(
previousValueComparator(async (prevState, currState) => {
const { completedOnboarding: prevCompletedOnboarding } = prevState;
@@ -109,6 +108,7 @@ export default class AccountTracker {
}
}, this.onboardingController.store.getState()),
);
+ this.ethersProvider = new Web3Provider(this._provider);
}
start() {
@@ -391,9 +391,9 @@ export default class AccountTracker {
newAccounts[address] = { address, balance: null };
}
});
- this.ethersProvider = new ethers.providers.Web3Provider(this._provider);
+ this.ethersProvider = new Web3Provider(this._provider);
- const ethContract = await new ethers.Contract(
+ const ethContract = await new Contract(
deployedContractAddress,
SINGLE_CALL_BALANCES_ABI,
this.ethersProvider,
diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json
index 2208d70dfc2a..8d5454123850 100644
--- a/lavamoat/browserify/beta/policy.json
+++ b/lavamoat/browserify/beta/policy.json
@@ -138,11 +138,89 @@
"ethereumjs-util": true
}
},
+ "@ethersproject/abi": {
+ "globals": {
+ "console.log": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/address": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/providers>@ethersproject/rlp": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/bytes": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/constants": {
+ "packages": {
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/hash": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/providers>@ethersproject/base64": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/keccak256": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256>js-sha3": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/keccak256>js-sha3": {
+ "globals": {
+ "define": true
+ },
+ "packages": {
+ "browserify>process": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/logger": {
+ "globals": {
+ "console": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/properties": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/strings": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
"@ethersproject/bignumber": {
"packages": {
- "@ethersproject/bignumber>bn.js": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber>bn.js": true
}
},
"@ethersproject/bignumber>bn.js": {
@@ -158,15 +236,85 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi": true,
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true
+ }
+ },
+ "@ethersproject/hdnode": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
"@ethersproject/bignumber": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/transactions": true
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/hdnode>@ethersproject/wordlists": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/basex": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/properties": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/sha2": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/signing-key": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "ganache>secp256k1>elliptic": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/transactions": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/providers>@ethersproject/rlp": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/wordlists": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true
}
},
"@ethersproject/providers": {
@@ -180,24 +328,72 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
"@ethersproject/bignumber": true,
- "@ethersproject/providers>bech32": true,
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/networks": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/web": true
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true,
+ "@ethersproject/providers>@ethersproject/base64": true,
+ "@ethersproject/providers>@ethersproject/networks": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@ethersproject/providers>@ethersproject/web": true,
+ "@ethersproject/providers>bech32": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/abstract-provider": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/base64": {
+ "globals": {
+ "atob": true,
+ "btoa": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/networks": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/random": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/rlp": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/web": {
+ "globals": {
+ "clearTimeout": true,
+ "fetch": true,
+ "setTimeout": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/providers>@ethersproject/base64": true
}
},
"@formatjs/intl-relativetimeformat": {
@@ -507,6 +703,7 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>abort-controller": true,
@@ -520,7 +717,6 @@
"eth-query": true,
"eth-rpc-errors": true,
"ethereumjs-util": true,
- "ethers>@ethersproject/abi": true,
"single-call-balance-checker-abi": true,
"uuid": true
}
@@ -643,7 +839,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware>eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -759,7 +955,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-ledger-bridge-keyring>eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -785,7 +981,7 @@
"eth-trezor-keyring>hdkey>secp256k1>bip66": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-token-tracker": {
@@ -1090,13 +1286,13 @@
"setInterval": true
},
"packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
"@ethersproject/bignumber": true,
"@ethersproject/providers": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/smart-transactions-controller>bignumber.js": true,
- "ethers>@ethersproject/bytes": true,
"fast-json-patch": true,
"lodash": true
}
@@ -1618,6 +1814,7 @@
},
"@truffle/decoder>@truffle/encoder": {
"packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
"@ethersproject/bignumber": true,
"@truffle/codec": true,
"@truffle/codec>@truffle/abi-utils": true,
@@ -1626,7 +1823,6 @@
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs": true,
"@truffle/decoder>@truffle/encoder>big.js": true,
"@truffle/decoder>@truffle/encoder>bignumber.js": true,
- "ethers>@ethersproject/address": true,
"lodash": true,
"nock>debug": true
}
@@ -1643,11 +1839,11 @@
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/ens": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/resolver": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>content-hash": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>js-sha3": true,
"browserify>buffer": true,
"eth-ens-namehash": true,
- "ethereumjs-wallet>bs58check>bs58": true,
- "ethers": true
+ "ethereumjs-wallet>bs58check>bs58": true
}
},
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/address-encoder": {
@@ -1709,6 +1905,91 @@
"ethereumjs-wallet>bs58check>bs58>base-x": true
}
},
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers": {
+ "packages": {
+ "@ethersproject/abi": true,
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/contracts": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/hdnode>@ethersproject/wordlists": true,
+ "@ethersproject/providers": true,
+ "@ethersproject/providers>@ethersproject/base64": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@ethersproject/providers>@ethersproject/rlp": true,
+ "@ethersproject/providers>@ethersproject/web": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/solidity": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/units": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/wallet": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets>aes-js": true,
+ "ethereumjs-util>ethereum-cryptography>scrypt-js": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets>aes-js": {
+ "globals": {
+ "define": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/solidity": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/units": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/wallet": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": true
+ }
+ },
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>js-sha3": {
"globals": {
"define": true
@@ -1891,7 +2172,7 @@
},
"browserify>crypto-browserify>browserify-cipher>browserify-des>des.js": {
"packages": {
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
"pumpify>inherits": true
}
},
@@ -1910,7 +2191,7 @@
"browserify>crypto-browserify>public-encrypt>parse-asn1": true,
"browserify>stream-browserify": true,
"ethereumjs-util>create-hash": true,
- "ethers>@ethersproject/signing-key>elliptic": true,
+ "ganache>secp256k1>elliptic": true,
"pumpify>inherits": true
}
},
@@ -1918,7 +2199,7 @@
"packages": {
"bn.js": true,
"browserify>buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"browserify>crypto-browserify>create-hmac": {
@@ -1942,7 +2223,7 @@
"browserify>crypto-browserify>diffie-hellman>miller-rabin": {
"packages": {
"bn.js": true,
- "ethers>@ethersproject/signing-key>elliptic>brorand": true
+ "ganache>secp256k1>elliptic>brorand": true
}
},
"browserify>crypto-browserify>pbkdf2": {
@@ -1992,7 +2273,7 @@
"bn.js": true,
"browserify>buffer": true,
"browserify>vm-browserify": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
"pumpify>inherits": true
}
},
@@ -2428,6 +2709,7 @@
},
"packages": {
"@ethereumjs/common>crc-32": true,
+ "@ethersproject/abi": true,
"bn.js": true,
"browserify>buffer": true,
"browserify>process": true,
@@ -2441,11 +2723,10 @@
"eth-lattice-keyring>gridplus-sdk>js-sha3": true,
"eth-lattice-keyring>gridplus-sdk>rlp": true,
"eth-lattice-keyring>gridplus-sdk>secp256k1": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/signing-key>elliptic": true,
+ "ganache>secp256k1>elliptic": true,
"lodash": true
}
},
@@ -2558,7 +2839,7 @@
},
"eth-lattice-keyring>gridplus-sdk>secp256k1": {
"packages": {
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-lattice-keyring>rlp": {
@@ -2602,7 +2883,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -2667,7 +2948,7 @@
"eth-trezor-keyring>hdkey>secp256k1>bip66": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-trezor-keyring>hdkey>secp256k1>bip66": {
@@ -2728,7 +3009,7 @@
"ethereumjs-util>create-hash": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-abi>ethereumjs-util>ethjs-util": {
@@ -2829,6 +3110,12 @@
"browserify>buffer": true
}
},
+ "ethereumjs-util>ethereum-cryptography>hash.js": {
+ "packages": {
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "pumpify>inherits": true
+ }
+ },
"ethereumjs-util>ethereum-cryptography>keccak": {
"packages": {
"browserify>buffer": true,
@@ -2846,9 +3133,18 @@
"pumpify>inherits": true
}
},
+ "ethereumjs-util>ethereum-cryptography>scrypt-js": {
+ "globals": {
+ "define": true,
+ "setTimeout": true
+ },
+ "packages": {
+ "browserify>timers-browserify": true
+ }
+ },
"ethereumjs-util>ethereum-cryptography>secp256k1": {
"packages": {
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-util>rlp": {
@@ -2909,7 +3205,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>ethereumjs-util>ethjs-util": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-wallet>ethereumjs-util>ethjs-util": {
@@ -2946,330 +3242,9 @@
"msCrypto": true
}
},
- "ethers": {
- "packages": {
- "@ethersproject/bignumber": true,
- "@ethersproject/contracts": true,
- "@ethersproject/providers": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/rlp": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/solidity": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/units": true,
- "ethers>@ethersproject/wallet": true,
- "ethers>@ethersproject/web": true,
- "ethers>@ethersproject/wordlists": true
- }
- },
- "ethers>@ethersproject/abi": {
- "globals": {
- "console.log": true
- },
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/abstract-provider": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/abstract-signer": {
- "packages": {
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/address": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/rlp": true
- }
- },
- "ethers>@ethersproject/base64": {
- "globals": {
- "atob": true,
- "btoa": true
- },
- "packages": {
- "ethers>@ethersproject/bytes": true
- }
- },
- "ethers>@ethersproject/basex": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/bytes": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/constants": {
- "packages": {
- "@ethersproject/bignumber": true
- }
- },
- "ethers>@ethersproject/hash": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/hdnode": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/pbkdf2": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/wordlists": true
- }
- },
- "ethers>@ethersproject/json-wallets": {
- "packages": {
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets>aes-js": true,
- "ethers>@ethersproject/json-wallets>scrypt-js": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/pbkdf2": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true
- }
- },
- "ethers>@ethersproject/json-wallets>aes-js": {
- "globals": {
- "define": true
- }
- },
- "ethers>@ethersproject/json-wallets>scrypt-js": {
- "globals": {
- "define": true,
- "setTimeout": true
- },
- "packages": {
- "browserify>timers-browserify": true
- }
- },
- "ethers>@ethersproject/keccak256": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256>js-sha3": true
- }
- },
- "ethers>@ethersproject/keccak256>js-sha3": {
- "globals": {
- "define": true
- },
- "packages": {
- "browserify>process": true
- }
- },
- "ethers>@ethersproject/logger": {
- "globals": {
- "console": true
- }
- },
- "ethers>@ethersproject/networks": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/pbkdf2": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/sha2": true
- }
- },
- "ethers>@ethersproject/properties": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
"ethers>@ethersproject/random": {
"globals": {
"crypto.getRandomValues": true
- },
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/rlp": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/sha2": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/sha2>hash.js": true
- }
- },
- "ethers>@ethersproject/sha2>hash.js": {
- "packages": {
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "pumpify>inherits": true
- }
- },
- "ethers>@ethersproject/signing-key": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/signing-key>elliptic": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic": {
- "packages": {
- "bn.js": true,
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "ethers>@ethersproject/signing-key>elliptic>brorand": true,
- "ethers>@ethersproject/signing-key>elliptic>hmac-drbg": true,
- "ethers>@ethersproject/signing-key>elliptic>minimalistic-crypto-utils": true,
- "pumpify>inherits": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic>brorand": {
- "globals": {
- "crypto": true,
- "msCrypto": true
- },
- "packages": {
- "browserify>browser-resolve": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic>hmac-drbg": {
- "packages": {
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "ethers>@ethersproject/signing-key>elliptic>minimalistic-crypto-utils": true
- }
- },
- "ethers>@ethersproject/solidity": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/strings": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/transactions": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/rlp": true,
- "ethers>@ethersproject/signing-key": true
- }
- },
- "ethers>@ethersproject/units": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/wallet": {
- "packages": {
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/transactions": true
- }
- },
- "ethers>@ethersproject/web": {
- "globals": {
- "clearTimeout": true,
- "fetch": true,
- "setTimeout": true
- },
- "packages": {
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/wordlists": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
}
},
"ethjs": {
@@ -3422,6 +3397,33 @@
"define": true
}
},
+ "ganache>secp256k1>elliptic": {
+ "packages": {
+ "bn.js": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
+ "ganache>secp256k1>elliptic>brorand": true,
+ "ganache>secp256k1>elliptic>hmac-drbg": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-crypto-utils": true,
+ "pumpify>inherits": true
+ }
+ },
+ "ganache>secp256k1>elliptic>brorand": {
+ "globals": {
+ "crypto": true,
+ "msCrypto": true
+ },
+ "packages": {
+ "browserify>browser-resolve": true
+ }
+ },
+ "ganache>secp256k1>elliptic>hmac-drbg": {
+ "packages": {
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-crypto-utils": true
+ }
+ },
"globalthis>define-properties": {
"packages": {
"globalthis>define-properties>has-property-descriptors": true,
diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json
index 6a0915e9593d..75f907c9ad04 100644
--- a/lavamoat/browserify/flask/policy.json
+++ b/lavamoat/browserify/flask/policy.json
@@ -138,11 +138,89 @@
"ethereumjs-util": true
}
},
+ "@ethersproject/abi": {
+ "globals": {
+ "console.log": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/address": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/providers>@ethersproject/rlp": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/bytes": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/constants": {
+ "packages": {
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/hash": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/providers>@ethersproject/base64": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/keccak256": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256>js-sha3": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/keccak256>js-sha3": {
+ "globals": {
+ "define": true
+ },
+ "packages": {
+ "browserify>process": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/logger": {
+ "globals": {
+ "console": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/properties": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/strings": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
"@ethersproject/bignumber": {
"packages": {
- "@ethersproject/bignumber>bn.js": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber>bn.js": true
}
},
"@ethersproject/bignumber>bn.js": {
@@ -158,15 +236,85 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi": true,
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true
+ }
+ },
+ "@ethersproject/hdnode": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
"@ethersproject/bignumber": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/transactions": true
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/hdnode>@ethersproject/wordlists": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/basex": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/properties": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/sha2": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/signing-key": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "ganache>secp256k1>elliptic": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/transactions": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/providers>@ethersproject/rlp": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/wordlists": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true
}
},
"@ethersproject/providers": {
@@ -180,24 +328,72 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
"@ethersproject/bignumber": true,
- "@ethersproject/providers>bech32": true,
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/networks": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/web": true
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true,
+ "@ethersproject/providers>@ethersproject/base64": true,
+ "@ethersproject/providers>@ethersproject/networks": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@ethersproject/providers>@ethersproject/web": true,
+ "@ethersproject/providers>bech32": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/abstract-provider": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/base64": {
+ "globals": {
+ "atob": true,
+ "btoa": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/networks": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/random": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/rlp": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/web": {
+ "globals": {
+ "clearTimeout": true,
+ "fetch": true,
+ "setTimeout": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/providers>@ethersproject/base64": true
}
},
"@formatjs/intl-relativetimeformat": {
@@ -507,6 +703,7 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>abort-controller": true,
@@ -520,7 +717,6 @@
"eth-query": true,
"eth-rpc-errors": true,
"ethereumjs-util": true,
- "ethers>@ethersproject/abi": true,
"single-call-balance-checker-abi": true,
"uuid": true
}
@@ -643,7 +839,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware>eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -759,7 +955,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-ledger-bridge-keyring>eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -785,7 +981,7 @@
"eth-trezor-keyring>hdkey>secp256k1>bip66": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-token-tracker": {
@@ -1182,13 +1378,13 @@
"setInterval": true
},
"packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
"@ethersproject/bignumber": true,
"@ethersproject/providers": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/smart-transactions-controller>bignumber.js": true,
- "ethers>@ethersproject/bytes": true,
"fast-json-patch": true,
"lodash": true
}
@@ -1942,6 +2138,7 @@
},
"@truffle/decoder>@truffle/encoder": {
"packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
"@ethersproject/bignumber": true,
"@truffle/codec": true,
"@truffle/codec>@truffle/abi-utils": true,
@@ -1950,7 +2147,6 @@
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs": true,
"@truffle/decoder>@truffle/encoder>big.js": true,
"@truffle/decoder>@truffle/encoder>bignumber.js": true,
- "ethers>@ethersproject/address": true,
"lodash": true,
"nock>debug": true
}
@@ -1967,11 +2163,11 @@
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/ens": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/resolver": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>content-hash": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>js-sha3": true,
"browserify>buffer": true,
"eth-ens-namehash": true,
- "ethereumjs-wallet>bs58check>bs58": true,
- "ethers": true
+ "ethereumjs-wallet>bs58check>bs58": true
}
},
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/address-encoder": {
@@ -2033,6 +2229,91 @@
"ethereumjs-wallet>bs58check>bs58>base-x": true
}
},
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers": {
+ "packages": {
+ "@ethersproject/abi": true,
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/contracts": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/hdnode>@ethersproject/wordlists": true,
+ "@ethersproject/providers": true,
+ "@ethersproject/providers>@ethersproject/base64": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@ethersproject/providers>@ethersproject/rlp": true,
+ "@ethersproject/providers>@ethersproject/web": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/solidity": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/units": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/wallet": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets>aes-js": true,
+ "ethereumjs-util>ethereum-cryptography>scrypt-js": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets>aes-js": {
+ "globals": {
+ "define": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/solidity": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/units": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/wallet": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": true
+ }
+ },
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>js-sha3": {
"globals": {
"define": true
@@ -2215,7 +2496,7 @@
},
"browserify>crypto-browserify>browserify-cipher>browserify-des>des.js": {
"packages": {
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
"pumpify>inherits": true
}
},
@@ -2234,7 +2515,7 @@
"browserify>crypto-browserify>public-encrypt>parse-asn1": true,
"browserify>stream-browserify": true,
"ethereumjs-util>create-hash": true,
- "ethers>@ethersproject/signing-key>elliptic": true,
+ "ganache>secp256k1>elliptic": true,
"pumpify>inherits": true
}
},
@@ -2242,7 +2523,7 @@
"packages": {
"bn.js": true,
"browserify>buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"browserify>crypto-browserify>create-hmac": {
@@ -2266,7 +2547,7 @@
"browserify>crypto-browserify>diffie-hellman>miller-rabin": {
"packages": {
"bn.js": true,
- "ethers>@ethersproject/signing-key>elliptic>brorand": true
+ "ganache>secp256k1>elliptic>brorand": true
}
},
"browserify>crypto-browserify>pbkdf2": {
@@ -2316,7 +2597,7 @@
"bn.js": true,
"browserify>buffer": true,
"browserify>vm-browserify": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
"pumpify>inherits": true
}
},
@@ -2752,6 +3033,7 @@
},
"packages": {
"@ethereumjs/common>crc-32": true,
+ "@ethersproject/abi": true,
"bn.js": true,
"browserify>buffer": true,
"browserify>process": true,
@@ -2765,11 +3047,10 @@
"eth-lattice-keyring>gridplus-sdk>js-sha3": true,
"eth-lattice-keyring>gridplus-sdk>rlp": true,
"eth-lattice-keyring>gridplus-sdk>secp256k1": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/signing-key>elliptic": true,
+ "ganache>secp256k1>elliptic": true,
"lodash": true
}
},
@@ -2882,7 +3163,7 @@
},
"eth-lattice-keyring>gridplus-sdk>secp256k1": {
"packages": {
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-lattice-keyring>rlp": {
@@ -2926,7 +3207,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -2991,7 +3272,7 @@
"eth-trezor-keyring>hdkey>secp256k1>bip66": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-trezor-keyring>hdkey>secp256k1>bip66": {
@@ -3052,7 +3333,7 @@
"ethereumjs-util>create-hash": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-abi>ethereumjs-util>ethjs-util": {
@@ -3153,6 +3434,12 @@
"browserify>buffer": true
}
},
+ "ethereumjs-util>ethereum-cryptography>hash.js": {
+ "packages": {
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "pumpify>inherits": true
+ }
+ },
"ethereumjs-util>ethereum-cryptography>keccak": {
"packages": {
"browserify>buffer": true,
@@ -3170,9 +3457,18 @@
"pumpify>inherits": true
}
},
+ "ethereumjs-util>ethereum-cryptography>scrypt-js": {
+ "globals": {
+ "define": true,
+ "setTimeout": true
+ },
+ "packages": {
+ "browserify>timers-browserify": true
+ }
+ },
"ethereumjs-util>ethereum-cryptography>secp256k1": {
"packages": {
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-util>rlp": {
@@ -3233,7 +3529,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>ethereumjs-util>ethjs-util": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-wallet>ethereumjs-util>ethjs-util": {
@@ -3270,330 +3566,9 @@
"msCrypto": true
}
},
- "ethers": {
- "packages": {
- "@ethersproject/bignumber": true,
- "@ethersproject/contracts": true,
- "@ethersproject/providers": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/rlp": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/solidity": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/units": true,
- "ethers>@ethersproject/wallet": true,
- "ethers>@ethersproject/web": true,
- "ethers>@ethersproject/wordlists": true
- }
- },
- "ethers>@ethersproject/abi": {
- "globals": {
- "console.log": true
- },
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/abstract-provider": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/abstract-signer": {
- "packages": {
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/address": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/rlp": true
- }
- },
- "ethers>@ethersproject/base64": {
- "globals": {
- "atob": true,
- "btoa": true
- },
- "packages": {
- "ethers>@ethersproject/bytes": true
- }
- },
- "ethers>@ethersproject/basex": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/bytes": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/constants": {
- "packages": {
- "@ethersproject/bignumber": true
- }
- },
- "ethers>@ethersproject/hash": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/hdnode": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/pbkdf2": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/wordlists": true
- }
- },
- "ethers>@ethersproject/json-wallets": {
- "packages": {
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets>aes-js": true,
- "ethers>@ethersproject/json-wallets>scrypt-js": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/pbkdf2": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true
- }
- },
- "ethers>@ethersproject/json-wallets>aes-js": {
- "globals": {
- "define": true
- }
- },
- "ethers>@ethersproject/json-wallets>scrypt-js": {
- "globals": {
- "define": true,
- "setTimeout": true
- },
- "packages": {
- "browserify>timers-browserify": true
- }
- },
- "ethers>@ethersproject/keccak256": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256>js-sha3": true
- }
- },
- "ethers>@ethersproject/keccak256>js-sha3": {
- "globals": {
- "define": true
- },
- "packages": {
- "browserify>process": true
- }
- },
- "ethers>@ethersproject/logger": {
- "globals": {
- "console": true
- }
- },
- "ethers>@ethersproject/networks": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/pbkdf2": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/sha2": true
- }
- },
- "ethers>@ethersproject/properties": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
"ethers>@ethersproject/random": {
"globals": {
"crypto.getRandomValues": true
- },
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/rlp": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/sha2": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/sha2>hash.js": true
- }
- },
- "ethers>@ethersproject/sha2>hash.js": {
- "packages": {
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "pumpify>inherits": true
- }
- },
- "ethers>@ethersproject/signing-key": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/signing-key>elliptic": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic": {
- "packages": {
- "bn.js": true,
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "ethers>@ethersproject/signing-key>elliptic>brorand": true,
- "ethers>@ethersproject/signing-key>elliptic>hmac-drbg": true,
- "ethers>@ethersproject/signing-key>elliptic>minimalistic-crypto-utils": true,
- "pumpify>inherits": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic>brorand": {
- "globals": {
- "crypto": true,
- "msCrypto": true
- },
- "packages": {
- "browserify>browser-resolve": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic>hmac-drbg": {
- "packages": {
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "ethers>@ethersproject/signing-key>elliptic>minimalistic-crypto-utils": true
- }
- },
- "ethers>@ethersproject/solidity": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/strings": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/transactions": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/rlp": true,
- "ethers>@ethersproject/signing-key": true
- }
- },
- "ethers>@ethersproject/units": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/wallet": {
- "packages": {
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/transactions": true
- }
- },
- "ethers>@ethersproject/web": {
- "globals": {
- "clearTimeout": true,
- "fetch": true,
- "setTimeout": true
- },
- "packages": {
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/wordlists": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
}
},
"ethjs": {
@@ -3746,6 +3721,33 @@
"define": true
}
},
+ "ganache>secp256k1>elliptic": {
+ "packages": {
+ "bn.js": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
+ "ganache>secp256k1>elliptic>brorand": true,
+ "ganache>secp256k1>elliptic>hmac-drbg": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-crypto-utils": true,
+ "pumpify>inherits": true
+ }
+ },
+ "ganache>secp256k1>elliptic>brorand": {
+ "globals": {
+ "crypto": true,
+ "msCrypto": true
+ },
+ "packages": {
+ "browserify>browser-resolve": true
+ }
+ },
+ "ganache>secp256k1>elliptic>hmac-drbg": {
+ "packages": {
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-crypto-utils": true
+ }
+ },
"globalthis>define-properties": {
"packages": {
"globalthis>define-properties>has-property-descriptors": true,
diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json
index 2208d70dfc2a..8d5454123850 100644
--- a/lavamoat/browserify/main/policy.json
+++ b/lavamoat/browserify/main/policy.json
@@ -138,11 +138,89 @@
"ethereumjs-util": true
}
},
+ "@ethersproject/abi": {
+ "globals": {
+ "console.log": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/address": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/providers>@ethersproject/rlp": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/bytes": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/constants": {
+ "packages": {
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/hash": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/providers>@ethersproject/base64": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/keccak256": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256>js-sha3": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/keccak256>js-sha3": {
+ "globals": {
+ "define": true
+ },
+ "packages": {
+ "browserify>process": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/logger": {
+ "globals": {
+ "console": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/properties": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/abi>@ethersproject/strings": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
"@ethersproject/bignumber": {
"packages": {
- "@ethersproject/bignumber>bn.js": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber>bn.js": true
}
},
"@ethersproject/bignumber>bn.js": {
@@ -158,15 +236,85 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi": true,
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true
+ }
+ },
+ "@ethersproject/hdnode": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
"@ethersproject/bignumber": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/transactions": true
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/hdnode>@ethersproject/wordlists": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/basex": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/properties": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/sha2": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/signing-key": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "ganache>secp256k1>elliptic": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/transactions": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/providers>@ethersproject/rlp": true
+ }
+ },
+ "@ethersproject/hdnode>@ethersproject/wordlists": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true
}
},
"@ethersproject/providers": {
@@ -180,24 +328,72 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
"@ethersproject/bignumber": true,
- "@ethersproject/providers>bech32": true,
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/networks": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/web": true
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true,
+ "@ethersproject/providers>@ethersproject/base64": true,
+ "@ethersproject/providers>@ethersproject/networks": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@ethersproject/providers>@ethersproject/web": true,
+ "@ethersproject/providers>bech32": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/abstract-provider": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/base64": {
+ "globals": {
+ "atob": true,
+ "btoa": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/networks": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/random": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/rlp": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true
+ }
+ },
+ "@ethersproject/providers>@ethersproject/web": {
+ "globals": {
+ "clearTimeout": true,
+ "fetch": true,
+ "setTimeout": true
+ },
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/providers>@ethersproject/base64": true
}
},
"@formatjs/intl-relativetimeformat": {
@@ -507,6 +703,7 @@
"setTimeout": true
},
"packages": {
+ "@ethersproject/abi": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>abort-controller": true,
@@ -520,7 +717,6 @@
"eth-query": true,
"eth-rpc-errors": true,
"ethereumjs-util": true,
- "ethers>@ethersproject/abi": true,
"single-call-balance-checker-abi": true,
"uuid": true
}
@@ -643,7 +839,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-json-rpc-infura>eth-json-rpc-middleware>eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -759,7 +955,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-ledger-bridge-keyring>eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -785,7 +981,7 @@
"eth-trezor-keyring>hdkey>secp256k1>bip66": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"@metamask/eth-token-tracker": {
@@ -1090,13 +1286,13 @@
"setInterval": true
},
"packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
"@ethersproject/bignumber": true,
"@ethersproject/providers": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/smart-transactions-controller>bignumber.js": true,
- "ethers>@ethersproject/bytes": true,
"fast-json-patch": true,
"lodash": true
}
@@ -1618,6 +1814,7 @@
},
"@truffle/decoder>@truffle/encoder": {
"packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
"@ethersproject/bignumber": true,
"@truffle/codec": true,
"@truffle/codec>@truffle/abi-utils": true,
@@ -1626,7 +1823,6 @@
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs": true,
"@truffle/decoder>@truffle/encoder>big.js": true,
"@truffle/decoder>@truffle/encoder>bignumber.js": true,
- "ethers>@ethersproject/address": true,
"lodash": true,
"nock>debug": true
}
@@ -1643,11 +1839,11 @@
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/ens": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/resolver": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>content-hash": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers": true,
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>js-sha3": true,
"browserify>buffer": true,
"eth-ens-namehash": true,
- "ethereumjs-wallet>bs58check>bs58": true,
- "ethers": true
+ "ethereumjs-wallet>bs58check>bs58": true
}
},
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>@ensdomains/address-encoder": {
@@ -1709,6 +1905,91 @@
"ethereumjs-wallet>bs58check>bs58>base-x": true
}
},
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers": {
+ "packages": {
+ "@ethersproject/abi": true,
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/constants": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/contracts": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/basex": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/hdnode>@ethersproject/wordlists": true,
+ "@ethersproject/providers": true,
+ "@ethersproject/providers>@ethersproject/base64": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@ethersproject/providers>@ethersproject/rlp": true,
+ "@ethersproject/providers>@ethersproject/web": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/solidity": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/units": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/wallet": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/pbkdf2": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets>aes-js": true,
+ "ethereumjs-util>ethereum-cryptography>scrypt-js": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets>aes-js": {
+ "globals": {
+ "define": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/solidity": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/strings": true,
+ "@ethersproject/bignumber": true,
+ "@ethersproject/hdnode>@ethersproject/sha2": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/units": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/bignumber": true
+ }
+ },
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/wallet": {
+ "packages": {
+ "@ethersproject/abi>@ethersproject/address": true,
+ "@ethersproject/abi>@ethersproject/bytes": true,
+ "@ethersproject/abi>@ethersproject/hash": true,
+ "@ethersproject/abi>@ethersproject/keccak256": true,
+ "@ethersproject/abi>@ethersproject/logger": true,
+ "@ethersproject/abi>@ethersproject/properties": true,
+ "@ethersproject/hdnode": true,
+ "@ethersproject/hdnode>@ethersproject/abstract-signer": true,
+ "@ethersproject/hdnode>@ethersproject/signing-key": true,
+ "@ethersproject/hdnode>@ethersproject/transactions": true,
+ "@ethersproject/providers>@ethersproject/abstract-provider": true,
+ "@ethersproject/providers>@ethersproject/random": true,
+ "@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>ethers>@ethersproject/json-wallets": true
+ }
+ },
"@truffle/decoder>@truffle/encoder>@ensdomains/ensjs>js-sha3": {
"globals": {
"define": true
@@ -1891,7 +2172,7 @@
},
"browserify>crypto-browserify>browserify-cipher>browserify-des>des.js": {
"packages": {
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
"pumpify>inherits": true
}
},
@@ -1910,7 +2191,7 @@
"browserify>crypto-browserify>public-encrypt>parse-asn1": true,
"browserify>stream-browserify": true,
"ethereumjs-util>create-hash": true,
- "ethers>@ethersproject/signing-key>elliptic": true,
+ "ganache>secp256k1>elliptic": true,
"pumpify>inherits": true
}
},
@@ -1918,7 +2199,7 @@
"packages": {
"bn.js": true,
"browserify>buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"browserify>crypto-browserify>create-hmac": {
@@ -1942,7 +2223,7 @@
"browserify>crypto-browserify>diffie-hellman>miller-rabin": {
"packages": {
"bn.js": true,
- "ethers>@ethersproject/signing-key>elliptic>brorand": true
+ "ganache>secp256k1>elliptic>brorand": true
}
},
"browserify>crypto-browserify>pbkdf2": {
@@ -1992,7 +2273,7 @@
"bn.js": true,
"browserify>buffer": true,
"browserify>vm-browserify": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
"pumpify>inherits": true
}
},
@@ -2428,6 +2709,7 @@
},
"packages": {
"@ethereumjs/common>crc-32": true,
+ "@ethersproject/abi": true,
"bn.js": true,
"browserify>buffer": true,
"browserify>process": true,
@@ -2441,11 +2723,10 @@
"eth-lattice-keyring>gridplus-sdk>js-sha3": true,
"eth-lattice-keyring>gridplus-sdk>rlp": true,
"eth-lattice-keyring>gridplus-sdk>secp256k1": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/signing-key>elliptic": true,
+ "ganache>secp256k1>elliptic": true,
"lodash": true
}
},
@@ -2558,7 +2839,7 @@
},
"eth-lattice-keyring>gridplus-sdk>secp256k1": {
"packages": {
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-lattice-keyring>rlp": {
@@ -2602,7 +2883,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-sig-util>ethereumjs-util>ethjs-util": {
@@ -2667,7 +2948,7 @@
"eth-trezor-keyring>hdkey>secp256k1>bip66": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>safe-buffer": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"eth-trezor-keyring>hdkey>secp256k1>bip66": {
@@ -2728,7 +3009,7 @@
"ethereumjs-util>create-hash": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-abi>ethereumjs-util>ethjs-util": {
@@ -2829,6 +3110,12 @@
"browserify>buffer": true
}
},
+ "ethereumjs-util>ethereum-cryptography>hash.js": {
+ "packages": {
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "pumpify>inherits": true
+ }
+ },
"ethereumjs-util>ethereum-cryptography>keccak": {
"packages": {
"browserify>buffer": true,
@@ -2846,9 +3133,18 @@
"pumpify>inherits": true
}
},
+ "ethereumjs-util>ethereum-cryptography>scrypt-js": {
+ "globals": {
+ "define": true,
+ "setTimeout": true
+ },
+ "packages": {
+ "browserify>timers-browserify": true
+ }
+ },
"ethereumjs-util>ethereum-cryptography>secp256k1": {
"packages": {
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-util>rlp": {
@@ -2909,7 +3205,7 @@
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-util>rlp": true,
"ethereumjs-wallet>ethereumjs-util>ethjs-util": true,
- "ethers>@ethersproject/signing-key>elliptic": true
+ "ganache>secp256k1>elliptic": true
}
},
"ethereumjs-wallet>ethereumjs-util>ethjs-util": {
@@ -2946,330 +3242,9 @@
"msCrypto": true
}
},
- "ethers": {
- "packages": {
- "@ethersproject/bignumber": true,
- "@ethersproject/contracts": true,
- "@ethersproject/providers": true,
- "ethers>@ethersproject/abi": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/rlp": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/solidity": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/units": true,
- "ethers>@ethersproject/wallet": true,
- "ethers>@ethersproject/web": true,
- "ethers>@ethersproject/wordlists": true
- }
- },
- "ethers>@ethersproject/abi": {
- "globals": {
- "console.log": true
- },
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/abstract-provider": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/abstract-signer": {
- "packages": {
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/address": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/rlp": true
- }
- },
- "ethers>@ethersproject/base64": {
- "globals": {
- "atob": true,
- "btoa": true
- },
- "packages": {
- "ethers>@ethersproject/bytes": true
- }
- },
- "ethers>@ethersproject/basex": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/properties": true
- }
- },
- "ethers>@ethersproject/bytes": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/constants": {
- "packages": {
- "@ethersproject/bignumber": true
- }
- },
- "ethers>@ethersproject/hash": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/hdnode": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/basex": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/pbkdf2": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true,
- "ethers>@ethersproject/wordlists": true
- }
- },
- "ethers>@ethersproject/json-wallets": {
- "packages": {
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets>aes-js": true,
- "ethers>@ethersproject/json-wallets>scrypt-js": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/pbkdf2": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/strings": true,
- "ethers>@ethersproject/transactions": true
- }
- },
- "ethers>@ethersproject/json-wallets>aes-js": {
- "globals": {
- "define": true
- }
- },
- "ethers>@ethersproject/json-wallets>scrypt-js": {
- "globals": {
- "define": true,
- "setTimeout": true
- },
- "packages": {
- "browserify>timers-browserify": true
- }
- },
- "ethers>@ethersproject/keccak256": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256>js-sha3": true
- }
- },
- "ethers>@ethersproject/keccak256>js-sha3": {
- "globals": {
- "define": true
- },
- "packages": {
- "browserify>process": true
- }
- },
- "ethers>@ethersproject/logger": {
- "globals": {
- "console": true
- }
- },
- "ethers>@ethersproject/networks": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/pbkdf2": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/sha2": true
- }
- },
- "ethers>@ethersproject/properties": {
- "packages": {
- "ethers>@ethersproject/logger": true
- }
- },
"ethers>@ethersproject/random": {
"globals": {
"crypto.getRandomValues": true
- },
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/rlp": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/sha2": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/sha2>hash.js": true
- }
- },
- "ethers>@ethersproject/sha2>hash.js": {
- "packages": {
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "pumpify>inherits": true
- }
- },
- "ethers>@ethersproject/signing-key": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/signing-key>elliptic": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic": {
- "packages": {
- "bn.js": true,
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "ethers>@ethersproject/signing-key>elliptic>brorand": true,
- "ethers>@ethersproject/signing-key>elliptic>hmac-drbg": true,
- "ethers>@ethersproject/signing-key>elliptic>minimalistic-crypto-utils": true,
- "pumpify>inherits": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic>brorand": {
- "globals": {
- "crypto": true,
- "msCrypto": true
- },
- "packages": {
- "browserify>browser-resolve": true
- }
- },
- "ethers>@ethersproject/signing-key>elliptic>hmac-drbg": {
- "packages": {
- "ethers>@ethersproject/sha2>hash.js": true,
- "ethers>@ethersproject/sha2>hash.js>minimalistic-assert": true,
- "ethers>@ethersproject/signing-key>elliptic>minimalistic-crypto-utils": true
- }
- },
- "ethers>@ethersproject/solidity": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/sha2": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/strings": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/transactions": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/constants": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/rlp": true,
- "ethers>@ethersproject/signing-key": true
- }
- },
- "ethers>@ethersproject/units": {
- "packages": {
- "@ethersproject/bignumber": true,
- "ethers>@ethersproject/logger": true
- }
- },
- "ethers>@ethersproject/wallet": {
- "packages": {
- "ethers>@ethersproject/abstract-provider": true,
- "ethers>@ethersproject/abstract-signer": true,
- "ethers>@ethersproject/address": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/hdnode": true,
- "ethers>@ethersproject/json-wallets": true,
- "ethers>@ethersproject/keccak256": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/random": true,
- "ethers>@ethersproject/signing-key": true,
- "ethers>@ethersproject/transactions": true
- }
- },
- "ethers>@ethersproject/web": {
- "globals": {
- "clearTimeout": true,
- "fetch": true,
- "setTimeout": true
- },
- "packages": {
- "ethers>@ethersproject/base64": true,
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
- }
- },
- "ethers>@ethersproject/wordlists": {
- "packages": {
- "ethers>@ethersproject/bytes": true,
- "ethers>@ethersproject/hash": true,
- "ethers>@ethersproject/logger": true,
- "ethers>@ethersproject/properties": true,
- "ethers>@ethersproject/strings": true
}
},
"ethjs": {
@@ -3422,6 +3397,33 @@
"define": true
}
},
+ "ganache>secp256k1>elliptic": {
+ "packages": {
+ "bn.js": true,
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
+ "ganache>secp256k1>elliptic>brorand": true,
+ "ganache>secp256k1>elliptic>hmac-drbg": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-crypto-utils": true,
+ "pumpify>inherits": true
+ }
+ },
+ "ganache>secp256k1>elliptic>brorand": {
+ "globals": {
+ "crypto": true,
+ "msCrypto": true
+ },
+ "packages": {
+ "browserify>browser-resolve": true
+ }
+ },
+ "ganache>secp256k1>elliptic>hmac-drbg": {
+ "packages": {
+ "ethereumjs-util>ethereum-cryptography>hash.js": true,
+ "ganache>secp256k1>elliptic>minimalistic-assert": true,
+ "ganache>secp256k1>elliptic>minimalistic-crypto-utils": true
+ }
+ },
"globalthis>define-properties": {
"packages": {
"globalthis>define-properties>has-property-descriptors": true,
diff --git a/lavamoat/build-system/policy.json b/lavamoat/build-system/policy.json
index dc50f82f732f..888c48556dab 100644
--- a/lavamoat/build-system/policy.json
+++ b/lavamoat/build-system/policy.json
@@ -1910,6 +1910,7 @@
},
"packages": {
"chokidar>braces": true,
+ "chokidar>fsevents": true,
"chokidar>glob-parent": true,
"chokidar>is-binary-path": true,
"chokidar>normalize-path": true,
@@ -5219,6 +5220,7 @@
"gulp-watch>path-is-absolute": true,
"gulp>glob-watcher>anymatch": true,
"gulp>glob-watcher>chokidar>braces": true,
+ "gulp>glob-watcher>chokidar>fsevents": true,
"gulp>glob-watcher>chokidar>glob-parent": true,
"gulp>glob-watcher>chokidar>is-binary-path": true,
"gulp>glob-watcher>chokidar>readdirp": true,
diff --git a/package.json b/package.json
index 4daa48764528..77eecfe7da42 100644
--- a/package.json
+++ b/package.json
@@ -204,7 +204,10 @@
"@ensdomains/content-hash": "^2.5.6",
"@ethereumjs/common": "^2.3.1",
"@ethereumjs/tx": "^3.2.1",
+ "@ethersproject/abi": "^5.6.4",
+ "@ethersproject/bignumber": "^5.6.2",
"@ethersproject/contracts": "^5.7.0",
+ "@ethersproject/hdnode": "^5.6.2",
"@ethersproject/providers": "^5.7.2",
"@formatjs/intl-relativetimeformat": "^5.2.6",
"@fortawesome/fontawesome-free": "^5.13.0",
@@ -283,7 +286,6 @@
"ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^7.0.10",
"ethereumjs-wallet": "^0.6.4",
- "ethers": "^5.6.4",
"ethjs": "^0.4.0",
"ethjs-contract": "^0.2.3",
"ethjs-query": "^0.3.4",
diff --git a/shared/modules/transaction.utils.js b/shared/modules/transaction.utils.js
index 9e95fb9a0011..44337a6d8a9a 100644
--- a/shared/modules/transaction.utils.js
+++ b/shared/modules/transaction.utils.js
@@ -1,5 +1,5 @@
import { isHexString } from 'ethereumjs-util';
-import { ethers } from 'ethers';
+import { Interface } from '@ethersproject/abi';
import { abiERC721, abiERC20, abiERC1155 } from '@metamask/metamask-eth-abis';
import log from 'loglevel';
import {
@@ -35,9 +35,9 @@ import { isEqualCaseInsensitive } from './string-utils';
* representation of the function.
*/
-const erc20Interface = new ethers.utils.Interface(abiERC20);
-const erc721Interface = new ethers.utils.Interface(abiERC721);
-const erc1155Interface = new ethers.utils.Interface(abiERC1155);
+const erc20Interface = new Interface(abiERC20);
+const erc721Interface = new Interface(abiERC721);
+const erc1155Interface = new Interface(abiERC1155);
export function transactionMatchesNetwork(transaction, chainId, networkId) {
if (typeof transaction.chainId !== 'undefined') {
diff --git a/test/e2e/seeder/ganache-seeder.js b/test/e2e/seeder/ganache-seeder.js
index 0eaa7ae32ed2..8f963640fb95 100644
--- a/test/e2e/seeder/ganache-seeder.js
+++ b/test/e2e/seeder/ganache-seeder.js
@@ -1,4 +1,6 @@
-const { ethers } = require('ethers');
+const { Web3Provider } = require('@ethersproject/providers');
+const { ContractFactory } = require('@ethersproject/contracts');
+
const { SMART_CONTRACTS, contractConfiguration } = require('./smart-contracts');
const GanacheContractAddressRegistry = require('./ganache-contract-address-registry');
@@ -18,13 +20,10 @@ class GanacheSeeder {
*/
async deploySmartContract(contractName) {
- const ethersProvider = new ethers.providers.Web3Provider(
- this.ganacheProvider,
- 'any',
- );
+ const ethersProvider = new Web3Provider(this.ganacheProvider, 'any');
const signer = ethersProvider.getSigner();
const fromAddress = await signer.getAddress();
- const contractFactory = new ethers.ContractFactory(
+ const contractFactory = new ContractFactory(
contractConfiguration[contractName].abi,
contractConfiguration[contractName].bytecode,
signer,
diff --git a/ui/components/app/srp-input/srp-input.js b/ui/components/app/srp-input/srp-input.js
index 7cde8bb454a1..5468dbf791ed 100644
--- a/ui/components/app/srp-input/srp-input.js
+++ b/ui/components/app/srp-input/srp-input.js
@@ -1,4 +1,4 @@
-import { ethers } from 'ethers';
+import { isValidMnemonic } from '@ethersproject/hdnode';
import React, { useCallback, useState } from 'react';
import PropTypes from 'prop-types';
import { useI18nContext } from '../../../hooks/useI18nContext';
@@ -15,8 +15,6 @@ import {
} from '../../../helpers/constants/design-system';
import { parseSecretRecoveryPhrase } from './parse-secret-recovery-phrase';
-const { isValidMnemonic } = ethers.utils;
-
const defaultNumberOfWords = 12;
const hasUpperCase = (draftSrp) => {
diff --git a/ui/ducks/domains.js b/ui/ducks/domains.js
index c04988ebddee..b17ff2a914a8 100644
--- a/ui/ducks/domains.js
+++ b/ui/ducks/domains.js
@@ -3,7 +3,7 @@ import log from 'loglevel';
import networkMap from 'ethereum-ens-network-map';
import { isConfusing } from 'unicode-confusables';
import { isHexString } from 'ethereumjs-util';
-import { ethers } from 'ethers';
+import { Web3Provider } from '@ethersproject/providers';
import { getCurrentChainId } from '../selectors';
import {
@@ -148,14 +148,11 @@ export function initializeDomainSlice() {
const ensAddress = networkMap[network];
const networkIsSupported = Boolean(ensAddress);
if (networkIsSupported) {
- web3Provider = new ethers.providers.Web3Provider(
- global.ethereumProvider,
- {
- chainId: parseInt(network, 10),
- name: networkName,
- ensAddress,
- },
- );
+ web3Provider = new Web3Provider(global.ethereumProvider, {
+ chainId: parseInt(network, 10),
+ name: networkName,
+ ensAddress,
+ });
dispatch(enableDomainLookup(network));
} else {
web3Provider = null;
diff --git a/ui/ducks/send/helpers.test.js b/ui/ducks/send/helpers.test.js
index 69de6bed9213..d74f3def2504 100644
--- a/ui/ducks/send/helpers.test.js
+++ b/ui/ducks/send/helpers.test.js
@@ -1,4 +1,4 @@
-import { ethers } from 'ethers';
+import { BigNumber } from '@ethersproject/bignumber';
import { GAS_LIMITS } from '../../../shared/constants/gas';
import {
AssetType,
@@ -69,7 +69,7 @@ describe('Send Slice Helpers', () => {
details: {
address: '0xToken',
standard: TokenStandard.ERC721,
- tokenId: ethers.BigNumber.from(15000).toString(),
+ tokenId: BigNumber.from(15000).toString(),
},
},
recipient: {
@@ -82,7 +82,7 @@ describe('Send Slice Helpers', () => {
data: generateERC721TransferData({
toAddress: BURN_ADDRESS,
fromAddress: '0x00',
- tokenId: ethers.BigNumber.from(15000).toString(),
+ tokenId: BigNumber.from(15000).toString(),
}),
to: '0xToken',
type: '0x0',
diff --git a/ui/ducks/send/send.test.js b/ui/ducks/send/send.test.js
index 9877d3218f65..17fc0ac47ec4 100644
--- a/ui/ducks/send/send.test.js
+++ b/ui/ducks/send/send.test.js
@@ -1,7 +1,7 @@
import sinon from 'sinon';
import createMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
-import { ethers } from 'ethers';
+import { BigNumber } from '@ethersproject/bignumber';
import {
CONTRACT_ADDRESS_ERROR,
INSUFFICIENT_FUNDS_ERROR,
@@ -2536,7 +2536,7 @@ describe('Send Slice', () => {
data: generateERC721TransferData({
toAddress: BURN_ADDRESS,
fromAddress: '0xAddress',
- tokenId: ethers.BigNumber.from(15000).toString(),
+ tokenId: BigNumber.from(15000).toString(),
}),
from: '0xAddress',
to: '0xCollectibleAddress',
diff --git a/ui/pages/send/send.test.js b/ui/pages/send/send.test.js
index ddd2596d893b..017dc786b109 100644
--- a/ui/pages/send/send.test.js
+++ b/ui/pages/send/send.test.js
@@ -47,18 +47,13 @@ setBackgroundConnection({
promisifiedBackground: jest.fn(),
});
-jest.mock('ethers', () => {
- const originalModule = jest.requireActual('ethers');
+jest.mock('@ethersproject/providers', () => {
+ const originalModule = jest.requireActual('@ethersproject/providers');
return {
...originalModule,
- ethers: {
- ...originalModule.ethers,
- providers: {
- Web3Provider: jest.fn().mockImplementation(() => {
- return {};
- }),
- },
- },
+ Web3Provider: jest.fn().mockImplementation(() => {
+ return {};
+ }),
};
});
const baseStore = {
diff --git a/yarn.lock b/yarn.lock
index 037d6cc359d0..e893ddad7b67 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2038,7 +2038,7 @@ __metadata:
languageName: node
linkType: hard
-"@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.7.0":
+"@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.6.4, @ethersproject/abi@npm:^5.7.0":
version: 5.7.0
resolution: "@ethersproject/abi@npm:5.7.0"
dependencies:
@@ -2179,7 +2179,7 @@ __metadata:
languageName: node
linkType: hard
-"@ethersproject/hdnode@npm:5.7.0, @ethersproject/hdnode@npm:^5.7.0":
+"@ethersproject/hdnode@npm:5.7.0, @ethersproject/hdnode@npm:^5.6.2, @ethersproject/hdnode@npm:^5.7.0":
version: 5.7.0
resolution: "@ethersproject/hdnode@npm:5.7.0"
dependencies:
@@ -15873,7 +15873,7 @@ __metadata:
languageName: node
linkType: hard
-"ethers@npm:^5.0.13, ethers@npm:^5.6.4":
+"ethers@npm:^5.0.13":
version: 5.7.2
resolution: "ethers@npm:5.7.2"
dependencies:
@@ -24085,8 +24085,10 @@ __metadata:
"@ensdomains/content-hash": ^2.5.6
"@ethereumjs/common": ^2.3.1
"@ethereumjs/tx": ^3.2.1
+ "@ethersproject/abi": ^5.6.4
"@ethersproject/bignumber": ^5.7.0
"@ethersproject/contracts": ^5.7.0
+ "@ethersproject/hdnode": ^5.6.2
"@ethersproject/providers": ^5.7.2
"@formatjs/intl-relativetimeformat": ^5.2.6
"@fortawesome/fontawesome-free": ^5.13.0
@@ -24250,7 +24252,6 @@ __metadata:
ethereumjs-abi: ^0.6.4
ethereumjs-util: ^7.0.10
ethereumjs-wallet: ^0.6.4
- ethers: ^5.6.4
ethjs: ^0.4.0
ethjs-contract: ^0.2.3
ethjs-query: ^0.3.4
From 3ff12d70e9a07d2efb35afde6577d95a8f77a0f5 Mon Sep 17 00:00:00 2001
From: Brad Decker
Date: Tue, 24 Jan 2023 08:44:49 -0600
Subject: [PATCH 07/21] Replace usages of conversion util in rest of UI folder
in favor of Numeric (#17334)
---
shared/modules/Numeric.ts | 3 +-
.../confirm-transaction.duck.js | 7 +-
ui/ducks/send/helpers.js | 31 ++---
ui/ducks/send/send.js | 123 +++++++++++-------
ui/ducks/swaps/swaps.js | 19 ++-
ui/helpers/utils/confirm-tx.util.js | 100 +++++---------
ui/helpers/utils/confirm-tx.util.test.js | 30 -----
ui/helpers/utils/gas.js | 36 ++---
ui/helpers/utils/gas.test.js | 12 --
ui/helpers/utils/token-util.js | 33 ++---
ui/helpers/utils/util.js | 9 +-
ui/hooks/gasFeeInput/test-utils.js | 29 +----
ui/hooks/gasFeeInput/useGasFeeErrors.js | 22 +---
.../gasFeeInput/useTransactionFunctions.js | 8 +-
ui/hooks/useCurrencyDisplay.js | 19 ++-
ui/hooks/useIncrementedGasFees.js | 4 +-
.../confirm-decrypt-message.component.js | 18 +--
...confirm-encryption-public-key.component.js | 18 +--
.../confirm-transaction-base.component.js | 2 +-
ui/pages/send/send.constants.js | 34 ++---
ui/pages/send/send.utils.js | 96 ++++----------
ui/pages/send/send.utils.test.js | 81 ++----------
ui/selectors/custom-gas.js | 91 +++++--------
23 files changed, 288 insertions(+), 537 deletions(-)
diff --git a/shared/modules/Numeric.ts b/shared/modules/Numeric.ts
index b8149f6015e0..6525ab325563 100644
--- a/shared/modules/Numeric.ts
+++ b/shared/modules/Numeric.ts
@@ -278,7 +278,8 @@ export class Numeric {
this.value = bnToBigNumber(value);
} else if (
isNullOrUndefined(value) ||
- (typeof value === 'number' && isNaN(value))
+ (typeof value === 'number' && isNaN(value)) ||
+ (typeof value === 'string' && value === '')
) {
// There are parts of the codebase that call this method without a value,
// or with a 'NaN' (which is probably a bug somewhere in our tests?).
diff --git a/ui/ducks/confirm-transaction/confirm-transaction.duck.js b/ui/ducks/confirm-transaction/confirm-transaction.duck.js
index bb846a204762..a8a9ba00734b 100644
--- a/ui/ducks/confirm-transaction/confirm-transaction.duck.js
+++ b/ui/ducks/confirm-transaction/confirm-transaction.duck.js
@@ -13,8 +13,8 @@ import {
} from '../../helpers/utils/confirm-tx.util';
import {
- conversionUtil,
getValueFromWeiHex,
+ hexToDecimal,
sumHexes,
} from '../../../shared/modules/conversion.utils';
import { getAveragePriceEstimateInHexWEI } from '../../selectors/custom-gas';
@@ -293,10 +293,7 @@ export function setTransactionToConfirm(transactionId) {
}
if (txParams.nonce) {
- const nonce = conversionUtil(txParams.nonce, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- });
+ const nonce = hexToDecimal(txParams.nonce);
dispatch(updateNonce(nonce));
}
diff --git a/ui/ducks/send/helpers.js b/ui/ducks/send/helpers.js
index d0497c892974..a414a7f2b7c5 100644
--- a/ui/ducks/send/helpers.js
+++ b/ui/ducks/send/helpers.js
@@ -1,5 +1,6 @@
import { addHexPrefix } from 'ethereumjs-util';
import abi from 'human-standard-token-abi';
+import BigNumber from 'bignumber.js';
import { GAS_LIMITS, MIN_GAS_LIMIT_HEX } from '../../../shared/constants/gas';
import { calcTokenAmount } from '../../../shared/lib/transactions-controller-utils';
import { CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP } from '../../../shared/constants/network';
@@ -8,11 +9,6 @@ import {
TransactionEnvelopeType,
} from '../../../shared/constants/transaction';
import { readAddressAsContract } from '../../../shared/modules/contract-utils';
-import {
- conversionUtil,
- multiplyCurrencies,
-} from '../../../shared/modules/conversion.utils';
-import { ETH, GWEI } from '../../helpers/constants/common';
import {
addGasBuffer,
generateERC20TransferData,
@@ -21,6 +17,7 @@ import {
} from '../../pages/send/send.utils';
import { getGasPriceInHexWei } from '../../selectors';
import { estimateGas } from '../../store/actions';
+import { Numeric } from '../../../shared/modules/Numeric';
export async function estimateGasLimitForSend({
selectedAddress,
@@ -109,15 +106,10 @@ export async function estimateGasLimitForSend({
if (!isSimpleSendOnNonStandardNetwork) {
// If we do not yet have a gasLimit, we must call into our background
// process to get an estimate for gasLimit based on known parameters.
-
- paramsForGasEstimate.gas = addHexPrefix(
- multiplyCurrencies(blockGasLimit, 0.95, {
- multiplicandBase: 16,
- multiplierBase: 10,
- roundDown: '0',
- toNumericBase: 'hex',
- }),
- );
+ paramsForGasEstimate.gas = new Numeric(blockGasLimit, 16)
+ .times(new Numeric(0.95, 10))
+ .round(0, BigNumber.ROUND_DOWN)
+ .toPrefixedHexString();
}
// The buffer multipler reduces transaction failures by ensuring that the
@@ -268,14 +260,9 @@ export function generateTransactionParams(sendState) {
* @returns {string}
*/
export function getRoundedGasPrice(gasPriceEstimate) {
- const gasPriceInDecGwei = conversionUtil(gasPriceEstimate, {
- numberOfDecimals: 9,
- toDenomination: GWEI,
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- fromCurrency: ETH,
- fromDenomination: GWEI,
- });
+ const gasPriceInDecGwei = new Numeric(gasPriceEstimate, 10)
+ .round(9)
+ .toString();
const gasPriceAsNumber = Number(gasPriceInDecGwei);
return getGasPriceInHexWei(gasPriceAsNumber);
}
diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js
index d17cbc61e9d4..491e6e42a09a 100644
--- a/ui/ducks/send/send.js
+++ b/ui/ducks/send/send.js
@@ -4,12 +4,8 @@ import { addHexPrefix } from 'ethereumjs-util';
import { debounce } from 'lodash';
import { v4 as uuidv4 } from 'uuid';
import {
- conversionGreaterThan,
- conversionUtil,
+ decimalToHex,
getValueFromWeiHex,
- multiplyCurrencies,
- subtractCurrencies,
- sumHexes,
} from '../../../shared/modules/conversion.utils';
import { GAS_ESTIMATE_TYPES, GAS_LIMITS } from '../../../shared/constants/gas';
import {
@@ -109,6 +105,7 @@ import {
calcGasTotal,
calcTokenAmount,
} from '../../../shared/lib/transactions-controller-utils';
+import { Numeric } from '../../../shared/modules/Numeric';
import {
estimateGasLimitForSend,
generateTransactionParams,
@@ -902,31 +899,21 @@ const slice = createSlice({
let amount = '0x0';
if (draftTransaction.asset.type === AssetType.token) {
const decimals = draftTransaction.asset.details?.decimals ?? 0;
+
const multiplier = Math.pow(10, Number(decimals));
- amount = multiplyCurrencies(
- draftTransaction.asset.balance,
- multiplier,
- {
- toNumericBase: 'hex',
- multiplicandBase: 16,
- multiplierBase: 10,
- },
- );
+ amount = new Numeric(draftTransaction.asset.balance, 16)
+ .times(multiplier, 10)
+ .toString();
} else {
- const _gasTotal = sumHexes(
+ const _gasTotal = new Numeric(
draftTransaction.gas.gasTotal || '0x0',
- state.gasTotalForLayer1 || '0x0',
- );
- amount = subtractCurrencies(
- addHexPrefix(draftTransaction.asset.balance),
- addHexPrefix(_gasTotal),
- {
- toNumericBase: 'hex',
- aBase: 16,
- bBase: 16,
- },
- );
+ 16,
+ ).add(new Numeric(state.gasTotalForLayer1 || '0x0', 16));
+
+ amount = new Numeric(draftTransaction.asset.balance, 16)
+ .minus(_gasTotal)
+ .toString();
}
slice.caseReducers.updateSendAmount(state, {
payload: amount,
@@ -1266,6 +1253,9 @@ const slice = createSlice({
validateAmountField: (state) => {
const draftTransaction =
state.draftTransactions[state.currentTransactionUUID];
+
+ const amountValue = new Numeric(draftTransaction.amount.value, 16);
+
switch (true) {
// set error to INSUFFICIENT_FUNDS_FOR_GAS_ERROR if the account balance is lower
// than the total price of the transaction inclusive of gas fees.
@@ -1289,10 +1279,7 @@ const slice = createSlice({
break;
// if the amount is negative, set error to NEGATIVE_ETH_ERROR
// TODO: change this to NEGATIVE_ERROR and remove the currency bias.
- case conversionGreaterThan(
- { value: 0, fromNumericBase: 'dec' },
- { value: draftTransaction.amount.value, fromNumericBase: 'hex' },
- ):
+ case amountValue.isNegative():
draftTransaction.amount.error = NEGATIVE_ETH_ERROR;
break;
// If none of the above are true, set error to null
@@ -1407,28 +1394,81 @@ const slice = createSlice({
validateSendState: (state) => {
const draftTransaction =
state.draftTransactions[state.currentTransactionUUID];
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: 'Begin validating send state',
+ });
if (draftTransaction) {
switch (true) {
case Boolean(draftTransaction.amount.error):
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Amount is in error ${draftTransaction.amount.error}`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case Boolean(draftTransaction.gas.error):
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Gas is in error ${draftTransaction.gas.error}`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case Boolean(draftTransaction.asset.error):
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Asset is in error ${draftTransaction.asset.error}`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case draftTransaction.asset.type === AssetType.token &&
draftTransaction.asset.details === null:
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Asset is TOKEN and token details is null`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case state.stage === SEND_STAGES.ADD_RECIPIENT:
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Form is invalid because stage is ADD_RECIPIENT`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case state.stage === SEND_STAGES.INACTIVE:
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Form is invalid because stage is INACTIVE`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case state.gasEstimateIsLoading:
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Form is invalid because gasEstimateIsLoading`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case new BigNumber(draftTransaction.gas.gasLimit, 16).lessThan(
new BigNumber(state.gasLimitMinimum),
):
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Form is invalid because ${draftTransaction.gas.gasLimit} is lessThan ${state.gasLimitMinimum}`,
+ });
+
draftTransaction.status = SEND_STATUSES.INVALID;
break;
case draftTransaction.recipient.warning === 'loading':
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Form is invalid because recipient warning is loading`,
+ });
+ draftTransaction.status = SEND_STATUSES.INVALID;
+ break;
case draftTransaction.recipient.warning ===
KNOWN_RECIPIENT_ADDRESS_WARNING &&
draftTransaction.recipient.recipientWarningAcknowledged === false:
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Form is invalid because recipient warning not acknolwedged`,
+ });
draftTransaction.status = SEND_STATUSES.INVALID;
break;
default:
+ slice.caseReducers.addHistoryEntry(state, {
+ payload: `Form is valid`,
+ });
draftTransaction.status = SEND_STATUSES.VALID;
}
}
@@ -1730,13 +1770,7 @@ export function editExistingTransaction(assetType, transactionId) {
const address = getTokenAddressParam(tokenData);
const nickname = getAddressBookEntryOrAccountName(state, address) ?? '';
- const tokenAmountInHex = addHexPrefix(
- conversionUtil(tokenAmountInDec, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- }),
- );
-
+ const tokenAmountInHex = addHexPrefix(decimalToHex(tokenAmountInDec));
await dispatch(
actions.addNewDraft({
...draftTransactionInitialState,
@@ -1936,14 +1970,13 @@ export function updateSendAmount(amount) {
10,
Number(draftTransaction.asset.details?.decimals || 0),
);
- const decimalValueString = conversionUtil(addHexPrefix(amount), {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- toCurrency: draftTransaction.asset.details?.symbol,
- conversionRate: multiplier,
- invertConversionRate: true,
- });
-
+ const decimalValueString = new Numeric(addHexPrefix(amount), 16)
+ .toBase(10)
+ .applyConversionRate(
+ draftTransaction.asset.details?.symbol ? multiplier : 1,
+ true,
+ )
+ .toString();
logAmount = `${Number(decimalValueString) ? decimalValueString : ''} ${
draftTransaction.asset.details?.symbol
}`;
diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js
index 1e9fb41bcca8..3f469e01a1d4 100644
--- a/ui/ducks/swaps/swaps.js
+++ b/ui/ducks/swaps/swaps.js
@@ -53,7 +53,6 @@ import {
} from '../../pages/swaps/swaps.util';
import {
addHexes,
- conversionLessThan,
decGWEIToHexWEI,
decimalToHex,
getValueFromWeiHex,
@@ -91,6 +90,8 @@ import {
calcGasTotal,
calcTokenAmount,
} from '../../../shared/lib/transactions-controller-utils';
+import { EtherDenomination } from '../../../shared/constants/common';
+import { Numeric } from '../../../shared/modules/Numeric';
export const GAS_PRICES_LOADING_STATES = {
INITIAL: 'INITIAL',
@@ -289,15 +290,13 @@ export function shouldShowCustomPriceTooLowWarning(state) {
return false;
}
- const customPriceRisksSwapFailure = conversionLessThan(
- {
- value: customGasPrice,
- fromNumericBase: 'hex',
- fromDenomination: 'WEI',
- toDenomination: 'GWEI',
- },
- { value: average, fromNumericBase: 'dec' },
- );
+ const customPriceRisksSwapFailure = new Numeric(
+ customGasPrice,
+ 16,
+ EtherDenomination.WEI,
+ )
+ .toDenomination(EtherDenomination.GWEI)
+ .greaterThan(average, 10);
return customPriceRisksSwapFailure;
}
diff --git a/ui/helpers/utils/confirm-tx.util.js b/ui/helpers/utils/confirm-tx.util.js
index 315cbcc551ef..fd2c706492c1 100644
--- a/ui/helpers/utils/confirm-tx.util.js
+++ b/ui/helpers/utils/confirm-tx.util.js
@@ -1,63 +1,31 @@
import currencyFormatter from 'currency-formatter';
import currencies from 'currency-formatter/currencies';
import BigNumber from 'bignumber.js';
-import { addHexPrefix } from '../../../app/scripts/lib/util';
import { unconfirmedTransactionsCountSelector } from '../../selectors';
-import {
- conversionUtil,
- addCurrencies,
- multiplyCurrencies,
- conversionGreaterThan,
-} from '../../../shared/modules/conversion.utils';
-
-export function increaseLastGasPrice(lastGasPrice) {
- return addHexPrefix(
- multiplyCurrencies(lastGasPrice || '0x0', 1.1, {
- multiplicandBase: 16,
- multiplierBase: 10,
- toNumericBase: 'hex',
- }),
- );
-}
-
-export function hexGreaterThan(a, b) {
- return conversionGreaterThan(
- { value: a, fromNumericBase: 'hex' },
- { value: b, fromNumericBase: 'hex' },
- );
-}
+import { Numeric } from '../../../shared/modules/Numeric';
+import { EtherDenomination } from '../../../shared/constants/common';
-export function getHexGasTotal({ gasLimit, gasPrice }) {
- return addHexPrefix(
- multiplyCurrencies(gasLimit || '0x0', gasPrice || '0x0', {
- toNumericBase: 'hex',
- multiplicandBase: 16,
- multiplierBase: 16,
- }),
- );
+export function getHexGasTotal({ gasLimit = '0x0', gasPrice = '0x0' }) {
+ return new Numeric(gasLimit, 16)
+ .times(new Numeric(gasPrice, 16))
+ .toPrefixedHexString();
}
-export function addEth(...args) {
- return args.reduce((acc, ethAmount) => {
- return addCurrencies(acc, ethAmount, {
- toNumericBase: 'dec',
- numberOfDecimals: 6,
- aBase: 10,
- bBase: 10,
- });
- });
+export function addEth(firstValue, ...otherValues) {
+ return otherValues
+ .reduce((numericAcc, ethAmount) => {
+ return numericAcc.add(new Numeric(ethAmount, 10)).round(6);
+ }, new Numeric(firstValue, 10))
+ .toString();
}
-export function addFiat(...args) {
- return args.reduce((acc, fiatAmount) => {
- return addCurrencies(acc, fiatAmount, {
- toNumericBase: 'dec',
- numberOfDecimals: 2,
- aBase: 10,
- bBase: 10,
- });
- });
+export function addFiat(firstValue, ...otherValues) {
+ return otherValues
+ .reduce((numericAcc, fiatAmount) => {
+ return numericAcc.add(new Numeric(fiatAmount, 10)).round(2);
+ }, new Numeric(firstValue, 10))
+ .toString();
}
export function getTransactionFee({
@@ -67,15 +35,14 @@ export function getTransactionFee({
conversionRate,
numberOfDecimals,
}) {
- return conversionUtil(value, {
- fromNumericBase: 'BN',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- fromCurrency,
- toCurrency,
- numberOfDecimals,
- conversionRate,
- });
+ let fee = new Numeric(value, 16, EtherDenomination.WEI)
+ .toDenomination(EtherDenomination.ETH)
+ .toBase(10);
+
+ if (fromCurrency !== toCurrency && conversionRate) {
+ fee = fee.applyConversionRate(conversionRate);
+ }
+ return fee.round(numberOfDecimals).toString();
}
export function formatCurrency(value, currencyCode) {
@@ -98,14 +65,13 @@ export function convertTokenToFiat({
}) {
const totalExchangeRate = conversionRate * contractExchangeRate;
- return conversionUtil(value, {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- fromCurrency,
- toCurrency,
- numberOfDecimals: 2,
- conversionRate: totalExchangeRate,
- });
+ let tokenInFiat = new Numeric(value, 10);
+
+ if (fromCurrency !== toCurrency && totalExchangeRate) {
+ tokenInFiat = tokenInFiat.applyConversionRate(totalExchangeRate);
+ }
+
+ return tokenInFiat.round(2).toString();
}
export function hasUnconfirmedTransactions(state) {
diff --git a/ui/helpers/utils/confirm-tx.util.test.js b/ui/helpers/utils/confirm-tx.util.test.js
index d0f4971a8488..5389164c900c 100644
--- a/ui/helpers/utils/confirm-tx.util.test.js
+++ b/ui/helpers/utils/confirm-tx.util.test.js
@@ -2,36 +2,6 @@ import { GAS_LIMITS } from '../../../shared/constants/gas';
import * as utils from './confirm-tx.util';
describe('Confirm Transaction utils', () => {
- describe('increaseLastGasPrice', () => {
- it('should increase the gasPrice by 10%', () => {
- const increasedGasPrice = utils.increaseLastGasPrice('0xa');
- expect(increasedGasPrice).toStrictEqual('0xb');
- });
-
- it('should prefix the result with 0x', () => {
- const increasedGasPrice = utils.increaseLastGasPrice('a');
- expect(increasedGasPrice).toStrictEqual('0xb');
- });
- });
-
- describe('hexGreaterThan', () => {
- it('should return true if the first value is greater than the second value', () => {
- expect(utils.hexGreaterThan('0xb', '0xa')).toStrictEqual(true);
- });
-
- it('should return false if the first value is less than the second value', () => {
- expect(utils.hexGreaterThan('0xa', '0xb')).toStrictEqual(false);
- });
-
- it('should return false if the first value is equal to the second value', () => {
- expect(utils.hexGreaterThan('0xa', '0xa')).toStrictEqual(false);
- });
-
- it('should correctly compare prefixed and non-prefixed hex values', () => {
- expect(utils.hexGreaterThan('0xb', 'a')).toStrictEqual(true);
- });
- });
-
describe('getHexGasTotal', () => {
it('should multiply the hex gasLimit and hex gasPrice values together', () => {
expect(
diff --git a/ui/helpers/utils/gas.js b/ui/helpers/utils/gas.js
index 0355a3449bfc..1aa19cafc488 100644
--- a/ui/helpers/utils/gas.js
+++ b/ui/helpers/utils/gas.js
@@ -1,20 +1,19 @@
import { constant, times, uniq, zip } from 'lodash';
import BigNumber from 'bignumber.js';
-import { addHexPrefix } from 'ethereumjs-util';
import {
GAS_RECOMMENDATIONS,
EDIT_GAS_MODES,
} from '../../../shared/constants/gas';
-import {
- hexWEIToDecGWEI,
- multiplyCurrencies,
-} from '../../../shared/modules/conversion.utils';
+import { hexWEIToDecGWEI } from '../../../shared/modules/conversion.utils';
+import { Numeric } from '../../../shared/modules/Numeric';
import {
bnGreaterThan,
isNullish,
roundToDecimalPlacesRemovingExtraZeroes,
} from './util';
+const TEN_PERCENT_NUMERIC = new Numeric(1.1, 10);
+
export const gasEstimateGreaterThanGasUsedPlusTenPercent = (
gasUsed,
gasFeeEstimates,
@@ -35,33 +34,16 @@ export const gasEstimateGreaterThanGasUsedPlusTenPercent = (
* by 1.10 to get bare minimum new gas fee.
*
* @param {string | undefined} hexStringValue - hex value in wei to be incremented
- * @param conversionOptions
* @returns {string | undefined} hex value in WEI 10% higher than the param.
*/
-export function addTenPercent(hexStringValue, conversionOptions = {}) {
+export function addTenPercentAndRound(hexStringValue) {
if (hexStringValue === undefined) {
return undefined;
}
- return addHexPrefix(
- multiplyCurrencies(hexStringValue, 1.1, {
- toNumericBase: 'hex',
- multiplicandBase: 16,
- multiplierBase: 10,
- numberOfDecimals: 0,
- ...conversionOptions,
- }),
- );
-}
-
-/**
- * Simple helper to save on duplication to multiply the supplied wei hex string
- * by 1.10 to get bare minimum new gas fee.
- *
- * @param {string | undefined} hexStringValue - hex value in wei to be incremented
- * @returns {string | undefined} hex value in WEI 10% higher than the param.
- */
-export function addTenPercentAndRound(hexStringValue) {
- return addTenPercent(hexStringValue, { numberOfDecimals: 0 });
+ return new Numeric(hexStringValue, 16)
+ .times(TEN_PERCENT_NUMERIC)
+ .round(0)
+ .toPrefixedHexString();
}
export function isMetamaskSuggestedGasEstimate(estimate) {
diff --git a/ui/helpers/utils/gas.test.js b/ui/helpers/utils/gas.test.js
index cf197afb79b4..177206a22a89 100644
--- a/ui/helpers/utils/gas.test.js
+++ b/ui/helpers/utils/gas.test.js
@@ -1,7 +1,6 @@
import { PRIORITY_LEVELS } from '../../../shared/constants/gas';
import {
- addTenPercent,
gasEstimateGreaterThanGasUsedPlusTenPercent,
formatGasFeeOrFeeRange,
} from './gas';
@@ -38,17 +37,6 @@ describe('Gas utils', () => {
});
});
- describe('addTenPercent', () => {
- it('should add 10% to hex value passed', () => {
- const result = addTenPercent('0x59682f00');
- expect(result).toStrictEqual('0x62590080');
- });
- it('should return undefined if undefined value is passed', () => {
- const result = addTenPercent(undefined);
- expect(result).toBeUndefined();
- });
- });
-
describe('formatGasFeeOrFeeRange', () => {
describe('given a singular fee', () => {
it('should return a string "X GWEI" where X is the fee rounded to the given precision', () => {
diff --git a/ui/helpers/utils/token-util.js b/ui/helpers/utils/token-util.js
index 04e63db9c18e..863cb5f769f4 100644
--- a/ui/helpers/utils/token-util.js
+++ b/ui/helpers/utils/token-util.js
@@ -1,14 +1,11 @@
import log from 'loglevel';
-import {
- conversionUtil,
- multiplyCurrencies,
-} from '../../../shared/modules/conversion.utils';
import { getTokenStandardAndDetails } from '../../store/actions';
import { isEqualCaseInsensitive } from '../../../shared/modules/string-utils';
import { parseStandardTokenTransactionData } from '../../../shared/modules/transaction.utils';
import { TokenStandard } from '../../../shared/constants/transaction';
import { getTokenValueParam } from '../../../shared/lib/metamask-controller-utils';
import { calcTokenAmount } from '../../../shared/lib/transactions-controller-utils';
+import { Numeric } from '../../../shared/modules/Numeric';
import * as util from './util';
import { formatCurrency } from './confirm-tx.util';
@@ -189,21 +186,19 @@ export function getTokenFiatAmount(
return undefined;
}
- const currentTokenToFiatRate = multiplyCurrencies(
- contractExchangeRate,
- conversionRate,
- {
- multiplicandBase: 10,
- multiplierBase: 10,
- },
- );
- const currentTokenInFiat = conversionUtil(tokenAmount, {
- fromNumericBase: 'dec',
- fromCurrency: tokenSymbol,
- toCurrency: currentCurrency.toUpperCase(),
- numberOfDecimals: 2,
- conversionRate: currentTokenToFiatRate,
- });
+ const currentTokenToFiatRate = new Numeric(contractExchangeRate, 10)
+ .times(new Numeric(conversionRate, 10))
+ .toString();
+
+ let currentTokenInFiat = new Numeric(tokenAmount, 10);
+
+ if (tokenSymbol !== currentCurrency.toUpperCase() && currentTokenToFiatRate) {
+ currentTokenInFiat = currentTokenInFiat.applyConversionRate(
+ currentTokenToFiatRate,
+ );
+ }
+
+ currentTokenInFiat = currentTokenInFiat.round(2).toString();
let result;
if (hideCurrencySymbol) {
result = formatCurrency(currentTokenInFiat, currentCurrency);
diff --git a/ui/helpers/utils/util.js b/ui/helpers/utils/util.js
index e470f69b0353..85850630d66f 100644
--- a/ui/helpers/utils/util.js
+++ b/ui/helpers/utils/util.js
@@ -15,7 +15,7 @@ import {
TRUNCATED_NAME_CHAR_LIMIT,
TRUNCATED_ADDRESS_END_CHARS,
} from '../../../shared/constants/labels';
-import { toBigNumber } from '../../../shared/modules/conversion.utils';
+import { Numeric } from '../../../shared/modules/Numeric';
// formatData :: ( date: ) -> String
export function formatDate(date, format = "M/d/y 'at' T") {
@@ -485,9 +485,10 @@ export function roundToDecimalPlacesRemovingExtraZeroes(
if (numberish === undefined || numberish === null) {
return '';
}
- return toBigNumber
- .dec(toBigNumber.dec(numberish).toFixed(numberOfDecimalPlaces))
- .toNumber();
+ return new Numeric(
+ new Numeric(numberish, 10).toFixed(numberOfDecimalPlaces),
+ 10,
+ ).toNumber();
}
/**
diff --git a/ui/hooks/gasFeeInput/test-utils.js b/ui/hooks/gasFeeInput/test-utils.js
index 949600092c91..4ceb2ac53bd9 100644
--- a/ui/hooks/gasFeeInput/test-utils.js
+++ b/ui/hooks/gasFeeInput/test-utils.js
@@ -1,10 +1,6 @@
import { useSelector } from 'react-redux';
import { GAS_ESTIMATE_TYPES } from '../../../shared/constants/gas';
-import {
- conversionUtil,
- multiplyCurrencies,
-} from '../../../shared/modules/conversion.utils';
import {
getConversionRate,
getNativeCurrency,
@@ -26,6 +22,8 @@ import {
getCustomMaxFeePerGas,
getCustomMaxPriorityFeePerGas,
} from '../../ducks/swaps/swaps';
+import { Numeric } from '../../../shared/modules/Numeric';
+import { EtherDenomination } from '../../../shared/constants/common';
// Why this number?
// 20 gwei * 21000 gasLimit = 420,000 gwei
@@ -148,30 +146,15 @@ export const generateUseSelectorRouter =
return undefined;
};
-export function getTotalCostInETH(gwei, gasLimit) {
- return multiplyCurrencies(gwei, gasLimit, {
- fromDenomination: 'GWEI',
- toDenomination: 'ETH',
- multiplicandBase: 10,
- multiplierBase: 10,
- });
-}
-
export function convertFromHexToFiat(value) {
- const val = conversionUtil(value, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- });
+ const val = new Numeric(value, 16).toBase(10).toString();
return `$${(val * MOCK_ETH_USD_CONVERSION_RATE).toFixed(2)}`;
}
export function convertFromHexToETH(value) {
- const val = conversionUtil(value, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- });
+ const val = new Numeric(value, 16, EtherDenomination.WEI)
+ .toBase(10)
+ .toDenomination(EtherDenomination.ETH);
return `${val} ETH`;
}
diff --git a/ui/hooks/gasFeeInput/useGasFeeErrors.js b/ui/hooks/gasFeeInput/useGasFeeErrors.js
index 49771b83705d..6a8ba2d5ce70 100644
--- a/ui/hooks/gasFeeInput/useGasFeeErrors.js
+++ b/ui/hooks/gasFeeInput/useGasFeeErrors.js
@@ -1,11 +1,6 @@
import { useMemo } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
import { GAS_ESTIMATE_TYPES, GAS_LIMITS } from '../../../shared/constants/gas';
-import {
- conversionLessThan,
- conversionGreaterThan,
- addHexes,
-} from '../../../shared/modules/conversion.utils';
import {
checkNetworkAndAccountSupports1559,
getSelectedAccount,
@@ -13,13 +8,13 @@ import {
import { isLegacyTransaction } from '../../helpers/utils/transactions.util';
import { bnGreaterThan, bnLessThan } from '../../helpers/utils/util';
import { GAS_FORM_ERRORS } from '../../helpers/constants/gas';
+import { Numeric } from '../../../shared/modules/Numeric';
const HIGH_FEE_WARNING_MULTIPLIER = 1.5;
const validateGasLimit = (gasLimit, minimumGasLimit) => {
- const gasLimitTooLow = conversionLessThan(
- { value: gasLimit, fromNumericBase: 'dec' },
- { value: minimumGasLimit || GAS_LIMITS.SIMPLE, fromNumericBase: 'hex' },
+ const gasLimitTooLow = new Numeric(gasLimit, 10).lessThan(
+ new Numeric(minimumGasLimit || GAS_LIMITS.SIMPLE, 16),
);
if (gasLimitTooLow) {
@@ -139,15 +134,12 @@ const hasBalanceError = (minimumCostInHexWei, transaction, ethBalance) => {
if (minimumCostInHexWei === undefined || ethBalance === undefined) {
return false;
}
- const minimumTxCostInHexWei = addHexes(
- minimumCostInHexWei,
- transaction?.txParams?.value || '0x0',
+ const minimumTxCostInHexWei = new Numeric(minimumCostInHexWei, 16).add(
+ new Numeric(transaction?.txParams?.value || '0x0', 16),
);
+ const ethBalanceInHexWei = new Numeric(ethBalance, 16);
- return conversionGreaterThan(
- { value: minimumTxCostInHexWei, fromNumericBase: 'hex' },
- { value: ethBalance, fromNumericBase: 'hex' },
- );
+ return minimumTxCostInHexWei.greaterThan(ethBalanceInHexWei);
};
/**
diff --git a/ui/hooks/gasFeeInput/useTransactionFunctions.js b/ui/hooks/gasFeeInput/useTransactionFunctions.js
index 15af059f64b9..9158a8329215 100644
--- a/ui/hooks/gasFeeInput/useTransactionFunctions.js
+++ b/ui/hooks/gasFeeInput/useTransactionFunctions.js
@@ -2,10 +2,6 @@ import { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { EDIT_GAS_MODES, PRIORITY_LEVELS } from '../../../shared/constants/gas';
-import {
- decGWEIToHexWEI,
- decimalToHex,
-} from '../../../shared/modules/conversion.utils';
import {
addTenPercentAndRound,
editGasModeIsSpeedUpOrCancel,
@@ -18,6 +14,10 @@ import {
updateSwapsUserFeeLevel,
updateTransactionGasFees,
} from '../../store/actions';
+import {
+ decGWEIToHexWEI,
+ decimalToHex,
+} from '../../../shared/modules/conversion.utils';
/**
* @typedef {object} TransactionFunctionsReturnType
diff --git a/ui/hooks/useCurrencyDisplay.js b/ui/hooks/useCurrencyDisplay.js
index eb675428b76c..2963f53eb60c 100644
--- a/ui/hooks/useCurrencyDisplay.js
+++ b/ui/hooks/useCurrencyDisplay.js
@@ -7,11 +7,10 @@ import {
getNativeCurrency,
} from '../ducks/metamask/metamask';
-import {
- conversionUtil,
- getValueFromWeiHex,
-} from '../../shared/modules/conversion.utils';
+import { getValueFromWeiHex } from '../../shared/modules/conversion.utils';
import { TEST_NETWORK_TICKER_MAP } from '../../shared/constants/network';
+import { Numeric } from '../../shared/modules/Numeric';
+import { EtherDenomination } from '../../shared/constants/common';
/**
* Defines the shape of the options parameter for useCurrencyDisplay
@@ -61,13 +60,11 @@ export function useCurrencyDisplay(
currency === nativeCurrency ||
(!isUserPreferredCurrency && !nativeCurrency)
) {
- return conversionUtil(inputValue, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- numberOfDecimals: numberOfDecimals || 2,
- toDenomination: denomination,
- });
+ return new Numeric(inputValue, 16, EtherDenomination.WEI)
+ .toDenomination(denomination || EtherDenomination.ETH)
+ .round(numberOfDecimals || 2)
+ .toBase(10)
+ .toString();
} else if (isUserPreferredCurrency && conversionRate) {
return formatCurrency(
getValueFromWeiHex({
diff --git a/ui/hooks/useIncrementedGasFees.js b/ui/hooks/useIncrementedGasFees.js
index 14e58391be55..e85c7362b4c0 100644
--- a/ui/hooks/useIncrementedGasFees.js
+++ b/ui/hooks/useIncrementedGasFees.js
@@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js';
import { useMemo } from 'react';
import { decGWEIToHexWEI } from '../../shared/modules/conversion.utils';
import { isEIP1559Transaction } from '../../shared/modules/transaction.utils';
-import { addTenPercent } from '../helpers/utils/gas';
+import { addTenPercentAndRound } from '../helpers/utils/gas';
import { useGasFeeEstimates } from './useGasFeeEstimates';
/**
@@ -15,7 +15,7 @@ import { useGasFeeEstimates } from './useGasFeeEstimates';
* @returns {string} hexWei value of the higher of the two inputs.
*/
function getHighestIncrementedFee(originalFee, currentEstimate) {
- const buffedOriginalHexWei = addTenPercent(originalFee);
+ const buffedOriginalHexWei = addTenPercentAndRound(originalFee);
const currentEstimateHexWei = decGWEIToHexWEI(currentEstimate);
return new BigNumber(buffedOriginalHexWei, 16).greaterThan(
diff --git a/ui/pages/confirm-decrypt-message/confirm-decrypt-message.component.js b/ui/pages/confirm-decrypt-message/confirm-decrypt-message.component.js
index f30576674a8f..ed12e9e81d33 100644
--- a/ui/pages/confirm-decrypt-message/confirm-decrypt-message.component.js
+++ b/ui/pages/confirm-decrypt-message/confirm-decrypt-message.component.js
@@ -11,7 +11,8 @@ import { PageContainerFooter } from '../../components/ui/page-container';
import { EVENT } from '../../../shared/constants/metametrics';
import { SECOND } from '../../../shared/constants/time';
-import { conversionUtil } from '../../../shared/modules/conversion.utils';
+import { Numeric } from '../../../shared/modules/Numeric';
+import { EtherDenomination } from '../../../shared/constants/common';
export default class ConfirmDecryptMessage extends Component {
static contextTypes = {
@@ -98,13 +99,14 @@ export default class ConfirmDecryptMessage extends Component {
} = this.state;
const { t } = this.context;
- const nativeCurrencyBalance = conversionUtil(balance, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- numberOfDecimals: 6,
- conversionRate,
- });
+ const nativeCurrencyBalance = new Numeric(
+ balance,
+ 16,
+ EtherDenomination.WEI,
+ )
+ .applyConversionRate(conversionRate)
+ .round(6)
+ .toBase(10);
return (
diff --git a/ui/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js b/ui/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js
index acf4328b3100..205f2d0cca78 100644
--- a/ui/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js
+++ b/ui/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js
@@ -6,8 +6,9 @@ import Identicon from '../../components/ui/identicon';
import { PageContainerFooter } from '../../components/ui/page-container';
import { EVENT } from '../../../shared/constants/metametrics';
-import { conversionUtil } from '../../../shared/modules/conversion.utils';
import SiteOrigin from '../../components/ui/site-origin';
+import { Numeric } from '../../../shared/modules/Numeric';
+import { EtherDenomination } from '../../../shared/constants/common';
export default class ConfirmEncryptionPublicKey extends Component {
static contextTypes = {
@@ -74,13 +75,14 @@ export default class ConfirmEncryptionPublicKey extends Component {
} = this.props;
const { t } = this.context;
- const nativeCurrencyBalance = conversionUtil(balance, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- numberOfDecimals: 6,
- conversionRate,
- });
+ const nativeCurrencyBalance = new Numeric(
+ balance,
+ 16,
+ EtherDenomination.WEI,
+ )
+ .applyConversionRate(conversionRate)
+ .round(6)
+ .toBase(10);
return (
diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js
index 19eaf03c5682..ecbe550d03f3 100644
--- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js
+++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js
@@ -67,12 +67,12 @@ import {
CHAIN_ID_TO_NETWORK_ID_MAP,
///: END:ONLY_INCLUDE_IN
} from '../../../shared/constants/network';
-import TransactionAlerts from '../../components/app/transaction-alerts';
import {
addHexes,
hexToDecimal,
hexWEIToDecGWEI,
} from '../../../shared/modules/conversion.utils';
+import TransactionAlerts from '../../components/app/transaction-alerts';
const renderHeartBeatIfNotInTest = () =>
process.env.IN_TEST ? null :
;
diff --git a/ui/pages/send/send.constants.js b/ui/pages/send/send.constants.js
index 38acb8081fbd..a93828ddd465 100644
--- a/ui/pages/send/send.constants.js
+++ b/ui/pages/send/send.constants.js
@@ -1,31 +1,25 @@
-import {
- conversionUtil,
- multiplyCurrencies,
-} from '../../../shared/modules/conversion.utils';
-import { addHexPrefix } from '../../../app/scripts/lib/util';
import { MIN_GAS_LIMIT_HEX } from '../../../shared/constants/gas';
+import { Numeric } from '../../../shared/modules/Numeric';
+import { EtherDenomination } from '../../../shared/constants/common';
const MIN_GAS_PRICE_DEC = '0';
const MIN_GAS_PRICE_HEX = parseInt(MIN_GAS_PRICE_DEC, 10).toString(16);
-const MIN_GAS_LIMIT_DEC = '21000';
+const MIN_GAS_LIMIT_DEC = new Numeric('21000', 10);
const MAX_GAS_LIMIT_DEC = '7920027';
const HIGH_FEE_WARNING_MULTIPLIER = 1.5;
-const MIN_GAS_PRICE_GWEI = addHexPrefix(
- conversionUtil(MIN_GAS_PRICE_HEX, {
- fromDenomination: 'WEI',
- toDenomination: 'GWEI',
- fromNumericBase: 'hex',
- toNumericBase: 'hex',
- numberOfDecimals: 1,
- }),
-);
+const MIN_GAS_PRICE_GWEI = new Numeric(
+ MIN_GAS_PRICE_HEX,
+ 16,
+ EtherDenomination.WEI,
+)
+ .toDenomination(EtherDenomination.GWEI)
+ .round(1)
+ .toPrefixedHexString();
-const MIN_GAS_TOTAL = multiplyCurrencies(MIN_GAS_LIMIT_HEX, MIN_GAS_PRICE_HEX, {
- toNumericBase: 'hex',
- multiplicandBase: 16,
- multiplierBase: 16,
-});
+const MIN_GAS_TOTAL = new Numeric(MIN_GAS_LIMIT_HEX, 16)
+ .times(new Numeric(MIN_GAS_PRICE_HEX, 16, EtherDenomination.WEI))
+ .toPrefixedHexString();
const TOKEN_TRANSFER_FUNCTION_SIGNATURE = '0xa9059cbb';
const COLLECTIBLE_TRANSFER_FROM_FUNCTION_SIGNATURE = '0x23b872dd';
diff --git a/ui/pages/send/send.utils.js b/ui/pages/send/send.utils.js
index 317a6f8cd395..4463fd9b3c50 100644
--- a/ui/pages/send/send.utils.js
+++ b/ui/pages/send/send.utils.js
@@ -1,16 +1,8 @@
import abi from 'ethereumjs-abi';
-import {
- addCurrencies,
- conversionUtil,
- conversionGTE,
- multiplyCurrencies,
- conversionGreaterThan,
- conversionLessThan,
-} from '../../../shared/modules/conversion.utils';
import { addHexPrefix } from '../../../app/scripts/lib/util';
import { TokenStandard } from '../../../shared/constants/transaction';
-import { calcTokenAmount } from '../../../shared/lib/transactions-controller-utils';
+import { Numeric } from '../../../shared/modules/Numeric';
import {
TOKEN_TRANSFER_FUNCTION_SIGNATURE,
COLLECTIBLE_TRANSFER_FROM_FUNCTION_SIGNATURE,
@@ -33,46 +25,22 @@ function isBalanceSufficient({
gasTotal = '0x0',
primaryCurrency,
}) {
- const totalAmount = addCurrencies(amount, gasTotal, {
- aBase: 16,
- bBase: 16,
- toNumericBase: 'hex',
- });
+ let totalAmount = new Numeric(amount, 16).add(new Numeric(gasTotal, 16));
+ let balanceNumeric = new Numeric(balance, 16);
- const balanceIsSufficient = conversionGTE(
- {
- value: balance,
- fromNumericBase: 'hex',
- fromCurrency: primaryCurrency,
- conversionRate,
- },
- {
- value: totalAmount,
- fromNumericBase: 'hex',
- conversionRate,
- fromCurrency: primaryCurrency,
- },
- );
+ if (typeof primaryCurrency !== 'undefined' && primaryCurrency !== null) {
+ totalAmount = totalAmount.applyConversionRate(conversionRate);
+ balanceNumeric = balanceNumeric.applyConversionRate(conversionRate);
+ }
- return balanceIsSufficient;
+ return balanceNumeric.greaterThanOrEqualTo(totalAmount);
}
function isTokenBalanceSufficient({ amount = '0x0', tokenBalance, decimals }) {
- const amountInDec = conversionUtil(amount, {
- fromNumericBase: 'hex',
- });
+ const amountNumeric = new Numeric(amount, 16).shiftedBy(decimals);
+ const tokenBalanceNumeric = new Numeric(tokenBalance, 16);
- const tokenBalanceIsSufficient = conversionGTE(
- {
- value: tokenBalance,
- fromNumericBase: 'hex',
- },
- {
- value: calcTokenAmount(amountInDec, decimals),
- },
- );
-
- return tokenBalanceIsSufficient;
+ return tokenBalanceNumeric.greaterThanOrEqualTo(amountNumeric);
}
function addGasBuffer(
@@ -80,43 +48,25 @@ function addGasBuffer(
blockGasLimitHex,
bufferMultiplier = 1.5,
) {
- const upperGasLimit = multiplyCurrencies(blockGasLimitHex, 0.9, {
- toNumericBase: 'hex',
- multiplicandBase: 16,
- multiplierBase: 10,
- numberOfDecimals: '0',
- });
- const bufferedGasLimit = multiplyCurrencies(
- initialGasLimitHex,
- bufferMultiplier,
- {
- toNumericBase: 'hex',
- multiplicandBase: 16,
- multiplierBase: 10,
- numberOfDecimals: '0',
- },
- );
+ const initialGasLimit = new Numeric(initialGasLimitHex, 16);
+ const upperGasLimit = new Numeric(blockGasLimitHex, 16)
+ .times(new Numeric(0.9, 10))
+ .round(0);
+
+ const bufferedGasLimit = initialGasLimit
+ .times(new Numeric(bufferMultiplier, 10))
+ .round(0);
// if initialGasLimit is above blockGasLimit, dont modify it
- if (
- conversionGreaterThan(
- { value: initialGasLimitHex, fromNumericBase: 'hex' },
- { value: upperGasLimit, fromNumericBase: 'hex' },
- )
- ) {
+ if (initialGasLimit.greaterThanOrEqualTo(upperGasLimit)) {
return initialGasLimitHex;
}
// if bufferedGasLimit is below blockGasLimit, use bufferedGasLimit
- if (
- conversionLessThan(
- { value: bufferedGasLimit, fromNumericBase: 'hex' },
- { value: upperGasLimit, fromNumericBase: 'hex' },
- )
- ) {
- return bufferedGasLimit;
+ if (bufferedGasLimit.lessThan(upperGasLimit)) {
+ return bufferedGasLimit.toString();
}
// otherwise use blockGasLimit
- return upperGasLimit;
+ return upperGasLimit.toString();
}
function generateERC20TransferData({
diff --git a/ui/pages/send/send.utils.test.js b/ui/pages/send/send.utils.test.js
index 4c772298f334..401bc696b564 100644
--- a/ui/pages/send/send.utils.test.js
+++ b/ui/pages/send/send.utils.test.js
@@ -1,11 +1,5 @@
import { rawEncode } from 'ethereumjs-abi';
-import {
- addCurrencies,
- conversionGTE,
- conversionUtil,
-} from '../../../shared/modules/conversion.utils';
-
import {
generateERC20TransferData,
isBalanceSufficient,
@@ -13,35 +7,6 @@ import {
ellipsify,
} from './send.utils';
-jest.mock('../../../shared/modules/conversion.utils', () => ({
- addCurrencies: jest.fn((a, b) => {
- let [a1, b1] = [a, b];
- if (String(a).match(/^0x.+/u)) {
- a1 = Number(String(a).slice(2));
- }
- if (String(b).match(/^0x.+/u)) {
- b1 = Number(String(b).slice(2));
- }
- return a1 + b1;
- }),
- conversionUtil: jest.fn((val) => parseInt(val, 16)),
- conversionGTE: jest.fn((obj1, obj2) => obj1.value >= obj2.value),
- multiplyCurrencies: jest.fn((a, b) => `${a}x${b}`),
- conversionGreaterThan: (obj1, obj2) => obj1.value > obj2.value,
- conversionLessThan: (obj1, obj2) => obj1.value < obj2.value,
-}));
-
-jest.mock('../../../shared/lib/transactions-controller-utils', () => {
- const originalModule = jest.requireActual(
- '../../../shared/lib/transactions-controller-utils',
- );
-
- return {
- ...originalModule,
- calcTokenAmount: (a, d) => `calc:${a}${d}`,
- };
-});
-
jest.mock('ethereumjs-abi', () => ({
rawEncode: jest.fn().mockReturnValue(16, 1100),
}));
@@ -84,7 +49,7 @@ describe('send utils', () => {
});
describe('isBalanceSufficient()', () => {
- it('should correctly call addCurrencies and return the result of calling conversionGTE', () => {
+ it('should correctly sum the appropriate currencies and ensure that balance is greater', () => {
const result = isBalanceSufficient({
amount: 15,
balance: 100,
@@ -92,53 +57,29 @@ describe('send utils', () => {
gasTotal: 17,
primaryCurrency: 'ABC',
});
- expect(addCurrencies).toHaveBeenCalledWith(15, 17, {
- aBase: 16,
- bBase: 16,
- toNumericBase: 'hex',
- });
- expect(conversionGTE).toHaveBeenCalledWith(
- {
- value: 100,
- fromNumericBase: 'hex',
- fromCurrency: 'ABC',
- conversionRate: 3,
- },
- {
- value: 32,
- fromNumericBase: 'hex',
- conversionRate: 3,
- fromCurrency: 'ABC',
- },
- );
-
expect(result).toStrictEqual(true);
});
});
describe('isTokenBalanceSufficient()', () => {
- it('should correctly call conversionUtil and return the result of calling conversionGTE', () => {
+ it('should return true for a sufficient balance for token spend', () => {
const result = isTokenBalanceSufficient({
amount: '0x10',
tokenBalance: 123,
decimals: 10,
});
- expect(conversionUtil).toHaveBeenCalledWith('0x10', {
- fromNumericBase: 'hex',
- });
+ expect(result).toStrictEqual(true);
+ });
- expect(conversionGTE).toHaveBeenCalledWith(
- {
- value: 123,
- fromNumericBase: 'hex',
- },
- {
- value: 'calc:1610',
- },
- );
+ it('should return false for an insufficient balance for token spend', () => {
+ const result = isTokenBalanceSufficient({
+ amount: '0x10000',
+ tokenBalance: 123,
+ decimals: 10,
+ });
- expect(result).toStrictEqual(false);
+ expect(result).toStrictEqual(true);
});
});
diff --git a/ui/selectors/custom-gas.js b/ui/selectors/custom-gas.js
index 1a0b276cac4f..fa2a39ed2c08 100644
--- a/ui/selectors/custom-gas.js
+++ b/ui/selectors/custom-gas.js
@@ -1,9 +1,5 @@
import { addHexPrefix } from '../../app/scripts/lib/util';
-import {
- conversionUtil,
- conversionGreaterThan,
- decEthToConvertedCurrency,
-} from '../../shared/modules/conversion.utils';
+import { decEthToConvertedCurrency } from '../../shared/modules/conversion.utils';
import { formatCurrency } from '../helpers/utils/confirm-tx.util';
import { formatETHFee } from '../helpers/utils/formatters';
@@ -15,6 +11,8 @@ import {
isEIP1559Network,
} from '../ducks/metamask/metamask';
import { calcGasTotal } from '../../shared/lib/transactions-controller-utils';
+import { Numeric } from '../../shared/modules/Numeric';
+import { EtherDenomination } from '../../shared/constants/common';
import { getIsMainnet } from '.';
export function getCustomGasLimit(state) {
@@ -91,15 +89,9 @@ export function isCustomPriceSafe(state) {
return false;
}
- const customPriceSafe = conversionGreaterThan(
- {
- value: customGasPrice,
- fromNumericBase: 'hex',
- fromDenomination: 'WEI',
- toDenomination: 'GWEI',
- },
- { value: safeLow, fromNumericBase: 'dec' },
- );
+ const customPriceSafe = new Numeric(customGasPrice, 16, EtherDenomination.WEI)
+ .toDenomination(EtherDenomination.GWEI)
+ .greaterThan(safeLow, 10);
return customPriceSafe;
}
@@ -117,15 +109,9 @@ export function isCustomPriceSafeForCustomNetwork(state) {
return false;
}
- const customPriceSafe = conversionGreaterThan(
- {
- value: customGasPrice,
- fromNumericBase: 'hex',
- fromDenomination: 'WEI',
- toDenomination: 'GWEI',
- },
- { value: estimatedPrice, fromNumericBase: 'dec' },
- );
+ const customPriceSafe = new Numeric(customGasPrice, 16, EtherDenomination.WEI)
+ .toDenomination(EtherDenomination.GWEI)
+ .greaterThan(estimatedPrice, 10);
return customPriceSafe;
}
@@ -139,18 +125,13 @@ export function isCustomPriceExcessive(state, checkSend = false) {
}
// Custom gas should be considered excessive when it is 1.5 times greater than the fastest estimate.
- const customPriceExcessive = conversionGreaterThan(
- {
- value: customPrice,
- fromNumericBase: 'hex',
- fromDenomination: 'WEI',
- toDenomination: 'GWEI',
- },
- {
- fromNumericBase: 'dec',
- value: Math.floor(fastPrice * 1.5),
- },
- );
+ const customPriceExcessive = new Numeric(
+ customPrice,
+ 16,
+ EtherDenomination.WEI,
+ )
+ .toDenomination(EtherDenomination.GWEI)
+ .greaterThan(Math.floor(fastPrice * 1.5), 10);
return customPriceExcessive;
}
@@ -160,12 +141,14 @@ export function basicPriceEstimateToETHTotal(
gasLimit,
numberOfDecimals = 9,
) {
- return conversionUtil(calcGasTotal(gasLimit, estimate), {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'GWEI',
- numberOfDecimals,
- });
+ return new Numeric(
+ calcGasTotal(gasLimit, estimate),
+ 16,
+ EtherDenomination.GWEI,
+ )
+ .round(numberOfDecimals)
+ .toBase(10)
+ .toString();
}
export function getRenderableEthFee(
@@ -174,10 +157,7 @@ export function getRenderableEthFee(
numberOfDecimals = 9,
nativeCurrency = 'ETH',
) {
- const value = conversionUtil(estimate, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- });
+ const value = new Numeric(estimate, 10).toBase(16).toString();
const fee = basicPriceEstimateToETHTotal(value, gasLimit, numberOfDecimals);
return formatETHFee(fee, nativeCurrency);
}
@@ -188,10 +168,7 @@ export function getRenderableConvertedCurrencyFee(
convertedCurrency,
conversionRate,
) {
- const value = conversionUtil(estimate, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- });
+ const value = new Numeric(estimate, 10).toBase(16).toString();
const fee = basicPriceEstimateToETHTotal(value, gasLimit);
const feeInCurrency = decEthToConvertedCurrency(
fee,
@@ -202,20 +179,14 @@ export function getRenderableConvertedCurrencyFee(
}
export function priceEstimateToWei(priceEstimate) {
- return conversionUtil(priceEstimate, {
- fromNumericBase: 'hex',
- toNumericBase: 'hex',
- fromDenomination: 'GWEI',
- toDenomination: 'WEI',
- numberOfDecimals: 9,
- });
+ return new Numeric(priceEstimate, 16, EtherDenomination.GWEI)
+ .toDenomination(EtherDenomination.WEI)
+ .round(9)
+ .toString();
}
export function getGasPriceInHexWei(price) {
- const value = conversionUtil(price, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- });
+ const value = new Numeric(price, 10).toBase(16).toString();
return addHexPrefix(priceEstimateToWei(value));
}
From 2900fe2c1a7e1f4321f1469d10a5c057ef090bea Mon Sep 17 00:00:00 2001
From: Maarten Zuidhoorn
Date: Tue, 24 Jan 2023 16:03:01 +0100
Subject: [PATCH 08/21] Move subject type enum to
`@metamask/subject-metadata-controller` (#16431)
* Move subject type enum to @metamask/controllers
* Fix imports
---
app/scripts/metamask-controller.js | 30 ++++++++++---------
app/scripts/migrations/069.js | 6 ++--
app/scripts/migrations/069.test.js | 6 ++--
shared/constants/app.ts | 14 ---------
ui/hooks/useOriginMetadata.js | 4 +--
.../permissions-connect.container.js | 6 ++--
ui/selectors/selectors.js | 13 ++++----
7 files changed, 32 insertions(+), 47 deletions(-)
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 09ee91298b88..fa3135f657b3 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -46,7 +46,10 @@ import {
PermissionController,
PermissionsRequestNotFoundError,
} from '@metamask/permission-controller';
-import { SubjectMetadataController } from '@metamask/subject-metadata-controller';
+import {
+ SubjectMetadataController,
+ SubjectType,
+} from '@metamask/subject-metadata-controller';
///: BEGIN:ONLY_INCLUDE_IN(flask)
import { RateLimitController } from '@metamask/rate-limit-controller';
import { NotificationController } from '@metamask/notification-controller';
@@ -97,7 +100,6 @@ import {
SNAP_DIALOG_TYPES,
///: END:ONLY_INCLUDE_IN
POLLING_TOKEN_ENVIRONMENT_TYPES,
- SUBJECT_TYPES,
} from '../../shared/constants/app';
import { EVENT, EVENT_NAMES } from '../../shared/constants/metametrics';
@@ -1494,7 +1496,7 @@ export default class MetamaskController extends EventEmitter {
version,
} = snap;
this.subjectMetadataController.addSubjectMetadata({
- subjectType: SUBJECT_TYPES.SNAP,
+ subjectType: SubjectType.Snap,
name: proposedName,
origin: snap.id,
version,
@@ -3541,9 +3543,9 @@ export default class MetamaskController extends EventEmitter {
if (subjectType) {
_subjectType = subjectType;
} else if (sender.id && sender.id !== this.extension.runtime.id) {
- _subjectType = SUBJECT_TYPES.EXTENSION;
+ _subjectType = SubjectType.Extension;
} else {
- _subjectType = SUBJECT_TYPES.WEBSITE;
+ _subjectType = SubjectType.Website;
}
if (sender.url) {
@@ -3595,7 +3597,7 @@ export default class MetamaskController extends EventEmitter {
this.setupProviderConnection(
mux.createStream('provider'),
sender,
- SUBJECT_TYPES.INTERNAL,
+ SubjectType.Internal,
);
}
@@ -3711,15 +3713,15 @@ export default class MetamaskController extends EventEmitter {
*
* @param {*} outStream - The stream to provide over.
* @param {MessageSender | SnapSender} sender - The sender of the messages on this stream
- * @param {string} subjectType - The type of the sender, i.e. subject.
+ * @param {SubjectType} subjectType - The type of the sender, i.e. subject.
*/
setupProviderConnection(outStream, sender, subjectType) {
let origin;
- if (subjectType === SUBJECT_TYPES.INTERNAL) {
+ if (subjectType === SubjectType.Internal) {
origin = ORIGIN_METAMASK;
}
///: BEGIN:ONLY_INCLUDE_IN(flask)
- else if (subjectType === SUBJECT_TYPES.SNAP) {
+ else if (subjectType === SubjectType.Snap) {
origin = sender.snapId;
}
///: END:ONLY_INCLUDE_IN
@@ -3731,7 +3733,7 @@ export default class MetamaskController extends EventEmitter {
this.subjectMetadataController.addSubjectMetadata({
origin,
extensionId: sender.id,
- subjectType: SUBJECT_TYPES.EXTENSION,
+ subjectType: SubjectType.Extension,
});
}
@@ -3777,7 +3779,7 @@ export default class MetamaskController extends EventEmitter {
this.setupUntrustedCommunication({
connectionStream,
sender: { snapId },
- subjectType: SUBJECT_TYPES.SNAP,
+ subjectType: SubjectType.Snap,
});
}
///: END:ONLY_INCLUDE_IN
@@ -3834,7 +3836,7 @@ export default class MetamaskController extends EventEmitter {
);
// onboarding
- if (subjectType === SUBJECT_TYPES.WEBSITE) {
+ if (subjectType === SubjectType.Website) {
engine.push(
createOnboardingMiddleware({
location: sender.url,
@@ -3942,7 +3944,7 @@ export default class MetamaskController extends EventEmitter {
///: BEGIN:ONLY_INCLUDE_IN(flask)
engine.push(
- createSnapMethodMiddleware(subjectType === SUBJECT_TYPES.SNAP, {
+ createSnapMethodMiddleware(subjectType === SubjectType.Snap, {
getAppKey: this.getAppKeyForSubject.bind(this, origin),
getUnlockPromise: this.appStateController.getUnlockPromise.bind(
this.appStateController,
@@ -3975,7 +3977,7 @@ export default class MetamaskController extends EventEmitter {
);
///: END:ONLY_INCLUDE_IN
- if (subjectType !== SUBJECT_TYPES.INTERNAL) {
+ if (subjectType !== SubjectType.Internal) {
// permissions
engine.push(
this.permissionController.createPermissionMiddleware({
diff --git a/app/scripts/migrations/069.js b/app/scripts/migrations/069.js
index 8635fb9cd0f1..2f07770e9665 100644
--- a/app/scripts/migrations/069.js
+++ b/app/scripts/migrations/069.js
@@ -1,5 +1,5 @@
+import { SubjectType } from '@metamask/subject-metadata-controller';
import { cloneDeep } from 'lodash';
-import { SUBJECT_TYPES } from '../../../shared/constants/app';
const version = 69;
@@ -32,8 +32,8 @@ function transformState(state) {
!Array.isArray(metadata)
) {
metadata.subjectType = metadata.extensionId
- ? SUBJECT_TYPES.EXTENSION
- : SUBJECT_TYPES.WEBSITE;
+ ? SubjectType.Extension
+ : SubjectType.Website;
}
});
}
diff --git a/app/scripts/migrations/069.test.js b/app/scripts/migrations/069.test.js
index 8a830d693f6e..84200a08f5c1 100644
--- a/app/scripts/migrations/069.test.js
+++ b/app/scripts/migrations/069.test.js
@@ -1,4 +1,4 @@
-import { SUBJECT_TYPES } from '../../../shared/constants/app';
+import { SubjectType } from '@metamask/subject-metadata-controller';
import migration69 from './069';
describe('migration #69', () => {
@@ -61,14 +61,14 @@ describe('migration #69', () => {
name: 'DEX Aggregator - 1inch.exchange',
origin: 'https://1inch.exchange',
extensionId: null,
- subjectType: SUBJECT_TYPES.WEBSITE,
+ subjectType: SubjectType.Website,
},
'https://ascii-tree-generator.com': {
iconUrl: 'https://ascii-tree-generator.com/favicon.ico',
name: 'ASCII Tree Generator',
origin: 'https://ascii-tree-generator.com',
extensionId: 'ascii-tree-generator-extension',
- subjectType: SUBJECT_TYPES.EXTENSION,
+ subjectType: SubjectType.Extension,
},
'https://null.com': null,
'https://foo.com': 'bad data',
diff --git a/shared/constants/app.ts b/shared/constants/app.ts
index a84c02e7b119..62e240696087 100644
--- a/shared/constants/app.ts
+++ b/shared/constants/app.ts
@@ -78,20 +78,6 @@ export const EXTENSION_MESSAGES = {
READY: 'METAMASK_EXTENSION_READY',
} as const;
-/**
- * The different kinds of subjects that MetaMask may interact with, including
- * third parties and itself (e.g. when the background communicated with the UI).
- */
-export const SUBJECT_TYPES = {
- EXTENSION: 'extension',
- INTERNAL: 'internal',
- UNKNOWN: 'unknown',
- WEBSITE: 'website',
- ///: BEGIN:ONLY_INCLUDE_IN(flask)
- SNAP: 'snap',
- ///: END:ONLY_INCLUDE_IN
-} as const;
-
export const POLLING_TOKEN_ENVIRONMENT_TYPES = {
[ENVIRONMENT_TYPE_POPUP]: 'popupGasPollTokens',
[ENVIRONMENT_TYPE_NOTIFICATION]: 'notificationGasPollTokens',
diff --git a/ui/hooks/useOriginMetadata.js b/ui/hooks/useOriginMetadata.js
index 481d3a7333fa..fe1eaef104a1 100644
--- a/ui/hooks/useOriginMetadata.js
+++ b/ui/hooks/useOriginMetadata.js
@@ -1,6 +1,6 @@
+import { SubjectType } from '@metamask/subject-metadata-controller';
import { useSelector } from 'react-redux';
import { getTargetSubjectMetadata } from '../selectors';
-import { SUBJECT_TYPES } from '../../shared/constants/app';
/**
* @typedef {object} OriginMetadata
@@ -34,7 +34,7 @@ export function useOriginMetadata(origin) {
host: url.host,
hostname: url.hostname,
origin,
- subjectType: SUBJECT_TYPES.UNKNOWN,
+ subjectType: SubjectType.Unknown,
};
} catch (_) {
// do nothing
diff --git a/ui/pages/permissions-connect/permissions-connect.container.js b/ui/pages/permissions-connect/permissions-connect.container.js
index d99ed279c232..39d3109ffe06 100644
--- a/ui/pages/permissions-connect/permissions-connect.container.js
+++ b/ui/pages/permissions-connect/permissions-connect.container.js
@@ -1,3 +1,4 @@
+import { SubjectType } from '@metamask/subject-metadata-controller';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import {
@@ -32,7 +33,6 @@ import {
CONNECT_SNAP_UPDATE_ROUTE,
///: END:ONLY_INCLUDE_IN
} from '../../helpers/constants/routes';
-import { SUBJECT_TYPES } from '../../../shared/constants/app';
import PermissionApproval from './permissions-connect.component';
const mapStateToProps = (state, ownProps) => {
@@ -68,11 +68,11 @@ const mapStateToProps = (state, ownProps) => {
origin,
iconUrl: null,
extensionId: null,
- subjectType: SUBJECT_TYPES.UNKNOWN,
+ subjectType: SubjectType.Unknown,
};
///: BEGIN:ONLY_INCLUDE_IN(flask)
- const isSnap = targetSubjectMetadata.subjectType === SUBJECT_TYPES.SNAP;
+ const isSnap = targetSubjectMetadata.subjectType === SubjectType.Snap;
///: END:ONLY_INCLUDE_IN
const accountsWithLabels = getAccountsWithLabels(state);
diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js
index a5ce6a86fbe0..d4c4c3686bdb 100644
--- a/ui/selectors/selectors.js
+++ b/ui/selectors/selectors.js
@@ -1,3 +1,6 @@
+///: BEGIN:ONLY_INCLUDE_IN(flask)
+import { SubjectType } from '@metamask/subject-metadata-controller';
+///: END:ONLY_INCLUDE_IN
import {
createSelector,
createSelectorCreator,
@@ -28,13 +31,7 @@ import {
LedgerTransportTypes,
HardwareTransportStates,
} from '../../shared/constants/hardware-wallets';
-
-import {
- MESSAGE_TYPE,
- ///: BEGIN:ONLY_INCLUDE_IN(flask)
- SUBJECT_TYPES,
- ///: END:ONLY_INCLUDE_IN
-} from '../../shared/constants/app';
+import { MESSAGE_TYPE } from '../../shared/constants/app';
import { TRUNCATED_NAME_CHAR_LIMIT } from '../../shared/constants/labels';
@@ -632,7 +629,7 @@ export function getTargetSubjectMetadata(state, origin) {
const metadata = getSubjectMetadata(state)[origin];
///: BEGIN:ONLY_INCLUDE_IN(flask)
- if (metadata?.subjectType === SUBJECT_TYPES.SNAP) {
+ if (metadata?.subjectType === SubjectType.Snap) {
const { svgIcon, ...remainingMetadata } = metadata;
return {
...remainingMetadata,
From cd484835e36f347aa6a2b5c4857fe5891513ab0b Mon Sep 17 00:00:00 2001
From: weizman
Date: Tue, 24 Jan 2023 17:29:06 +0200
Subject: [PATCH 09/21] Add Firefox Snow support (#17147)
---
development/build/static.js | 3 +--
package.json | 2 +-
yarn.lock | 10 +++++-----
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/development/build/static.js b/development/build/static.js
index d018f8a99b20..b32c339fe4b6 100644
--- a/development/build/static.js
+++ b/development/build/static.js
@@ -25,8 +25,7 @@ module.exports = function createStaticAssetTasks({
browserPlatforms.forEach((browser) => {
const [copyTargetsProd, copyTargetsDev] = getCopyTargets(
shouldIncludeLockdown,
- // Snow currently only works on Chromium based browsers
- shouldIncludeSnow && browser === 'chrome',
+ shouldIncludeSnow,
);
copyTargetsProds[browser] = copyTargetsProd;
copyTargetsDevs[browser] = copyTargetsDev;
diff --git a/package.json b/package.json
index 77eecfe7da42..b2eab479c6c9 100644
--- a/package.json
+++ b/package.json
@@ -213,7 +213,7 @@
"@fortawesome/fontawesome-free": "^5.13.0",
"@keystonehq/bc-ur-registry-eth": "^0.12.1",
"@keystonehq/metamask-airgapped-keyring": "^0.6.1",
- "@lavamoat/snow": "^1.3.0",
+ "@lavamoat/snow": "^1.4.1",
"@material-ui/core": "^4.11.0",
"@metamask/address-book-controller": "^1.0.0",
"@metamask/announcement-controller": "^1.0.0",
diff --git a/yarn.lock b/yarn.lock
index e893ddad7b67..c49e86de0d0f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3347,12 +3347,12 @@ __metadata:
languageName: node
linkType: hard
-"@lavamoat/snow@npm:^1.3.0":
- version: 1.3.0
- resolution: "@lavamoat/snow@npm:1.3.0"
+"@lavamoat/snow@npm:^1.4.1":
+ version: 1.4.1
+ resolution: "@lavamoat/snow@npm:1.4.1"
dependencies:
is-cross-origin: ^1.0.1
- checksum: 580a8378a098936d0d4df31abc1f688c57194225414baea0292ece51efcc0865565af5e974784ee5156291380e86da91996efa00637363ceb76335824122a6f4
+ checksum: d4dcd9907bb4caa7ac7fc130dbe7eff0295a992769136895c222b8e823edb0de44aa822e467670515ef70e85b9e5edb93c4ca9ffc05735ed18528304e478754a
languageName: node
linkType: hard
@@ -24096,7 +24096,7 @@ __metadata:
"@keystonehq/metamask-airgapped-keyring": ^0.6.1
"@lavamoat/allow-scripts": ^2.0.3
"@lavamoat/lavapack": ^4.0.0
- "@lavamoat/snow": ^1.3.0
+ "@lavamoat/snow": ^1.4.1
"@material-ui/core": ^4.11.0
"@metamask/address-book-controller": ^1.0.0
"@metamask/announcement-controller": ^1.0.0
From f5426a84d9125f0476c65dc469d727cb1120d589 Mon Sep 17 00:00:00 2001
From: Danica Shen
Date: Tue, 24 Jan 2023 16:38:01 +0000
Subject: [PATCH 10/21] feat(mme-17212): convert shared/constants/swaps.js ->
Typescript (#17322)
---
shared/constants/{swaps.js => swaps.ts} | 88 ++++++++++++-------
ui/ducks/swaps/swaps.js | 10 +--
ui/hooks/useTokensToSearch.js | 8 +-
.../swaps/awaiting-swap/awaiting-swap.test.js | 4 +-
ui/pages/swaps/build-quote/build-quote.js | 6 +-
.../slippage-buttons/slippage-buttons.js | 18 ++--
.../slippage-buttons.stories.js | 2 +-
.../slippage-buttons/slippage-buttons.test.js | 12 +--
8 files changed, 88 insertions(+), 60 deletions(-)
rename shared/constants/{swaps.js => swaps.ts} (85%)
diff --git a/shared/constants/swaps.js b/shared/constants/swaps.ts
similarity index 85%
rename from shared/constants/swaps.js
rename to shared/constants/swaps.ts
index 649312be5068..8a8c0726be98 100644
--- a/shared/constants/swaps.js
+++ b/shared/constants/swaps.ts
@@ -16,10 +16,34 @@ export const CONTRACT_DATA_DISABLED_ERROR = 'contract-data-disabled';
export const OFFLINE_FOR_MAINTENANCE = 'offline-for-maintenance';
export const SWAPS_FETCH_ORDER_CONFLICT = 'swaps-fetch-order-conflict';
-// An address that the metaswap-api recognizes as the default token for the current network, in place of the token address that ERC-20 tokens have
+// An address that the metaswap-api recognizes as the default token for the current network,
+// in place of the token address that ERC-20 tokens have
const DEFAULT_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000000';
-export const ETH_SWAPS_TOKEN_OBJECT = {
+interface SwapsTokenObject {
+ /**
+ * The symbol of token object
+ */
+ symbol: string;
+ /**
+ * The name for the network
+ */
+ name: string;
+ /**
+ * An address that the metaswap-api recognizes as the default token
+ */
+ address: string;
+ /**
+ * Number of digits after decimal point
+ */
+ decimals: number;
+ /**
+ * URL for token icon
+ */
+ iconUrl: string;
+}
+
+export const ETH_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
symbol: CURRENCY_SYMBOLS.ETH,
name: 'Ether',
address: DEFAULT_TOKEN_ADDRESS,
@@ -27,49 +51,53 @@ export const ETH_SWAPS_TOKEN_OBJECT = {
iconUrl: ETH_TOKEN_IMAGE_URL,
};
-export const BNB_SWAPS_TOKEN_OBJECT = {
+export const BNB_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
symbol: CURRENCY_SYMBOLS.BNB,
name: 'Binance Coin',
address: DEFAULT_TOKEN_ADDRESS,
decimals: 18,
iconUrl: BNB_TOKEN_IMAGE_URL,
-};
+} as const;
-export const MATIC_SWAPS_TOKEN_OBJECT = {
+export const MATIC_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
symbol: CURRENCY_SYMBOLS.MATIC,
name: 'Matic',
address: DEFAULT_TOKEN_ADDRESS,
decimals: 18,
iconUrl: MATIC_TOKEN_IMAGE_URL,
-};
+} as const;
-export const AVAX_SWAPS_TOKEN_OBJECT = {
+export const AVAX_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
symbol: CURRENCY_SYMBOLS.AVALANCHE,
name: 'Avalanche',
address: DEFAULT_TOKEN_ADDRESS,
decimals: 18,
iconUrl: AVAX_TOKEN_IMAGE_URL,
-};
+} as const;
-export const TEST_ETH_SWAPS_TOKEN_OBJECT = {
+export const TEST_ETH_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
symbol: CURRENCY_SYMBOLS.TEST_ETH,
name: 'Test Ether',
address: DEFAULT_TOKEN_ADDRESS,
decimals: 18,
iconUrl: TEST_ETH_TOKEN_IMAGE_URL,
-};
+} as const;
-export const GOERLI_SWAPS_TOKEN_OBJECT = {
+export const GOERLI_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
symbol: CURRENCY_SYMBOLS.ETH,
name: 'Ether',
address: DEFAULT_TOKEN_ADDRESS,
decimals: 18,
iconUrl: TEST_ETH_TOKEN_IMAGE_URL,
-};
+} as const;
-export const ARBITRUM_SWAPS_TOKEN_OBJECT = { ...ETH_SWAPS_TOKEN_OBJECT };
+export const ARBITRUM_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
+ ...ETH_SWAPS_TOKEN_OBJECT,
+} as const;
-export const OPTIMISM_SWAPS_TOKEN_OBJECT = { ...ETH_SWAPS_TOKEN_OBJECT };
+export const OPTIMISM_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {
+ ...ETH_SWAPS_TOKEN_OBJECT,
+} as const;
// A gas value for ERC20 approve calls that should be sufficient for all ERC20 approve implementations
export const DEFAULT_ERC20_APPROVE_GAS = '0x1d4c0';
@@ -124,17 +152,17 @@ export const ALLOWED_PROD_SWAPS_CHAIN_IDS = [
CHAIN_IDS.AVALANCHE,
CHAIN_IDS.OPTIMISM,
CHAIN_IDS.ARBITRUM,
-];
+] as const;
export const ALLOWED_DEV_SWAPS_CHAIN_IDS = [
...ALLOWED_PROD_SWAPS_CHAIN_IDS,
CHAIN_IDS.GOERLI,
-];
+] as const;
export const ALLOWED_SMART_TRANSACTIONS_CHAIN_IDS = [
CHAIN_IDS.MAINNET,
CHAIN_IDS.GOERLI,
-];
+] as const;
export const SWAPS_CHAINID_CONTRACT_ADDRESS_MAP = {
[CHAIN_IDS.MAINNET]: MAINNET_CONTRACT_ADDRESS,
@@ -145,7 +173,7 @@ export const SWAPS_CHAINID_CONTRACT_ADDRESS_MAP = {
[CHAIN_IDS.AVALANCHE]: AVALANCHE_CONTRACT_ADDRESS,
[CHAIN_IDS.OPTIMISM]: OPTIMISM_CONTRACT_ADDRESS,
[CHAIN_IDS.ARBITRUM]: ARBITRUM_CONTRACT_ADDRESS,
-};
+} as const;
export const SWAPS_WRAPPED_TOKENS_ADDRESSES = {
[CHAIN_IDS.MAINNET]: WETH_CONTRACT_ADDRESS,
@@ -156,7 +184,7 @@ export const SWAPS_WRAPPED_TOKENS_ADDRESSES = {
[CHAIN_IDS.AVALANCHE]: WAVAX_CONTRACT_ADDRESS,
[CHAIN_IDS.OPTIMISM]: WETH_OPTIMISM_CONTRACT_ADDRESS,
[CHAIN_IDS.ARBITRUM]: WETH_ARBITRUM_CONTRACT_ADDRESS,
-};
+} as const;
export const ALLOWED_CONTRACT_ADDRESSES = {
[CHAIN_IDS.MAINNET]: [
@@ -191,7 +219,7 @@ export const ALLOWED_CONTRACT_ADDRESSES = {
SWAPS_CHAINID_CONTRACT_ADDRESS_MAP[CHAIN_IDS.ARBITRUM],
SWAPS_WRAPPED_TOKENS_ADDRESSES[CHAIN_IDS.ARBITRUM],
],
-};
+} as const;
export const SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {
[CHAIN_IDS.MAINNET]: ETH_SWAPS_TOKEN_OBJECT,
@@ -202,7 +230,7 @@ export const SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {
[CHAIN_IDS.AVALANCHE]: AVAX_SWAPS_TOKEN_OBJECT,
[CHAIN_IDS.OPTIMISM]: OPTIMISM_SWAPS_TOKEN_OBJECT,
[CHAIN_IDS.ARBITRUM]: ARBITRUM_SWAPS_TOKEN_OBJECT,
-};
+} as const;
export const SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP = {
[CHAIN_IDS.BSC]: BSC_DEFAULT_BLOCK_EXPLORER_URL,
@@ -212,7 +240,7 @@ export const SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP = {
[CHAIN_IDS.AVALANCHE]: AVALANCHE_DEFAULT_BLOCK_EXPLORER_URL,
[CHAIN_IDS.OPTIMISM]: OPTIMISM_DEFAULT_BLOCK_EXPLORER_URL,
[CHAIN_IDS.ARBITRUM]: ARBITRUM_DEFAULT_BLOCK_EXPLORER_URL,
-};
+} as const;
export const ETHEREUM = 'ethereum';
export const POLYGON = 'polygon';
@@ -224,12 +252,12 @@ export const ARBITRUM = 'arbitrum';
export const SWAPS_CLIENT_ID = 'extension';
-export const TOKEN_BUCKET_PRIORITY = {
- OWNED: 'owned',
- TOP: 'top',
-};
+export enum TokenBucketPriority {
+ owned = 'owned',
+ top = 'top',
+}
-export const SLIPPAGE = {
- DEFAULT: 2,
- HIGH: 3,
-};
+export enum Slippage {
+ default = 2,
+ high = 3,
+}
diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js
index 3f469e01a1d4..d44ccc8d321f 100644
--- a/ui/ducks/swaps/swaps.js
+++ b/ui/ducks/swaps/swaps.js
@@ -77,7 +77,7 @@ import {
SWAP_FAILED_ERROR,
SWAPS_FETCH_ORDER_CONFLICT,
ALLOWED_SMART_TRANSACTIONS_CHAIN_IDS,
- SLIPPAGE,
+ Slippage,
} from '../../../shared/constants/swaps';
import {
TransactionType,
@@ -112,7 +112,7 @@ const initialState = {
fromTokenInputValue: '',
fromTokenError: null,
isFeatureFlagLoaded: false,
- maxSlippage: SLIPPAGE.DEFAULT,
+ maxSlippage: Slippage.default,
quotesFetchStartTime: null,
reviewSwapClickedTimestamp: null,
topAssets: {},
@@ -742,7 +742,7 @@ export const fetchQuotesAndSetQuoteState = (
token_to: toTokenSymbol,
request_type: balanceError ? 'Quote' : 'Order',
slippage: maxSlippage,
- custom_slippage: maxSlippage !== SLIPPAGE.DEFAULT,
+ custom_slippage: maxSlippage !== Slippage.default,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
stx_enabled: smartTransactionsEnabled,
@@ -796,7 +796,7 @@ export const fetchQuotesAndSetQuoteState = (
token_to: toTokenSymbol,
request_type: balanceError ? 'Quote' : 'Order',
slippage: maxSlippage,
- custom_slippage: maxSlippage !== SLIPPAGE.DEFAULT,
+ custom_slippage: maxSlippage !== Slippage.default,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
stx_enabled: smartTransactionsEnabled,
@@ -821,7 +821,7 @@ export const fetchQuotesAndSetQuoteState = (
),
request_type: balanceError ? 'Quote' : 'Order',
slippage: maxSlippage,
- custom_slippage: maxSlippage !== SLIPPAGE.DEFAULT,
+ custom_slippage: maxSlippage !== Slippage.default,
response_time: Date.now() - fetchStartTime,
best_quote_source: newSelectedQuote.aggregator,
available_quotes: Object.values(fetchedQuotes)?.length,
diff --git a/ui/hooks/useTokensToSearch.js b/ui/hooks/useTokensToSearch.js
index b56a71d25548..459abcd12747 100644
--- a/ui/hooks/useTokensToSearch.js
+++ b/ui/hooks/useTokensToSearch.js
@@ -16,7 +16,7 @@ import { getConversionRate } from '../ducks/metamask/metamask';
import { getSwapsTokens } from '../ducks/swaps/swaps';
import { isSwapsDefaultTokenSymbol } from '../../shared/modules/swaps.utils';
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
-import { TOKEN_BUCKET_PRIORITY } from '../../shared/constants/swaps';
+import { TokenBucketPriority } from '../../shared/constants/swaps';
import { CHAIN_IDS, CURRENCY_SYMBOLS } from '../../shared/constants/network';
import { useEqualityCheck } from './useEqualityCheck';
@@ -96,7 +96,7 @@ export function useTokensToSearch({
usersTokens = [],
topTokens = {},
shuffledTokensList,
- tokenBucketPriority = TOKEN_BUCKET_PRIORITY.OWNED,
+ tokenBucketPriority = TokenBucketPriority.owned,
}) {
const chainId = useSelector(getCurrentChainId);
const tokenConversionRates = useSelector(getTokenExchangeRates, isEqual);
@@ -156,7 +156,7 @@ export function useTokensToSearch({
chainId,
tokenList,
);
- if (tokenBucketPriority === TOKEN_BUCKET_PRIORITY.OWNED) {
+ if (tokenBucketPriority === TokenBucketPriority.owned) {
if (
isSwapsDefaultTokenSymbol(renderableDataToken.symbol, chainId) ||
usersTokensAddressMap[token.address.toLowerCase()]
@@ -189,7 +189,7 @@ export function useTokensToSearch({
},
);
tokensToSearchBuckets.top = tokensToSearchBuckets.top.filter(Boolean);
- if (tokenBucketPriority === TOKEN_BUCKET_PRIORITY.OWNED) {
+ if (tokenBucketPriority === TokenBucketPriority.owned) {
return [
...tokensToSearchBuckets.owned,
...tokensToSearchBuckets.top,
diff --git a/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js b/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js
index e213d4ca4909..e432145de66c 100644
--- a/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js
+++ b/ui/pages/swaps/awaiting-swap/awaiting-swap.test.js
@@ -9,7 +9,7 @@ import {
fireEvent,
} from '../../../../test/jest';
import {
- SLIPPAGE,
+ Slippage,
QUOTES_EXPIRED_ERROR,
SWAP_FAILED_ERROR,
ERROR_FETCHING_QUOTES,
@@ -28,7 +28,7 @@ const createProps = (customProps = {}) => {
tokensReceived: 'tokens received:',
submittingSwap: true,
inputValue: 5,
- maxSlippage: SLIPPAGE.DEFAULT,
+ maxSlippage: Slippage.default,
txId: 6571648590592143,
...customProps,
};
diff --git a/ui/pages/swaps/build-quote/build-quote.js b/ui/pages/swaps/build-quote/build-quote.js
index b5b3bed7d2bb..bb62e69fb58b 100644
--- a/ui/pages/swaps/build-quote/build-quote.js
+++ b/ui/pages/swaps/build-quote/build-quote.js
@@ -86,7 +86,7 @@ import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
import {
SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP,
SWAPS_CHAINID_DEFAULT_TOKEN_MAP,
- TOKEN_BUCKET_PRIORITY,
+ TokenBucketPriority,
} from '../../../../shared/constants/swaps';
import {
@@ -221,13 +221,13 @@ export default function BuildQuote({
usersTokens: memoizedUsersTokens,
topTokens: topAssets,
shuffledTokensList,
- tokenBucketPriority: TOKEN_BUCKET_PRIORITY.OWNED,
+ tokenBucketPriority: TokenBucketPriority.owned,
});
const tokensToSearchSwapTo = useTokensToSearch({
usersTokens: memoizedUsersTokens,
topTokens: topAssets,
shuffledTokensList,
- tokenBucketPriority: TOKEN_BUCKET_PRIORITY.TOP,
+ tokenBucketPriority: TokenBucketPriority.top,
});
const selectedToToken =
tokensToSearchSwapFrom.find(({ address }) =>
diff --git a/ui/pages/swaps/slippage-buttons/slippage-buttons.js b/ui/pages/swaps/slippage-buttons/slippage-buttons.js
index 653497940ee0..e85fdde4896d 100644
--- a/ui/pages/swaps/slippage-buttons/slippage-buttons.js
+++ b/ui/pages/swaps/slippage-buttons/slippage-buttons.js
@@ -15,7 +15,7 @@ import {
DISPLAY,
} from '../../../helpers/constants/design-system';
import { getTranslatedStxErrorMessage } from '../swaps.util';
-import { SLIPPAGE } from '../../../../shared/constants/swaps';
+import { Slippage } from '../../../../shared/constants/swaps';
export default function SlippageButtons({
onSelect,
@@ -31,7 +31,7 @@ export default function SlippageButtons({
const [customValue, setCustomValue] = useState(() => {
if (
typeof currentSlippage === 'number' &&
- !Object.values(SLIPPAGE).includes(currentSlippage)
+ !Object.values(Slippage).includes(currentSlippage)
) {
return currentSlippage.toString();
}
@@ -39,9 +39,9 @@ export default function SlippageButtons({
});
const [enteringCustomValue, setEnteringCustomValue] = useState(false);
const [activeButtonIndex, setActiveButtonIndex] = useState(() => {
- if (currentSlippage === SLIPPAGE.HIGH) {
+ if (currentSlippage === Slippage.high) {
return 1; // 3% slippage.
- } else if (currentSlippage === SLIPPAGE.DEFAULT) {
+ } else if (currentSlippage === Slippage.default) {
return 0; // 2% slippage.
} else if (typeof currentSlippage === 'number') {
return 2; // Custom slippage.
@@ -49,7 +49,7 @@ export default function SlippageButtons({
return 0;
});
const [open, setOpen] = useState(() => {
- return currentSlippage !== SLIPPAGE.DEFAULT; // Only open Advanced options by default if it's not default slippage.
+ return currentSlippage !== Slippage.default; // Only open Advanced options by default if it's not default slippage.
});
const [inputRef, setInputRef] = useState(null);
@@ -133,20 +133,20 @@ export default function SlippageButtons({
setCustomValue('');
setEnteringCustomValue(false);
setActiveButtonIndex(0);
- onSelect(SLIPPAGE.DEFAULT);
+ onSelect(Slippage.default);
}}
>
- {t('swapSlippagePercent', [SLIPPAGE.DEFAULT])}
+ {t('swapSlippagePercent', [Slippage.default])}
diff --git a/ui/components/component-library/avatar-favicon/avatar-favicon.js b/ui/components/component-library/avatar-favicon/avatar-favicon.js
index 168e304370fb..4831663bdcf4 100644
--- a/ui/components/component-library/avatar-favicon/avatar-favicon.js
+++ b/ui/components/component-library/avatar-favicon/avatar-favicon.js
@@ -40,7 +40,7 @@ export const AvatarFavicon = ({
/>
) : (
-
-
-
-
+
+
+
+
+
```
### Color and Background Color
diff --git a/ui/components/component-library/avatar-icon/__snapshots__/avatar-icon.test.js.snap b/ui/components/component-library/avatar-icon/__snapshots__/avatar-icon.test.js.snap
index 94ba48ffc56e..e7132ee0df50 100644
--- a/ui/components/component-library/avatar-icon/__snapshots__/avatar-icon.test.js.snap
+++ b/ui/components/component-library/avatar-icon/__snapshots__/avatar-icon.test.js.snap
@@ -8,7 +8,7 @@ exports[`AvatarIcon should render correctly 1`] = `
>
diff --git a/ui/components/component-library/avatar-icon/avatar-icon.stories.js b/ui/components/component-library/avatar-icon/avatar-icon.stories.js
index cc117da5fe97..0b4bbdb47dea 100644
--- a/ui/components/component-library/avatar-icon/avatar-icon.stories.js
+++ b/ui/components/component-library/avatar-icon/avatar-icon.stories.js
@@ -88,7 +88,7 @@ export default {
};
const Template = (args) => {
- return ;
+ return ;
};
export const DefaultStory = Template.bind({});
@@ -105,7 +105,7 @@ export const Size = (args) => (
);
Size.args = {
- iconName: ICON_NAMES.CHECK_CIRCLE_ON_FILLED,
+ iconName: ICON_NAMES.CONFIRMATION,
};
export const IconName = (args) => (
@@ -113,31 +113,31 @@ export const IconName = (args) => (
@@ -148,37 +148,37 @@ export const ColorAndBackgroundColor = (args) => (
diff --git a/ui/components/component-library/avatar-icon/avatar-icon.test.js b/ui/components/component-library/avatar-icon/avatar-icon.test.js
index 144a31492dd4..fc8e3babac35 100644
--- a/ui/components/component-library/avatar-icon/avatar-icon.test.js
+++ b/ui/components/component-library/avatar-icon/avatar-icon.test.js
@@ -10,7 +10,7 @@ describe('AvatarIcon', () => {
it('should render correctly', () => {
const { getByTestId, container } = render(
,
);
@@ -22,27 +22,27 @@ describe('AvatarIcon', () => {
const { getByTestId } = render(
<>
@@ -68,7 +68,7 @@ describe('AvatarIcon', () => {
it('should render with added classname', () => {
const { getByTestId } = render(
,
@@ -79,7 +79,7 @@ describe('AvatarIcon', () => {
it('should render with icon', () => {
const { getByTestId } = render(
,
);
@@ -90,7 +90,7 @@ describe('AvatarIcon', () => {
it('should render with success color icon and background color', () => {
const { getByTestId } = render(
Button;
+Button;
```
diff --git a/ui/components/component-library/button-base/button-base.js b/ui/components/component-library/button-base/button-base.js
index 64c4c9a615a0..0c554a99147b 100644
--- a/ui/components/component-library/button-base/button-base.js
+++ b/ui/components/component-library/button-base/button-base.js
@@ -84,8 +84,8 @@ export const ButtonBase = ({
{loading && (
)}
diff --git a/ui/components/component-library/button-base/button-base.stories.js b/ui/components/component-library/button-base/button-base.stories.js
index 4905122e79d5..38b7c3c6fb15 100644
--- a/ui/components/component-library/button-base/button-base.stories.js
+++ b/ui/components/component-library/button-base/button-base.stories.js
@@ -167,8 +167,8 @@ Loading.args = {
loading: true,
};
-export const IconName = (args) => (
-
+export const Icon = (args) => (
+
Button
);
diff --git a/ui/components/component-library/button-icon/README.mdx b/ui/components/component-library/button-icon/README.mdx
index 19475e809683..da806682d1a7 100644
--- a/ui/components/component-library/button-icon/README.mdx
+++ b/ui/components/component-library/button-icon/README.mdx
@@ -29,7 +29,7 @@ Use the [IconSearch](/story/components-componentlibrary-icon--default-story) sto
import { ButtonIcon } from '../ui/component-library';
import { ICON_NAMES } from '../icon';
-;
+;
```
### Size
@@ -52,8 +52,8 @@ Possible sizes include:
import { SIZES } from '../../../helpers/constants/design-system';
import { ButtonIcon } from '../ui/component-library';
-
-
+
+
```
### Aria Label
@@ -68,7 +68,7 @@ Use the `ariaLabel` prop to set the name of the ButtonIcon for proper accessibil
import { ButtonIcon } from '../ui/component-library';
-
+
```
@@ -89,7 +89,7 @@ Button `as` options:
import { ButtonIcon } from '../ui/component-library';
-
+
```
@@ -142,5 +142,5 @@ Use the boolean `disabled` prop to disable button
```jsx
import { ButtonIcon } from '../ui/component-library';
-;
+;
```
diff --git a/ui/components/component-library/button-icon/__snapshots__/button-icon.test.js.snap b/ui/components/component-library/button-icon/__snapshots__/button-icon.test.js.snap
index 6100807d7332..f2616c2c6f0d 100644
--- a/ui/components/component-library/button-icon/__snapshots__/button-icon.test.js.snap
+++ b/ui/components/component-library/button-icon/__snapshots__/button-icon.test.js.snap
@@ -9,7 +9,7 @@ exports[`ButtonIcon should render button element correctly 1`] = `
>
diff --git a/ui/components/component-library/button-icon/button-icon.stories.js b/ui/components/component-library/button-icon/button-icon.stories.js
index c90962b3389c..dc3d8f128b7a 100644
--- a/ui/components/component-library/button-icon/button-icon.stories.js
+++ b/ui/components/component-library/button-icon/button-icon.stories.js
@@ -94,7 +94,7 @@ export default {
export const DefaultStory = (args) => ;
DefaultStory.args = {
- iconName: ICON_NAMES.CLOSE_OUTLINE,
+ iconName: ICON_NAMES.CLOSE,
ariaLabel: 'Close',
};
@@ -103,7 +103,7 @@ DefaultStory.storyName = 'Default';
export const IconName = (args) => ;
IconName.args = {
- iconName: ICON_NAMES.CLOSE_OUTLINE,
+ iconName: ICON_NAMES.CLOSE,
ariaLabel: 'Close',
};
@@ -117,14 +117,14 @@ export const Size = (args) => (
@@ -134,7 +134,7 @@ export const AriaLabel = (args) => (
<>
@@ -152,11 +152,7 @@ export const AriaLabel = (args) => (
export const As = (args) => (
-
+
(
-
+
);
Color.args = {
@@ -187,7 +183,7 @@ Color.args = {
};
export const Disabled = (args) => (
-
+
);
Disabled.args = {
diff --git a/ui/components/component-library/button-icon/button-icon.test.js b/ui/components/component-library/button-icon/button-icon.test.js
index be07763d6b86..367be115172d 100644
--- a/ui/components/component-library/button-icon/button-icon.test.js
+++ b/ui/components/component-library/button-icon/button-icon.test.js
@@ -11,7 +11,7 @@ describe('ButtonIcon', () => {
const { getByTestId, container } = render(
,
);
@@ -25,7 +25,7 @@ describe('ButtonIcon', () => {
,
);
@@ -39,7 +39,7 @@ describe('ButtonIcon', () => {
,
);
@@ -51,13 +51,13 @@ describe('ButtonIcon', () => {
const { getByTestId } = render(
<>
{
const { getByTestId } = render(
<>
{
,
);
@@ -115,7 +115,7 @@ describe('ButtonIcon', () => {
>,
@@ -128,7 +128,7 @@ describe('ButtonIcon', () => {
const { getByTestId } = render(
,
@@ -139,7 +139,7 @@ describe('ButtonIcon', () => {
it('should render with aria-label', () => {
const { getByLabelText } = render(
- ,
+ ,
);
expect(getByLabelText('add')).toBeDefined();
diff --git a/ui/components/component-library/button/README.mdx b/ui/components/component-library/button/README.mdx
index 7783d7eda16b..6c37fd94ae2c 100644
--- a/ui/components/component-library/button/README.mdx
+++ b/ui/components/component-library/button/README.mdx
@@ -186,5 +186,5 @@ Use the [IconSearch](/story/ui-components-component-library-icon-icon-stories-js
import { Button } from '../ui/component-library';
import { ICON_NAMES } from '../icon';
-;
+;
```
diff --git a/ui/components/component-library/button/button.stories.js b/ui/components/component-library/button/button.stories.js
index c4725f910620..b385c603a3e9 100644
--- a/ui/components/component-library/button/button.stories.js
+++ b/ui/components/component-library/button/button.stories.js
@@ -205,8 +205,8 @@ Loading.args = {
loading: true,
};
-export const IconName = (args) => ;
-
-IconName.args = {
- iconName: ICON_NAMES.ADD_SQUARE_FILLED,
-};
+export const Icon = (args) => (
+
+);
diff --git a/ui/components/component-library/form-text-field/README.mdx b/ui/components/component-library/form-text-field/README.mdx
index 16018e146376..6a01a0279dca 100644
--- a/ui/components/component-library/form-text-field/README.mdx
+++ b/ui/components/component-library/form-text-field/README.mdx
@@ -229,11 +229,7 @@ return (
Submit
-
+
Clear form
{submitted === FORM_STATE.SUCCESS && (
@@ -294,7 +290,7 @@ import {
Custom spending cap
{
Submit
-
+
Clear form
{submitted === FORM_STATE.SUCCESS && (
@@ -439,7 +435,7 @@ export const CustomLabelOrHelpText = () => (
Custom spending cap
diff --git a/ui/components/component-library/help-text/help-text.stories.js b/ui/components/component-library/help-text/help-text.stories.js
index 199eaa5f2f6f..54f1f62e2e24 100644
--- a/ui/components/component-library/help-text/help-text.stories.js
+++ b/ui/components/component-library/help-text/help-text.stories.js
@@ -57,7 +57,7 @@ export const Children = (args) => (
diff --git a/ui/components/component-library/help-text/help-text.test.js b/ui/components/component-library/help-text/help-text.test.js
index b87a6619d91f..32778962bbaa 100644
--- a/ui/components/component-library/help-text/help-text.test.js
+++ b/ui/components/component-library/help-text/help-text.test.js
@@ -22,7 +22,7 @@ describe('HelpText', () => {
it('should render with react nodes inside the HelpText', () => {
const { getByText, getByTestId } = render(
- help text
+ help text
,
);
expect(getByText('help text')).toBeDefined();
diff --git a/ui/components/component-library/icon/README.mdx b/ui/components/component-library/icon/README.mdx
index a7d20a0fac21..c26bc15adb55 100644
--- a/ui/components/component-library/icon/README.mdx
+++ b/ui/components/component-library/icon/README.mdx
@@ -29,10 +29,10 @@ Use the [IconSearch](/story/components-componentlibrary-icon--default-story) sto
```jsx
import { Icon, ICON_NAMES } from '../../components/component-library';
-
-
-
-
+
+
+
+
// etc...
```
@@ -42,7 +42,6 @@ Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-s
Possible sizes include:
-- `SIZES.XXS` 10px
- `SIZES.XS` 12px
- `SIZES.SM` 16px
- `SIZES.MD` 20px
@@ -58,12 +57,11 @@ Possible sizes include:
import { SIZES } from '../../../helpers/constants/design-system';
import { Icon, ICON_NAMES } from '../../components/component-library';
-
-
-
-
-
-
+
+
+
+
+
Auto also exists and inherits the
font-size of the parent element.
@@ -82,21 +80,21 @@ Use the `color` prop and the `COLORS` object from `./ui/helpers/constants/design
import { COLORS } from '../../../helpers/constants/design-system';
import { Icon, ICON_NAMES } from '../../components/component-library';
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
```
### Adding a new icon
@@ -119,7 +117,7 @@ If your svg **does not** contain a single path, you will need to get a designer
#### Step 2.
-Add your optimized svg file to to `app/images/icons` and ensure the icon name starts with `icon-` e.g. `icon-add-square-filled.svg`
+Add your optimized svg file to to `app/images/icons`
#### Step 3.
diff --git a/ui/components/component-library/icon/__snapshots__/icon.test.js.snap b/ui/components/component-library/icon/__snapshots__/icon.test.js.snap
index fa37d3955da7..ee1e15831059 100644
--- a/ui/components/component-library/icon/__snapshots__/icon.test.js.snap
+++ b/ui/components/component-library/icon/__snapshots__/icon.test.js.snap
@@ -5,7 +5,7 @@ exports[`Icon should render correctly 1`] = `
`;
diff --git a/ui/components/component-library/icon/icon.constants.js b/ui/components/component-library/icon/icon.constants.js
index 7cd4da2c1cda..f2beab695d09 100644
--- a/ui/components/component-library/icon/icon.constants.js
+++ b/ui/components/component-library/icon/icon.constants.js
@@ -15,7 +15,6 @@ import { SIZES } from '../../../helpers/constants/design-system';
/* eslint-disable prefer-destructuring*/ // process.env is not a standard JavaScript object, so we are not able to use object destructuring
export const ICON_NAMES = JSON.parse(process.env.ICON_NAMES);
export const ICON_SIZES = {
- XXS: SIZES.XXS,
XS: SIZES.XS,
SM: SIZES.SM,
MD: SIZES.MD,
diff --git a/ui/components/component-library/icon/icon.js b/ui/components/component-library/icon/icon.js
index 531f4d10cb4d..acbb21404f2f 100644
--- a/ui/components/component-library/icon/icon.js
+++ b/ui/components/component-library/icon/icon.js
@@ -30,8 +30,8 @@ export const Icon = ({
* the icon component uses mask-image instead of rendering
* the svg directly.
*/
- maskImage: `url('./images/icons/icon-${name}.svg')`,
- WebkitMaskImage: `url('./images/icons/icon-${name}.svg')`,
+ maskImage: `url('./images/icons/${name}.svg')`,
+ WebkitMaskImage: `url('./images/icons/${name}.svg')`,
...style,
}}
{...props}
@@ -46,7 +46,7 @@ Icon.propTypes = {
name: PropTypes.oneOf(Object.values(ICON_NAMES)).isRequired,
/**
* The size of the Icon.
- * Possible values could be SIZES.XXS (10px), SIZES.XS (12px), SIZES.SM (16px), SIZES.MD (20px), SIZES.LG (24px), SIZES.XL (32px),
+ * Possible values could be SIZES.XS (12px), SIZES.SM (16px), SIZES.MD (20px), SIZES.LG (24px), SIZES.XL (32px),
* Default value is SIZES.MD (20px).
*/
size: PropTypes.oneOf(Object.values(ICON_SIZES)),
diff --git a/ui/components/component-library/icon/icon.scss b/ui/components/component-library/icon/icon.scss
index d07795176c0b..3c2c86b8ed6c 100644
--- a/ui/components/component-library/icon/icon.scss
+++ b/ui/components/component-library/icon/icon.scss
@@ -16,9 +16,6 @@
-webkit-mask-position: center;
// Size
- &--size-xxs {
- --size: 10px;
- }
&--size-xs {
--size: 12px;
diff --git a/ui/components/component-library/icon/icon.stories.js b/ui/components/component-library/icon/icon.stories.js
index a165fb647a48..3ddce7976620 100644
--- a/ui/components/component-library/icon/icon.stories.js
+++ b/ui/components/component-library/icon/icon.stories.js
@@ -93,7 +93,7 @@ export default {
},
},
args: {
- name: ICON_NAMES.ADD_SQUARE_FILLED,
+ name: ICON_NAMES.ADD_SQUARE,
color: COLORS.INHERIT,
size: SIZES.MD,
},
@@ -179,7 +179,7 @@ export const DefaultStory = (args) => {
backgroundColor={COLORS.BACKGROUND_ALTERNATIVE}
rightAccessory={
{
it('should render correctly', () => {
const { getByTestId, container } = render(
- ,
+ ,
);
expect(getByTestId('icon')).toBeDefined();
expect(container.querySelector('svg')).toBeDefined();
@@ -17,7 +17,7 @@ describe('Icon', () => {
it('should render with a custom class', () => {
const { getByTestId } = render(
,
@@ -34,7 +34,7 @@ describe('Icon', () => {
*/
const { getByTestId } = render(
,
@@ -47,75 +47,60 @@ describe('Icon', () => {
it('should render with different icons using mask-image and image urls', () => {
const { getByTestId } = render(
<>
-
-
-
-
+
+
+
+
>,
);
- expect(
- window.getComputedStyle(getByTestId('icon-add-square-filled')).maskImage,
- ).toBe(`url('./images/icons/icon-add-square-filled.svg')`);
- expect(
- window.getComputedStyle(getByTestId('icon-bank-filled')).maskImage,
- ).toBe(`url('./images/icons/icon-bank-filled.svg')`);
- expect(
- window.getComputedStyle(getByTestId('icon-bookmark-filled')).maskImage,
- ).toBe(`url('./images/icons/icon-bookmark-filled.svg')`);
- expect(
- window.getComputedStyle(getByTestId('icon-calculator-filled')).maskImage,
- ).toBe(`url('./images/icons/icon-calculator-filled.svg')`);
+ expect(window.getComputedStyle(getByTestId('add-square')).maskImage).toBe(
+ `url('./images/icons/add-square.svg')`,
+ );
+ expect(window.getComputedStyle(getByTestId('bank')).maskImage).toBe(
+ `url('./images/icons/bank.svg')`,
+ );
+ expect(window.getComputedStyle(getByTestId('bookmark')).maskImage).toBe(
+ `url('./images/icons/bookmark.svg')`,
+ );
+ expect(window.getComputedStyle(getByTestId('calculator')).maskImage).toBe(
+ `url('./images/icons/calculator.svg')`,
+ );
});
it('should render with different size classes', () => {
const { getByTestId } = render(
<>
-
>,
);
- expect(getByTestId('icon-xxs')).toHaveClass('mm-icon--size-xxs');
expect(getByTestId('icon-xs')).toHaveClass('mm-icon--size-xs');
expect(getByTestId('icon-sm')).toHaveClass('mm-icon--size-sm');
expect(getByTestId('icon-md')).toHaveClass('mm-icon--size-md');
@@ -127,17 +112,17 @@ describe('Icon', () => {
const { getByTestId } = render(
<>
diff --git a/ui/components/component-library/label/README.mdx b/ui/components/component-library/label/README.mdx
index fcc9eb1674f5..2f89a8259459 100644
--- a/ui/components/component-library/label/README.mdx
+++ b/ui/components/component-library/label/README.mdx
@@ -39,7 +39,7 @@ import { Label, TextField, Icon, ICON_NAMES } from '../../component-library';
Text and icon
diff --git a/ui/components/component-library/label/label.stories.js b/ui/components/component-library/label/label.stories.js
index 430ac7c100ce..533f73db288f 100644
--- a/ui/components/component-library/label/label.stories.js
+++ b/ui/components/component-library/label/label.stories.js
@@ -62,7 +62,7 @@ export const Children = (args) => (
Text and icon
diff --git a/ui/components/component-library/label/label.test.js b/ui/components/component-library/label/label.test.js
index 6e1ccb0bcbe6..0ddd844d4a80 100644
--- a/ui/components/component-library/label/label.test.js
+++ b/ui/components/component-library/label/label.test.js
@@ -21,7 +21,7 @@ describe('label', () => {
const { getByText, getByTestId } = render(
,
);
expect(getByText('label')).toBeDefined();
diff --git a/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap b/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap
index 2364103f906e..933b2b59de5d 100644
--- a/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap
+++ b/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap
@@ -18,7 +18,7 @@ exports[`PickerNetwork should render the label inside the PickerNetwork 1`] = `
diff --git a/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap b/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap
index faad6d96a424..a0223753901e 100644
--- a/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap
+++ b/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap
@@ -11,7 +11,7 @@ exports[`TagUrl should render the label inside the TagUrl 1`] = `
>
}
/>
@@ -108,7 +108,7 @@ import { ButtonIcon, Icon, ICON_NAMES, TextFieldBase } from '../../component-lib
placeholder="Public address (0x), or ENS"
rightAccessory={
@@ -130,7 +130,7 @@ import { ButtonIcon, Icon, ICON_NAMES, TextFieldBase } from '../../component-lib
rightAccessory={
isAddressValid && (
)
@@ -217,7 +217,7 @@ const TextFieldCustomInput = (args) => (
size={SIZES.LG}
InputComponent={CustomInputComponent}
leftAccessory={
-
+
}
/>
);
diff --git a/ui/components/component-library/text-field-base/text-field-base.stories.js b/ui/components/component-library/text-field-base/text-field-base.stories.js
index 52128fd692ca..c04162de3e25 100644
--- a/ui/components/component-library/text-field-base/text-field-base.stories.js
+++ b/ui/components/component-library/text-field-base/text-field-base.stories.js
@@ -243,10 +243,7 @@ export const LeftAccessoryRightAccessory = (args) => {
name="search"
onChange={handleOnChange}
leftAccessory={
-
+
}
/>
{
onChange={handleOnChange}
rightAccessory={
@@ -317,10 +314,7 @@ export const LeftAccessoryRightAccessory = (args) => {
}
rightAccessory={
value.accountAddress.length === 42 && (
-
+
)
}
/>
@@ -470,7 +464,7 @@ export const InputComponent = (args) => (
size={SIZES.LG}
InputComponent={CustomInputComponent}
leftAccessory={
-
+
}
/>
);
diff --git a/ui/components/component-library/text-field-search/__snapshots__/text-field-search.test.js.snap b/ui/components/component-library/text-field-search/__snapshots__/text-field-search.test.js.snap
index cebcf32b50dd..c49d54b337a3 100644
--- a/ui/components/component-library/text-field-search/__snapshots__/text-field-search.test.js.snap
+++ b/ui/components/component-library/text-field-search/__snapshots__/text-field-search.test.js.snap
@@ -7,7 +7,7 @@ exports[`TextFieldSearch should render correctly 1`] = `
>
}
+ leftAccessory={}
showClearButton
clearButtonOnClick={clearButtonOnClick}
clearButtonProps={clearButtonProps}
diff --git a/ui/components/component-library/text-field/text-field.js b/ui/components/component-library/text-field/text-field.js
index 2f4386a91119..cf2c8356ebdd 100644
--- a/ui/components/component-library/text-field/text-field.js
+++ b/ui/components/component-library/text-field/text-field.js
@@ -30,7 +30,7 @@ export const TextField = ({
Date: Tue, 24 Jan 2023 12:49:26 -0600
Subject: [PATCH 13/21] Complete level 36 migration of TypeScript by converting
conversion.utils.js and deprecate old conversion util (#17262)
---
shared/modules/conversion.utils.js | 452 ------------------------
shared/modules/conversion.utils.test.js | 215 +----------
shared/modules/conversion.utils.ts | 172 +++++++++
3 files changed, 182 insertions(+), 657 deletions(-)
delete mode 100644 shared/modules/conversion.utils.js
create mode 100644 shared/modules/conversion.utils.ts
diff --git a/shared/modules/conversion.utils.js b/shared/modules/conversion.utils.js
deleted file mode 100644
index d413ed013e97..000000000000
--- a/shared/modules/conversion.utils.js
+++ /dev/null
@@ -1,452 +0,0 @@
-/**
- * Currency Conversion Utility
- * This utility function can be used for converting currency related values within metamask.
- * The caller should be able to pass it a value, along with information about the value's
- * numeric base, denomination and currency, and the desired numeric base, denomination and
- * currency. It should return a single value.
- *
- * @param {(number | string | BN)} value - The value to convert.
- * @param {object} [options] - Options to specify details of the conversion
- * @param {string} [options.fromCurrency = 'ETH' | 'USD'] - The currency of the passed value
- * @param {string} [options.toCurrency = 'ETH' | 'USD'] - The desired currency of the result
- * @param {string} [options.fromNumericBase = 'hex' | 'dec' | 'BN'] - The numeric basic of the passed value.
- * @param {string} [options.toNumericBase = 'hex' | 'dec' | 'BN'] - The desired numeric basic of the result.
- * @param {string} [options.fromDenomination = 'WEI'] - The denomination of the passed value
- * @param {string} [options.numberOfDecimals] - The desired number of decimals in the result
- * @param {string} [options.roundDown] - The desired number of decimals to round down to
- * @param {number} [options.conversionRate] - The rate to use to make the fromCurrency -> toCurrency conversion
- * @returns {(number | string | BN)}
- *
- * The utility passes value along with the options as a single object to the `converter` function.
- * `converter` conditional modifies the supplied `value` property, depending
- * on the accompanying options.
- */
-
-import BigNumber from 'bignumber.js';
-
-import { addHexPrefix, BN } from 'ethereumjs-util';
-import { ETH, WEI } from '../../ui/helpers/constants/common';
-
-import { stripHexPrefix } from './hexstring-utils';
-
-// Big Number Constants
-const BIG_NUMBER_WEI_MULTIPLIER = new BigNumber('1000000000000000000');
-const BIG_NUMBER_GWEI_MULTIPLIER = new BigNumber('1000000000');
-const BIG_NUMBER_ETH_MULTIPLIER = new BigNumber('1');
-
-// Setter Maps
-const toBigNumber = {
- hex: (n) => new BigNumber(stripHexPrefix(n), 16),
- dec: (n) => new BigNumber(String(n), 10),
- BN: (n) => new BigNumber(n.toString(16), 16),
-};
-const toNormalizedDenomination = {
- WEI: (bigNumber) => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER),
- GWEI: (bigNumber) => bigNumber.div(BIG_NUMBER_GWEI_MULTIPLIER),
- ETH: (bigNumber) => bigNumber.div(BIG_NUMBER_ETH_MULTIPLIER),
-};
-const toSpecifiedDenomination = {
- WEI: (bigNumber) => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).round(),
- GWEI: (bigNumber) => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).round(9),
- ETH: (bigNumber) => bigNumber.times(BIG_NUMBER_ETH_MULTIPLIER).round(9),
-};
-const baseChange = {
- hex: (n) => n.toString(16),
- dec: (n) => new BigNumber(n).toString(10),
- BN: (n) => new BN(n.toString(16)),
-};
-
-// Utility function for checking base types
-const isValidBase = (base) => {
- return Number.isInteger(base) && base > 1;
-};
-
-/**
- * Defines the base type of numeric value
- *
- * @typedef {('hex' | 'dec' | 'BN')} NumericBase
- */
-
-/**
- * Defines which type of denomination a value is in
- *
- * @typedef {('WEI' | 'GWEI' | 'ETH')} EthDenomination
- */
-
-/**
- * Utility method to convert a value between denominations, formats and currencies.
- *
- * @param {object} input
- * @param {string | BigNumber} input.value
- * @param {NumericBase} input.fromNumericBase
- * @param {EthDenomination} [input.fromDenomination]
- * @param {string} [input.fromCurrency]
- * @param {NumericBase} input.toNumericBase
- * @param {EthDenomination} [input.toDenomination]
- * @param {string} [input.toCurrency]
- * @param {number} [input.numberOfDecimals]
- * @param {number} [input.conversionRate]
- * @param {boolean} [input.invertConversionRate]
- * @param {string} [input.roundDown]
- */
-const converter = ({
- value,
- fromNumericBase,
- fromDenomination,
- fromCurrency,
- toNumericBase,
- toDenomination,
- toCurrency,
- numberOfDecimals,
- conversionRate,
- invertConversionRate,
- roundDown,
-}) => {
- let convertedValue = fromNumericBase
- ? toBigNumber[fromNumericBase](value)
- : value;
-
- if (fromDenomination) {
- convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
- }
-
- if (fromCurrency !== toCurrency) {
- if (conversionRate === null || conversionRate === undefined) {
- throw new Error(
- `Converting from ${fromCurrency} to ${toCurrency} requires a conversionRate, but one was not provided`,
- );
- }
- let rate = toBigNumber.dec(conversionRate);
- if (invertConversionRate) {
- rate = new BigNumber(1.0).div(conversionRate);
- }
- convertedValue = convertedValue.times(rate);
- }
-
- if (toDenomination) {
- convertedValue = toSpecifiedDenomination[toDenomination](convertedValue);
- }
-
- if (numberOfDecimals !== undefined && numberOfDecimals !== null) {
- convertedValue = convertedValue.round(
- numberOfDecimals,
- BigNumber.ROUND_HALF_DOWN,
- );
- }
-
- if (roundDown) {
- convertedValue = convertedValue.round(roundDown, BigNumber.ROUND_DOWN);
- }
-
- if (toNumericBase) {
- convertedValue = baseChange[toNumericBase](convertedValue);
- }
- return convertedValue;
-};
-
-const conversionUtil = (
- value,
- {
- fromCurrency = null,
- toCurrency = fromCurrency,
- fromNumericBase,
- toNumericBase,
- fromDenomination,
- toDenomination,
- numberOfDecimals,
- conversionRate,
- invertConversionRate,
- },
-) => {
- if (fromCurrency !== toCurrency && !conversionRate) {
- return 0;
- }
- return converter({
- fromCurrency,
- toCurrency,
- fromNumericBase,
- toNumericBase,
- fromDenomination,
- toDenomination,
- numberOfDecimals,
- conversionRate,
- invertConversionRate,
- value: value || '0',
- });
-};
-
-const getBigNumber = (value, base) => {
- if (!isValidBase(base)) {
- throw new Error('Must specify valid base');
- }
-
- // We don't include 'number' here, because BigNumber will throw if passed
- // a number primitive it considers unsafe.
- if (typeof value === 'string' || value instanceof BigNumber) {
- return new BigNumber(value, base);
- }
-
- return new BigNumber(String(value), base);
-};
-
-const addCurrencies = (a, b, options = {}) => {
- const { aBase, bBase, ...conversionOptions } = options;
-
- if (!isValidBase(aBase) || !isValidBase(bBase)) {
- throw new Error('Must specify valid aBase and bBase');
- }
-
- const value = getBigNumber(a, aBase).add(getBigNumber(b, bBase));
-
- return converter({
- value,
- ...conversionOptions,
- });
-};
-
-const subtractCurrencies = (a, b, options = {}) => {
- const { aBase, bBase, ...conversionOptions } = options;
-
- if (!isValidBase(aBase) || !isValidBase(bBase)) {
- throw new Error('Must specify valid aBase and bBase');
- }
-
- const value = getBigNumber(a, aBase).minus(getBigNumber(b, bBase));
-
- return converter({
- value,
- ...conversionOptions,
- });
-};
-
-const multiplyCurrencies = (a, b, options = {}) => {
- const { multiplicandBase, multiplierBase, ...conversionOptions } = options;
-
- if (!isValidBase(multiplicandBase) || !isValidBase(multiplierBase)) {
- throw new Error('Must specify valid multiplicandBase and multiplierBase');
- }
-
- const value = getBigNumber(a, multiplicandBase).times(
- getBigNumber(b, multiplierBase),
- );
-
- return converter({
- value,
- ...conversionOptions,
- });
-};
-
-const divideCurrencies = (a, b, options = {}) => {
- const { dividendBase, divisorBase, ...conversionOptions } = options;
-
- if (!isValidBase(dividendBase) || !isValidBase(divisorBase)) {
- throw new Error('Must specify valid dividendBase and divisorBase');
- }
-
- const value = getBigNumber(a, dividendBase).div(getBigNumber(b, divisorBase));
-
- return converter({
- value,
- ...conversionOptions,
- });
-};
-
-const conversionGreaterThan = ({ ...firstProps }, { ...secondProps }) => {
- const firstValue = converter({ ...firstProps });
- const secondValue = converter({ ...secondProps });
-
- return firstValue.gt(secondValue);
-};
-
-const conversionLessThan = ({ ...firstProps }, { ...secondProps }) => {
- const firstValue = converter({ ...firstProps });
- const secondValue = converter({ ...secondProps });
-
- return firstValue.lt(secondValue);
-};
-
-const conversionMax = ({ ...firstProps }, { ...secondProps }) => {
- const firstIsGreater = conversionGreaterThan(
- { ...firstProps },
- { ...secondProps },
- );
-
- return firstIsGreater ? firstProps.value : secondProps.value;
-};
-
-const conversionGTE = ({ ...firstProps }, { ...secondProps }) => {
- const firstValue = converter({ ...firstProps });
- const secondValue = converter({ ...secondProps });
- return firstValue.greaterThanOrEqualTo(secondValue);
-};
-
-const conversionLTE = ({ ...firstProps }, { ...secondProps }) => {
- const firstValue = converter({ ...firstProps });
- const secondValue = converter({ ...secondProps });
- return firstValue.lessThanOrEqualTo(secondValue);
-};
-
-const toNegative = (n, options = {}) => {
- return multiplyCurrencies(n, -1, options);
-};
-
-function decGWEIToHexWEI(decGWEI) {
- return conversionUtil(decGWEI, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- fromDenomination: 'GWEI',
- toDenomination: 'WEI',
- });
-}
-
-export function subtractHexes(aHexWEI, bHexWEI) {
- return subtractCurrencies(aHexWEI, bHexWEI, {
- aBase: 16,
- bBase: 16,
- toNumericBase: 'hex',
- numberOfDecimals: 6,
- });
-}
-
-export function addHexes(aHexWEI, bHexWEI) {
- return addCurrencies(aHexWEI, bHexWEI, {
- aBase: 16,
- bBase: 16,
- toNumericBase: 'hex',
- numberOfDecimals: 6,
- });
-}
-
-export function decWEIToDecETH(hexWEI) {
- return conversionUtil(hexWEI, {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- toDenomination: 'ETH',
- });
-}
-
-export function hexWEIToDecETH(hexWEI) {
- return conversionUtil(hexWEI, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- toDenomination: 'ETH',
- });
-}
-
-export function decEthToConvertedCurrency(
- ethTotal,
- convertedCurrency,
- conversionRate,
-) {
- return conversionUtil(ethTotal, {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- fromCurrency: 'ETH',
- toCurrency: convertedCurrency,
- numberOfDecimals: 2,
- conversionRate,
- });
-}
-
-export function getWeiHexFromDecimalValue({
- value,
- fromCurrency,
- conversionRate,
- fromDenomination,
- invertConversionRate,
-}) {
- return conversionUtil(value, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- toCurrency: ETH,
- fromCurrency,
- conversionRate,
- invertConversionRate,
- fromDenomination,
- toDenomination: WEI,
- });
-}
-
-/**
- * Converts a BN object to a hex string with a '0x' prefix
- *
- * @param {BN} inputBn - The BN to convert to a hex string
- * @returns {string} A '0x' prefixed hex string
- */
-export function bnToHex(inputBn) {
- return addHexPrefix(inputBn.toString(16));
-}
-
-export function getValueFromWeiHex({
- value,
- fromCurrency = ETH,
- toCurrency,
- conversionRate,
- numberOfDecimals,
- toDenomination,
-}) {
- return conversionUtil(value, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromCurrency,
- toCurrency,
- numberOfDecimals,
- fromDenomination: WEI,
- toDenomination,
- conversionRate,
- });
-}
-
-export function sumHexes(...args) {
- const total = args.reduce((acc, hexAmount) => {
- return addCurrencies(acc, hexAmount, {
- toNumericBase: 'hex',
- aBase: 16,
- bBase: 16,
- });
- });
-
- return addHexPrefix(total);
-}
-
-export function hexWEIToDecGWEI(decGWEI) {
- return conversionUtil(decGWEI, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- toDenomination: 'GWEI',
- });
-}
-
-export function decimalToHex(decimal) {
- return conversionUtil(decimal, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- });
-}
-
-export function hexToDecimal(hexValue) {
- return conversionUtil(hexValue, {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- });
-}
-
-export {
- conversionUtil,
- addCurrencies,
- multiplyCurrencies,
- conversionGreaterThan,
- conversionLessThan,
- conversionGTE,
- conversionLTE,
- conversionMax,
- toNegative,
- subtractCurrencies,
- decGWEIToHexWEI,
- toBigNumber,
- toNormalizedDenomination,
- divideCurrencies,
-};
diff --git a/shared/modules/conversion.utils.test.js b/shared/modules/conversion.utils.test.js
index c6b064a94f8e..c3f2b6a92bad 100644
--- a/shared/modules/conversion.utils.test.js
+++ b/shared/modules/conversion.utils.test.js
@@ -1,212 +1,11 @@
-import BigNumber from 'bignumber.js';
-import { ETH } from '../../ui/helpers/constants/common';
+import { EtherDenomination } from '../constants/common';
import {
- addCurrencies,
- conversionUtil,
decWEIToDecETH,
- divideCurrencies,
getValueFromWeiHex,
getWeiHexFromDecimalValue,
} from './conversion.utils';
describe('conversion utils', () => {
- describe('addCurrencies()', () => {
- it('add whole numbers', () => {
- const result = addCurrencies(3, 9, {
- aBase: 10,
- bBase: 10,
- });
- expect(result.toNumber()).toStrictEqual(12);
- });
-
- it('add decimals', () => {
- const result = addCurrencies(1.3, 1.9, {
- aBase: 10,
- bBase: 10,
- });
- expect(result.toNumber()).toStrictEqual(3.2);
- });
-
- it('add repeating decimals', () => {
- const result = addCurrencies(1 / 3, 1 / 9, {
- aBase: 10,
- bBase: 10,
- });
- expect(result.toNumber()).toStrictEqual(0.4444444444444444);
- });
- });
-
- describe('conversionUtil', () => {
- it('returns expected types', () => {
- const conv1 = conversionUtil(1000000000000000000, {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- });
- const conv2 = conversionUtil(1, {
- fromNumericBase: 'dec',
- fromDenomination: 'ETH',
- toDenomination: 'WEI',
- });
- expect(typeof conv1 === 'string').toStrictEqual(true);
- expect(conv2 instanceof BigNumber).toStrictEqual(true);
- });
- it('converts from dec to hex', () => {
- expect(
- conversionUtil('1000000000000000000', {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- }),
- ).toStrictEqual('de0b6b3a7640000');
- expect(
- conversionUtil('1500000000000000000', {
- fromNumericBase: 'dec',
- toNumericBase: 'hex',
- }),
- ).toStrictEqual('14d1120d7b160000');
- });
- it('converts hex formatted numbers to dec', () => {
- expect(
- conversionUtil('0xde0b6b3a7640000', {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- }),
- ).toStrictEqual('1000000000000000000');
- expect(
- conversionUtil('0x14d1120d7b160000', {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- }),
- ).toStrictEqual('1500000000000000000');
- });
- it('converts WEI to ETH', () => {
- expect(
- conversionUtil('0xde0b6b3a7640000', {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- toDenomination: 'ETH',
- }),
- ).toStrictEqual('1');
- expect(
- conversionUtil('0x14d1120d7b160000', {
- fromNumericBase: 'hex',
- toNumericBase: 'dec',
- fromDenomination: 'WEI',
- toDenomination: 'ETH',
- }),
- ).toStrictEqual('1.5');
- });
- it('converts ETH to WEI', () => {
- expect(
- conversionUtil('1', {
- fromNumericBase: 'dec',
- fromDenomination: 'ETH',
- toDenomination: 'WEI',
- }).toNumber(),
- ).toStrictEqual(1000000000000000000);
- expect(
- conversionUtil('1.5', {
- fromNumericBase: 'dec',
- fromDenomination: 'ETH',
- toDenomination: 'WEI',
- }).toNumber(),
- ).toStrictEqual(1500000000000000000);
- });
- it('converts ETH to GWEI', () => {
- expect(
- conversionUtil('1', {
- fromNumericBase: 'dec',
- fromDenomination: 'ETH',
- toDenomination: 'GWEI',
- }).toNumber(),
- ).toStrictEqual(1000000000);
- expect(
- conversionUtil('1.5', {
- fromNumericBase: 'dec',
- fromDenomination: 'ETH',
- toDenomination: 'GWEI',
- }).toNumber(),
- ).toStrictEqual(1500000000);
- });
- it('converts ETH to USD', () => {
- expect(
- conversionUtil('1', {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- toCurrency: 'usd',
- conversionRate: 468.58,
- numberOfDecimals: 2,
- }),
- ).toStrictEqual('468.58');
- expect(
- conversionUtil('1.5', {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- toCurrency: 'usd',
- conversionRate: 468.58,
- numberOfDecimals: 2,
- }),
- ).toStrictEqual('702.87');
- });
- it('converts USD to ETH', () => {
- expect(
- conversionUtil('468.58', {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- toCurrency: 'usd',
- conversionRate: 468.58,
- numberOfDecimals: 2,
- invertConversionRate: true,
- }),
- ).toStrictEqual('1');
- expect(
- conversionUtil('702.87', {
- fromNumericBase: 'dec',
- toNumericBase: 'dec',
- toCurrency: 'usd',
- conversionRate: 468.58,
- numberOfDecimals: 2,
- invertConversionRate: true,
- }),
- ).toStrictEqual('1.5');
- });
- });
-
- describe('divideCurrencies()', () => {
- it('should correctly divide decimal values', () => {
- const result = divideCurrencies(9, 3, {
- dividendBase: 10,
- divisorBase: 10,
- });
- expect(result.toNumber()).toStrictEqual(3);
- });
-
- it('should correctly divide hexadecimal values', () => {
- const result = divideCurrencies(1000, 0xa, {
- dividendBase: 16,
- divisorBase: 16,
- });
- expect(result.toNumber()).toStrictEqual(0x100);
- });
-
- it('should correctly divide hexadecimal value from decimal value', () => {
- const result = divideCurrencies(0x3e8, 0xa, {
- dividendBase: 16,
- divisorBase: 16,
- });
- expect(result.toNumber()).toStrictEqual(0x100);
- });
-
- it('should throw error for wrong base value', () => {
- expect(() => {
- divideCurrencies(0x3e8, 0xa, {
- dividendBase: 10.5,
- divisorBase: 7,
- });
- }).toThrow('Must specify valid dividendBase and divisorBase');
- });
- });
-
describe('decWEIToDecETH', () => {
it('converts 10000000000000 WEI to ETH', () => {
const ethDec = decWEIToDecETH('10000000000000');
@@ -223,11 +22,18 @@ describe('conversion utils', () => {
it('should correctly convert 0 in ETH', () => {
const weiValue = getWeiHexFromDecimalValue({
value: '0',
- fromCurrency: ETH,
- fromDenomination: ETH,
+ fromDenomination: EtherDenomination.ETH,
});
expect(weiValue).toStrictEqual('0');
});
+
+ it('should correctly convert 10 in ETH to 8ac7230489e80000 (10000000000000000000) wei', () => {
+ const weiValue = getWeiHexFromDecimalValue({
+ value: '10',
+ fromDenomination: EtherDenomination.ETH,
+ });
+ expect(weiValue).toStrictEqual('8ac7230489e80000');
+ });
});
describe('getValueFromWeiHex', () => {
@@ -235,7 +41,6 @@ describe('conversion utils', () => {
const ethTransactionAmount = getValueFromWeiHex({
value: '0xde0b6b3a7640000',
toCurrency: 'ETH',
- conversionRate: 468.58,
numberOfDecimals: 6,
});
diff --git a/shared/modules/conversion.utils.ts b/shared/modules/conversion.utils.ts
new file mode 100644
index 000000000000..e2466bcabb1a
--- /dev/null
+++ b/shared/modules/conversion.utils.ts
@@ -0,0 +1,172 @@
+import { BigNumber } from 'bignumber.js';
+
+import { addHexPrefix, BN } from 'ethereumjs-util';
+import { EtherDenomination } from '../constants/common';
+import { Numeric, NumericValue } from './Numeric';
+
+export function decGWEIToHexWEI(decGWEI: number) {
+ return new Numeric(decGWEI, 10, EtherDenomination.GWEI)
+ .toBase(16)
+ .toDenomination(EtherDenomination.WEI)
+ .toString();
+}
+
+export function subtractHexes(aHexWEI: string, bHexWEI: string) {
+ return new Numeric(aHexWEI, 16)
+ .minus(new Numeric(bHexWEI, 16))
+ .round(6, BigNumber.ROUND_HALF_DOWN)
+ .toString();
+}
+
+export function addHexes(aHexWEI: string, bHexWEI: string) {
+ return new Numeric(aHexWEI, 16)
+ .add(new Numeric(bHexWEI, 16))
+ .round(6, BigNumber.ROUND_HALF_DOWN)
+ .toString();
+}
+
+export function decWEIToDecETH(decWEI: string) {
+ return new Numeric(decWEI, 10, EtherDenomination.WEI)
+ .toDenomination(EtherDenomination.ETH)
+ .toString();
+}
+
+export function hexWEIToDecETH(hexWEI: string) {
+ return new Numeric(hexWEI, 16, EtherDenomination.WEI)
+ .toDenomination(EtherDenomination.ETH)
+ .toBase(10)
+ .toString();
+}
+
+export function decEthToConvertedCurrency(
+ ethTotal: NumericValue,
+ convertedCurrency?: string,
+ conversionRate?: number,
+) {
+ let numeric = new Numeric(ethTotal, 10, EtherDenomination.ETH);
+
+ if (convertedCurrency !== EtherDenomination.ETH) {
+ numeric = numeric.applyConversionRate(conversionRate);
+ }
+
+ return numeric.round(2);
+}
+
+export function getWeiHexFromDecimalValue({
+ value,
+ conversionRate = 1,
+ fromDenomination,
+ fromCurrency,
+ invertConversionRate = false,
+}: {
+ value: NumericValue;
+ conversionRate?: number;
+ fromDenomination?: EtherDenomination;
+ fromCurrency?: string;
+ invertConversionRate?: boolean;
+}) {
+ let numeric = new Numeric(value, 10, fromDenomination);
+ if (fromCurrency !== EtherDenomination.ETH) {
+ numeric = numeric.applyConversionRate(conversionRate, invertConversionRate);
+ }
+ return numeric.toBase(16).toDenomination(EtherDenomination.WEI).toString();
+}
+
+/**
+ * Converts a BN object to a hex string with a '0x' prefix
+ *
+ * @param inputBn - The BN to convert to a hex string
+ * @returns A '0x' prefixed hex string
+ */
+export function bnToHex(inputBn: BN) {
+ return addHexPrefix(inputBn.toString(16));
+}
+
+export function getEthConversionFromWeiHex({
+ value,
+ fromCurrency = EtherDenomination.ETH,
+ conversionRate,
+ numberOfDecimals = 6,
+}: {
+ value: NumericValue;
+ conversionRate?: number;
+ fromCurrency?: EtherDenomination | string;
+ numberOfDecimals?: number;
+}) {
+ const denominations = [
+ EtherDenomination.ETH,
+ EtherDenomination.GWEI,
+ EtherDenomination.WEI,
+ ];
+
+ let nonZeroDenomination;
+
+ for (let i = 0; i < denominations.length; i++) {
+ const convertedValue = getValueFromWeiHex({
+ value,
+ conversionRate,
+ fromCurrency,
+ toCurrency: fromCurrency,
+ numberOfDecimals,
+ toDenomination: denominations[i],
+ });
+
+ if (convertedValue !== '0' || i === denominations.length - 1) {
+ nonZeroDenomination = `${convertedValue} ${denominations[i]}`;
+ break;
+ }
+ }
+
+ return nonZeroDenomination;
+}
+
+export function getValueFromWeiHex({
+ value,
+ fromCurrency = EtherDenomination.ETH,
+ toCurrency,
+ conversionRate,
+ numberOfDecimals,
+ toDenomination = EtherDenomination.ETH,
+}: {
+ value: NumericValue;
+ fromCurrency?: EtherDenomination | string;
+ toCurrency?: EtherDenomination | string;
+ conversionRate?: number;
+ numberOfDecimals?: number;
+ toDenomination?: EtherDenomination;
+}) {
+ let numeric = new Numeric(value, 16, EtherDenomination.WEI);
+ if (fromCurrency !== toCurrency) {
+ numeric = numeric.applyConversionRate(conversionRate);
+ }
+ return numeric
+ .toBase(10)
+ .toDenomination(toDenomination)
+ .round(numberOfDecimals, BigNumber.ROUND_HALF_DOWN)
+ .toString();
+}
+
+export function sumHexes(first: string, ...args: string[]) {
+ const firstValue = new Numeric(first, 16);
+ const total = args.reduce(
+ (acc, hexAmount) => acc.add(new Numeric(hexAmount, 16)),
+ firstValue,
+ );
+
+ return total.toPrefixedHexString();
+}
+
+export function hexWEIToDecGWEI(value: number | string | BigNumber | BN) {
+ return new Numeric(value, 16, EtherDenomination.WEI)
+ .toBase(10)
+ .toDenomination(EtherDenomination.GWEI)
+ .toString();
+}
+
+export function decimalToHex(decimal: number | string | BigNumber | BN) {
+ return new Numeric(decimal, 10).toBase(16).toString();
+}
+
+export function hexToDecimal(hexValue: number | string | BigNumber | BN) {
+ return new Numeric(hexValue, 16).toBase(10).toString();
+}
From c35b9dea64adc4ccc3897998fa01f35db1de9b95 Mon Sep 17 00:00:00 2001
From: weizman
Date: Tue, 24 Jan 2023 21:24:01 +0200
Subject: [PATCH 14/21] remove duplicate comment line (#17381)
---
development/build/index.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/development/build/index.js b/development/build/index.js
index 73a2d2d21b27..304a621233bb 100755
--- a/development/build/index.js
+++ b/development/build/index.js
@@ -73,7 +73,6 @@ async function defineAndRunBuildTasks() {
version,
} = await parseArgv();
- // build lavamoat runtime file
// build lavamoat runtime file
await lavapack.buildRuntime({
scuttleGlobalThis: true,
From 8a6bf4d1c90d494a890ed54d23f67a73c94a16d6 Mon Sep 17 00:00:00 2001
From: Nidhi Kumari
Date: Wed, 25 Jan 2023 09:24:13 +0530
Subject: [PATCH 15/21] Nit fixes for story-test integration (#17344)
* nit fix for story-test integration
* updated package.jsson
---
development/highlights/storybook.js | 2 ++
package.json | 4 ++--
ui/components/app/app-header/app-header.stories.js | 1 -
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/development/highlights/storybook.js b/development/highlights/storybook.js
index 800a4accb7a0..357faf13abb6 100644
--- a/development/highlights/storybook.js
+++ b/development/highlights/storybook.js
@@ -75,6 +75,8 @@ function urlForStoryFile(filename, artifactBase) {
}
/**
+ * Get the ID for a story file.
+ *
* @param {fileName} string - The fileName to get the story id.
* @returns The id of the story.
*/
diff --git a/package.json b/package.json
index b2eab479c6c9..b756c9929db5 100644
--- a/package.json
+++ b/package.json
@@ -309,7 +309,6 @@
"nonce-tracker": "^1.0.0",
"obj-multiplex": "^1.0.0",
"pify": "^5.0.0",
- "playwright": "^1.29.2",
"promise-to-callback": "^1.0.0",
"prop-types": "^15.6.1",
"pubnub": "4.27.3",
@@ -344,7 +343,6 @@
"unicode-confusables": "^0.1.1",
"uuid": "^8.3.2",
"valid-url": "^1.0.9",
- "wait-on": "^7.0.1",
"web3-stream-provider": "^4.0.0",
"zxcvbn": "^4.4.2"
},
@@ -484,6 +482,7 @@
"nock": "^13.2.9",
"node-fetch": "^2.6.1",
"nyc": "^15.0.0",
+ "playwright": "^1.29.2",
"polyfill-crypto.getrandomvalues": "^1.0.0",
"prettier": "^2.7.1",
"prettier-plugin-sort-json": "^1.0.0",
@@ -519,6 +518,7 @@
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.1",
+ "wait-on": "^7.0.1",
"watchify": "^4.0.0",
"webextension-polyfill": "^0.8.0",
"webpack": "^5.75.0",
diff --git a/ui/components/app/app-header/app-header.stories.js b/ui/components/app/app-header/app-header.stories.js
index ab2700dcca66..b2b75ae0b6cc 100644
--- a/ui/components/app/app-header/app-header.stories.js
+++ b/ui/components/app/app-header/app-header.stories.js
@@ -1,7 +1,6 @@
import React from 'react';
import AppHeader from '.';
-// eslint-disable-next-line import/no-anonymous-default-export
export default {
title: 'Components/App/AppHeader',
From 47f6d46bb39f3070c1fbb3f792067ac62f09e431 Mon Sep 17 00:00:00 2001
From: ryanml
Date: Wed, 25 Jan 2023 07:08:35 -0700
Subject: [PATCH 16/21] Add alt text for NFT images (#17284)
---
.../collectible-details.js | 3 ++
.../collectibles-items/collectibles-items.js | 4 +++
ui/helpers/utils/collectibles.js | 3 ++
ui/helpers/utils/collectibles.test.js | 31 +++++++++++++++++++
4 files changed, 41 insertions(+)
create mode 100644 ui/helpers/utils/collectibles.js
create mode 100644 ui/helpers/utils/collectibles.test.js
diff --git a/ui/components/app/collectible-details/collectible-details.js b/ui/components/app/collectible-details/collectible-details.js
index 0c198a58c970..87159ee94901 100644
--- a/ui/components/app/collectible-details/collectible-details.js
+++ b/ui/components/app/collectible-details/collectible-details.js
@@ -20,6 +20,7 @@ import {
} from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { getAssetImageURL, shortenAddress } from '../../../helpers/utils/util';
+import { getCollectibleImageAlt } from '../../../helpers/utils/collectibles';
import {
getCurrentChainId,
getIpfsGateway,
@@ -82,6 +83,7 @@ export default function CollectibleDetails({ collectible }) {
imageOriginal ?? image,
ipfsGateway,
);
+ const collectibleImageAlt = getCollectibleImageAlt(collectible);
const isDataURI = collectibleImageURL.startsWith('data:');
const onRemove = () => {
@@ -178,6 +180,7 @@ export default function CollectibleDetails({ collectible }) {
) : (
diff --git a/ui/components/app/collectibles-items/collectibles-items.js b/ui/components/app/collectibles-items/collectibles-items.js
index a4e10b40d94d..a1eaf999bb13 100644
--- a/ui/components/app/collectibles-items/collectibles-items.js
+++ b/ui/components/app/collectibles-items/collectibles-items.js
@@ -25,6 +25,7 @@ import {
} from '../../../selectors';
import { ASSET_ROUTE } from '../../../helpers/constants/routes';
import { getAssetImageURL } from '../../../helpers/utils/util';
+import { getCollectibleImageAlt } from '../../../helpers/utils/collectibles';
import { updateCollectibleDropDownState } from '../../../store/actions';
import { usePrevious } from '../../../hooks/usePrevious';
import { getCollectiblesDropdownState } from '../../../ducks/metamask/metamask';
@@ -90,6 +91,7 @@ export default function CollectiblesItems({
if (collectionImage) {
return (
@@ -175,6 +177,7 @@ export default function CollectiblesItems({
const { image, address, tokenId, backgroundColor, name } =
collectible;
const collectibleImage = getAssetImageURL(image, ipfsGateway);
+ const collectibleImageAlt = getCollectibleImageAlt(collectible);
const handleImageClick = () =>
history.push(`${ASSET_ROUTE}/${address}/${tokenId}`);
@@ -200,6 +203,7 @@ export default function CollectiblesItems({
) : (
diff --git a/ui/helpers/utils/collectibles.js b/ui/helpers/utils/collectibles.js
new file mode 100644
index 000000000000..e08fea1f4f15
--- /dev/null
+++ b/ui/helpers/utils/collectibles.js
@@ -0,0 +1,3 @@
+export const getCollectibleImageAlt = ({ name, tokenId, description }) => {
+ return description ?? `${name} ${tokenId}`;
+};
diff --git a/ui/helpers/utils/collectibles.test.js b/ui/helpers/utils/collectibles.test.js
new file mode 100644
index 000000000000..0e224100cf57
--- /dev/null
+++ b/ui/helpers/utils/collectibles.test.js
@@ -0,0 +1,31 @@
+import { getCollectibleImageAlt } from './collectibles';
+
+describe('Collectibles Utils', () => {
+ describe('getCollectibleImageAlt', () => {
+ it('returns the description attribute when it is available', () => {
+ expect(
+ getCollectibleImageAlt({
+ name: 'Cool NFT',
+ tokenId: '555',
+ description: 'This is a really cool NFT',
+ }),
+ ).toBe('This is a really cool NFT');
+ });
+
+ it('returns the formatted name and tokenId attributes when a description is not present', () => {
+ expect(
+ getCollectibleImageAlt({
+ name: 'Cool NFT',
+ tokenId: '555',
+ description: null,
+ }),
+ ).toBe('Cool NFT 555');
+ expect(
+ getCollectibleImageAlt({
+ name: 'Cool NFT',
+ tokenId: '555',
+ }),
+ ).toBe('Cool NFT 555');
+ });
+ });
+});
From 129a06cc124ae7cb5e3e362ffa95561a6fbd914b Mon Sep 17 00:00:00 2001
From: Niranjana Binoy <43930900+NiranjanaBinoy@users.noreply.github.com>
Date: Wed, 25 Jan 2023 10:15:58 -0500
Subject: [PATCH 17/21] Copy update on Transaction breakdown for ApproveToken
(#17296)
---
app/_locales/de/messages.json | 7 -------
app/_locales/el/messages.json | 7 -------
app/_locales/en/messages.json | 10 +++++-----
app/_locales/es/messages.json | 7 -------
app/_locales/es_419/messages.json | 7 -------
app/_locales/fr/messages.json | 7 -------
app/_locales/hi/messages.json | 7 -------
app/_locales/id/messages.json | 7 -------
app/_locales/it/messages.json | 7 -------
app/_locales/ja/messages.json | 7 -------
app/_locales/ko/messages.json | 7 -------
app/_locales/ph/messages.json | 7 -------
app/_locales/pt/messages.json | 7 -------
app/_locales/pt_BR/messages.json | 7 -------
app/_locales/ru/messages.json | 7 -------
app/_locales/tl/messages.json | 7 -------
app/_locales/tr/messages.json | 7 -------
app/_locales/vi/messages.json | 7 -------
app/_locales/zh_CN/messages.json | 7 -------
app/_locales/zh_TW/messages.json | 7 -------
test/e2e/tests/collectibles.spec.js | 2 +-
test/e2e/tests/custom-token-add-approve.spec.js | 16 ++++++++--------
.../transaction-breakdown.component.js | 2 +-
ui/hooks/useTransactionDisplayData.js | 4 +++-
24 files changed, 18 insertions(+), 149 deletions(-)
diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json
index a9e0f83f5eb5..33529f7833f0 100644
--- a/app/_locales/de/messages.json
+++ b/app/_locales/de/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Genehmigen"
},
- "approveSpendLimit": {
- "message": "$1 Ausgabelimit genehmigen",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Dies gestattet es Dritten, ohne weitere Benachrichtigung auf die folgenden NFTs zuzugreifen und diese zu übertragen, bis Sie dieses Zugriffsrecht widerrufen."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Diese Transaktion beschleunigen"
},
- "spendLimitAmount": {
- "message": "Ausgabelimitbetrag"
- },
"spendLimitInsufficient": {
"message": "Ausgabelimit unzureichend"
},
diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json
index 3f197f16800c..1ee944aa8213 100644
--- a/app/_locales/el/messages.json
+++ b/app/_locales/el/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Έγκριση"
},
- "approveSpendLimit": {
- "message": "Έγκριση ορίου δαπανών $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Αυτό επιτρέπει σε τρίτα μέρη να έχουν πρόσβαση και να μεταφέρουν τα ακόλουθα NFT χωρίς περαιτέρω ειδοποίηση μέχρι να ανακαλέσετε την πρόσβασή τους."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Επιτάχυνση αυτής της συναλλαγής"
},
- "spendLimitAmount": {
- "message": "Ποσό ορίου δαπανών"
- },
"spendLimitInsufficient": {
"message": "Ανεπαρκές όριο δαπανών"
},
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index db771ad38aaf..be6317ea6170 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -370,8 +370,8 @@
"approveButtonText": {
"message": "Approve"
},
- "approveSpendLimit": {
- "message": "Approve $1 spend limit",
+ "approveSpendingCap": {
+ "message": "Approve $1 spending cap",
"description": "The token symbol that is being approved"
},
"approveTokenDescription": {
@@ -3473,9 +3473,6 @@
"speedUpTransaction": {
"message": "Speed up this transaction"
},
- "spendLimitAmount": {
- "message": "Spend limit amount"
- },
"spendLimitInsufficient": {
"message": "Spend limit insufficient"
},
@@ -3492,6 +3489,9 @@
"spendLimitTooLarge": {
"message": "Spend limit too large"
},
+ "spendingCap": {
+ "message": "Spending cap"
+ },
"spendingCapError": {
"message": "Error: Enter numbers only"
},
diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json
index 981790fb6492..a76091764ec0 100644
--- a/app/_locales/es/messages.json
+++ b/app/_locales/es/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Aprobar"
},
- "approveSpendLimit": {
- "message": "Aprobar límite de gastos de $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Esto permite que un tercero acceda y transfiera los siguientes NFT sin previo aviso hasta que usted revoque su acceso."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Acelerar esta transacción"
},
- "spendLimitAmount": {
- "message": "Monto de límite de gastos"
- },
"spendLimitInsufficient": {
"message": "Límite de gastos insuficiente"
},
diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json
index 3ef2f63bca3a..ce5fa117e559 100644
--- a/app/_locales/es_419/messages.json
+++ b/app/_locales/es_419/messages.json
@@ -226,10 +226,6 @@
"approveButtonText": {
"message": "Aprobar"
},
- "approveSpendLimit": {
- "message": "Aprobar límite de gastos de $1",
- "description": "The token symbol that is being approved"
- },
"approved": {
"message": "Aprobado"
},
@@ -2360,9 +2356,6 @@
"speedUpTransaction": {
"message": "Acelerar esta transacción"
},
- "spendLimitAmount": {
- "message": "Monto de límite de gastos"
- },
"spendLimitInsufficient": {
"message": "Límite de gastos insuficiente"
},
diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json
index 8bf8d486acb7..3d78096ce89d 100644
--- a/app/_locales/fr/messages.json
+++ b/app/_locales/fr/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Approuver"
},
- "approveSpendLimit": {
- "message": "Approuver la limite de dépenses de $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Tant que vous n’aurez pas révoqué cette autorisation, l’autre partie pourra accéder à votre portefeuille et transférer sans préavis les NFT suivants."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Accélérez cette transaction"
},
- "spendLimitAmount": {
- "message": "Montant limite de dépenses"
- },
"spendLimitInsufficient": {
"message": "Limite de dépenses insuffisante"
},
diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json
index b2d154dd10e1..f106f73b65ca 100644
--- a/app/_locales/hi/messages.json
+++ b/app/_locales/hi/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "अनुमोदित करें"
},
- "approveSpendLimit": {
- "message": "$1 खर्च सीमा अनुमोदित करें",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "यह किसी तीसरे पक्ष को बिना किसी नोटिस के निम्नलिखित NFTs को ऐक्सेस करने और स्थानांतरित करने की अनुमति देता है जब तक कि आप इसकी ऐक्सेस को रद्द नहीं कर देते।"
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "इस लेनदेन को गति दें"
},
- "spendLimitAmount": {
- "message": "खर्च सीमा राशि"
- },
"spendLimitInsufficient": {
"message": "खर्च सीमा अपर्याप्त है"
},
diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json
index 1fabd1a343bf..912f8b1d9e4b 100644
--- a/app/_locales/id/messages.json
+++ b/app/_locales/id/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Setujui"
},
- "approveSpendLimit": {
- "message": "Setujui batas penggunaan $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Hal ini memungkinkan pihak ketiga untuk mengakses dan mentransfer NFT berikut tanpa pemberitahuan lebih lanjut sampai Anda mencabut aksesnya."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Percepat transaksi ini"
},
- "spendLimitAmount": {
- "message": "Jumlah batas penggunaan"
- },
"spendLimitInsufficient": {
"message": "Batas penggunaan tidak mencukupi"
},
diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json
index 6fc451f0347a..f59741a28501 100644
--- a/app/_locales/it/messages.json
+++ b/app/_locales/it/messages.json
@@ -305,10 +305,6 @@
"approveButtonText": {
"message": "Approva"
},
- "approveSpendLimit": {
- "message": "Approva limite di spesa per $1",
- "description": "The token symbol that is being approved"
- },
"approved": {
"message": "Approvato"
},
@@ -1753,9 +1749,6 @@
"speedUpTransaction": {
"message": "Accelera questa transazione"
},
- "spendLimitAmount": {
- "message": "Limite di spesa"
- },
"spendLimitInsufficient": {
"message": "Limite di spesa insufficiente"
},
diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json
index f06f587de45b..406ead8f08b8 100644
--- a/app/_locales/ja/messages.json
+++ b/app/_locales/ja/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "承認"
},
- "approveSpendLimit": {
- "message": "$1使用限度額の承認",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "これにより、アクセス許可を取り消すまで、第三者が今後通知なしに次の NFT にアクセスし、転送できるようになります。"
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "このトランザクションをスピードアップ"
},
- "spendLimitAmount": {
- "message": "使用限度額"
- },
"spendLimitInsufficient": {
"message": "使用限度額が十分ではありません"
},
diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json
index b9319686d4a9..0fe204a3cf13 100644
--- a/app/_locales/ko/messages.json
+++ b/app/_locales/ko/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "승인"
},
- "approveSpendLimit": {
- "message": "$1 지출 한도 승인",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "이렇게 하면 사용자가 액세스를 취소할 때까지 제삼자가 가 통지 없이 다음과 같은 NFT에 액세스하고 이를 전송할 수 있습니다."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "이 거래 가속화"
},
- "spendLimitAmount": {
- "message": "지출 한도 금액"
- },
"spendLimitInsufficient": {
"message": "지출 한도 부족"
},
diff --git a/app/_locales/ph/messages.json b/app/_locales/ph/messages.json
index 3f5ac76b15ca..daac6088331e 100644
--- a/app/_locales/ph/messages.json
+++ b/app/_locales/ph/messages.json
@@ -134,10 +134,6 @@
"approveButtonText": {
"message": "Aprubahan"
},
- "approveSpendLimit": {
- "message": "Aprubahan ang limitasyon sa paggastos na $1",
- "description": "The token symbol that is being approved"
- },
"approved": {
"message": "Inaprubahan"
},
@@ -1555,9 +1551,6 @@
"speedUpTransaction": {
"message": "Pabilisin ang transaksyong ito"
},
- "spendLimitAmount": {
- "message": "Halaga ng limitasyon sa paggastos"
- },
"spendLimitInsufficient": {
"message": "Hindi sapat ang limitasyon sa paggastos"
},
diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json
index 601d77dd3bf3..e964f1498606 100644
--- a/app/_locales/pt/messages.json
+++ b/app/_locales/pt/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Aprovar"
},
- "approveSpendLimit": {
- "message": "Aprovar limite de gastos de $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Isso permite que terceiros acessem e transfiram os seguintes NFTs sem aviso prévio até que você revogue o acesso."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Acelerar essa transação"
},
- "spendLimitAmount": {
- "message": "Valor do limite de gastos"
- },
"spendLimitInsufficient": {
"message": "Limite de gastos insuficiente"
},
diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json
index 38d4622bff47..d1085d8ba661 100644
--- a/app/_locales/pt_BR/messages.json
+++ b/app/_locales/pt_BR/messages.json
@@ -226,10 +226,6 @@
"approveButtonText": {
"message": "Aprovar"
},
- "approveSpendLimit": {
- "message": "Aprovar limite de gastos de $1",
- "description": "The token symbol that is being approved"
- },
"approved": {
"message": "Aprovado"
},
@@ -2360,9 +2356,6 @@
"speedUpTransaction": {
"message": "Acelerar essa transação"
},
- "spendLimitAmount": {
- "message": "Valor do limite de gastos"
- },
"spendLimitInsufficient": {
"message": "Limite de gastos insuficiente"
},
diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json
index 3e74814de283..91a5d6166e1c 100644
--- a/app/_locales/ru/messages.json
+++ b/app/_locales/ru/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Одобрить"
},
- "approveSpendLimit": {
- "message": "Одобрить предел расходов $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Это позволяет третьей стороне получать доступ и передавать следующие NFT без дополнительного уведомления, пока вы не отзовете ее доступ."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Ускорить эту транзакцию"
},
- "spendLimitAmount": {
- "message": "Сумма лимита расходов"
- },
"spendLimitInsufficient": {
"message": "Недостаточный лимит расходов"
},
diff --git a/app/_locales/tl/messages.json b/app/_locales/tl/messages.json
index 850af882bd5f..71ec1a5afd92 100644
--- a/app/_locales/tl/messages.json
+++ b/app/_locales/tl/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Aprubahan"
},
- "approveSpendLimit": {
- "message": "Aprubahan ang limitasyon sa paggastos na $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Nagbibigay-daan ito sa third party na i-access at ilipat ang mga sumusunod na NFT nang walang karagdagang abiso hanggang sa bawiin mo ang pag-access nito."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Pabilisin ang transaksyong ito"
},
- "spendLimitAmount": {
- "message": "Halaga ng limitasyon sa paggastos"
- },
"spendLimitInsufficient": {
"message": "Hindi sapat ang limitasyon sa paggastos"
},
diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json
index cd1749176d98..d06f1ef6b112 100644
--- a/app/_locales/tr/messages.json
+++ b/app/_locales/tr/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Onayla"
},
- "approveSpendLimit": {
- "message": "$1 harcama limitini onayla",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Üçüncü bir tarafın, siz bu erişimi iptal edene kadar başka bildirim yapılmaksızın aşağıdaki NFT'lere erişim sağlamasına ve onları transfer edebilmesine izin verir."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Bu işlemi hızlandır"
},
- "spendLimitAmount": {
- "message": "Harcama limiti tutarı"
- },
"spendLimitInsufficient": {
"message": "Harcama limiti yetersiz"
},
diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json
index bf3aa2dc60d3..d9f953807e64 100644
--- a/app/_locales/vi/messages.json
+++ b/app/_locales/vi/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "Phê duyệt"
},
- "approveSpendLimit": {
- "message": "Phê duyệt giới hạn chi tiêu $1",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "Điều này cho phép bên thứ ba được quyền truy cập và chuyển các NFT sau đây mà không cần thông báo thêm cho đến khi bạn thu hồi quyền truy cập của họ."
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "Tăng tốc giao dịch này"
},
- "spendLimitAmount": {
- "message": "Khoản tiền giới hạn chi tiêu"
- },
"spendLimitInsufficient": {
"message": "Giới hạn chi tiêu không đủ"
},
diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json
index 43b618451b04..3f4a42c59b9c 100644
--- a/app/_locales/zh_CN/messages.json
+++ b/app/_locales/zh_CN/messages.json
@@ -370,10 +370,6 @@
"approveButtonText": {
"message": "批准"
},
- "approveSpendLimit": {
- "message": "批准 $1 消费限额",
- "description": "The token symbol that is being approved"
- },
"approveTokenDescription": {
"message": "这允许第三方访问和转移以下 NFT,而无需另行通知,直到您撤销其访问权限。"
},
@@ -3442,9 +3438,6 @@
"speedUpTransaction": {
"message": "加速该交易"
},
- "spendLimitAmount": {
- "message": "消费限额"
- },
"spendLimitInsufficient": {
"message": "消费限额不足"
},
diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json
index 05a5c3ceff07..30f4d1b5a241 100644
--- a/app/_locales/zh_TW/messages.json
+++ b/app/_locales/zh_TW/messages.json
@@ -133,10 +133,6 @@
"approveButtonText": {
"message": "批准"
},
- "approveSpendLimit": {
- "message": "批准 $1 花費限額",
- "description": "The token symbol that is being approved"
- },
"approved": {
"message": "已許可"
},
@@ -1462,9 +1458,6 @@
"speedUpTransaction": {
"message": "加速這筆交易"
},
- "spendLimitAmount": {
- "message": "花費額度上限"
- },
"spendLimitInsufficient": {
"message": "花費額度上限不足"
},
diff --git a/test/e2e/tests/collectibles.spec.js b/test/e2e/tests/collectibles.spec.js
index c8e5484fb419..9ef28314c9bf 100644
--- a/test/e2e/tests/collectibles.spec.js
+++ b/test/e2e/tests/collectibles.spec.js
@@ -131,7 +131,7 @@ describe('Collectibles', function () {
// Verify transaction
const completedTx = await driver.findElement('.list-item__title');
const completedTxText = await completedTx.getText();
- assert.equal(completedTxText, 'Approve Token spend limit');
+ assert.equal(completedTxText, 'Approve token spending cap');
},
);
});
diff --git a/test/e2e/tests/custom-token-add-approve.spec.js b/test/e2e/tests/custom-token-add-approve.spec.js
index d11ce56fb7d1..4eb9fdb75d9f 100644
--- a/test/e2e/tests/custom-token-add-approve.spec.js
+++ b/test/e2e/tests/custom-token-add-approve.spec.js
@@ -196,11 +196,11 @@ describe('Create token, approve token and approve token without gas', function (
const approveTokenTask = await driver.waitForSelector({
// Selects only the very first transaction list item immediately following the 'Pending' header
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
- text: 'Approve Token spend limit',
+ text: 'Approve token spending cap',
});
assert.equal(
await approveTokenTask.getText(),
- 'Approve Token spend limit',
+ 'Approve token spending cap',
);
},
);
@@ -339,11 +339,11 @@ describe('Create token, approve token and approve token without gas', function (
const approveTokenTask = await driver.waitForSelector({
// Select only the heading of the first entry in the transaction list.
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
- text: 'Approve Token spend limit',
+ text: 'Approve token spending cap',
});
assert.equal(
await approveTokenTask.getText(),
- 'Approve Token spend limit',
+ 'Approve token spending cap',
);
},
);
@@ -426,11 +426,11 @@ describe('Create token, approve token and approve token without gas', function (
const approveTokenTask = await driver.waitForSelector({
// Select only the heading of the first entry in the transaction list.
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
- text: 'Approve Token spend limit',
+ text: 'Approve token spending cap',
});
assert.equal(
await approveTokenTask.getText(),
- 'Approve Token spend limit',
+ 'Approve token spending cap',
);
},
);
@@ -490,11 +490,11 @@ describe('Create token, approve token and approve token without gas', function (
// check transaction in Activity tab
const approveTokenTask = await driver.waitForSelector({
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
- text: 'Approve Token spend limit',
+ text: 'Approve token spending cap',
});
assert.equal(
await approveTokenTask.getText(),
- 'Approve Token spend limit',
+ 'Approve token spending cap',
);
},
);
diff --git a/ui/components/app/transaction-breakdown/transaction-breakdown.component.js b/ui/components/app/transaction-breakdown/transaction-breakdown.component.js
index ce179036c606..821a3da708b0 100644
--- a/ui/components/app/transaction-breakdown/transaction-breakdown.component.js
+++ b/ui/components/app/transaction-breakdown/transaction-breakdown.component.js
@@ -74,7 +74,7 @@ export default class TransactionBreakdown extends PureComponent {
)}
{primaryCurrency}
diff --git a/ui/hooks/useTransactionDisplayData.js b/ui/hooks/useTransactionDisplayData.js
index 24f65dd73bb3..f0d981127e24 100644
--- a/ui/hooks/useTransactionDisplayData.js
+++ b/ui/hooks/useTransactionDisplayData.js
@@ -222,7 +222,9 @@ export function useTransactionDisplayData(transactionGroup) {
} else if (type === TransactionType.tokenMethodApprove) {
category = TransactionGroupCategory.approval;
prefix = '';
- title = t('approveSpendLimit', [token?.symbol || t('token')]);
+ title = t('approveSpendingCap', [
+ token?.symbol || t('token').toLowerCase(),
+ ]);
subtitle = origin;
subtitleContainsOrigin = true;
} else if (type === TransactionType.tokenMethodSetApprovalForAll) {
From 073718d965da25b68b4f5f988ce86c8a7fa58e2c Mon Sep 17 00:00:00 2001
From: Brad Decker
Date: Wed, 25 Jan 2023 09:47:02 -0600
Subject: [PATCH 18/21] Convert ui/helpers/constants/common to typescript
(#17348)
---
.../app/currency-input/currency-input.js | 12 ++++++------
.../transaction-breakdown.component.js | 18 +++++++-----------
...r-preferenced-currency-display.component.js | 5 +++--
...ser-preferenced-currency-display.stories.js | 5 +++--
.../currency-display.component.js | 7 +++++--
.../ui/token-input/token-input.component.js | 8 ++++----
ui/ducks/send/send.js | 10 ++++++----
ui/helpers/constants/{common.js => common.ts} | 11 -----------
ui/hooks/gasFeeInput/test-utils.js | 3 +--
ui/hooks/useUserPreferencedCurrency.js | 5 +++--
.../confirm-token-transaction-base.js | 7 ++++---
11 files changed, 42 insertions(+), 49 deletions(-)
rename ui/helpers/constants/{common.js => common.ts} (74%)
diff --git a/ui/components/app/currency-input/currency-input.js b/ui/components/app/currency-input/currency-input.js
index 0d5ea0873756..564a9ee01b2e 100644
--- a/ui/components/app/currency-input/currency-input.js
+++ b/ui/components/app/currency-input/currency-input.js
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import UnitInput from '../../ui/unit-input';
import CurrencyDisplay from '../../ui/currency-display';
-import { ETH } from '../../../helpers/constants/common';
import { I18nContext } from '../../../contexts/i18n';
import {
getConversionRate,
@@ -14,6 +13,7 @@ import {
getValueFromWeiHex,
getWeiHexFromDecimalValue,
} from '../../../../shared/modules/conversion.utils';
+import { EtherDenomination } from '../../../../shared/constants/common';
/**
* Component that allows user to enter currency values as a number, and props receive a converted
@@ -39,7 +39,7 @@ export default function CurrencyInput({
const conversionRate = useSelector(getConversionRate);
const showFiat = useSelector(getShouldShowFiat);
const hideSecondary = !showFiat;
- const primarySuffix = preferredCurrency || ETH;
+ const primarySuffix = preferredCurrency || EtherDenomination.ETH;
const secondarySuffix = secondaryCurrency.toUpperCase();
const [isSwapped, setSwapped] = useState(false);
@@ -57,7 +57,7 @@ export default function CurrencyInput({
})
: getValueFromWeiHex({
value: hexValue,
- toCurrency: ETH,
+ toCurrency: EtherDenomination.ETH,
numberOfDecimals: 8,
});
@@ -82,8 +82,8 @@ export default function CurrencyInput({
})
: getWeiHexFromDecimalValue({
value: newDecimalValue,
- fromCurrency: ETH,
- fromDenomination: ETH,
+ fromCurrency: EtherDenomination.ETH,
+ fromDenomination: EtherDenomination.ETH,
conversionRate,
});
@@ -116,7 +116,7 @@ export default function CurrencyInput({
if (shouldUseFiat) {
// Display ETH
- currency = preferredCurrency || ETH;
+ currency = preferredCurrency || EtherDenomination.ETH;
numberOfDecimals = 8;
} else {
// Display Fiat
diff --git a/ui/components/app/transaction-breakdown/transaction-breakdown.component.js b/ui/components/app/transaction-breakdown/transaction-breakdown.component.js
index 821a3da708b0..3317060327c9 100644
--- a/ui/components/app/transaction-breakdown/transaction-breakdown.component.js
+++ b/ui/components/app/transaction-breakdown/transaction-breakdown.component.js
@@ -4,12 +4,8 @@ import classnames from 'classnames';
import CurrencyDisplay from '../../ui/currency-display';
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
import HexToDecimal from '../../ui/hex-to-decimal';
-import {
- GWEI,
- PRIMARY,
- SECONDARY,
- ETH,
-} from '../../../helpers/constants/common';
+import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
+import { EtherDenomination } from '../../../../shared/constants/common';
import TransactionBreakdownRow from './transaction-breakdown-row';
export default class TransactionBreakdown extends PureComponent {
@@ -114,7 +110,7 @@ export default class TransactionBreakdown extends PureComponent {
className="transaction-breakdown__value"
data-testid="transaction-breakdown__base-fee"
currency={nativeCurrency}
- denomination={GWEI}
+ denomination={EtherDenomination.GWEI}
value={baseFee}
numberOfDecimals={10}
hideLabel
@@ -127,7 +123,7 @@ export default class TransactionBreakdown extends PureComponent {
className="transaction-breakdown__value"
data-testid="transaction-breakdown__priority-fee"
currency={nativeCurrency}
- denomination={GWEI}
+ denomination={EtherDenomination.GWEI}
value={priorityFee}
numberOfDecimals={10}
hideLabel
@@ -149,7 +145,7 @@ export default class TransactionBreakdown extends PureComponent {
className="transaction-breakdown__value"
data-testid="transaction-breakdown__gas-price"
currency={nativeCurrency}
- denomination={GWEI}
+ denomination={EtherDenomination.GWEI}
value={gasPrice}
numberOfDecimals={9}
hideLabel
@@ -163,7 +159,7 @@ export default class TransactionBreakdown extends PureComponent {
className="transaction-breakdown__value"
data-testid="transaction-breakdown__effective-gas-price"
currency={nativeCurrency}
- denomination={ETH}
+ denomination={EtherDenomination.ETH}
numberOfDecimals={6}
value={hexGasTotal}
type={PRIMARY}
@@ -185,7 +181,7 @@ export default class TransactionBreakdown extends PureComponent {
{
return (
- currency === ETH &&
+ currency === EtherDenomination.ETH &&
showEthLogo && (
Date: Wed, 25 Jan 2023 10:33:06 -0600
Subject: [PATCH 19/21] Fix broken NFT import and auto-detect flows (#17384)
* Fix broken NFT import and auto-detect flows
---
app/scripts/metamask-controller.js | 8 ++++++--
.../app/collectibles-tab/collectibles-tab.test.js | 6 ++++--
ui/ducks/metamask/metamask.js | 13 ++++++++++---
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index fa3135f657b3..0936e5b20611 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -342,6 +342,7 @@ export default class MetamaskController extends EventEmitter {
...networkState,
providerConfig: {
...networkState.provider,
+ chainId: hexToDecimal(networkState.provider.chainId),
},
};
return cb(modifiedNetworkState);
@@ -972,8 +973,11 @@ export default class MetamaskController extends EventEmitter {
getTokenValueParam(transactionData);
const { allNfts } = this.nftController.state;
+ const chainIdAsDecimal = hexToDecimal(chainId);
// check if its a known collectible
- const knownCollectible = allNfts?.[userAddress]?.[chainId].find(
+ const knownCollectible = allNfts?.[userAddress]?.[
+ chainIdAsDecimal
+ ]?.find(
({ address, tokenId }) =>
isEqualCaseInsensitive(address, contractAddress) &&
tokenId === transactionDataTokenId,
@@ -984,7 +988,7 @@ export default class MetamaskController extends EventEmitter {
this.nftController.checkAndUpdateSingleNftOwnershipStatus(
knownCollectible,
false,
- { userAddress, chainId },
+ { userAddress, chainId: chainIdAsDecimal },
);
}
}
diff --git a/ui/components/app/collectibles-tab/collectibles-tab.test.js b/ui/components/app/collectibles-tab/collectibles-tab.test.js
index e9d10278d68f..36d09250959d 100644
--- a/ui/components/app/collectibles-tab/collectibles-tab.test.js
+++ b/ui/components/app/collectibles-tab/collectibles-tab.test.js
@@ -5,6 +5,7 @@ import configureStore from '../../../store/store';
import { renderWithProvider } from '../../../../test/jest/rendering';
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
import { setBackgroundConnection } from '../../../../test/jest';
+import { hexToDecimal } from '../../../../shared/modules/conversion.utils';
import CollectiblesTab from '.';
const COLLECTIBLES = [
@@ -153,16 +154,17 @@ const render = ({
useNftDetection,
onAddNFT = jest.fn(),
}) => {
+ const chainIdAsDecimal = hexToDecimal(chainId);
const store = configureStore({
metamask: {
allNfts: {
[ACCOUNT_1]: {
- [chainId]: collectibles,
+ [chainIdAsDecimal]: collectibles,
},
},
allNftContracts: {
[ACCOUNT_1]: {
- [chainId]: collectibleContracts,
+ [chainIdAsDecimal]: collectibleContracts,
},
},
provider: { chainId },
diff --git a/ui/ducks/metamask/metamask.js b/ui/ducks/metamask/metamask.js
index 4ca87f16ccc0..43ef831194a3 100644
--- a/ui/ducks/metamask/metamask.js
+++ b/ui/ducks/metamask/metamask.js
@@ -17,7 +17,10 @@ import { setCustomGasLimit, setCustomGasPrice } from '../gas/gas.duck';
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
import { isEqualCaseInsensitive } from '../../../shared/modules/string-utils';
import { stripHexPrefix } from '../../../shared/modules/hexstring-utils';
-import { decGWEIToHexWEI } from '../../../shared/modules/conversion.utils';
+import {
+ decGWEIToHexWEI,
+ hexToDecimal,
+} from '../../../shared/modules/conversion.utils';
export default function reduceMetamask(state = {}, action) {
const metamaskState = {
@@ -280,7 +283,9 @@ export const getCollectibles = (state) => {
},
} = state;
- return allNfts?.[selectedAddress]?.[chainId] ?? [];
+ const chainIdAsDecimal = hexToDecimal(chainId);
+
+ return allNfts?.[selectedAddress]?.[chainIdAsDecimal] ?? [];
};
export const getCollectibleContracts = (state) => {
@@ -292,7 +297,9 @@ export const getCollectibleContracts = (state) => {
},
} = state;
- return allNftContracts?.[selectedAddress]?.[chainId] ?? [];
+ const chainIdAsDecimal = hexToDecimal(chainId);
+
+ return allNftContracts?.[selectedAddress]?.[chainIdAsDecimal] ?? [];
};
export function getBlockGasLimit(state) {
From d2331c0e0b629a39bd070c04fbf1b358700a850e Mon Sep 17 00:00:00 2001
From: Mark Stacey
Date: Wed, 25 Jan 2023 14:22:04 -0330
Subject: [PATCH 20/21] Fix Playwright install step (#17415)
The Playwright install step run in the `test-storybook` job has been
updated to ensure that we are running the correct install command.
Previously we were using `yarn dlx`, which would use the latest version
of `Playwright` rather than the one currently installed. Instead now we
are using `yarn exec`, which will invoke the `playwright` binary from
the locally installed package. This binary has an `install` command
that completes the necessary setup, which is to install custom patched
browsers for Playwright to run.
---
.circleci/config.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index c85c506e4283..185043f98499 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -524,7 +524,7 @@ jobs:
at: .
- run:
name: Install Playwright browsers
- command: yarn dlx playwright install
+ command: yarn exec playwright install
- run:
name: Test Storybook
command: yarn test-storybook:ci
From 23133a27355e0d6f81afa63b309a8192983cebdc Mon Sep 17 00:00:00 2001
From: Garrett Bear
Date: Wed, 25 Jan 2023 10:11:13 -0800
Subject: [PATCH 21/21] fix icon names (#17391)
---
.../app/collectible-details/collectible-details.js | 8 ++------
.../app/flask/snap-delineator/snap-delineator.js | 2 +-
.../app/signature-request-siwe/signature-request-siwe.js | 4 ++--
ui/components/component-library/banner-base/README.mdx | 2 +-
.../component-library/banner-base/banner-base.js | 2 +-
.../component-library/banner-base/banner-base.stories.js | 4 ++--
.../component-library/banner-base/banner-base.test.js | 5 +----
.../component-library/button-base/button-base.test.js | 2 +-
.../component-library/button-link/button-link.test.js | 2 +-
.../button-primary/button-primary.test.js | 2 +-
.../button-secondary/button-secondary.test.js | 2 +-
ui/components/component-library/button/button.test.js | 2 +-
.../onboarding-flow/privacy-settings/privacy-settings.js | 2 +-
13 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/ui/components/app/collectible-details/collectible-details.js b/ui/components/app/collectible-details/collectible-details.js
index 87159ee94901..f1d2edf87d21 100644
--- a/ui/components/app/collectible-details/collectible-details.js
+++ b/ui/components/app/collectible-details/collectible-details.js
@@ -277,9 +277,7 @@ export default function CollectibleDetails({ collectible }) {
handleSourceCopy(collectibleImageURL);
}}
iconName={
- sourceCopied
- ? ICON_NAMES.COPY_SUCCESS_FILLED
- : ICON_NAMES.COPY_FILLED
+ sourceCopied ? ICON_NAMES.COPY_SUCCESS : ICON_NAMES.COPY
}
/>
@@ -334,9 +332,7 @@ export default function CollectibleDetails({ collectible }) {
handleAddressCopy(address);
}}
iconName={
- addressCopied
- ? ICON_NAMES.COPY_SUCCESS_FILLED
- : ICON_NAMES.COPY_FILLED
+ addressCopied ? ICON_NAMES.COPY_SUCCESS : ICON_NAMES.COPY
}
/>
diff --git a/ui/components/app/flask/snap-delineator/snap-delineator.js b/ui/components/app/flask/snap-delineator/snap-delineator.js
index 0a29d2e442e6..908a29d79f4e 100644
--- a/ui/components/app/flask/snap-delineator/snap-delineator.js
+++ b/ui/components/app/flask/snap-delineator/snap-delineator.js
@@ -31,7 +31,7 @@ export const SnapDelineator = ({ snapName, children }) => {
paddingTop={1}
paddingBottom={1}
>
-
+
}
+ icon={}
/>
)}
{!isSIWEDomainValid && (
@@ -121,7 +121,7 @@ export default function SignatureRequestSIWE({
iconFillColor="var(--color-error-default)"
useIcon
withRightButton
- icon={}
+ icon={}
/>
)}
}
+ startAccessory={}
>
The info icon on the left is passed through the startAccessory prop
;
diff --git a/ui/components/component-library/banner-base/banner-base.js b/ui/components/component-library/banner-base/banner-base.js
index 1cc0fab51a21..7141d3650094 100644
--- a/ui/components/component-library/banner-base/banner-base.js
+++ b/ui/components/component-library/banner-base/banner-base.js
@@ -68,7 +68,7 @@ export const BannerBase = ({
{onClose && (
,
+ startAccessory: ,
};
DefaultStory.storyName = 'Default';
@@ -165,5 +165,5 @@ StartAccessory.args = {
title: 'Start accessory demo',
children:
'The info icon on the left is passed through the startAccessory prop',
- startAccessory: ,
+ startAccessory: ,
};
diff --git a/ui/components/component-library/banner-base/banner-base.test.js b/ui/components/component-library/banner-base/banner-base.test.js
index 5e19a10c57ca..61dbbbf4b0bf 100644
--- a/ui/components/component-library/banner-base/banner-base.test.js
+++ b/ui/components/component-library/banner-base/banner-base.test.js
@@ -72,10 +72,7 @@ describe('BannerBase', () => {
const { getByTestId } = render(
+
}
/>,
);
diff --git a/ui/components/component-library/button-base/button-base.test.js b/ui/components/component-library/button-base/button-base.test.js
index 4ba5ac432928..99ca354f94e6 100644
--- a/ui/components/component-library/button-base/button-base.test.js
+++ b/ui/components/component-library/button-base/button-base.test.js
@@ -100,7 +100,7 @@ describe('ButtonBase', () => {
const { getByTestId } = render(
,
);
diff --git a/ui/components/component-library/button-link/button-link.test.js b/ui/components/component-library/button-link/button-link.test.js
index 08cfa8c816bd..2c1b31c5d32f 100644
--- a/ui/components/component-library/button-link/button-link.test.js
+++ b/ui/components/component-library/button-link/button-link.test.js
@@ -82,7 +82,7 @@ describe('ButtonLink', () => {
});
it('should render with icon', () => {
const { container } = render(
- ,
+ ,
);
const icons = container.getElementsByClassName('mm-icon').length;
diff --git a/ui/components/component-library/button-primary/button-primary.test.js b/ui/components/component-library/button-primary/button-primary.test.js
index dbf1e815bea3..500915d916e3 100644
--- a/ui/components/component-library/button-primary/button-primary.test.js
+++ b/ui/components/component-library/button-primary/button-primary.test.js
@@ -89,7 +89,7 @@ describe('ButtonPrimary', () => {
});
it('should render with icon', () => {
const { container } = render(
- ,
+ ,
);
const icons = container.getElementsByClassName('mm-icon').length;
diff --git a/ui/components/component-library/button-secondary/button-secondary.test.js b/ui/components/component-library/button-secondary/button-secondary.test.js
index 79ffca27c688..5549e15737a8 100644
--- a/ui/components/component-library/button-secondary/button-secondary.test.js
+++ b/ui/components/component-library/button-secondary/button-secondary.test.js
@@ -93,7 +93,7 @@ describe('ButtonSecondary', () => {
});
it('should render with icon', () => {
const { container } = render(
- ,
+ ,
);
const icons = container.getElementsByClassName('mm-icon').length;
diff --git a/ui/components/component-library/button/button.test.js b/ui/components/component-library/button/button.test.js
index f63e2bcdaf9a..9cf7460d6209 100644
--- a/ui/components/component-library/button/button.test.js
+++ b/ui/components/component-library/button/button.test.js
@@ -133,7 +133,7 @@ describe('Button', () => {
const { getByTestId } = render(