@toruslabs/ethereum-controllers 5.9.2 → 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.
@@ -1143,15 +1143,16 @@ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
1143
1143
  * Network state changes also retrigger accounts update.
1144
1144
  */
1145
1145
  class AccountTrackerController extends base_controllers_namespaceObject.BaseController {
1146
- constructor({
1147
- config,
1148
- state,
1149
- provider,
1150
- blockTracker,
1151
- getIdentities,
1152
- onPreferencesStateChange,
1153
- getCurrentChainId
1154
- }) {
1146
+ constructor(_ref) {
1147
+ let {
1148
+ config,
1149
+ state,
1150
+ provider,
1151
+ blockTracker,
1152
+ getIdentities,
1153
+ onPreferencesStateChange,
1154
+ getCurrentChainId
1155
+ } = _ref;
1155
1156
  super({
1156
1157
  config,
1157
1158
  state
@@ -1287,8 +1288,8 @@ const util_namespaceObject = require("@ethereumjs/util");
1287
1288
  ;// CONCATENATED MODULE: external "bignumber.js"
1288
1289
  const external_bignumber_js_namespaceObject = require("bignumber.js");
1289
1290
  var external_bignumber_js_default = /*#__PURE__*/__webpack_require__.n(external_bignumber_js_namespaceObject);
1290
- ;// CONCATENATED MODULE: external "@metamask/rpc-errors"
1291
- const rpc_errors_namespaceObject = require("@metamask/rpc-errors");
1291
+ ;// CONCATENATED MODULE: external "@toruslabs/openlogin-jrpc"
1292
+ const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
1292
1293
  ;// CONCATENATED MODULE: ./src/Transaction/TransactionUtils.ts
1293
1294
 
1294
1295
 
@@ -1304,8 +1305,14 @@ const erc1155Interface = new external_ethers_namespaceObject.Interface(erc1155Ab
1304
1305
  // functions that handle normalizing of that key in txParams
1305
1306
 
1306
1307
  const normalizers = {
1307
- from: (from, LowerCase = true) => LowerCase ? (0,util_namespaceObject.addHexPrefix)(from).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(from),
1308
- to: (to, LowerCase = true) => LowerCase ? (0,util_namespaceObject.addHexPrefix)(to).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(to),
1308
+ from: function (from) {
1309
+ let LowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1310
+ return LowerCase ? (0,util_namespaceObject.addHexPrefix)(from).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(from);
1311
+ },
1312
+ to: function (to) {
1313
+ let LowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1314
+ return LowerCase ? (0,util_namespaceObject.addHexPrefix)(to).toLowerCase() : (0,util_namespaceObject.addHexPrefix)(to);
1315
+ },
1309
1316
  nonce: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
1310
1317
  customNonceValue: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
1311
1318
  value: value => (0,util_namespaceObject.addHexPrefix)(value),
@@ -1320,7 +1327,8 @@ const normalizers = {
1320
1327
  /**
1321
1328
  * normalizes txParams
1322
1329
  */
1323
- function normalizeTxParameters(txParameters, lowerCase = true) {
1330
+ function normalizeTxParameters(txParameters) {
1331
+ let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1324
1332
  // apply only keys in the normalizers
1325
1333
  const normalizedTxParameters = {
1326
1334
  id: txParameters.id || (0,base_controllers_namespaceObject.randomId)(),
@@ -1371,7 +1379,7 @@ function isLegacyTransaction(transaction) {
1371
1379
  */
1372
1380
  function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated, mutuallyExclusiveField) {
1373
1381
  if (typeof txParams[mutuallyExclusiveField] !== "undefined") {
1374
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`);
1382
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`);
1375
1383
  }
1376
1384
  }
1377
1385
 
@@ -1381,7 +1389,7 @@ function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated,
1381
1389
  */
1382
1390
  function ensureFieldIsString(txParams, field) {
1383
1391
  if (typeof txParams[field] !== "string") {
1384
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`);
1392
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`);
1385
1393
  }
1386
1394
  }
1387
1395
 
@@ -1395,13 +1403,13 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
1395
1403
  case "maxFeePerGas":
1396
1404
  case "maxPriorityFeePerGas":
1397
1405
  if (txParams.type && txParams.type !== TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
1398
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + `including maxFeePerGas and maxPriorityFeePerGas requires type: "${TRANSACTION_ENVELOPE_TYPES.FEE_MARKET}"`);
1406
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + `including maxFeePerGas and maxPriorityFeePerGas requires type: "${TRANSACTION_ENVELOPE_TYPES.FEE_MARKET}"`);
1399
1407
  }
1400
1408
  break;
1401
1409
  case "gasPrice":
1402
1410
  default:
1403
1411
  if (txParams.type && txParams.type === TRANSACTION_ENVELOPE_TYPES.FEE_MARKET) {
1404
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + "included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas");
1412
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + "included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas");
1405
1413
  }
1406
1414
  }
1407
1415
  }
@@ -1411,10 +1419,10 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
1411
1419
  */
1412
1420
  function validateFrom(txParams) {
1413
1421
  if (!(typeof txParams.from === "string")) {
1414
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid "from" address "${txParams.from}": not a string.`);
1422
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid "from" address "${txParams.from}": not a string.`);
1415
1423
  }
1416
1424
  if (!(0,util_namespaceObject.isValidAddress)(txParams.from)) {
1417
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams('Invalid "from" address.');
1425
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "from" address.');
1418
1426
  }
1419
1427
  }
1420
1428
 
@@ -1426,10 +1434,10 @@ function validateRecipient(txParameters) {
1426
1434
  if (txParameters.data) {
1427
1435
  delete txParameters.to;
1428
1436
  } else {
1429
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1437
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1430
1438
  }
1431
1439
  } else if (txParameters.to !== undefined && !(0,util_namespaceObject.isValidAddress)(txParameters.to)) {
1432
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1440
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1433
1441
  }
1434
1442
  return txParameters;
1435
1443
  }
@@ -1438,19 +1446,21 @@ function validateRecipient(txParameters) {
1438
1446
  * Validates the given tx parameters
1439
1447
  * @throws if the tx params contains invalid fields
1440
1448
  */
1441
- function validateTxParameters(txParams, eip1559Compatibility = true) {
1449
+ function validateTxParameters(txParams) {
1450
+ let eip1559Compatibility = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1442
1451
  if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
1443
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
1452
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
1444
1453
  }
1445
1454
  if (!txParams.to && !txParams.data) {
1446
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams('Invalid transaction params: must specify "data" for contract deployments, or "to" (and optionally "data") for all other types of transactions.');
1455
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid transaction params: must specify "data" for contract deployments, or "to" (and optionally "data") for all other types of transactions.');
1447
1456
  }
1448
1457
  if (isEIP1559Transaction({
1449
1458
  transaction: txParams
1450
1459
  }) && !eip1559Compatibility) {
1451
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
1460
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
1452
1461
  }
1453
- Object.entries(txParams).forEach(([key, value]) => {
1462
+ Object.entries(txParams).forEach(_ref => {
1463
+ let [key, value] = _ref;
1454
1464
  // validate types
1455
1465
  switch (key) {
1456
1466
  case "from":
@@ -1478,15 +1488,15 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
1478
1488
  case "value":
1479
1489
  ensureFieldIsString(txParams, "value");
1480
1490
  if (value.toString().includes("-")) {
1481
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value "${value}": not a positive number.`);
1491
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value "${value}": not a positive number.`);
1482
1492
  }
1483
1493
  if (value.toString().includes(".")) {
1484
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value of "${value}": number must be in wei.`);
1494
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value of "${value}": number must be in wei.`);
1485
1495
  }
1486
1496
  break;
1487
1497
  case "chainId":
1488
1498
  if (typeof value !== "number" && typeof value !== "string") {
1489
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${key} is not a Number or hex string. got: (${value})`);
1499
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${key} is not a Number or hex string. got: (${value})`);
1490
1500
  }
1491
1501
  break;
1492
1502
  default:
@@ -1494,7 +1504,8 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
1494
1504
  }
1495
1505
  });
1496
1506
  }
1497
- function normalizeAndValidateTxParams(txParams, lowerCase = true) {
1507
+ function normalizeAndValidateTxParams(txParams) {
1508
+ let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1498
1509
  const normalizedTxParams = normalizeTxParameters(txParams, lowerCase);
1499
1510
  validateTxParameters(normalizedTxParams);
1500
1511
  return normalizedTxParams;
@@ -1840,10 +1851,11 @@ const DEFAULT_POLLING_INTERVAL = 20;
1840
1851
  const DEFAULT_RETRY_TIMEOUT = 2;
1841
1852
  const SEC = 1000;
1842
1853
  class PollingBlockTracker extends base_controllers_namespaceObject.BaseBlockTracker {
1843
- constructor({
1844
- config,
1845
- state = {}
1846
- }) {
1854
+ constructor(_ref) {
1855
+ let {
1856
+ config,
1857
+ state = {}
1858
+ } = _ref;
1847
1859
  if (!config.provider) {
1848
1860
  throw new Error("PollingBlockTracker - no provider specified.");
1849
1861
  }
@@ -1924,11 +1936,12 @@ const http_helpers_namespaceObject = require("@toruslabs/http-helpers");
1924
1936
 
1925
1937
 
1926
1938
  class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyController {
1927
- constructor({
1928
- config,
1929
- state,
1930
- onNetworkChanged
1931
- }) {
1939
+ constructor(_ref) {
1940
+ let {
1941
+ config,
1942
+ state,
1943
+ onNetworkChanged
1944
+ } = _ref;
1932
1945
  super({
1933
1946
  config,
1934
1947
  state
@@ -2023,8 +2036,6 @@ class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyCo
2023
2036
  };
2024
2037
  }
2025
2038
  }
2026
- ;// CONCATENATED MODULE: external "lodash"
2027
- const external_lodash_namespaceObject = require("lodash");
2028
2039
  ;// CONCATENATED MODULE: external "@babel/runtime/helpers/objectDestructuringEmpty"
2029
2040
  const objectDestructuringEmpty_namespaceObject = require("@babel/runtime/helpers/objectDestructuringEmpty");
2030
2041
  var objectDestructuringEmpty_default = /*#__PURE__*/__webpack_require__.n(objectDestructuringEmpty_namespaceObject);
@@ -2102,19 +2113,20 @@ const isValidBase = base => Number.isInteger(base) && base > 1;
2102
2113
  /**
2103
2114
  * Utility method to convert a value between denominations, formats and currencies.
2104
2115
  */
2105
- const converter = ({
2106
- value,
2107
- fromNumericBase,
2108
- fromDenomination,
2109
- fromCurrency,
2110
- toNumericBase,
2111
- toDenomination,
2112
- toCurrency,
2113
- numberOfDecimals,
2114
- conversionRate,
2115
- invertConversionRate,
2116
- roundDown
2117
- }) => {
2116
+ const converter = _ref => {
2117
+ let {
2118
+ value,
2119
+ fromNumericBase,
2120
+ fromDenomination,
2121
+ fromCurrency,
2122
+ toNumericBase,
2123
+ toDenomination,
2124
+ toCurrency,
2125
+ numberOfDecimals,
2126
+ conversionRate,
2127
+ invertConversionRate,
2128
+ roundDown
2129
+ } = _ref;
2118
2130
  let convertedValue = fromNumericBase ? toBigNumber[fromNumericBase](value) : value;
2119
2131
  if (fromDenomination) {
2120
2132
  convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
@@ -2143,17 +2155,18 @@ const converter = ({
2143
2155
  }
2144
2156
  return convertedValue;
2145
2157
  };
2146
- const conversionUtil = (value, {
2147
- fromCurrency = null,
2148
- toCurrency = fromCurrency,
2149
- fromNumericBase,
2150
- toNumericBase,
2151
- fromDenomination,
2152
- toDenomination,
2153
- numberOfDecimals,
2154
- conversionRate,
2155
- invertConversionRate
2156
- }) => {
2158
+ const conversionUtil = (value, _ref2) => {
2159
+ let {
2160
+ fromCurrency = null,
2161
+ toCurrency = fromCurrency,
2162
+ fromNumericBase,
2163
+ toNumericBase,
2164
+ fromDenomination,
2165
+ toDenomination,
2166
+ numberOfDecimals,
2167
+ conversionRate,
2168
+ invertConversionRate
2169
+ } = _ref2;
2157
2170
  if (fromCurrency !== toCurrency && !conversionRate) {
2158
2171
  return 0;
2159
2172
  }
@@ -2182,7 +2195,8 @@ const getBigNumber = (value, base) => {
2182
2195
  }
2183
2196
  return new (external_bignumber_js_default())(String(value), base);
2184
2197
  };
2185
- const addCurrencies = (a, b, options = {}) => {
2198
+ const addCurrencies = function (a, b) {
2199
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2186
2200
  const {
2187
2201
  aBase,
2188
2202
  bBase
@@ -2196,7 +2210,8 @@ const addCurrencies = (a, b, options = {}) => {
2196
2210
  value
2197
2211
  }, conversionOptions));
2198
2212
  };
2199
- const subtractCurrencies = (a, b, options = {}) => {
2213
+ const subtractCurrencies = function (a, b) {
2214
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2200
2215
  const {
2201
2216
  aBase,
2202
2217
  bBase
@@ -2210,7 +2225,8 @@ const subtractCurrencies = (a, b, options = {}) => {
2210
2225
  value
2211
2226
  }, conversionOptions));
2212
2227
  };
2213
- const multiplyCurrencies = (a, b, options = {}) => {
2228
+ const multiplyCurrencies = function (a, b) {
2229
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2214
2230
  const {
2215
2231
  multiplicandBase,
2216
2232
  multiplierBase
@@ -2224,41 +2240,44 @@ const multiplyCurrencies = (a, b, options = {}) => {
2224
2240
  value
2225
2241
  }, conversionOptions));
2226
2242
  };
2227
- const conversionGreaterThan = (_ref, _ref2) => {
2228
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref2), _ref2));
2229
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref), _ref));
2243
+ const conversionGreaterThan = (_ref3, _ref4) => {
2244
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref4), _ref4));
2245
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref3), _ref3));
2230
2246
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2231
2247
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2232
2248
  return firstValue.gt(secondValue);
2233
2249
  };
2234
- const conversionLessThan = (_ref3, _ref4) => {
2235
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref4), _ref4));
2236
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref3), _ref3));
2250
+ const conversionLessThan = (_ref5, _ref6) => {
2251
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref6), _ref6));
2252
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref5), _ref5));
2237
2253
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2238
2254
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2239
2255
  return firstValue.lt(secondValue);
