@toruslabs/ethereum-controllers 5.9.1 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,19 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import { CHAIN_NAMESPACES, BaseController, randomId, TransactionStatus, TRANSACTION_TYPES, formatSmallNumbers, addressSlicer, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, significantDigits, BaseBlockTracker, timeout, BaseCurrencyController, BaseKeyringController, PROVIDER_JRPC_METHODS, createFetchMiddleware, createInflightCacheMiddleware, createSwappableProxy, createEventEmitterProxy, BasePreferencesController, isUnauthorizedError, TX_EVENTS, BaseTransactionStateManager, transactionMatchesNetwork as transactionMatchesNetwork$1 } from '@toruslabs/base-controllers';
3
+ import { CHAIN_NAMESPACES, BaseController, randomId, TransactionStatus, TRANSACTION_TYPES, formatSmallNumbers, addressSlicer, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, significantDigits, BaseBlockTracker, timeout, BaseCurrencyController, cloneDeep, BaseKeyringController, PROVIDER_JRPC_METHODS, createFetchMiddleware, createInflightCacheMiddleware, createSwappableProxy, createEventEmitterProxy, BasePreferencesController, isUnauthorizedError, TX_EVENTS, BaseTransactionStateManager, omitBy, transactionMatchesNetwork as transactionMatchesNetwork$1, pickBy } from '@toruslabs/base-controllers';
4
4
  import { Mutex } from 'async-mutex';
5
5
  import { BrowserProvider, toQuantity, Contract, Interface, isHexString as isHexString$1, JsonRpcProvider, keccak256 } from 'ethers';
6
6
  import log from 'loglevel';
7
7
  import { isHexString, addHexPrefix, isValidAddress, toChecksumAddress, stripHexPrefix, bytesToHex, privateToPublic, privateToAddress, ecsign, bigIntToBytes } from '@ethereumjs/util';
8
8
  import BigNumber from 'bignumber.js';
