@toruslabs/ethereum-controllers 5.9.2 → 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.
@@ -1287,8 +1287,8 @@ const util_namespaceObject = require("@ethereumjs/util");
1287
1287
  ;// CONCATENATED MODULE: external "bignumber.js"
1288
1288
  const external_bignumber_js_namespaceObject = require("bignumber.js");
1289
1289
  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");
1290
+ ;// CONCATENATED MODULE: external "@toruslabs/openlogin-jrpc"
1291
+ const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
1292
1292
  ;// CONCATENATED MODULE: ./src/Transaction/TransactionUtils.ts
1293
1293
 
1294
1294
 
@@ -1371,7 +1371,7 @@ function isLegacyTransaction(transaction) {
1371
1371
  */
1372
1372
  function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated, mutuallyExclusiveField) {
1373
1373
  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`);
1374
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`);
1375
1375
  }
1376
1376
  }
1377
1377
 
@@ -1381,7 +1381,7 @@ function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated,
1381
1381
  */
1382
1382
  function ensureFieldIsString(txParams, field) {
1383
1383
  if (typeof txParams[field] !== "string") {
1384
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`);
1384
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`);
1385
1385
  }
1386
1386
  }
1387
1387
 
@@ -1395,13 +1395,13 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
1395
1395
  case "maxFeePerGas":
1396
1396
  case "maxPriorityFeePerGas":
1397
1397
  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}"`);
1398
+ 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
1399
  }
1400
1400
  break;
1401
1401
  case "gasPrice":
1402
1402
  default:
1403
1403
  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");
1404
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but ` + "included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas");
1405
1405
  }
1406
1406
  }
1407
1407
  }
@@ -1411,10 +1411,10 @@ function ensureProperTransactionEnvelopeTypeProvided(txParams, field) {
1411
1411
  */
1412
1412
  function validateFrom(txParams) {
1413
1413
  if (!(typeof txParams.from === "string")) {
1414
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid "from" address "${txParams.from}": not a string.`);
1414
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid "from" address "${txParams.from}": not a string.`);
1415
1415
  }
1416
1416
  if (!(0,util_namespaceObject.isValidAddress)(txParams.from)) {
1417
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams('Invalid "from" address.');
1417
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "from" address.');
1418
1418
  }
1419
1419
  }
1420
1420
 
@@ -1426,10 +1426,10 @@ function validateRecipient(txParameters) {
1426
1426
  if (txParameters.data) {
1427
1427
  delete txParameters.to;
1428
1428
  } else {
1429
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1429
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1430
1430
  }
1431
1431
  } else if (txParameters.to !== undefined && !(0,util_namespaceObject.isValidAddress)(txParameters.to)) {
1432
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1432
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams('Invalid "to" address.');
1433
1433
  }
1434
1434
  return txParameters;
1435
1435
  }
@@ -1440,15 +1440,15 @@ function validateRecipient(txParameters) {
1440
1440
  */
1441
1441
  function validateTxParameters(txParams, eip1559Compatibility = true) {
1442
1442
  if (!txParams || typeof txParams !== "object" || Array.isArray(txParams)) {
1443
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
1443
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams("Invalid transaction params: must be an object.");
1444
1444
  }
1445
1445
  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.');
1446
+ 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
1447
  }
1448
1448
  if (isEIP1559Transaction({
1449
1449
  transaction: txParams
1450
1450
  }) && !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");
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");
1452
1452
  }
1453
1453
  Object.entries(txParams).forEach(([key, value]) => {
1454
1454
  // validate types
@@ -1478,15 +1478,15 @@ function validateTxParameters(txParams, eip1559Compatibility = true) {
1478
1478
  case "value":
1479
1479
  ensureFieldIsString(txParams, "value");
1480
1480
  if (value.toString().includes("-")) {
1481
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value "${value}": not a positive number.`);
1481
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value "${value}": not a positive number.`);
1482
1482
  }
1483
1483
  if (value.toString().includes(".")) {
1484
- throw rpc_errors_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value of "${value}": number must be in wei.`);
1484
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction value of "${value}": number must be in wei.`);
1485
1485
  }
1486
1486
  break;
1487
1487
  case "chainId":
1488
1488
  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})`);
