@metamask/smart-transactions-controller 18.1.0 → 19.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -1
- package/dist/{SmartTransactionsController.js → SmartTransactionsController.cjs} +18 -24
- package/dist/SmartTransactionsController.cjs.map +1 -0
- package/dist/{SmartTransactionsController.d.ts → SmartTransactionsController.d.cts} +17 -20
- package/dist/SmartTransactionsController.d.cts.map +1 -0
- package/dist/SmartTransactionsController.d.mts +149 -0
- package/dist/SmartTransactionsController.d.mts.map +1 -0
- package/dist/SmartTransactionsController.mjs +696 -0
- package/dist/SmartTransactionsController.mjs.map +1 -0
- package/dist/{constants.js → constants.cjs} +1 -1
- package/dist/constants.cjs.map +1 -0
- package/dist/{constants.d.ts → constants.d.cts} +1 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +23 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +30 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/{types.js → types.cjs} +1 -1
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +2 -8
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +118 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +51 -0
- package/dist/types.mjs.map +1 -0
- package/dist/{utils.js → utils.cjs} +3 -3
- package/dist/utils.cjs.map +1 -0
- package/dist/{utils.d.ts → utils.d.cts} +6 -5
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +90 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +265 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +37 -15
- package/dist/SmartTransactionsController.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [19.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add missing exports for types ([#537](https://github.com/MetaMask/smart-transactions-controller/pull/537))
|
|
15
|
+
- `Fee`
|
|
16
|
+
- `Fees`
|
|
17
|
+
- `IndividualTxFees`
|
|
18
|
+
- `FeatureFlags`
|
|
19
|
+
- `SmartTransactionMinedTx`
|
|
20
|
+
- `SmartTransaction`
|
|
21
|
+
- `SmartTransactionCancellationReason`
|
|
22
|
+
- `SmartTransactionStatuses`
|
|
23
|
+
- `ClientId`
|
|
24
|
+
|
|
25
|
+
## [19.0.0]
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- This package can now be used in ESM environments as well as CommonJS ([#469](https://github.com/MetaMask/smart-transactions-controller/pull/469))
|
|
30
|
+
- Add two new controller state metadata properties: `includeInStateLogs` and `usedInUi` ([#531](https://github.com/MetaMask/smart-transactions-controller/pull/531))
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- **BREAKING:** Disallow subpath exports ([#469](https://github.com/MetaMask/smart-transactions-controller/pull/469))
|
|
35
|
+
- **BREAKING:** Upgrade peer dependency `@metamask/transaction-controller` from `^58.0.0` to `^60.4.0` ([#532](https://github.com/MetaMask/smart-transactions-controller/pull/532), [#534](https://github.com/MetaMask/smart-transactions-controller/pull/534))
|
|
36
|
+
- **BREAKING:** Remove `getNonceLock`, `confirmExternalTransaction`, `getTransactions`, and `updateTransaction` constructor option in favor of messenger actions ([#534](https://github.com/MetaMask/smart-transactions-controller/pull/534))
|
|
37
|
+
- The messenger is now used to access TransactionController; you must add these actions to the SmartTransactionController messenger allowlist:
|
|
38
|
+
- `TransactionController:getNonceLock`
|
|
39
|
+
- `TransactionController:confirmExternalTransaction`
|
|
40
|
+
- `TransactionController:getTransactions`
|
|
41
|
+
- `TransactionController:updateTransaction`
|
|
42
|
+
- Upgrade `@metamask/base-controller` from `^7.0.1` to `^8.3.0` ([#529](https://github.com/MetaMask/smart-transactions-controller/pull/529))
|
|
43
|
+
- Upgrade `@metamask/polling-controller` from `^12.0.0` to `^14.0.0` ([#529](https://github.com/MetaMask/smart-transactions-controller/pull/529))
|
|
44
|
+
|
|
45
|
+
### Removed
|
|
46
|
+
|
|
47
|
+
- **BREAKING:** Remove default export ([#535](https://github.com/MetaMask/smart-transactions-controller/pull/535))
|
|
48
|
+
- Use `import { SmartTransactionsController } from '@metamask/smart-transactions-controller'` instead.
|
|
49
|
+
|
|
10
50
|
## [18.1.0]
|
|
11
51
|
|
|
12
52
|
### Added
|
|
@@ -28,6 +68,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
28
68
|
### Changed
|
|
29
69
|
|
|
30
70
|
- **BREAKING:** Bump peer dependency on `@metamask/network-controller` to `^24.0.0` ([#519](https://github.com/MetaMask/smart-transactions-controller/pull/519))
|
|
71
|
+
- **BREAKING:** Bump dependency and peer dependency on `@metamask/transaction-controller` to `^58.0.0` ([#520](https://github.com/MetaMask/smart-transactions-controller/pull/520))
|
|
72
|
+
- The `confirmExternalTransaction` constructor option now expects to match `TransactionController` from this version
|
|
73
|
+
- The `getNonceLock` constructor option now expects to match `TransactionController` from this version
|
|
74
|
+
- The `getTransactions` constructor option now returns an object that matches `TransactionMeta` from this version
|
|
75
|
+
- The `updateTransaction` constructor option now expects an object that matches `TransactionMeta` from this version
|
|
76
|
+
- The `transactionMeta` option of the `submitSignedTransactions` method now expects an object that matches `TransactionMeta` from this version
|
|
77
|
+
- The `txParams` option of the `submitSignedTransactions` method now expects an object that matches `TransactionParams` from this version
|
|
31
78
|
|
|
32
79
|
## [16.5.0]
|
|
33
80
|
|
|
@@ -583,7 +630,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
583
630
|
- Add initial SmartTransactionsController ([#1](https://github.com/MetaMask/smart-transactions-controller/pull/1))
|
|
584
631
|
- Initial commit
|
|
585
632
|
|
|
586
|
-
[Unreleased]: https://github.com/MetaMask/smart-transactions-controller/compare/
|
|
633
|
+
[Unreleased]: https://github.com/MetaMask/smart-transactions-controller/compare/v19.1.0...HEAD
|
|
634
|
+
[19.1.0]: https://github.com/MetaMask/smart-transactions-controller/compare/v19.0.0...v19.1.0
|
|
635
|
+
[19.0.0]: https://github.com/MetaMask/smart-transactions-controller/compare/v18.1.0...v19.0.0
|
|
587
636
|
[18.1.0]: https://github.com/MetaMask/smart-transactions-controller/compare/v18.0.0...v18.1.0
|
|
588
637
|
[18.0.0]: https://github.com/MetaMask/smart-transactions-controller/compare/v17.0.0...v18.0.0
|
|
589
638
|
[17.0.0]: https://github.com/MetaMask/smart-transactions-controller/compare/v16.5.0...v17.0.0
|
|
@@ -13,19 +13,19 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _SmartTransactionsController_instances, _SmartTransactionsController_interval, _SmartTransactionsController_clientId, _SmartTransactionsController_chainId, _SmartTransactionsController_supportedChainIds,
|
|
16
|
+
var _SmartTransactionsController_instances, _SmartTransactionsController_interval, _SmartTransactionsController_clientId, _SmartTransactionsController_chainId, _SmartTransactionsController_supportedChainIds, _SmartTransactionsController_ethQuery, _SmartTransactionsController_trackMetaMetricsEvent, _SmartTransactionsController_getMetaMetricsProps, _SmartTransactionsController_getFeatureFlags, _SmartTransactionsController_trace, _SmartTransactionsController_fetch, _SmartTransactionsController_updateSmartTransaction, _SmartTransactionsController_addMetaMetricsPropsToNewSmartTransaction, _SmartTransactionsController_createOrUpdateSmartTransaction, _SmartTransactionsController_doesTransactionNeedConfirmation, _SmartTransactionsController_confirmSmartTransaction, _SmartTransactionsController_addNonceToTransaction, _SmartTransactionsController_getChainId, _SmartTransactionsController_getChainIds, _SmartTransactionsController_getNetworkClientId, _SmartTransactionsController_getEthQuery, _SmartTransactionsController_getCurrentSmartTransactions, _SmartTransactionsController_wipeSmartTransactionsPerChainId;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getDefaultSmartTransactionsControllerState = exports.DEFAULT_INTERVAL = void 0;
|
|
18
|
+
exports.SmartTransactionsController = exports.getDefaultSmartTransactionsControllerState = exports.DEFAULT_INTERVAL = void 0;
|
|
19
19
|
const bytes_1 = require("@ethersproject/bytes");
|
|
20
20
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
21
21
|
const eth_query_1 = __importDefault(require("@metamask/eth-query"));
|
|
22
22
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
23
23
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
24
24
|
const bignumber_js_1 = require("bignumber.js");
|
|
25
|
-
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
26
|
-
const constants_1 = require("./constants");
|
|
27
|
-
const types_1 = require("./types");
|
|
28
|
-
const utils_1 = require("./utils");
|
|
25
|
+
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep.js"));
|
|
26
|
+
const constants_1 = require("./constants.cjs");
|
|
27
|
+
const types_1 = require("./types.cjs");
|
|
28
|
+
const utils_1 = require("./utils.cjs");
|
|
29
29
|
const SECOND = 1000;
|
|
30
30
|
exports.DEFAULT_INTERVAL = SECOND * 5;
|
|
31
31
|
const ETH_QUERY_ERROR_MSG = '`ethQuery` is not defined on SmartTransactionsController';
|
|
@@ -35,8 +35,10 @@ const ETH_QUERY_ERROR_MSG = '`ethQuery` is not defined on SmartTransactionsContr
|
|
|
35
35
|
const controllerName = 'SmartTransactionsController';
|
|
36
36
|
const controllerMetadata = {
|
|
37
37
|
smartTransactionsState: {
|
|
38
|
+
includeInStateLogs: true,
|
|
38
39
|
persist: false,
|
|
39
40
|
anonymous: true,
|
|
41
|
+
usedInUi: true,
|
|
40
42
|
},
|
|
41
43
|
};
|
|
42
44
|
/**
|
|
@@ -74,7 +76,7 @@ function getDefaultSmartTransactionsControllerState() {
|
|
|
74
76
|
}
|
|
75
77
|
exports.getDefaultSmartTransactionsControllerState = getDefaultSmartTransactionsControllerState;
|
|
76
78
|
class SmartTransactionsController extends (0, polling_controller_1.StaticIntervalPollingController)() {
|
|
77
|
-
constructor({ interval = exports.DEFAULT_INTERVAL, clientId, chainId: InitialChainId = controller_utils_1.ChainId.mainnet, supportedChainIds = [controller_utils_1.ChainId.mainnet, controller_utils_1.ChainId.sepolia],
|
|
79
|
+
constructor({ interval = exports.DEFAULT_INTERVAL, clientId, chainId: InitialChainId = controller_utils_1.ChainId.mainnet, supportedChainIds = [controller_utils_1.ChainId.mainnet, controller_utils_1.ChainId.sepolia], trackMetaMetricsEvent, state = {}, messenger, getMetaMetricsProps, getFeatureFlags, trace, }) {
|
|
78
80
|
super({
|
|
79
81
|
name: controllerName,
|
|
80
82
|
metadata: controllerMetadata,
|
|
@@ -86,28 +88,20 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
|
|
|
86
88
|
_SmartTransactionsController_clientId.set(this, void 0);
|
|
87
89
|
_SmartTransactionsController_chainId.set(this, void 0);
|
|
88
90
|
_SmartTransactionsController_supportedChainIds.set(this, void 0);
|
|
89
|
-
_SmartTransactionsController_getNonceLock.set(this, void 0);
|
|
90
91
|
_SmartTransactionsController_ethQuery.set(this, void 0);
|
|
91
|
-
_SmartTransactionsController_confirmExternalTransaction.set(this, void 0);
|
|
92
|
-
_SmartTransactionsController_getRegularTransactions.set(this, void 0);
|
|
93
92
|
_SmartTransactionsController_trackMetaMetricsEvent.set(this, void 0);
|
|
94
93
|
_SmartTransactionsController_getMetaMetricsProps.set(this, void 0);
|
|
95
94
|
_SmartTransactionsController_getFeatureFlags.set(this, void 0);
|
|
96
|
-
_SmartTransactionsController_updateTransaction.set(this, void 0);
|
|
97
95
|
_SmartTransactionsController_trace.set(this, void 0);
|
|
98
96
|
__classPrivateFieldSet(this, _SmartTransactionsController_interval, interval, "f");
|
|
99
97
|
__classPrivateFieldSet(this, _SmartTransactionsController_clientId, clientId, "f");
|
|
100
98
|
__classPrivateFieldSet(this, _SmartTransactionsController_chainId, InitialChainId, "f");
|
|
101
99
|
__classPrivateFieldSet(this, _SmartTransactionsController_supportedChainIds, supportedChainIds, "f");
|
|
102
100
|
this.setIntervalLength(interval);
|
|
103
|
-
__classPrivateFieldSet(this, _SmartTransactionsController_getNonceLock, getNonceLock, "f");
|
|
104
101
|
__classPrivateFieldSet(this, _SmartTransactionsController_ethQuery, undefined, "f");
|
|
105
|
-
__classPrivateFieldSet(this, _SmartTransactionsController_confirmExternalTransaction, confirmExternalTransaction, "f");
|
|
106
|
-
__classPrivateFieldSet(this, _SmartTransactionsController_getRegularTransactions, getTransactions, "f");
|
|
107
102
|
__classPrivateFieldSet(this, _SmartTransactionsController_trackMetaMetricsEvent, trackMetaMetricsEvent, "f");
|
|
108
103
|
__classPrivateFieldSet(this, _SmartTransactionsController_getMetaMetricsProps, getMetaMetricsProps, "f");
|
|
109
104
|
__classPrivateFieldSet(this, _SmartTransactionsController_getFeatureFlags, getFeatureFlags, "f");
|
|
110
|
-
__classPrivateFieldSet(this, _SmartTransactionsController_updateTransaction, updateTransaction, "f");
|
|
111
105
|
__classPrivateFieldSet(this, _SmartTransactionsController_trace, trace !== null && trace !== void 0 ? trace : ((_request, fn) => fn === null || fn === void 0 ? void 0 : fn()), "f");
|
|
112
106
|
this.initializeSmartTransactionsForChainId();
|
|
113
107
|
this.messagingSystem.subscribe('NetworkController:stateChange', ({ selectedNetworkClientId }) => {
|
|
@@ -371,7 +365,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
|
|
|
371
365
|
// This should only happen for Swaps. Non-swaps transactions should already have a nonce
|
|
372
366
|
if (requiresNonce) {
|
|
373
367
|
try {
|
|
374
|
-
nonceLock = await
|
|
368
|
+
nonceLock = await this.messagingSystem.call('TransactionController:getNonceLock', txParams.from, selectedNetworkClientId);
|
|
375
369
|
nonce = (0, bytes_1.hexlify)(nonceLock.nextNonce);
|
|
376
370
|
nonceDetails = nonceLock.nonceDetails;
|
|
377
371
|
(_a = txParams.nonce) !== null && _a !== void 0 ? _a : (txParams.nonce = nonce);
|
|
@@ -485,8 +479,8 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
|
|
|
485
479
|
}
|
|
486
480
|
}
|
|
487
481
|
}
|
|
488
|
-
exports.
|
|
489
|
-
_SmartTransactionsController_interval = new WeakMap(), _SmartTransactionsController_clientId = new WeakMap(), _SmartTransactionsController_chainId = new WeakMap(), _SmartTransactionsController_supportedChainIds = new WeakMap(),
|
|
482
|
+
exports.SmartTransactionsController = SmartTransactionsController;
|
|
483
|
+
_SmartTransactionsController_interval = new WeakMap(), _SmartTransactionsController_clientId = new WeakMap(), _SmartTransactionsController_chainId = new WeakMap(), _SmartTransactionsController_supportedChainIds = new WeakMap(), _SmartTransactionsController_ethQuery = new WeakMap(), _SmartTransactionsController_trackMetaMetricsEvent = new WeakMap(), _SmartTransactionsController_getMetaMetricsProps = new WeakMap(), _SmartTransactionsController_getFeatureFlags = new WeakMap(), _SmartTransactionsController_trace = new WeakMap(), _SmartTransactionsController_instances = new WeakSet(), _SmartTransactionsController_fetch =
|
|
490
484
|
/* istanbul ignore next */
|
|
491
485
|
async function _SmartTransactionsController_fetch(request, options) {
|
|
492
486
|
const fetchOptions = Object.assign(Object.assign({}, options), { headers: Object.assign({ 'Content-Type': 'application/json' }, (__classPrivateFieldGet(this, _SmartTransactionsController_clientId, "f") && { 'X-Client-Id': __classPrivateFieldGet(this, _SmartTransactionsController_clientId, "f") })) });
|
|
@@ -566,8 +560,8 @@ async function _SmartTransactionsController_fetch(request, options) {
|
|
|
566
560
|
})) {
|
|
567
561
|
(0, utils_1.markRegularTransactionAsFailed)({
|
|
568
562
|
smartTransaction: nextSmartTransaction,
|
|
569
|
-
getRegularTransactions:
|
|
570
|
-
updateTransaction:
|
|
563
|
+
getRegularTransactions: () => this.messagingSystem.call('TransactionController:getTransactions'),
|
|
564
|
+
updateTransaction: (transactionMeta, note) => this.messagingSystem.call('TransactionController:updateTransaction', transactionMeta, note),
|
|
571
565
|
});
|
|
572
566
|
}
|
|
573
567
|
if ((smartTransaction.status === types_1.SmartTransactionStatuses.SUCCESS ||
|
|
@@ -587,7 +581,7 @@ async function _SmartTransactionsController_fetch(request, options) {
|
|
|
587
581
|
if (!txHash) {
|
|
588
582
|
return true;
|
|
589
583
|
}
|
|
590
|
-
const transactions =
|
|
584
|
+
const transactions = this.messagingSystem.call('TransactionController:getTransactions');
|
|
591
585
|
const foundTransaction = transactions === null || transactions === void 0 ? void 0 : transactions.find((tx) => {
|
|
592
586
|
var _a;
|
|
593
587
|
return ((_a = tx.hash) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === txHash.toLowerCase();
|
|
@@ -626,7 +620,7 @@ async function _SmartTransactionsController_fetch(request, options) {
|
|
|
626
620
|
const txMeta = entry.length > 0
|
|
627
621
|
? Object.assign(Object.assign({}, originalTxMeta), { history: originalTxMeta.history.concat(entry) }) : originalTxMeta;
|
|
628
622
|
if (__classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_doesTransactionNeedConfirmation).call(this, txHash)) {
|
|
629
|
-
|
|
623
|
+
this.messagingSystem.call('TransactionController:confirmExternalTransaction',
|
|
630
624
|
// TODO: Replace 'as' assertion with correct typing for `txMeta`
|
|
631
625
|
txMeta, transactionReceipt,
|
|
632
626
|
// TODO: Replace 'as' assertion with correct typing for `baseFeePerGas`
|
|
@@ -654,7 +648,7 @@ async function _SmartTransactionsController_fetch(request, options) {
|
|
|
654
648
|
this.messagingSystem.publish(`SmartTransactionsController:smartTransactionConfirmationDone`, smartTransaction);
|
|
655
649
|
}
|
|
656
650
|
}, _SmartTransactionsController_addNonceToTransaction = async function _SmartTransactionsController_addNonceToTransaction(transaction, networkClientId) {
|
|
657
|
-
const nonceLock = await
|
|
651
|
+
const nonceLock = await this.messagingSystem.call('TransactionController:getNonceLock', transaction.from, networkClientId);
|
|
658
652
|
const nonce = nonceLock.nextNonce;
|
|
659
653
|
nonceLock.releaseLock();
|
|
660
654
|
return Object.assign(Object.assign({}, transaction), { nonce: `0x${nonce.toString(16)}` });
|
|
@@ -699,4 +693,4 @@ async function _SmartTransactionsController_fetch(request, options) {
|
|
|
699
693
|
newSmartTransactionsForSelectedChain;
|
|
700
694
|
});
|
|
701
695
|
};
|
|
702
|
-
//# sourceMappingURL=SmartTransactionsController.
|
|
696
|
+
//# sourceMappingURL=SmartTransactionsController.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartTransactionsController.cjs","sourceRoot":"","sources":["../src/SmartTransactionsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gDAA+C;AAO/C,iEAMoC;AACpC,oEAA2C;AAO3C,qEAA+E;AAS/E,6EAAqE;AACrE,+CAAyC;AACzC,oEAAyC;AAEzC,+CAIqB;AAcrB,uCAA4D;AAC5D,uCAeiB;AAEjB,MAAM,MAAM,GAAG,IAAI,CAAC;AACP,QAAA,gBAAgB,GAAG,MAAM,GAAG,CAAC,CAAC;AAC3C,MAAM,mBAAmB,GACvB,0DAA0D,CAAC;AAE7D;;GAEG;AACH,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD,MAAM,kBAAkB,GAAoD;IAC1E,sBAAsB,EAAE;QACtB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,IAAI;QACf,QAAQ,EAA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,EAAE,iBAAiB,EAAE,GAC9C,GAAG,IAAI,CAAC,KAAK,CAAC;IACf,MAAM,iCAAiC,GACrC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,OAAO,CAAC,CAAC;IAC/B,IACE,CAAC,iCAAiC;QAClC,iCAAiC,CAAC,MAAM,KAAK,CAAC,EAC9C;QACA,OAAO;KACR;IACD,MAAM,oCAAoC,GACxC,iCAAiC,CAAC,MAAM,CACtC,CAAC,gBAAkC,EAAE,EAAE,WACrC,OAAA,CAAA,MAAA,gBAAgB,CAAC,QAAQ,0CAAE,IAAI,MAAK,gBAAgB,CAAA,EAAA,CACvD,CAAC;IACJ,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACpB,KAAK,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,OAAO,CAAC;YACrD,oCAAoC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { hexlify } from '@ethersproject/bytes';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport {\n query,\n safelyExecute,\n ChainId,\n isSafeDynamicKey,\n type TraceCallback,\n} from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport type {\n NetworkClientId,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type {\n TransactionControllerConfirmExternalTransactionAction,\n TransactionControllerGetNonceLockAction,\n TransactionControllerGetTransactionsAction,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport { TransactionStatus } from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\nimport cloneDeep from 'lodash/cloneDeep';\n\nimport {\n MetaMetricsEventCategory,\n MetaMetricsEventName,\n SmartTransactionsTraceName,\n} from './constants';\nimport type {\n Fees,\n Hex,\n IndividualTxFees,\n SignedCanceledTransaction,\n SignedTransaction,\n SmartTransaction,\n SmartTransactionsStatus,\n UnsignedTransaction,\n MetaMetricsProps,\n FeatureFlags,\n ClientId,\n} from './types';\nimport { APIType, SmartTransactionStatuses } from './types';\nimport {\n calculateStatus,\n generateHistoryEntry,\n getAPIRequestURL,\n handleFetch,\n incrementNonceInHex,\n isSmartTransactionCancellable,\n isSmartTransactionPending,\n replayHistory,\n snapshotFromTxMeta,\n getTxHash,\n getSmartTransactionMetricsProperties,\n getSmartTransactionMetricsSensitiveProperties,\n shouldMarkRegularTransactionAsFailed,\n markRegularTransactionAsFailed,\n} from './utils';\n\nconst SECOND = 1000;\nexport const DEFAULT_INTERVAL = SECOND * 5;\nconst ETH_QUERY_ERROR_MSG =\n '`ethQuery` is not defined on SmartTransactionsController';\n\n/**\n * The name of the {@link SmartTransactionsController}\n */\nconst controllerName = 'SmartTransactionsController';\n\nconst controllerMetadata: StateMetadata<SmartTransactionsControllerState> = {\n smartTransactionsState: {\n includeInStateLogs: true,\n persist: false,\n anonymous: true,\n usedInUi: true,\n },\n};\n\ntype FeeEstimates = {\n approvalTxFees: IndividualTxFees | null;\n tradeTxFees: IndividualTxFees | null;\n};\n\nexport type SmartTransactionsControllerState = {\n smartTransactionsState: {\n smartTransactions: Record<Hex, SmartTransaction[]>;\n userOptIn: boolean | null;\n userOptInV2: boolean | null;\n liveness: boolean | null;\n fees: FeeEstimates;\n feesByChainId: Record<Hex, FeeEstimates>;\n livenessByChainId: Record<Hex, boolean>;\n };\n};\n\n/**\n * Get the default {@link SmartTransactionsController} state.\n *\n * @returns The default {@link SmartTransactionsController} state.\n */\nexport function getDefaultSmartTransactionsControllerState(): SmartTransactionsControllerState {\n return {\n smartTransactionsState: {\n smartTransactions: {},\n userOptIn: null,\n userOptInV2: null,\n fees: {\n approvalTxFees: null,\n tradeTxFees: null,\n },\n liveness: true,\n livenessByChainId: {\n [ChainId.mainnet]: true,\n [ChainId.sepolia]: true,\n },\n feesByChainId: {\n [ChainId.mainnet]: {\n approvalTxFees: null,\n tradeTxFees: null,\n },\n [ChainId.sepolia]: {\n approvalTxFees: null,\n tradeTxFees: null,\n },\n },\n },\n };\n}\n\nexport type SmartTransactionsControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n SmartTransactionsControllerState\n >;\n\n/**\n * The actions that can be performed using the {@link SmartTransactionsController}.\n */\nexport type SmartTransactionsControllerActions =\n SmartTransactionsControllerGetStateAction;\n\ntype AllowedActions =\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerGetStateAction\n | TransactionControllerGetNonceLockAction\n | TransactionControllerConfirmExternalTransactionAction\n | TransactionControllerGetTransactionsAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type SmartTransactionsControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n SmartTransactionsControllerState\n >;\n\nexport type SmartTransactionsControllerSmartTransactionEvent = {\n type: 'SmartTransactionsController:smartTransaction';\n payload: [SmartTransaction];\n};\n\nexport type SmartTransactionsControllerSmartTransactionConfirmationDoneEvent = {\n type: 'SmartTransactionsController:smartTransactionConfirmationDone';\n payload: [SmartTransaction];\n};\n\n/**\n * The events that {@link SmartTransactionsController} can emit.\n */\nexport type SmartTransactionsControllerEvents =\n | SmartTransactionsControllerStateChangeEvent\n | SmartTransactionsControllerSmartTransactionEvent\n | SmartTransactionsControllerSmartTransactionConfirmationDoneEvent;\n\ntype AllowedEvents = NetworkControllerStateChangeEvent;\n\n/**\n * The messenger of the {@link SmartTransactionsController}.\n */\nexport type SmartTransactionsControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n SmartTransactionsControllerActions | AllowedActions,\n SmartTransactionsControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\ntype SmartTransactionsControllerOptions = {\n interval?: number;\n clientId: ClientId;\n chainId?: Hex;\n supportedChainIds?: Hex[];\n trackMetaMetricsEvent: (\n event: {\n event: MetaMetricsEventName;\n category: MetaMetricsEventCategory;\n properties?: ReturnType<typeof getSmartTransactionMetricsProperties>;\n sensitiveProperties?: ReturnType<\n typeof getSmartTransactionMetricsSensitiveProperties\n >;\n },\n options?: { metaMetricsId?: string } & Record<string, boolean>,\n ) => void;\n state?: Partial<SmartTransactionsControllerState>;\n messenger: SmartTransactionsControllerMessenger;\n getMetaMetricsProps: () => Promise<MetaMetricsProps>;\n getFeatureFlags: () => FeatureFlags;\n trace?: TraceCallback;\n};\n\nexport type SmartTransactionsControllerPollingInput = {\n chainIds: Hex[];\n};\n\nexport class SmartTransactionsController extends StaticIntervalPollingController<SmartTransactionsControllerPollingInput>()<\n typeof controllerName,\n SmartTransactionsControllerState,\n SmartTransactionsControllerMessenger\n> {\n #interval: number;\n\n #clientId: ClientId;\n\n #chainId: Hex;\n\n #supportedChainIds: Hex[];\n\n timeoutHandle?: NodeJS.Timeout;\n\n #ethQuery: EthQuery | undefined;\n\n readonly #trackMetaMetricsEvent: SmartTransactionsControllerOptions['trackMetaMetricsEvent'];\n\n readonly #getMetaMetricsProps: () => Promise<MetaMetricsProps>;\n\n #getFeatureFlags: SmartTransactionsControllerOptions['getFeatureFlags'];\n\n #trace: TraceCallback;\n\n /* istanbul ignore next */\n async #fetch(request: string, options?: RequestInit) {\n const fetchOptions = {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n ...(this.#clientId && { 'X-Client-Id': this.#clientId }),\n },\n };\n\n return handleFetch(request, fetchOptions);\n }\n\n constructor({\n interval = DEFAULT_INTERVAL,\n clientId,\n chainId: InitialChainId = ChainId.mainnet,\n supportedChainIds = [ChainId.mainnet, ChainId.sepolia],\n trackMetaMetricsEvent,\n state = {},\n messenger,\n getMetaMetricsProps,\n getFeatureFlags,\n trace,\n }: SmartTransactionsControllerOptions) {\n super({\n name: controllerName,\n metadata: controllerMetadata,\n messenger,\n state: {\n ...getDefaultSmartTransactionsControllerState(),\n ...state,\n },\n });\n this.#interval = interval;\n this.#clientId = clientId;\n this.#chainId = InitialChainId;\n this.#supportedChainIds = supportedChainIds;\n this.setIntervalLength(interval);\n this.#ethQuery = undefined;\n this.#trackMetaMetricsEvent = trackMetaMetricsEvent;\n this.#getMetaMetricsProps = getMetaMetricsProps;\n this.#getFeatureFlags = getFeatureFlags;\n this.#trace = trace ?? (((_request, fn) => fn?.()) as TraceCallback);\n\n this.initializeSmartTransactionsForChainId();\n\n this.messagingSystem.subscribe(\n 'NetworkController:stateChange',\n ({ selectedNetworkClientId }) => {\n const {\n configuration: { chainId },\n provider,\n } = this.messagingSystem.call(\n 'NetworkController:getNetworkClientById',\n selectedNetworkClientId,\n );\n this.#chainId = chainId;\n this.#ethQuery = new EthQuery(provider);\n this.initializeSmartTransactionsForChainId();\n this.checkPoll(this.state);\n },\n );\n\n this.messagingSystem.subscribe(\n `${controllerName}:stateChange`,\n (currentState) => this.checkPoll(currentState),\n );\n }\n\n async _executePoll({\n chainIds,\n }: SmartTransactionsControllerPollingInput): Promise<void> {\n // if this is going to be truly UI driven polling we shouldn't really reach here\n // with a networkClientId that is not supported, but for now I'll add a check in case\n // wondering if we should add some kind of predicate to the polling controller to check whether\n // we should poll or not\n const filteredChainIds = (chainIds ?? []).filter((chainId) =>\n this.#supportedChainIds.includes(chainId),\n );\n\n if (filteredChainIds.length === 0) {\n return Promise.resolve();\n }\n return this.updateSmartTransactions({ chainIds: filteredChainIds });\n }\n\n checkPoll({\n smartTransactionsState: { smartTransactions },\n }: SmartTransactionsControllerState) {\n const smartTransactionsForAllChains =\n Object.values(smartTransactions).flat();\n\n const pendingTransactions = smartTransactionsForAllChains?.filter(\n isSmartTransactionPending,\n );\n if (!this.timeoutHandle && pendingTransactions?.length > 0) {\n this.poll();\n } else if (this.timeoutHandle && pendingTransactions?.length === 0) {\n this.stop();\n }\n }\n\n initializeSmartTransactionsForChainId() {\n if (this.#supportedChainIds.includes(this.#chainId)) {\n this.update((state) => {\n state.smartTransactionsState.smartTransactions[this.#chainId] =\n state.smartTransactionsState.smartTransactions[this.#chainId] ?? [];\n });\n }\n }\n\n async poll(interval?: number): Promise<void> {\n if (interval) {\n this.#interval = interval;\n }\n\n this.timeoutHandle && clearInterval(this.timeoutHandle);\n\n if (!this.#supportedChainIds.includes(this.#chainId)) {\n return;\n }\n\n this.timeoutHandle = setInterval(() => {\n safelyExecute(async () => this.updateSmartTransactions());\n }, this.#interval);\n await safelyExecute(async () => this.updateSmartTransactions());\n }\n\n async stop() {\n this.timeoutHandle && clearInterval(this.timeoutHandle);\n this.timeoutHandle = undefined;\n }\n\n setOptInState(optInState: boolean | null): void {\n this.update((state) => {\n state.smartTransactionsState.userOptInV2 = optInState;\n });\n }\n\n trackStxStatusChange(\n smartTransaction: SmartTransaction,\n prevSmartTransaction?: SmartTransaction,\n ) {\n let updatedSmartTransaction = cloneDeep(smartTransaction);\n updatedSmartTransaction = {\n ...cloneDeep(prevSmartTransaction),\n ...updatedSmartTransaction,\n };\n\n if (updatedSmartTransaction.status === prevSmartTransaction?.status) {\n return; // If status hasn't changed, don't track it again.\n }\n\n this.#trackMetaMetricsEvent({\n event: MetaMetricsEventName.StxStatusUpdated,\n category: MetaMetricsEventCategory.Transactions,\n properties: getSmartTransactionMetricsProperties(updatedSmartTransaction),\n sensitiveProperties: getSmartTransactionMetricsSensitiveProperties(\n updatedSmartTransaction,\n ),\n });\n }\n\n isNewSmartTransaction(smartTransactionUuid: string, chainId?: Hex): boolean {\n const {\n smartTransactionsState: { smartTransactions },\n } = this.state;\n const currentSmartTransactions =\n smartTransactions[chainId ?? this.#chainId];\n const currentIndex = currentSmartTransactions?.findIndex(\n (stx) => stx.uuid === smartTransactionUuid,\n );\n return currentIndex === -1 || currentIndex === undefined;\n }\n\n updateSmartTransaction(\n smartTransaction: SmartTransaction,\n { networkClientId }: { networkClientId?: NetworkClientId } = {},\n ) {\n let ethQuery = this.#ethQuery;\n let chainId = this.#chainId;\n if (networkClientId) {\n const { configuration, provider } = this.messagingSystem.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n chainId = configuration.chainId;\n ethQuery = new EthQuery(provider);\n }\n\n this.#createOrUpdateSmartTransaction(smartTransaction, {\n chainId,\n ethQuery,\n });\n }\n\n #updateSmartTransaction(\n smartTransaction: SmartTransaction,\n {\n chainId = this.#chainId,\n }: {\n chainId: Hex;\n },\n ) {\n const {\n smartTransactionsState: { smartTransactions },\n } = this.state;\n const currentSmartTransactions = smartTransactions[chainId] ?? [];\n const currentIndex = currentSmartTransactions?.findIndex(\n (stx) => stx.uuid === smartTransaction.uuid,\n );\n\n if (currentIndex === -1) {\n return; // Smart transaction not found, don't update anything.\n }\n\n if (!isSafeDynamicKey(chainId)) {\n return;\n }\n\n this.update((state) => {\n state.smartTransactionsState.smartTransactions[chainId][currentIndex] = {\n ...state.smartTransactionsState.smartTransactions[chainId][\n currentIndex\n ],\n ...smartTransaction,\n };\n });\n }\n\n async #addMetaMetricsPropsToNewSmartTransaction(\n smartTransaction: SmartTransaction,\n ) {\n const metaMetricsProps = await this.#getMetaMetricsProps();\n smartTransaction.accountHardwareType =\n metaMetricsProps?.accountHardwareType;\n smartTransaction.accountType = metaMetricsProps?.accountType;\n smartTransaction.deviceModel = metaMetricsProps?.deviceModel;\n }\n\n async #createOrUpdateSmartTransaction(\n smartTransaction: SmartTransaction,\n {\n chainId = this.#chainId,\n ethQuery = this.#ethQuery,\n }: {\n chainId: Hex;\n ethQuery: EthQuery | undefined;\n },\n ): Promise<void> {\n const {\n smartTransactionsState: { smartTransactions },\n } = this.state;\n const currentSmartTransactions = smartTransactions[chainId] ?? [];\n const currentIndex = currentSmartTransactions?.findIndex(\n (stx) => stx.uuid === smartTransaction.uuid,\n );\n const isNewSmartTransaction = this.isNewSmartTransaction(\n smartTransaction.uuid,\n chainId,\n );\n if (ethQuery === undefined) {\n throw new Error(ETH_QUERY_ERROR_MSG);\n }\n\n if (isNewSmartTransaction) {\n try {\n await this.#addMetaMetricsPropsToNewSmartTransaction(smartTransaction);\n } catch (error) {\n console.error(\n 'Failed to add metrics props to smart transaction:',\n error,\n );\n // Continue without metrics props\n }\n }\n\n this.trackStxStatusChange(\n smartTransaction,\n isNewSmartTransaction\n ? undefined\n : currentSmartTransactions[currentIndex],\n );\n\n if (isNewSmartTransaction) {\n // add smart transaction\n const cancelledNonceIndex = currentSmartTransactions?.findIndex(\n (stx: SmartTransaction) =>\n stx.txParams?.nonce === smartTransaction.txParams?.nonce &&\n stx.status?.startsWith('cancelled'),\n );\n const snapshot = cloneDeep(smartTransaction);\n const history = [snapshot];\n const historifiedSmartTransaction = { ...smartTransaction, history };\n const nextSmartTransactions =\n cancelledNonceIndex > -1\n ? currentSmartTransactions\n .slice(0, cancelledNonceIndex)\n .concat(currentSmartTransactions.slice(cancelledNonceIndex + 1))\n .concat(historifiedSmartTransaction)\n : currentSmartTransactions.concat(historifiedSmartTransaction);\n\n this.update((state) => {\n state.smartTransactionsState.smartTransactions[chainId] =\n nextSmartTransactions;\n });\n return;\n }\n\n const currentSmartTransaction = currentSmartTransactions[currentIndex];\n const nextSmartTransaction = {\n ...currentSmartTransaction,\n ...smartTransaction,\n };\n\n // We have to emit this event here, because then a txHash is returned to the TransactionController once it's available\n // and the #doesTransactionNeedConfirmation function will work properly, since it will find the txHash in the regular transactions list.\n this.messagingSystem.publish(\n `SmartTransactionsController:smartTransaction`,\n nextSmartTransaction,\n );\n\n if (\n shouldMarkRegularTransactionAsFailed({\n smartTransaction: nextSmartTransaction,\n clientId: this.#clientId,\n getFeatureFlags: this.#getFeatureFlags,\n })\n ) {\n markRegularTransactionAsFailed({\n smartTransaction: nextSmartTransaction,\n getRegularTransactions: () =>\n this.messagingSystem.call('TransactionController:getTransactions'),\n updateTransaction: (transactionMeta: TransactionMeta, note: string) =>\n this.messagingSystem.call(\n 'TransactionController:updateTransaction',\n transactionMeta,\n note,\n ),\n });\n }\n\n if (\n (smartTransaction.status === SmartTransactionStatuses.SUCCESS ||\n smartTransaction.status === SmartTransactionStatuses.REVERTED) &&\n !smartTransaction.confirmed\n ) {\n await this.#confirmSmartTransaction(nextSmartTransaction, {\n chainId,\n ethQuery,\n });\n } else {\n this.#updateSmartTransaction(smartTransaction, {\n chainId,\n });\n }\n }\n\n async updateSmartTransactions(\n {\n chainIds,\n }: {\n chainIds: Hex[];\n } = {\n chainIds: this.#getChainIds(),\n },\n ): Promise<void> {\n const {\n smartTransactionsState: { smartTransactions },\n } = this.state;\n\n // Iterate over each chain group directly\n for (const [chainId, transactions] of Object.entries(smartTransactions)) {\n if (chainIds && !chainIds.includes(chainId as Hex)) {\n continue;\n }\n // Filter pending transactions and map them to the desired shape\n const pendingTransactions = transactions\n .filter(isSmartTransactionPending)\n .map((pendingSmartTransaction) => {\n // Use the transaction's chainId (from the key) to derive a networkClientId\n const networkClientIdToUse = this.#getNetworkClientId({\n chainId: chainId as Hex,\n });\n return {\n uuid: pendingSmartTransaction.uuid,\n networkClientId: networkClientIdToUse,\n chainId: pendingSmartTransaction.chainId as Hex, // same as the key, but explicit on the transaction\n };\n });\n\n if (pendingTransactions.length > 0) {\n // Since each group is per chain, all transactions share the same chainId.\n await this.fetchSmartTransactionsStatus(pendingTransactions);\n }\n }\n }\n\n #doesTransactionNeedConfirmation(txHash: string | undefined): boolean {\n if (!txHash) {\n return true;\n }\n const transactions = this.messagingSystem.call(\n 'TransactionController:getTransactions',\n );\n const foundTransaction = transactions?.find((tx) => {\n return tx.hash?.toLowerCase() === txHash.toLowerCase();\n });\n if (!foundTransaction) {\n return true;\n }\n // If a found transaction is either confirmed or submitted, it doesn't need confirmation from the STX controller.\n // When it's in the submitted state, the TransactionController checks its status and confirms it,\n // so no need to confirm it again here.\n return ![TransactionStatus.confirmed, TransactionStatus.submitted].includes(\n foundTransaction.status,\n );\n }\n\n async #confirmSmartTransaction(\n smartTransaction: SmartTransaction,\n {\n chainId = this.#chainId,\n ethQuery = this.#ethQuery,\n }: {\n chainId: Hex;\n ethQuery: EthQuery | undefined;\n },\n ) {\n if (ethQuery === undefined) {\n throw new Error(ETH_QUERY_ERROR_MSG);\n }\n const txHash = smartTransaction.statusMetadata?.minedHash;\n try {\n const transactionReceipt: {\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n blockNumber: string;\n } | null = await query(ethQuery, 'getTransactionReceipt', [txHash]);\n const transaction: {\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n } | null = await query(ethQuery, 'getTransactionByHash', [txHash]);\n\n const maxFeePerGas = transaction?.maxFeePerGas;\n const maxPriorityFeePerGas = transaction?.maxPriorityFeePerGas;\n if (transactionReceipt?.blockNumber) {\n const blockData: { baseFeePerGas?: Hex } | null = await query(\n ethQuery,\n 'getBlockByNumber',\n [transactionReceipt?.blockNumber, false],\n );\n const baseFeePerGas = blockData?.baseFeePerGas;\n const updatedTxParams = {\n ...smartTransaction.txParams,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n // call confirmExternalTransaction\n const originalTxMeta = {\n ...smartTransaction,\n id: smartTransaction.uuid,\n status: TransactionStatus.confirmed,\n hash: txHash,\n txParams: updatedTxParams,\n };\n // create txMeta snapshot for history\n const snapshot = snapshotFromTxMeta(originalTxMeta);\n // recover previous tx state obj\n const previousState = replayHistory(originalTxMeta.history);\n // generate history entry and add to history\n const entry = generateHistoryEntry(\n previousState,\n snapshot,\n 'txStateManager: setting status to confirmed',\n );\n const txMeta =\n entry.length > 0\n ? {\n ...originalTxMeta,\n history: originalTxMeta.history.concat(entry),\n }\n : originalTxMeta;\n\n if (this.#doesTransactionNeedConfirmation(txHash)) {\n this.messagingSystem.call(\n 'TransactionController:confirmExternalTransaction',\n // TODO: Replace 'as' assertion with correct typing for `txMeta`\n txMeta as TransactionMeta,\n transactionReceipt,\n // TODO: Replace 'as' assertion with correct typing for `baseFeePerGas`\n baseFeePerGas as Hex,\n );\n }\n this.#trackMetaMetricsEvent({\n event: MetaMetricsEventName.StxConfirmed,\n category: MetaMetricsEventCategory.Transactions,\n properties: getSmartTransactionMetricsProperties(smartTransaction),\n sensitiveProperties:\n getSmartTransactionMetricsSensitiveProperties(smartTransaction),\n });\n this.#updateSmartTransaction(\n { ...smartTransaction, confirmed: true },\n {\n chainId,\n },\n );\n }\n } catch (error) {\n this.#trackMetaMetricsEvent({\n event: MetaMetricsEventName.StxConfirmationFailed,\n category: MetaMetricsEventCategory.Transactions,\n });\n console.error('confirm error', error);\n } finally {\n this.messagingSystem.publish(\n `SmartTransactionsController:smartTransactionConfirmationDone`,\n smartTransaction,\n );\n }\n }\n\n // ! Ask backend API to accept list of uuids as params\n async fetchSmartTransactionsStatus(\n transactions: {\n uuid: string;\n networkClientId?: NetworkClientId;\n chainId: Hex;\n }[],\n ): Promise<Record<string, SmartTransactionsStatus>> {\n // Since transactions come from the same chain group, take the chainId from the first one.\n const { chainId } = transactions[0];\n\n // Build query parameters with all UUIDs\n const uuids = transactions.map((tx) => tx.uuid);\n const params = new URLSearchParams({ uuids: uuids.join(',') });\n\n // Get the ethQuery for the first transaction's networkClientId\n const ethQuery = this.#getEthQuery({\n networkClientId: transactions[0].networkClientId,\n });\n\n // Construct the URL and fetch the data\n const url = `${getAPIRequestURL(\n APIType.BATCH_STATUS,\n chainId,\n )}?${params.toString()}`;\n const data = (await this.#fetch(url)) as Record<\n string,\n SmartTransactionsStatus\n >;\n\n // Process each returned status\n for (const [uuid, stxStatus] of Object.entries(data)) {\n const matchingTx = transactions.find((tx) => tx.uuid === uuid);\n if (!matchingTx) {\n console.error(`No matching transaction found for uuid: ${uuid}`);\n continue;\n }\n\n const smartTransaction: SmartTransaction = {\n statusMetadata: stxStatus,\n status: calculateStatus(stxStatus),\n cancellable: isSmartTransactionCancellable(stxStatus),\n uuid,\n networkClientId: matchingTx.networkClientId,\n };\n\n await this.#createOrUpdateSmartTransaction(smartTransaction, {\n chainId,\n ethQuery,\n });\n }\n\n return data;\n }\n\n async #addNonceToTransaction(\n transaction: UnsignedTransaction,\n networkClientId: NetworkClientId,\n ): Promise<UnsignedTransaction> {\n const nonceLock = await this.messagingSystem.call(\n 'TransactionController:getNonceLock',\n transaction.from,\n networkClientId,\n );\n const nonce = nonceLock.nextNonce;\n nonceLock.releaseLock();\n return {\n ...transaction,\n nonce: `0x${nonce.toString(16)}`,\n };\n }\n\n clearFees(): Fees {\n const fees = {\n approvalTxFees: null,\n tradeTxFees: null,\n };\n this.update((state) => {\n state.smartTransactionsState.fees = fees;\n });\n\n return fees;\n }\n\n async getFees(\n tradeTx: UnsignedTransaction,\n approvalTx?: UnsignedTransaction,\n { networkClientId }: { networkClientId?: NetworkClientId } = {},\n ): Promise<Fees> {\n const selectedNetworkClientId =\n networkClientId ??\n this.messagingSystem.call('NetworkController:getState')\n .selectedNetworkClientId;\n const chainId = this.#getChainId({\n networkClientId: selectedNetworkClientId,\n });\n const transactions: UnsignedTransaction[] = [];\n let unsignedTradeTransactionWithNonce;\n if (approvalTx) {\n const unsignedApprovalTransactionWithNonce =\n await this.#addNonceToTransaction(approvalTx, selectedNetworkClientId);\n transactions.push(unsignedApprovalTransactionWithNonce);\n unsignedTradeTransactionWithNonce = {\n ...tradeTx,\n // If there is an approval tx, the trade tx's nonce is increased by 1.\n nonce: incrementNonceInHex(unsignedApprovalTransactionWithNonce.nonce),\n };\n } else if (tradeTx.nonce) {\n unsignedTradeTransactionWithNonce = tradeTx;\n } else {\n unsignedTradeTransactionWithNonce = await this.#addNonceToTransaction(\n tradeTx,\n selectedNetworkClientId,\n );\n }\n transactions.push(unsignedTradeTransactionWithNonce);\n const data = await this.#trace(\n { name: SmartTransactionsTraceName.GetFees },\n async () =>\n await this.#fetch(getAPIRequestURL(APIType.GET_FEES, chainId), {\n method: 'POST',\n body: JSON.stringify({\n txs: transactions,\n }),\n }),\n );\n let approvalTxFees: IndividualTxFees | null;\n let tradeTxFees: IndividualTxFees | null;\n if (approvalTx) {\n approvalTxFees = data?.txs[0];\n tradeTxFees = data?.txs[1];\n } else {\n approvalTxFees = null;\n tradeTxFees = data?.txs[0];\n }\n\n this.update((state) => {\n if (chainId === this.#chainId) {\n state.smartTransactionsState.fees = {\n approvalTxFees,\n tradeTxFees,\n };\n }\n state.smartTransactionsState.feesByChainId[chainId] = {\n approvalTxFees,\n tradeTxFees,\n };\n });\n\n return {\n approvalTxFees,\n tradeTxFees,\n };\n }\n\n // * After this successful call client must add a nonce representative to\n // * transaction controller external transactions list\n async submitSignedTransactions({\n transactionMeta,\n txParams,\n signedTransactions,\n signedCanceledTransactions = [],\n networkClientId,\n }: {\n signedTransactions: SignedTransaction[];\n signedCanceledTransactions?: SignedCanceledTransaction[];\n transactionMeta?: TransactionMeta;\n txParams?: TransactionParams;\n networkClientId?: NetworkClientId;\n }) {\n const selectedNetworkClientId =\n networkClientId ??\n this.messagingSystem.call('NetworkController:getState')\n .selectedNetworkClientId;\n const chainId = this.#getChainId({\n networkClientId: selectedNetworkClientId,\n });\n const ethQuery = this.#getEthQuery({\n networkClientId: selectedNetworkClientId,\n });\n const data = await this.#trace(\n { name: SmartTransactionsTraceName.SubmitTransactions },\n async () =>\n await this.#fetch(\n getAPIRequestURL(APIType.SUBMIT_TRANSACTIONS, chainId),\n {\n method: 'POST',\n body: JSON.stringify({\n rawTxs: signedTransactions,\n rawCancelTxs: signedCanceledTransactions,\n }),\n },\n ),\n );\n const time = Date.now();\n let preTxBalance;\n try {\n if (txParams?.from) {\n const preTxBalanceBN = await query(ethQuery, 'getBalance', [\n txParams.from,\n ]);\n preTxBalance = new BigNumber(preTxBalanceBN).toString(16);\n }\n } catch (error) {\n console.error('ethQuery.getBalance error:', error);\n }\n\n const requiresNonce = txParams && !txParams.nonce;\n let nonce;\n let nonceLock;\n let nonceDetails = {};\n\n // This should only happen for Swaps. Non-swaps transactions should already have a nonce\n if (requiresNonce) {\n try {\n nonceLock = await this.messagingSystem.call(\n 'TransactionController:getNonceLock',\n txParams.from,\n selectedNetworkClientId,\n );\n nonce = hexlify(nonceLock.nextNonce);\n nonceDetails = nonceLock.nonceDetails;\n txParams.nonce ??= nonce;\n } catch (error) {\n console.error('Failed to acquire nonce lock:', error);\n throw error;\n }\n }\n\n const txHashes = signedTransactions.map((tx) => getTxHash(tx));\n const submitTransactionResponse = {\n ...data,\n txHash: txHashes[txHashes.length - 1], // For backward compatibility - use the last tx hash\n txHashes,\n };\n\n try {\n await this.#createOrUpdateSmartTransaction(\n {\n chainId,\n nonceDetails,\n preTxBalance,\n status: SmartTransactionStatuses.PENDING,\n time,\n txParams,\n uuid: submitTransactionResponse.uuid,\n txHash: submitTransactionResponse.txHash,\n cancellable: true,\n type: transactionMeta?.type ?? 'swap',\n transactionId: transactionMeta?.id,\n networkClientId: selectedNetworkClientId,\n txHashes, // Add support for multiple transaction hashes\n },\n { chainId, ethQuery },\n );\n } catch (error) {\n console.error('Failed to create a smart transaction:', error);\n throw error;\n } finally {\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n }\n\n return submitTransactionResponse;\n }\n\n #getChainId({\n networkClientId,\n }: { networkClientId?: NetworkClientId } = {}): Hex {\n if (networkClientId) {\n return this.messagingSystem.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n ).configuration.chainId;\n }\n\n return this.#chainId;\n }\n\n #getChainIds(): Hex[] {\n const { networkConfigurationsByChainId } = this.messagingSystem.call(\n 'NetworkController:getState',\n );\n return Object.keys(networkConfigurationsByChainId).filter(\n (chainId): chainId is Hex =>\n this.#supportedChainIds.includes(chainId as Hex),\n );\n }\n\n #getNetworkClientId({ chainId }: { chainId: string }): string {\n const { networkConfigurationsByChainId } = this.messagingSystem.call(\n 'NetworkController:getState',\n );\n return networkConfigurationsByChainId[chainId as Hex].rpcEndpoints[\n networkConfigurationsByChainId[chainId as Hex].defaultRpcEndpointIndex\n ].networkClientId;\n }\n\n #getEthQuery({\n networkClientId,\n }: {\n networkClientId?: NetworkClientId;\n } = {}): EthQuery {\n if (networkClientId) {\n const { provider } = this.messagingSystem.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return new EthQuery(provider);\n }\n\n if (this.#ethQuery === undefined) {\n throw new Error(ETH_QUERY_ERROR_MSG);\n }\n\n return this.#ethQuery;\n }\n\n // TODO: This should return if the cancellation was on chain or not (for nonce management)\n // After this successful call client must update nonce representative\n // in transaction controller external transactions list\n async cancelSmartTransaction(\n uuid: string,\n {\n networkClientId,\n }: {\n networkClientId?: NetworkClientId;\n } = {},\n ): Promise<void> {\n const chainId = this.#getChainId({ networkClientId });\n await this.#trace(\n { name: SmartTransactionsTraceName.CancelTransaction },\n async () =>\n await this.#fetch(getAPIRequestURL(APIType.CANCEL, chainId), {\n method: 'POST',\n body: JSON.stringify({ uuid }),\n }),\n );\n }\n\n async fetchLiveness({\n networkClientId,\n }: {\n networkClientId?: NetworkClientId;\n } = {}): Promise<boolean> {\n const chainId = this.#getChainId({ networkClientId });\n let liveness = false;\n try {\n const response = await this.#trace(\n { name: SmartTransactionsTraceName.FetchLiveness },\n async () =>\n await this.#fetch(getAPIRequestURL(APIType.LIVENESS, chainId)),\n );\n liveness = Boolean(response.smartTransactions);\n } catch (error) {\n console.log('\"fetchLiveness\" API call failed');\n }\n\n this.update((state) => {\n if (chainId === this.#chainId) {\n state.smartTransactionsState.liveness = liveness;\n }\n state.smartTransactionsState.livenessByChainId[chainId] = liveness;\n });\n\n return liveness;\n }\n\n async setStatusRefreshInterval(interval: number): Promise<void> {\n if (interval !== this.#interval) {\n this.#interval = interval;\n }\n }\n\n #getCurrentSmartTransactions(): SmartTransaction[] {\n const {\n smartTransactionsState: { smartTransactions },\n } = this.state;\n const smartTransactionsForAllChains =\n Object.values(smartTransactions).flat();\n if (\n !smartTransactionsForAllChains ||\n smartTransactionsForAllChains.length === 0\n ) {\n return [];\n }\n return smartTransactionsForAllChains;\n }\n\n getTransactions({\n addressFrom,\n status,\n }: {\n addressFrom: string;\n status: SmartTransactionStatuses;\n }): SmartTransaction[] {\n const currentSmartTransactions = this.#getCurrentSmartTransactions();\n return currentSmartTransactions.filter((stx) => {\n return stx.status === status && stx.txParams?.from === addressFrom;\n });\n }\n\n getSmartTransactionByMinedTxHash(\n txHash: string | undefined,\n ): SmartTransaction | undefined {\n if (!txHash) {\n return undefined;\n }\n const currentSmartTransactions = this.#getCurrentSmartTransactions();\n return currentSmartTransactions.find((smartTransaction) => {\n return (\n smartTransaction.statusMetadata?.minedHash?.toLowerCase() ===\n txHash.toLowerCase()\n );\n });\n }\n\n wipeSmartTransactions({\n address,\n ignoreNetwork,\n }: {\n address: string;\n ignoreNetwork?: boolean;\n }): void {\n if (!address) {\n return;\n }\n const addressLowerCase = address.toLowerCase();\n if (ignoreNetwork) {\n const {\n smartTransactionsState: { smartTransactions },\n } = this.state;\n (Object.keys(smartTransactions) as Hex[]).forEach((chainId) => {\n this.#wipeSmartTransactionsPerChainId({\n chainId,\n addressLowerCase,\n });\n });\n } else {\n this.#wipeSmartTransactionsPerChainId({\n chainId: this.#chainId,\n addressLowerCase,\n });\n }\n }\n\n #wipeSmartTransactionsPerChainId({\n chainId,\n addressLowerCase,\n }: {\n chainId: Hex;\n addressLowerCase: string;\n }): void {\n const {\n smartTransactionsState: { smartTransactions },\n } = this.state;\n const smartTransactionsForSelectedChain: SmartTransaction[] =\n smartTransactions?.[chainId];\n if (\n !smartTransactionsForSelectedChain ||\n smartTransactionsForSelectedChain.length === 0\n ) {\n return;\n }\n const newSmartTransactionsForSelectedChain =\n smartTransactionsForSelectedChain.filter(\n (smartTransaction: SmartTransaction) =>\n smartTransaction.txParams?.from !== addressLowerCase,\n );\n this.update((state) => {\n state.smartTransactionsState.smartTransactions[chainId] =\n newSmartTransactionsForSelectedChain;\n });\n }\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { ControllerGetStateAction, ControllerStateChangeEvent,
|
|
3
|
-
import { type TraceCallback } from
|
|
4
|
-
import type { NetworkClientId, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction, NetworkControllerStateChangeEvent } from
|
|
5
|
-
import type {
|
|
6
|
-
import { MetaMetricsEventCategory, MetaMetricsEventName } from
|
|
7
|
-
import type { Fees, Hex, IndividualTxFees, SignedCanceledTransaction, SignedTransaction, SmartTransaction, SmartTransactionsStatus, UnsignedTransaction,
|
|
8
|
-
import { SmartTransactionStatuses } from
|
|
9
|
-
import { getSmartTransactionMetricsProperties, getSmartTransactionMetricsSensitiveProperties } from
|
|
2
|
+
import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
|
|
3
|
+
import { type TraceCallback } from "@metamask/controller-utils";
|
|
4
|
+
import type { NetworkClientId, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction, NetworkControllerStateChangeEvent } from "@metamask/network-controller";
|
|
5
|
+
import type { TransactionControllerConfirmExternalTransactionAction, TransactionControllerGetNonceLockAction, TransactionControllerGetTransactionsAction, TransactionControllerUpdateTransactionAction, TransactionMeta, TransactionParams } from "@metamask/transaction-controller";
|
|
6
|
+
import { MetaMetricsEventCategory, MetaMetricsEventName } from "./constants.cjs";
|
|
7
|
+
import type { Fees, Hex, IndividualTxFees, SignedCanceledTransaction, SignedTransaction, SmartTransaction, SmartTransactionsStatus, UnsignedTransaction, MetaMetricsProps, FeatureFlags, ClientId } from "./types.cjs";
|
|
8
|
+
import { SmartTransactionStatuses } from "./types.cjs";
|
|
9
|
+
import { getSmartTransactionMetricsProperties, getSmartTransactionMetricsSensitiveProperties } from "./utils.cjs";
|
|
10
10
|
export declare const DEFAULT_INTERVAL: number;
|
|
11
11
|
/**
|
|
12
12
|
* The name of the {@link SmartTransactionsController}
|
|
@@ -38,7 +38,7 @@ export declare type SmartTransactionsControllerGetStateAction = ControllerGetSta
|
|
|
38
38
|
* The actions that can be performed using the {@link SmartTransactionsController}.
|
|
39
39
|
*/
|
|
40
40
|
export declare type SmartTransactionsControllerActions = SmartTransactionsControllerGetStateAction;
|
|
41
|
-
declare type AllowedActions = NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetStateAction;
|
|
41
|
+
declare type AllowedActions = NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetStateAction | TransactionControllerGetNonceLockAction | TransactionControllerConfirmExternalTransactionAction | TransactionControllerGetTransactionsAction | TransactionControllerUpdateTransactionAction;
|
|
42
42
|
export declare type SmartTransactionsControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SmartTransactionsControllerState>;
|
|
43
43
|
export declare type SmartTransactionsControllerSmartTransactionEvent = {
|
|
44
44
|
type: 'SmartTransactionsController:smartTransaction';
|
|
@@ -56,14 +56,12 @@ declare type AllowedEvents = NetworkControllerStateChangeEvent;
|
|
|
56
56
|
/**
|
|
57
57
|
* The messenger of the {@link SmartTransactionsController}.
|
|
58
58
|
*/
|
|
59
|
-
export declare type SmartTransactionsControllerMessenger =
|
|
59
|
+
export declare type SmartTransactionsControllerMessenger = RestrictedMessenger<typeof controllerName, SmartTransactionsControllerActions | AllowedActions, SmartTransactionsControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
60
60
|
declare type SmartTransactionsControllerOptions = {
|
|
61
61
|
interval?: number;
|
|
62
62
|
clientId: ClientId;
|
|
63
63
|
chainId?: Hex;
|
|
64
64
|
supportedChainIds?: Hex[];
|
|
65
|
-
getNonceLock: TransactionController['getNonceLock'];
|
|
66
|
-
confirmExternalTransaction: TransactionController['confirmExternalTransaction'];
|
|
67
65
|
trackMetaMetricsEvent: (event: {
|
|
68
66
|
event: MetaMetricsEventName;
|
|
69
67
|
category: MetaMetricsEventCategory;
|
|
@@ -74,34 +72,32 @@ declare type SmartTransactionsControllerOptions = {
|
|
|
74
72
|
} & Record<string, boolean>) => void;
|
|
75
73
|
state?: Partial<SmartTransactionsControllerState>;
|
|
76
74
|
messenger: SmartTransactionsControllerMessenger;
|
|
77
|
-
getTransactions: (options?: GetTransactionsOptions) => TransactionMeta[];
|
|
78
75
|
getMetaMetricsProps: () => Promise<MetaMetricsProps>;
|
|
79
76
|
getFeatureFlags: () => FeatureFlags;
|
|
80
|
-
updateTransaction: (transaction: TransactionMeta, note: string) => void;
|
|
81
77
|
trace?: TraceCallback;
|
|
82
78
|
};
|
|
83
79
|
export declare type SmartTransactionsControllerPollingInput = {
|
|
84
80
|
chainIds: Hex[];
|
|
85
81
|
};
|
|
86
82
|
declare const SmartTransactionsController_base: (abstract new (...args: any[]) => {
|
|
87
|
-
readonly "__#
|
|
88
|
-
"__#
|
|
83
|
+
readonly "__#14@#intervalIds": Record<string, NodeJS.Timeout>;
|
|
84
|
+
"__#14@#intervalLength": number | undefined;
|
|
89
85
|
setIntervalLength(intervalLength: number): void;
|
|
90
86
|
getIntervalLength(): number | undefined;
|
|
91
87
|
_startPolling(input: SmartTransactionsControllerPollingInput): void;
|
|
92
88
|
_stopPollingByPollingTokenSetId(key: string): void;
|
|
93
|
-
readonly "__#
|
|
94
|
-
"__#
|
|
89
|
+
readonly "__#3@#pollingTokenSets": Map<string, Set<string>>;
|
|
90
|
+
"__#3@#callbacks": Map<string, Set<(input: SmartTransactionsControllerPollingInput) => void>>;
|
|
95
91
|
_executePoll(input: SmartTransactionsControllerPollingInput): Promise<void>;
|
|
96
92
|
startPolling(input: SmartTransactionsControllerPollingInput): string;
|
|
97
93
|
stopAllPolling(): void;
|
|
98
94
|
stopPollingByPollingToken(pollingToken: string): void;
|
|
99
95
|
onPollingComplete(input: SmartTransactionsControllerPollingInput, callback: (input: SmartTransactionsControllerPollingInput) => void): void;
|
|
100
96
|
}) & typeof import("@metamask/base-controller").BaseController;
|
|
101
|
-
export
|
|
97
|
+
export declare class SmartTransactionsController extends SmartTransactionsController_base<typeof controllerName, SmartTransactionsControllerState, SmartTransactionsControllerMessenger> {
|
|
102
98
|
#private;
|
|
103
99
|
timeoutHandle?: NodeJS.Timeout;
|
|
104
|
-
constructor({ interval, clientId, chainId: InitialChainId, supportedChainIds,
|
|
100
|
+
constructor({ interval, clientId, chainId: InitialChainId, supportedChainIds, trackMetaMetricsEvent, state, messenger, getMetaMetricsProps, getFeatureFlags, trace, }: SmartTransactionsControllerOptions);
|
|
105
101
|
_executePoll({ chainIds, }: SmartTransactionsControllerPollingInput): Promise<void>;
|
|
106
102
|
checkPoll({ smartTransactionsState: { smartTransactions }, }: SmartTransactionsControllerState): void;
|
|
107
103
|
initializeSmartTransactionsForChainId(): void;
|
|
@@ -150,3 +146,4 @@ export default class SmartTransactionsController extends SmartTransactionsContro
|
|
|
150
146
|
}): void;
|
|
151
147
|
}
|
|
152
148
|
export {};
|
|
149
|
+
//# sourceMappingURL=SmartTransactionsController.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartTransactionsController.d.cts","sourceRoot":"","sources":["../src/SmartTransactionsController.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EAEpB,kCAAkC;AACnC,OAAO,EAKL,KAAK,aAAa,EACnB,mCAAmC;AAEpC,OAAO,KAAK,EACV,eAAe,EACf,2CAA2C,EAC3C,+BAA+B,EAC/B,iCAAiC,EAClC,qCAAqC;AAEtC,OAAO,KAAK,EACV,qDAAqD,EACrD,uCAAuC,EACvC,0CAA0C,EAC1C,4CAA4C,EAC5C,eAAe,EACf,iBAAiB,EAClB,yCAAyC;AAK1C,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EAErB,wBAAoB;AACrB,OAAO,KAAK,EACV,IAAI,EACJ,GAAG,EACH,gBAAgB,EAChB,yBAAyB,EACzB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACT,oBAAgB;AACjB,OAAO,EAAW,wBAAwB,EAAE,oBAAgB;AAC5D,OAAO,EAWL,oCAAoC,EACpC,6CAA6C,EAG9C,oBAAgB;AAGjB,eAAO,MAAM,gBAAgB,QAAa,CAAC;AAI3C;;GAEG;AACH,QAAA,MAAM,cAAc,gCAAgC,CAAC;AAWrD,aAAK,YAAY,GAAG;IAClB,cAAc,EAAE,gBAAgB,GAAG,IAAI,CAAC;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