@metamask/transaction-controller 7.1.0 → 8.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionController.d.ts","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAKtC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAsB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,8BAA8B,CAAC;AActC,OAAO,EAEL,kBAAkB,EAEnB,MAAM,+BAA+B,CAAC;AAgBvC,eAAO,MAAM,QAAQ,WAAW,CAAC;AAEjC;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;I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AAM,EACf,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAoBX,eAAe;IA8D7B;;;;;;;OAOG;YACW,kBAAkB;IAwFhC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,wBAAwB;IA0BhC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IASpB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;;OAKG;YACW,oCAAoC;IA4DlD;;;;;;;;OAQG;YACW,4BAA4B;YAa5B,eAAe;IAmB7B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,sBAAsB;CAc/B;AAED,eAAe,qBAAqB,CAAC"}
@@ -12,46 +12,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.WalletDevice = exports.TransactionStatus = exports.HARDFORK = void 0;
16
- const events_1 = require("events");
17
- const ethereumjs_util_1 = require("ethereumjs-util");
18
- const eth_rpc_errors_1 = require("eth-rpc-errors");
19
- const eth_method_registry_1 = __importDefault(require("eth-method-registry"));
20
- const eth_query_1 = __importDefault(require("eth-query"));
21
- const common_1 = __importDefault(require("@ethereumjs/common"));
15
+ exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0;
16
+ const common_1 = require("@ethereumjs/common");
22
17
  const tx_1 = require("@ethereumjs/tx");
23
- const uuid_1 = require("uuid");
24
- const async_mutex_1 = require("async-mutex");
25
18
  const base_controller_1 = require("@metamask/base-controller");
26
19
  const controller_utils_1 = require("@metamask/controller-utils");
20
+ const eth_query_1 = __importDefault(require("@metamask/eth-query"));
21
+ const async_mutex_1 = require("async-mutex");
22
+ const eth_method_registry_1 = __importDefault(require("eth-method-registry"));
23
+ const eth_rpc_errors_1 = require("eth-rpc-errors");
24
+ const ethereumjs_util_1 = require("ethereumjs-util");
25
+ const events_1 = require("events");
27
26
  const nonce_tracker_1 = __importDefault(require("nonce-tracker"));
27
+ const uuid_1 = require("uuid");
28
+ const EtherscanRemoteTransactionSource_1 = require("./EtherscanRemoteTransactionSource");
29
+ const IncomingTransactionHelper_1 = require("./IncomingTransactionHelper");
30
+ const types_1 = require("./types");
28
31
  const utils_1 = require("./utils");
29
- exports.HARDFORK = 'london';
30
- /**
31
- * The status of the transaction. Each status represents the state of the transaction internally
32
- * in the wallet. Some of these correspond with the state of the transaction on the network, but
33
- * some are wallet-specific.
34
- */
35
- var TransactionStatus;
36
- (function (TransactionStatus) {
37
- TransactionStatus["approved"] = "approved";
38
- TransactionStatus["cancelled"] = "cancelled";
39
- TransactionStatus["confirmed"] = "confirmed";
40
- TransactionStatus["failed"] = "failed";
41
- TransactionStatus["rejected"] = "rejected";
42
- TransactionStatus["signed"] = "signed";
43
- TransactionStatus["submitted"] = "submitted";
44
- TransactionStatus["unapproved"] = "unapproved";
45
- })(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {}));
46
- /**
47
- * Options for wallet device.
48
- */
49
- var WalletDevice;
50
- (function (WalletDevice) {
51
- WalletDevice["MM_MOBILE"] = "metamask_mobile";
52
- WalletDevice["MM_EXTENSION"] = "metamask_extension";
53
- WalletDevice["OTHER"] = "other_device";
54
- })(WalletDevice = exports.WalletDevice || (exports.WalletDevice = {}));
32
+ exports.HARDFORK = common_1.Hardfork.London;
55
33
  /**
56
34
  * Multiplier used to determine a transaction's increased gas fee during cancellation
57
35
  */