1489
+ throw openlogin_jrpc_namespaceObject.rpcErrors.invalidParams(`Invalid transaction params: ${key} is not a Number or hex string. got: (${value})`);
1490
1490
  }
1491
1491
  break;
1492
1492
  default:
@@ -2023,8 +2023,6 @@ class CurrencyController extends base_controllers_namespaceObject.BaseCurrencyCo
2023
2023
  };
2024
2024
  }
2025
2025
  }
2026
- ;// CONCATENATED MODULE: external "lodash"
2027
- const external_lodash_namespaceObject = require("lodash");
2028
2026
  ;// CONCATENATED MODULE: external "@babel/runtime/helpers/objectDestructuringEmpty"
2029
2027
  const objectDestructuringEmpty_namespaceObject = require("@babel/runtime/helpers/objectDestructuringEmpty");
2030
2028
  var objectDestructuringEmpty_default = /*#__PURE__*/__webpack_require__.n(objectDestructuringEmpty_namespaceObject);
@@ -2422,7 +2420,6 @@ function calculateTimeEstimate(maxPriorityFeePerGas, maxFeePerGas, gasFeeEstimat
2422
2420
 
2423
2421
 
2424
2422
 
2425
-
2426
2423
  const GAS_FEE_API = "https://mock-gas-server.herokuapp.com/";
2427
2424
  const LEGACY_GAS_PRICES_API_URL = "https://api.metaswap.codefi.network/gasPrices";
2428
2425
  /**
@@ -2548,7 +2545,7 @@ class GasFeeController extends base_controllers_namespaceObject.BaseController {
2548
2545
  external_loglevel_default().warn(error);
2549
2546
  isEIP1559Compatible = false;
2550
2547
  }
2551
- let newState = (0,external_lodash_namespaceObject.cloneDeep)(this.defaultState);
2548
+ let newState = (0,base_controllers_namespaceObject.cloneDeep)(this.defaultState);
2552
2549
  try {
2553
2550
  if (isEIP1559Compatible) {
2554
2551
  let estimates;
@@ -2610,7 +2607,7 @@ class GasFeeController extends base_controllers_namespaceObject.BaseController {
2610
2607
  }, this.config.interval);
2611
2608
  }
2612
2609
  resetState() {
2613
- this.update((0,external_lodash_namespaceObject.cloneDeep)(this.defaultState));
2610
+ this.update((0,base_controllers_namespaceObject.cloneDeep)(this.defaultState));
2614
2611
  }
2615
2612
  async getEIP1559Compatibility() {
2616
2613
  var _this$getCurrentAccou, _this$getCurrentAccou2;
@@ -2809,15 +2806,15 @@ class AbstractMessageController extends base_controllers_namespaceObject.BaseCon
2809
2806
  return new Promise((resolve, reject) => {
2810
2807
  const handleFinished = msg => {
2811
2808
  if (msg.status === MessageStatus.REJECTED) {
2812
- return reject(rpc_errors_namespaceObject.providerErrors.userRejectedRequest(`${messageName} Signature: User denied message signature`));
2809
+ return reject(openlogin_jrpc_namespaceObject.providerErrors.userRejectedRequest(`${messageName} Signature: User denied message signature`));
2813
2810
  }
2814
2811
  if (msg.status === MessageStatus.FAILED) {
2815
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`${messageName} Signature: failed to sign message ${msg.error}`));
2812
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`${messageName} Signature: failed to sign message ${msg.error}`));
2816
2813
  }
2817
2814
  if (msg.status === MessageStatus.SIGNED) {
2818
2815
  return resolve(msg.rawSig);
2819
2816
  }
2820
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`${messageName} Signature: Unknown problem: ${JSON.stringify(msgParams)}`));
2817
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`${messageName} Signature: Unknown problem: ${JSON.stringify(msgParams)}`));
2821
2818
  };
2822
2819
  this.once(`${msgParams.id}:finished`, handleFinished);
2823
2820
  });
@@ -3496,8 +3493,6 @@ class TypedMessageController extends AbstractMessageController {
3496
3493
  return Promise.resolve(messageParams);
3497
3494
  }
3498
3495
  }
3499
- ;// CONCATENATED MODULE: external "@toruslabs/openlogin-jrpc"
3500
- const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
3501
3496
  ;// CONCATENATED MODULE: ./src/Network/createEthereumMiddleware.ts
3502
3497
 
3503
3498
 
@@ -4432,6 +4427,9 @@ class NftHandler {
4432
4427
  return contract[method](tokenId);
4433
4428
  }
4434
4429
  }
4430
+ ;// CONCATENATED MODULE: external "deepmerge"
4431
+ const external_deepmerge_namespaceObject = require("deepmerge");
4432
+ var external_deepmerge_default = /*#__PURE__*/__webpack_require__.n(external_deepmerge_namespaceObject);
4435
4433
  ;// CONCATENATED MODULE: ./src/Nfts/NftsController.ts
4436
4434
 
4437
4435
 
@@ -4636,7 +4634,7 @@ class NftsController extends base_controllers_namespaceObject.BaseController {
4636
4634
  const nonZeroTokens = promiseSettledResult.filter(x => x.status === "fulfilled").map(x => x.value);
4637
4635
  this.update({
4638
4636
  nfts: {
4639
- [userAddress]: (0,external_lodash_namespaceObject.merge)(this.userNfts, nonZeroTokens)
4637
+ [userAddress]: external_deepmerge_default()(this.userNfts, nonZeroTokens)
4640
4638
  }
4641
4639
  });
4642
4640
  }
@@ -5949,7 +5947,7 @@ class TransactionGasUtil {
5949
5947
  Estimates the tx's gas usage
5950
5948
  */
5951
5949
  async estimateTxGas(txMeta) {
5952
- const txParams = (0,external_lodash_namespaceObject.cloneDeep)(txMeta.transaction);
5950
+ const txParams = (0,base_controllers_namespaceObject.cloneDeep)(txMeta.transaction);
5953
5951
 
5954
5952
  // `eth_estimateGas` can fail if the user has insufficient balance for the
5955
5953
  // value being sent, or for the gas cost. We don't want to check their
@@ -5965,6 +5963,26 @@ class TransactionGasUtil {
5965
5963
  });
5966
5964
  }
5967
5965
  }
