@toruslabs/ethereum-controllers 5.10.0 → 5.10.1

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,16 +1143,15 @@ 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(_ref) {
1147
- let {
1148
- config,
1149
- state,
1150
- provider,
1151
- blockTracker,
1152
- getIdentities,
1153
- onPreferencesStateChange,
1154
- getCurrentChainId
1155
- } = _ref;
1146
+ constructor({
1147
+ config,
1148
+ state,
1149
+ provider,
1150
+ blockTracker,
1151
+ getIdentities,
1152
+ onPreferencesStateChange,
1153
+ getCurrentChainId
1154
+ }) {
1156
1155
  super({
1157
1156
  config,
1158
1157
  state
@@ -1305,14 +1304,8 @@ const erc1155Interface = new external_ethers_namespaceObject.Interface(erc1155Ab
1305
1304
  // functions that handle normalizing of that key in txParams
1306
1305
 
1307
1306
  const normalizers = {
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
- },
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),
1316
1309
  nonce: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
1317
1310
  customNonceValue: nonce => (0,util_namespaceObject.addHexPrefix)(nonce),
1318
1311
  value: value => (0,util_namespaceObject.addHexPrefix)(value),
@@ -1327,8 +1320,7 @@ const normalizers = {
1327
1320
  /**
1328
1321
  * normalizes txParams
1329
1322
  */
1330
- function normalizeTxParameters(txParameters) {
1331
- let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1323
+ function normalizeTxParameters(txParameters, lowerCase = true) {
1332
1324
  // apply only keys in the normalizers
1333
1325
  const normalizedTxParameters = {
1334
1326
  id: txParameters.id || (0,base_controllers_namespaceObject.randomId)(),
@@ -1446,8 +1438,7 @@ function validateRecipient(txParameters) {
1446
1438
  * Validates the given tx parameters
1447
1439
  * @throws if the tx params contains invalid fields
1448
1440
  */
1449
- function validateTxParameters(txParams) {
1450
- let eip1559Compatibility = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1441
+ function validateTxParameters(txParams, eip1559Compatibility = true) {
1451
1442
  if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
1452
1443
  throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
1453
1444
  }
@@ -1459,8 +1450,7 @@ function validateTxParameters(txParams) {
1459
1450
  }) && !eip1559Compatibility) {
1460
1451
  throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559");
1461
1452
  }
1462
- Object.entries(txParams).forEach(_ref => {
1463
- let [key, value] = _ref;
1453
+ Object.entries(txParams).forEach(([key, value]) => {
1464
1454
  // validate types
1465
1455
  switch (key) {
1466
1456
  case "from":
@@ -1504,8 +1494,7 @@ function validateTxParameters(txParams) {
1504
1494
  }
1505
1495
  });
1506
1496
  }
1507
- function normalizeAndValidateTxParams(txParams) {
1508
- let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1497
+ function normalizeAndValidateTxParams(txParams, lowerCase = true) {
1509
1498
  const normalizedTxParams = normalizeTxParameters(txParams, lowerCase);
1510
1499
  validateTxParameters(normalizedTxParams);
1511
1500
  return normalizedTxParams;
@@ -1851,11 +1840,10 @@ const DEFAULT_POLLING_INTERVAL = 20;
1851
1840
  const DEFAULT_RETRY_TIMEOUT = 2;
1852
1841
  const SEC = 1000;
1853
1842
  class PollingBlockTracker extends base_controllers_namespaceObject.BaseBlockTracker {
1854
- constructor(_ref) {
1855
- let {
1856
- config,
1857
- state = {}
1858
- } = _ref;
1843
+ constructor({
1844
+ config,
1845
+ state = {}
1846
+ }) {
1859
1847
  if (!config.provider) {
1860
1848
  throw new Error("PollingBlockTracker - no provider specified.");
1861
1849
  }
@@ -1936,12 +1924,11 @@ const http_helpers_namespaceObject = require("@toruslabs/http-helpers");
1936
1924
 
1937
1925
 
1938
1926
  class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyController {
1939
- constructor(_ref) {
1940
- let {
1941
- config,
1942
- state,
1943
- onNetworkChanged
1944
- } = _ref;
1927
+ constructor({
1928
+ config,
1929
+ state,
1930
+ onNetworkChanged
1931
+ }) {
1945
1932
  super({
1946
1933
  config,
1947
1934
  state
@@ -2113,20 +2100,19 @@ const isValidBase = base => Number.isInteger(base) && base > 1;
2113
2100
  /**
2114
2101
  * Utility method to convert a value between denominations, formats and currencies.
2115
2102
  */
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;
2103
+ const converter = ({
2104
+ value,
2105
+ fromNumericBase,
2106
+ fromDenomination,
2107
+ fromCurrency,
2108
+ toNumericBase,
2109
+ toDenomination,
2110
+ toCurrency,
2111
+ numberOfDecimals,
2112
+ conversionRate,
2113
+ invertConversionRate,
2114
+ roundDown
2115
+ }) => {
2130
2116
  let convertedValue = fromNumericBase ? toBigNumber[fromNumericBase](value) : value;
2131
2117
  if (fromDenomination) {
2132
2118
  convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
@@ -2155,18 +2141,17 @@ const converter = _ref => {
2155
2141
  }
2156
2142
  return convertedValue;
2157
2143
  };
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;
2144
+ const conversionUtil = (value, {
2145
+ fromCurrency = null,
2146
+ toCurrency = fromCurrency,
2147
+ fromNumericBase,
2148
+ toNumericBase,
2149
+ fromDenomination,
2150
+ toDenomination,
2151
+ numberOfDecimals,
2152
+ conversionRate,
2153
+ invertConversionRate
2154
+ }) => {
2170
2155
  if (fromCurrency !== toCurrency && !conversionRate) {
2171
2156
  return 0;
2172
2157
  }
@@ -2195,8 +2180,7 @@ const getBigNumber = (value, base) => {
2195
2180
  }
2196
2181
  return new (external_bignumber_js_default())(String(value), base);
2197
2182
  };
2198
- const addCurrencies = function (a, b) {
2199
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2183
+ const addCurrencies = (a, b, options = {}) => {
2200
2184
  const {
2201
2185
  aBase,
2202
2186
  bBase
@@ -2210,8 +2194,7 @@ const addCurrencies = function (a, b) {
2210
2194
  value
2211
2195
  }, conversionOptions));
2212
2196
  };
2213
- const subtractCurrencies = function (a, b) {
2214
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2197
+ const subtractCurrencies = (a, b, options = {}) => {
2215
2198
  const {
2216
2199
  aBase,
2217
2200
  bBase
@@ -2225,8 +2208,7 @@ const subtractCurrencies = function (a, b) {
2225
2208
  value
2226
2209
  }, conversionOptions));
2227
2210
  };
2228
- const multiplyCurrencies = function (a, b) {
2229
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2211
+ const multiplyCurrencies = (a, b, options = {}) => {
2230
2212
  const {
2231
2213
  multiplicandBase,
2232
2214
  multiplierBase
@@ -2240,44 +2222,41 @@ const multiplyCurrencies = function (a, b) {
2240
2222
  value
2241
2223
  }, conversionOptions));
2242
2224
  };
2243
- const conversionGreaterThan = (_ref3, _ref4) => {
2244
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref4), _ref4));
2245
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref3), _ref3));
2225
+ const conversionGreaterThan = (_ref, _ref2) => {
2226
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref2), _ref2));
2227
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref), _ref));
2246
2228
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2247
2229
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2248
2230
  return firstValue.gt(secondValue);
2249
2231
  };
2250
- const conversionLessThan = (_ref5, _ref6) => {
2251
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref6), _ref6));
2252
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref5), _ref5));
2232
+ const conversionLessThan = (_ref3, _ref4) => {
2233
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref4), _ref4));
2234
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref3), _ref3));
2253
2235
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2254
2236
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2255
2237
  return firstValue.lt(secondValue);