@@ -83,34 +61,6 @@ class TransactionController extends base_controller_1.BaseController {
83
61
  constructor({ getNetworkState, onNetworkStateChange, provider, blockTracker, messenger, }, config, state) {
84
62
  super(config, state);
85
63
  this.mutex = new async_mutex_1.Mutex();
86
- this.normalizeTokenTx = (txMeta, currentNetworkID, currentChainId) => {
87
- const time = parseInt(txMeta.timeStamp, 10) * 1000;
88
- const { to, from, gas, gasPrice, gasUsed, hash, contractAddress, tokenDecimal, tokenSymbol, value, } = txMeta;
89
- return {
90
- id: (0, uuid_1.v1)({ msecs: time }),
91
- isTransfer: true,
92
- networkID: currentNetworkID,
93
- chainId: currentChainId,
94
- status: TransactionStatus.confirmed,
95
- time,
96
- transaction: {
97
- chainId: currentChainId,
98
- from,
99
- gas,
100
- gasPrice,
101
- gasUsed,
102
- to,
103
- value,
104
- },
105
- transactionHash: hash,
106
- transferInformation: {
107
- contractAddress,
108
- decimals: Number(tokenDecimal),
109
- symbol: tokenSymbol,
110
- },
111
- verifiedOnBlockchain: false,
112
- };
113
- };
114
64
  /**
115
65
  * EventEmitter instance used to listen to specific transactional events
116
66
  */
@@ -136,8 +86,14 @@ class TransactionController extends base_controller_1.BaseController {
136
86
  this.nonceTracker = new nonce_tracker_1.default({
137
87
  provider,
138
88
  blockTracker,
139
- getPendingTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, TransactionStatus.submitted, this.state.transactions),
140
- getConfirmedTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, TransactionStatus.confirmed, this.state.transactions),
89
+ getPendingTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.submitted, this.state.transactions),
90
+ getConfirmedTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.confirmed, this.state.transactions),
91
+ });
92
+ this.incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
93
+ getNetworkState,
94
+ getEthQuery: () => this.ethQuery,
95
+ transactionLimit: this.config.txHistoryLimit,
96
+ remoteTransactionSource: new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource(),
141
97
  });
142
98
  onNetworkStateChange(() => {
143
99
  this.ethQuery = new eth_query_1.default(this.provider);
@@ -146,7 +102,7 @@ class TransactionController extends base_controller_1.BaseController {
146
102
  this.poll();
147
103
  }
148
104
  failTransaction(transactionMeta, error) {
149
- const newTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { error, status: TransactionStatus.failed });
105
+ const newTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { error, status: types_1.TransactionStatus.failed });
150
106
  this.updateTransaction(newTransactionMeta);
151
107
  this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta);
152
108
  }
@@ -157,43 +113,6 @@ class TransactionController extends base_controller_1.BaseController {
157
113
  return { registryMethod, parsedRegistryMethod };
158
114
  });
159
115
  }