5966
+ ;// CONCATENATED MODULE: ./src/utils/lodashUtils.ts
5967
+ function sortBy(arr, key) {
5968
+ return arr.slice().sort((a, b) => {
5969
+ if (a[key] < b[key]) return -1;
5970
+ if (a[key] > b[key]) return 1;
5971
+ return 0;
5972
+ });
5973
+ }
5974
+ function keyBy(arr, key) {
5975
+ return arr.reduce((acc, item) => {
5976
+ const keyValue = item[key];
5977
+ if (typeof keyValue === "string" || typeof keyValue === "number") {
5978
+ acc[keyValue.toString()] = item;
5979
+ }
5980
+ return acc;
5981
+ }, {});
5982
+ }
5983
+ function mapValues(obj, iteratee) {
5984
+ return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, iteratee(value, key)]));
5985
+ }
5968
5986
  ;// CONCATENATED MODULE: external "fast-json-patch"
5969
5987
  const external_fast_json_patch_namespaceObject = require("fast-json-patch");
5970
5988
  var external_fast_json_patch_default = /*#__PURE__*/__webpack_require__.n(external_fast_json_patch_namespaceObject);
@@ -5996,13 +6014,13 @@ function generateHistoryEntry(previousState, newState, note) {
5996
6014
  Recovers previous txMeta state obj
5997
6015
  */
5998
6016
  function replayHistory(_shortHistory) {
5999
- const shortHistory = (0,external_lodash_namespaceObject.cloneDeep)(_shortHistory);
6017
+ const shortHistory = (0,base_controllers_namespaceObject.cloneDeep)(_shortHistory);
6000
6018
  return shortHistory.reduce((val, entry) => external_fast_json_patch_default().applyPatch(val, entry).newDocument);
6001
6019
  }
6002
6020
  function snapshotFromTxMeta(txMeta) {
6003
6021
  const shallow = objectSpread2_default()({}, txMeta);
6004
6022
  delete shallow.history;
6005
- return (0,external_lodash_namespaceObject.cloneDeep)(shallow);
6023
+ return (0,base_controllers_namespaceObject.cloneDeep)(shallow);
6006
6024
  }
6007
6025
 
6008
6026
  ;// CONCATENATED MODULE: ./src/Transaction/TransactionStateManager.ts
@@ -6127,7 +6145,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6127
6145
  } = this.state;