2256
2238
  };
2257
- const conversionMax = (_ref7, _ref8) => {
2258
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref8), _ref8));
2259
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref7), _ref7));
2239
+ const conversionMax = (_ref5, _ref6) => {
2240
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref6), _ref6));
2241
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref5), _ref5));
2260
2242
  const firstIsGreater = conversionGreaterThan(objectSpread2_default()({}, firstProps), objectSpread2_default()({}, secondProps));
2261
2243
  return firstIsGreater ? firstProps.value : secondProps.value;
2262
2244
  };
2263
- const conversionGTE = (_ref9, _ref10) => {
2264
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref10), _ref10));
2265
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref9), _ref9));
2245
+ const conversionGTE = (_ref7, _ref8) => {
2246
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref8), _ref8));
2247
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref7), _ref7));
2266
2248
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2267
2249
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2268
2250
  return firstValue.isGreaterThanOrEqualTo(secondValue);
2269
2251
  };
2270
- const conversionLTE = (_ref11, _ref12) => {
2271
- let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref12), _ref12));
2272
- let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref11), _ref11));
2252
+ const conversionLTE = (_ref9, _ref10) => {
2253
+ let secondProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref10), _ref10));
2254
+ let firstProps = Object.assign({}, (objectDestructuringEmpty_default()(_ref9), _ref9));
2273
2255
  const firstValue = converter(objectSpread2_default()({}, firstProps));
2274
2256
  const secondValue = converter(objectSpread2_default()({}, secondProps));
2275
2257
  return firstValue.isLessThanOrEqualTo(secondValue);
2276
2258
  };