160
- /**
161
- * Normalizes the transaction information from etherscan
162
- * to be compatible with the TransactionMeta interface.
163
- *
164
- * @param txMeta - The transaction.
165
- * @param currentNetworkID - The current network ID.
166
- * @param currentChainId - The current chain ID.
167
- * @returns The normalized transaction.
168
- */
169
- normalizeTx(txMeta, currentNetworkID, currentChainId) {
170
- const time = parseInt(txMeta.timeStamp, 10) * 1000;
171
- const normalizedTransactionBase = {
172
- blockNumber: txMeta.blockNumber,
173
- id: (0, uuid_1.v1)({ msecs: time }),
174
- networkID: currentNetworkID,
175
- chainId: currentChainId,
176
- time,
177
- transaction: {
178
- data: txMeta.input,
179
- from: txMeta.from,
180
- gas: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gas)),
181
- gasPrice: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gasPrice)),
182
- gasUsed: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gasUsed)),
183
- nonce: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.nonce)),
184
- to: txMeta.to,
185
- value: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.value)),
186
- },
187
- transactionHash: txMeta.hash,
188
- verifiedOnBlockchain: false,
189
- };
190
- /* istanbul ignore else */
191
- if (txMeta.isError === '0') {
192
- return Object.assign(Object.assign({}, normalizedTransactionBase), { status: TransactionStatus.confirmed });
193
- }
194
- /* istanbul ignore next */
195
- return Object.assign(Object.assign({}, normalizedTransactionBase), { error: new Error('Transaction failed'), status: TransactionStatus.failed });
196
- }
197
116
  /**
198
117
  * Starts a new polling interval.
199
118
  *
@@ -256,7 +175,7 @@ class TransactionController extends base_controller_1.BaseController {
256
175
  networkID: networkId !== null && networkId !== void 0 ? networkId : undefined,
257
176
  chainId: providerConfig.chainId,
258
177
  origin,
259
- status: TransactionStatus.unapproved,
178
+ status: types_1.TransactionStatus.unapproved,
260
179
  time: Date.now(),
261
180
  transaction,
262
181
  deviceConfirmedOn,
@@ -300,14 +219,15 @@ class TransactionController extends base_controller_1.BaseController {
300
219
  if (chain !== controller_utils_1.RPC &&
301
220
  chain !== controller_utils_1.NetworkType['linea-goerli'] &&
302
221
  chain !== controller_utils_1.NetworkType['linea-mainnet']) {
303
- return new common_1.default({ chain, hardfork: exports.HARDFORK });
222
+ return new common_1.Common({ chain, hardfork: exports.HARDFORK });
304
223
  }
305
224
  const customChainParams = {
306
225
  name,
307
226
  chainId: parseInt(chainId, 16),
308
227
  networkId: networkId === null ? NaN : parseInt(networkId, undefined),
228
+ defaultHardfork: exports.HARDFORK,
309
229
  };
310
- return common_1.default.forCustomChain(controller_utils_1.NetworkType.mainnet, customChainParams, exports.HARDFORK);
230
+ return common_1.Common.custom(customChainParams);
311
231
  }
312
232
  /**
313
233
  * Attempts to cancel a transaction based on its ID by setting its status to "rejected"
@@ -372,7 +292,7 @@ class TransactionController extends base_controller_1.BaseController {
372
292
  const signedTx = yield this.sign(unsignedEthTx, transactionMeta.transaction.from);
373
293
  const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
374
294
  yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTransaction]);
375
- transactionMeta.status = TransactionStatus.cancelled;
295
+ transactionMeta.status = types_1.TransactionStatus.cancelled;
376
296
  this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);
377
297
  });
378
298
  }
@@ -584,57 +504,19 @@ class TransactionController extends base_controller_1.BaseController {
584
504
  */
