update prettier (#15360)

feature/default_network_editable
Brad Decker 2 years ago committed by GitHub
parent 9e7c75d06d
commit c72199a1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/scripts/background.js
  2. 9
      app/scripts/controllers/detect-tokens.js
  3. 10
      app/scripts/controllers/detect-tokens.test.js
  4. 77
      app/scripts/controllers/incoming-transactions.test.js
  5. 3
      app/scripts/controllers/metametrics.js
  6. 10
      app/scripts/controllers/metametrics.test.js
  7. 13
      app/scripts/controllers/network/network-controller.test.js
  8. 3
      app/scripts/controllers/network/pending-middleware.test.js
  9. 12
      app/scripts/controllers/network/util.test.js
  10. 5
      app/scripts/controllers/permissions/caveat-mutators.test.js
  11. 31
      app/scripts/controllers/swaps.js
  12. 62
      app/scripts/controllers/swaps.test.js
  13. 5
      app/scripts/controllers/threebox.js
  14. 62
      app/scripts/controllers/transactions/index.js
  15. 6
      app/scripts/controllers/transactions/index.test.js
  16. 9
      app/scripts/controllers/transactions/pending-tx-tracker.js
  17. 39
      app/scripts/controllers/transactions/pending-tx-tracker.test.js
  18. 7
      app/scripts/controllers/transactions/tx-gas-utils.js
  19. 5
      app/scripts/lib/buy-url.js
  20. 5
      app/scripts/lib/buy-url.test.js
  21. 5
      app/scripts/lib/ens-ipfs/resolver.js
  22. 5
      app/scripts/lib/personal-message-manager.js
  23. 5
      app/scripts/lib/typed-message-manager.js
  24. 541
      app/scripts/metamask-controller.js
  25. 38
      app/scripts/metamask-controller.test.js
  26. 7
      app/scripts/migrations/022.test.js
  27. 3
      app/scripts/migrations/030.js
  28. 3
      app/scripts/migrations/047.js
  29. 10
      app/scripts/migrations/049.js
  30. 7
      app/scripts/migrations/052.js
  31. 9
      app/scripts/migrations/055.js
  32. 5
      app/scripts/migrations/056.js
  33. 18
      app/scripts/migrations/064.test.js
  34. 6
      app/scripts/migrations/065.js
  35. 11
      app/scripts/migrations/067.js
  36. 5
      app/scripts/migrations/068.js
  37. 6
      app/scripts/migrations/068.test.js
  38. 6
      app/scripts/platforms/extension.js
  39. 10
      development/build/transforms/remove-fenced-code.js
  40. 5
      development/build/transforms/remove-fenced-code.test.js
  41. 3
      development/verify-locale-strings.js
  42. 6
      package.json
  43. 6
      shared/constants/tokens.js
  44. 5
      shared/modules/contract-utils.test.js
  45. 6
      shared/modules/transaction.utils.js
  46. 9
      shared/modules/transaction.utils.test.js
  47. 24
      test/e2e/metamask-ui.spec.js
  48. 7
      test/e2e/tests/chain-interactions.spec.js
  49. 3
      test/e2e/tests/custom-rpc-history.spec.js
  50. 15
      test/e2e/tests/custom-token-add-approve.spec.js
  51. 7
      ui/components/app/add-network/add-network.js
  52. 7
      ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.js
  53. 12
      ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-gas-limit/advanced-gas-fee-gas-limit.js
  54. 15
      ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-inputs/base-fee-input/base-fee-input.js
  55. 15
      ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-inputs/priority-fee-input/priority-fee-input.js
  56. 8
      ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-save/advanced-gas-fee-save.js
  57. 6
      ui/components/app/asset-list/asset-list.js
  58. 3
      ui/components/app/cancel-button/cancel-button.js
  59. 17
      ui/components/app/cancel-speedup-popover/cancel-speedup-popover.test.js
  60. 6
      ui/components/app/collectible-options/collectible-options.js
  61. 21
      ui/components/app/collectibles-items/collectibles-items.js
  62. 7
      ui/components/app/collectibles-tab/collectibles-tab.js
  63. 6
      ui/components/app/collectibles-tab/collectibles-tab.test.js
  64. 5
      ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-summary/confirm-page-container-summary.component.js
  65. 7
      ui/components/app/connected-accounts-list/connected-accounts-list.component.js
  66. 3
      ui/components/app/connected-accounts-permissions/connected-accounts-permissions.js
  67. 6
      ui/components/app/contact-list/recipient-group/recipient-group.component.js
  68. 5
      ui/components/app/detected-token/detected-token-selection-popover/detected-token-selection-popover.js
  69. 17
      ui/components/app/detected-token/detected-token.js
  70. 5
      ui/components/app/dropdowns/network-dropdown.js
  71. 5
      ui/components/app/edit-gas-display/edit-gas-display.component.js
  72. 8
      ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.js
  73. 5
      ui/components/app/edit-gas-fee-popover/edit-gas-item/useGasItemFeeDetails.js
  74. 6
      ui/components/app/edit-gas-popover/edit-gas-popover.component.js
  75. 6
      ui/components/app/flask/experimental-area/experimental-area.js
  76. 15
      ui/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js
  77. 5
      ui/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/advanced-tab-content-component.test.js
  78. 5
      ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js
  79. 25
      ui/components/app/gas-customization/gas-price-button-group/gas-price-button-group-component.test.js
  80. 4
      ui/components/app/gas-timing/gas-timing.component.test.js
  81. 7
      ui/components/app/ledger-instruction-field/ledger-instruction-field.js
  82. 7
      ui/components/app/loading-network-screen/loading-network-screen.component.js
  83. 6
      ui/components/app/menu-bar/menu-bar.js
  84. 3
      ui/components/app/metamask-template-renderer/metamask-template-renderer.stories.js
  85. 8
      ui/components/app/modals/cancel-transaction/cancel-transaction.container.js
  86. 24
      ui/components/app/modals/edit-approval-permission/edit-approval-permission.component.js
  87. 3
      ui/components/app/permissions-connect-footer/permissions-connect-footer.component.js
  88. 3
      ui/components/app/signature-request-original/signature-request-original.component.js
  89. 6
      ui/components/app/signature-request-original/signature-request-original.container.js
  90. 13
      ui/components/app/signature-request/signature-request.container.js
  91. 3
      ui/components/app/signature-request/signature-request.container.test.js
  92. 22
      ui/components/app/srp-input/srp-input.test.js
  93. 24
      ui/components/app/transaction-activity-log/transaction-activity-log.component.test.js
  94. 4
      ui/components/app/transaction-activity-log/transaction-activity-log.container.js
  95. 18
      ui/components/app/transaction-activity-log/transaction-activity-log.util.test.js
  96. 3
      ui/components/app/transaction-detail-item/transaction-detail-item.component.js
  97. 16
      ui/components/app/transaction-list-item/smart-transaction-list-item.component.js
  98. 5
      ui/components/app/transaction-list-item/transaction-list-item.component.js
  99. 3
      ui/components/app/whats-new-popup/whats-new-popup.js
  100. 3
      ui/components/ui/definition-list/definition-list.stories.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -615,11 +615,11 @@ function setupController(initState, initLangCode, remoteSourcePort) {
const { unapprovedMsgCount } = controller.messageManager;
const { unapprovedPersonalMsgCount } = controller.personalMessageManager;
const { unapprovedDecryptMsgCount } = controller.decryptMessageManager;
const {
unapprovedEncryptionPublicKeyMsgCount,
} = controller.encryptionPublicKeyManager;
const { unapprovedEncryptionPublicKeyMsgCount } =
controller.encryptionPublicKeyManager;
const { unapprovedTypedMessagesCount } = controller.typedMessageManager;
const pendingApprovalCount = controller.approvalController.getTotalApprovalCount();
const pendingApprovalCount =
controller.approvalController.getTotalApprovalCount();
const waitingForUnlockCount =
controller.appStateController.waitingForUnlock.length;
return (

@ -174,13 +174,8 @@ export default class DetectTokensController {
if (result) {
const nonZeroTokenAddresses = Object.keys(result);
for (const nonZeroTokenAddress of nonZeroTokenAddresses) {
const {
address,
symbol,
decimals,
iconUrl,
aggregators,
} = tokenList[nonZeroTokenAddress];
const { address, symbol, decimals, iconUrl, aggregators } =
tokenList[nonZeroTokenAddress];
eventTokensDetails.push(`${symbol} - ${address}`);

@ -291,9 +291,8 @@ describe('DetectTokensController', function () {
const contractAddressesToDetect = erc20ContractAddresses.filter(
(address) => address !== existingTokenAddress,
);
const indexOfTokenToAdd = contractAddressesToDetect.indexOf(
tokenAddressToAdd,
);
const indexOfTokenToAdd =
contractAddressesToDetect.indexOf(tokenAddressToAdd);
const balances = new Array(contractAddressesToDetect.length);
balances[indexOfTokenToAdd] = new BigNumber(10);
@ -353,9 +352,8 @@ describe('DetectTokensController', function () {
const contractAddressesToDetect = erc20ContractAddresses.filter(
(address) => address !== existingTokenAddress,
);
const indexOfTokenToAdd = contractAddressesToDetect.indexOf(
tokenAddressToAdd,
);
const indexOfTokenToAdd =
contractAddressesToDetect.indexOf(tokenAddressToAdd);
const balances = new Array(contractAddressesToDetect.length);
balances[indexOfTokenToAdd] = new BigNumber(10);

@ -190,9 +190,8 @@ describe('IncomingTransactionsController', function () {
);
assert(mockedNetworkMethods.onNetworkDidChange.calledOnce);
const networkControllerListenerCallback = mockedNetworkMethods.onNetworkDidChange.getCall(
0,
).args[0];
const networkControllerListenerCallback =
mockedNetworkMethods.onNetworkDidChange.getCall(0).args[0];
assert.strictEqual(incomingTransactionsController._update.callCount, 0);
networkControllerListenerCallback('testNetworkType');
assert.strictEqual(incomingTransactionsController._update.callCount, 1);
@ -253,8 +252,10 @@ describe('IncomingTransactionsController', function () {
initState: getNonEmptyInitState(),
},
);
const startBlock = getNonEmptyInitState()
.incomingTxLastFetchedBlockByChainId[ROPSTEN_CHAIN_ID];
const startBlock =
getNonEmptyInitState().incomingTxLastFetchedBlockByChainId[
ROPSTEN_CHAIN_ID
];
nock('https://api-ropsten.etherscan.io')
.get(
`/api?module=account&action=txlist&address=${MOCK_SELECTED_ADDRESS}&tag=latest&page=1&startBlock=${startBlock}`,
@ -546,8 +547,10 @@ describe('IncomingTransactionsController', function () {
},
);
const NEW_MOCK_SELECTED_ADDRESS = `${MOCK_SELECTED_ADDRESS}9`;
const startBlock = getNonEmptyInitState()
.incomingTxLastFetchedBlockByChainId[ROPSTEN_CHAIN_ID];
const startBlock =
getNonEmptyInitState().incomingTxLastFetchedBlockByChainId[
ROPSTEN_CHAIN_ID
];
nock('https://api-ropsten.etherscan.io')
.get(
`/api?module=account&action=txlist&address=${NEW_MOCK_SELECTED_ADDRESS}&tag=latest&page=1&startBlock=${startBlock}`,
@ -572,7 +575,8 @@ describe('IncomingTransactionsController', function () {
incomingTransactionsController.store,
);
const subscription = incomingTransactionsController.preferencesController.store.subscribe.getCall(
const subscription =
incomingTransactionsController.preferencesController.store.subscribe.getCall(
1,
).args[0];
// The incoming transactions controller will always skip the first event
@ -658,7 +662,8 @@ describe('IncomingTransactionsController', function () {
incomingTransactionsController.store,
);
const subscription = incomingTransactionsController.preferencesController.store.subscribe.getCall(
const subscription =
incomingTransactionsController.preferencesController.store.subscribe.getCall(
1,
).args[0];
// The incoming transactions controller will always skip the first event
@ -682,9 +687,8 @@ describe('IncomingTransactionsController', function () {
});
it('should update when switching to a supported network', async function () {
const mockedNetworkMethods = getMockNetworkControllerMethods(
ROPSTEN_CHAIN_ID,
);
const mockedNetworkMethods =
getMockNetworkControllerMethods(ROPSTEN_CHAIN_ID);
const incomingTransactionsController = new IncomingTransactionsController(
{
blockTracker: getMockBlockTracker(),
@ -693,8 +697,10 @@ describe('IncomingTransactionsController', function () {
initState: getNonEmptyInitState(),
},
);
const startBlock = getNonEmptyInitState()
.incomingTxLastFetchedBlockByChainId[ROPSTEN_CHAIN_ID];
const startBlock =
getNonEmptyInitState().incomingTxLastFetchedBlockByChainId[
ROPSTEN_CHAIN_ID
];
nock('https://api-ropsten.etherscan.io')
.get(
`/api?module=account&action=txlist&address=${MOCK_SELECTED_ADDRESS}&tag=latest&page=1&startBlock=${startBlock}`,
@ -715,8 +721,8 @@ describe('IncomingTransactionsController', function () {
incomingTransactionsController.store,
);
const subscription = mockedNetworkMethods.onNetworkDidChange.getCall(0)
.args[0];
const subscription =
mockedNetworkMethods.onNetworkDidChange.getCall(0).args[0];
await subscription(ROPSTEN_CHAIN_ID);
await updateStateCalled();
@ -763,9 +769,8 @@ describe('IncomingTransactionsController', function () {
});
it('should not update when switching to an unsupported network', async function () {
const mockedNetworkMethods = getMockNetworkControllerMethods(
ROPSTEN_CHAIN_ID,
);
const mockedNetworkMethods =
getMockNetworkControllerMethods(ROPSTEN_CHAIN_ID);
const incomingTransactionsController = new IncomingTransactionsController(
{
blockTracker: getMockBlockTracker(),
@ -796,8 +801,8 @@ describe('IncomingTransactionsController', function () {
incomingTransactionsController.store,
);
const subscription = mockedNetworkMethods.onNetworkDidChange.getCall(0)
.args[0];
const subscription =
mockedNetworkMethods.onNetworkDidChange.getCall(0).args[0];
incomingTransactionsController.getCurrentChainId = () => FAKE_CHAIN_ID;
await subscription();
@ -820,15 +825,14 @@ describe('IncomingTransactionsController', function () {
describe('_update', function () {
describe('when state is empty (initialized)', function () {
it('should use provided block number and update the latest block seen', async function () {
const incomingTransactionsController = new IncomingTransactionsController(
{
const incomingTransactionsController =
new IncomingTransactionsController({
blockTracker: getMockBlockTracker(),
...getMockNetworkControllerMethods(ROPSTEN_CHAIN_ID),
preferencesController: getMockPreferencesController(),
initState: getEmptyInitState(),
getCurrentChainId: () => ROPSTEN_CHAIN_ID,
},
);
});
sinon.spy(incomingTransactionsController.store, 'updateState');
incomingTransactionsController._getNewIncomingTransactions = sinon
@ -857,15 +861,14 @@ describe('IncomingTransactionsController', function () {
});
it('should update the last fetched block for network to highest block seen in incoming txs', async function () {
const incomingTransactionsController = new IncomingTransactionsController(
{
const incomingTransactionsController =
new IncomingTransactionsController({
blockTracker: getMockBlockTracker(),
...getMockNetworkControllerMethods(ROPSTEN_CHAIN_ID),
preferencesController: getMockPreferencesController(),
initState: getEmptyInitState(),
getCurrentChainId: () => ROPSTEN_CHAIN_ID,
},
);
});
const NEW_TRANSACTION_ONE = {
id: 555,
@ -911,15 +914,14 @@ describe('IncomingTransactionsController', function () {
describe('when state is populated with prior data for network', function () {
it('should use the last fetched block for the current network and increment by 1 in state', async function () {
const incomingTransactionsController = new IncomingTransactionsController(
{
const incomingTransactionsController =
new IncomingTransactionsController({
blockTracker: getMockBlockTracker(),
...getMockNetworkControllerMethods(ROPSTEN_CHAIN_ID),
preferencesController: getMockPreferencesController(),
initState: getNonEmptyInitState(),
getCurrentChainId: () => ROPSTEN_CHAIN_ID,
},
);
});
sinon.spy(incomingTransactionsController.store, 'updateState');
incomingTransactionsController._getNewIncomingTransactions = sinon
.stub()
@ -1105,7 +1107,8 @@ describe('IncomingTransactionsController', function () {
},
);
const result = await incomingTransactionsController._getNewIncomingTransactions(
const result =
await incomingTransactionsController._getNewIncomingTransactions(
ADDRESS_TO_FETCH_FOR,
'789',
ROPSTEN_CHAIN_ID,
@ -1137,7 +1140,8 @@ describe('IncomingTransactionsController', function () {
},
);
const result = await incomingTransactionsController._getNewIncomingTransactions(
const result =
await incomingTransactionsController._getNewIncomingTransactions(
ADDRESS_TO_FETCH_FOR,
'789',
ROPSTEN_CHAIN_ID,
@ -1164,7 +1168,8 @@ describe('IncomingTransactionsController', function () {
},
);
const result = await incomingTransactionsController._getNewIncomingTransactions(
const result =
await incomingTransactionsController._getNewIncomingTransactions(
ADDRESS_TO_FETCH_FOR,
'789',
ROPSTEN_CHAIN_ID,

@ -558,7 +558,8 @@ export default class MetaMetricsController {
[TRAITS.NETWORKS_ADDED]: metamaskState.frequentRpcListDetail.map(
(rpc) => rpc.chainId,
),
[TRAITS.NETWORKS_WITHOUT_TICKER]: metamaskState.frequentRpcListDetail.reduce(
[TRAITS.NETWORKS_WITHOUT_TICKER]:
metamaskState.frequentRpcListDetail.reduce(
(networkList, currentNetwork) => {
if (!currentNetwork.ticker) {
networkList.push(currentNetwork.chainId);

@ -132,12 +132,10 @@ function getMetaMetricsController({
} = {}) {
return new MetaMetricsController({
segment,
getNetworkIdentifier: networkController.getNetworkIdentifier.bind(
networkController,
),
getCurrentChainId: networkController.getCurrentChainId.bind(
networkController,
),
getNetworkIdentifier:
networkController.getNetworkIdentifier.bind(networkController),
getCurrentChainId:
networkController.getCurrentChainId.bind(networkController),
onNetworkDidChange: networkController.on.bind(
networkController,
NETWORK_EVENTS.NETWORK_DID_CHANGE,

@ -34,8 +34,8 @@ describe('NetworkController', () => {
describe('#provider', () => {
it('provider should be updatable without reassignment', () => {
networkController.initializeProvider(networkControllerProviderConfig);
const providerProxy = networkController.getProviderAndBlockTracker()
.provider;
const providerProxy =
networkController.getProviderAndBlockTracker().provider;
expect(providerProxy.test).toBeUndefined();
providerProxy.setTarget({ test: true });
expect(providerProxy.test).toStrictEqual(true);
@ -79,7 +79,8 @@ describe('NetworkController', () => {
describe('#getEIP1559Compatibility', () => {
it('should return false when baseFeePerGas is not in the block header', async () => {
networkController.initializeProvider(networkControllerProviderConfig);
const supportsEIP1559 = await networkController.getEIP1559Compatibility();
const supportsEIP1559 =
await networkController.getEIP1559Compatibility();
expect(supportsEIP1559).toStrictEqual(false);
});
@ -88,7 +89,8 @@ describe('NetworkController', () => {
getLatestBlockStub.callsFake(() =>
Promise.resolve({ baseFeePerGas: '0xa ' }),
);
const supportsEIP1559 = await networkController.getEIP1559Compatibility();
const supportsEIP1559 =
await networkController.getEIP1559Compatibility();
expect(supportsEIP1559).toStrictEqual(true);
});
@ -98,7 +100,8 @@ describe('NetworkController', () => {
Promise.resolve({ baseFeePerGas: '0xa ' }),
);
await networkController.getEIP1559Compatibility();
const supportsEIP1559 = await networkController.getEIP1559Compatibility();
const supportsEIP1559 =
await networkController.getEIP1559Compatibility();
expect(getLatestBlockStub.calledOnce).toStrictEqual(true);
expect(supportsEIP1559).toStrictEqual(true);
});

@ -68,8 +68,7 @@ describe('PendingNonceMiddleware', () => {
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
gas: GAS_LIMITS.SIMPLE,
gasPrice: '0x1e8480',
hash:
'0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
hash: '0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
input: '0x',
nonce: '0x4',
type: TRANSACTION_ENVELOPE_TYPES.LEGACY,

@ -25,8 +25,7 @@ describe('network utils', () => {
chainId: '0x3',
time: 1624408066355,
metamaskNetworkId: '3',
hash:
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
hash: '0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
r: '0x4c3111e42ed5eec3dcecba1e234700f387e8693c373c61c3e54a762a26f1570e',
s: '0x18bfc4eeb7ebcfacc3bd59ea100a6834ea3265e65945dbec69aa2a06564fafff',
v: '0x29',
@ -38,8 +37,7 @@ describe('network utils', () => {
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
gas: '0x7b0d',
gasPrice: '0x77359400',
hash:
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
hash: '0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
input: '0x',
maxFeePerGas: '0x77359400',
maxPriorityFeePerGas: '0x77359400',
@ -72,8 +70,7 @@ describe('network utils', () => {
chainId: '0x3',
time: 1624408066355,
metamaskNetworkId: '3',
hash:
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
hash: '0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
r: '0x4c3111e42ed5eec3dcecba1e234700f387e8693c373c61c3e54a762a26f1570e',
s: '0x18bfc4eeb7ebcfacc3bd59ea100a6834ea3265e65945dbec69aa2a06564fafff',
v: '0x29',
@ -84,8 +81,7 @@ describe('network utils', () => {
blockNumber: null,
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
gas: '0x7b0d',
hash:
'0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
hash: '0x4bcb6cd6b182209585f8ad140260ddb35c81a575dd40f508d9767e652a9f60e7',
input: '0x',
gasPrice: '0x77359400',
nonce: '0x4b',

@ -4,9 +4,8 @@ import { CaveatMutatorFactories } from './caveat-mutators';
describe('caveat mutators', () => {
describe('restrictReturnedAccounts', () => {
const { removeAccount } = CaveatMutatorFactories[
CaveatTypes.restrictReturnedAccounts
];
const { removeAccount } =
CaveatMutatorFactories[CaveatTypes.restrictReturnedAccounts];
describe('removeAccount', () => {
it('returns the no-op operation if the target account is not permitted', () => {

@ -90,7 +90,8 @@ const initialState = {
swapsQuoteRefreshTime: FALLBACK_QUOTE_REFRESH_TIME,
swapsQuotePrefetchingRefreshTime: FALLBACK_QUOTE_REFRESH_TIME,
swapsStxBatchStatusRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME,
swapsStxGetTransactionsRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME,
swapsStxGetTransactionsRefreshTime:
FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME,
swapsStxMaxFeeMultiplier: FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER,
swapsFeatureFlags: {},
},
@ -336,10 +337,8 @@ export default class SwapsController {
if (Object.values(newQuotes).length === 0) {
this.setSwapsErrorKey(QUOTES_NOT_AVAILABLE_ERROR);
} else {
const [
_topAggId,
quotesWithSavingsAndFeeData,
] = await this._findTopQuoteAndCalculateSavings(newQuotes);
const [_topAggId, quotesWithSavingsAndFeeData] =
await this._findTopQuoteAndCalculateSavings(newQuotes);
topAggId = _topAggId;
newQuotes = quotesWithSavingsAndFeeData;
}
@ -486,10 +485,8 @@ export default class SwapsController {
const quoteToUpdate = { ...swapsState.quotes[initialAggId] };
const {
gasLimit: newGasEstimate,
simulationFails,
} = await this.timedoutGasReturn(quoteToUpdate.trade);
const { gasLimit: newGasEstimate, simulationFails } =
await this.timedoutGasReturn(quoteToUpdate.trade);
if (newGasEstimate && !simulationFails) {
const gasEstimateWithRefund = calculateGasEstimateWithRefund(
@ -637,9 +634,8 @@ export default class SwapsController {
}
async _findTopQuoteAndCalculateSavings(quotes = {}) {
const {
contractExchangeRates: tokenConversionRates,
} = this.getTokenRatesState();
const { contractExchangeRates: tokenConversionRates } =
this.getTokenRatesState();
const {
swapsState: { customGasPrice, customMaxPriorityFeePerGas },
} = this.store.getState();
@ -652,10 +648,8 @@ export default class SwapsController {
const newQuotes = cloneDeep(quotes);
const {
gasFeeEstimates,
gasEstimateType,
} = await this._getEIP1559GasFeeEstimates();
const { gasFeeEstimates, gasEstimateType } =
await this._getEIP1559GasFeeEstimates();
let usedGasPrice = '0x0';
@ -756,9 +750,8 @@ export default class SwapsController {
const tokenPercentageOfPreFeeDestAmount = new BigNumber(100, 10)
.minus(metaMaskFee, 10)
.div(100);
const destinationAmountBeforeMetaMaskFee = decimalAdjustedDestinationAmount.div(
tokenPercentageOfPreFeeDestAmount,
);
const destinationAmountBeforeMetaMaskFee =
decimalAdjustedDestinationAmount.div(tokenPercentageOfPreFeeDestAmount);
const metaMaskFeeInTokens = destinationAmountBeforeMetaMaskFee.minus(
decimalAdjustedDestinationAmount,
);

@ -42,8 +42,7 @@ const TEST_AGG_ID_APPROVAL = 'TEST_AGG_APPROVAL';
const POLLING_TIMEOUT = SECOND * 1000;
const MOCK_APPROVAL_NEEDED = {
data:
'0x095ea7b300000000000000000000000095e6f48254609a6ee006f7d493c8e5fb97094cef0000000000000000000000000000000000000000004a817c7ffffffdabf41c00',
data: '0x095ea7b300000000000000000000000095e6f48254609a6ee006f7d493c8e5fb97094cef0000000000000000000000000000000000000000004a817c7ffffffdabf41c00',
to: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
amount: '0',
from: '0x2369267687A84ac7B494daE2f1542C40E37f4455',
@ -139,7 +138,8 @@ const EMPTY_INIT_STATE = {
swapsQuoteRefreshTime: 60000,
swapsQuotePrefetchingRefreshTime: 60000,
swapsStxBatchStatusRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME,
swapsStxGetTransactionsRefreshTime: FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME,
swapsStxGetTransactionsRefreshTime:
FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME,
swapsStxMaxFeeMultiplier: FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER,
swapsUserFeeLevel: '',
saveFetchedQuotes: false,
@ -370,13 +370,10 @@ describe('SwapsController', function () {
baseGasEstimate,
);
const {
gasLimit: bufferedGasLimit,
} = await swapsController.getBufferedGasLimit();
const {
gasEstimate,
gasEstimateWithRefund,
} = swapsController.store.getState().swapsState.quotes[initialAggId];
const { gasLimit: bufferedGasLimit } =
await swapsController.getBufferedGasLimit();
const { gasEstimate, gasEstimateWithRefund } =
swapsController.store.getState().swapsState.quotes[initialAggId];
assert.strictEqual(gasEstimate, bufferedGasLimit);
assert.strictEqual(
gasEstimateWithRefund,
@ -416,10 +413,8 @@ describe('SwapsController', function () {
});
it('returns the top aggId and quotes with savings and fee values if passed necessary data and an even number of quotes', async function () {
const [
topAggId,
resultQuotes,
] = await swapsController._findTopQuoteAndCalculateSavings(
const [topAggId, resultQuotes] =
await swapsController._findTopQuoteAndCalculateSavings(
getTopQuoteAndSavingsMockQuotes(),
);
assert.equal(topAggId, TEST_AGG_ID_1);
@ -442,10 +437,8 @@ describe('SwapsController', function () {
medianMetaMaskFee: '0.0202',
};
const [
topAggId,
resultQuotes,
] = await swapsController._findTopQuoteAndCalculateSavings(testInput);
const [topAggId, resultQuotes] =
await swapsController._findTopQuoteAndCalculateSavings(testInput);
assert.equal(topAggId, TEST_AGG_ID_1);
assert.deepStrictEqual(resultQuotes, expectedResultQuotes);
});
@ -485,10 +478,8 @@ describe('SwapsController', function () {
},
};
const [
topAggId,
resultQuotes,
] = await swapsController._findTopQuoteAndCalculateSavings(testInput);
const [topAggId, resultQuotes] =
await swapsController._findTopQuoteAndCalculateSavings(testInput);
assert.equal(topAggId, TEST_AGG_ID_1);
assert.deepStrictEqual(resultQuotes, expectedResultQuotes);
});
@ -503,7 +494,8 @@ describe('SwapsController', function () {
trade: { value: '0x8ac7230489e80000' },
}),
);
const baseExpectedResultQuotes = getTopQuoteAndSavingsBaseExpectedResults();
const baseExpectedResultQuotes =
getTopQuoteAndSavingsBaseExpectedResults();
const expectedResultQuotes = {
[TEST_AGG_ID_1]: {
...baseExpectedResultQuotes[TEST_AGG_ID_1],
@ -549,10 +541,8 @@ describe('SwapsController', function () {
},
};
const [
topAggId,
resultQuotes,
] = await swapsController._findTopQuoteAndCalculateSavings(testInput);
const [topAggId, resultQuotes] =
await swapsController._findTopQuoteAndCalculateSavings(testInput);
assert.equal(topAggId, TEST_AGG_ID_1);
assert.deepStrictEqual(resultQuotes, expectedResultQuotes);
});
@ -569,7 +559,8 @@ describe('SwapsController', function () {
);
// 0.04 ETH fee included in trade value
testInput[TEST_AGG_ID_1].trade.value = '0x8b553ece48ec0000';
const baseExpectedResultQuotes = getTopQuoteAndSavingsBaseExpectedResults();
const baseExpectedResultQuotes =
getTopQuoteAndSavingsBaseExpectedResults();
const expectedResultQuotes = {
[TEST_AGG_ID_1]: {
...baseExpectedResultQuotes[TEST_AGG_ID_1],
@ -626,10 +617,8 @@ describe('SwapsController', function () {
delete expectedResultQuotes[TEST_AGG_ID_1].isBestQuote;
delete expectedResultQuotes[TEST_AGG_ID_1].savings;
const [
topAggId,
resultQuotes,
] = await swapsController._findTopQuoteAndCalculateSavings(testInput);
const [topAggId, resultQuotes] =
await swapsController._findTopQuoteAndCalculateSavings(testInput);
assert.equal(topAggId, TEST_AGG_ID_2);
assert.deepStrictEqual(resultQuotes, expectedResultQuotes);
});
@ -638,7 +627,8 @@ describe('SwapsController', function () {
const testInput = getTopQuoteAndSavingsMockQuotes();
// 0.04 ETH fee included in trade value
testInput[TEST_AGG_ID_1].trade.value = '0x8e1bc9bf040000';
const baseExpectedResultQuotes = getTopQuoteAndSavingsBaseExpectedResults();
const baseExpectedResultQuotes =
getTopQuoteAndSavingsBaseExpectedResults();
const expectedResultQuotes = {
...baseExpectedResultQuotes,
[TEST_AGG_ID_1]: {
@ -662,10 +652,8 @@ describe('SwapsController', function () {
delete expectedResultQuotes[TEST_AGG_ID_1].isBestQuote;
delete expectedResultQuotes[TEST_AGG_ID_1].savings;
const [
topAggId,
resultQuotes,
] = await swapsController._findTopQuoteAndCalculateSavings(testInput);
const [topAggId, resultQuotes] =
await swapsController._findTopQuoteAndCalculateSavings(testInput);
assert.equal(topAggId, TEST_AGG_ID_2);
assert.deepStrictEqual(resultQuotes, expectedResultQuotes);
});

@ -225,9 +225,8 @@ export default class ThreeBoxController {
PreferencesController: preferences,
AddressBookController: addressBook,
};
const initialMigrationState = migrator.generateInitialState(
formattedStateBackup,
);
const initialMigrationState =
migrator.generateInitialState(formattedStateBackup);
const migratedState = await migrator.migrateData(initialMigrationState);
return {
preferences: migratedState.data.PreferencesController,

@ -174,9 +174,8 @@ export default class TransactionController extends EventEmitter {
);
return [...pendingTransactions, ...externalPendingTransactions];
},
getConfirmedTransactions: this.txStateManager.getConfirmedTransactions.bind(
this.txStateManager,
),
getConfirmedTransactions:
this.txStateManager.getConfirmedTransactions.bind(this.txStateManager),
});
this.pendingTxTracker = new PendingTransactionTracker({
@ -189,9 +188,8 @@ export default class TransactionController extends EventEmitter {
return [...pending, ...approved];
},
approveTransaction: this.approveTransaction.bind(this),
getCompletedTransactions: this.txStateManager.getConfirmedTransactions.bind(
this.txStateManager,
),
getCompletedTransactions:
this.txStateManager.getConfirmedTransactions.bind(this.txStateManager),
});
this.txStateManager.store.subscribe(() =>
@ -227,10 +225,10 @@ export default class TransactionController extends EventEmitter {
}
async getEIP1559Compatibility(fromAddress) {
const currentNetworkIsCompatible = await this._getCurrentNetworkEIP1559Compatibility();
const fromAccountIsCompatible = await this._getCurrentAccountEIP1559Compatibility(
fromAddress,
);
const currentNetworkIsCompatible =
await this._getCurrentNetworkEIP1559Compatibility();
const fromAccountIsCompatible =
await this._getCurrentAccountEIP1559Compatibility(fromAddress);
return currentNetworkIsCompatible && fromAccountIsCompatible;
}
@ -815,10 +813,8 @@ export default class TransactionController extends EventEmitter {
maxFeePerGas: defaultMaxFeePerGas,
maxPriorityFeePerGas: defaultMaxPriorityFeePerGas,
} = await this._getDefaultGasFees(txMeta, eip1559Compatibility);
const {
gasLimit: defaultGasLimit,
simulationFails,
} = await this._getDefaultGasLimit(txMeta, getCodeResponse);
const { gasLimit: defaultGasLimit, simulationFails } =
await this._getDefaultGasLimit(txMeta, getCodeResponse);
// eslint-disable-next-line no-param-reassign
txMeta = this.txStateManager.getTransaction(txMeta.id);
@ -960,10 +956,8 @@ export default class TransactionController extends EventEmitter {
}
try {
const {
gasFeeEstimates,
gasEstimateType,
} = await this._getEIP1559GasFeeEstimates();
const { gasFeeEstimates, gasEstimateType } =
await this._getEIP1559GasFeeEstimates();
if (
eip1559Compatibility &&
gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET
@ -1038,11 +1032,8 @@ export default class TransactionController extends EventEmitter {
return { gasLimit: GAS_LIMITS.SIMPLE };
}
const {
blockGasLimit,
estimatedGasHex,
simulationFails,
} = await this.txGasUtil.analyzeGasUsage(txMeta);
const { blockGasLimit, estimatedGasHex, simulationFails } =
await this.txGasUtil.analyzeGasUsage(txMeta);
// add additional gas buffer to our estimation for safety
const gasLimit = this.txGasUtil.addGasBuffer(
@ -1545,9 +1536,8 @@ export default class TransactionController extends EventEmitter {
const metricsParams = { gas_used: gasUsed };
if (submittedTime) {
metricsParams.completion_time = this._getTransactionCompletionTime(
submittedTime,
);
metricsParams.completion_time =
this._getTransactionCompletionTime(submittedTime);
}
if (txReceipt.status === '0x0') {
@ -1606,9 +1596,8 @@ export default class TransactionController extends EventEmitter {
const metricsParams = { gas_used: gasUsed };
if (submittedTime) {
metricsParams.completion_time = this._getTransactionCompletionTime(
submittedTime,
);
metricsParams.completion_time =
this._getTransactionCompletionTime(submittedTime);
}
if (txReceipt.status === '0x0') {
@ -1673,10 +1662,8 @@ export default class TransactionController extends EventEmitter {
*/
async createTransactionEventFragment(transactionId, event) {
const txMeta = this.txStateManager.getTransaction(transactionId);
const {
properties,
sensitiveProperties,
} = await this._buildEventFragmentProperties(txMeta);
const { properties, sensitiveProperties } =
await this._buildEventFragmentProperties(txMeta);
this._createTransactionEventFragment(
txMeta,
event,
@ -2052,7 +2039,8 @@ export default class TransactionController extends EventEmitter {
if (gasFeeEstimates?.[estimateType]?.suggestedMaxPriorityFeePerGas) {
defaultMaxPriorityFeePerGas =
gasFeeEstimates[estimateType]?.suggestedMaxPriorityFeePerGas;
gasParams.default_max_priority_fee_per_gas = defaultMaxPriorityFeePerGas;
gasParams.default_max_priority_fee_per_gas =
defaultMaxPriorityFeePerGas;
}
}
}
@ -2272,10 +2260,8 @@ export default class TransactionController extends EventEmitter {
if (!txMeta) {
return;
}
const {
properties,
sensitiveProperties,
} = await this._buildEventFragmentProperties(txMeta, extraParams);
const { properties, sensitiveProperties } =
await this._buildEventFragmentProperties(txMeta, extraParams);
// Create event fragments for event types that spawn fragments, and ensure
// existence of fragments for event types that act upon them.

@ -2291,8 +2291,7 @@ describe('Transaction Controller', function () {
providerResultStub.eth_getCode = '0xab';
// test update gasFees
await txController.updateEditableParams('1', {
data:
'0xa9059cbb000000000000000000000000e18035bf8712672935fdb4e5e431b1a0183d2dfc0000000000000000000000000000000000000000000000000de0b6b3a7640000',
data: '0xa9059cbb000000000000000000000000e18035bf8712672935fdb4e5e431b1a0183d2dfc0000000000000000000000000000000000000000000000000de0b6b3a7640000',
});
const result = txStateManager.getTransaction('1');
assert.equal(
@ -2316,8 +2315,7 @@ describe('Transaction Controller', function () {
// maxFeePerGas: '0x004',
to: VALID_ADDRESS,
from: VALID_ADDRESS,
data:
'0xa9059cbb000000000000000000000000e18035bf8712672935fdb4e5e431b1a0183d2dfc0000000000000000000000000000000000000000000000000de0b6b3a7640000',
data: '0xa9059cbb000000000000000000000000e18035bf8712672935fdb4e5e431b1a0183d2dfc0000000000000000000000000000000000000000000000000de0b6b3a7640000',
},
estimateUsed: '0x005',
estimatedBaseFee: '0x006',

@ -198,13 +198,8 @@ export default class PendingTransactionTracker extends EventEmitter {
try {
const transactionReceipt = await this.query.getTransactionReceipt(txHash);
if (transactionReceipt?.blockNumber) {
const {
baseFeePerGas,
timestamp: blockTimestamp,
} = await this.query.getBlockByHash(
transactionReceipt?.blockHash,
false,
);
const { baseFeePerGas, timestamp: blockTimestamp } =
await this.query.getBlockByHash(transactionReceipt?.blockHash, false);
this.emit(
'tx:confirmed',

@ -154,8 +154,7 @@ describe('PendingTransactionTracker', function () {
it('should call _checkPendingTx for each pending transaction', async function () {
const txMeta = {
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SIGNED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -212,8 +211,7 @@ describe('PendingTransactionTracker', function () {
it('should publish a new transaction', async function () {
const txMeta = {
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SIGNED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -257,8 +255,7 @@ describe('PendingTransactionTracker', function () {
it('should publish the given transaction if more than 2**retryCount blocks have passed', async function () {
const txMeta = {
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SIGNED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -304,8 +301,7 @@ describe('PendingTransactionTracker', function () {
it('should NOT publish the given transaction if fewer than 2**retryCount blocks have passed', async function () {
const txMeta = {
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SIGNED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -404,8 +400,7 @@ describe('PendingTransactionTracker', function () {
assert.ok(
await pendingTxTracker._checkIfTxWasDropped({
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SUBMITTED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -437,8 +432,7 @@ describe('PendingTransactionTracker', function () {
const dropped = await pendingTxTracker._checkIfTxWasDropped({
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SUBMITTED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -458,8 +452,7 @@ describe('PendingTransactionTracker', function () {
const confirmedTxList = [
{
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.CONFIRMED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -471,8 +464,7 @@ describe('PendingTransactionTracker', function () {
},
{
id: 2,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.CONFIRMED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -517,8 +509,7 @@ describe('PendingTransactionTracker', function () {
const confirmedTxList = [
{
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.CONFIRMED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -530,8 +521,7 @@ describe('PendingTransactionTracker', function () {
},
{
id: 2,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.CONFIRMED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -577,8 +567,7 @@ describe('PendingTransactionTracker', function () {
it("should emit 'tx:warning' if getTransactionReceipt rejects", async function () {
const txMeta = {
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SUBMITTED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
@ -730,8 +719,7 @@ describe('PendingTransactionTracker', function () {
txParams: { nonce: '0x1' },
id: '123',
value: '0x02',
hash:
'0x2a919d2512ec963f524bfd9730fb66b6d5a2e399d1dd957abb5e2b544a12644b',
hash: '0x2a919d2512ec963f524bfd9730fb66b6d5a2e399d1dd957abb5e2b544a12644b',
},
];
const pendingTxTracker = new PendingTransactionTracker({
@ -774,8 +762,7 @@ describe('PendingTransactionTracker', function () {
const nonceBN = new BN(2);
const txMeta = {
id: 1,
hash:
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
hash: '0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
status: TRANSACTION_STATUSES.SUBMITTED,
txParams: {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',

@ -102,11 +102,8 @@ export default class TxGasUtil {
}
async getBufferedGasLimit(txMeta, multiplier) {
const {
blockGasLimit,
estimatedGasHex,
simulationFails,
} = await this.analyzeGasUsage(txMeta);
const { blockGasLimit, estimatedGasHex, simulationFails } =
await this.analyzeGasUsage(txMeta);
// add additional gas buffer to our estimation for safety
const gasLimit = this.addGasBuffer(

@ -82,9 +82,8 @@ const createTransakUrl = (walletAddress, chainId) => {
* @returns String
*/
const createMoonPayUrl = async (walletAddress, chainId) => {
const {
moonPay: { defaultCurrencyCode, showOnlyCurrencies } = {},
} = BUYABLE_CHAINS_MAP[chainId];
const { moonPay: { defaultCurrencyCode, showOnlyCurrencies } = {} } =
BUYABLE_CHAINS_MAP[chainId];
const moonPayQueryParams = new URLSearchParams({
apiKey: MOONPAY_API_KEY,
walletAddress,

@ -116,9 +116,8 @@ describe('buy-url', () => {
});
it('returns a MoonPay url with a prefilled wallet address for the Ethereum network', async () => {
const {
moonPay: { defaultCurrencyCode, showOnlyCurrencies } = {},
} = BUYABLE_CHAINS_MAP[MAINNET.chainId];
const { moonPay: { defaultCurrencyCode, showOnlyCurrencies } = {} } =
BUYABLE_CHAINS_MAP[MAINNET.chainId];
const moonPayQueryParams = new URLSearchParams({
apiKey: MOONPAY_API_KEY,
walletAddress: MAINNET.address,

@ -35,9 +35,8 @@ export default async function resolveEnsToIpfsContentId({ provider, name }) {
const type = contentHash.getCodec(rawContentHash);
if (type === 'ipfs-ns' || type === 'ipns-ns') {
decodedContentHash = contentHash.helpers.cidV0ToV1Base32(
decodedContentHash,
);
decodedContentHash =
contentHash.helpers.cidV0ToV1Base32(decodedContentHash);
}
return { type, hash: decodedContentHash };

@ -314,8 +314,9 @@ export default class PersonalMessageManager extends EventEmitter {
*/
_saveMsgList() {
const unapprovedPersonalMsgs = this.getUnapprovedMsgs();
const unapprovedPersonalMsgCount = Object.keys(unapprovedPersonalMsgs)
.length;
const unapprovedPersonalMsgCount = Object.keys(
unapprovedPersonalMsgs,
).length;
this.memStore.updateState({
unapprovedPersonalMsgs,
unapprovedPersonalMsgCount,

@ -391,8 +391,9 @@ export default class TypedMessageManager extends EventEmitter {
*/
_saveMsgList() {
const unapprovedTypedMessages = this.getUnapprovedMsgs();
const unapprovedTypedMessagesCount = Object.keys(unapprovedTypedMessages)
.length;
const unapprovedTypedMessagesCount = Object.keys(
unapprovedTypedMessages,
).length;
this.memStore.updateState({
unapprovedTypedMessages,
unapprovedTypedMessagesCount,

@ -229,8 +229,10 @@ export default class MetamaskController extends EventEmitter {
// now we can initialize the RPC provider, which other controllers require
this.initializeProvider();
this.provider = this.networkController.getProviderAndBlockTracker().provider;
this.blockTracker = this.networkController.getProviderAndBlockTracker().blockTracker;
this.provider =
this.networkController.getProviderAndBlockTracker().provider;
this.blockTracker =
this.networkController.getProviderAndBlockTracker().blockTracker;
this.preferencesController = new PreferencesController({
initState: initState.PreferencesController,
@ -276,16 +278,19 @@ export default class MetamaskController extends EventEmitter {
this.collectiblesController = new CollectiblesController(
{
onPreferencesStateChange: this.preferencesController.store.subscribe.bind(
onPreferencesStateChange:
this.preferencesController.store.subscribe.bind(
this.preferencesController.store,
),
onNetworkStateChange: this.networkController.store.subscribe.bind(
this.networkController.store,
),
getERC721AssetName: this.assetsContractController.getERC721AssetName.bind(
getERC721AssetName:
this.assetsContractController.getERC721AssetName.bind(
this.assetsContractController,
),
getERC721AssetSymbol: this.assetsContractController.getERC721AssetSymbol.bind(
getERC721AssetSymbol:
this.assetsContractController.getERC721AssetSymbol.bind(
this.assetsContractController,
),
getERC721TokenURI: this.assetsContractController.getERC721TokenURI.bind(
@ -294,10 +299,12 @@ export default class MetamaskController extends EventEmitter {
getERC721OwnerOf: this.assetsContractController.getERC721OwnerOf.bind(
this.assetsContractController,
),
getERC1155BalanceOf: this.assetsContractController.getERC1155BalanceOf.bind(
getERC1155BalanceOf:
this.assetsContractController.getERC1155BalanceOf.bind(
this.assetsContractController,
),
getERC1155TokenURI: this.assetsContractController.getERC1155TokenURI.bind(
getERC1155TokenURI:
this.assetsContractController.getERC1155TokenURI.bind(
this.assetsContractController,
),
onCollectibleAdded: ({ address, symbol, tokenId, standard, source }) =>
@ -327,14 +334,16 @@ export default class MetamaskController extends EventEmitter {
{
onCollectiblesStateChange: (listener) =>
this.collectiblesController.subscribe(listener),
onPreferencesStateChange: this.preferencesController.store.subscribe.bind(
onPreferencesStateChange:
this.preferencesController.store.subscribe.bind(
this.preferencesController.store,
),
onNetworkStateChange: this.networkController.store.subscribe.bind(
this.networkController.store,
),
getOpenSeaApiKey: () => this.collectiblesController.openSeaApiKey,
getBalancesInSingleCall: this.assetsContractController.getBalancesInSingleCall.bind(
getBalancesInSingleCall:
this.assetsContractController.getBalancesInSingleCall.bind(
this.assetsContractController,
),
addCollectible: this.collectiblesController.addCollectible.bind(
@ -385,12 +394,12 @@ export default class MetamaskController extends EventEmitter {
this.networkController,
NETWORK_EVENTS.NETWORK_DID_CHANGE,
),
getCurrentNetworkEIP1559Compatibility: this.networkController.getEIP1559Compatibility.bind(
getCurrentNetworkEIP1559Compatibility:
this.networkController.getEIP1559Compatibility.bind(
this.networkController,
),
getCurrentAccountEIP1559Compatibility: this.getCurrentAccountEIP1559Compatibility.bind(
this,
),
getCurrentAccountEIP1559Compatibility:
this.getCurrentAccountEIP1559Compatibility.bind(this),
legacyAPIEndpoint: `${gasApiBaseUrl}/networks/<chain_id>/gasPrices`,
EIP1559APIEndpoint: `${gasApiBaseUrl}/networks/<chain_id>/suggestedGasFees`,
getCurrentNetworkLegacyGasAPICompatibility: () => {
@ -587,7 +596,8 @@ export default class MetamaskController extends EventEmitter {
const accountsMissingIdentities = accounts.filter(
(address) => !identities[address],
);
const keyringTypesWithMissingIdentities = accountsMissingIdentities.map(
const keyringTypesWithMissingIdentities =
accountsMissingIdentities.map(
(address) =>
this.keyringController.getKeyringForAccount(address)?.type,
);
@ -790,12 +800,12 @@ export default class MetamaskController extends EventEmitter {
getProviderConfig: this.networkController.getProviderConfig.bind(
this.networkController,
),
getCurrentNetworkEIP1559Compatibility: this.networkController.getEIP1559Compatibility.bind(
getCurrentNetworkEIP1559Compatibility:
this.networkController.getEIP1559Compatibility.bind(
this.networkController,
),
getCurrentAccountEIP1559Compatibility: this.getCurrentAccountEIP1559Compatibility.bind(
this,
),
getCurrentAccountEIP1559Compatibility:
this.getCurrentAccountEIP1559Compatibility.bind(this),
networkStore: this.networkController.networkStore,
getCurrentChainId: this.networkController.getCurrentChainId.bind(
this.networkController,
@ -813,10 +823,12 @@ export default class MetamaskController extends EventEmitter {
updateEventFragment: this.metaMetricsController.updateEventFragment.bind(
this.metaMetricsController,
),
finalizeEventFragment: this.metaMetricsController.finalizeEventFragment.bind(
finalizeEventFragment:
this.metaMetricsController.finalizeEventFragment.bind(
this.metaMetricsController,
),
getEventFragmentById: this.metaMetricsController.getEventFragmentById.bind(
getEventFragmentById:
this.metaMetricsController.getEventFragmentById.bind(
this.metaMetricsController,
),
trackMetaMetricsEvent: this.metaMetricsController.trackEvent.bind(
@ -824,15 +836,14 @@ export default class MetamaskController extends EventEmitter {
),
getParticipateInMetrics: () =>
this.metaMetricsController.state.participateInMetaMetrics,
getEIP1559GasFeeEstimates: this.gasFeeController.fetchGasFeeEstimates.bind(
this.gasFeeController,
),
getExternalPendingTransactions: this.getExternalPendingTransactions.bind(
this,
),
getEIP1559GasFeeEstimates:
this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController),
getExternalPendingTransactions:
this.getExternalPendingTransactions.bind(this),
getAccountType: this.getAccountType.bind(this),
getDeviceModel: this.getDeviceModel.bind(this),
getTokenStandardAndDetails: this.assetsContractController.getTokenStandardAndDetails.bind(
getTokenStandardAndDetails:
this.assetsContractController.getTokenStandardAndDetails.bind(
this.assetsContractController,
),
});
@ -844,7 +855,8 @@ export default class MetamaskController extends EventEmitter {
status === TRANSACTION_STATUSES.FAILED
) {
const txMeta = this.txController.txStateManager.getTransaction(txId);
const frequentRpcListDetail = this.preferencesController.getFrequentRpcListDetail();
const frequentRpcListDetail =
this.preferencesController.getFrequentRpcListDetail();
let rpcPrefs = {};
if (txMeta.chainId) {
const rpcSettings = frequentRpcListDetail.find(
@ -971,9 +983,8 @@ export default class MetamaskController extends EventEmitter {
getCurrentChainId: this.networkController.getCurrentChainId.bind(
this.networkController,
),
getEIP1559GasFeeEstimates: this.gasFeeController.fetchGasFeeEstimates.bind(
this.gasFeeController,
),
getEIP1559GasFeeEstimates:
this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController),
});
this.smartTransactionsController = new SmartTransactionsController(
{
@ -986,9 +997,8 @@ export default class MetamaskController extends EventEmitter {
getNonceLock: this.txController.nonceTracker.getNonceLock.bind(
this.txController.nonceTracker,
),
confirmExternalTransaction: this.txController.confirmExternalTransaction.bind(
this.txController,
),
confirmExternalTransaction:
this.txController.confirmExternalTransaction.bind(this.txController),
provider: this.provider,
trackMetaMetricsEvent: this.metaMetricsController.trackEvent.bind(
this.metaMetricsController,
@ -1065,8 +1075,8 @@ export default class MetamaskController extends EventEmitter {
CurrencyController: this.currencyRateController,
AlertController: this.alertController.store,
OnboardingController: this.onboardingController.store,
IncomingTransactionsController: this.incomingTransactionsController
.store,
IncomingTransactionsController:
this.incomingTransactionsController.store,
PermissionController: this.permissionController,
PermissionLogController: this.permissionLogController.store,
SubjectMetadataController: this.subjectMetadataController,
@ -1353,7 +1363,8 @@ export default class MetamaskController extends EventEmitter {
{ suppressUnauthorizedError = true } = {},
) => {
if (origin === ORIGIN_METAMASK) {
const selectedAddress = this.preferencesController.getSelectedAddress();
const selectedAddress =
this.preferencesController.getSelectedAddress();
return selectedAddress ? [selectedAddress] : [];
} else if (this.isUnlocked()) {
return await this.getPermittedAccounts(origin, {
@ -1381,9 +1392,8 @@ export default class MetamaskController extends EventEmitter {
},
})[0],
};
const providerProxy = this.networkController.initializeProvider(
providerOpts,
);
const providerProxy =
this.networkController.initializeProvider(providerOpts);
return providerProxy;
}
@ -1525,7 +1535,8 @@ export default class MetamaskController extends EventEmitter {
setUseTokenDetection: preferencesController.setUseTokenDetection.bind(
preferencesController,
),
setUseCollectibleDetection: preferencesController.setUseCollectibleDetection.bind(
setUseCollectibleDetection:
preferencesController.setUseCollectibleDetection.bind(
preferencesController,
),
setOpenSeaEnabled: preferencesController.setOpenSeaEnabled.bind(
@ -1534,7 +1545,8 @@ export default class MetamaskController extends EventEmitter {
setIpfsGateway: preferencesController.setIpfsGateway.bind(
preferencesController,
),
setParticipateInMetaMetrics: metaMetricsController.setParticipateInMetaMetrics.bind(
setParticipateInMetaMetrics:
metaMetricsController.setParticipateInMetaMetrics.bind(
metaMetricsController,
),
setCurrentLocale: preferencesController.setCurrentLocale.bind(
@ -1559,32 +1571,24 @@ export default class MetamaskController extends EventEmitter {
forgetDevice: this.forgetDevice.bind(this),
checkHardwareStatus: this.checkHardwareStatus.bind(this),
unlockHardwareWalletAccount: this.unlockHardwareWalletAccount.bind(this),
setLedgerTransportPreference: this.setLedgerTransportPreference.bind(
this,
),
attemptLedgerTransportCreation: this.attemptLedgerTransportCreation.bind(
this,
),
establishLedgerTransportPreference: this.establishLedgerTransportPreference.bind(
this,
),
setLedgerTransportPreference:
this.setLedgerTransportPreference.bind(this),
attemptLedgerTransportCreation:
this.attemptLedgerTransportCreation.bind(this),
establishLedgerTransportPreference:
this.establishLedgerTransportPreference.bind(this),
// qr hardware devices
submitQRHardwareCryptoHDKey: qrHardwareKeyring.submitCryptoHDKey.bind(
qrHardwareKeyring,
),
submitQRHardwareCryptoAccount: qrHardwareKeyring.submitCryptoAccount.bind(
qrHardwareKeyring,
),
cancelSyncQRHardware: qrHardwareKeyring.cancelSync.bind(
qrHardwareKeyring,
),
submitQRHardwareSignature: qrHardwareKeyring.submitSignature.bind(
qrHardwareKeyring,
),
cancelQRHardwareSignRequest: qrHardwareKeyring.cancelSignRequest.bind(
qrHardwareKeyring,
),
submitQRHardwareCryptoHDKey:
qrHardwareKeyring.submitCryptoHDKey.bind(qrHardwareKeyring),
submitQRHardwareCryptoAccount:
qrHardwareKeyring.submitCryptoAccount.bind(qrHardwareKeyring),
cancelSyncQRHardware:
qrHardwareKeyring.cancelSync.bind(qrHardwareKeyring),
submitQRHardwareSignature:
qrHardwareKeyring.submitSignature.bind(qrHardwareKeyring),
cancelQRHardwareSignRequest:
qrHardwareKeyring.cancelSignRequest.bind(qrHardwareKeyring),
// mobile
fetchInfoToSync: this.fetchInfoToSync.bind(this),
@ -1594,12 +1598,10 @@ export default class MetamaskController extends EventEmitter {
verifyPassword: this.verifyPassword.bind(this),
// network management
setProviderType: networkController.setProviderType.bind(
networkController,
),
rollbackToPreviousProvider: networkController.rollbackToPreviousProvider.bind(
networkController,
),
setProviderType:
networkController.setProviderType.bind(networkController),
rollbackToPreviousProvider:
networkController.rollbackToPreviousProvider.bind(networkController),
setCustomRpc: this.setCustomRpc.bind(this),
updateAndSetCustomRpc: this.updateAndSetCustomRpc.bind(this),
delCustomRpc: this.delCustomRpc.bind(this),
@ -1610,12 +1612,10 @@ export default class MetamaskController extends EventEmitter {
preferencesController,
),
addToken: tokensController.addToken.bind(tokensController),
rejectWatchAsset: tokensController.rejectWatchAsset.bind(
tokensController,
),
acceptWatchAsset: tokensController.acceptWatchAsset.bind(
tokensController,
),
rejectWatchAsset:
tokensController.rejectWatchAsset.bind(tokensController),
acceptWatchAsset:
tokensController.acceptWatchAsset.bind(tokensController),
updateTokenType: tokensController.updateTokenType.bind(tokensController),
setAccountLabel: preferencesController.setAccountLabel.bind(
preferencesController,
@ -1630,7 +1630,8 @@ export default class MetamaskController extends EventEmitter {
addKnownMethodData: preferencesController.addKnownMethodData.bind(
preferencesController,
),
setDismissSeedBackUpReminder: preferencesController.setDismissSeedBackUpReminder.bind(
setDismissSeedBackUpReminder:
preferencesController.setDismissSeedBackUpReminder.bind(
preferencesController,
),
setAdvancedGasFee: preferencesController.setAdvancedGasFee.bind(
@ -1640,7 +1641,8 @@ export default class MetamaskController extends EventEmitter {
preferencesController,
),
setTheme: preferencesController.setTheme.bind(preferencesController),
setCustomNetworkListEnabled: preferencesController.setCustomNetworkListEnabled.bind(
setCustomNetworkListEnabled:
preferencesController.setCustomNetworkListEnabled.bind(
preferencesController,
),
// AssetsContractController
@ -1651,11 +1653,13 @@ export default class MetamaskController extends EventEmitter {
collectiblesController,
),
addCollectibleVerifyOwnership: collectiblesController.addCollectibleVerifyOwnership.bind(
addCollectibleVerifyOwnership:
collectiblesController.addCollectibleVerifyOwnership.bind(
collectiblesController,
),
removeAndIgnoreCollectible: collectiblesController.removeAndIgnoreCollectible.bind(
removeAndIgnoreCollectible:
collectiblesController.removeAndIgnoreCollectible.bind(
collectiblesController,
),
@ -1663,11 +1667,13 @@ export default class MetamaskController extends EventEmitter {
collectiblesController,
),
checkAndUpdateAllCollectiblesOwnershipStatus: collectiblesController.checkAndUpdateAllCollectiblesOwnershipStatus.bind(
checkAndUpdateAllCollectiblesOwnershipStatus:
collectiblesController.checkAndUpdateAllCollectiblesOwnershipStatus.bind(
collectiblesController,
),
checkAndUpdateSingleCollectibleOwnershipStatus: collectiblesController.checkAndUpdateSingleCollectibleOwnershipStatus.bind(
checkAndUpdateSingleCollectibleOwnershipStatus:
collectiblesController.checkAndUpdateSingleCollectibleOwnershipStatus.bind(
collectiblesController,
),
@ -1682,37 +1688,41 @@ export default class MetamaskController extends EventEmitter {
),
// AppStateController
setLastActiveTime: appStateController.setLastActiveTime.bind(
appStateController,
),
setDefaultHomeActiveTabName: appStateController.setDefaultHomeActiveTabName.bind(
setLastActiveTime:
appStateController.setLastActiveTime.bind(appStateController),
setDefaultHomeActiveTabName:
appStateController.setDefaultHomeActiveTabName.bind(appStateController),
setConnectedStatusPopoverHasBeenShown:
appStateController.setConnectedStatusPopoverHasBeenShown.bind(
appStateController,
),
setConnectedStatusPopoverHasBeenShown: appStateController.setConnectedStatusPopoverHasBeenShown.bind(
setRecoveryPhraseReminderHasBeenShown:
appStateController.setRecoveryPhraseReminderHasBeenShown.bind(
appStateController,
),
setRecoveryPhraseReminderHasBeenShown: appStateController.setRecoveryPhraseReminderHasBeenShown.bind(
setRecoveryPhraseReminderLastShown:
appStateController.setRecoveryPhraseReminderLastShown.bind(
appStateController,
),
setRecoveryPhraseReminderLastShown: appStateController.setRecoveryPhraseReminderLastShown.bind(
setShowTestnetMessageInDropdown:
appStateController.setShowTestnetMessageInDropdown.bind(
appStateController,
),
setShowTestnetMessageInDropdown: appStateController.setShowTestnetMessageInDropdown.bind(
setCollectiblesDetectionNoticeDismissed:
appStateController.setCollectiblesDetectionNoticeDismissed.bind(
appStateController,
),
setCollectiblesDetectionNoticeDismissed: appStateController.setCollectiblesDetectionNoticeDismissed.bind(
setEnableEIP1559V2NoticeDismissed:
appStateController.setEnableEIP1559V2NoticeDismissed.bind(
appStateController,
),
setEnableEIP1559V2NoticeDismissed: appStateController.setEnableEIP1559V2NoticeDismissed.bind(
appStateController,
),
updateCollectibleDropDownState: appStateController.updateCollectibleDropDownState.bind(
updateCollectibleDropDownState:
appStateController.updateCollectibleDropDownState.bind(
appStateController,
),
// EnsController
tryReverseResolveAddress: ensController.reverseResolveAddress.bind(
ensController,
),
tryReverseResolveAddress:
ensController.reverseResolveAddress.bind(ensController),
// KeyringController
setLocked: this.setLocked.bind(this),
@ -1723,44 +1733,34 @@ export default class MetamaskController extends EventEmitter {
// txController
cancelTransaction: txController.cancelTransaction.bind(txController),
updateTransaction: txController.updateTransaction.bind(txController),
updateAndApproveTransaction: txController.updateAndApproveTransaction.bind(
txController,
),
approveTransactionsWithSameNonce: txController.approveTransactionsWithSameNonce.bind(
txController,
),
updateAndApproveTransaction:
txController.updateAndApproveTransaction.bind(txController),
approveTransactionsWithSameNonce:
txController.approveTransactionsWithSameNonce.bind(txController),
createCancelTransaction: this.createCancelTransaction.bind(this),
createSpeedUpTransaction: this.createSpeedUpTransaction.bind(this),
estimateGas: this.estimateGas.bind(this),
getNextNonce: this.getNextNonce.bind(this),
addUnapprovedTransaction: txController.addUnapprovedTransaction.bind(
txController,
),
createTransactionEventFragment: txController.createTransactionEventFragment.bind(
txController,
),
addUnapprovedTransaction:
txController.addUnapprovedTransaction.bind(txController),
createTransactionEventFragment:
txController.createTransactionEventFragment.bind(txController),
getTransactions: txController.getTransactions.bind(txController),
updateEditableParams: txController.updateEditableParams.bind(
txController,
),
updateTransactionGasFees: txController.updateTransactionGasFees.bind(
txController,
),
updateTransactionSendFlowHistory: txController.updateTransactionSendFlowHistory.bind(
txController,
),
updateEditableParams:
txController.updateEditableParams.bind(txController),
updateTransactionGasFees:
txController.updateTransactionGasFees.bind(txController),
updateTransactionSendFlowHistory:
txController.updateTransactionSendFlowHistory.bind(txController),
updateSwapApprovalTransaction: txController.updateSwapApprovalTransaction.bind(
txController,
),
updateSwapTransaction: txController.updateSwapTransaction.bind(
txController,
),
updateSwapApprovalTransaction:
txController.updateSwapApprovalTransaction.bind(txController),
updateSwapTransaction:
txController.updateSwapTransaction.bind(txController),
updatePreviousGasParams: txController.updatePreviousGasParams.bind(
txController,
),
updatePreviousGasParams:
txController.updatePreviousGasParams.bind(txController),
// messageManager
signMessage: this.signMessage.bind(this),
cancelMessage: this.cancelMessage.bind(this),
@ -1783,53 +1783,45 @@ export default class MetamaskController extends EventEmitter {
cancelEncryptionPublicKey: this.cancelEncryptionPublicKey.bind(this),
// onboarding controller
setSeedPhraseBackedUp: onboardingController.setSeedPhraseBackedUp.bind(
onboardingController,
),
completeOnboarding: onboardingController.completeOnboarding.bind(
onboardingController,
),
setFirstTimeFlowType: onboardingController.setFirstTimeFlowType.bind(
onboardingController,
),
setSeedPhraseBackedUp:
onboardingController.setSeedPhraseBackedUp.bind(onboardingController),
completeOnboarding:
onboardingController.completeOnboarding.bind(onboardingController),
setFirstTimeFlowType:
onboardingController.setFirstTimeFlowType.bind(onboardingController),
// alert controller
setAlertEnabledness: alertController.setAlertEnabledness.bind(
alertController,
),
setUnconnectedAccountAlertShown: alertController.setUnconnectedAccountAlertShown.bind(
alertController,
),
setWeb3ShimUsageAlertDismissed: alertController.setWeb3ShimUsageAlertDismissed.bind(
alertController,
),
setAlertEnabledness:
alertController.setAlertEnabledness.bind(alertController),
setUnconnectedAccountAlertShown:
alertController.setUnconnectedAccountAlertShown.bind(alertController),
setWeb3ShimUsageAlertDismissed:
alertController.setWeb3ShimUsageAlertDismissed.bind(alertController),
// 3Box
setThreeBoxSyncingPermission: threeBoxController.setThreeBoxSyncingPermission.bind(
threeBoxController,
),
restoreFromThreeBox: threeBoxController.restoreFromThreeBox.bind(
threeBoxController,
),
setShowRestorePromptToFalse: threeBoxController.setShowRestorePromptToFalse.bind(
threeBoxController,
),
getThreeBoxLastUpdated: threeBoxController.getLastUpdated.bind(
threeBoxController,
),
turnThreeBoxSyncingOn: threeBoxController.turnThreeBoxSyncingOn.bind(
setThreeBoxSyncingPermission:
threeBoxController.setThreeBoxSyncingPermission.bind(
threeBoxController,
),
restoreFromThreeBox:
threeBoxController.restoreFromThreeBox.bind(threeBoxController),
setShowRestorePromptToFalse:
threeBoxController.setShowRestorePromptToFalse.bind(threeBoxController),
getThreeBoxLastUpdated:
threeBoxController.getLastUpdated.bind(threeBoxController),
turnThreeBoxSyncingOn:
threeBoxController.turnThreeBoxSyncingOn.bind(threeBoxController),
initializeThreeBox: this.initializeThreeBox.bind(this),
// permissions
removePermissionsFor: permissionController.revokePermissions.bind(
permissionController,
),
approvePermissionsRequest: permissionController.acceptPermissionsRequest.bind(
removePermissionsFor:
permissionController.revokePermissions.bind(permissionController),
approvePermissionsRequest:
permissionController.acceptPermissionsRequest.bind(
permissionController,
),
rejectPermissionsRequest: permissionController.rejectPermissionsRequest.bind(
rejectPermissionsRequest:
permissionController.rejectPermissionsRequest.bind(
permissionController,
),
...getPermissionBackgroundApiMethods(permissionController),
@ -1847,79 +1839,70 @@ export default class MetamaskController extends EventEmitter {
///: END:ONLY_INCLUDE_IN
// swaps
fetchAndSetQuotes: swapsController.fetchAndSetQuotes.bind(
swapsController,
),
setSelectedQuoteAggId: swapsController.setSelectedQuoteAggId.bind(
swapsController,
),
fetchAndSetQuotes:
swapsController.fetchAndSetQuotes.bind(swapsController),
setSelectedQuoteAggId:
swapsController.setSelectedQuoteAggId.bind(swapsController),
resetSwapsState: swapsController.resetSwapsState.bind(swapsController),
setSwapsTokens: swapsController.setSwapsTokens.bind(swapsController),
clearSwapsQuotes: swapsController.clearSwapsQuotes.bind(swapsController),
setApproveTxId: swapsController.setApproveTxId.bind(swapsController),
setTradeTxId: swapsController.setTradeTxId.bind(swapsController),
setSwapsTxGasPrice: swapsController.setSwapsTxGasPrice.bind(
swapsController,
),
setSwapsTxGasLimit: swapsController.setSwapsTxGasLimit.bind(
swapsController,
),
setSwapsTxMaxFeePerGas: swapsController.setSwapsTxMaxFeePerGas.bind(
swapsController,
),
setSwapsTxMaxFeePriorityPerGas: swapsController.setSwapsTxMaxFeePriorityPerGas.bind(
swapsController,
),
safeRefetchQuotes: swapsController.safeRefetchQuotes.bind(
swapsController,
),
stopPollingForQuotes: swapsController.stopPollingForQuotes.bind(
swapsController,
),
setBackgroundSwapRouteState: swapsController.setBackgroundSwapRouteState.bind(
swapsController,
),
resetPostFetchState: swapsController.resetPostFetchState.bind(
swapsController,
),
setSwapsTxGasPrice:
swapsController.setSwapsTxGasPrice.bind(swapsController),
setSwapsTxGasLimit:
swapsController.setSwapsTxGasLimit.bind(swapsController),
setSwapsTxMaxFeePerGas:
swapsController.setSwapsTxMaxFeePerGas.bind(swapsController),
setSwapsTxMaxFeePriorityPerGas:
swapsController.setSwapsTxMaxFeePriorityPerGas.bind(swapsController),
safeRefetchQuotes:
swapsController.safeRefetchQuotes.bind(swapsController),
stopPollingForQuotes:
swapsController.stopPollingForQuotes.bind(swapsController),
setBackgroundSwapRouteState:
swapsController.setBackgroundSwapRouteState.bind(swapsController),
resetPostFetchState:
swapsController.resetPostFetchState.bind(swapsController),
setSwapsErrorKey: swapsController.setSwapsErrorKey.bind(swapsController),
setInitialGasEstimate: swapsController.setInitialGasEstimate.bind(
swapsController,
),
setCustomApproveTxData: swapsController.setCustomApproveTxData.bind(
swapsController,
),
setInitialGasEstimate:
swapsController.setInitialGasEstimate.bind(swapsController),
setCustomApproveTxData:
swapsController.setCustomApproveTxData.bind(swapsController),
setSwapsLiveness: swapsController.setSwapsLiveness.bind(swapsController),
setSwapsFeatureFlags: swapsController.setSwapsFeatureFlags.bind(
swapsController,
),
setSwapsUserFeeLevel: swapsController.setSwapsUserFeeLevel.bind(
swapsController,
),
setSwapsQuotesPollingLimitEnabled: swapsController.setSwapsQuotesPollingLimitEnabled.bind(
swapsController,
),
setSwapsFeatureFlags:
swapsController.setSwapsFeatureFlags.bind(swapsController),
setSwapsUserFeeLevel:
swapsController.setSwapsUserFeeLevel.bind(swapsController),
setSwapsQuotesPollingLimitEnabled:
swapsController.setSwapsQuotesPollingLimitEnabled.bind(swapsController),
// Smart Transactions
setSmartTransactionsOptInStatus: smartTransactionsController.setOptInState.bind(
setSmartTransactionsOptInStatus:
smartTransactionsController.setOptInState.bind(
smartTransactionsController,
),
fetchSmartTransactionFees: smartTransactionsController.getFees.bind(
smartTransactionsController,
),
submitSignedTransactions: smartTransactionsController.submitSignedTransactions.bind(
submitSignedTransactions:
smartTransactionsController.submitSignedTransactions.bind(
smartTransactionsController,
),
cancelSmartTransaction: smartTransactionsController.cancelSmartTransaction.bind(
cancelSmartTransaction:
smartTransactionsController.cancelSmartTransaction.bind(
smartTransactionsController,
),
fetchSmartTransactionsLiveness: smartTransactionsController.fetchLiveness.bind(
fetchSmartTransactionsLiveness:
smartTransactionsController.fetchLiveness.bind(
smartTransactionsController,
),
updateSmartTransaction: smartTransactionsController.updateSmartTransaction.bind(
updateSmartTransaction:
smartTransactionsController.updateSmartTransaction.bind(
smartTransactionsController,
),
setStatusRefreshInterval: smartTransactionsController.setStatusRefreshInterval.bind(
setStatusRefreshInterval:
smartTransactionsController.setStatusRefreshInterval.bind(
smartTransactionsController,
),
@ -1941,9 +1924,8 @@ export default class MetamaskController extends EventEmitter {
),
// approval controller
resolvePendingApproval: approvalController.accept.bind(
approvalController,
),
resolvePendingApproval:
approvalController.accept.bind(approvalController),
rejectPendingApproval: async (id, error) => {
approvalController.reject(
id,
@ -1957,25 +1939,22 @@ export default class MetamaskController extends EventEmitter {
),
// GasFeeController
getGasFeeEstimatesAndStartPolling: gasFeeController.getGasFeeEstimatesAndStartPolling.bind(
getGasFeeEstimatesAndStartPolling:
gasFeeController.getGasFeeEstimatesAndStartPolling.bind(
gasFeeController,
),
disconnectGasFeeEstimatePoller: gasFeeController.disconnectPoller.bind(
gasFeeController,
),
disconnectGasFeeEstimatePoller:
gasFeeController.disconnectPoller.bind(gasFeeController),
getGasFeeTimeEstimate: gasFeeController.getTimeEstimate.bind(
gasFeeController,
),
getGasFeeTimeEstimate:
gasFeeController.getTimeEstimate.bind(gasFeeController),
addPollingTokenToAppState: appStateController.addPollingToken.bind(
appStateController,
),
addPollingTokenToAppState:
appStateController.addPollingToken.bind(appStateController),
removePollingTokenFromAppState: appStateController.removePollingToken.bind(
appStateController,
),
removePollingTokenFromAppState:
appStateController.removePollingToken.bind(appStateController),
// DetectTokenController
detectNewTokens: detectTokensController.detectNewTokens.bind(
@ -1990,19 +1969,20 @@ export default class MetamaskController extends EventEmitter {
: null,
/** Token Detection V2 */
addDetectedTokens: tokensController.addDetectedTokens.bind(
tokensController,
),
addDetectedTokens:
tokensController.addDetectedTokens.bind(tokensController),
addImportedTokens: tokensController.addTokens.bind(tokensController),
ignoreTokens: tokensController.ignoreTokens.bind(tokensController),
getBalancesInSingleCall: assetsContractController.getBalancesInSingleCall.bind(
getBalancesInSingleCall:
assetsContractController.getBalancesInSingleCall.bind(
assetsContractController,
),
};
}
async getTokenStandardAndDetails(address, userAddress, tokenId) {
const details = await this.assetsContractController.getTokenStandardAndDetails(
const details =
await this.assetsContractController.getTokenStandardAndDetails(
address,
userAddress,
tokenId,
@ -2159,9 +2139,8 @@ export default class MetamaskController extends EventEmitter {
ethQuery,
);
const primaryKeyring = keyringController.getKeyringsByType(
'HD Key Tree',
)[0];
const primaryKeyring =
keyringController.getKeyringsByType('HD Key Tree')[0];
if (!primaryKeyring) {
throw new Error('MetamaskController - No HD Key Tree found');
}
@ -2186,7 +2165,8 @@ export default class MetamaskController extends EventEmitter {
// keyring's iframe and have the setting initialized properly
// Optimistically called to not block MetaMask login due to
// Ledger Keyring GitHub downtime
const transportPreference = this.preferencesController.getLedgerTransportPreference();
const transportPreference =
this.preferencesController.getLedgerTransportPreference();
this.setLedgerTransportPreference(transportPreference);
// set new identities
@ -2280,12 +2260,10 @@ export default class MetamaskController extends EventEmitter {
});
// Accounts
const hdKeyring = this.keyringController.getKeyringsByType(
'HD Key Tree',
)[0];
const simpleKeyPairKeyrings = this.keyringController.getKeyringsByType(
'Simple Key Pair',
);
const hdKeyring =
this.keyringController.getKeyringsByType('HD Key Tree')[0];
const simpleKeyPairKeyrings =
this.keyringController.getKeyringsByType('Simple Key Pair');
const hdAccounts = await hdKeyring.getAccounts();
const simpleKeyPairKeyringAccounts = await Promise.all(
simpleKeyPairKeyrings.map((keyring) => keyring.getAccounts()),
@ -2342,7 +2320,8 @@ export default class MetamaskController extends EventEmitter {
}
try {
const threeBoxSyncingAllowed = this.threeBoxController.getThreeBoxSyncingState();
const threeBoxSyncingAllowed =
this.threeBoxController.getThreeBoxSyncingState();
if (threeBoxSyncingAllowed && !this.threeBoxController.box) {
// 'await' intentionally omitted to avoid waiting for initialization
this.threeBoxController.init();
@ -2358,7 +2337,8 @@ export default class MetamaskController extends EventEmitter {
// keyring's iframe and have the setting initialized properly
// Optimistically called to not block MetaMask login due to
// Ledger Keyring GitHub downtime
const transportPreference = this.preferencesController.getLedgerTransportPreference();
const transportPreference =
this.preferencesController.getLedgerTransportPreference();
this.setLedgerTransportPreference(transportPreference);
@ -2454,7 +2434,8 @@ export default class MetamaskController extends EventEmitter {
}
async establishLedgerTransportPreference() {
const transportPreference = this.preferencesController.getLedgerTransportPreference();
const transportPreference =
this.preferencesController.getLedgerTransportPreference();
return await this.setLedgerTransportPreference(transportPreference);
}
@ -2626,9 +2607,8 @@ export default class MetamaskController extends EventEmitter {
* @returns {} keyState
*/
async addNewAccount() {
const primaryKeyring = this.keyringController.getKeyringsByType(
'HD Key Tree',
)[0];
const primaryKeyring =
this.keyringController.getKeyringsByType('HD Key Tree')[0];
if (!primaryKeyring) {
throw new Error('MetamaskController - No HD Key Tree found');
}
@ -2661,9 +2641,8 @@ export default class MetamaskController extends EventEmitter {
* encoded as an array of UTF-8 bytes.
*/
async verifySeedPhrase() {
const primaryKeyring = this.keyringController.getKeyringsByType(
'HD Key Tree',
)[0];
const primaryKeyring =
this.keyringController.getKeyringsByType('HD Key Tree')[0];
if (!primaryKeyring) {
throw new Error('MetamaskController - No HD Key Tree found');
}
@ -3098,7 +3077,8 @@ export default class MetamaskController extends EventEmitter {
}
default: {
const promise = this.encryptionPublicKeyManager.addUnapprovedMessageAsync(
const promise =
this.encryptionPublicKeyManager.addUnapprovedMessageAsync(
msgParams,
req,
);
@ -3640,7 +3620,8 @@ export default class MetamaskController extends EventEmitter {
subjectType,
// Miscellaneous
addSubjectMetadata: this.subjectMetadataController.addSubjectMetadata.bind(
addSubjectMetadata:
this.subjectMetadataController.addSubjectMetadata.bind(
this.subjectMetadataController,
),
getProviderState: this.getProviderState.bind(this),
@ -3650,7 +3631,8 @@ export default class MetamaskController extends EventEmitter {
handleWatchAssetRequest: this.tokensController.watchAsset.bind(
this.tokensController,
),
requestUserApproval: this.approvalController.addAndShowApprovalRequest.bind(
requestUserApproval:
this.approvalController.addAndShowApprovalRequest.bind(
this.approvalController,
),
sendMetrics: this.metaMetricsController.trackEvent.bind(
@ -3667,12 +3649,14 @@ export default class MetamaskController extends EventEmitter {
this.permissionController,
origin,
),
requestAccountsPermission: this.permissionController.requestPermissions.bind(
requestAccountsPermission:
this.permissionController.requestPermissions.bind(
this.permissionController,
{ origin },
{ eth_accounts: {} },
),
requestPermissionsForOrigin: this.permissionController.requestPermissions.bind(
requestPermissionsForOrigin:
this.permissionController.requestPermissions.bind(
this.permissionController,
{ origin },
),
@ -3718,7 +3702,8 @@ export default class MetamaskController extends EventEmitter {
getWeb3ShimUsageState: this.alertController.getWeb3ShimUsageState.bind(
this.alertController,
),
setWeb3ShimUsageRecorded: this.alertController.setWeb3ShimUsageRecorded.bind(
setWeb3ShimUsageRecorded:
this.alertController.setWeb3ShimUsageRecorded.bind(
this.alertController,
),
}),
@ -3736,9 +3721,8 @@ export default class MetamaskController extends EventEmitter {
origin,
),
requestPermissions: async (requestedPermissions) => {
const [
approvedPermissions,
] = await this.permissionController.requestPermissions(
const [approvedPermissions] =
await this.permissionController.requestPermissions(
{ origin },
requestedPermissions,
);
@ -4031,10 +4015,8 @@ export default class MetamaskController extends EventEmitter {
* @returns {Promise<number>}
*/
async getPendingNonce(address) {
const {
nonceDetails,
releaseLock,
} = await this.txController.nonceTracker.getNonceLock(address);
const { nonceDetails, releaseLock } =
await this.txController.nonceTracker.getNonceLock(address);
const pendingNonce = nonceDetails.params.highestSuggested;
releaseLock();
@ -4150,7 +4132,8 @@ export default class MetamaskController extends EventEmitter {
nickname = '',
rpcPrefs = {},
) {
const frequentRpcListDetail = this.preferencesController.getFrequentRpcListDetail();
const frequentRpcListDetail =
this.preferencesController.getFrequentRpcListDetail();
const rpcSettings = frequentRpcListDetail.find(
(rpc) => rpcUrl === rpc.rpcUrl,
);
@ -4199,7 +4182,8 @@ export default class MetamaskController extends EventEmitter {
* @returns {object} rpcInfo found in the frequentRpcList
*/
findCustomRpcBy(rpcInfo) {
const frequentRpcListDetail = this.preferencesController.getFrequentRpcListDetail();
const frequentRpcListDetail =
this.preferencesController.getFrequentRpcListDetail();
for (const existingRpcInfo of frequentRpcListDetail) {
for (const key of Object.keys(rpcInfo)) {
if (existingRpcInfo[key] === rpcInfo[key]) {
@ -4220,10 +4204,10 @@ export default class MetamaskController extends EventEmitter {
* @param {string} transportType - The Ledger transport type.
*/
async setLedgerTransportPreference(transportType) {
const currentValue = this.preferencesController.getLedgerTransportPreference();
const newValue = this.preferencesController.setLedgerTransportPreference(
transportType,
);
const currentValue =
this.preferencesController.getLedgerTransportPreference();
const newValue =
this.preferencesController.setLedgerTransportPreference(transportType);
const keyring = await this.getKeyringForDevice(DEVICE_NAMES.LEDGER);
if (keyring?.updateTransportMethod) {
@ -4289,9 +4273,8 @@ export default class MetamaskController extends EventEmitter {
onEnvironmentTypeClosed(environmentType) {
const appStatePollingTokenType =
POLLING_TOKEN_ENVIRONMENT_TYPES[environmentType];
const pollingTokensToDisconnect = this.appStateController.store.getState()[
appStatePollingTokenType
];
const pollingTokensToDisconnect =
this.appStateController.store.getState()[appStatePollingTokenType];
pollingTokensToDisconnect.forEach((pollingToken) => {
this.gasFeeController.disconnectPoller(pollingToken);
this.appStateController.removePollingToken(

@ -221,7 +221,8 @@ describe('MetaMaskController', function () {
});
it('adds private key to keyrings in KeyringController', async function () {
const simpleKeyrings = metamaskController.keyringController.getKeyringsByType(
const simpleKeyrings =
metamaskController.keyringController.getKeyringsByType(
'Simple Key Pair',
);
const privKeyBuffer = simpleKeyrings[0].wallets[0].privateKey;
@ -234,7 +235,8 @@ describe('MetaMaskController', function () {
});
it('adds 1 account', async function () {
const keyringAccounts = await metamaskController.keyringController.getAccounts();
const keyringAccounts =
await metamaskController.keyringController.getAccounts();
assert.equal(
keyringAccounts[keyringAccounts.length - 1],
'0xe18035bf8712672935fdb4e5e431b1a0183d2dfc',
@ -259,7 +261,8 @@ describe('MetaMaskController', function () {
const identities = Object.keys(
metamaskController.preferencesController.store.getState().identities,
);
const addresses = await metamaskController.keyringController.getAccounts();
const addresses =
await metamaskController.keyringController.getAccounts();
identities.forEach((identity) => {
assert.ok(
@ -486,7 +489,8 @@ describe('MetaMaskController', function () {
});
it('changes preferences controller select address', function () {
const preferenceControllerState = metamaskController.preferencesController.store.getState();
const preferenceControllerState =
metamaskController.preferencesController.store.getState();
assert.equal(preferenceControllerState.selectedAddress, address);
});
@ -517,7 +521,8 @@ describe('MetaMaskController', function () {
await metamaskController
.connectHardware(DEVICE_NAMES.TREZOR, 0)
.catch(() => null);
const keyrings = await metamaskController.keyringController.getKeyringsByType(
const keyrings =
await metamaskController.keyringController.getKeyringsByType(
KEYRING_TYPES.TREZOR,
);
assert.deepEqual(
@ -532,7 +537,8 @@ describe('MetaMaskController', function () {
await metamaskController
.connectHardware(DEVICE_NAMES.LEDGER, 0)
.catch(() => null);
const keyrings = await metamaskController.keyringController.getKeyringsByType(
const keyrings =
await metamaskController.keyringController.getKeyringsByType(
KEYRING_TYPES.LEDGER,
);
assert.deepEqual(
@ -586,7 +592,8 @@ describe('MetaMaskController', function () {
.connectHardware(DEVICE_NAMES.TREZOR, 0)
.catch(() => null);
await metamaskController.forgetDevice(DEVICE_NAMES.TREZOR);
const keyrings = await metamaskController.keyringController.getKeyringsByType(
const keyrings =
await metamaskController.keyringController.getKeyringsByType(
KEYRING_TYPES.TREZOR,
);
@ -645,7 +652,8 @@ describe('MetaMaskController', function () {
});
it('should set unlockedAccount in the keyring', async function () {
const keyrings = await metamaskController.keyringController.getKeyringsByType(
const keyrings =
await metamaskController.keyringController.getKeyringsByType(
KEYRING_TYPES.TREZOR,
);
assert.equal(keyrings[0].unlockedAccount, accountToUnlock);
@ -690,7 +698,8 @@ describe('MetaMaskController', function () {
CUSTOM_RPC_URL,
CUSTOM_RPC_CHAIN_ID,
);
const networkControllerState = metamaskController.networkController.store.getState();
const networkControllerState =
metamaskController.networkController.store.getState();
assert.equal(networkControllerState.provider.rpcUrl, CUSTOM_RPC_URL);
});
});
@ -726,7 +735,8 @@ describe('MetaMaskController', function () {
it('#addNewAccount', async function () {
await metamaskController.addNewAccount();
const getAccounts = await metamaskController.keyringController.getAccounts();
const getAccounts =
await metamaskController.keyringController.getAccounts();
assert.equal(getAccounts.length, 2);
});
});
@ -959,7 +969,8 @@ describe('MetaMaskController', function () {
// handle the promise so it doesn't throw an unhandledRejection
promise.then(noop).catch(noop);
metamaskPersonalMsgs = metamaskController.personalMessageManager.getUnapprovedMsgs();
metamaskPersonalMsgs =
metamaskController.personalMessageManager.getUnapprovedMsgs();
personalMessages = metamaskController.personalMessageManager.messages;
msgId = Object.keys(metamaskPersonalMsgs)[0];
personalMessages[0].msgParams.metamaskId = parseInt(msgId, 10);
@ -1250,9 +1261,8 @@ describe('MetaMaskController', function () {
describe('markNotificationsAsRead', function () {
it('marks the notification as read', function () {
metamaskController.markNotificationsAsRead([NOTIFICATION_ID]);
const readNotification = metamaskController.getState().notifications[
NOTIFICATION_ID
];
const readNotification =
metamaskController.getState().notifications[NOTIFICATION_ID];
assert.notEqual(readNotification.readDate, null);
});
});

@ -18,11 +18,8 @@ const storage = {
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
it('should add submittedTime key on the txMeta if appropriate', async () => {
const migratedData = await migration22.migrate(storage);
const [
txMeta1,
txMeta2,
txMeta3,
] = migratedData.data.TransactionController.transactions;
const [txMeta1, txMeta2, txMeta3] =
migratedData.data.TransactionController.transactions;
expect(migratedData.meta.version).toStrictEqual(22);
// should have written a submitted time

@ -33,7 +33,8 @@ function transformState(state) {
delete frequentRpcListDetail[index].chainId;
}
});
newState.PreferencesController.frequentRpcListDetail = frequentRpcListDetail;
newState.PreferencesController.frequentRpcListDetail =
frequentRpcListDetail;
}
}
if (state.NetworkController) {

@ -21,7 +21,8 @@ function transformState(state) {
if (Array.isArray(transactions)) {
transactions.forEach((transaction) => {
if (typeof transaction.metamaskNetworkId === 'number') {
transaction.metamaskNetworkId = transaction.metamaskNetworkId.toString();
transaction.metamaskNetworkId =
transaction.metamaskNetworkId.toString();
}
});
}

@ -18,11 +18,8 @@ export default {
function transformState(state = {}) {
if (state.PreferencesController) {
const {
metaMetricsId,
participateInMetaMetrics,
metaMetricsSendCount,
} = state.PreferencesController;
const { metaMetricsId, participateInMetaMetrics, metaMetricsSendCount } =
state.PreferencesController;
state.MetaMetricsController = state.MetaMetricsController ?? {};
if (metaMetricsId !== undefined) {
@ -31,7 +28,8 @@ function transformState(state = {}) {
}
if (participateInMetaMetrics !== undefined) {
state.MetaMetricsController.participateInMetaMetrics = participateInMetaMetrics;
state.MetaMetricsController.participateInMetaMetrics =
participateInMetaMetrics;
delete state.PreferencesController.participateInMetaMetrics;
}

@ -34,11 +34,8 @@ export default {
function transformState(state = {}) {
if (state.PreferencesController) {
const {
accountTokens,
accountHiddenTokens,
frequentRpcListDetail,
} = state.PreferencesController;
const { accountTokens, accountHiddenTokens, frequentRpcListDetail } =
state.PreferencesController;
const newAccountTokens = {};
const newAccountHiddenTokens = {};

@ -23,12 +23,15 @@ function transformState(state) {
if (
state?.IncomingTransactionsController?.incomingTxLastFetchedBlocksByNetwork
) {
state.IncomingTransactionsController.incomingTxLastFetchedBlockByChainId = mapKeys(
state.IncomingTransactionsController.incomingTxLastFetchedBlocksByNetwork,
state.IncomingTransactionsController.incomingTxLastFetchedBlockByChainId =
mapKeys(
state.IncomingTransactionsController
.incomingTxLastFetchedBlocksByNetwork,
// using optional chaining in case user's state has fetched blocks for
// RPC network types (which don't map to a single chainId). This should
// not be possible, but it's safer
(_, key) => NETWORK_TYPE_TO_ID_MAP[key]?.chainId ?? UNKNOWN_CHAIN_ID_KEY,
(_, key) =>
NETWORK_TYPE_TO_ID_MAP[key]?.chainId ?? UNKNOWN_CHAIN_ID_KEY,
);
// Now that mainnet and test net last fetched blocks are keyed by their
// respective chainIds, we can safely delete anything we had for custom

@ -30,9 +30,8 @@ export default {
PreferencesController.accountTokens[account],
);
chains.forEach((chain) => {
PreferencesController.accountTokens[account][
chain
] = PreferencesController.accountTokens[account][chain].filter(
PreferencesController.accountTokens[account][chain] =
PreferencesController.accountTokens[account][chain].filter(
({ address }) => address,
);
});

@ -95,8 +95,7 @@ describe('migration #64', () => {
s: '0x49f74084dd8c517b305a2e60b39ae9002176a5244cb06de8f9ea3757811f5ec6',
status: 'confirmed',
estimatedBaseFee: 'b',
hash:
'0x4d8543f12afd3795b94d723dcd0e20bfc3740e1af668e5e90a0c5ec49f36ba12',
hash: '0x4d8543f12afd3795b94d723dcd0e20bfc3740e1af668e5e90a0c5ec49f36ba12',
},
1: {
type: SENT_ETHER,
@ -118,8 +117,7 @@ describe('migration #64', () => {
status: 'unapproved',
time: 1631118004776,
txParams: {
data:
'0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029',
data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029',
from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e',
gas: '0x31413',
value: '0x0',
@ -159,8 +157,7 @@ describe('migration #64', () => {
gas: '0xa9fe',
},
estimatedBaseFee: 'b',
hash:
'0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b',
hash: '0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b',
origin: 'https://metamask.github.io',
r: '0xc2b2901f3593536d21e9b136c469b9b8f91a944f18a29a3cdf3a2eaadf660e71',
rawTx:
@ -277,8 +274,7 @@ describe('migration #64', () => {
s: '0x49f74084dd8c517b305a2e60b39ae9002176a5244cb06de8f9ea3757811f5ec6',
status: 'confirmed',
estimatedBaseFee: 'b',
hash:
'0x4d8543f12afd3795b94d723dcd0e20bfc3740e1af668e5e90a0c5ec49f36ba12',
hash: '0x4d8543f12afd3795b94d723dcd0e20bfc3740e1af668e5e90a0c5ec49f36ba12',
},
1: {
type: TRANSACTION_TYPES.SIMPLE_SEND,
@ -300,8 +296,7 @@ describe('migration #64', () => {
status: 'unapproved',
time: 1631118004776,
txParams: {
data:
'0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029',
data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029',
from: '0x0f002c95c041f003be01c3e4f52cae1f6ab3ba6e',
gas: '0x31413',
value: '0x0',
@ -341,8 +336,7 @@ describe('migration #64', () => {
gas: '0xa9fe',
},
estimatedBaseFee: 'b',
hash:
'0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b',
hash: '0x19ffab8a9467df9afbef82d8907f9e39f0696c7a774ed5473ecf7337adcc674b',
origin: 'https://metamask.github.io',
r: '0xc2b2901f3593536d21e9b136c469b9b8f91a944f18a29a3cdf3a2eaadf660e71',
rawTx:

@ -19,10 +19,8 @@ export default {
function transformState(state) {
if (state.PreferencesController) {
const {
completedOnboarding,
firstTimeFlowType,
} = state.PreferencesController;
const { completedOnboarding, firstTimeFlowType } =
state.PreferencesController;
state.OnboardingController = state.OnboardingController ?? {};
if (completedOnboarding !== undefined) {

@ -36,14 +36,13 @@ function transformState(state) {
const cachedBalances = state.CachedBalancesController?.cachedBalances || {};
const userIsCurrentlyOnATestNet = TEST_CHAINS.includes(provider?.chainId);
const userHasMadeATestNetTransaction = Object.values(
transactions,
).some(({ chainId }) => TEST_CHAINS.includes(chainId));
const userHasMadeATestNetTransaction = Object.values(transactions).some(
({ chainId }) => TEST_CHAINS.includes(chainId),
);
const userHasACachedBalanceOnATestnet = TEST_CHAINS.some((chainId) => {
const cachedBalancesForChain = Object.values(cachedBalances[chainId] || {});
const userHasABalanceGreaterThanZeroOnThisChain = cachedBalancesForChain.some(
hexNumberIsGreaterThanZero,
);
const userHasABalanceGreaterThanZeroOnThisChain =
cachedBalancesForChain.some(hexNumberIsGreaterThanZero);
return userHasABalanceGreaterThanZeroOnThisChain;
});
const userHasUsedATestnet =

@ -38,9 +38,8 @@ function transformState(state) {
permissionActivityLog: permissionsLog,
permissionHistory: permissionsHistory,
},
SubjectMetadataController: getSubjectMetadataControllerState(
domainMetadata,
),
SubjectMetadataController:
getSubjectMetadataControllerState(domainMetadata),
};
}

@ -119,10 +119,8 @@ describe('migration #68', () => {
};
const newStorage = await migration68.migrate(oldStorage);
const {
PermissionLogController,
SubjectMetadataController,
} = newStorage.data;
const { PermissionLogController, SubjectMetadataController } =
newStorage.data;
const expected = getOldState().PermissionsMetadata;
expect(PermissionLogController.permissionHistory).toStrictEqual(

@ -80,10 +80,8 @@ export default class ExtensionPlatform {
}
getVersion() {
const {
version,
version_name: versionName,
} = browser.runtime.getManifest();
const { version, version_name: versionName } =
browser.runtime.getManifest();
const versionParts = version.split('.');
if (versionName) {

@ -320,9 +320,8 @@ function removeFencedCode(filePath, typeOfCurrentBuild, fileContent) {
let currentCommand;
for (let i = 0; i < parsedDirectives.length; i++) {
const { line, indices, terminus, command, parameters } = parsedDirectives[
i
];
const { line, indices, terminus, command, parameters } =
parsedDirectives[i];
if (i % 2 === 0) {
if (terminus !== DirectiveTerminuses.BEGIN) {
throw new Error(
@ -368,9 +367,8 @@ function removeFencedCode(filePath, typeOfCurrentBuild, fileContent) {
}
// Forbid empty fences
const { line: previousLine, indices: previousIndices } = parsedDirectives[
i - 1
];
const { line: previousLine, indices: previousIndices } =
parsedDirectives[i - 1];
if (fileContent.substring(previousIndices[1], indices[0]).trim() === '') {
throw new Error(
`Empty fence found in file "${filePath}":\n${previousLine}\n${line}\n`,

@ -289,9 +289,8 @@ describe('build/transforms/remove-fenced-code', () => {
),
).toStrictEqual([ignoredLine, true]);
const modifiedInputWithoutFences = testData.validInputs.withoutFences.concat(
ignoredLine,
);
const modifiedInputWithoutFences =
testData.validInputs.withoutFences.concat(ignoredLine);
// These inputs will not be transformed
expect(

@ -183,7 +183,8 @@ async function verifyEnglishLocale() {
ignore: [testGlob],
});
const strictSearchRegex = /\bt\(\s*'(\w+)'\s*\)|\btranslationKey:\s*'(\w+)'/gu;
const strictSearchRegex =
/\bt\(\s*'(\w+)'\s*\)|\btranslationKey:\s*'(\w+)'/gu;
// match "t(`...`)" because constructing message keys from template strings
// prevents this script from finding the messages, and then inappropriately
// deletes them

@ -296,7 +296,7 @@
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-node": "^0.3.4",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.22.1",
@ -304,7 +304,7 @@
"eslint-plugin-jsdoc": "^39.3.3",
"eslint-plugin-mocha": "^8.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.23.1",
"eslint-plugin-react-hooks": "^4.2.0",
"fancy-log": "^1.3.3",
@ -343,7 +343,7 @@
"nyc": "^15.0.0",
"patch-package": "^6.4.7",
"polyfill-crypto.getrandomvalues": "^1.0.0",
"prettier": "^2.2.1",
"prettier": "^2.7.1",
"prettier-plugin-sort-json": "^0.0.1",
"proxyquire": "^2.1.3",
"pumpify": "^2.0.1",

@ -5,9 +5,9 @@ import contractMap from '@metamask/contract-metadata';
* `@metamask/contract-metadata`. Used primarily to validate if manually entered
* contract addresses do not match one of our listed tokens
*/
export const LISTED_CONTRACT_ADDRESSES = Object.keys(
contractMap,
).map((address) => address.toLowerCase());
export const LISTED_CONTRACT_ADDRESSES = Object.keys(contractMap).map(
(address) => address.toLowerCase(),
);
/**
* @typedef {object} TokenDetails

@ -19,9 +19,8 @@ describe('Contract Utils', () => {
},
};
const {
isContractAddress: isNotContractAddress,
} = await readAddressAsContract(
const { isContractAddress: isNotContractAddress } =
await readAddressAsContract(
mockEthQuery,
'0x76B4aa9Fc4d351a0062c6af8d186DF959D564A84',
);

@ -157,10 +157,8 @@ export async function determineTransactionType(txParams, query) {
if (data && !to) {
result = TRANSACTION_TYPES.DEPLOY_CONTRACT;
} else {
const {
contractCode: resultCode,
isContractAddress,
} = await readAddressAsContract(query, to);
const { contractCode: resultCode, isContractAddress } =
await readAddressAsContract(query, to);
contractCode = resultCode;

@ -149,8 +149,7 @@ describe('Transaction.utils', function () {
const result = await determineTransactionType(
{
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
data:
'0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a',
data: '0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a',
},
new EthQuery(_provider),
);
@ -174,8 +173,7 @@ describe('Transaction.utils', function () {
const result = await determineTransactionType(
{
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
data:
'0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a',
data: '0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a',
},
new EthQuery(_provider),
);
@ -199,8 +197,7 @@ describe('Transaction.utils', function () {
const result = await determineTransactionType(
{
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
data:
'0x095ea7b30000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C9700000000000000000000000000000000000000000000000000000000000000005',
data: '0x095ea7b30000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C9700000000000000000000000000000000000000000000000000000000000000005',
},
new EthQuery(_provider),
);

@ -405,8 +405,7 @@ describe('MetaMask', function () {
it('finds the transaction in the transactions list', async function () {
await driver.waitForSelector(
{
css:
'.transaction-list__completed-transactions .transaction-list-item__primary-currency',
css: '.transaction-list__completed-transactions .transaction-list-item__primary-currency',
text: '-1 TST',
},
{ timeout: 10000 },
@ -488,8 +487,7 @@ describe('MetaMask', function () {
it('finds the transaction in the transactions list', async function () {
await driver.waitForSelector({
css:
'.transaction-list__completed-transactions .transaction-list-item__primary-currency',
css: '.transaction-list__completed-transactions .transaction-list-item__primary-currency',
text: '-1.5 TST',
});
@ -545,8 +543,7 @@ describe('MetaMask', function () {
await driver.waitForSelector({
// Selects only the very first transaction list item immediately following the 'Pending' header
css:
'.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
css: '.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
text: 'Approve TST spend limit',
});
@ -638,8 +635,7 @@ describe('MetaMask', function () {
it('finds the transaction in the transactions list', async function () {
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',
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
text: 'Approve TST spend limit',
});
});
@ -691,14 +687,12 @@ describe('MetaMask', function () {
await driver.waitForSelector({
// Select the heading of the first transaction list item in the
// completed transaction list with text matching Send TST
css:
'.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
text: 'Send TST',
});
await driver.waitForSelector({
css:
'.transaction-list__completed-transactions .transaction-list-item:first-child .transaction-list-item__primary-currency',
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .transaction-list-item__primary-currency',
text: '-1.5 TST',
});
});
@ -735,8 +729,7 @@ describe('MetaMask', function () {
await driver.waitForSelector({
// Selects only the very first transaction list item immediately following the 'Pending' header
css:
'.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
css: '.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
text: 'Approve TST spend limit',
});
@ -760,8 +753,7 @@ describe('MetaMask', function () {
it('finds the transaction in the transactions list', async function () {
await driver.waitForSelector({
css:
'.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
text: 'Approve TST spend limit',
});
});

@ -39,11 +39,8 @@ describe('Chain Interactions', function () {
);
// verify chain details
const [
networkName,
networkUrl,
chainIdElement,
] = await driver.findElements('.definition-list dd');
const [networkName, networkUrl, chainIdElement] =
await driver.findElements('.definition-list dd');
assert.equal(await networkName.getText(), `Localhost ${port}`);
assert.equal(await networkUrl.getText(), `http://127.0.0.1:${port}`);
assert.equal(await chainIdElement.getText(), chainId.toString());

@ -132,8 +132,7 @@ describe('Stores custom RPC history', function () {
await chainIdInput.clear();
await chainIdInput.sendKeys(duplicateChainId);
await driver.findElement({
text:
'This Chain ID is currently used by the Localhost 8545 network.',
text: 'This Chain ID is currently used by the Localhost 8545 network.',
tag: 'h6',
});

@ -171,8 +171,7 @@ describe.skip('Create token, approve token and approve token without gas', funct
await driver.waitForSelector({
// Selects only the very first transaction list item immediately following the 'Pending' header
css:
'.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
css: '.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
text: 'Approve Token spend limit',
});
},
@ -230,8 +229,7 @@ describe.skip('Create token, approve token and approve token without gas', funct
await driver.clickElement({ text: 'Save', tag: 'button' });
await driver.waitForSelector({
css:
'.confirm-approve-content__transaction-details-content__secondary-fee',
css: '.confirm-approve-content__transaction-details-content__secondary-fee',
text: '0.0006 ETH',
});
@ -269,8 +267,7 @@ describe.skip('Create token, approve token and approve token without gas', funct
await driver.clickElement({ tag: 'button', text: 'Activity' });
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',
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
text: 'Approve Token spend limit',
});
},
@ -331,8 +328,7 @@ describe.skip('Create token, approve token and approve token without gas', funct
await driver.waitForSelector({
// Selects only the very first transaction list item immediately following the 'Pending' header
css:
'.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
css: '.transaction-list__pending-transactions .transaction-list__header + .transaction-list-item .list-item__heading',
text: 'Approve Token spend limit',
});
@ -347,8 +343,7 @@ describe.skip('Create token, approve token and approve token without gas', funct
await driver.clickElement({ text: 'Confirm', tag: 'button' });
await driver.waitForSelector({
css:
'.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
css: '.transaction-list__completed-transactions .transaction-list-item:first-child .list-item__heading',
text: 'Approve Token spend limit',
});
},

@ -58,14 +58,13 @@ const AddNetwork = () => {
const [showPopover, setShowPopover] = useState(false);
useEffect(() => {
const anAddNetworkConfirmationFromMetaMaskExists = unapprovedConfirmations?.find(
(confirmation) => {
const anAddNetworkConfirmationFromMetaMaskExists =
unapprovedConfirmations?.find((confirmation) => {
return (
confirmation.origin === 'metamask' &&
confirmation.type === MESSAGE_TYPE.ADD_ETHEREUM_CHAIN
);
},
);
});
if (!showPopover && anAddNetworkConfirmationFromMetaMaskExists) {
setShowPopover(true);
}

@ -22,11 +22,8 @@ import { useI18nContext } from '../../../../hooks/useI18nContext';
const AdvancedGasFeeDefaults = () => {
const t = useI18nContext();
const dispatch = useDispatch();
const {
gasErrors,
maxBaseFee,
maxPriorityFeePerGas,
} = useAdvancedGasFeePopoverContext();
const { gasErrors, maxBaseFee, maxPriorityFeePerGas } =
useAdvancedGasFeePopoverContext();
const advancedGasFeeValues = useSelector(getAdvancedGasFeeValues);
const { updateTransactionEventFragment } = useTransactionEventFragment();
const { editGasMode } = useGasFeeContext();

@ -20,14 +20,10 @@ const validateGasLimit = (gasLimit, minimumGasLimitDec) => {
const AdvancedGasFeeGasLimit = () => {
const t = useI18nContext();
const {
setGasLimit: setGasLimitInContext,
setErrorValue,
} = useAdvancedGasFeePopoverContext();
const {
gasLimit: gasLimitInTransaction,
minimumGasLimitDec,
} = useGasFeeContext();
const { setGasLimit: setGasLimitInContext, setErrorValue } =
useAdvancedGasFeePopoverContext();
const { gasLimit: gasLimitInTransaction, minimumGasLimitDec } =
useGasFeeContext();
const [isEditing, setEditing] = useState(false);
const [gasLimit, setGasLimit] = useState(gasLimitInTransaction);
const [gasLimitError, setGasLimitError] = useState();

@ -45,12 +45,8 @@ const validateBaseFee = (value, gasFeeEstimates, maxPriorityFeePerGas) => {
const BaseFeeInput = () => {
const t = useI18nContext();
const {
gasFeeEstimates,
estimateUsed,
maxFeePerGas,
editGasMode,
} = useGasFeeContext();
const { gasFeeEstimates, estimateUsed, maxFeePerGas, editGasMode } =
useGasFeeContext();
const {
gasLimit,
maxPriorityFeePerGas,
@ -59,11 +55,8 @@ const BaseFeeInput = () => {
setMaxBaseFee,
} = useAdvancedGasFeePopoverContext();
const {
estimatedBaseFee,
historicalBaseFeeRange,
baseFeeTrend,
} = gasFeeEstimates;
const { estimatedBaseFee, historicalBaseFeeRange, baseFeeTrend } =
gasFeeEstimates;
const [baseFeeError, setBaseFeeError] = useState();
const { currency, numberOfDecimals } = useUserPreferencedCurrency(PRIMARY);

@ -46,17 +46,10 @@ const validatePriorityFee = (value, gasFeeEstimates) => {
const PriorityFeeInput = () => {
const t = useI18nContext();
const advancedGasFeeValues = useSelector(getAdvancedGasFeeValues);
const {
gasLimit,
setErrorValue,
setMaxPriorityFeePerGas,
} = useAdvancedGasFeePopoverContext();
const {
editGasMode,
estimateUsed,
gasFeeEstimates,
maxPriorityFeePerGas,
} = useGasFeeContext();
const { gasLimit, setErrorValue, setMaxPriorityFeePerGas } =
useAdvancedGasFeePopoverContext();
const { editGasMode, estimateUsed, gasFeeEstimates, maxPriorityFeePerGas } =
useGasFeeContext();
const {
latestPriorityFeeRange,
historicalPriorityFeeRange,

@ -15,12 +15,8 @@ const AdvancedGasFeeSaveButton = () => {
const { updateTransactionEventFragment } = useTransactionEventFragment();
const { updateTransaction } = useGasFeeContext();
const t = useI18nContext();
const {
gasLimit,
hasErrors,
maxFeePerGas,
maxPriorityFeePerGas,
} = useAdvancedGasFeePopoverContext();
const { gasLimit, hasErrors, maxFeePerGas, maxPriorityFeePerGas } =
useAdvancedGasFeePopoverContext();
const onSave = () => {
updateTransaction({

@ -57,10 +57,8 @@ const AssetList = ({ onClickAsset }) => {
},
);
const [
secondaryCurrencyDisplay,
secondaryCurrencyProperties,
] = useCurrencyDisplay(selectedAccountBalance, {
const [secondaryCurrencyDisplay, secondaryCurrencyProperties] =
useCurrencyDisplay(selectedAccountBalance, {
numberOfDecimals: secondaryNumberOfDecimals,
currency: secondaryCurrency,
});

@ -36,7 +36,8 @@ export default function CancelButton({
type="secondary"
className={classnames({
'transaction-list-item__header-button': !detailsModal,
'transaction-list-item-details__header-button-rounded-button': detailsModal,
'transaction-list-item-details__header-button-rounded-button':
detailsModal,
})}
disabled={!hasEnoughCancelGas}
>

@ -24,10 +24,8 @@ const MAXGASCOST_ABOVE_MOCK_MEDIUM_BN = new BigNumber(
MAXFEEPERGAS_ABOVE_MOCK_MEDIUM_HEX,
16,
).times(21000, 10);
const MAXGASCOST_ABOVE_MOCK_MEDIUM_BN_PLUS_TEN_PCT_HEX = MAXGASCOST_ABOVE_MOCK_MEDIUM_BN.times(
1.1,
10,
).toString(16);
const MAXGASCOST_ABOVE_MOCK_MEDIUM_BN_PLUS_TEN_PCT_HEX =
MAXGASCOST_ABOVE_MOCK_MEDIUM_BN.times(1.1, 10).toString(16);
const EXPECTED_ETH_FEE_1 = hexWEIToDecETH(
MAXGASCOST_ABOVE_MOCK_MEDIUM_BN_PLUS_TEN_PCT_HEX,
@ -40,18 +38,15 @@ const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI = new BigNumber(
decGWEIToHexWEI(MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_DEC_GWEI),
16,
);
const MAXFEEPERGAS_BELOW_MOCK_MEDIUM_HEX = MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI.div(
10,
10,
).toString(16);
const MAXFEEPERGAS_BELOW_MOCK_MEDIUM_HEX =
MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI.div(10, 10).toString(16);
const EXPECTED_ETH_FEE_2 = hexWEIToDecETH(
MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI.times(21000, 10).toString(16),
);
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_HEX_WEI = MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI.toString(
16,
);
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_HEX_WEI =
MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI.toString(16);
jest.mock('../../../store/actions', () => ({
disconnectGasFeeEstimatePoller: jest.fn(),

@ -6,10 +6,8 @@ import { Menu, MenuItem } from '../../ui/menu';
const CollectibleOptions = ({ onRemove, onViewOnOpensea }) => {
const t = useContext(I18nContext);
const [
collectibleOptionsButtonElement,
setCollectibleOptionsButtonElement,
] = useState(null);
const [collectibleOptionsButtonElement, setCollectibleOptionsButtonElement] =
useState(null);
const [collectibleOptionsOpen, setCollectibleOptionsOpen] = useState(false);
return (

@ -118,9 +118,8 @@ export default function CollectiblesItems({
[key]: !isExpanded,
};
collectiblesDropdownState[selectedAddress][
chainId
] = newCurrentAccountState;
collectiblesDropdownState[selectedAddress][chainId] =
newCurrentAccountState;
dispatch(updateCollectibleDropDownState(collectiblesDropdownState));
};
@ -186,13 +185,8 @@ export default function CollectiblesItems({
{isExpanded ? (
<Box display={DISPLAY.FLEX} flexWrap={FLEX_WRAP.WRAP} gap={4}>
{collectibles.map((collectible, i) => {
const {
image,
address,
tokenId,
backgroundColor,
name,
} = collectible;
const { image, address, tokenId, backgroundColor, name } =
collectible;
const collectibleImage = getAssetImageURL(image, ipfsGateway);
const handleImageClick = () =>
history.push(`${ASSET_ROUTE}/${address}/${tokenId}`);
@ -249,11 +243,8 @@ export default function CollectiblesItems({
>
<>
{collectionsKeys.map((key) => {
const {
collectibles,
collectionName,
collectionImage,
} = collections[key];
const { collectibles, collectionName, collectionImage } =
collections[key];
return renderCollection({
collectibles,

@ -36,11 +36,8 @@ export default function CollectiblesTab({ onAddNFT }) {
const t = useI18nContext();
const dispatch = useDispatch();
const {
collectiblesLoading,
collections,
previouslyOwnedCollection,
} = useCollectiblesCollections();
const { collectiblesLoading, collections, previouslyOwnedCollection } =
useCollectiblesCollections();
const onEnableAutoDetect = () => {
history.push(EXPERIMENTAL_ROUTE);

@ -182,10 +182,12 @@ describe('Collectible Items', () => {
const checkAndUpdateAllCollectiblesOwnershipStatusStub = jest.fn();
const updateCollectibleDropDownStateStub = jest.fn();
setBackgroundConnection({
setCollectiblesDetectionNoticeDismissed: setCollectiblesDetectionNoticeDismissedStub,
setCollectiblesDetectionNoticeDismissed:
setCollectiblesDetectionNoticeDismissedStub,
detectCollectibles: detectCollectiblesStub,
getState: getStateStub,
checkAndUpdateAllCollectiblesOwnershipStatus: checkAndUpdateAllCollectiblesOwnershipStatusStub,
checkAndUpdateAllCollectiblesOwnershipStatus:
checkAndUpdateAllCollectiblesOwnershipStatusStub,
updateCollectibleDropDownState: updateCollectibleDropDownStateStub,
});
const historyPushMock = jest.fn();

@ -42,9 +42,8 @@ const ConfirmPageContainerSummary = (props) => {
TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM,
TRANSACTION_TYPES.TOKEN_METHOD_SAFE_TRANSFER_FROM,
];
const isContractTypeTransaction = contractInitiatedTransactionType.includes(
transactionType,
);
const isContractTypeTransaction =
contractInitiatedTransactionType.includes(transactionType);
let contractAddress;
if (isContractTypeTransaction) {
// If the transaction is TOKEN_METHOD_TRANSFER or TOKEN_METHOD_TRANSFER_FROM

@ -125,11 +125,8 @@ export default class ConnectedAccountsList extends PureComponent {
}
render() {
const {
connectedAccounts,
selectedAddress,
shouldRenderListOptions,
} = this.props;
const { connectedAccounts, selectedAddress, shouldRenderListOptions } =
this.props;
const { t } = this.context;
return (

@ -36,7 +36,8 @@ const ConnectedAccountsPermissions = ({ permissions }) => {
className={classnames(
'connected-accounts-permissions__list-container',
{
'connected-accounts-permissions__list-container--expanded': expanded,
'connected-accounts-permissions__list-container--expanded':
expanded,
},
)}
>

@ -37,10 +37,8 @@ export default function RecipientGroup({
address,
selectedAddress,
),
'send__select-recipient-wrapper__group-item--selected': addressesEqual(
address,
selectedAddress,
),
'send__select-recipient-wrapper__group-item--selected':
addressesEqual(address, selectedAddress),
})}
>
<Identicon address={address} diameter={28} />

@ -27,9 +27,8 @@ const DetectedTokenSelectionPopover = ({
const trackEvent = useContext(MetaMetricsContext);
const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);
const { selected: selectedTokens = [] } = sortingBasedOnTokenSelection(
tokensListDetected,
);
const { selected: selectedTokens = [] } =
sortingBasedOnTokenSelection(tokensListDetected);
const numOfTokensImporting =
selectedTokens.length === detectedTokens.length
? `All`

@ -45,10 +45,8 @@ const DetectedToken = ({ setShowDetectedTokens }) => {
return tokenObj;
}, {}),
);
const [
showDetectedTokenIgnoredPopover,
setShowDetectedTokenIgnoredPopover,
] = useState(false);
const [showDetectedTokenIgnoredPopover, setShowDetectedTokenIgnoredPopover] =
useState(false);
const importSelectedTokens = async (selectedTokens) => {
selectedTokens.forEach((importedToken) => {
@ -71,10 +69,8 @@ const DetectedToken = ({ setShowDetectedTokens }) => {
};
const handleClearTokensSelection = async () => {
const {
selected: selectedTokens = [],
deselected: deSelectedTokens = [],
} = sortingBasedOnTokenSelection(tokensListDetected);
const { selected: selectedTokens = [], deselected: deSelectedTokens = [] } =
sortingBasedOnTokenSelection(tokensListDetected);
if (deSelectedTokens.length < detectedTokens.length) {
await importSelectedTokens(selectedTokens);
@ -115,9 +111,8 @@ const DetectedToken = ({ setShowDetectedTokens }) => {
};
const onImport = async () => {
const { selected: selectedTokens = [] } = sortingBasedOnTokenSelection(
tokensListDetected,
);
const { selected: selectedTokens = [] } =
sortingBasedOnTokenSelection(tokensListDetected);
if (selectedTokens.length < detectedTokens.length) {
setShowDetectedTokenIgnoredPopover(true);

@ -295,9 +295,8 @@ class NetworkDropdown extends Component {
onClickOutside={(event) => {
const { classList } = event.target;
const isInClassList = (className) => classList.contains(className);
const notToggleElementIndex = notToggleElementClassnames.findIndex(
isInClassList,
);
const notToggleElementIndex =
notToggleElementClassnames.findIndex(isInClassList);
if (notToggleElementIndex === -1) {
event.stopPropagation();

@ -99,9 +99,8 @@ export default function EditGasDisplay({
}
}, [showAdvancedForm]);
const dappSuggestedAndTxParamGasFeesAreTheSame = areDappSuggestedAndTxParamGasFeesTheSame(
transaction,
);
const dappSuggestedAndTxParamGasFeesAreTheSame =
areDappSuggestedAndTxParamGasFeesTheSame(transaction);
const requireDappAcknowledgement = Boolean(
transaction?.dappSuggestedGasFees &&

@ -21,12 +21,8 @@ import NetworkStatistics from './network-statistics';
const EditGasFeePopover = () => {
const { balanceError, editGasMode } = useGasFeeContext();
const t = useI18nContext();
const {
closeAllModals,
closeModal,
currentModal,
openModalCount,
} = useTransactionModalContext();
const { closeAllModals, closeModal, currentModal, openModalCount } =
useTransactionModalContext();
if (currentModal !== 'editGasFee') {
return null;

@ -29,9 +29,8 @@ export const useGasItemFeeDetails = (priorityLevel) => {
maxPriorityFeePerGas: maxPriorityFeePerGasValue,
transaction,
} = useGasFeeContext();
const [estimateGreaterThanGasUse, setEstimateGreaterThanGasUse] = useState(
false,
);
const [estimateGreaterThanGasUse, setEstimateGreaterThanGasUse] =
useState(false);
const advancedGasFeeValues = useSelector(getAdvancedGasFeeValues);
let maxFeePerGas;

@ -63,10 +63,8 @@ export default function EditGasPopover({
supportsEIP1559;
const [showEducationContent, setShowEducationContent] = useState(false);
const [
dappSuggestedGasFeeAcknowledged,
setDappSuggestedGasFeeAcknowledged,
] = useState(false);
const [dappSuggestedGasFeeAcknowledged, setDappSuggestedGasFeeAcknowledged] =
useState(false);
const minimumGasLimitDec = hexToDecimal(minimumGasLimit);
const updatedCustomGasSettings = useIncrementedGasFees(transaction);

@ -15,7 +15,8 @@ function lineBreaksToBr(source) {
});
}
const METAMASK_LOGO = lineBreaksToBr(`MMm*mmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmm*mMM
const METAMASK_LOGO =
lineBreaksToBr(`MMm*mmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmm*mMM
MM*./***mMMMMMMMMMMMMMMMMMMMMMMMMMMm***/.*MM
MM/...///*mMMMMMMMMMMMMMMMMMMMMMMm*///.../MM
Mm.....//../*mMMMMMMMMMMMMMMMMm*/..//.....mM
@ -57,7 +58,8 @@ MMMMMMMMMMMMMMMMMm/....../mMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMmmmmmmmmMMMMMMMMMMMMMMMMMM`);
/* eslint-disable no-irregular-whitespace */
const EXPERIMENTAL_AREA = lineBreaksToBr(`█▄██▀██░██▀██▀▀ █▀▀█▄░█▀█▀█▀▀█▀██▄░██▀▀ ▄▀██▄░█
const EXPERIMENTAL_AREA =
lineBreaksToBr(`█▄██▀██░██▀██▀▀ █▀▀█▄░█▀█▀█▀▀█▀██▄░██▀▀ ▄▀██▄░█

@ -166,7 +166,8 @@ export default class AdvancedGasInputs extends Component {
errorType === 'error',
'advanced-gas-inputs__gas-edit-row__input--warning':
errorType === 'warning',
'advanced-gas-inputs__gas-edit-row__input-arrows--hidden': disabled,
'advanced-gas-inputs__gas-edit-row__input-arrows--hidden':
disabled,
},
)}
>
@ -210,10 +211,8 @@ export default class AdvancedGasInputs extends Component {
return null;
}
const {
errorText: gasPriceErrorText,
errorType: gasPriceErrorType,
} = this.gasPriceError({
const { errorText: gasPriceErrorText, errorType: gasPriceErrorType } =
this.gasPriceError({
insufficientBalance,
customPriceIsSafe,
isSpeedUp,
@ -228,10 +227,8 @@ export default class AdvancedGasInputs extends Component {
</div>
) : null;
const {
errorText: gasLimitErrorText,
errorType: gasLimitErrorType,
} = this.gasLimitError({ insufficientBalance, gasLimit, minimumGasLimit });
const { errorText: gasLimitErrorText, errorType: gasLimitErrorType } =
this.gasLimitError({ insufficientBalance, gasLimit, minimumGasLimit });
const gasLimitErrorComponent = gasLimitErrorType ? (
<div
className={`advanced-gas-inputs__gas-edit-row__${gasLimitErrorType}-text`}

@ -49,9 +49,8 @@ describe('AdvancedTabContent Component', () => {
});
it('should call renderDataSummary with the expected params', () => {
const renderDataSummaryArgs = AdvancedTabContent.prototype.renderDataSummary.getCall(
0,
).args;
const renderDataSummaryArgs =
AdvancedTabContent.prototype.renderDataSummary.getCall(0).args;
expect(renderDataSummaryArgs).toStrictEqual(['$0.25']);
});
});

@ -138,9 +138,8 @@ const mapStateToProps = (state, ownProps) => {
conversionRate,
});
const isGasEstimate = getIsGasEstimatesFetched(state);
const customNetworkEstimateWasFetched = getIsCustomNetworkGasPriceFetched(
state,
);
const customNetworkEstimateWasFetched =
getIsCustomNetworkGasPriceFetched(state);
let customPriceIsSafe = true;
if ((isMainnet || process.env.IN_TEST) && isGasEstimate) {

@ -69,11 +69,8 @@ describe('GasPriceButtonGroup Component', () => {
});
it('should render the correct props on the ButtonGroup', () => {
const {
className,
defaultActiveButtonIndex,
noButtonActiveByDefault,
} = wrapper.props();
const { className, defaultActiveButtonIndex, noButtonActiveByDefault } =
wrapper.props();
expect(className).toStrictEqual('gas-price-button-group');
expect(defaultActiveButtonIndex).toStrictEqual(2);
expect(noButtonActiveByDefault).toStrictEqual(true);
@ -195,7 +192,8 @@ describe('GasPriceButtonGroup Component', () => {
});
it('should render a feeInPrimaryCurrency if passed a feeInPrimaryCurrency', () => {
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent(
const renderButtonContentResult =
GasPriceButtonGroup.prototype.renderButtonContent(
{
feeInPrimaryCurrency: 'mockFeeInPrimaryCurrency',
},
@ -217,7 +215,8 @@ describe('GasPriceButtonGroup Component', () => {
});
it('should render a feeInSecondaryCurrency if passed a feeInSecondaryCurrency', () => {
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent(
const renderButtonContentResult =
GasPriceButtonGroup.prototype.renderButtonContent(
{
feeInSecondaryCurrency: 'mockFeeInSecondaryCurrency',
},
@ -239,7 +238,8 @@ describe('GasPriceButtonGroup Component', () => {
});
it('should render a timeEstimate if passed a timeEstimate', () => {
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent(
const renderButtonContentResult =
GasPriceButtonGroup.prototype.renderButtonContent(
{
timeEstimate: 'mockTimeEstimate',
},
@ -261,7 +261,8 @@ describe('GasPriceButtonGroup Component', () => {
});
it('should render a check if showCheck is true', () => {
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent(
const renderButtonContentResult =
GasPriceButtonGroup.prototype.renderButtonContent(
{},
{
className: 'someClass',
@ -296,10 +297,8 @@ describe('GasPriceButtonGroup Component', () => {
});
it('should render no elements if all args passed', () => {
const renderButtonContentResult = GasPriceButtonGroup.prototype.renderButtonContent(
{},
{},
);
const renderButtonContentResult =
GasPriceButtonGroup.prototype.renderButtonContent({}, {});
const wrappedRenderButtonContentResult = shallowWithContext(
renderButtonContentResult,
);

@ -61,7 +61,9 @@ const DEFAULT_OPTS = {
isGasEstimatesLoading: true,
};
const generateUseSelectorRouter = (opts = DEFAULT_OPTS) => (selector) => {
const generateUseSelectorRouter =
(opts = DEFAULT_OPTS) =>
(selector) => {
if (selector === checkNetworkAndAccountSupports1559) {
return true;
}

@ -173,11 +173,10 @@ export default function LedgerInstructionField({ showDataInstruction }) {
type="link"
onClick={async () => {
if (environmentTypeIsFullScreen) {
const connectedDevices = await window.navigator.hid.requestDevice(
{
const connectedDevices =
await window.navigator.hid.requestDevice({
filters: [{ vendorId: LEDGER_USB_VENDOR_ID }],
},
);
});
const webHidIsConnected = connectedDevices.some(
(device) =>
device.vendorId === Number(LEDGER_USB_VENDOR_ID),

@ -59,11 +59,8 @@ export default class LoadingNetworkScreen extends PureComponent {
};
renderErrorScreenContent = () => {
const {
showNetworkDropdown,
setProviderArgs,
setProviderType,
} = this.props;
const { showNetworkDropdown, setProviderArgs, setProviderType } =
this.props;
return (
<div className="loading-overlay__error-screen">

@ -17,10 +17,8 @@ export default function MenuBar() {
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);
const history = useHistory();
const [
accountOptionsButtonElement,
setAccountOptionsButtonElement,
] = useState(null);
const [accountOptionsButtonElement, setAccountOptionsButtonElement] =
useState(null);
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false);
const origin = useSelector(getOriginOfCurrentTab);

@ -40,8 +40,7 @@ const SECTIONS = {
key: 'TDL',
props: {
dictionary: {
term:
'a word or phrase used to describe a thing or to express a concept, especially in a particular kind of language or branch of study.',
term: 'a word or phrase used to describe a thing or to express a concept, especially in a particular kind of language or branch of study.',
definition:
'a statement of the exact meaning of a word, especially in a dictionary.',
dl: 'HTML tag denoting a definition list',

@ -6,12 +6,8 @@ import CancelTransaction from './cancel-transaction.component';
const mapStateToProps = (state, ownProps) => {
const { metamask } = state;
const {
transactionId,
originalGasPrice,
newGasFee,
customGasSettings,
} = ownProps;
const { transactionId, originalGasPrice, newGasFee, customGasSettings } =
ownProps;
const { currentNetworkTxList } = metamask;
const transaction = currentNetworkTxList.find(
({ id }) => id === transactionId,

@ -87,8 +87,10 @@ export default class EditApprovalPermission extends PureComponent {
>
<div
className={classnames({
'edit-approval-permission__edit-section__radio-button-outline': !selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__radio-button-outline--selected': selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__radio-button-outline':
!selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__radio-button-outline--selected':
selectedOptionIsUnlimited,
})}
/>
<div className="edit-approval-permission__edit-section__radio-button-fill" />
@ -99,8 +101,10 @@ export default class EditApprovalPermission extends PureComponent {
<div className="edit-approval-permission__edit-section__option-text">
<div
className={classnames({
'edit-approval-permission__edit-section__option-label': !selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__option-label--selected': selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__option-label':
!selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__option-label--selected':
selectedOptionIsUnlimited,
})}
>
{new BigNumber(tokenAmount).equals(
@ -126,8 +130,10 @@ export default class EditApprovalPermission extends PureComponent {
>
<div
className={classnames({
'edit-approval-permission__edit-section__radio-button-outline': selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__radio-button-outline--selected': !selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__radio-button-outline':
selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__radio-button-outline--selected':
!selectedOptionIsUnlimited,
})}
/>
<div className="edit-approval-permission__edit-section__radio-button-fill" />
@ -138,8 +144,10 @@ export default class EditApprovalPermission extends PureComponent {
<div className="edit-approval-permission__edit-section__option-text">
<div
className={classnames({
'edit-approval-permission__edit-section__option-label': selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__option-label--selected': !selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__option-label':
selectedOptionIsUnlimited,
'edit-approval-permission__edit-section__option-label--selected':
!selectedOptionIsUnlimited,
})}
>
{t('customSpendLimit')}

@ -16,8 +16,7 @@ export default class PermissionsConnectFooter extends Component {
className="permissions-connect-footer__text--link"
onClick={() => {
global.platform.openTab({
url:
'https://metamask.zendesk.com/hc/en-us/articles/4405506066331-User-guide-Dapps',
url: 'https://metamask.zendesk.com/hc/en-us/articles/4405506066331-User-guide-Dapps',
});
}}
>

@ -228,8 +228,7 @@ export default class SignatureRequestOriginal extends Component {
className="request-signature__help-link"
onClick={() => {
global.platform.openTab({
url:
'https://consensys.net/blog/metamask/the-seal-of-approval-know-what-youre-consenting-to-with-permissions-and-approvals-in-metamask/',
url: 'https://consensys.net/blog/metamask/the-seal-of-approval-know-what-youre-consenting-to-with-permissions-and-approvals-in-metamask/',
});
}}
>

@ -26,10 +26,8 @@ function mapStateToProps(state, ownProps) {
msgParams: { from },
} = ownProps.txData;
const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(
state,
from,
);
const hardwareWalletRequiresConnection =
doesAddressRequireLedgerHidConnection(state, from);
const isLedgerWallet = isAddressLedger(state, from);
const messagesList = unconfirmedMessagesHashSelector(state);
const messagesCount = getTotalUnapprovedMessagesCount(state);

@ -13,10 +13,8 @@ function mapStateToProps(state, ownProps) {
const {
msgParams: { from },
} = txData;
const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(
state,
from,
);
const hardwareWalletRequiresConnection =
doesAddressRequireLedgerHidConnection(state, from);
const isLedgerWallet = isAddressLedger(state, from);
return {
@ -28,11 +26,8 @@ function mapStateToProps(state, ownProps) {
}
function mergeProps(stateProps, dispatchProps, ownProps) {
const {
allAccounts,
isLedgerWallet,
hardwareWalletRequiresConnection,
} = stateProps;
const { allAccounts, isLedgerWallet, hardwareWalletRequiresConnection } =
stateProps;
const {
signPersonalMessage,
signTypedMessage,

@ -40,8 +40,7 @@ describe('Signature Request', () => {
txData: {
msgParams: {
id: 1,
data:
'{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":"4","verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","wallet":"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},"contents":"Hello, Bob!"}}',
data: '{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":"4","verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","wallet":"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},"contents":"Hello, Bob!"}}',
from: '0xd8f6a2ffb0fc5952d16c9768b71cfd35b6399aa5',
origin: 'test.domain',
},

@ -1738,11 +1738,8 @@ describe('srp-input', () => {
it('should be updated on paste to allow room for a longer SRP', async () => {
const onChange = jest.fn();
const {
getByTestId,
queryByTestId,
queryByRole,
} = renderWithLocalization(
const { getByTestId, queryByTestId, queryByRole } =
renderWithLocalization(
<SrpInput
onChange={onChange}
srpText={enLocale.secretRecoveryPhrase.message}
@ -1764,12 +1761,8 @@ describe('srp-input', () => {
it('should be updated on paste to match the size of a shorter SRP', async () => {
const onChange = jest.fn();
const {
getByRole,
getByTestId,
queryByTestId,
queryByRole,
} = renderWithLocalization(
const { getByRole, getByTestId, queryByTestId, queryByRole } =
renderWithLocalization(
<SrpInput
onChange={onChange}
srpText={enLocale.secretRecoveryPhrase.message}
@ -1792,11 +1785,8 @@ describe('srp-input', () => {
it('should round up to nearest valid size on paste when SRP has an invalid number of words', async () => {
const onChange = jest.fn();
const {
getByTestId,
queryByTestId,
queryByRole,
} = renderWithLocalization(
const { getByTestId, queryByTestId, queryByRole } =
renderWithLocalization(
<SrpInput
onChange={onChange}
srpText={enLocale.secretRecoveryPhrase.message}

@ -7,32 +7,28 @@ describe('TransactionActivityLog Component', () => {
const activities = [
{
eventKey: 'transactionCreated',
hash:
'0xe46c7f9b39af2fbf1c53e66f72f80343ab54c2c6dba902d51fb98ada08fe1a63',
hash: '0xe46c7f9b39af2fbf1c53e66f72f80343ab54c2c6dba902d51fb98ada08fe1a63',
id: 2005383477493174,
timestamp: 1543957986150,
value: '0x2386f26fc10000',
},
{
eventKey: 'transactionSubmitted',
hash:
'0xe46c7f9b39af2fbf1c53e66f72f80343ab54c2c6dba902d51fb98ada08fe1a63',
hash: '0xe46c7f9b39af2fbf1c53e66f72f80343ab54c2c6dba902d51fb98ada08fe1a63',
id: 2005383477493174,
timestamp: 1543957987853,
value: '0x1319718a5000',
},
{
eventKey: 'transactionResubmitted',
hash:
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
hash: '0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
id: 2005383477493175,
timestamp: 1543957991563,
value: '0x1502634b5800',
},
{
eventKey: 'transactionConfirmed',
hash:
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
hash: '0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
id: 2005383477493175,
timestamp: 1543958029960,
value: '0x1502634b5800',
@ -75,16 +71,14 @@ describe('TransactionActivityLog Component', () => {
},
{
eventKey: 'transactionResubmitted',
hash:
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
hash: '0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
id: 2,
timestamp: 3,
value: '0x1',
},
{
eventKey: 'transactionCancelAttempted',
hash:
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
hash: '0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
id: 3,
timestamp: 4,
value: '0x1',
@ -131,16 +125,14 @@ describe('TransactionActivityLog Component', () => {
},
{
eventKey: 'transactionResubmitted',
hash:
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
hash: '0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
id: 2,
timestamp: 3,
value: '0x1',
},
{
eventKey: 'transactionCancelAttempted',
hash:
'0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
hash: '0x7d09d337fc6f5d6fe2dbf3a6988d69532deb0a82b665f9180b5a20db377eea87',
id: 3,
timestamp: 4,
value: '0x1',

@ -12,7 +12,9 @@ import {
TRANSACTION_CANCEL_ATTEMPTED_EVENT,
} from './transaction-activity-log.constants';
const matchesEventKey = (matchEventKey) => ({ eventKey }) =>
const matchesEventKey =
(matchEventKey) =>
({ eventKey }) =>
eventKey === matchEventKey;
const mapStateToProps = (state) => {

@ -21,8 +21,7 @@ describe('TransactionActivityLog utils', () => {
it('should return activities for an array of transactions', () => {
const transactions = [
{
hash:
'0xa14f13d36b3901e352ce3a7acb9b47b001e5a3370f06232a0953c6fc6fad91b3',
hash: '0xa14f13d36b3901e352ce3a7acb9b47b001e5a3370f06232a0953c6fc6fad91b3',
history: [
{
id: 6400627574331058,
@ -92,8 +91,7 @@ describe('TransactionActivityLog utils', () => {
type: TRANSACTION_TYPES.STANDARD,
},
{
hash:
'0xecbe181ee67c4291d04a7cb9ffbf1d5d831e4fbaa89994fd06bab5dd4cc79b33',
hash: '0xecbe181ee67c4291d04a7cb9ffbf1d5d831e4fbaa89994fd06bab5dd4cc79b33',
history: [
{
id: 6400627574331060,
@ -195,8 +193,7 @@ describe('TransactionActivityLog utils', () => {
id: 6400627574331058,
metamaskNetworkId: ROPSTEN_NETWORK_ID,
chainId: ROPSTEN_CHAIN_ID,
hash:
'0xa14f13d36b3901e352ce3a7acb9b47b001e5a3370f06232a0953c6fc6fad91b3',
hash: '0xa14f13d36b3901e352ce3a7acb9b47b001e5a3370f06232a0953c6fc6fad91b3',
eventKey: 'transactionCreated',
timestamp: 1543958845581,
value: '0x2386f26fc10000',
@ -205,8 +202,7 @@ describe('TransactionActivityLog utils', () => {
id: 6400627574331058,
metamaskNetworkId: ROPSTEN_NETWORK_ID,
chainId: ROPSTEN_CHAIN_ID,
hash:
'0xa14f13d36b3901e352ce3a7acb9b47b001e5a3370f06232a0953c6fc6fad91b3',
hash: '0xa14f13d36b3901e352ce3a7acb9b47b001e5a3370f06232a0953c6fc6fad91b3',
eventKey: 'transactionSubmitted',
timestamp: 1543958848147,
value: '0x1319718a5000',
@ -215,8 +211,7 @@ describe('TransactionActivityLog utils', () => {
id: 6400627574331060,
metamaskNetworkId: ROPSTEN_NETWORK_ID,
chainId: ROPSTEN_CHAIN_ID,
hash:
'0xecbe181ee67c4291d04a7cb9ffbf1d5d831e4fbaa89994fd06bab5dd4cc79b33',
hash: '0xecbe181ee67c4291d04a7cb9ffbf1d5d831e4fbaa89994fd06bab5dd4cc79b33',
eventKey: 'transactionResubmitted',
timestamp: 1543958860061,
value: '0x171c3a061400',
@ -225,8 +220,7 @@ describe('TransactionActivityLog utils', () => {
id: 6400627574331060,
metamaskNetworkId: ROPSTEN_NETWORK_ID,
chainId: ROPSTEN_CHAIN_ID,
hash:
'0xecbe181ee67c4291d04a7cb9ffbf1d5d831e4fbaa89994fd06bab5dd4cc79b33',
hash: '0xecbe181ee67c4291d04a7cb9ffbf1d5d831e4fbaa89994fd06bab5dd4cc79b33',
eventKey: 'transactionConfirmed',
timestamp: 1543958897165,
value: '0x171c3a061400',

@ -40,7 +40,8 @@ export default function TransactionDetailItem({
</Typography>
<div
className={classnames('transaction-detail-item__detail-values', {
'transaction-detail-item__detail-values--flex-width': flexWidthValues,
'transaction-detail-item__detail-values--flex-width':
flexWidthValues,
})}
>
{detailText && (

@ -27,18 +27,10 @@ export default function SmartTransactionListItem({
const t = useI18nContext();
const [cancelSwapLinkClicked, setCancelSwapLinkClicked] = useState(false);
const [showDetails, setShowDetails] = useState(false);
const {
primaryCurrency,
recipientAddress,
isPending,
senderAddress,
} = useTransactionDisplayData(transactionGroup);
const {
sourceTokenSymbol,
destinationTokenSymbol,
time,
status,
} = smartTransaction;
const { primaryCurrency, recipientAddress, isPending, senderAddress } =
useTransactionDisplayData(transactionGroup);
const { sourceTokenSymbol, destinationTokenSymbol, time, status } =
smartTransaction;
const category = TRANSACTION_GROUP_CATEGORIES.SWAP;
const title = t('swapTokenToToken', [
sourceTokenSymbol,

@ -50,9 +50,8 @@ function TransactionListItemInner({
const history = useHistory();
const { hasCancelled } = transactionGroup;
const [showDetails, setShowDetails] = useState(false);
const [showCancelEditGasPopover, setShowCancelEditGasPopover] = useState(
false,
);
const [showCancelEditGasPopover, setShowCancelEditGasPopover] =
useState(false);
const [showRetryEditGasPopover, setShowRetryEditGasPopover] = useState(false);
const { supportsEIP1559V2 } = useGasFeeContext();
const { openModal } = useTransactionModalContext();

@ -23,8 +23,7 @@ function getActionFunctionById(id, history) {
const actionFunctions = {
2: () => {
global.platform.openTab({
url:
'https://survey.alchemer.com/s3/6173069/MetaMask-Extension-NPS-January-2021',
url: 'https://survey.alchemer.com/s3/6173069/MetaMask-Extension-NPS-January-2021',
});
},
3: () => {

@ -7,8 +7,7 @@ import {
import DefinitionList from './definition-list';
const basic = {
term:
'a word or phrase used to describe a thing or to express a concept, especially in a particular kind of language or branch of study.',
term: 'a word or phrase used to describe a thing or to express a concept, especially in a particular kind of language or branch of study.',
definition:
'a statement of the exact meaning of a word, especially in a dictionary.',
dl: 'HTML tag denoting a definition list',

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save