2277
- const toNegative = function (n) {
2278
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2279
- return multiplyCurrencies(n, -1, options);
2280
- };
2259
+ const toNegative = (n, options = {}) => multiplyCurrencies(n, -1, options);
2281
2260
  const decGWEIToHexWEI = decGWEI => {
2282
2261
  return conversionUtil(decGWEI, {
2283
2262
  fromNumericBase: "dec",
@@ -2447,21 +2426,20 @@ const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices
2447
2426
  * Returns gas prices in dec gwei
2448
2427
  */
2449
2428
  class GasFeeController extends base_controllers_namespaceObject.BaseController {
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;
2429
+ constructor({
2430
+ config,
2431
+ state,
2432
+ getNetworkIdentifier,
2433
+ getProvider,
2434
+ fetchGasEstimates = gasUtil_fetchGasEstimates,
2435
+ fetchEthGasPriceEstimate = gasUtil_fetchEthGasPriceEstimate,
2436
+ fetchLegacyGasPriceEstimates = gasUtil_fetchLegacyGasPriceEstimates,
2437
+ fetchGasEstimatesViaEthFeeHistory = gasUtil_fetchGasEstimatesViaEthFeeHistory,
2438
+ getCurrentNetworkLegacyGasAPICompatibility,
2439
+ getCurrentNetworkEIP1559Compatibility,
2440
+ getCurrentAccountEIP1559Compatibility,
2441
+ onNetworkStateChange
2442
+ }) {
2465
2443
  super({
2466
2444
  config,
2467
2445
  state
@@ -2651,11 +2629,10 @@ const eth_sig_util_namespaceObject = require("@metamask/eth-sig-util");
2651
2629
 
2652
2630
 
2653
2631
  class KeyringController extends base_controllers_namespaceObject.BaseKeyringController {
2654
- constructor(_ref) {
2655
- let {
2656
- config,
2657
- state
2658
- } = _ref;
2632
+ constructor({
2633
+ config,
2634
+ state
2635
+ }) {
2659
2636
  super({
2660
2637
  config,
2661
2638
  state
@@ -2765,12 +2742,11 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
2765
2742
  * Controller in charge of managing - storing, adding, removing, updating - Messages.
2766
2743
  *
2767
2744
  */
2768
- constructor(_ref) {
2769
- let {
2770
- config,
2771
- state,
2772
- getNetworkIdentifier
2773
- } = _ref;
2745
+ constructor({
2746
+ config,
2747
+ state,
2748
+ getNetworkIdentifier
2749
+ }) {
2774
2750
  super({
2775
2751
  config,
2776
2752
  state
@@ -3008,13 +2984,12 @@ function validateSwitchChainData(data) {
3008
2984
 
3009
2985
 
3010
2986
  class AddChainController extends AbstractMessageController {
3011
- constructor(_ref) {
3012
- let {
3013
- config,
3014
- state,
3015
- getNetworkIdentifier,
3016
- addChain
3017
- } = _ref;
2987
+ constructor({
2988
+ config,
2989
+ state,
2990
+ getNetworkIdentifier,
2991
+ addChain
2992
+ }) {
3018
2993
  super({
3019
2994
  config,
3020
2995
  state,
@@ -3079,13 +3054,12 @@ class AddChainController extends AbstractMessageController {
3079
3054
 
3080
3055
 
3081
3056
  class DecryptMessageController extends AbstractMessageController {
3082
- constructor(_ref) {
3083
- let {
3084
- config,
3085
- state,
3086
- decryptMessage,
3087
- getNetworkIdentifier
3088
- } = _ref;
3057
+ constructor({
3058
+ config,
3059
+ state,
3060
+ decryptMessage,
3061
+ getNetworkIdentifier
3062
+ }) {
3089
3063
  super({
3090
3064
  config,
3091
3065
  state,
@@ -3152,13 +3126,12 @@ class DecryptMessageController extends AbstractMessageController {
3152
3126
 
3153
3127
 
3154
3128
  class EncryptionPublicKeyController extends AbstractMessageController {
3155
- constructor(_ref) {
3156
- let {
3157
- config,
3158
- state,
3159
- signEncryptionPublicKey,
3160
- getNetworkIdentifier
3161
- } = _ref;
3129
+ constructor({
3130
+ config,
3131
+ state,
3132
+ signEncryptionPublicKey,
3133
+ getNetworkIdentifier
3134
+ }) {
3162
3135
  super({
3163
3136
  config,
3164
3137
  state,
@@ -3225,13 +3198,12 @@ class EncryptionPublicKeyController extends AbstractMessageController {
3225
3198
 
3226
3199
 
3227
3200
  class MessageController extends AbstractMessageController {
3228
- constructor(_ref) {
3229
- let {
3230
- config,
3231
- state,
3232
- signMessage,
3233
- getNetworkIdentifier
3234
- } = _ref;
3201
+ constructor({
3202
+ config,
3203
+ state,
3204
+ signMessage,
3205
+ getNetworkIdentifier
3206
+ }) {
3235
3207
  super({
3236
3208
  config,
3237
3209
  state,
@@ -3296,13 +3268,12 @@ class MessageController extends AbstractMessageController {
3296
3268
 
3297
3269
 
3298
3270
  class PersonalMessageController extends AbstractMessageController {
3299
- constructor(_ref) {
3300
- let {
3301
- config,
3302
- state,
3303
- signPersonalMessage,
3304
- getNetworkIdentifier
3305
- } = _ref;
3271
+ constructor({
3272
+ config,
3273
+ state,
3274
+ signPersonalMessage,
3275
+ getNetworkIdentifier
3276
+ }) {
3306
3277
  super({
3307
3278
  config,
3308
3279
  state,
@@ -3367,13 +3338,12 @@ class PersonalMessageController extends AbstractMessageController {
3367
3338
 
3368
3339
 
3369
3340
  class SwitchChainController extends AbstractMessageController {
3370
- constructor(_ref) {
3371
- let {
3372
- config,
3373
- state,
3374
- getNetworkIdentifier,
3375
- switchChain
3376
- } = _ref;
3341
+ constructor({
3342
+ config,
3343
+ state,
3344
+ getNetworkIdentifier,
3345
+ switchChain
3346
+ }) {
3377
3347
  super({
3378
3348
  config,
3379
3349
  state,
@@ -3452,13 +3422,12 @@ function getMessageType(version) {
3452
3422
  }
3453
3423
  }
3454
3424
  class TypedMessageController extends AbstractMessageController {
3455
- constructor(_ref) {
3456
- let {
3457
- config,
3458
- state,
3459
- signTypedData,
3460
- getNetworkIdentifier
3461
- } = _ref;
3425
+ constructor({
3426
+ config,
3427
+ state,
3428
+ signTypedData,
3429
+ getNetworkIdentifier
3430
+ }) {
3462
3431
  super({
3463
3432
  config,
3464
3433
  state,
@@ -3529,10 +3498,9 @@ class TypedMessageController extends AbstractMessageController {
3529
3498
 
3530
3499
 
3531
3500
 
3532
- function createGetAccountsMiddleware(_ref) {
3533
- let {
3534
- getAccounts
3535
- } = _ref;
3501
+ function createGetAccountsMiddleware({
3502
+ getAccounts
3503
+ }) {
3536
3504
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3537
3505
  const {
3538
3506
  method
@@ -3543,10 +3511,9 @@ function createGetAccountsMiddleware(_ref) {
3543
3511
  response.result = accounts;
3544
3512
  });
3545
3513
  }
3546
- function createProcessTransactionMiddleware(_ref2) {
3547
- let {
3548
- processTransaction
3549
- } = _ref2;
3514
+ function createProcessTransactionMiddleware({
3515
+ processTransaction
3516
+ }) {
3550
3517
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3551
3518
  const {
3552
3519
  method
@@ -3556,10 +3523,9 @@ function createProcessTransactionMiddleware(_ref2) {
3556
3523
  response.result = await processTransaction(request.params, request);
3557
3524
  });
3558
3525
  }
3559
- function createProcessEthSignMessage(_ref3) {
3560
- let {
3561
- processEthSignMessage
3562
- } = _ref3;
3526
+ function createProcessEthSignMessage({
3527
+ processEthSignMessage
3528
+ }) {
3563
3529
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3564
3530
  const {
3565
3531
  method
@@ -3581,10 +3547,9 @@ function createProcessEthSignMessage(_ref3) {
3581
3547
  response.result = await processEthSignMessage(msgParams, request);
3582
3548
  });
3583
3549
  }
3584
- function createProcessTypedMessage(_ref4) {
3585
- let {
3586
- processTypedMessage
3587
- } = _ref4;
3550
+ function createProcessTypedMessage({
3551
+ processTypedMessage
3552
+ }) {
3588
3553
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3589
3554
  const {
3590
3555
  method
@@ -3607,10 +3572,9 @@ function createProcessTypedMessage(_ref4) {
3607
3572
  response.result = await processTypedMessage(msgParams, request);
3608
3573
  });
3609
3574
  }
3610
- function createProcessTypedMessageV3(_ref5) {
3611
- let {
3612
- processTypedMessageV3
3613
- } = _ref5;
3575
+ function createProcessTypedMessageV3({
3576
+ processTypedMessageV3
3577
+ }) {
3614
3578
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3615
3579
  const {
3616
3580
  method
@@ -3633,10 +3597,9 @@ function createProcessTypedMessageV3(_ref5) {
3633
3597
  response.result = await processTypedMessageV3(msgParams, request);
3634
3598
  });
3635
3599
  }
3636
- function createProcessTypedMessageV4(_ref6) {
3637
- let {
3638
- processTypedMessageV4
3639
- } = _ref6;
3600
+ function createProcessTypedMessageV4({
3601
+ processTypedMessageV4
3602
+ }) {
3640
3603
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3641
3604
  const {
3642
3605
  method
@@ -3659,10 +3622,9 @@ function createProcessTypedMessageV4(_ref6) {
3659
3622
  response.result = await processTypedMessageV4(msgParams, request);
3660
3623
  });
3661
3624
  }
3662
- function createProcessPersonalMessage(_ref7) {
3663
- let {
3664
- processPersonalMessage
3665
- } = _ref7;
3625
+ function createProcessPersonalMessage({
3626
+ processPersonalMessage
3627
+ }) {
3666
3628
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3667
3629
  const {
3668
3630
  method
@@ -3695,10 +3657,9 @@ function createProcessPersonalMessage(_ref7) {
3695
3657
  response.result = await processPersonalMessage(msgParams, request);
3696
3658
  });
3697
3659
  }
3698
- function createPendingNonceMiddleware(_ref8) {
3699
- let {
3700
- getPendingNonce
3701
- } = _ref8;
3660
+ function createPendingNonceMiddleware({
3661
+ getPendingNonce
3662
+ }) {
3702
3663
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3703
3664
  const {
3704
3665
  params,
@@ -3760,10 +3721,9 @@ function formatTxMetaForRpcResult(txMeta) {
3760
3721
  }
3761
3722
  return formattedTxMeta;
3762
3723
  }
3763
- function createPendingTxMiddleware(_ref9) {
3764
- let {
3765
- getPendingTransactionByHash
3766
- } = _ref9;
3724
+ function createPendingTxMiddleware({
3725
+ getPendingTransactionByHash
3726
+ }) {
3767
3727
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3768
3728
  const {
3769
3729
  params,
@@ -3779,10 +3739,9 @@ function createPendingTxMiddleware(_ref9) {
3779
3739
  return undefined;
3780
3740
  });
3781
3741
  }
3782
- function createProcessEncryptionPublicKeyMiddleware(_ref10) {
3783
- let {
3784
- processEncryptionPublicKey
3785
- } = _ref10;
3742
+ function createProcessEncryptionPublicKeyMiddleware({
3743
+ processEncryptionPublicKey
3744
+ }) {
3786
3745
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3787
3746
  const {
3788
3747
  method
@@ -3802,10 +3761,9 @@ function createProcessEncryptionPublicKeyMiddleware(_ref10) {
3802
3761
  response.result = await processEncryptionPublicKey(msgParams, request);
3803
3762
  });
3804
3763
  }
3805
- function createProcessDecryptMessageMiddleware(_ref11) {
3806
- let {
3807
- processDecryptMessage
3808
- } = _ref11;
3764
+ function createProcessDecryptMessageMiddleware({
3765
+ processDecryptMessage
3766
+ }) {
3809
3767
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3810
3768
  const {
3811
3769
  method
@@ -3825,10 +3783,9 @@ function createProcessDecryptMessageMiddleware(_ref11) {
3825
3783
  response.result = await processDecryptMessage(msgParams, request);
3826
3784
  });
3827
3785
  }
3828
- function createProcessSwitchEthereumChain(_ref12) {
3829
- let {
3830
- processSwitchEthereumChain
3831
- } = _ref12;
3786
+ function createProcessSwitchEthereumChain({
3787
+ processSwitchEthereumChain
3788
+ }) {
3832
3789
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3833
3790
  const {
3834
3791
  method
@@ -3845,10 +3802,9 @@ function createProcessSwitchEthereumChain(_ref12) {
3845
3802
  response.result = await processSwitchEthereumChain(msgParams, request);
3846
3803
  });
3847
3804
  }
3848
- function createProcessAddEthereumChain(_ref13) {
3849
- let {
3850
- processAddEthereumChain
3851
- } = _ref13;
3805
+ function createProcessAddEthereumChain({
3806
+ processAddEthereumChain
3807
+ }) {
3852
3808
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3853
3809
  const {
3854
3810
  method
@@ -3865,10 +3821,9 @@ function createProcessAddEthereumChain(_ref13) {
3865
3821
  response.result = await processAddEthereumChain(msgParams, request);
3866
3822
  });
3867
3823
  }
3868
- function createRequestAccountsMiddleware(_ref14) {
3869
- let {
3870
- requestAccounts
3871
- } = _ref14;
3824
+ function createRequestAccountsMiddleware({
3825
+ requestAccounts
3826
+ }) {
3872
3827
  return (0,openlogin_jrpc_namespaceObject.createAsyncMiddleware)(async (request, response, next) => {
3873
3828
  const {
3874
3829
  method
@@ -4112,11 +4067,10 @@ const NetworkController_excluded = ["chainId", "rpcTarget"];
4112
4067
 
4113
4068
 
4114
4069
  class NetworkController extends base_controllers_namespaceObject.BaseController {
4115
- constructor(_ref) {
4116
- let {
4117
- config,
4118
- state
4119
- } = _ref;
4070
+ constructor({
4071
+ config,
4072
+ state
4073
+ }) {
4120
4074
  super({
4121
4075
  config,
4122
4076
  state
@@ -4243,11 +4197,10 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
4243
4197
  rpcTarget
4244
4198
  }, rest));
4245
4199
  }
4246
- setNetworkClient(_ref2) {
4247
- let {
4248
- networkMiddleware,
4249
- blockTracker
4250
- } = _ref2;
4200
+ setNetworkClient({
4201
+ networkMiddleware,
4202
+ blockTracker
4203
+ }) {
4251
4204
  const ethereumMiddleware = createEthereumMiddleware(this.baseProviderHandlers);
4252
4205
  const engine = new openlogin_jrpc_namespaceObject.JRPCEngine();
4253
4206
  engine.push(ethereumMiddleware);
@@ -4258,11 +4211,10 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
4258
4211
  blockTracker
4259
4212
  });
4260
4213
  }
4261
- setProvider(_ref3) {
4262
- let {
4263
- provider,
4264
- blockTracker
4265
- } = _ref3;
4214
+ setProvider({
4215
+ provider,
4216
+ blockTracker
4217
+ }) {
4266
4218
  if (this.providerProxy) {
4267
4219
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4268
4220
  // @ts-ignore
@@ -4309,19 +4261,18 @@ class NetworkController extends base_controllers_namespaceObject.BaseController
4309
4261
 
4310
4262
 
4311
4263
  class NftHandler {
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;
4264
+ constructor({
4265
+ chainId,
4266
+ contractAddress,
4267
+ contractImage,
4268
+ contractName,
4269
+ contractSymbol,
4270
+ nftStandard,
4271
+ provider,
4272
+ contractDescription,
4273
+ contractFallbackLogo,
4274
+ contractSupply
4275
+ }) {
4325
4276
  defineProperty_default()(this, "contractAddress", void 0);
4326
4277
  defineProperty_default()(this, "contractName", void 0);
4327
4278
  defineProperty_default()(this, "contractSymbol", void 0);
@@ -4469,8 +4420,7 @@ class NftHandler {
4469
4420
  const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
4470
4421
  return contract.supportsInterface(interfaceId);
4471
4422
  }
4472
- async getCollectibleTokenURI(tokenId) {
4473
- let standard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CONTRACT_TYPE_ERC721;
4423
+ async getCollectibleTokenURI(tokenId, standard = CONTRACT_TYPE_ERC721) {
4474
4424
  const method = standard === CONTRACT_TYPE_ERC721 ? "tokenURI" : "uri";
4475
4425
  const abi = standard === CONTRACT_TYPE_ERC721 ? erc721Abi : erc1155Abi;
4476
4426
  const contract = new external_ethers_namespaceObject.Contract(this.contractAddress, abi, this.provider);
@@ -4492,16 +4442,15 @@ var external_deepmerge_default = /*#__PURE__*/__webpack_require__.n(external_dee
4492
4442
 
4493
4443
  const DEFAULT_INTERVAL = 180 * 1000;
4494
4444
  class NftsController extends base_controllers_namespaceObject.BaseController {
4495
- constructor(_ref) {
4496
- let {
4497
- config,
4498
- state,
4499
- provider,
4500
- getCustomNfts,
4501
- getSimpleHashNfts,
4502
- onPreferencesStateChange,
4503
- onNetworkStateChange
4504
- } = _ref;
4445
+ constructor({
4446
+ config,
4447
+ state,
4448
+ provider,
4449
+ getCustomNfts,
4450
+ getSimpleHashNfts,
4451
+ onPreferencesStateChange,
4452
+ onNetworkStateChange
4453
+ }) {
4505
4454
  super({
4506
4455
  config,
4507
4456
  state
@@ -4699,16 +4648,15 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
4699
4648
 
4700
4649
 
4701
4650
  class PreferencesController extends base_controllers_namespaceObject.BasePreferencesController {
4702
- constructor(_ref) {
4703
- let {
4704
- config,
4705
- state,
4706
- provider,
4707
- signAuthMessage,
4708
- getProviderConfig,
4709
- setProviderConfig,
4710
- validateSignMessage
4711
- } = _ref;
4651
+ constructor({
4652
+ config,
4653
+ state,
4654
+ provider,
4655
+ signAuthMessage,
4656
+ getProviderConfig,
4657
+ setProviderConfig,
4658
+ validateSignMessage
4659
+ }) {
4712
4660
  super({
4713
4661
  config,
4714
4662
  state,
@@ -4988,10 +4936,9 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
4988
4936
  }
4989
4937
 
4990
4938
  // Custom Network methods
4991
- async addCustomNetwork(_ref2) {
4992
- let {
4993
- network
4994
- } = _ref2;
4939
+ async addCustomNetwork({
4940
+ network
4941
+ }) {
4995
4942
  try {
4996
4943
  const {
4997
4944
  selectedAddress
@@ -5031,11 +4978,10 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
5031
4978
  return false;
5032
4979
  }
5033
4980
  }
5034
- async editCustomNetwork(_ref3) {
5035
- let {
5036
- network,
5037
- id
5038
- } = _ref3;
4981
+ async editCustomNetwork({
4982
+ network,
4983
+ id
4984
+ }) {
5039
4985
  try {
5040
4986
  const {
5041
4987
  selectedAddress
@@ -5058,9 +5004,8 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
5058
5004
  return false;
5059
5005
  }
5060
5006
  }
5061
- getChainOptions() {
5007
+ getChainOptions(address = this.state.selectedAddress) {
5062
5008
  var _identities$address$c, _identities$address;
5063
- let address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.selectedAddress;
5064
5009
  const {
5065
5010
  identities
5066
5011
  } = this.state;
@@ -5171,14 +5116,13 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
5171
5116
 
5172
5117
 
5173
5118
  class TokenHandler {
5174
- constructor(_ref) {
5175
- let {
5176
- address,
5177
- symbol,
5178
- decimals,
5179
- name,
5180
- provider
5181
- } = _ref;
5119
+ constructor({
5120
+ address,
5121
+ symbol,
5122
+ decimals,
5123
+ name,
5124
+ provider
5125
+ }) {
5182
5126
  defineProperty_default()(this, "address", void 0);
5183
5127
  defineProperty_default()(this, "symbol", void 0);
5184
5128
  defineProperty_default()(this, "decimals", void 0);
@@ -5223,14 +5167,13 @@ class TokenHandler {
5223
5167
 
5224
5168
  const DEFAULT_CURRENCY = "eth";
5225
5169
  class TokenRatesController extends base_controllers_namespaceObject.BaseController {
5226
- constructor(_ref) {
5227
- let {
5228
- config,
5229
- state,
5230
- onPreferencesStateChange,
5231
- onNetworkStateChange,
5232
- onTokensStateChange
5233
- } = _ref;
5170
+ constructor({
5171
+ config,
5172
+ state,
5173
+ onPreferencesStateChange,
5174
+ onNetworkStateChange,
5175
+ onTokensStateChange
5176
+ }) {
5234
5177
  super({
5235
5178
  config,
5236
5179
  state
@@ -5351,17 +5294,16 @@ const mergeTokenArrays = (oldArray, newArray) => {
5351
5294
  };
5352
5295
  const TokensController_DEFAULT_INTERVAL = 180 * 1000;
5353
5296
  class TokensController extends base_controllers_namespaceObject.BaseController {
5354
- constructor(_ref) {
5355
- let {
5356
- config,
5357
- state,
5358
- provider,
5359
- getCustomTokens,
5360
- getEtherScanTokens,
5361
- getProviderConfig,
5362
- onPreferencesStateChange,
5363
- onNetworkStateChange
5364
- } = _ref;
5297
+ constructor({
5298
+ config,
5299
+ state,
5300
+ provider,
5301
+ getCustomTokens,
5302
+ getEtherScanTokens,
5303
+ getProviderConfig,
5304
+ onPreferencesStateChange,
5305
+ onNetworkStateChange
5306
+ }) {
5365
5307
  super({
5366
5308
  config,
5367
5309
  state
@@ -5584,13 +5526,12 @@ class TokensController extends base_controllers_namespaceObject.BaseController {
5584
5526
 
5585
5527
 
5586
5528
  class NonceTracker {
5587
- constructor(_ref) {
5588
- let {
5589
- provider,
5590
- blockTracker,
5591
- getPendingTransactions,
5592
- getConfirmedTransactions
5593
- } = _ref;
5529
+ constructor({
5530
+ provider,
5531
+ blockTracker,
5532
+ getPendingTransactions,
5533
+ getConfirmedTransactions
5534
+ }) {
5594
5535
  defineProperty_default()(this, "provider", void 0);
5595
5536
  defineProperty_default()(this, "blockTracker", void 0);
5596
5537
  defineProperty_default()(this, "getPendingTransactions", void 0);
@@ -5734,15 +5675,14 @@ class NonceTracker {
5734
5675
 
5735
5676
 
5736
5677
  class PendingTransactionTracker extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
5737
- constructor(_ref) {
5738
- let {
5739
- provider,
5740
- nonceTracker,
5741
- approveTransaction,
5742
- publishTransaction,
5743
- getPendingTransactions,
5744
- getConfirmedTransactions
5745
- } = _ref;
5678
+ constructor({
5679
+ provider,
5680
+ nonceTracker,
5681
+ approveTransaction,
5682
+ publishTransaction,
5683
+ getPendingTransactions,
5684
+ getConfirmedTransactions
5685
+ }) {
5746
5686
  super();
5747
5687
  defineProperty_default()(this, "DROPPED_BUFFER_COUNT", 3);
5748
5688
  defineProperty_default()(this, "nonceTracker", void 0);
@@ -5989,8 +5929,7 @@ class TransactionGasUtil {
5989
5929
  /**
5990
5930
  Adds a gas buffer with out exceeding the block gas limit
5991
5931
  */
5992
- addGasBuffer(initialGasLimitHex, blockGasLimitHex) {
5993
- let multiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1.5;
5932
+ addGasBuffer(initialGasLimitHex, blockGasLimitHex, multiplier = 1.5) {
5994
5933
  const initialGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(initialGasLimitHex), 16);
5995
5934
  const blockGasLimitBn = new external_bn_js_namespaceObject.BN((0,util_namespaceObject.stripHexPrefix)(blockGasLimitHex), 16);
5996
5935
  const upperGasLimitBn = blockGasLimitBn.muln(0.9);
@@ -6042,10 +5981,7 @@ function keyBy(arr, key) {
6042
5981
  }, {});
6043
5982
  }
6044
5983
  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
- }));
5984
+ return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, iteratee(value, key)]));
6049
5985
  }
6050
5986
  ;// CONCATENATED MODULE: external "fast-json-patch"
6051
5987
  const external_fast_json_patch_namespaceObject = require("fast-json-patch");
@@ -6094,20 +6030,18 @@ function snapshotFromTxMeta(txMeta) {
6094
6030
 
6095
6031
 
6096
6032
  class TransactionStateManager extends base_controllers_namespaceObject.BaseTransactionStateManager {
6097
- constructor(_ref) {
6098
- let {
6099
- config,
6100
- state,
6101
- getCurrentChainId
6102
- } = _ref;
6033
+ constructor({
6034
+ config,
6035
+ state,
6036
+ getCurrentChainId
6037
+ }) {
6103
6038
  super({
6104
6039
  config,
6105
6040
  state,
6106
6041
  getCurrentChainId
6107
6042
  });
6108
6043
  }
6109
- generateTxMeta() {
6110
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6044
+ generateTxMeta(opts = {}) {
6111
6045
  const chainId = this.getCurrentChainId();
6112
6046
  if (chainId === "loading") throw new Error("Torus is having trouble connecting to the network");
6113
6047
  let dappSuggestedGasFees = null;
@@ -6217,13 +6151,12 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6217
6151
  })
6218
6152
  });
6219
6153
  }
6220
- getTransactions() {
6221
- let {
6222
- searchCriteria = {},
6223
- initialList = undefined,
6224
- filterToCurrentNetwork = true,
6225
- limit = undefined
6226
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6154
+ getTransactions({
6155
+ searchCriteria = {},
6156
+ initialList = undefined,
6157
+ filterToCurrentNetwork = true,
6158
+ limit = undefined
6159
+ } = {}) {
6227
6160
  const chainId = this.getCurrentChainId();
6228
6161
  // searchCriteria is an object that might have values that aren't predicate
6229
6162
  // methods. When providing any other value type (string, number, etc), we
@@ -6399,20 +6332,19 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6399
6332
 
6400
6333
 
6401
6334
  class TransactionController extends TransactionStateManager {
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;
6335
+ constructor({
6336
+ config,
6337
+ state,
6338
+ provider,
6339
+ blockTracker,
6340
+ signEthTx,
6341
+ getCurrentChainId,
6342
+ getCurrentNetworkEIP1559Compatibility,
6343
+ getProviderConfig,
6344
+ getCurrentAccountEIP1559Compatibility,
6345
+ getSelectedAddress,
6346
+ getEIP1559GasFeeEstimates
6347
+ }) {
6416
6348
  super({
6417
6349
  config,
6418
6350
  state,
@@ -6807,11 +6739,10 @@ class TransactionController extends TransactionStateManager {
6807
6739
  this.updateTransactionInState(data.txMeta);
6808
6740
  });
6809
6741
  this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_DROPPED, data => this.setTxStatusDropped(data.txId));
6810
- this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE, _ref2 => {
6811
- let {
6812
- txMeta,
6813
- latestBlockNumber
6814
- } = _ref2;
6742
+ this.pendingTxTracker.on(base_controllers_namespaceObject.TX_EVENTS.TX_BLOCK_UPDATE, ({
6743
+ txMeta,
6744
+ latestBlockNumber
6745
+ }) => {
6815
6746
  if (!txMeta.firstRetryBlockNumber) {
6816
6747
  txMeta.firstRetryBlockNumber = latestBlockNumber;
6817
6748
  this.updateTransactionInState(txMeta);