585
505
  fetchAll(address, opt) {
586
506
  return __awaiter(this, void 0, void 0, function* () {
587
- const { providerConfig, networkId: currentNetworkID } = this.getNetworkState();
588
- const { chainId: currentChainId, type: networkType } = providerConfig;
589
- const { transactions } = this.state;
590
- const supportedNetworkIds = ['1', '5', '11155111'];
591
- /* istanbul ignore next */
592
- if (currentNetworkID === null ||
593
- supportedNetworkIds.indexOf(currentNetworkID) === -1) {
594
- return undefined;
595
- }
596
- const [etherscanTxResponse, etherscanTokenResponse] = yield (0, utils_1.handleTransactionFetch)(networkType, address, this.config.txHistoryLimit, opt);
597
- const normalizedTxs = etherscanTxResponse.result.map((tx) => this.normalizeTx(tx, currentNetworkID, currentChainId));
598
- const normalizedTokenTxs = etherscanTokenResponse.result.map((tx) => this.normalizeTokenTx(tx, currentNetworkID, currentChainId));
599
- const [updateRequired, allTxs] = this.etherscanTransactionStateReconciler([...normalizedTxs, ...normalizedTokenTxs], transactions);
600
- allTxs.sort((a, b) => (a.time < b.time ? -1 : 1));
601
- let latestIncomingTxBlockNumber;
602
- allTxs.forEach((tx) => __awaiter(this, void 0, void 0, function* () {
603
- /* istanbul ignore next */
604
- if (
605
- // Using fallback to networkID only when there is no chainId present. Should be removed when networkID is completely removed.
606
- (tx.chainId === currentChainId ||
607
- (!tx.chainId && tx.networkID === currentNetworkID)) &&
608
- tx.transaction.to &&
609
- tx.transaction.to.toLowerCase() === address.toLowerCase()) {
610
- if (tx.blockNumber &&
611
- (!latestIncomingTxBlockNumber ||
612
- parseInt(latestIncomingTxBlockNumber, 10) <
613
- parseInt(tx.blockNumber, 10))) {
614
- latestIncomingTxBlockNumber = tx.blockNumber;
615
- }
616
- }
617
- /* istanbul ignore else */
618
- if (tx.toSmartContract === undefined) {
619
- // If not `to` is a contract deploy, if not `data` is send eth
620
- if (tx.transaction.to &&
621
- (!tx.transaction.data || tx.transaction.data !== '0x')) {
622
- const code = yield (0, controller_utils_1.query)(this.ethQuery, 'getCode', [
623
- tx.transaction.to,
624
- ]);
625
- tx.toSmartContract = (0, controller_utils_1.isSmartContractCode)(code);
626
- }
627
- else {
628
- tx.toSmartContract = false;
629
- }
630
- }
631
- }));
632
- // Update state only if new transactions were fetched or
633
- // the status or gas data of a transaction has changed
507
+ const { transactions: localTransactions } = this.state;
508
+ const { updateRequired, transactions, latestBlockNumber } = yield this.incomingTransactionHelper.reconcile({
509
+ address,
510
+ localTransactions,
511
+ fromBlock: opt === null || opt === void 0 ? void 0 : opt.fromBlock,
512
+ apiKey: opt === null || opt === void 0 ? void 0 : opt.etherscanApiKey,
513
+ });
634
514
  if (updateRequired) {
635
- this.update({ transactions: this.trimTransactionsForState(allTxs) });
515
+ this.update({
516
+ transactions: this.trimTransactionsForState(transactions),
517
+ });
636
518
  }
637
- return latestIncomingTxBlockNumber;
519
+ return latestBlockNumber;
638
520
  });
639
521
  }
640
522
  processApproval(transactionMeta) {
@@ -663,14 +545,14 @@ class TransactionController extends base_controller_1.BaseController {
663
545
  }
664
546
  const finalMeta = this.getTransaction(transactionId);
665
547
  switch (finalMeta === null || finalMeta === void 0 ? void 0 : finalMeta.status) {
666
- case TransactionStatus.failed:
548
+ case types_1.TransactionStatus.failed:
667
549
  resultCallbacks === null || resultCallbacks === void 0 ? void 0 : resultCallbacks.error(finalMeta.error);
668
550
  throw eth_rpc_errors_1.ethErrors.rpc.internal(finalMeta.error.message);
669
- case TransactionStatus.cancelled:
551
+ case types_1.TransactionStatus.cancelled:
670
552
  const cancelError = eth_rpc_errors_1.ethErrors.rpc.internal('User cancelled the transaction');
671
553
  resultCallbacks === null || resultCallbacks === void 0 ? void 0 : resultCallbacks.error(cancelError);
672
554
  throw cancelError;
673
- case TransactionStatus.submitted:
555
+ case types_1.TransactionStatus.submitted:
674
556
  resultCallbacks === null || resultCallbacks === void 0 ? void 0 : resultCallbacks.success();
675
557
  return finalMeta.transactionHash;
676
558
  default:
@@ -709,7 +591,7 @@ class TransactionController extends base_controller_1.BaseController {
709
591
  this.failTransaction(transactionMeta, new Error('No chainId defined.'));
710
592
  return;
711
593
  }
712
- const { approved: status } = TransactionStatus;
594
+ const { approved: status } = types_1.TransactionStatus;
713
595
  let nonceToUse = nonce;
714
596
  // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction
715
597
  // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce
@@ -732,7 +614,7 @@ class TransactionController extends base_controller_1.BaseController {
732
614
  }
733
615
  const unsignedEthTx = this.prepareUnsignedEthTx(txParams);
734
616
  const signedTx = yield this.sign(unsignedEthTx, from);
735
- transactionMeta.status = TransactionStatus.signed;
617
+ transactionMeta.status = types_1.TransactionStatus.signed;
736
618
  this.updateTransaction(transactionMeta);
737
619
  const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
738
620
  transactionMeta.rawTransaction = rawTransaction;
@@ -741,7 +623,7 @@ class TransactionController extends base_controller_1.BaseController {
741
623
  rawTransaction,
742
624
  ]);
743
625
  transactionMeta.transactionHash = transactionHash;
744
- transactionMeta.status = TransactionStatus.submitted;
626
+ transactionMeta.status = types_1.TransactionStatus.submitted;
745
627
  this.updateTransaction(transactionMeta);
746
628
  this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);