2240
2256
  };
2241
- const conversionMax = (_ref5, _ref6) => {
2242
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref6), _ref6));
2243
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref5), _ref5));
2257
+ const conversionMax = (_ref7, _ref8) => {
2258
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref8), _ref8));
2259
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref7), _ref7));
2244
2260
  const firstIsGreater = conversionGreaterThan(objectSpread2_default()({}, firstProps), objectSpread2_default()({}, secondProps));
2245
2261
  return firstIsGreater ? firstProps.value : secondProps.value;
2246
2262
  };
2247
- const conversionGTE = (_ref7, _ref8) => {
2248
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref8), _ref8));
2249
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref7), _ref7));
2263
+ const conversionGTE = (_ref9, _ref10) => {
2264
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref10), _ref10));
2265
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref9), _ref9));
2250
2266
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2251
2267
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2252
2268
  return firstValue.isGreaterThanOrEqualTo(secondValue);
2253
2269
  };
2254
- const conversionLTE = (_ref9, _ref10) => {
2255
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref10), _ref10));
2256
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref9), _ref9));
2270
+ const conversionLTE = (_ref11, _ref12) => {
2271
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref12), _ref12));
2272
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref11), _ref11));
2257
2273
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2258
2274
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2259
2275
  return firstValue.isLessThanOrEqualTo(secondValue);