9
- import { rpcErrors, providerErrors } from '@metamask/rpc-errors';
9
+ import { rpcErrors, providerErrors, createAsyncMiddleware, mergeMiddleware, createScaffoldMiddleware, providerFromMiddleware, JRPCEngine, providerFromEngine, SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
10
10
  import { get } from '@toruslabs/http-helpers';
11
- import { cloneDeep, merge, omitBy, mapValues, keyBy, sortBy, pickBy } from 'lodash';
12
11
  import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
13
12
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
14
13
  import BN, { BN as BN$1 } from 'bn.js';
15
14
  import { concatSig, personalSign, signTypedData, getEncryptionPublicKey, decrypt, typedSignatureHash, TYPED_MESSAGE_SCHEMA, SignTypedDataVersion } from '@metamask/eth-sig-util';
16
- import { validate } from 'jsonschema';
17
- import { createAsyncMiddleware, mergeMiddleware, createScaffoldMiddleware, providerFromMiddleware, JRPCEngine, providerFromEngine, SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
18
15
  import stringify from 'fast-safe-stringify';
19
- import { Hardfork, Common } from '@ethereumjs/common';
20
- import { TransactionFactory } from '@ethereumjs/tx';
16
+ import deepmerge from 'deepmerge';
21
17
  import jsonDiffer from 'fast-json-patch';
22
18
 
23
19
  const erc20Abi = [{
@@ -868,15 +864,16 @@ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
868
864
  * Network state changes also retrigger accounts update.
869
865
  */
870
866
  class AccountTrackerController extends BaseController {
871
- constructor({
872
- config,
873
- state,
874
- provider,
875
- blockTracker,
876
- getIdentities,
877
- onPreferencesStateChange,
878
- getCurrentChainId
879
- }) {
867
+ constructor(_ref) {
868
+ let {
869
+ config,
870
+ state,
871
+ provider,
872
+ blockTracker,
873
+ getIdentities,
874
+ onPreferencesStateChange,
875
+ getCurrentChainId
876
+ } = _ref;
880
877
  super({
881
878
  config,
882
879
  state
@@ -1014,8 +1011,14 @@ const erc1155Interface = new Interface(erc1155Abi);
1014
1011
  // functions that handle normalizing of that key in txParams
1015
1012
 
1016
1013
  const normalizers = {
1017
- from: (from, LowerCase = true) => LowerCase ? addHexPrefix(from).toLowerCase() : addHexPrefix(from),
1018
- to: (to, LowerCase = true) => LowerCase ? addHexPrefix(to).toLowerCase() : addHexPrefix(to),
1014
+ from: function (from) {
1015
+ let LowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1016
+ return LowerCase ? addHexPrefix(from).toLowerCase() : addHexPrefix(from);
1017
+ },
1018
+ to: function (to) {
1019
+ let LowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1020
+ return LowerCase ? addHexPrefix(to).toLowerCase() : addHexPrefix(to);
1021
+ },
1019
1022
  nonce: nonce => addHexPrefix(nonce),
1020
1023
  customNonceValue: nonce => addHexPrefix(nonce),
1021
1024
  value: value => addHexPrefix(value),
@@ -1030,7 +1033,8 @@ const normalizers = {
1030
1033
  /**
1031
1034
  * normalizes txParams
1032
1035
  */
1033
- function normalizeTxParameters(txParameters, lowerCase = true) {
1036
+ function normalizeTxParameters(txParameters) {
1037
+ let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1034
1038
  // apply only keys in the normalizers
1035
1039
  const normalizedTxParameters = {
1036
1040
  id: txParameters.id || randomId(),
@@ -1148,7 +1152,8 @@ function validateRecipient(txParameters) {
1148
1152
  * Validates the given tx parameters
1149
1153
  * @throws if the tx params contains invalid fields
1150
1154
  */
1151
- function validateTxParameters(txParams, eip1559Compatibility = true) {
1155
+ function validateTxParameters(txParams) {
1156
+ let eip1559Compatibility = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1152
1157
  if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
1153
1158
  throw rpcErrors.invalidParams("Invalid transaction params: must be an object.");
1154
1159
  }
@@ -1160,7 +1165,8 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
1160
1165
  }) && !eip1559Compatibility) {
1161
1166
  throw rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
1162
1167
  }
1163
- Object.entries(txParams).forEach(([key, value]) => {
1168
+ Object.entries(txParams).forEach(_ref => {
1169
+ let [key, value] = _ref;
1164
1170
  // validate types
1165
1171
  switch (key) {
1166
1172
  case "from":
@@ -1204,7 +1210,8 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
1204
1210
  }
1205
1211
  });
1206
1212
  }
1207
- function normalizeAndValidateTxParams(txParams, lowerCase = true) {
1213
+ function normalizeAndValidateTxParams(txParams) {
1214
+ let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1208
1215
  const normalizedTxParams = normalizeTxParameters(txParams, lowerCase);
1209
1216
  validateTxParameters(normalizedTxParams);
1210
1217
  return normalizedTxParams;
@@ -1540,10 +1547,11 @@ const DEFAULT_POLLING_INTERVAL = 20;
1540
1547
  const DEFAULT_RETRY_TIMEOUT = 2;
1541
1548
  const SEC = 1000;
1542
1549
  class PollingBlockTracker extends BaseBlockTracker {
1543
- constructor({
1544
- config,
1545
- state = {}
1546
- }) {
1550
+ constructor(_ref) {
1551
+ let {
1552
+ config,
1553
+ state = {}
1554
+ } = _ref;
1547
1555
  if (!config.provider) {
1548
1556
  throw new Error("PollingBlockTracker - no provider specified.");
1549
1557
  }
@@ -1615,11 +1623,12 @@ class PollingBlockTracker extends BaseBlockTracker {
1615
1623
  }
1616
1624
 
1617
1625
  class CurrencyController extends BaseCurrencyController {
1618
- constructor({
1619
- config,
1620
- state,
1621
- onNetworkChanged
1622
- }) {
1626
+ constructor(_ref) {
1627
+ let {
1628
+ config,
1629
+ state,
1630
+ onNetworkChanged
1631
+ } = _ref;
1623
1632
  super({
1624
1633
  config,
1625
1634
  state
@@ -1751,19 +1760,20 @@ const isValidBase = base => Number.isInteger(base) && base > 1;
1751
1760
  /**
1752
1761
  * Utility method to convert a value between denominations, formats and currencies.
1753
1762
  */
1754
- const converter = ({
1755
- value,
1756
- fromNumericBase,
1757
- fromDenomination,
1758
- fromCurrency,
1759
- toNumericBase,
1760
- toDenomination,
1761
- toCurrency,
1762
- numberOfDecimals,
1763
- conversionRate,
1764
- invertConversionRate,
1765
- roundDown
1766
- }) => {
1763
+ const converter = _ref => {
1764
+ let {
1765
+ value,
1766
+ fromNumericBase,
1767
+ fromDenomination,
1768
+ fromCurrency,
1769
+ toNumericBase,
1770
+ toDenomination,
1771
+ toCurrency,
1772
+ numberOfDecimals,
1773
+ conversionRate,
1774
+ invertConversionRate,
1775
+ roundDown
1776
+ } = _ref;
1767
1777
  let convertedValue = fromNumericBase ? toBigNumber[fromNumericBase](value) : value;
1768
1778
  if (fromDenomination) {
1769
1779
  convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
@@ -1792,17 +1802,18 @@ const converter = ({
1792
1802
  }
1793
1803
  return convertedValue;
1794
1804
  };
1795
- const conversionUtil = (value, {
1796
- fromCurrency = null,
1797
- toCurrency = fromCurrency,
1798
- fromNumericBase,
1799
- toNumericBase,
1800
- fromDenomination,
1801
- toDenomination,
1802
- numberOfDecimals,
1803
- conversionRate,
1804
- invertConversionRate
1805
- }) => {
1805
+ const conversionUtil = (value, _ref2) => {
1806
+ let {
1807
+ fromCurrency = null,
1808
+ toCurrency = fromCurrency,
1809
+ fromNumericBase,
1810
+ toNumericBase,
1811
+ fromDenomination,
1812
+ toDenomination,
1813
+ numberOfDecimals,
1814
+ conversionRate,
1815
+ invertConversionRate
1816
+ } = _ref2;
1806
1817
  if (fromCurrency !== toCurrency && !conversionRate) {
1807
1818
  return 0;
1808
1819
  }
@@ -1831,7 +1842,8 @@ const getBigNumber = (value, base) => {
1831
1842
  }
1832
1843
  return new BigNumber(String(value), base);
1833
1844
  };
1834
- const addCurrencies = (a, b, options = {}) => {
1845
+ const addCurrencies = function (a, b) {
1846
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1835
1847
  const {
1836
1848
  aBase,
1837
1849
  bBase
@@ -1845,7 +1857,8 @@ const addCurrencies = (a, b, options = {}) => {
1845
1857
  value
1846
1858
  }, conversionOptions));
1847
1859
  };
1848
- const subtractCurrencies = (a, b, options = {}) => {
1860
+ const subtractCurrencies = function (a, b) {
1861
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1849
1862
  const {
1850
1863
  aBase,
1851
1864
  bBase
@@ -1859,7 +1872,8 @@ const subtractCurrencies = (a, b, options = {}) => {
1859
1872
  value
1860
1873
  }, conversionOptions));
1861
1874
  };
1862
- const multiplyCurrencies = (a, b, options = {}) => {
1875
+ const multiplyCurrencies = function (a, b) {
1876
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1863
1877
  const {
1864
1878
  multiplicandBase,
1865
1879
  multiplierBase
@@ -1873,41 +1887,44 @@ const multiplyCurrencies = (a, b, options = {}) => {
1873
1887
  value
1874
1888
  }, conversionOptions));
1875
1889
  };
1876
- const conversionGreaterThan = (_ref, _ref2) => {
1877
- let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref2), _ref2));
1878
- let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
1890
+ const conversionGreaterThan = (_ref3, _ref4) => {
1891
+ let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref4), _ref4));
1892
+ let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref3), _ref3));
1879
1893
  const firstValue = converter(_objectSpread({}, firstProps));
1880
1894
  const secondValue = converter(_objectSpread({}, secondProps));
1881
1895
  return firstValue.gt(secondValue);
1882
1896
  };
1883
- const conversionLessThan = (_ref3, _ref4) => {
1884
- let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref4), _ref4));
1885
- let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref3), _ref3));
1897
+ const conversionLessThan = (_ref5, _ref6) => {
1898
+ let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref6), _ref6));
1899
+ let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref5), _ref5));
1886
1900
  const firstValue = converter(_objectSpread({}, firstProps));
1887
1901
  const secondValue = converter(_objectSpread({}, secondProps));
1888
1902
  return firstValue.lt(secondValue);
1889
1903
  };
1890
- const conversionMax = (_ref5, _ref6) => {
1891
- let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref6), _ref6));
1892
- let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref5), _ref5));
1904
+ const conversionMax = (_ref7, _ref8) => {
1905
+ let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref8), _ref8));
1906
+ let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref7), _ref7));
1893
1907
  const firstIsGreater = conversionGreaterThan(_objectSpread({}, firstProps), _objectSpread({}, secondProps));
