@metamask-previews/transaction-controller 9.0.0-preview.3dbf14f → 9.2.0-preview.b963821

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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [9.2.0]
10
+ ### Added
11
+ - Persist `estimatedBaseFee` in `stopTransaction` and `speedUpTransaction` ([#1621](https://github.com/MetaMask/core/pull/1621))
12
+ - Add `securityAlertResponse` to `addTransaction` `opts` argument ([#1636](https://github.com/MetaMask/core/pull/1636))
13
+
14
+ ## [9.1.0]
15
+ ### Added
16
+ - Add `blockTimestamp` to `TransactionMetaBase` type ([#1616](https://github.com/MetaMask/core/pull/1616))
17
+ - Update `queryTransactionStatuses` to populate `blockTimestamp` on each transaction when it is verified ([#1616](https://github.com/MetaMask/core/pull/1616))
18
+
19
+ ### Changed
20
+ - Bump dependency and peer dependency on `@metamask/approval-controller` to ^3.5.1
21
+ - Bump dependency on `@metamask/base-controller` to ^3.2.1
22
+ - Bump dependency on `@metamask/controller-utils` to ^4.3.2
23
+ - Bump dependency and peer dependency on `@metamask/network-controller` to ^12.1.2
24
+
9
25
  ## [9.0.0]
10
26
  ### Added
11
27
  - Add `baseFeePerGas` to transaction metadata ([#1590](https://github.com/MetaMask/core/pull/1590))
@@ -135,7 +151,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
135
151
 
136
152
  All changes listed after this point were applied to this package following the monorepo conversion.
137
153
 
138
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@9.0.0...HEAD
154
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@9.2.0...HEAD
155
+ [9.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@9.1.0...@metamask/transaction-controller@9.2.0
156
+ [9.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@9.0.0...@metamask/transaction-controller@9.1.0
139
157
  [9.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@8.0.1...@metamask/transaction-controller@9.0.0
140
158
  [8.0.1]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@8.0.0...@metamask/transaction-controller@8.0.1
141
159
  [8.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@7.1.0...@metamask/transaction-controller@8.0.0
@@ -1 +1 @@
1
- {"version":3,"file":"EtherscanRemoteTransactionSource.d.ts","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAgB3C,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,qBAAa,gCACX,YAAW,uBAAuB;;gBAMtB,EACV,MAAM,EACN,qBAAqB,GACtB,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAO;IAK5D,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAInC,iBAAiB,CACrB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,eAAe,EAAE,CAAC;CA4F9B"}
1
+ {"version":3,"file":"EtherscanRemoteTransactionSource.d.ts","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAgB3C,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,qBAAa,gCACX,YAAW,uBAAuB;;gBAMtB,EACV,MAAM,EACN,qBAAqB,GACtB,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAO;IAK5D,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAInC,iBAAiB,CACrB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,eAAe,EAAE,CAAC;CA6F9B"}
@@ -83,6 +83,7 @@ _EtherscanRemoteTransactionSource_apiKey = new WeakMap(), _EtherscanRemoteTransa
83
83
  status: types_1.TransactionStatus.confirmed,
84
84
  time,
85
85
  transaction: {
86
+ chainId: currentChainId,
86
87
  from: txMeta.from,
87
88
  gas: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gas)),
88
89
  gasPrice: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gasPrice)),
@@ -1 +1 @@
1
- {"version":3,"file":"EtherscanRemoteTransactionSource.js","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AAErD,qDAAqC;AACrC,+BAAoC;AAEpC,2CAA2D;AAQ3D,2CAGqB;AAMrB,mCAA4C;AAE5C;;GAEG;AACH,MAAa,gCAAgC;IAO3C,YAAY,EACV,MAAM,EACN,qBAAqB,MACmC,EAAE;;QAP5D,2DAAiB;QAEjB,0EAAgC;QAM9B,uBAAA,IAAI,4CAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,2DAA0B,qBAAqB,aAArB,qBAAqB,cAArB,qBAAqB,GAAI,IAAI,MAAA,CAAC;IAC9D,CAAC;IAED,kBAAkB,CAAC,OAAY;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,wCAA4B,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAEK,iBAAiB,CACrB,OAAuC;;YAEvC,MAAM,gBAAgB,mCACjB,OAAO,KACV,MAAM,EAAE,uBAAA,IAAI,gDAAQ,EACpB,OAAO,EAAE,OAAO,CAAC,cAAc,GAChC,CA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BAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,eAAe,EAAE,MAAM,CAAC,IAAI;QAC5B,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { BNToHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { BN } from 'ethereumjs-util';\nimport { v1 as random } from 'uuid';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from './constants';\nimport type {\n EtherscanTokenTransactionMeta,\n EtherscanTransactionMeta,\n EtherscanTransactionMetaBase,\n EtherscanTransactionRequest,\n EtherscanTransactionResponse,\n} from './etherscan';\nimport {\n fetchEtherscanTokenTransactions,\n fetchEtherscanTransactions,\n} from './etherscan';\nimport type {\n RemoteTransactionSource,\n RemoteTransactionSourceRequest,\n TransactionMeta,\n} from './types';\nimport { TransactionStatus } from './types';\n\n/**\n * A RemoteTransactionSource that fetches transaction data from Etherscan.\n */\nexport class EtherscanRemoteTransactionSource\n implements RemoteTransactionSource\n{\n #apiKey?: string;\n\n #includeTokenTransfers: boolean;\n\n constructor({\n apiKey,\n includeTokenTransfers,\n }: { apiKey?: string; includeTokenTransfers?: boolean } = {}) {\n this.#apiKey = apiKey;\n this.#includeTokenTransfers = includeTokenTransfers ?? true;\n }\n\n isSupportedNetwork(chainId: Hex): boolean {\n return Object.keys(ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId);\n }\n\n async fetchTransactions(\n request: RemoteTransactionSourceRequest,\n ): Promise<TransactionMeta[]> {\n const etherscanRequest: EtherscanTransactionRequest = {\n ...request,\n apiKey: this.#apiKey,\n chainId: request.currentChainId,\n };\n\n const transactionPromise = fetchEtherscanTransactions(etherscanRequest);\n\n const tokenTransactionPromise = this.#includeTokenTransfers\n ? fetchEtherscanTokenTransactions(etherscanRequest)\n : Promise.resolve({\n result: [] as EtherscanTokenTransactionMeta[],\n } as EtherscanTransactionResponse<EtherscanTokenTransactionMeta>);\n\n const [etherscanTransactions, etherscanTokenTransactions] =\n await Promise.all([transactionPromise, tokenTransactionPromise]);\n\n const transactions = etherscanTransactions.result.map((tx) =>\n this.#normalizeTransaction(tx, request.currentChainId),\n );\n\n const tokenTransactions = etherscanTokenTransactions.result.map((tx) =>\n this.#normalizeTokenTransaction(tx, request.currentChainId),\n );\n\n return [...transactions, ...tokenTransactions];\n }\n\n #normalizeTransaction(\n txMeta: EtherscanTransactionMeta,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, currentChainId);\n\n return {\n ...base,\n transaction: {\n ...base.transaction,\n data: txMeta.input,\n },\n ...(txMeta.isError === '0'\n ? { status: TransactionStatus.confirmed }\n : {\n error: new Error('Transaction failed'),\n status: TransactionStatus.failed,\n }),\n };\n }\n\n #normalizeTokenTransaction(\n txMeta: EtherscanTokenTransactionMeta,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, currentChainId);\n\n return {\n ...base,\n isTransfer: true,\n transferInformation: {\n contractAddress: txMeta.contractAddress,\n decimals: Number(txMeta.tokenDecimal),\n symbol: txMeta.tokenSymbol,\n },\n };\n }\n\n #normalizeTransactionBase(\n txMeta: EtherscanTransactionMetaBase,\n currentChainId: Hex,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n\n return {\n blockNumber: txMeta.blockNumber,\n chainId: currentChainId,\n id: random({ msecs: time }),\n status: TransactionStatus.confirmed,\n time,\n transaction: {\n from: txMeta.from,\n gas: BNToHex(new BN(txMeta.gas)),\n gasPrice: BNToHex(new BN(txMeta.gasPrice)),\n gasUsed: BNToHex(new BN(txMeta.gasUsed)),\n nonce: BNToHex(new BN(txMeta.nonce)),\n to: txMeta.to,\n value: BNToHex(new BN(txMeta.value)),\n },\n transactionHash: txMeta.hash,\n verifiedOnBlockchain: false,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"EtherscanRemoteTransactionSource.js","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.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OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,cAAc;QACvB,EAAE,EAAE,IAAA,SAAM,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC3B,MAAM,EAAE,yBAAiB,CAAC,SAAS;QACnC,IAAI;QACJ,WAAW,EAAE;YACX,OAAO,EAAE,cAAc;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,GAAG,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,QAAQ,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1C,OAAO,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACxC,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpC,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,eAAe,EAAE,MAAM,CAAC,IAAI;QAC5B,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { BNToHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { BN } from 'ethereumjs-util';\nimport { v1 as random } from 'uuid';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from './constants';\nimport type {\n EtherscanTokenTransactionMeta,\n EtherscanTransactionMeta,\n EtherscanTransactionMetaBase,\n EtherscanTransactionRequest,\n EtherscanTransactionResponse,\n} from './etherscan';\nimport {\n fetchEtherscanTokenTransactions,\n fetchEtherscanTransactions,\n} from './etherscan';\nimport type {\n RemoteTransactionSource,\n RemoteTransactionSourceRequest,\n TransactionMeta,\n} from './types';\nimport { TransactionStatus } from './types';\n\n/**\n * A RemoteTransactionSource that fetches transaction data from Etherscan.\n */\nexport class EtherscanRemoteTransactionSource\n implements RemoteTransactionSource\n{\n #apiKey?: string;\n\n #includeTokenTransfers: boolean;\n\n constructor({\n apiKey,\n includeTokenTransfers,\n }: { apiKey?: string; includeTokenTransfers?: boolean } = {}) {\n this.#apiKey = apiKey;\n this.#includeTokenTransfers = includeTokenTransfers ?? true;\n }\n\n isSupportedNetwork(chainId: Hex): boolean {\n return Object.keys(ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId);\n }\n\n async fetchTransactions(\n request: RemoteTransactionSourceRequest,\n ): Promise<TransactionMeta[]> {\n const etherscanRequest: EtherscanTransactionRequest = {\n ...request,\n apiKey: this.#apiKey,\n chainId: request.currentChainId,\n };\n\n const transactionPromise = fetchEtherscanTransactions(etherscanRequest);\n\n const tokenTransactionPromise = this.#includeTokenTransfers\n ? fetchEtherscanTokenTransactions(etherscanRequest)\n : Promise.resolve({\n result: [] as EtherscanTokenTransactionMeta[],\n } as EtherscanTransactionResponse<EtherscanTokenTransactionMeta>);\n\n const [etherscanTransactions, etherscanTokenTransactions] =\n await Promise.all([transactionPromise, tokenTransactionPromise]);\n\n const transactions = etherscanTransactions.result.map((tx) =>\n this.#normalizeTransaction(tx, request.currentChainId),\n );\n\n const tokenTransactions = etherscanTokenTransactions.result.map((tx) =>\n this.#normalizeTokenTransaction(tx, request.currentChainId),\n );\n\n return [...transactions, ...tokenTransactions];\n }\n\n #normalizeTransaction(\n txMeta: EtherscanTransactionMeta,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, currentChainId);\n\n return {\n ...base,\n transaction: {\n ...base.transaction,\n data: txMeta.input,\n },\n ...(txMeta.isError === '0'\n ? { status: TransactionStatus.confirmed }\n : {\n error: new Error('Transaction failed'),\n status: TransactionStatus.failed,\n }),\n };\n }\n\n #normalizeTokenTransaction(\n txMeta: EtherscanTokenTransactionMeta,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, currentChainId);\n\n return {\n ...base,\n isTransfer: true,\n transferInformation: {\n contractAddress: txMeta.contractAddress,\n decimals: Number(txMeta.tokenDecimal),\n symbol: txMeta.tokenSymbol,\n },\n };\n }\n\n #normalizeTransactionBase(\n txMeta: EtherscanTransactionMetaBase,\n currentChainId: Hex,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n\n return {\n blockNumber: txMeta.blockNumber,\n chainId: currentChainId,\n id: random({ msecs: time }),\n status: TransactionStatus.confirmed,\n time,\n transaction: {\n chainId: currentChainId,\n from: txMeta.from,\n gas: BNToHex(new BN(txMeta.gas)),\n gasPrice: BNToHex(new BN(txMeta.gasPrice)),\n gasUsed: BNToHex(new BN(txMeta.gasUsed)),\n nonce: BNToHex(new BN(txMeta.nonce)),\n to: txMeta.to,\n value: BNToHex(new BN(txMeta.value)),\n },\n transactionHash: txMeta.hash,\n verifiedOnBlockchain: false,\n };\n }\n}\n"]}
@@ -5,8 +5,9 @@ import type { AddApprovalRequest } from '@metamask/approval-controller';
5
5
  import type { BaseConfig, BaseState, RestrictedControllerMessenger } from '@metamask/base-controller';
6
6
  import { BaseController } from '@metamask/base-controller';
7
7
  import type { BlockTracker, NetworkState, Provider } from '@metamask/network-controller';
8
+ import type { Hex } from '@metamask/utils';
8
9
  import { EventEmitter } from 'events';
9
- import type { Transaction, TransactionMeta, WalletDevice } from './types';
10
+ import type { Transaction, TransactionMeta, TransactionReceipt, WalletDevice } from './types';
10
11
  export declare const HARDFORK = Hardfork.London;
11
12
  /**
12
13
  * @type Result
@@ -172,15 +173,19 @@ export declare class TransactionController extends BaseController<TransactionCon
172
173
  *
173
174
  * @param transaction - The transaction object to add.
174
175
  * @param opts - Additional options to control how the transaction is added.
176
+ * @param opts.actionId - Unique ID to prevent duplicate requests.
175
177
  * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
176
178
  * @param opts.origin - The origin of the transaction request, such as a dApp hostname.
177
179
  * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
180
+ * @param opts.securityAlertResponse - Response from security validator.
178
181
  * @returns Object containing a promise resolving to the transaction hash if approved.
179
182
  */
180
- addTransaction(transaction: Transaction, { deviceConfirmedOn, origin, requireApproval, }?: {
183
+ addTransaction(transaction: Transaction, { actionId, deviceConfirmedOn, origin, requireApproval, securityAlertResponse, }?: {
184
+ actionId?: string;
181
185
  deviceConfirmedOn?: WalletDevice;
182
186
  origin?: string;
183
187
  requireApproval?: boolean | undefined;
188
+ securityAlertResponse?: Record<string, unknown>;
184
189
  }): Promise<Result>;
185
190
  startIncomingTransactionPolling(): void;
186
191
  stopIncomingTransactionPolling(): void;
@@ -195,15 +200,25 @@ export declare class TransactionController extends BaseController<TransactionCon
195
200
  *
196
201
  * @param transactionID - The ID of the transaction to cancel.
197
202
  * @param gasValues - The gas values to use for the cancellation transaction.
203
+ * @param options - The options for the cancellation transaction.
204
+ * @param options.estimatedBaseFee - The estimated base fee of the transaction.
198
205
  */
199
- stopTransaction(transactionID: string, gasValues?: GasPriceValue | FeeMarketEIP1559Values): Promise<void>;
206
+ stopTransaction(transactionID: string, gasValues?: GasPriceValue | FeeMarketEIP1559Values, { estimatedBaseFee }?: {
207
+ estimatedBaseFee?: string;
208
+ }): Promise<void>;
200
209
  /**
201
210
  * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.
202
211
  *
203
212
  * @param transactionID - The ID of the transaction to speed up.
204
- * @param gasValues - The gas values to use for the speed up transation.
213
+ * @param gasValues - The gas values to use for the speed up transaction.
214
+ * @param options - The options for the speed up transaction.
215
+ * @param options.actionId - Unique ID to prevent duplicate requests
216
+ * @param options.estimatedBaseFee - The estimated base fee of the transaction.
205
217
  */
206
- speedUpTransaction(transactionID: string, gasValues?: GasPriceValue | FeeMarketEIP1559Values): Promise<void>;
218
+ speedUpTransaction(transactionID: string, gasValues?: GasPriceValue | FeeMarketEIP1559Values, { actionId, estimatedBaseFee, }?: {
219
+ actionId?: string;
220
+ estimatedBaseFee?: string;
221
+ }): Promise<void>;
207
222
  /**
208
223
  * Estimates required gas for a given transaction.
209
224
  *
@@ -241,6 +256,14 @@ export declare class TransactionController extends BaseController<TransactionCon
241
256
  wipeTransactions(ignoreNetwork?: boolean, address?: string): void;
242
257
  startIncomingTransactionProcessing(): void;
243
258
  stopIncomingTransactionProcessing(): void;
259
+ /**
260
+ * Adds external provided transaction to state as confirmed transaction.
261
+ *
262
+ * @param transactionMeta - TransactionMeta to add transactions.
263
+ * @param transactionReceipt - TransactionReceipt of the external transaction.
264
+ * @param baseFeePerGas - Base fee per gas of the external transaction.
265
+ */
266
+ confirmExternalTransaction(transactionMeta: TransactionMeta, transactionReceipt: TransactionReceipt, baseFeePerGas: Hex): Promise<void>;
244
267
  private processApproval;
245
268
  /**
246
269
  * Approves a transaction and updates it's status in state. If this is not a
@@ -323,6 +346,33 @@ export declare class TransactionController extends BaseController<TransactionCon
323
346
  private onIncomingTransactions;
324
347
  private onUpdatedLastFetchedBlockNumbers;
325
348
  private generateDappSuggestedGasFees;
349
+ /**
350
+ * Validates and adds external provided transaction to state.
351
+ *
352
+ * @param transactionMeta - Nominated external transaction to be added to state.
353
+ */
354
+ private addExternalTransaction;
355
+ /**
356
+ * Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions
357
+ * in the transactions have the same nonce.
358
+ *
359
+ * @param transactionId - Used to identify original transaction.
360
+ */
361
+ private markNonceDuplicatesDropped;
362
+ /**
363
+ * Method to set transaction status to dropped.
364
+ *
365
+ * @param transactionMeta - TransactionMeta of transaction to be marked as dropped.
366
+ */
367
+ private setTransactionStatusDropped;
368
+ /**
369
+ * Get transaction with provided actionId.
370
+ *
371
+ * @param actionId - Unique ID to prevent duplicate requests
372
+ * @returns the filtered transaction
373
+ */
374
+ private getTransactionWithActionId;
375
+ private waitForTransactionFinished;
326
376
  }
327
377
  export default TransactionController;
328
378
  //# sourceMappingURL=TransactionController.d.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E,kBAAkB,EACtC,aAAa,EAAE,GAAG;YAyBN,eAAe;IAkF7B;;;;;;;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;IAmElD;;;;;;;;OAQG;YACW,4BAA4B;YAa5B,eAAe;IAsB7B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,oBAAoB;IAS5B;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,sBAAsB;IA0B9B,OAAO,CAAC,gCAAgC;IAaxC,OAAO,CAAC,4BAA4B;IAsCpC;;;;OAIG;YACW,sBAAsB;IA4BpC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IA8BlC;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAKnC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;YAMpB,0BAA0B;CASzC;AAED,eAAe,qBAAqB,CAAC"}
@@ -26,6 +26,7 @@ const events_1 = require("events");
26
26
  const nonce_tracker_1 = __importDefault(require("nonce-tracker"));
27
27
  const uuid_1 = require("uuid");
28
28
  const EtherscanRemoteTransactionSource_1 = require("./EtherscanRemoteTransactionSource");
29
+ const external_transactions_1 = require("./external-transactions");
29
30
  const IncomingTransactionHelper_1 = require("./IncomingTransactionHelper");
30
31
  const types_1 = require("./types");
31
32
  const utils_1 = require("./utils");
@@ -176,19 +177,23 @@ class TransactionController extends base_controller_1.BaseController {
176
177
  *
177
178
  * @param transaction - The transaction object to add.
178
179
  * @param opts - Additional options to control how the transaction is added.
180
+ * @param opts.actionId - Unique ID to prevent duplicate requests.
179
181
  * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
180
182
  * @param opts.origin - The origin of the transaction request, such as a dApp hostname.
181
183
  * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
184
+ * @param opts.securityAlertResponse - Response from security validator.
182
185
  * @returns Object containing a promise resolving to the transaction hash if approved.
183
186
  */
184
- addTransaction(transaction, { deviceConfirmedOn, origin, requireApproval, } = {}) {
187
+ addTransaction(transaction, { actionId, deviceConfirmedOn, origin, requireApproval, securityAlertResponse, } = {}) {
185
188
  return __awaiter(this, void 0, void 0, function* () {
186
189
  const chainId = this.getChainId();
187
190
  const { transactions } = this.state;
188
191
  transaction = (0, utils_1.normalizeTransaction)(transaction);
189
192
  (0, utils_1.validateTransaction)(transaction);
190
193
  const dappSuggestedGasFees = this.generateDappSuggestedGasFees(transaction, origin);
191
- const transactionMeta = {
194
+ const existingTransactionMeta = this.getTransactionWithActionId(actionId);
195
+ // If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.
196
+ const transactionMeta = existingTransactionMeta || {
192
197
  id: (0, uuid_1.v1)(),
193
198
  chainId,
194
199
  origin,
@@ -198,6 +203,9 @@ class TransactionController extends base_controller_1.BaseController {
198
203
  deviceConfirmedOn,
199
204
  verifiedOnBlockchain: false,
200
205
  dappSuggestedGasFees,
206
+ securityAlertResponse,
207
+ // Add actionId to txMeta to check if same actionId is seen again
208
+ actionId,
201
209
  };
202
210
  try {
203
211
  const { gas, estimateGasError } = yield this.estimateGas(transaction);
@@ -208,11 +216,17 @@ class TransactionController extends base_controller_1.BaseController {
208
216
  this.failTransaction(transactionMeta, error);
209
217
  return Promise.reject(error);
210
218
  }
211
- transactions.push(transactionMeta);
212
- this.update({ transactions: this.trimTransactionsForState(transactions) });
213
- this.hub.emit(`unapprovedTransaction`, transactionMeta);
219
+ // Checks if a transaction already exists with a given actionId
220
+ if (!existingTransactionMeta) {
221
+ transactions.push(transactionMeta);
222
+ this.update({
223
+ transactions: this.trimTransactionsForState(transactions),
224
+ });
225
+ this.hub.emit(`unapprovedTransaction`, transactionMeta);
226
+ }
214
227
  return {
215
228
  result: this.processApproval(transactionMeta, {
229
+ isExisting: Boolean(existingTransactionMeta),
216
230
  requireApproval,
217
231
  }),
218
232
  transactionMeta,
@@ -252,8 +266,10 @@ class TransactionController extends base_controller_1.BaseController {
252
266
  *
253
267
  * @param transactionID - The ID of the transaction to cancel.
254
268
  * @param gasValues - The gas values to use for the cancellation transaction.
269
+ * @param options - The options for the cancellation transaction.
270
+ * @param options.estimatedBaseFee - The estimated base fee of the transaction.
255
271
  */
256
- stopTransaction(transactionID, gasValues) {
272
+ stopTransaction(transactionID, gasValues, { estimatedBaseFee } = {}) {
257
273
  var _a, _b;
258
274
  return __awaiter(this, void 0, void 0, function* () {
259
275
  if (gasValues) {
@@ -309,6 +325,7 @@ class TransactionController extends base_controller_1.BaseController {
309
325
  const signedTx = yield this.sign(unsignedEthTx, transactionMeta.transaction.from);
310
326
  const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
311
327
  yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTransaction]);
328
+ transactionMeta.estimatedBaseFee = estimatedBaseFee;
312
329
  transactionMeta.status = types_1.TransactionStatus.cancelled;
313
330
  this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);
314
331
  });
@@ -317,11 +334,18 @@ class TransactionController extends base_controller_1.BaseController {
317
334
  * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.
318
335
  *
319
336
  * @param transactionID - The ID of the transaction to speed up.
320
- * @param gasValues - The gas values to use for the speed up transation.
337
+ * @param gasValues - The gas values to use for the speed up transaction.
338
+ * @param options - The options for the speed up transaction.
339
+ * @param options.actionId - Unique ID to prevent duplicate requests
340
+ * @param options.estimatedBaseFee - The estimated base fee of the transaction.
321
341
  */
322
- speedUpTransaction(transactionID, gasValues) {
342
+ speedUpTransaction(transactionID, gasValues, { actionId, estimatedBaseFee, } = {}) {
323
343
  var _a, _b;
324
344
  return __awaiter(this, void 0, void 0, function* () {
345
+ // If transaction is found for same action id, do not create a new speed up transaction.
346
+ if (this.getTransactionWithActionId(actionId)) {
347
+ return;
348
+ }
325
349
  if (gasValues) {
326
350
  (0, utils_1.validateGasValues)(gasValues);
327
351
  }
@@ -363,7 +387,8 @@ class TransactionController extends base_controller_1.BaseController {
363
387
  const transactionHash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [
364
388
  rawTransaction,
365
389
  ]);
366
- const baseTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { id: (0, uuid_1.v1)(), time: Date.now(), transactionHash });
390
+ const baseTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { estimatedBaseFee, id: (0, uuid_1.v1)(), time: Date.now(), transactionHash,
391
+ actionId });
367
392
  const newTransactionMeta = newMaxFeePerGas && newMaxPriorityFeePerGas
368
393
  ? Object.assign(Object.assign({}, baseTransactionMeta), { transaction: Object.assign(Object.assign({}, transactionMeta.transaction), { maxFeePerGas: newMaxFeePerGas, maxPriorityFeePerGas: newMaxPriorityFeePerGas }) }) : Object.assign(Object.assign({}, baseTransactionMeta), { transaction: Object.assign(Object.assign({}, transactionMeta.transaction), { gasPrice: newGasPrice }) });
369
394
  transactions.push(newTransactionMeta);
@@ -515,35 +540,70 @@ class TransactionController extends base_controller_1.BaseController {
515
540
  stopIncomingTransactionProcessing() {
516
541
  this.incomingTransactionHelper.stop();
517
542
  }
518
- processApproval(transactionMeta, { requireApproval, shouldShowRequest = true, }) {
543
+ /**
544
+ * Adds external provided transaction to state as confirmed transaction.
545
+ *
546
+ * @param transactionMeta - TransactionMeta to add transactions.
547
+ * @param transactionReceipt - TransactionReceipt of the external transaction.
548
+ * @param baseFeePerGas - Base fee per gas of the external transaction.
549
+ */
550
+ confirmExternalTransaction(transactionMeta, transactionReceipt, baseFeePerGas) {
519
551
  return __awaiter(this, void 0, void 0, function* () {
520
- const transactionId = transactionMeta.id;
521
- let resultCallbacks;
552
+ // Run validation and add external transaction to state.
553
+ this.addExternalTransaction(transactionMeta);
522
554
  try {
523
- if (requireApproval !== false) {
524
- const acceptResult = yield this.requestApproval(transactionMeta, {
525
- shouldShowRequest,
526
- });
527
- resultCallbacks = acceptResult.resultCallbacks;
528
- }
529
- const { meta, isCompleted } = this.isTransactionCompleted(transactionId);
530
- if (meta && !isCompleted) {
531
- yield this.approveTransaction(transactionId);
555
+ const transactionId = transactionMeta.id;
556
+ // Make sure status is confirmed and define gasUsed as in receipt.
557
+ transactionMeta.status = types_1.TransactionStatus.confirmed;
558
+ transactionMeta.txReceipt = transactionReceipt;
559
+ if (baseFeePerGas) {
560
+ transactionMeta.baseFeePerGas = baseFeePerGas;
532
561
  }
562
+ // Update same nonce local transactions as dropped and define replacedBy properties.
563
+ this.markNonceDuplicatesDropped(transactionId);
564
+ // Update external provided transaction with updated gas values and confirmed status.
565
+ this.updateTransaction(transactionMeta);
533
566
  }
534
567
  catch (error) {
535
- const { meta, isCompleted } = this.isTransactionCompleted(transactionId);
536
- if (meta && !isCompleted) {
537
- if (error.code === eth_rpc_errors_1.errorCodes.provider.userRejectedRequest) {
538
- this.cancelTransaction(transactionId);
539
- throw eth_rpc_errors_1.ethErrors.provider.userRejectedRequest('User rejected the transaction');
568
+ console.error(error);
569
+ }
570
+ });
571
+ }
572
+ processApproval(transactionMeta, { isExisting = false, requireApproval, shouldShowRequest = true, }) {
573
+ return __awaiter(this, void 0, void 0, function* () {
574
+ const transactionId = transactionMeta.id;
575
+ let resultCallbacks;
576
+ const { meta, isCompleted } = this.isTransactionCompleted(transactionId);
577
+ const finishedPromise = isCompleted
578
+ ? Promise.resolve(meta)
579
+ : this.waitForTransactionFinished(transactionId);
580
+ if (meta && !isExisting && !isCompleted) {
581
+ try {
582
+ if (requireApproval !== false) {
583
+ const acceptResult = yield this.requestApproval(transactionMeta, {
584
+ shouldShowRequest,
585
+ });
586
+ resultCallbacks = acceptResult.resultCallbacks;
540
587
  }
541
- else {
542
- this.failTransaction(meta, error);
588
+ const { isCompleted: isTxCompleted } = this.isTransactionCompleted(transactionId);
589
+ if (!isTxCompleted) {
590
+ yield this.approveTransaction(transactionId);
591
+ }
592
+ }
593
+ catch (error) {
594
+ const { isCompleted: isTxCompleted } = this.isTransactionCompleted(transactionId);
595
+ if (!isTxCompleted) {
596
+ if (error.code === eth_rpc_errors_1.errorCodes.provider.userRejectedRequest) {
597
+ this.cancelTransaction(transactionId);
598
+ throw eth_rpc_errors_1.ethErrors.provider.userRejectedRequest('User rejected the transaction');
599
+ }
600
+ else {
601
+ this.failTransaction(meta, error);
602
+ }
543
603
  }
544
604
  }
545
605
  }
546
- const finalMeta = this.getTransaction(transactionId);
606
+ const finalMeta = yield finishedPromise;
547
607
  switch (finalMeta === null || finalMeta === void 0 ? void 0 : finalMeta.status) {
548
608
  case types_1.TransactionStatus.failed:
549
609
  resultCallbacks === null || resultCallbacks === void 0 ? void 0 : resultCallbacks.error(finalMeta.error);
@@ -623,6 +683,7 @@ class TransactionController extends base_controller_1.BaseController {
623
683
  ]);
624
684
  transactionMeta.transactionHash = transactionHash;
625
685
  transactionMeta.status = types_1.TransactionStatus.submitted;
686
+ transactionMeta.submittedTime = new Date().getTime();
626
687
  this.updateTransaction(transactionMeta);
627
688
  this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);
628
689
  }
@@ -739,6 +800,7 @@ class TransactionController extends base_controller_1.BaseController {
739
800
  meta.transaction.gasUsed = txReceipt.gasUsed;
740
801
  meta.txReceipt = txReceipt;
741
802
  meta.baseFeePerGas = txBlock === null || txBlock === void 0 ? void 0 : txBlock.baseFeePerGas;
803
+ meta.blockTimestamp = txBlock === null || txBlock === void 0 ? void 0 : txBlock.timestamp;
742
804
  // According to the Web3 docs:
743
805
  // TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.
744
806
  if (Number(txReceipt.status) === 0) {
@@ -808,15 +870,15 @@ class TransactionController extends base_controller_1.BaseController {
808
870
  }, shouldShowRequest));
809
871
  });
810
872
  }
811
- getTransaction(transactionID) {
873
+ getTransaction(transactionId) {
812
874
  const { transactions } = this.state;
813
- return transactions.find(({ id }) => id === transactionID);
875
+ return transactions.find(({ id }) => id === transactionId);
814
876
  }
815
877
  getApprovalId(txMeta) {
816
878
  return String(txMeta.id);
817
879
  }
818
- isTransactionCompleted(transactionid) {
819
- const transaction = this.getTransaction(transactionid);
880
+ isTransactionCompleted(transactionId) {
881
+ const transaction = this.getTransaction(transactionId);
820
882
  if (!transaction) {
821
883
  return { meta: undefined, isCompleted: false };
822
884
  }
@@ -825,7 +887,7 @@ class TransactionController extends base_controller_1.BaseController {
825
887
  }
826
888
  getChainId() {
827
889
  const { providerConfig } = this.getNetworkState();
828
- return providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.chainId;
890
+ return providerConfig.chainId;
829
891
  }
830
892
  prepareUnsignedEthTx(txParams) {
831
893
  return tx_1.TransactionFactory.fromTxData(txParams, {
@@ -852,7 +914,6 @@ class TransactionController extends base_controller_1.BaseController {
852
914
  const customChainParams = {
853
915
  name,
854
916
  chainId: parseInt(chainId, 16),
855
- // networkId: networkId === null ? NaN : parseInt(networkId, undefined),
856
917
  defaultHardfork: exports.HARDFORK,
857
918
  };
858
919
  return common_1.Common.custom(customChainParams);
@@ -899,6 +960,86 @@ class TransactionController extends base_controller_1.BaseController {
899
960
  }
900
961
  return dappSuggestedGasFees;
901
962
  }
963
+ /**
964
+ * Validates and adds external provided transaction to state.
965
+ *
966
+ * @param transactionMeta - Nominated external transaction to be added to state.
967
+ */
968
+ addExternalTransaction(transactionMeta) {
969
+ var _a;
970
+ return __awaiter(this, void 0, void 0, function* () {
971
+ const chainId = this.getChainId();
972
+ const { transactions } = this.state;
973
+ const fromAddress = (_a = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.transaction) === null || _a === void 0 ? void 0 : _a.from;
974
+ const sameFromAndNetworkTransactions = transactions.filter((transaction) => transaction.transaction.from === fromAddress &&
975
+ transaction.chainId === chainId);
976
+ const confirmedTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status === types_1.TransactionStatus.confirmed);
977
+ const pendingTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status === types_1.TransactionStatus.submitted);
978
+ (0, external_transactions_1.validateConfirmedExternalTransaction)(transactionMeta, confirmedTxs, pendingTxs);
979
+ const updatedTransactions = [...transactions, transactionMeta];
980
+ this.update({
981
+ transactions: this.trimTransactionsForState(updatedTransactions),
982
+ });
983
+ });
984
+ }
985
+ /**
986
+ * Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions
987
+ * in the transactions have the same nonce.
988
+ *
989
+ * @param transactionId - Used to identify original transaction.
990
+ */
991
+ markNonceDuplicatesDropped(transactionId) {
992
+ var _a, _b;
993
+ const chainId = this.getChainId();
994
+ const transactionMeta = this.getTransaction(transactionId);
995
+ const nonce = (_a = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.transaction) === null || _a === void 0 ? void 0 : _a.nonce;
996
+ const from = (_b = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.transaction) === null || _b === void 0 ? void 0 : _b.from;
997
+ const sameNonceTxs = this.state.transactions.filter((transaction) => transaction.transaction.from === from &&
998
+ transaction.transaction.nonce === nonce &&
999
+ transaction.chainId === chainId);
1000
+ if (!sameNonceTxs.length) {
1001
+ return;
1002
+ }
1003
+ // Mark all same nonce transactions as dropped and give it a replacedBy hash
1004
+ for (const transaction of sameNonceTxs) {
1005
+ if (transaction.id === transactionId) {
1006
+ continue;
1007
+ }
1008
+ transaction.replacedBy = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.hash;
1009
+ transaction.replacedById = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.id;
1010
+ // Drop any transaction that wasn't previously failed (off chain failure)
1011
+ if (transaction.status !== types_1.TransactionStatus.failed) {
1012
+ this.setTransactionStatusDropped(transaction);
1013
+ }
1014
+ }
1015
+ }
1016
+ /**
1017
+ * Method to set transaction status to dropped.
1018
+ *
1019
+ * @param transactionMeta - TransactionMeta of transaction to be marked as dropped.
1020
+ */
1021
+ setTransactionStatusDropped(transactionMeta) {
1022
+ transactionMeta.status = types_1.TransactionStatus.dropped;
1023
+ this.updateTransaction(transactionMeta);
1024
+ }
1025
+ /**
1026
+ * Get transaction with provided actionId.
1027
+ *
1028
+ * @param actionId - Unique ID to prevent duplicate requests
1029
+ * @returns the filtered transaction
1030
+ */
1031
+ getTransactionWithActionId(actionId) {
1032
+ return this.state.transactions.find((transaction) => actionId && transaction.actionId === actionId);
1033
+ }
1034
+ waitForTransactionFinished(transactionId) {
1035
+ return __awaiter(this, void 0, void 0, function* () {
1036
+ return new Promise((resolve) => {
1037
+ this.hub.once(`${transactionId}:finished`, (txMeta) => {
1038
+ resolve(txMeta);
1039
+ });
1040
+ });
1041
+ });
1042
+ }
902
1043
  }
903
1044
  exports.TransactionController = TransactionController;
904
1045
  exports.default = TransactionController;