2260
2276
  };
2261
- const toNegative = (n, options = {}) => multiplyCurrencies(n, -1, options);
2277
+ const toNegative = function (n) {
2278
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2279
+ return multiplyCurrencies(n, -1, options);
2280
+ };
2262
2281
  const decGWEIToHexWEI = decGWEI => {
2263
2282
  return conversionUtil(decGWEI, {
2264
2283
  fromNumericBase: "dec",
@@ -2422,27 +2441,27 @@ function calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, gasFeeEstimat
2422
2441
 
2423
2442
 
2424
2443
 
2425
-
2426
2444
  const GAS_FEE_API = "https://mock-gas-server.herokuapp.com/";
2427
2445
  const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices";
2428
2446
  /**
2429
2447
  * Returns gas prices in dec gwei
2430
2448
  */
2431
2449
  class GasFeeController extends base_controllers_namespaceObject.BaseController {
2432
- constructor({
2433
- config,
2434
- state,
2435
- getNetworkIdentifier,
2436
- getProvider,
2437
- fetchGasEstimates = gasUtil_fetchGasEstimates,
2438
- fetchEthGasPriceEstimate = gasUtil_fetchEthGasPriceEstimate,
2439
- fetchLegacyGasPriceEstimates = gasUtil_fetchLegacyGasPriceEstimates,
2440
- fetchGasEstimatesViaEthFeeHistory = gasUtil_fetchGasEstimatesViaEthFeeHistory,
2441
- getCurrentNetworkLegacyGasAPICompatibility,
2442
- getCurrentNetworkEIP1559Compatibility,
2443
- getCurrentAccountEIP1559Compatibility,
2444
- onNetworkStateChange
2445
- }) {
2450
+ constructor(_ref) {
2451
+ let {
2452
+ config,
2453
+ state,
2454
+ getNetworkIdentifier,
2455
+ getProvider,
2456
+ fetchGasEstimates = gasUtil_fetchGasEstimates,
2457
+ fetchEthGasPriceEstimate = gasUtil_fetchEthGasPriceEstimate,
2458
+ fetchLegacyGasPriceEstimates = gasUtil_fetchLegacyGasPriceEstimates,
2459
+ fetchGasEstimatesViaEthFeeHistory = gasUtil_fetchGasEstimatesViaEthFeeHistory,
2460
+ getCurrentNetworkLegacyGasAPICompatibility,
2461
+ getCurrentNetworkEIP1559Compatibility,
2462
+ getCurrentAccountEIP1559Compatibility,
2463
+ onNetworkStateChange
2464
+ } = _ref;
2446
2465
  super({
2447
2466
  config,
2448
2467
  state
@@ -2548,7 +2567,7 @@ class GasFeeController extends base_controllers_namespaceObject.BaseController {
2548
2567
  external_loglevel_default().warn(error);
2549
2568
  isEIP1559Compatible = false;
2550
2569
  }
2551
- let newState = (0,external_lodash_namespaceObject.cloneDeep)(this.defaultState);
2570
+ let newState = (0,base_controllers_namespaceObject.cloneDeep)(this.defaultState);
2552
2571
  try {
2553
2572
  if (isEIP1559Compatible) {
2554
2573
  let estimates;
@@ -2610,7 +2629,7 @@ class GasFeeController extends base_controllers_namespaceObject.BaseController {
2610
2629
  }, this.config.interval);
2611
2630
  }
2612
2631
  resetState() {
2613
- this.update((0,external_lodash_namespaceObject.cloneDeep)(this.defaultState));
2632
+ this.update((0,base_controllers_namespaceObject.cloneDeep)(this.defaultState));
2614
2633
  }
2615
2634
  async getEIP1559Compatibility() {
2616
2635
  var _this$getCurrentAccou, _this$getCurrentAccou2;
@@ -2632,10 +2651,11 @@ const eth_sig_util_namespaceObject = require("@metamask/eth-sig-util");
2632
2651
 
2633
2652
 
2634
2653
  class KeyringController extends base_controllers_namespaceObject.BaseKeyringController {
2635
- constructor({
2636
- config,
2637
- state
2638
- }) {
2654
+ constructor(_ref) {
2655
+ let {
2656
+ config,
2657
+ state
2658
+ } = _ref;
2639
2659
  super({
2640
2660
  config,
2641
2661
  state
@@ -2745,11 +2765,12 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
2745
2765
  * Controller in charge of managing - storing, adding, removing, updating - Messages.
2746
2766
  *
2747
2767
  */
2748
- constructor({
2749
- config,
2750
- state,
2751
- getNetworkIdentifier
2752
- }) {
2768
+ constructor(_ref) {
2769
+ let {
2770
+ config,
2771
+ state,
2772
+ getNetworkIdentifier
2773
+ } = _ref;
2753
2774
  super({
2754
2775
  config,
2755
2776
  state
@@ -2809,15 +2830,15 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
2809
2830
  return new Promise((resolve, reject) => {
2810
2831
  const handleFinished = msg => {
2811
2832
  if (msg.status === MessageStatus.REJECTED) {
2812
- return reject(rpc_errors_namespaceObject.providerErrors.userRejectedRequest(`${messageName} Signature: User denied message signature`));
2833
+ return reject(openlogin_jrpc_namespaceObject.providerErrors.userRejectedRequest(`${messageName} Signature: User denied message signature`));
2813
2834
  }
2814
2835
  if (msg.status === MessageStatus.FAILED) {
2815
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`${messageName} Signature: failed to sign message ${msg.error}`));
2836
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`${messageName} Signature: failed to sign message ${msg.error}`));
2816
2837
  }
2817
2838
  if (msg.status === MessageStatus.SIGNED) {
2818
2839
  return resolve(msg.rawSig);
2819
2840
  }
2820
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`${messageName} Signature: Unknown problem: ${JSON.stringify(msgParams)}`));
2841
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`${messageName} Signature: Unknown problem: ${JSON.stringify(msgParams)}`));
2821
2842
  };
2822
2843
  this.once(`${msgParams.id}:finished`, handleFinished);
2823
2844
  });
@@ -2987,12 +3008,13 @@ function validateSwitchChainData(data) {
2987
3008
 
2988
3009
 
2989
3010
  class AddChainController extends AbstractMessageController {
2990
- constructor({
2991
- config,
2992
- state,
2993
- getNetworkIdentifier,
2994
- addChain
2995
- }) {
3011
+ constructor(_ref) {
3012
+ let {
3013
+ config,
3014
+ state,
3015
+ getNetworkIdentifier,
3016
+ addChain
3017
+ } = _ref;
2996
3018
  super({
2997
3019
  config,
2998
3020
  state,
@@ -3057,12 +3079,13 @@ class AddChainController extends AbstractMessageController {
3057
3079
 
3058
3080
 
3059
3081
  class DecryptMessageController extends AbstractMessageController {
3060
- constructor({
3061
- config,
3062
- state,
3063
- decryptMessage,
3064
- getNetworkIdentifier
3065
- }) {
3082
+ constructor(_ref) {
3083
+ let {
3084
+ config,
3085
+ state,
3086
+ decryptMessage,
3087
+ getNetworkIdentifier
3088
+ } = _ref;
3066
3089
  super({
3067
3090
  config,
3068
3091
  state,
@@ -3129,12 +3152,13 @@ class DecryptMessageController extends AbstractMessageController {
3129
3152
 
3130
3153
 
3131
3154
  class EncryptionPublicKeyController extends AbstractMessageController {
3132
- constructor({
3133
- config,
3134
- state,
3135
- signEncryptionPublicKey,
3136
- getNetworkIdentifier
3137
- }) {
3155
+ constructor(_ref) {
3156
+ let {
3157
+ config,
3158
+ state,
3159
+ signEncryptionPublicKey,
3160
+ getNetworkIdentifier
3161
+ } = _ref;
3138
3162
  super({
3139
3163
  config,
3140
3164
  state,
@@ -3201,12 +3225,13 @@ class EncryptionPublicKeyController extends AbstractMessageController {
3201
3225
 
3202
3226
 
3203
3227
  class MessageController extends AbstractMessageController {
3204
- constructor({
3205
- config,
3206
- state,
3207
- signMessage,
3208
- getNetworkIdentifier
3209
- }) {
3228
+ constructor(_ref) {
3229
+ let {
3230
+ config,
3231
+ state,
3232
+ signMessage,
3233
+ getNetworkIdentifier
3234
+ } = _ref;
3210
3235
  super({
3211
3236
  config,
3212
3237
  state,
@@ -3271,12 +3296,13 @@ class MessageController extends AbstractMessageController {
3271
3296
 
3272
3297
 
3273
3298
  class PersonalMessageController extends AbstractMessageController {
3274
- constructor({
3275
- config,
3276
- state,
3277
- signPersonalMessage,
3278
- getNetworkIdentifier
3279
- }) {
3299
+ constructor(_ref) {
3300
+ let {
3301
+ config,
3302
+ state,
3303
+ signPersonalMessage,
3304
+ getNetworkIdentifier
3305
+ } = _ref;
3280
3306
  super({
3281
3307
  config,
3282
3308
  state,
@@ -3341,12 +3367,13 @@ class PersonalMessageController extends AbstractMessageController {
3341
3367
 
3342
3368
 
3343
3369
  class SwitchChainController extends AbstractMessageController {
3344
- constructor({
3345
- config,
3346
- state,
3347
- getNetworkIdentifier,
3348
- switchChain
3349
- }) {
3370
+ constructor(_ref) {
3371
+ let {
3372
+ config,
3373
+ state,
3374
+ getNetworkIdentifier,
3375
+ switchChain
3376
+ } = _ref;
3350
3377
  super({
3351
3378
  config,
3352
3379
  state,
@@ -3425,12 +3452,13 @@ function getMessageType(version) {
3425
3452
  }
3426
3453
  }
3427
3454
  class TypedMessageController extends AbstractMessageController {
3428
- constructor({
3429
- config,
3430
- state,
3431
- signTypedData,
3432
- getNetworkIdentifier
3433
- }) {
3455
+ constructor(_ref) {
3456
+ let {
3457
+ config,
3458
+ state,
3459
+ signTypedData,
3460
+ getNetworkIdentifier
3461
+ } = _ref;
3434
3462
  super({
3435
3463
  config,
3436
3464
  state,
@@ -3496,16 +3524,15 @@ class TypedMessageController extends AbstractMessageController {
3496
3524
  return Promise.resolve(messageParams);
3497
3525
  }
3498
3526
  }
3499
- ;// CONCATENATED MODULE: external "@toruslabs/openlogin-jrpc"
3500
- const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
3501
3527
  ;// CONCATENATED MODULE: ./src/Network/createEthereumMiddleware.ts
3502
3528
 
3503
3529
 
3504
3530
 
3505
3531
 
3506
- function createGetAccountsMiddleware({
3507
- getAccounts
3508
- }) {
3532
+ function createGetAccountsMiddleware(_ref) {
3533
+ let {
3534
+ getAccounts
3535
+ } = _ref;
3509
3536
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3510
3537
  const {
3511
3538
  method
@@ -3516,9 +3543,10 @@ function createGetAccountsMiddleware({
3516
3543
  response.result = accounts;
3517
3544
  });
3518
3545
  }
3519
- function createProcessTransactionMiddleware({
3520
- processTransaction
3521
- }) {
3546
+ function createProcessTransactionMiddleware(_ref2) {
3547
+ let {
3548
+ processTransaction
3549
+ } = _ref2;
3522
3550
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3523
3551
  const {
3524
3552
  method
@@ -3528,9 +3556,10 @@ function createProcessTransactionMiddleware({
3528
3556
  response.result = await processTransaction(request.params, request);
3529
3557
  });
3530
3558
  }
3531
- function createProcessEthSignMessage({
3532
- processEthSignMessage
3533
- }) {
3559
+ function createProcessEthSignMessage(_ref3) {
3560
+ let {
3561
+ processEthSignMessage
3562
+ } = _ref3;
3534
3563
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3535
3564
  const {
3536
3565
  method
@@ -3552,9 +3581,10 @@ function createProcessEthSignMessage({
3552
3581
  response.result = await processEthSignMessage(msgParams, request);
3553
3582
  });
3554
3583
  }
3555
- function createProcessTypedMessage({
3556
- processTypedMessage
3557
- }) {
3584
+ function createProcessTypedMessage(_ref4) {
3585
+ let {
3586
+ processTypedMessage
3587
+ } = _ref4;
3558
3588
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3559
3589
  const {
3560
3590
  method
@@ -3577,9 +3607,10 @@ function createProcessTypedMessage({
3577
3607
  response.result = await processTypedMessage(msgParams, request);
3578
3608
  });
3579
3609
  }
3580
- function createProcessTypedMessageV3({
3581
- processTypedMessageV3
3582
- }) {
3610
+ function createProcessTypedMessageV3(_ref5) {
3611
+ let {
3612
+ processTypedMessageV3
3613
+ } = _ref5;
3583
3614
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3584
3615
  const {
3585
3616
  method
@@ -3602,9 +3633,10 @@ function createProcessTypedMessageV3({
3602
3633
  response.result = await processTypedMessageV3(msgParams, request);
3603
3634
  });
3604
3635
  }
3605
- function createProcessTypedMessageV4({
3606
- processTypedMessageV4
3607
- }) {
3636
+ function createProcessTypedMessageV4(_ref6) {
3637
+ let {
3638
+ processTypedMessageV4
3639
+ } = _ref6;
3608
3640
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3609
3641
  const {
3610
3642
  method
@@ -3627,9 +3659,10 @@ function createProcessTypedMessageV4({
3627
3659
  response.result = await processTypedMessageV4(msgParams, request);
3628
3660
  });
3629
3661
  }
3630
- function createProcessPersonalMessage({
3631
- processPersonalMessage
3632
- }) {
3662
+ function createProcessPersonalMessage(_ref7) {
3663
+ let {
3664
+ processPersonalMessage
3665
+ } = _ref7;
3633
3666
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3634
3667
  const {
3635
3668
  method
@@ -3662,9 +3695,10 @@ function createProcessPersonalMessage({
3662
3695
  response.result = await processPersonalMessage(msgParams, request);
3663
3696
  });
3664
3697
  }
3665
- function createPendingNonceMiddleware({
3666
- getPendingNonce
3667
- }) {
3698
+ function createPendingNonceMiddleware(_ref8) {
3699
+ let {
3700
+ getPendingNonce
3701
+ } = _ref8;
3668
3702
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3669
3703
  const {
3670
3704
  params,
@@ -3726,9 +3760,10 @@ function formatTxMetaForRpcResult(txMeta) {
3726
3760
  }
3727
3761
  return formattedTxMeta;
3728
3762
  }
3729
- function createPendingTxMiddleware({
3730
- getPendingTransactionByHash
3731
- }) {
3763
+ function createPendingTxMiddleware(_ref9) {
3764
+ let {
3765
+ getPendingTransactionByHash
3766
+ } = _ref9;
3732
3767
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3733
3768
  const {
3734
3769
  params,
@@ -3744,9 +3779,10 @@ function createPendingTxMiddleware({
3744
3779
  return undefined;
3745
3780
  });
3746
3781
  }
3747
- function createProcessEncryptionPublicKeyMiddleware({
3748
- processEncryptionPublicKey
3749
- }) {
3782
+ function createProcessEncryptionPublicKeyMiddleware(_ref10) {
3783
+ let {
3784
+ processEncryptionPublicKey
3785
+ } = _ref10;
3750
3786
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3751
3787
  const {
3752
3788
  method
@@ -3766,9 +3802,10 @@ function createProcessEncryptionPublicKeyMiddleware({
3766
3802
  response.result = await processEncryptionPublicKey(msgParams, request);
3767
3803
  });
3768
3804
  }
3769
- function createProcessDecryptMessageMiddleware({
3770
- processDecryptMessage
3771
- }) {
3805
+ function createProcessDecryptMessageMiddleware(_ref11) {
3806
+ let {
3807
+ processDecryptMessage
3808
+ } = _ref11;
3772
3809
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3773
3810
  const {
3774
3811
  method
@@ -3788,9 +3825,10 @@ function createProcessDecryptMessageMiddleware({
3788
3825
  response.result = await processDecryptMessage(msgParams, request);
3789
3826
  });
3790
3827
  }
3791
- function createProcessSwitchEthereumChain({
3792
- processSwitchEthereumChain
3793
- }) {
3828
+ function createProcessSwitchEthereumChain(_ref12) {
3829
+ let {
3830
+ processSwitchEthereumChain
3831
+ } = _ref12;
3794
3832
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3795
3833
  const {
3796
3834
  method
@@ -3807,9 +3845,10 @@ function createProcessSwitchEthereumChain({
3807
3845
  response.result = await processSwitchEthereumChain(msgParams, request);
3808
3846
  });
3809
3847
  }
3810
- function createProcessAddEthereumChain({
3811
- processAddEthereumChain
3812
- }) {
3848
+ function createProcessAddEthereumChain(_ref13) {
3849
+ let {
3850
+ processAddEthereumChain
3851
+ } = _ref13;
3813
3852
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3814
3853
  const {
3815
3854
  method
@@ -3826,9 +3865,10 @@ function createProcessAddEthereumChain({
3826
3865
  response.result = await processAddEthereumChain(msgParams, request);
3827
3866
  });
3828
3867
  }
3829
- function createRequestAccountsMiddleware({
3830
- requestAccounts
3831
- }) {
3868
+ function createRequestAccountsMiddleware(_ref14) {
3869
+ let {
3870
+ requestAccounts
3871
+ } = _ref14;
3832
3872
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3833
3873
  const {
3834
3874
  method
@@ -4072,10 +4112,11 @@ const NetworkController_excluded = ["chainId", "rpcTarget"];
4072
4112
 
4073
4113
 
4074
4114
  class NetworkController extends base_controllers_namespaceObject.BaseController {
4075
- constructor({
4076
- config,
4077
- state
4078
- }) {
4115
+ constructor(_ref) {
4116
+ let {
4117
+ config,
4118
+ state
4119
+ } = _ref;
4079
4120
  super({
4080
4121
  config,
4081
4122
  state
@@ -4202,10 +4243,11 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
4202
4243
  rpcTarget
4203
4244
  }, rest));
4204
4245
  }
4205
- setNetworkClient({
4206
- networkMiddleware,
4207
- blockTracker
4208
- }) {
4246
+ setNetworkClient(_ref2) {
4247
+ let {
4248
+ networkMiddleware,
4249
+ blockTracker
4250
+ } = _ref2;
4209
4251
  const ethereumMiddleware = createEthereumMiddleware(this.baseProviderHandlers);
4210
4252
  const engine = new openlogin_jrpc_namespaceObject.JRPCEngine();
4211
4253
  engine.push(ethereumMiddleware);
@@ -4216,10 +4258,11 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
4216
4258
  blockTracker
4217
4259
  });
4218
4260
  }
4219
- setProvider({
4220
- provider,
4221
- blockTracker
4222
- }) {
4261
+ setProvider(_ref3) {
4262
+ let {
4263
+ provider,
4264
+ blockTracker
4265
+ } = _ref3;
4223
4266
  if (this.providerProxy) {
4224
4267
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4225
4268
  // @ts-ignore
@@ -4266,18 +4309,19 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
4266
4309
 
4267
4310
 
4268
4311
  class NftHandler {
4269
- constructor({
4270
- chainId,
4271
- contractAddress,
4272
- contractImage,
4273
- contractName,
4274
- contractSymbol,
4275
- nftStandard,
4276
- provider,
4277
- contractDescription,
4278
- contractFallbackLogo,
4279
- contractSupply
4280
- }) {
4312
+ constructor(_ref) {
4313
+ let {
4314
+ chainId,
4315
+ contractAddress,
4316
+ contractImage,
4317
+ contractName,
4318
+ contractSymbol,
4319
+ nftStandard,
4320
+ provider,
4321
+ contractDescription,
4322
+ contractFallbackLogo,
4323
+ contractSupply
4324
+ } = _ref;
4281
4325
  defineProperty_default()(this, "contractAddress", void 0);
4282
4326
  defineProperty_default()(this, "contractName", void 0);
4283
4327
  defineProperty_default()(this, "contractSymbol", void 0);
@@ -4425,13 +4469,17 @@ class NftHandler {
4425
4469
  const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
4426
4470
  return contract.supportsInterface(interfaceId);
4427
4471
  }
4428
- async getCollectibleTokenURI(tokenId, standard = CONTRACT_TYPE_ERC721) {
4472
+ async getCollectibleTokenURI(tokenId) {
4473
+ let standard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CONTRACT_TYPE_ERC721;
4429
4474
  const method = standard === CONTRACT_TYPE_ERC721 ? "tokenURI" : "uri";
4430
4475
  const abi = standard === CONTRACT_TYPE_ERC721 ? erc721Abi : erc1155Abi;
4431
4476
  const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
4432
4477
  return contract[method](tokenId);
4433
4478
  }
4434
4479
  }
4480
+ ;// CONCATENATED MODULE: external "deepmerge"
4481
+ const external_deepmerge_namespaceObject = require("deepmerge");
4482
+ var external_deepmerge_default = /*#__PURE__*/__webpack_require__.n(external_deepmerge_namespaceObject);
4435
4483
  ;// CONCATENATED MODULE: ./src/Nfts/NftsController.ts
4436
4484
 
4437
4485
 
@@ -4444,15 +4492,16 @@ class NftHandler {
4444
4492
 
4445
4493
  const DEFAULT_INTERVAL = 180 * 1000;
4446
4494
  class NftsController extends base_controllers_namespaceObject.BaseController {
4447
- constructor({
4448
- config,
4449
- state,
4450
- provider,
4451
- getCustomNfts,
4452
- getSimpleHashNfts,
4453
- onPreferencesStateChange,
4454
- onNetworkStateChange
4455
- }) {
4495
+ constructor(_ref) {
4496
+ let {
4497
+ config,
4498
+ state,
4499
+ provider,
4500
+ getCustomNfts,
4501
+ getSimpleHashNfts,
4502
+ onPreferencesStateChange,
4503
+ onNetworkStateChange
4504
+ } = _ref;
4456
4505
  super({
4457
4506
  config,
4458
4507
  state
@@ -4636,7 +4685,7 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
4636
4685
  const nonZeroTokens = promiseSettledResult.filter(x => x.status === "fulfilled").map(x => x.value);
4637
4686
  this.update({
4638
4687
  nfts: {
4639
- [userAddress]: (0,external_lodash_namespaceObject.merge)(this.userNfts, nonZeroTokens)
4688
+ [userAddress]: external_deepmerge_default()(this.userNfts, nonZeroTokens)
4640
4689
  }
4641
4690
  });
4642
4691
  }
@@ -4650,15 +4699,16 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
4650
4699
 
4651
4700
 
4652
4701
  class PreferencesController extends base_controllers_namespaceObject.BasePreferencesController {
4653
- constructor({
4654
- config,
4655
- state,
4656
- provider,
4657
- signAuthMessage,
4658
- getProviderConfig,
4659
- setProviderConfig,
4660
- validateSignMessage
4661
- }) {
4702
+ constructor(_ref) {
4703
+ let {
4704
+ config,
4705
+ state,
4706
+ provider,
4707
+ signAuthMessage,
4708
+ getProviderConfig,
4709
+ setProviderConfig,
4710
+ validateSignMessage
4711
+ } = _ref;
4662
4712
  super({
4663
4713
  config,
4664
4714
  state,
@@ -4938,9 +4988,10 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
4938
4988
  }
4939
4989
 
4940
4990
  // Custom Network methods
4941
- async addCustomNetwork({
4942
- network
4943
- }) {
4991
+ async addCustomNetwork(_ref2) {
4992
+ let {
4993
+ network
4994
+ } = _ref2;
4944
4995
  try {
4945
4996
  const {
4946
4997
  selectedAddress
@@ -4980,10 +5031,11 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
4980
5031
  return false;
4981
5032
  }
4982
5033
  }
4983
- async editCustomNetwork({
4984
- network,
4985
- id
4986
- }) {
5034
+ async editCustomNetwork(_ref3) {
5035
+ let {
5036
+ network,
5037
+ id
5038
+ } = _ref3;
4987
5039
  try {
4988
5040
  const {
4989
5041
  selectedAddress
@@ -5006,8 +5058,9 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
5006
5058
  return false;
5007
5059
  }
5008
5060
  }
5009
- getChainOptions(address = this.state.selectedAddress) {
5061
+ getChainOptions() {
5010
5062
  var _identities$address$c, _identities$address;
5063
+ let address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.selectedAddress;
5011
5064
  const {
5012
5065
  identities
5013
5066
  } = this.state;
@@ -5118,13 +5171,14 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
5118
5171
 
5119
5172
 
5120
5173
  class TokenHandler {
5121
- constructor({
5122
- address,
5123
- symbol,
5124
- decimals,
5125
- name,
5126
- provider
5127
- }) {
5174
+ constructor(_ref) {
5175
+ let {
5176
+ address,
5177
+ symbol,
5178
+ decimals,
5179
+ name,
5180
+ provider
5181
+ } = _ref;
5128
5182
  defineProperty_default()(this, "address", void 0);
5129
5183
  defineProperty_default()(this, "symbol", void 0);
5130
5184
  defineProperty_default()(this, "decimals", void 0);
@@ -5169,13 +5223,14 @@ class TokenHandler {
5169
5223
 
5170
5224
  const DEFAULT_CURRENCY = "eth";
5171
5225
  class TokenRatesController extends base_controllers_namespaceObject.BaseController {
5172
- constructor({
5173
- config,
5174
- state,
5175
- onPreferencesStateChange,
5176
- onNetworkStateChange,
5177
- onTokensStateChange
5178
- }) {
5226
+ constructor(_ref) {
5227
+ let {
5228
+ config,
5229
+ state,
5230
+ onPreferencesStateChange,
5231
+ onNetworkStateChange,
5232
+ onTokensStateChange
5233
+ } = _ref;
5179
5234
  super({
5180
5235
  config,
5181
5236
  state
@@ -5296,16 +5351,17 @@ const mergeTokenArrays = (oldArray, newArray) => {
5296
5351
  };
5297
5352
  const TokensController_DEFAULT_INTERVAL = 180 * 1000;
5298
5353
  class TokensController extends base_controllers_namespaceObject.BaseController {
5299
- constructor({
5300
- config,
5301
- state,
5302
- provider,
5303
- getCustomTokens,
5304
- getEtherScanTokens,
5305
- getProviderConfig,
5306
- onPreferencesStateChange,
5307
- onNetworkStateChange
5308
- }) {
5354
+ constructor(_ref) {
5355
+ let {
5356
+ config,
5357
+ state,
5358
+ provider,
5359
+ getCustomTokens,
5360
+ getEtherScanTokens,
5361
+ getProviderConfig,
5362
+ onPreferencesStateChange,
5363
+ onNetworkStateChange
5364
+ } = _ref;
5309
5365
  super({
5310
5366
  config,
5311
5367
  state
@@ -5528,12 +5584,13 @@ class TokensController extends base_controllers_namespaceObject.BaseController {
5528
5584
 
5529
5585
 
5530
5586
  class NonceTracker {
5531
- constructor({
5532
- provider,
5533
- blockTracker,
5534
- getPendingTransactions,
5535
- getConfirmedTransactions
5536
- }) {
5587
+ constructor(_ref) {
5588
+ let {
5589
+ provider,
5590
+ blockTracker,
5591
+ getPendingTransactions,
5592
+ getConfirmedTransactions
5593
+ } = _ref;
5537
5594
  defineProperty_default()(this, "provider", void 0);
5538
5595
  defineProperty_default()(this, "blockTracker", void 0);
5539
5596
  defineProperty_default()(this, "getPendingTransactions", void 0);
@@ -5677,14 +5734,15 @@ class NonceTracker {
5677
5734
 
5678
5735
 
5679
5736
  class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
5680
- constructor({
5681
- provider,
5682
- nonceTracker,
5683
- approveTransaction,
5684
- publishTransaction,
5685
- getPendingTransactions,
5686
- getConfirmedTransactions
5687
- }) {
5737
+ constructor(_ref) {
5738
+ let {
5739
+ provider,
5740
+ nonceTracker,
5741
+ approveTransaction,
5742
+ publishTransaction,
5743
+ getPendingTransactions,
5744
+ getConfirmedTransactions
5745
+ } = _ref;
5688
5746
  super();
5689
5747
  defineProperty_default()(this, "DROPPED_BUFFER_COUNT", 3);
5690
5748
  defineProperty_default()(this, "nonceTracker", void 0);
@@ -5931,7 +5989,8 @@ class TransactionGasUtil {
5931
5989
  /**
5932
5990
  Adds a gas buffer with out exceeding the block gas limit
5933
5991
  */
5934
- addGasBuffer(initialGasLimitHex, blockGasLimitHex, multiplier = 1.5) {
5992
+ addGasBuffer(initialGasLimitHex, blockGasLimitHex) {
5993
+ let multiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.5;
5935
5994
  const initialGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(initialGasLimitHex), 16);
5936
5995
  const blockGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(blockGasLimitHex), 16);
5937
5996
  const upperGasLimitBn = blockGasLimitBn.muln(0.9);
@@ -5949,7 +6008,7 @@ class TransactionGasUtil {
5949
6008
  Estimates the tx's gas usage
5950
6009
  */
5951
6010
  async estimateTxGas(txMeta) {
5952
- const txParams = (0,external_lodash_namespaceObject.cloneDeep)(txMeta.transaction);
6011
+ const txParams = (0,base_controllers_namespaceObject.cloneDeep)(txMeta.transaction);
5953
6012
 
5954
6013
  // `eth_estimateGas` can fail if the user has insufficient balance for the
5955
6014
  // value being sent, or for the gas cost. We don't want to check their
@@ -5965,6 +6024,29 @@ class TransactionGasUtil {
5965
6024
  });
5966
6025
  }
5967
6026
  }
6027
+ ;// CONCATENATED MODULE: ./src/utils/lodashUtils.ts
6028
+ function sortBy(arr, key) {
6029
+ return arr.slice().sort((a, b) => {
6030
+ if (a[key] < b[key]) return -1;
6031
+ if (a[key] > b[key]) return 1;
6032
+ return 0;
6033
+ });
6034
+ }
6035
+ function keyBy(arr, key) {
6036
+ return arr.reduce((acc, item) => {
6037
+ const keyValue = item[key];
6038
+ if (typeof keyValue === "string" || typeof keyValue === "number") {
6039
+ acc[keyValue.toString()] = item;
6040
+ }
6041
+ return acc;
6042
+ }, {});
6043
+ }
6044
+ function mapValues(obj, iteratee) {
6045
+ return Object.fromEntries(Object.entries(obj).map(_ref => {
6046
+ let [key, value] = _ref;
6047
+ return [key, iteratee(value, key)];
6048
+ }));
6049
+ }
5968
6050
  ;// CONCATENATED MODULE: external "fast-json-patch"
5969
6051
  const external_fast_json_patch_namespaceObject = require("fast-json-patch");
5970
6052
  var external_fast_json_patch_default = /*#__PURE__*/__webpack_require__.n(external_fast_json_patch_namespaceObject);
@@ -5996,13 +6078,13 @@ function generateHistoryEntry(previousState, newState, note) {
5996
6078
  Recovers previous txMeta state obj
5997
6079
  */
5998
6080
  function replayHistory(_shortHistory) {
5999
- const shortHistory = (0,external_lodash_namespaceObject.cloneDeep)(_shortHistory);
6081
+ const shortHistory = (0,base_controllers_namespaceObject.cloneDeep)(_shortHistory);
6000
6082
  return shortHistory.reduce((val, entry) => external_fast_json_patch_default().applyPatch(val, entry).newDocument);
6001
6083
  }
6002
6084
  function snapshotFromTxMeta(txMeta) {
6003
6085
  const shallow = objectSpread2_default()({}, txMeta);
6004
6086
  delete shallow.history;
6005
- return (0,external_lodash_namespaceObject.cloneDeep)(shallow);
6087
+ return (0,base_controllers_namespaceObject.cloneDeep)(shallow);
6006
6088
  }
6007
6089
 
6008
6090
  ;// CONCATENATED MODULE: ./src/Transaction/TransactionStateManager.ts
@@ -6012,18 +6094,20 @@ function snapshotFromTxMeta(txMeta) {
6012
6094
 
6013
6095
 
6014
6096
  class TransactionStateManager extends base_controllers_namespaceObject.BaseTransactionStateManager {
6015
- constructor({
6016
- config,
6017
- state,
6018
- getCurrentChainId
6019
- }) {
6097
+ constructor(_ref) {
6098
+ let {
6099
+ config,
6100
+ state,
6101
+ getCurrentChainId
6102
+ } = _ref;
6020
6103
  super({
6021
6104
  config,
6022
6105
  state,
6023
6106
  getCurrentChainId
6024
6107
  });
6025
6108
  }
6026
- generateTxMeta(opts = {}) {
6109
+ generateTxMeta() {
6110
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6027
6111
  const chainId = this.getCurrentChainId();
6028
6112
  if (chainId === "loading") throw new Error("Torus is having trouble connecting to the network");
6029
6113
  let dappSuggestedGasFees = null;
@@ -6127,18 +6211,19 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6127
6211
  } = this.state;
6128
6212
  const chainId = this.getCurrentChainId();
6129
6213
  this.update({
6130
- transactions: (0,external_lodash_namespaceObject.omitBy)(transactions, txMeta => {
6214
+ transactions: (0,base_controllers_namespaceObject.omitBy)(transactions, txMeta => {
6131
6215
  const transactionMatch = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(txMeta, chainId);
6132
6216
  return txMeta.transaction.from === address && transactionMatch;
6133
6217
  })
6134
6218
  });
6135
6219
  }
6136
- getTransactions({
6137
- searchCriteria = {},
6138
- initialList = undefined,
6139
- filterToCurrentNetwork = true,
6140
- limit = undefined
6141
- } = {}) {
6220
+ getTransactions() {
6221
+ let {
6222
+ searchCriteria = {},
6223
+ initialList = undefined,
6224
+ filterToCurrentNetwork = true,
6225
+ limit = undefined
6226
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6142
6227
  const chainId = this.getCurrentChainId();
6143
6228
  // searchCriteria is an object that might have values that aren't predicate
6144
6229
  // methods. When providing any other value type (string, number, etc), we
@@ -6146,17 +6231,17 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6146
6231
  // with the provided value". To conform this object to be only methods, we
6147
6232
  // mapValues (lodash) such that every value on the object is a method that
6148
6233
  // returns a boolean.
6149
- const predicateMethods = (0,external_lodash_namespaceObject.mapValues)(searchCriteria, predicate => typeof predicate === "function" ? predicate : v => v === predicate);
6234
+ const predicateMethods = mapValues(searchCriteria, predicate => typeof predicate === "function" ? predicate : v => v === predicate);
6150
6235
 
6151
6236
  // If an initial list is provided we need to change it back into an object
6152
6237
  // first, so that it matches the shape of our state. This is done by the
6153
6238
  // lodash keyBy method. This is the edge case for this method, typically
6154
6239
  // initialList will be undefined.
6155
- const transactionsToFilter = initialList ? (0,external_lodash_namespaceObject.keyBy)(initialList, "id") : this.state.transactions;
6240
+ const transactionsToFilter = initialList ? keyBy(initialList, "id") : this.state.transactions;
6156
6241
 
6157
6242
  // Combine sortBy and pickBy to transform our state object into an array of
6158
6243
  // matching transactions that are sorted by time.
6159
- const filteredTransactions = (0,external_lodash_namespaceObject.sortBy)((0,external_lodash_namespaceObject.pickBy)(transactionsToFilter, txMeta => {
6244
+ const filteredTransactions = sortBy(Object.values((0,base_controllers_namespaceObject.pickBy)(transactionsToFilter, txMeta => {
6160
6245
  // default matchesCriteria to the value of transactionMatchesNetwork
6161
6246
  // when filterToCurrentNetwork is true.
6162
6247
  const transactionMatches = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(txMeta, chainId);
@@ -6180,7 +6265,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6180
6265
  }
6181
6266
  }
6182
6267
  return true;
6183
- }), "time");
6268
+ })), "time");
6184
6269
  if (limit !== undefined) {
6185
6270
  // We need to have all transactions of a given nonce in order to display
6186
6271
  // necessary details in the UI. We use the size of this set to determine
@@ -6253,7 +6338,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6253
6338
  }
6254
6339
  getUnapprovedTxList() {
6255
6340
  const chainId = this.getCurrentChainId();
6256
- return (0,external_lodash_namespaceObject.pickBy)(this.state.transactions, transaction => {
6341
+ return (0,base_controllers_namespaceObject.pickBy)(this.state.transactions, transaction => {
6257
6342
  const transactionMatches = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(transaction, chainId);
6258
6343
  return transaction.status === base_controllers_namespaceObject.TransactionStatus.unapproved && transactionMatches;
6259
6344
  });
@@ -6314,19 +6399,20 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6314
6399
 
6315
6400
 
6316
6401
  class TransactionController extends TransactionStateManager {
6317
- constructor({
6318
- config,
6319
- state,
6320
- provider,
6321
- blockTracker,
6322
- signEthTx,
6323
- getCurrentChainId,
6324
- getCurrentNetworkEIP1559Compatibility,
6325
- getProviderConfig,
6326
- getCurrentAccountEIP1559Compatibility,
6327
- getSelectedAddress,
6328
- getEIP1559GasFeeEstimates
6329
- }) {
6402
+ constructor(_ref) {
6403
+ let {
6404
+ config,
6405
+ state,
6406
+ provider,
6407
+ blockTracker,
6408
+ signEthTx,
6409
+ getCurrentChainId,
6410
+ getCurrentNetworkEIP1559Compatibility,
6411
+ getProviderConfig,
6412
+ getCurrentAccountEIP1559Compatibility,
6413
+ getSelectedAddress,
6414
+ getEIP1559GasFeeEstimates
6415
+ } = _ref;
6330
6416
  super({
6331
6417
  config,
6332
6418
  state,
@@ -6387,15 +6473,15 @@ class TransactionController extends TransactionStateManager {
6387
6473
  return new Promise((resolve, reject) => {
6388
6474
  const handleFinished = msg => {
6389
6475
  if (msg.status === base_controllers_namespaceObject.TransactionStatus.rejected) {
6390
- return reject(rpc_errors_namespaceObject.providerErrors.userRejectedRequest(`Transaction Signature: User denied message signature`));
6476
+ return reject(openlogin_jrpc_namespaceObject.providerErrors.userRejectedRequest(`Transaction Signature: User denied message signature`));
6391
6477
  }
6392
6478
  if (msg.status === base_controllers_namespaceObject.TransactionStatus.failed) {
6393
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`Transaction Signature: failed to sign message ${msg.error}`));
6479
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`Transaction Signature: failed to sign message ${msg.error}`));
6394
6480
  }
6395
6481
  if (msg.status === base_controllers_namespaceObject.TransactionStatus.submitted) {
6396
6482
  return resolve(msg.transactionHash);
6397
6483
  }
6398
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`Transaction Signature: Unknown problem: ${JSON.stringify(txMeta.transaction)}`));
6484
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`Transaction Signature: Unknown problem: ${JSON.stringify(txMeta.transaction)}`));
6399
6485
  };
6400
6486
  this.once(`${txMeta.id}:finished`, handleFinished);
6401
6487
  });
@@ -6721,10 +6807,11 @@ class TransactionController extends TransactionStateManager {
6721
6807
  this.updateTransactionInState(data.txMeta);
6722
6808
  });
6723
6809
  this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_DROPPED, data => this.setTxStatusDropped(data.txId));
6724
- this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE, ({
6725
- txMeta,
6726
- latestBlockNumber
6727
- }) => {
6810
+ this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE, _ref2 => {
6811
+ let {
6812
+ txMeta,
6813
+ latestBlockNumber
6814
+ } = _ref2;
6728
6815
  if (!txMeta.firstRetryBlockNumber) {
6729
6816
  txMeta.firstRetryBlockNumber = latestBlockNumber;
6730
6817
  this.updateTransactionInState(txMeta);