1894
1908
  return firstIsGreater ? firstProps.value : secondProps.value;
1895
1909
  };
1896
- const conversionGTE = (_ref7, _ref8) => {
1897
- let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref8), _ref8));
1898
- let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref7), _ref7));
1910
+ const conversionGTE = (_ref9, _ref10) => {
1911
+ let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref10), _ref10));
1912
+ let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref9), _ref9));
1899
1913
  const firstValue = converter(_objectSpread({}, firstProps));
1900
1914
  const secondValue = converter(_objectSpread({}, secondProps));
1901
1915
  return firstValue.isGreaterThanOrEqualTo(secondValue);
1902
1916
  };
1903
- const conversionLTE = (_ref9, _ref10) => {
1904
- let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref10), _ref10));
1905
- let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref9), _ref9));
1917
+ const conversionLTE = (_ref11, _ref12) => {
1918
+ let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref12), _ref12));
1919
+ let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref11), _ref11));
1906
1920
  const firstValue = converter(_objectSpread({}, firstProps));
1907
1921
  const secondValue = converter(_objectSpread({}, secondProps));
1908
1922
  return firstValue.isLessThanOrEqualTo(secondValue);
1909
1923
  };
1910
- const toNegative = (n, options = {}) => multiplyCurrencies(n, -1, options);
1924
+ const toNegative = function (n) {
1925
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1926
+ return multiplyCurrencies(n, -1, options);
1927
+ };
1911
1928
  const decGWEIToHexWEI = decGWEI => {
1912
1929
  return conversionUtil(decGWEI, {
1913
1930
  fromNumericBase: "dec",
@@ -2065,20 +2082,21 @@ const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices
2065
2082
  * Returns gas prices in dec gwei
2066
2083
  */
2067
2084
  class GasFeeController extends BaseController {
2068
- constructor({
2069
- config,
2070
- state,
2071
- getNetworkIdentifier,
2072
- getProvider,
2073
- fetchGasEstimates: fetchGasEstimates$1 = fetchGasEstimates,
2074
- fetchEthGasPriceEstimate: fetchEthGasPriceEstimate$1 = fetchEthGasPriceEstimate,
2075
- fetchLegacyGasPriceEstimates: fetchLegacyGasPriceEstimates$1 = fetchLegacyGasPriceEstimates,
2076
- fetchGasEstimatesViaEthFeeHistory: fetchGasEstimatesViaEthFeeHistory$1 = fetchGasEstimatesViaEthFeeHistory,
2077
- getCurrentNetworkLegacyGasAPICompatibility,
2078
- getCurrentNetworkEIP1559Compatibility,
2079
- getCurrentAccountEIP1559Compatibility,
2080
- onNetworkStateChange
2081
- }) {
2085
+ constructor(_ref) {
2086
+ let {
2087
+ config,
2088
+ state,
2089
+ getNetworkIdentifier,
2090
+ getProvider,
2091
+ fetchGasEstimates: fetchGasEstimates$1 = fetchGasEstimates,
2092
+ fetchEthGasPriceEstimate: fetchEthGasPriceEstimate$1 = fetchEthGasPriceEstimate,
2093
+ fetchLegacyGasPriceEstimates: fetchLegacyGasPriceEstimates$1 = fetchLegacyGasPriceEstimates,
2094
+ fetchGasEstimatesViaEthFeeHistory: fetchGasEstimatesViaEthFeeHistory$1 = fetchGasEstimatesViaEthFeeHistory,
2095
+ getCurrentNetworkLegacyGasAPICompatibility,
2096
+ getCurrentNetworkEIP1559Compatibility,
2097
+ getCurrentAccountEIP1559Compatibility,
2098
+ onNetworkStateChange
2099
+ } = _ref;
2082
2100
  super({
2083
2101
  config,
2084
2102
  state
@@ -2263,10 +2281,11 @@ class GasFeeController extends BaseController {
2263
2281
  }
2264
2282
 
2265
2283
  class KeyringController extends BaseKeyringController {
2266
- constructor({
2267
- config,
2268
- state
2269
- }) {
2284
+ constructor(_ref) {
2285
+ let {
2286
+ config,
2287
+ state
2288
+ } = _ref;
2270
2289
  super({
2271
2290
  config,
2272
2291
  state
@@ -2372,11 +2391,12 @@ class AbstractMessageController extends BaseController {
2372
2391
  * Controller in charge of managing - storing, adding, removing, updating - Messages.
2373
2392
  *
2374
2393
  */
2375
- constructor({
2376
- config,
2377
- state,
2378
- getNetworkIdentifier
2379
- }) {
2394
+ constructor(_ref) {
2395
+ let {
2396
+ config,
2397
+ state,
2398
+ getNetworkIdentifier
2399
+ } = _ref;
2380
2400
  super({
2381
2401
  config,
2382
2402
  state
@@ -2503,7 +2523,7 @@ function validateTypedSignMessageDataV1(messageData) {
2503
2523
  throw new Error(`Expected EIP712 typed data.`);
2504
2524
  }
2505
2525
  }
2506
- function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
2526
+ async function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
2507
2527
  validateAddress(messageData.from, "from");
2508
2528
  if (!messageData.data || Array.isArray(messageData.data) || typeof messageData.data !== "object" && typeof messageData.data !== "string") {
2509
2529
  throw new Error(`Invalid message "data": Must be a valid string or object.`);
@@ -2518,6 +2538,9 @@ function validateTypedSignMessageDataV3V4(messageData, currentChainId) {
2518
2538
  throw new Error("Data must be passed as a valid JSON string.");
2519
2539
  }
2520
2540
  }
2541
+ const {
2542
+ validate
2543
+ } = await import('jsonschema');
2521
2544
  const validation = validate(data, TYPED_MESSAGE_SCHEMA);
2522
2545
  if (validation.errors.length > 0) {
2523
2546
  throw new Error("Data must conform to EIP-712 schema. See https://git.io/fNtcx.");
@@ -2601,12 +2624,13 @@ function validateSwitchChainData(data) {
2601
2624
  }
2602
2625
 
2603
2626
  class AddChainController extends AbstractMessageController {
2604
- constructor({
2605
- config,
2606
- state,
2607
- getNetworkIdentifier,
2608
- addChain
2609
- }) {
2627
+ constructor(_ref) {
2628
+ let {
2629
+ config,
2630
+ state,
2631
+ getNetworkIdentifier,
2632
+ addChain
2633
+ } = _ref;
2610
2634
  super({
2611
2635
  config,
2612
2636
  state,
@@ -2663,12 +2687,13 @@ class AddChainController extends AbstractMessageController {
2663
2687
  }
2664
2688
 
2665
2689
  class DecryptMessageController extends AbstractMessageController {
2666
- constructor({
2667
- config,
2668
- state,
2669
- decryptMessage,
2670
- getNetworkIdentifier
2671
- }) {
2690
+ constructor(_ref) {
2691
+ let {
2692
+ config,
2693
+ state,
2694
+ decryptMessage,
2695
+ getNetworkIdentifier
2696
+ } = _ref;
2672
2697
  super({
2673
2698
  config,
2674
2699
  state,
@@ -2727,12 +2752,13 @@ class DecryptMessageController extends AbstractMessageController {
2727
2752
  }
2728
2753
 
2729
2754
  class EncryptionPublicKeyController extends AbstractMessageController {
2730
- constructor({
2731
- config,
2732
- state,
2733
- signEncryptionPublicKey,
2734
- getNetworkIdentifier
2735
- }) {
2755
+ constructor(_ref) {
2756
+ let {
2757
+ config,
2758
+ state,
2759
+ signEncryptionPublicKey,
2760
+ getNetworkIdentifier
2761
+ } = _ref;
2736
2762
  super({
2737
2763
  config,
2738
2764
  state,
@@ -2792,12 +2818,13 @@ class EncryptionPublicKeyController extends AbstractMessageController {
2792
2818
  }
2793
2819
 
2794
2820
  class MessageController extends AbstractMessageController {
2795
- constructor({
2796
- config,
2797
- state,
2798
- signMessage,
2799
- getNetworkIdentifier
2800
- }) {
2821
+ constructor(_ref) {
2822
+ let {
2823
+ config,
2824
+ state,
2825
+ signMessage,
2826
+ getNetworkIdentifier
2827
+ } = _ref;
2801
2828
  super({
2802
2829
  config,
2803
2830
  state,
@@ -2855,12 +2882,13 @@ class MessageController extends AbstractMessageController {
2855
2882
  }
2856
2883
 
2857
2884
  class PersonalMessageController extends AbstractMessageController {
2858
- constructor({
2859
- config,
2860
- state,
2861
- signPersonalMessage,
2862
- getNetworkIdentifier
2863
- }) {
2885
+ constructor(_ref) {
2886
+ let {
2887
+ config,
2888
+ state,
2889
+ signPersonalMessage,
2890
+ getNetworkIdentifier
2891
+ } = _ref;
2864
2892
  super({
2865
2893
  config,
2866
2894
  state,
@@ -2918,12 +2946,13 @@ class PersonalMessageController extends AbstractMessageController {
2918
2946
  }
2919
2947
 
2920
2948
  class SwitchChainController extends AbstractMessageController {
2921
- constructor({
2922
- config,
2923
- state,
2924
- getNetworkIdentifier,
2925
- switchChain
2926
- }) {
2949
+ constructor(_ref) {
2950
+ let {
2951
+ config,
2952
+ state,
2953
+ getNetworkIdentifier,
2954
+ switchChain
2955
+ } = _ref;
2927
2956
  super({
2928
2957
  config,
2929
2958
  state,
@@ -2994,12 +3023,13 @@ function getMessageType(version) {
2994
3023
  }
2995
3024
  }
2996
3025
  class TypedMessageController extends AbstractMessageController {
2997
- constructor({
2998
- config,
2999
- state,
3000
- signTypedData,
3001
- getNetworkIdentifier
3002
- }) {
3026
+ constructor(_ref) {
3027
+ let {
3028
+ config,
3029
+ state,
3030
+ signTypedData,
3031
+ getNetworkIdentifier
3032
+ } = _ref;
3003
3033
  super({
3004
3034
  config,
3005
3035
  state,
@@ -3037,7 +3067,7 @@ class TypedMessageController extends AbstractMessageController {
3037
3067
  }
3038
3068
  if (version === SignTypedDataVersion.V3 || version === SignTypedDataVersion.V4) {
3039
3069
  const currentChainId = this.getNetworkIdentifier();
3040
- validateTypedSignMessageDataV3V4(messageParams, currentChainId);
3070
+ await validateTypedSignMessageDataV3V4(messageParams, currentChainId);
3041
3071
  }
3042
3072
  if (typeof messageParams.data !== "string" && (version === SignTypedDataVersion.V3 || version === SignTypedDataVersion.V4)) {
3043
3073
  messageParams.data = JSON.stringify(messageParams.data);
@@ -3066,9 +3096,10 @@ class TypedMessageController extends AbstractMessageController {
3066
3096
  }
3067
3097
  }
3068
3098
 
3069
- function createGetAccountsMiddleware({
3070
- getAccounts
3071
- }) {
3099
+ function createGetAccountsMiddleware(_ref) {
3100
+ let {
3101
+ getAccounts
3102
+ } = _ref;
3072
3103
  return createAsyncMiddleware(async (request, response, next) => {
3073
3104
  const {
3074
3105
  method
@@ -3079,9 +3110,10 @@ function createGetAccountsMiddleware({
3079
3110
  response.result = accounts;
3080
3111
  });
3081
3112
  }
3082
- function createProcessTransactionMiddleware({
3083
- processTransaction
3084
- }) {
3113
+ function createProcessTransactionMiddleware(_ref2) {
3114
+ let {
3115
+ processTransaction
3116
+ } = _ref2;
3085
3117
  return createAsyncMiddleware(async (request, response, next) => {
3086
3118
  const {
3087
3119
  method
@@ -3091,9 +3123,10 @@ function createProcessTransactionMiddleware({
3091
3123
  response.result = await processTransaction(request.params, request);
3092
3124
  });
3093
3125
  }
3094
- function createProcessEthSignMessage({
3095
- processEthSignMessage
3096
- }) {
3126
+ function createProcessEthSignMessage(_ref3) {
3127
+ let {
3128
+ processEthSignMessage
3129
+ } = _ref3;
3097
3130
  return createAsyncMiddleware(async (request, response, next) => {
3098
3131
  const {
3099
3132
  method
@@ -3115,9 +3148,10 @@ function createProcessEthSignMessage({
3115
3148
  response.result = await processEthSignMessage(msgParams, request);
3116
3149
  });
3117
3150
  }
3118
- function createProcessTypedMessage({
3119
- processTypedMessage
3120
- }) {
3151
+ function createProcessTypedMessage(_ref4) {
3152
+ let {
3153
+ processTypedMessage
3154
+ } = _ref4;
3121
3155
  return createAsyncMiddleware(async (request, response, next) => {
3122
3156
  const {
3123
3157
  method
@@ -3140,9 +3174,10 @@ function createProcessTypedMessage({
3140
3174
  response.result = await processTypedMessage(msgParams, request);
3141
3175
  });
3142
3176
  }
3143
- function createProcessTypedMessageV3({
3144
- processTypedMessageV3
3145
- }) {
3177
+ function createProcessTypedMessageV3(_ref5) {
3178
+ let {
3179
+ processTypedMessageV3
3180
+ } = _ref5;
3146
3181
  return createAsyncMiddleware(async (request, response, next) => {
3147
3182
  const {
3148
3183
  method
@@ -3165,9 +3200,10 @@ function createProcessTypedMessageV3({
3165
3200
  response.result = await processTypedMessageV3(msgParams, request);
3166
3201
  });
3167
3202
  }
3168
- function createProcessTypedMessageV4({
3169
- processTypedMessageV4
3170
- }) {
3203
+ function createProcessTypedMessageV4(_ref6) {
3204
+ let {
3205
+ processTypedMessageV4
3206
+ } = _ref6;
3171
3207
  return createAsyncMiddleware(async (request, response, next) => {
3172
3208
  const {
3173
3209
  method
@@ -3190,9 +3226,10 @@ function createProcessTypedMessageV4({
3190
3226
  response.result = await processTypedMessageV4(msgParams, request);
3191
3227
  });
3192
3228
  }
3193
- function createProcessPersonalMessage({
3194
- processPersonalMessage
3195
- }) {
3229
+ function createProcessPersonalMessage(_ref7) {
3230
+ let {
3231
+ processPersonalMessage
3232
+ } = _ref7;
3196
3233
  return createAsyncMiddleware(async (request, response, next) => {
3197
3234
  const {
3198
3235
  method
@@ -3225,9 +3262,10 @@ function createProcessPersonalMessage({
3225
3262
  response.result = await processPersonalMessage(msgParams, request);
3226
3263
  });
3227
3264
  }
3228
- function createPendingNonceMiddleware({
3229
- getPendingNonce
3230
- }) {
3265
+ function createPendingNonceMiddleware(_ref8) {
3266
+ let {
3267
+ getPendingNonce
3268
+ } = _ref8;
3231
3269
  return createAsyncMiddleware(async (request, response, next) => {
3232
3270
  const {
3233
3271
  params,
@@ -3289,9 +3327,10 @@ function formatTxMetaForRpcResult(txMeta) {
3289
3327
  }
3290
3328
  return formattedTxMeta;
3291
3329
  }
3292
- function createPendingTxMiddleware({
3293
- getPendingTransactionByHash
3294
- }) {
3330
+ function createPendingTxMiddleware(_ref9) {
3331
+ let {
3332
+ getPendingTransactionByHash
3333
+ } = _ref9;
3295
3334
  return createAsyncMiddleware(async (request, response, next) => {
3296
3335
  const {
3297
3336
  params,
@@ -3307,9 +3346,10 @@ function createPendingTxMiddleware({
3307
3346
  return undefined;
3308
3347
  });
3309
3348
  }
3310
- function createProcessEncryptionPublicKeyMiddleware({
3311
- processEncryptionPublicKey
3312
- }) {
3349
+ function createProcessEncryptionPublicKeyMiddleware(_ref10) {
3350
+ let {
3351
+ processEncryptionPublicKey
3352
+ } = _ref10;
3313
3353
  return createAsyncMiddleware(async (request, response, next) => {
3314
3354
  const {
3315
3355
  method
@@ -3329,9 +3369,10 @@ function createProcessEncryptionPublicKeyMiddleware({
3329
3369
  response.result = await processEncryptionPublicKey(msgParams, request);
3330
3370
  });
3331
3371
  }
3332
- function createProcessDecryptMessageMiddleware({
3333
- processDecryptMessage
3334
- }) {
3372
+ function createProcessDecryptMessageMiddleware(_ref11) {
3373
+ let {
3374
+ processDecryptMessage
3375
+ } = _ref11;
3335
3376
  return createAsyncMiddleware(async (request, response, next) => {
3336
3377
  const {
3337
3378
  method
@@ -3351,9 +3392,10 @@ function createProcessDecryptMessageMiddleware({
3351
3392
  response.result = await processDecryptMessage(msgParams, request);
3352
3393
  });
3353
3394
  }
3354
- function createProcessSwitchEthereumChain({
3355
- processSwitchEthereumChain
3356
- }) {
3395
+ function createProcessSwitchEthereumChain(_ref12) {
3396
+ let {
3397
+ processSwitchEthereumChain
3398
+ } = _ref12;
3357
3399
  return createAsyncMiddleware(async (request, response, next) => {
3358
3400
  const {
3359
3401
  method
@@ -3370,9 +3412,10 @@ function createProcessSwitchEthereumChain({
3370
3412
  response.result = await processSwitchEthereumChain(msgParams, request);
3371
3413
  });
3372
3414
  }
3373
- function createProcessAddEthereumChain({
3374
- processAddEthereumChain
3375
- }) {
3415
+ function createProcessAddEthereumChain(_ref13) {
3416
+ let {
3417
+ processAddEthereumChain
3418
+ } = _ref13;
3376
3419
  return createAsyncMiddleware(async (request, response, next) => {
3377
3420
  const {
3378
3421
  method
@@ -3389,9 +3432,10 @@ function createProcessAddEthereumChain({
3389
3432
  response.result = await processAddEthereumChain(msgParams, request);
3390
3433
  });
3391
3434
  }
3392
- function createRequestAccountsMiddleware({
3393
- requestAccounts
3394
- }) {
3435
+ function createRequestAccountsMiddleware(_ref14) {
3436
+ let {
3437
+ requestAccounts
3438
+ } = _ref14;
3395
3439
  return createAsyncMiddleware(async (request, response, next) => {
3396
3440
  const {
3397
3441
  method
@@ -3616,10 +3660,11 @@ function createJsonRpcClient(providerConfig, networkConfig) {
3616
3660
 
3617
3661
  const _excluded = ["chainId", "rpcTarget"];
3618
3662
  class NetworkController extends BaseController {
3619
- constructor({
3620
- config,
3621
- state
3622
- }) {
3663
+ constructor(_ref) {
3664
+ let {
3665
+ config,
3666
+ state
3667
+ } = _ref;
3623
3668
  super({
3624
3669
  config,
3625
3670
  state
@@ -3746,10 +3791,11 @@ class NetworkController extends BaseController {
3746
3791
  rpcTarget
3747
3792
  }, rest));
3748
3793
  }
3749
- setNetworkClient({
3750
- networkMiddleware,
3751
- blockTracker
3752
- }) {
3794
+ setNetworkClient(_ref2) {
3795
+ let {
3796
+ networkMiddleware,
3797
+ blockTracker
3798
+ } = _ref2;
3753
3799
  const ethereumMiddleware = createEthereumMiddleware(this.baseProviderHandlers);
3754
3800
  const engine = new JRPCEngine();
3755
3801
  engine.push(ethereumMiddleware);
@@ -3760,10 +3806,11 @@ class NetworkController extends BaseController {
3760
3806
  blockTracker
3761
3807
  });
3762
3808
  }
3763
- setProvider({
3764
- provider,
3765
- blockTracker
3766
- }) {
3809
+ setProvider(_ref3) {
3810
+ let {
3811
+ provider,
3812
+ blockTracker
3813
+ } = _ref3;
3767
3814
  if (this.providerProxy) {
3768
3815
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3769
3816
  // @ts-ignore
@@ -3802,18 +3849,19 @@ class NetworkController extends BaseController {
3802
3849
  }
3803
3850
 
3804
3851
  class NftHandler {
3805
- constructor({
3806
- chainId,
3807
- contractAddress,
3808
- contractImage,
3809
- contractName,
3810
- contractSymbol,
3811
- nftStandard,
3812
- provider,
3813
- contractDescription,
3814
- contractFallbackLogo,
3815
- contractSupply
3816
- }) {
3852
+ constructor(_ref) {
3853
+ let {
3854
+ chainId,
3855
+ contractAddress,
3856
+ contractImage,
3857
+ contractName,
3858
+ contractSymbol,
3859
+ nftStandard,
3860
+ provider,
3861
+ contractDescription,
3862
+ contractFallbackLogo,
3863
+ contractSupply
3864
+ } = _ref;
3817
3865
  _defineProperty(this, "contractAddress", void 0);
3818
3866
  _defineProperty(this, "contractName", void 0);
3819
3867
  _defineProperty(this, "contractSymbol", void 0);
@@ -3961,7 +4009,8 @@ class NftHandler {
3961
4009
  const contract = new Contract(this.contractAddress, abi, this.provider);
3962
4010
  return contract.supportsInterface(interfaceId);
3963
4011
  }
3964
- async getCollectibleTokenURI(tokenId, standard = CONTRACT_TYPE_ERC721) {
4012
+ async getCollectibleTokenURI(tokenId) {
4013
+ let standard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CONTRACT_TYPE_ERC721;
3965
4014
  const method = standard === CONTRACT_TYPE_ERC721 ? "tokenURI" : "uri";
3966
4015
  const abi = standard === CONTRACT_TYPE_ERC721 ? erc721Abi : erc1155Abi;
3967
4016
  const contract = new Contract(this.contractAddress, abi, this.provider);
@@ -3971,15 +4020,16 @@ class NftHandler {
3971
4020
 
3972
4021
  const DEFAULT_INTERVAL$1 = 180 * 1000;
3973
4022
  class NftsController extends BaseController {
3974
- constructor({
3975
- config,
3976
- state,
3977
- provider,
3978
- getCustomNfts,
3979
- getSimpleHashNfts,
3980
- onPreferencesStateChange,
3981
- onNetworkStateChange
3982
- }) {
4023
+ constructor(_ref) {
4024
+ let {
4025
+ config,
4026
+ state,
4027
+ provider,
4028
+ getCustomNfts,
4029
+ getSimpleHashNfts,
4030
+ onPreferencesStateChange,
4031
+ onNetworkStateChange
4032
+ } = _ref;
3983
4033
  super({
3984
4034
  config,
3985
4035
  state
@@ -4163,22 +4213,23 @@ class NftsController extends BaseController {
4163
4213
  const nonZeroTokens = promiseSettledResult.filter(x => x.status === "fulfilled").map(x => x.value);
4164
4214
  this.update({
4165
4215
  nfts: {
4166
- [userAddress]: merge(this.userNfts, nonZeroTokens)
4216
+ [userAddress]: deepmerge(this.userNfts, nonZeroTokens)
4167
4217
  }
4168
4218
  });
4169
4219
  }
4170
4220
  }
4171
4221
 
4172
4222
  class PreferencesController extends BasePreferencesController {
4173
- constructor({
4174
- config,
4175
- state,
4176
- provider,
4177
- signAuthMessage,
4178
- getProviderConfig,
4179
- setProviderConfig,
4180
- validateSignMessage
4181
- }) {
4223
+ constructor(_ref) {
4224
+ let {
4225
+ config,
4226
+ state,
4227
+ provider,
4228
+ signAuthMessage,
4229
+ getProviderConfig,
4230
+ setProviderConfig,
4231
+ validateSignMessage
4232
+ } = _ref;
4182
4233
  super({
4183
4234
  config,
4184
4235
  state,
@@ -4458,9 +4509,10 @@ class PreferencesController extends BasePreferencesController {
4458
4509
  }
4459
4510
 
4460
4511
  // Custom Network methods
4461
- async addCustomNetwork({
4462
- network
4463
- }) {
4512
+ async addCustomNetwork(_ref2) {
4513
+ let {
4514
+ network
4515
+ } = _ref2;
4464
4516
  try {
4465
4517
  const {
4466
4518
  selectedAddress
@@ -4500,10 +4552,11 @@ class PreferencesController extends BasePreferencesController {
4500
4552
  return false;
4501
4553
  }
4502
4554
  }
4503
- async editCustomNetwork({
4504
- network,
4505
- id
4506
- }) {
4555
+ async editCustomNetwork(_ref3) {
4556
+ let {
4557
+ network,
4558
+ id
4559
+ } = _ref3;
4507
4560
  try {
4508
4561
  const {
4509
4562
  selectedAddress
@@ -4526,8 +4579,9 @@ class PreferencesController extends BasePreferencesController {
4526
4579
  return false;
4527
4580
  }
4528
4581
  }
4529
- getChainOptions(address = this.state.selectedAddress) {
4582
+ getChainOptions() {
4530
4583
  var _identities$address$c, _identities$address;
4584
+ let address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.selectedAddress;
4531
4585
  const {
4532
4586
  identities
4533
4587
  } = this.state;
@@ -4634,13 +4688,14 @@ class PreferencesController extends BasePreferencesController {
4634
4688
  }
4635
4689
 
4636
4690
  class TokenHandler {
4637
- constructor({
4638
- address,
4639
- symbol,
4640
- decimals,
4641
- name,
4642
- provider
4643
- }) {
4691
+ constructor(_ref) {
4692
+ let {
4693
+ address,
4694
+ symbol,
4695
+ decimals,
4696
+ name,
4697
+ provider
4698
+ } = _ref;
4644
4699
  _defineProperty(this, "address", void 0);
4645
4700
  _defineProperty(this, "symbol", void 0);
4646
4701
  _defineProperty(this, "decimals", void 0);
@@ -4672,19 +4727,20 @@ class TokenHandler {
4672
4727
  async getUserBalance(userAddress) {
4673
4728
  if (!this.decimals) await this.getDecimals();
4674
4729
  const balance = await this.contract.balanceOf(userAddress);
4675
- return new BigNumber(balance).toString(16);
4730
+ return balance.toString(16);
4676
4731
  }
4677
4732
  }
4678
4733
 
4679
4734
  const DEFAULT_CURRENCY = "eth";
4680
4735
  class TokenRatesController extends BaseController {
4681
- constructor({
4682
- config,
4683
- state,
4684
- onPreferencesStateChange,
4685
- onNetworkStateChange,
4686
- onTokensStateChange
4687
- }) {
4736
+ constructor(_ref) {
4737
+ let {
4738
+ config,
4739
+ state,
4740
+ onPreferencesStateChange,
4741
+ onNetworkStateChange,
4742
+ onTokensStateChange
4743
+ } = _ref;
4688
4744
  super({
4689
4745
  config,
4690
4746
  state
@@ -4795,16 +4851,17 @@ const mergeTokenArrays = (oldArray, newArray) => {
4795
4851
  };
4796
4852
  const DEFAULT_INTERVAL = 180 * 1000;
4797
4853
  class TokensController extends BaseController {
4798
- constructor({
4799
- config,
4800
- state,
4801
- provider,
4802
- getCustomTokens,
4803
- getEtherScanTokens,
4804
- getProviderConfig,
4805
- onPreferencesStateChange,
4806
- onNetworkStateChange
4807
- }) {
4854
+ constructor(_ref) {
4855
+ let {
4856
+ config,
4857
+ state,
4858
+ provider,
4859
+ getCustomTokens,
4860
+ getEtherScanTokens,
4861
+ getProviderConfig,
4862
+ onPreferencesStateChange,
4863
+ onNetworkStateChange
4864
+ } = _ref;
4808
4865
  super({
4809
4866
  config,
4810
4867
  state
@@ -5022,12 +5079,13 @@ class TokensController extends BaseController {
5022
5079
  }
5023
5080
 
5024
5081
  class NonceTracker {
5025
- constructor({
5026
- provider,
5027
- blockTracker,
5028
- getPendingTransactions,
5029
- getConfirmedTransactions
5030
- }) {
5082
+ constructor(_ref) {
5083
+ let {
5084
+ provider,
5085
+ blockTracker,
5086
+ getPendingTransactions,
5087
+ getConfirmedTransactions
5088
+ } = _ref;
5031
5089
  _defineProperty(this, "provider", void 0);
5032
5090
  _defineProperty(this, "blockTracker", void 0);
5033
5091
  _defineProperty(this, "getPendingTransactions", void 0);
@@ -5165,14 +5223,15 @@ class NonceTracker {
5165
5223
  }
5166
5224
 
5167
5225
  class PendingTransactionTracker extends SafeEventEmitter {
5168
- constructor({
5169
- provider,
5170
- nonceTracker,
5171
- approveTransaction,
5172
- publishTransaction,
5173
- getPendingTransactions,
5174
- getConfirmedTransactions
5175
- }) {
5226
+ constructor(_ref) {
5227
+ let {
5228
+ provider,
5229
+ nonceTracker,
5230
+ approveTransaction,
5231
+ publishTransaction,
5232
+ getPendingTransactions,
5233
+ getConfirmedTransactions
5234
+ } = _ref;
5176
5235
  super();
5177
5236
  _defineProperty(this, "DROPPED_BUFFER_COUNT", 3);
5178
5237
  _defineProperty(this, "nonceTracker", void 0);
@@ -5414,7 +5473,8 @@ class TransactionGasUtil {
5414
5473
  /**
5415
5474
  Adds a gas buffer with out exceeding the block gas limit
5416
5475
  */
5417
- addGasBuffer(initialGasLimitHex, blockGasLimitHex, multiplier = 1.5) {
5476
+ addGasBuffer(initialGasLimitHex, blockGasLimitHex) {
5477
+ let multiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.5;
5418
5478
  const initialGasLimitBn = new BN$1(stripHexPrefix(initialGasLimitHex), 16);
5419
5479
  const blockGasLimitBn = new BN$1(stripHexPrefix(blockGasLimitHex), 16);
5420
5480
  const upperGasLimitBn = blockGasLimitBn.muln(0.9);
@@ -5449,6 +5509,29 @@ class TransactionGasUtil {
5449
5509
  }
5450
5510
  }
5451
5511
 
5512
+ function sortBy(arr, key) {
5513
+ return arr.slice().sort((a, b) => {
5514
+ if (a[key] < b[key]) return -1;
5515
+ if (a[key] > b[key]) return 1;
5516
+ return 0;
5517
+ });
5518
+ }
5519
+ function keyBy(arr, key) {
5520
+ return arr.reduce((acc, item) => {
5521
+ const keyValue = item[key];
5522
+ if (typeof keyValue === "string" || typeof keyValue === "number") {
5523
+ acc[keyValue.toString()] = item;
5524
+ }
5525
+ return acc;
5526
+ }, {});
5527
+ }
5528
+ function mapValues(obj, iteratee) {
5529
+ return Object.fromEntries(Object.entries(obj).map(_ref => {
5530
+ let [key, value] = _ref;
5531
+ return [key, iteratee(value, key)];
5532
+ }));
5533
+ }
5534
+
5452
5535
  /**
5453
5536
  Generates an array of history objects sense the previous state.
5454
5537
  The object has the keys
@@ -5483,18 +5566,20 @@ function snapshotFromTxMeta(txMeta) {
5483
5566
  }
5484
5567
 
5485
5568
  class TransactionStateManager extends BaseTransactionStateManager {
5486
- constructor({
5487
- config,
5488
- state,
5489
- getCurrentChainId
5490
- }) {
5569
+ constructor(_ref) {
5570
+ let {
5571
+ config,
5572
+ state,
5573
+ getCurrentChainId
5574
+ } = _ref;
5491
5575
  super({
5492
5576
  config,
5493
5577
  state,
5494
5578
  getCurrentChainId
5495
5579
  });
5496
5580
  }
5497
- generateTxMeta(opts = {}) {
5581
+ generateTxMeta() {
5582
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5498
5583
  const chainId = this.getCurrentChainId();
5499
5584
  if (chainId === "loading") throw new Error("Torus is having trouble connecting to the network");
5500
5585
  let dappSuggestedGasFees = null;
@@ -5604,12 +5689,13 @@ class TransactionStateManager extends BaseTransactionStateManager {
5604
5689
  })
5605
5690
  });
5606
5691
  }
5607
- getTransactions({
5608
- searchCriteria = {},
5609
- initialList = undefined,
5610
- filterToCurrentNetwork = true,
5611
- limit = undefined
5612
- } = {}) {
5692
+ getTransactions() {
5693
+ let {
5694
+ searchCriteria = {},
5695
+ initialList = undefined,
5696
+ filterToCurrentNetwork = true,
5697
+ limit = undefined
5698
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5613
5699
  const chainId = this.getCurrentChainId();
5614
5700
  // searchCriteria is an object that might have values that aren't predicate
5615
5701
  // methods. When providing any other value type (string, number, etc), we
@@ -5627,7 +5713,7 @@ class TransactionStateManager extends BaseTransactionStateManager {
5627
5713
 
5628
5714
  // Combine sortBy and pickBy to transform our state object into an array of
5629
5715
  // matching transactions that are sorted by time.
5630
- const filteredTransactions = sortBy(pickBy(transactionsToFilter, txMeta => {
5716
+ const filteredTransactions = sortBy(Object.values(pickBy(transactionsToFilter, txMeta => {
5631
5717
  // default matchesCriteria to the value of transactionMatchesNetwork
5632
5718
  // when filterToCurrentNetwork is true.
5633
5719
  const transactionMatches = transactionMatchesNetwork$1(txMeta, chainId);
@@ -5651,7 +5737,7 @@ class TransactionStateManager extends BaseTransactionStateManager {
5651
5737
  }
5652
5738
  }
5653
5739
  return true;
5654
- }), "time");
5740
+ })), "time");
5655
5741
  if (limit !== undefined) {
5656
5742
  // We need to have all transactions of a given nonce in order to display
5657
5743
  // necessary details in the UI. We use the size of this set to determine
@@ -5769,19 +5855,20 @@ class TransactionStateManager extends BaseTransactionStateManager {
5769
5855
  }
5770
5856
 
5771
5857
  class TransactionController extends TransactionStateManager {
5772
- constructor({
5773
- config,
5774
- state,
5775
- provider,
5776
- blockTracker,
5777
- signEthTx,
5778
- getCurrentChainId,
5779
- getCurrentNetworkEIP1559Compatibility,
5780
- getProviderConfig,
5781
- getCurrentAccountEIP1559Compatibility,
5782
- getSelectedAddress,
5783
- getEIP1559GasFeeEstimates
5784
- }) {
5858
+ constructor(_ref) {
5859
+ let {
5860
+ config,
5861
+ state,
5862
+ provider,
5863
+ blockTracker,
5864
+ signEthTx,
5865
+ getCurrentChainId,
5866
+ getCurrentNetworkEIP1559Compatibility,
5867
+ getProviderConfig,
5868
+ getCurrentAccountEIP1559Compatibility,
5869
+ getSelectedAddress,
5870
+ getEIP1559GasFeeEstimates
5871
+ } = _ref;
5785
5872
  super({
5786
5873
  config,
5787
5874
  state,
@@ -5910,6 +5997,9 @@ class TransactionController extends TransactionStateManager {
5910
5997
  });
5911
5998
  const fromAddress = txParams.from;
5912
5999
  const common = await this.getCommonConfiguration(fromAddress);
6000
+ const {
6001
+ TransactionFactory
6002
+ } = await import('@ethereumjs/tx');
5913
6003
  const unsignedEthTx = TransactionFactory.fromTxData(txParams, {
5914
6004
  common
5915
6005
  });
@@ -6173,10 +6263,11 @@ class TransactionController extends TransactionStateManager {
6173
6263
  this.updateTransactionInState(data.txMeta);
6174
6264
  });
6175
6265
  this.pendingTxTracker.on(TX_EVENTS.TX_DROPPED, data => this.setTxStatusDropped(data.txId));
6176
- this.pendingTxTracker.on(TX_EVENTS.TX_BLOCK_UPDATE, ({
6177
- txMeta,
6178
- latestBlockNumber
6179
- }) => {
6266
+ this.pendingTxTracker.on(TX_EVENTS.TX_BLOCK_UPDATE, _ref2 => {
6267
+ let {
6268
+ txMeta,
6269
+ latestBlockNumber
6270
+ } = _ref2;
6180
6271
  if (!txMeta.firstRetryBlockNumber) {
6181
6272
  txMeta.firstRetryBlockNumber = latestBlockNumber;
6182
6273
  this.updateTransactionInState(txMeta);
@@ -6226,6 +6317,10 @@ class TransactionController extends TransactionStateManager {
6226
6317
  displayName
6227
6318
  } = this.getProviderConfig();
6228
6319
  const supportsEIP1559 = await this.getEIP1559Compatibility(fromAddress);
6320
+ const {
6321
+ Common,
6322
+ Hardfork
6323
+ } = await import('@ethereumjs/common');
6229
6324
  const hardfork = supportsEIP1559 ? Hardfork.Paris : Hardfork.Berlin;
6230
6325
  return Common.custom({
6231
6326
  chainId: chainId === "loading" ? 0 : Number.parseInt(chainId, 16),