747
629
  }
@@ -768,7 +650,7 @@ class TransactionController extends base_controller_1.BaseController {
768
650
  if (!transactionMeta) {
769
651
  return;
770
652
  }
771
- transactionMeta.status = TransactionStatus.rejected;
653
+ transactionMeta.status = types_1.TransactionStatus.rejected;
772
654
  this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);
773
655
  const transactions = this.state.transactions.filter(({ id }) => id !== transactionID);
774
656
  this.update({ transactions: this.trimTransactionsForState(transactions) });
@@ -814,10 +696,10 @@ class TransactionController extends base_controller_1.BaseController {
814
696
  * @returns Whether the transaction is in a final state.
815
697
  */
816
698
  isFinalState(status) {
817
- return (status === TransactionStatus.rejected ||
818
- status === TransactionStatus.confirmed ||
819
- status === TransactionStatus.failed ||
820
- status === TransactionStatus.cancelled);
699
+ return (status === types_1.TransactionStatus.rejected ||
700
+ status === types_1.TransactionStatus.confirmed ||
701
+ status === types_1.TransactionStatus.failed ||
702
+ status === types_1.TransactionStatus.cancelled);
821
703
  }
822
704
  /**
823
705
  * Whether the transaction has at least completed all local processing.
@@ -827,11 +709,11 @@ class TransactionController extends base_controller_1.BaseController {
827
709
  */
828
710
  isLocalFinalState(status) {
829
711
  return [
830
- TransactionStatus.cancelled,
831
- TransactionStatus.confirmed,
832
- TransactionStatus.failed,
833
- TransactionStatus.rejected,
834
- TransactionStatus.submitted,
712
+ types_1.TransactionStatus.cancelled,
713
+ types_1.TransactionStatus.confirmed,
714
+ types_1.TransactionStatus.failed,
715
+ types_1.TransactionStatus.rejected,
716
+ types_1.TransactionStatus.submitted,
835
717
  ].includes(status);
836
718
  }
837
719
  /**
@@ -844,7 +726,7 @@ class TransactionController extends base_controller_1.BaseController {
844
726
  return __awaiter(this, void 0, void 0, function* () {
845
727
  const { status, transactionHash } = meta;
846
728
  switch (status) {
847
- case TransactionStatus.confirmed:
729
+ case types_1.TransactionStatus.confirmed:
848
730
  const txReceipt = yield (0, controller_utils_1.query)(this.ethQuery, 'getTransactionReceipt', [
849
731
  transactionHash,
850
732
  ]);
@@ -861,7 +743,7 @@ class TransactionController extends base_controller_1.BaseController {
861
743
  return [meta, false];
862
744
  }
863
745
  return [meta, true];
864
- case TransactionStatus.submitted:
746
+ case types_1.TransactionStatus.submitted:
865
747
  const txObj = yield (0, controller_utils_1.query)(this.ethQuery, 'getTransactionByHash', [
866
748
  transactionHash,
867
749
  ]);
@@ -876,7 +758,7 @@ class TransactionController extends base_controller_1.BaseController {
876
758
  }
877
759
  /* istanbul ignore next */
878
760
  if (txObj === null || txObj === void 0 ? void 0 : txObj.blockNumber) {
879
- meta.status = TransactionStatus.confirmed;
761
+ meta.status = types_1.TransactionStatus.confirmed;
880
762
  this.hub.emit(`${meta.id}:confirmed`, meta);
881
763
  return [meta, true];
882
764
  }
@@ -907,89 +789,6 @@ class TransactionController extends base_controller_1.BaseController {
907
789
  return Number(txReceipt.status) === 0;
908
790
  });
909
791
  }