6128
6146
  const chainId = this.getCurrentChainId();
6129
6147
  this.update({
6130
- transactions: (0,external_lodash_namespaceObject.omitBy)(transactions, txMeta => {
6148
+ transactions: (0,base_controllers_namespaceObject.omitBy)(transactions, txMeta => {
6131
6149
  const transactionMatch = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(txMeta, chainId);
6132
6150
  return txMeta.transaction.from === address && transactionMatch;
6133
6151
  })
@@ -6146,17 +6164,17 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6146
6164
  // with the provided value". To conform this object to be only methods, we
6147
6165
  // mapValues (lodash) such that every value on the object is a method that
6148
6166
  // returns a boolean.
6149
- const predicateMethods = (0,external_lodash_namespaceObject.mapValues)(searchCriteria, predicate => typeof predicate === "function" ? predicate : v => v === predicate);
6167
+ const predicateMethods = mapValues(searchCriteria, predicate => typeof predicate === "function" ? predicate : v => v === predicate);
6150
6168
 
6151
6169
  // If an initial list is provided we need to change it back into an object
6152
6170
  // first, so that it matches the shape of our state. This is done by the
6153
6171
  // lodash keyBy method. This is the edge case for this method, typically
6154
6172
  // initialList will be undefined.
6155
- const transactionsToFilter = initialList ? (0,external_lodash_namespaceObject.keyBy)(initialList, "id") : this.state.transactions;
6173
+ const transactionsToFilter = initialList ? keyBy(initialList, "id") : this.state.transactions;
6156
6174
 
6157
6175
  // Combine sortBy and pickBy to transform our state object into an array of
6158
6176
  // matching transactions that are sorted by time.
6159
- const filteredTransactions = (0,external_lodash_namespaceObject.sortBy)((0,external_lodash_namespaceObject.pickBy)(transactionsToFilter, txMeta => {
6177
+ const filteredTransactions = sortBy(Object.values((0,base_controllers_namespaceObject.pickBy)(transactionsToFilter, txMeta => {
6160
6178
  // default matchesCriteria to the value of transactionMatchesNetwork
6161
6179
  // when filterToCurrentNetwork is true.
6162
6180
  const transactionMatches = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(txMeta, chainId);
@@ -6180,7 +6198,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6180
6198
  }
6181
6199
  }
6182
6200
  return true;
6183
- }), "time");
6201
+ })), "time");
6184
6202
  if (limit !== undefined) {
6185
6203
  // We need to have all transactions of a given nonce in order to display
6186
6204
  // necessary details in the UI. We use the size of this set to determine
@@ -6253,7 +6271,7 @@ class TransactionStateManager extends base_controllers_namespaceObject.BaseTrans
6253
6271
  }
6254
6272
  getUnapprovedTxList() {
6255
6273
  const chainId = this.getCurrentChainId();
6256
- return (0,external_lodash_namespaceObject.pickBy)(this.state.transactions, transaction => {
6274
+ return (0,base_controllers_namespaceObject.pickBy)(this.state.transactions, transaction => {
6257
6275
  const transactionMatches = (0,base_controllers_namespaceObject.transactionMatchesNetwork)(transaction, chainId);
6258
6276
  return transaction.status === base_controllers_namespaceObject.TransactionStatus.unapproved && transactionMatches;
6259
6277
  });
@@ -6387,15 +6405,15 @@ class TransactionController extends TransactionStateManager {
6387
6405
  return new Promise((resolve, reject) => {
6388
6406
  const handleFinished = msg => {
6389
6407
  if (msg.status === base_controllers_namespaceObject.TransactionStatus.rejected) {
6390
- return reject(rpc_errors_namespaceObject.providerErrors.userRejectedRequest(`Transaction Signature: User denied message signature`));
6408
+ return reject(openlogin_jrpc_namespaceObject.providerErrors.userRejectedRequest(`Transaction Signature: User denied message signature`));
6391
6409
  }
6392
6410
  if (msg.status === base_controllers_namespaceObject.TransactionStatus.failed) {
6393
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`Transaction Signature: failed to sign message ${msg.error}`));
6411
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`Transaction Signature: failed to sign message ${msg.error}`));
6394
6412
  }
6395
6413
  if (msg.status === base_controllers_namespaceObject.TransactionStatus.submitted) {
6396
6414
  return resolve(msg.transactionHash);
6397
6415
  }
6398
- return reject(rpc_errors_namespaceObject.rpcErrors.internal(`Transaction Signature: Unknown problem: ${JSON.stringify(txMeta.transaction)}`));
6416
+ return reject(openlogin_jrpc_namespaceObject.rpcErrors.internal(`Transaction Signature: Unknown problem: ${JSON.stringify(txMeta.transaction)}`));
6399
6417
  };
6400
6418
  this.once(`${txMeta.id}:finished`, handleFinished);
6401
6419
  });
@@ -1,20 +1,19 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import { CHAIN_NAMESPACES, BaseController, randomId, TransactionStatus, TRANSACTION_TYPES, formatSmallNumbers, addressSlicer, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, significantDigits, BaseBlockTracker, timeout, BaseCurrencyController, BaseKeyringController, PROVIDER_JRPC_METHODS, createFetchMiddleware, createInflightCacheMiddleware, createSwappableProxy, createEventEmitterProxy, BasePreferencesController, isUnauthorizedError, TX_EVENTS, BaseTransactionStateManager, transactionMatchesNetwork as transactionMatchesNetwork$1 } from '@toruslabs/base-controllers';
3
+ import { CHAIN_NAMESPACES, BaseController, randomId, TransactionStatus, TRANSACTION_TYPES, formatSmallNumbers, addressSlicer, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, significantDigits, BaseBlockTracker, timeout, BaseCurrencyController, cloneDeep, BaseKeyringController, PROVIDER_JRPC_METHODS, createFetchMiddleware, createInflightCacheMiddleware, createSwappableProxy, createEventEmitterProxy, BasePreferencesController, isUnauthorizedError, TX_EVENTS, BaseTransactionStateManager, omitBy, transactionMatchesNetwork as transactionMatchesNetwork$1, pickBy } from '@toruslabs/base-controllers';
4
4
  import { Mutex } from 'async-mutex';
5
5
  import { BrowserProvider, toQuantity, Contract, Interface, isHexString as isHexString$1, JsonRpcProvider, keccak256 } from 'ethers';
6
6
  import log from 'loglevel';
7
7
  import { isHexString, addHexPrefix, isValidAddress, toChecksumAddress, stripHexPrefix, bytesToHex, privateToPublic, privateToAddress, ecsign, bigIntToBytes } from '@ethereumjs/util';
8
8
  import BigNumber from 'bignumber.js';
9
- import { rpcErrors, providerErrors } from '@metamask/rpc-errors';
9
+ import { rpcErrors, providerErrors, createAsyncMiddleware, mergeMiddleware, createScaffoldMiddleware, providerFromMiddleware, JRPCEngine, providerFromEngine, SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
10
10
  import { get } from '@toruslabs/http-helpers';
11
- import { cloneDeep, merge, omitBy, mapValues, keyBy, sortBy, pickBy } from 'lodash';
12
11
  import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
13
12
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
14
13
  import BN, { BN as BN$1 } from 'bn.js';
15
14
  import { concatSig, personalSign, signTypedData, getEncryptionPublicKey, decrypt, typedSignatureHash, TYPED_MESSAGE_SCHEMA, SignTypedDataVersion } from '@metamask/eth-sig-util';
16
- import { createAsyncMiddleware, mergeMiddleware, createScaffoldMiddleware, providerFromMiddleware, JRPCEngine, providerFromEngine, SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
17
15
  import stringify from 'fast-safe-stringify';
16
+ import deepmerge from 'deepmerge';
18
17
  import jsonDiffer from 'fast-json-patch';
19
18
 
20
19
  const erc20Abi = [{
@@ -4163,7 +4162,7 @@ class NftsController extends BaseController {
4163
4162
  const nonZeroTokens = promiseSettledResult.filter(x => x.status === "fulfilled").map(x => x.value);
4164
4163
  this.update({
4165
4164
  nfts: {
4166
- [userAddress]: merge(this.userNfts, nonZeroTokens)
4165
+ [userAddress]: deepmerge(this.userNfts, nonZeroTokens)
4167
4166
  }
4168
4167
  });
4169
4168
  }
@@ -5449,6 +5448,26 @@ class TransactionGasUtil {
5449
5448
  }
5450
5449
  }
5451
5450
 
5451
+ function sortBy(arr, key) {
5452
+ return arr.slice().sort((a, b) => {
5453
+ if (a[key] < b[key]) return -1;
5454
+ if (a[key] > b[key]) return 1;
5455
+ return 0;
5456
+ });
5457
+ }
5458
+ function keyBy(arr, key) {
5459
+ return arr.reduce((acc, item) => {
5460
+ const keyValue = item[key];
5461
+ if (typeof keyValue === "string" || typeof keyValue === "number") {
5462
+ acc[keyValue.toString()] = item;
5463
+ }
5464
+ return acc;
5465
+ }, {});
5466
+ }
5467
+ function mapValues(obj, iteratee) {
5468
+ return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, iteratee(value, key)]));
5469
+ }
5470
+
5452
5471
  /**
5453
5472
  Generates an array of history objects sense the previous state.
5454
5473
  The object has the keys
@@ -5627,7 +5646,7 @@ class TransactionStateManager extends BaseTransactionStateManager {
5627
5646
 
5628
5647
  // Combine sortBy and pickBy to transform our state object into an array of
5629
5648
  // matching transactions that are sorted by time.
5630
- const filteredTransactions = sortBy(pickBy(transactionsToFilter, txMeta => {
5649
+ const filteredTransactions = sortBy(Object.values(pickBy(transactionsToFilter, txMeta => {
5631
5650
  // default matchesCriteria to the value of transactionMatchesNetwork
5632
5651
  // when filterToCurrentNetwork is true.
5633
5652
  const transactionMatches = transactionMatchesNetwork$1(txMeta, chainId);
@@ -5651,7 +5670,7 @@ class TransactionStateManager extends BaseTransactionStateManager {
5651
5670
  }
5652
5671
  }
5653
5672
  return true;
5654
- }), "time");
5673
+ })), "time");
5655
5674
  if (limit !== undefined) {
5656
5675
  // We need to have all transactions of a given nonce in order to display
5657
5676
  // necessary details in the UI. We use the size of this set to determine