910
- /**
911
- * Method to verify the state of transactions using Etherscan as a source of truth.
912
- *
913
- * @param remoteTxs - Transactions to reconcile that are from a remote source.
914
- * @param localTxs - Transactions to reconcile that are local.
915
- * @returns A tuple containing a boolean indicating whether or not an update was required, and the updated transaction.
916
- */
917
- etherscanTransactionStateReconciler(remoteTxs, localTxs) {
918
- const updatedTxs = this.getUpdatedTransactions(remoteTxs, localTxs);
919
- const newTxs = this.getNewTransactions(remoteTxs, localTxs);
920
- const updatedLocalTxs = localTxs.map((tx) => {
921
- const txIdx = updatedTxs.findIndex(({ transactionHash }) => transactionHash === tx.transactionHash);
922
- return txIdx === -1 ? tx : updatedTxs[txIdx];
923
- });
924
- const updateRequired = newTxs.length > 0 || updatedLocalTxs.length > 0;
925
- return [updateRequired, [...newTxs, ...updatedLocalTxs]];
926
- }
927
- /**
928
- * Get all transactions that are in the remote transactions array
929
- * but not in the local transactions array.
930
- *
931
- * @param remoteTxs - Array of transactions from remote source.
932
- * @param localTxs - Array of transactions stored locally.
933
- * @returns The new transactions.
934
- */
935
- getNewTransactions(remoteTxs, localTxs) {
936
- return remoteTxs.filter((tx) => {
937
- const alreadyInTransactions = localTxs.find(({ transactionHash }) => transactionHash === tx.transactionHash);
938
- return !alreadyInTransactions;
939
- });
940
- }
941
- /**
942
- * Get all the transactions that are locally outdated with respect
943
- * to a remote source (etherscan or blockchain). The returned array
944
- * contains the transactions with the updated data.
945
- *
946
- * @param remoteTxs - Array of transactions from remote source.
947
- * @param localTxs - Array of transactions stored locally.
948
- * @returns The updated transactions.
949
- */
950
- getUpdatedTransactions(remoteTxs, localTxs) {
951
- return remoteTxs.filter((remoteTx) => {
952
- const isTxOutdated = localTxs.find((localTx) => {
953
- return (remoteTx.transactionHash === localTx.transactionHash &&
954
- this.isTransactionOutdated(remoteTx, localTx));
955
- });
956
- return isTxOutdated;
957
- });
958
- }
959
- /**
960
- * Verifies if a local transaction is outdated with respect to the remote transaction.
961
- *
962
- * @param remoteTx - The remote transaction from Etherscan.
963
- * @param localTx - The local transaction.
964
- * @returns Whether the transaction is outdated.
965
- */
966
- isTransactionOutdated(remoteTx, localTx) {
967
- const statusOutdated = this.isStatusOutdated(remoteTx.transactionHash, localTx.transactionHash, remoteTx.status, localTx.status);
968
- const gasDataOutdated = this.isGasDataOutdated(remoteTx.transaction.gasUsed, localTx.transaction.gasUsed);
969
- return statusOutdated || gasDataOutdated;
970
- }
971
- /**
972
- * Verifies if the status of a local transaction is outdated with respect to the remote transaction.
973
- *
974
- * @param remoteTxHash - Remote transaction hash.
975
- * @param localTxHash - Local transaction hash.
976
- * @param remoteTxStatus - Remote transaction status.
977
- * @param localTxStatus - Local transaction status.
978
- * @returns Whether the status is outdated.
979
- */
980
- isStatusOutdated(remoteTxHash, localTxHash, remoteTxStatus, localTxStatus) {
981
- return remoteTxHash === localTxHash && remoteTxStatus !== localTxStatus;
982
- }
983
- /**
984
- * Verifies if the gas data of a local transaction is outdated with respect to the remote transaction.
985
- *
986
- * @param remoteGasUsed - Remote gas used in the transaction.
987
- * @param localGasUsed - Local gas used in the transaction.
988
- * @returns Whether the gas data is outdated.
989
- */
990
- isGasDataOutdated(remoteGasUsed, localGasUsed) {
991
- return remoteGasUsed !== localGasUsed;
992
- }
993
792
  requestApproval(txMeta) {
994
793
  return __awaiter(this, void 0, void 0, function* () {
995
794
  const id = this.getApprovalId(txMeta);