@metamask-previews/transaction-controller 35.1.1-preview-63249efd → 35.1.1-preview-e8f9512d
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/dist/TransactionController.js +12 -11
- package/dist/TransactionController.mjs +11 -10
- package/dist/{chunk-DV4DIGIE.js → chunk-4OYPDGHO.js} +6 -6
- package/dist/{chunk-3Y7RHK6L.js → chunk-5HYWLTVQ.js} +3 -3
- package/dist/chunk-5QVDIVJH.js +68 -0
- package/dist/chunk-5QVDIVJH.js.map +1 -0
- package/dist/{chunk-EPCF4BU3.mjs → chunk-AWIJZAW3.mjs} +3 -3
- package/dist/{chunk-PI5XNTNC.js → chunk-BZV72SCF.js} +5 -5
- package/dist/{chunk-OBYKCUWH.js → chunk-EHWAY6XU.js} +9 -9
- package/dist/{chunk-GNAL5HC2.mjs → chunk-JIFPK37W.mjs} +2 -2
- package/dist/chunk-JOQK7A5G.mjs +68 -0
- package/dist/chunk-JOQK7A5G.mjs.map +1 -0
- package/dist/{chunk-OZ6UB42C.js → chunk-KTGMNUTQ.js} +2 -23
- package/dist/chunk-KTGMNUTQ.js.map +1 -0
- package/dist/{chunk-EUJSTRE7.mjs → chunk-KYRW4BLA.mjs} +3 -3
- package/dist/{chunk-ZAL2JFL6.mjs → chunk-LFFYCDHB.mjs} +1 -1
- package/dist/{chunk-ZAL2JFL6.mjs.map → chunk-LFFYCDHB.mjs.map} +1 -1
- package/dist/{chunk-TWU3E2S2.mjs → chunk-NNHSNPT2.mjs} +2 -2
- package/dist/{chunk-4IUBMIDQ.js → chunk-PSZ34BI5.js} +1 -1
- package/dist/{chunk-4IUBMIDQ.js.map → chunk-PSZ34BI5.js.map} +1 -1
- package/dist/{chunk-QH2H4W3N.js → chunk-QKV7E5BO.js} +5 -5
- package/dist/{chunk-EXQCUTGP.mjs → chunk-SFFOC25Q.mjs} +3 -3
- package/dist/{chunk-OSRJHVMI.js → chunk-UHAFIPSL.js} +6 -6
- package/dist/{chunk-Q56I5ONX.mjs → chunk-UHSRHP55.mjs} +1 -22
- package/dist/chunk-UHSRHP55.mjs.map +1 -0
- package/dist/{chunk-5MYXN7TL.mjs → chunk-VGFPVAKX.mjs} +2 -2
- package/dist/{chunk-X4UQYI6T.js → chunk-VKWOHNDO.js} +153 -251
- package/dist/chunk-VKWOHNDO.js.map +1 -0
- package/dist/{chunk-P6E3JOST.mjs → chunk-X4XSEYPL.mjs} +3 -3
- package/dist/{chunk-FGXUEMNU.mjs → chunk-XTMJ25EF.mjs} +133 -231
- package/dist/chunk-XTMJ25EF.mjs.map +1 -0
- package/dist/{chunk-SZRRNVKK.js → chunk-YWLMT7XH.js} +4 -4
- package/dist/errors.js +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.js +7 -7
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +6 -6
- package/dist/gas-flows/LineaGasFeeFlow.js +8 -8
- package/dist/gas-flows/LineaGasFeeFlow.mjs +7 -7
- package/dist/gas-flows/TestGasFeeFlow.js +1 -1
- package/dist/gas-flows/TestGasFeeFlow.mjs +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.js +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +1 -1
- package/dist/helpers/GasFeePoller.js +4 -4
- package/dist/helpers/GasFeePoller.mjs +3 -3
- package/dist/helpers/MultichainTrackingHelper.js +1 -1
- package/dist/helpers/MultichainTrackingHelper.mjs +1 -1
- package/dist/helpers/PendingTransactionTracker.js +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +1 -1
- package/dist/index.js +12 -11
- package/dist/index.mjs +11 -10
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts +1 -8
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +12 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/retry.d.ts +11 -0
- package/dist/types/utils/retry.d.ts.map +1 -0
- package/dist/types/utils/utils.d.ts +1 -15
- package/dist/types/utils/utils.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.mjs +1 -1
- package/dist/utils/external-transactions.js +1 -1
- package/dist/utils/external-transactions.mjs +1 -1
- package/dist/utils/gas-fees.js +6 -6
- package/dist/utils/gas-fees.mjs +5 -5
- package/dist/utils/gas-flow.js +3 -3
- package/dist/utils/gas-flow.mjs +2 -2
- package/dist/utils/retry.js +8 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/retry.mjs +8 -0
- package/dist/utils/retry.mjs.map +1 -0
- package/dist/utils/simulation-api.js +1 -1
- package/dist/utils/simulation-api.mjs +1 -1
- package/dist/utils/simulation.js +1 -1
- package/dist/utils/simulation.mjs +1 -1
- package/dist/utils/swaps.js +4 -4
- package/dist/utils/swaps.mjs +3 -3
- package/dist/utils/transaction-type.js +1 -1
- package/dist/utils/transaction-type.mjs +1 -1
- package/dist/utils/utils.js +3 -13
- package/dist/utils/utils.mjs +4 -14
- package/dist/utils/validation.js +4 -4
- package/dist/utils/validation.mjs +3 -3
- package/package.json +2 -2
- package/dist/chunk-FGXUEMNU.mjs.map +0 -1
- package/dist/chunk-OZ6UB42C.js.map +0 -1
- package/dist/chunk-Q56I5ONX.mjs.map +0 -1
- package/dist/chunk-X4UQYI6T.js.map +0 -1
- /package/dist/{chunk-DV4DIGIE.js.map → chunk-4OYPDGHO.js.map} +0 -0
- /package/dist/{chunk-3Y7RHK6L.js.map → chunk-5HYWLTVQ.js.map} +0 -0
- /package/dist/{chunk-EPCF4BU3.mjs.map → chunk-AWIJZAW3.mjs.map} +0 -0
- /package/dist/{chunk-PI5XNTNC.js.map → chunk-BZV72SCF.js.map} +0 -0
- /package/dist/{chunk-OBYKCUWH.js.map → chunk-EHWAY6XU.js.map} +0 -0
- /package/dist/{chunk-GNAL5HC2.mjs.map → chunk-JIFPK37W.mjs.map} +0 -0
- /package/dist/{chunk-EUJSTRE7.mjs.map → chunk-KYRW4BLA.mjs.map} +0 -0
- /package/dist/{chunk-TWU3E2S2.mjs.map → chunk-NNHSNPT2.mjs.map} +0 -0
- /package/dist/{chunk-QH2H4W3N.js.map → chunk-QKV7E5BO.js.map} +0 -0
- /package/dist/{chunk-EXQCUTGP.mjs.map → chunk-SFFOC25Q.mjs.map} +0 -0
- /package/dist/{chunk-OSRJHVMI.js.map → chunk-UHAFIPSL.js.map} +0 -0
- /package/dist/{chunk-5MYXN7TL.mjs.map → chunk-VGFPVAKX.mjs.map} +0 -0
- /package/dist/{chunk-P6E3JOST.mjs.map → chunk-X4XSEYPL.mjs.map} +0 -0
- /package/dist/{chunk-SZRRNVKK.js.map → chunk-YWLMT7XH.js.map} +0 -0
|
@@ -2,6 +2,9 @@ import {
|
|
|
2
2
|
getAndFormatTransactionsForNonceTracker,
|
|
3
3
|
getNextNonce
|
|
4
4
|
} from "./chunk-6DDVVUJC.mjs";
|
|
5
|
+
import {
|
|
6
|
+
getTransactionParamsWithIncreasedGasFee
|
|
7
|
+
} from "./chunk-JOQK7A5G.mjs";
|
|
5
8
|
import {
|
|
6
9
|
getSimulationData
|
|
7
10
|
} from "./chunk-3AVRGHUO.mjs";
|
|
@@ -11,7 +14,7 @@ import {
|
|
|
11
14
|
import {
|
|
12
15
|
validateTransactionOrigin,
|
|
13
16
|
validateTxParams
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-X4XSEYPL.mjs";
|
|
15
18
|
import {
|
|
16
19
|
PendingTransactionTracker
|
|
17
20
|
} from "./chunk-6B5BEO3R.mjs";
|
|
@@ -38,7 +41,7 @@ import {
|
|
|
38
41
|
} from "./chunk-FMRLPVFZ.mjs";
|
|
39
42
|
import {
|
|
40
43
|
GasFeePoller
|
|
41
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-VGFPVAKX.mjs";
|
|
42
45
|
import {
|
|
43
46
|
getTransactionLayer1GasFee,
|
|
44
47
|
updateTransactionLayer1GasFee
|
|
@@ -54,32 +57,28 @@ import {
|
|
|
54
57
|
} from "./chunk-EKJXGERC.mjs";
|
|
55
58
|
import {
|
|
56
59
|
LineaGasFeeFlow
|
|
57
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-KYRW4BLA.mjs";
|
|
58
61
|
import {
|
|
59
62
|
DefaultGasFeeFlow
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-AWIJZAW3.mjs";
|
|
61
64
|
import {
|
|
62
65
|
updateGasFees
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-SFFOC25Q.mjs";
|
|
64
67
|
import {
|
|
65
68
|
updatePostTransactionBalance,
|
|
66
69
|
updateSwapsTransaction
|
|
67
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-JIFPK37W.mjs";
|
|
68
71
|
import {
|
|
69
|
-
getIncreasedPriceFromExisting,
|
|
70
72
|
isEIP1559Transaction,
|
|
71
|
-
isFeeMarketEIP1559Values,
|
|
72
|
-
isGasPriceValue,
|
|
73
73
|
normalizeGasFeeValues,
|
|
74
74
|
normalizeTransactionParams,
|
|
75
75
|
normalizeTxError,
|
|
76
76
|
validateGasValues,
|
|
77
|
-
validateIfTransactionUnapproved
|
|
78
|
-
|
|
79
|
-
} from "./chunk-Q56I5ONX.mjs";
|
|
77
|
+
validateIfTransactionUnapproved
|
|
78
|
+
} from "./chunk-UHSRHP55.mjs";
|
|
80
79
|
import {
|
|
81
80
|
getGasFeeFlow
|
|
82
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-NNHSNPT2.mjs";
|
|
83
82
|
import {
|
|
84
83
|
projectLogger
|
|
85
84
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -143,7 +142,7 @@ function getDefaultTransactionControllerState() {
|
|
|
143
142
|
lastFetchedBlockNumbers: {}
|
|
144
143
|
};
|
|
145
144
|
}
|
|
146
|
-
var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _trace, _transactionHistoryLimit, _isSimulationEnabled, _testGasFeeFlows, _multichainTrackingHelper, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn, _onGasFeePollerTransactionUpdate, onGasFeePollerTransactionUpdate_fn, _getNetworkClientId, getNetworkClientId_fn, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn, _getGlobalChainId, getGlobalChainId_fn, _isCustomNetwork, isCustomNetwork_fn, _getSelectedAccount, getSelectedAccount_fn;
|
|
145
|
+
var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _trace, _transactionHistoryLimit, _isSimulationEnabled, _testGasFeeFlows, _multichainTrackingHelper, _retryTransaction, retryTransaction_fn, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn, _onGasFeePollerTransactionUpdate, onGasFeePollerTransactionUpdate_fn, _getNetworkClientId, getNetworkClientId_fn, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn, _getGlobalChainId, getGlobalChainId_fn, _isCustomNetwork, isCustomNetwork_fn, _getSelectedAccount, getSelectedAccount_fn;
|
|
147
146
|
var TransactionController = class extends BaseController {
|
|
148
147
|
/**
|
|
149
148
|
* Constructs a TransactionController.
|
|
@@ -213,6 +212,7 @@ var TransactionController = class extends BaseController {
|
|
|
213
212
|
...state
|
|
214
213
|
}
|
|
215
214
|
});
|
|
215
|
+
__privateAdd(this, _retryTransaction);
|
|
216
216
|
__privateAdd(this, _createNonceTracker);
|
|
217
217
|
__privateAdd(this, _createIncomingTransactionHelper);
|
|
218
218
|
__privateAdd(this, _createPendingTransactionTracker);
|
|
@@ -605,116 +605,30 @@ var TransactionController = class extends BaseController {
|
|
|
605
605
|
estimatedBaseFee,
|
|
606
606
|
actionId
|
|
607
607
|
} = {}) {
|
|
608
|
-
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
if (gasValues) {
|
|
612
|
-
gasValues = normalizeGasFeeValues(gasValues);
|
|
613
|
-
validateGasValues(gasValues);
|
|
614
|
-
}
|
|
615
|
-
projectLogger("Creating cancel transaction", transactionId, gasValues);
|
|
616
|
-
const transactionMeta = this.getTransaction(transactionId);
|
|
617
|
-
if (!transactionMeta) {
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
if (!this.sign) {
|
|
621
|
-
throw new Error("No sign method defined.");
|
|
622
|
-
}
|
|
623
|
-
const minGasPrice = getIncreasedPriceFromExisting(
|
|
624
|
-
transactionMeta.txParams.gasPrice,
|
|
625
|
-
CANCEL_RATE
|
|
626
|
-
);
|
|
627
|
-
const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;
|
|
628
|
-
const newGasPrice = gasPriceFromValues && validateMinimumIncrease(gasPriceFromValues, minGasPrice) || minGasPrice;
|
|
629
|
-
const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;
|
|
630
|
-
const minMaxFeePerGas = getIncreasedPriceFromExisting(
|
|
631
|
-
existingMaxFeePerGas,
|
|
632
|
-
CANCEL_RATE
|
|
633
|
-
);
|
|
634
|
-
const maxFeePerGasValues = isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;
|
|
635
|
-
const newMaxFeePerGas = maxFeePerGasValues && validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas) || existingMaxFeePerGas && minMaxFeePerGas;
|
|
636
|
-
const existingMaxPriorityFeePerGas = transactionMeta.txParams?.maxPriorityFeePerGas;
|
|
637
|
-
const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(
|
|
638
|
-
existingMaxPriorityFeePerGas,
|
|
639
|
-
CANCEL_RATE
|
|
640
|
-
);
|
|
641
|
-
const maxPriorityFeePerGasValues = isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;
|
|
642
|
-
const newMaxPriorityFeePerGas = maxPriorityFeePerGasValues && validateMinimumIncrease(
|
|
643
|
-
maxPriorityFeePerGasValues,
|
|
644
|
-
minMaxPriorityFeePerGas
|
|
645
|
-
) || existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas;
|
|
646
|
-
const newTxParams = newMaxFeePerGas && newMaxPriorityFeePerGas ? {
|
|
647
|
-
from: transactionMeta.txParams.from,
|
|
648
|
-
gasLimit: transactionMeta.txParams.gas,
|
|
649
|
-
maxFeePerGas: newMaxFeePerGas,
|
|
650
|
-
maxPriorityFeePerGas: newMaxPriorityFeePerGas,
|
|
651
|
-
type: "0x2" /* feeMarket */,
|
|
652
|
-
nonce: transactionMeta.txParams.nonce,
|
|
653
|
-
to: transactionMeta.txParams.from,
|
|
654
|
-
value: "0x0"
|
|
655
|
-
} : {
|
|
656
|
-
from: transactionMeta.txParams.from,
|
|
657
|
-
gasLimit: transactionMeta.txParams.gas,
|
|
658
|
-
gasPrice: newGasPrice,
|
|
659
|
-
nonce: transactionMeta.txParams.nonce,
|
|
660
|
-
to: transactionMeta.txParams.from,
|
|
661
|
-
value: "0x0"
|
|
662
|
-
};
|
|
663
|
-
const unsignedEthTx = this.prepareUnsignedEthTx(
|
|
664
|
-
transactionMeta.chainId,
|
|
665
|
-
newTxParams
|
|
666
|
-
);
|
|
667
|
-
const signedTx = await this.sign(
|
|
668
|
-
unsignedEthTx,
|
|
669
|
-
transactionMeta.txParams.from
|
|
670
|
-
);
|
|
671
|
-
const rawTx = bufferToHex(signedTx.serialize());
|
|
672
|
-
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
673
|
-
const oldFee = newTxParams.maxFeePerGas ? transactionMeta.txParams.maxFeePerGas : transactionMeta.txParams.gasPrice;
|
|
674
|
-
projectLogger("Submitting cancel transaction", {
|
|
675
|
-
oldFee,
|
|
676
|
-
newFee,
|
|
677
|
-
txParams: newTxParams
|
|
678
|
-
});
|
|
679
|
-
const ethQuery = __privateGet(this, _multichainTrackingHelper).getEthQuery({
|
|
680
|
-
networkClientId: transactionMeta.networkClientId,
|
|
681
|
-
chainId: transactionMeta.chainId
|
|
682
|
-
});
|
|
683
|
-
const hash = await this.publishTransactionForRetry(
|
|
684
|
-
ethQuery,
|
|
685
|
-
rawTx,
|
|
686
|
-
transactionMeta
|
|
687
|
-
);
|
|
688
|
-
const cancelTransactionMeta = {
|
|
608
|
+
return await __privateMethod(this, _retryTransaction, retryTransaction_fn).call(this, {
|
|
689
609
|
actionId,
|
|
690
|
-
chainId: transactionMeta.chainId,
|
|
691
|
-
networkClientId: transactionMeta.networkClientId,
|
|
692
610
|
estimatedBaseFee,
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
611
|
+
gasValues,
|
|
612
|
+
label: "cancel",
|
|
613
|
+
rate: CANCEL_RATE,
|
|
614
|
+
transactionId,
|
|
615
|
+
transactionType: "cancel" /* cancel */,
|
|
616
|
+
prepareTransactionParams: (txParams) => {
|
|
617
|
+
delete txParams.data;
|
|
618
|
+
txParams.to = txParams.from;
|
|
619
|
+
txParams.value = "0x0";
|
|
620
|
+
},
|
|
621
|
+
afterSubmit: (newTransactionMeta) => {
|
|
622
|
+
this.messagingSystem.publish(
|
|
623
|
+
`${controllerName}:transactionFinished`,
|
|
624
|
+
newTransactionMeta
|
|
625
|
+
);
|
|
626
|
+
__privateGet(this, _internalEvents).emit(
|
|
627
|
+
`${newTransactionMeta.id}:finished`,
|
|
628
|
+
newTransactionMeta
|
|
629
|
+
);
|
|
630
|
+
}
|
|
709
631
|
});
|
|
710
|
-
this.messagingSystem.publish(
|
|
711
|
-
`${controllerName}:transactionFinished`,
|
|
712
|
-
cancelTransactionMeta
|
|
713
|
-
);
|
|
714
|
-
__privateGet(this, _internalEvents).emit(
|
|
715
|
-
`${transactionMeta.id}:finished`,
|
|
716
|
-
cancelTransactionMeta
|
|
717
|
-
);
|
|
718
632
|
}
|
|
719
633
|
/**
|
|
720
634
|
* Attempts to speed up a transaction increasing transaction gasPrice by ten percent.
|
|
@@ -729,118 +643,21 @@ var TransactionController = class extends BaseController {
|
|
|
729
643
|
actionId,
|
|
730
644
|
estimatedBaseFee
|
|
731
645
|
} = {}) {
|
|
732
|
-
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
if (gasValues) {
|
|
736
|
-
gasValues = normalizeGasFeeValues(gasValues);
|
|
737
|
-
validateGasValues(gasValues);
|
|
738
|
-
}
|
|
739
|
-
projectLogger("Creating speed up transaction", transactionId, gasValues);
|
|
740
|
-
const transactionMeta = this.getTransaction(transactionId);
|
|
741
|
-
if (!transactionMeta) {
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
if (!this.sign) {
|
|
745
|
-
throw new Error("No sign method defined.");
|
|
746
|
-
}
|
|
747
|
-
const minGasPrice = getIncreasedPriceFromExisting(
|
|
748
|
-
transactionMeta.txParams.gasPrice,
|
|
749
|
-
SPEED_UP_RATE
|
|
750
|
-
);
|
|
751
|
-
const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;
|
|
752
|
-
const newGasPrice = gasPriceFromValues && validateMinimumIncrease(gasPriceFromValues, minGasPrice) || minGasPrice;
|
|
753
|
-
const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;
|
|
754
|
-
const minMaxFeePerGas = getIncreasedPriceFromExisting(
|
|
755
|
-
existingMaxFeePerGas,
|
|
756
|
-
SPEED_UP_RATE
|
|
757
|
-
);
|
|
758
|
-
const maxFeePerGasValues = isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;
|
|
759
|
-
const newMaxFeePerGas = maxFeePerGasValues && validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas) || existingMaxFeePerGas && minMaxFeePerGas;
|
|
760
|
-
const existingMaxPriorityFeePerGas = transactionMeta.txParams?.maxPriorityFeePerGas;
|
|
761
|
-
const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(
|
|
762
|
-
existingMaxPriorityFeePerGas,
|
|
763
|
-
SPEED_UP_RATE
|
|
764
|
-
);
|
|
765
|
-
const maxPriorityFeePerGasValues = isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;
|
|
766
|
-
const newMaxPriorityFeePerGas = maxPriorityFeePerGasValues && validateMinimumIncrease(
|
|
767
|
-
maxPriorityFeePerGasValues,
|
|
768
|
-
minMaxPriorityFeePerGas
|
|
769
|
-
) || existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas;
|
|
770
|
-
const txParams = newMaxFeePerGas && newMaxPriorityFeePerGas ? {
|
|
771
|
-
...transactionMeta.txParams,
|
|
772
|
-
gasLimit: transactionMeta.txParams.gas,
|
|
773
|
-
maxFeePerGas: newMaxFeePerGas,
|
|
774
|
-
maxPriorityFeePerGas: newMaxPriorityFeePerGas,
|
|
775
|
-
type: "0x2" /* feeMarket */
|
|
776
|
-
} : {
|
|
777
|
-
...transactionMeta.txParams,
|
|
778
|
-
gasLimit: transactionMeta.txParams.gas,
|
|
779
|
-
gasPrice: newGasPrice
|
|
780
|
-
};
|
|
781
|
-
const unsignedEthTx = this.prepareUnsignedEthTx(
|
|
782
|
-
transactionMeta.chainId,
|
|
783
|
-
txParams
|
|
784
|
-
);
|
|
785
|
-
const signedTx = await this.sign(
|
|
786
|
-
unsignedEthTx,
|
|
787
|
-
transactionMeta.txParams.from
|
|
788
|
-
);
|
|
789
|
-
const transactionMetaWithRsv = this.updateTransactionMetaRSV(
|
|
790
|
-
transactionMeta,
|
|
791
|
-
signedTx
|
|
792
|
-
);
|
|
793
|
-
const rawTx = bufferToHex(signedTx.serialize());
|
|
794
|
-
const newFee = txParams.maxFeePerGas ?? txParams.gasPrice;
|
|
795
|
-
const oldFee = txParams.maxFeePerGas ? transactionMetaWithRsv.txParams.maxFeePerGas : transactionMetaWithRsv.txParams.gasPrice;
|
|
796
|
-
projectLogger("Submitting speed up transaction", { oldFee, newFee, txParams });
|
|
797
|
-
const ethQuery = __privateGet(this, _multichainTrackingHelper).getEthQuery({
|
|
798
|
-
networkClientId: transactionMeta.networkClientId,
|
|
799
|
-
chainId: transactionMeta.chainId
|
|
800
|
-
});
|
|
801
|
-
const hash = await this.publishTransactionForRetry(
|
|
802
|
-
ethQuery,
|
|
803
|
-
rawTx,
|
|
804
|
-
transactionMeta
|
|
805
|
-
);
|
|
806
|
-
const baseTransactionMeta = {
|
|
807
|
-
...transactionMetaWithRsv,
|
|
808
|
-
estimatedBaseFee,
|
|
809
|
-
id: random(),
|
|
810
|
-
time: Date.now(),
|
|
811
|
-
hash,
|
|
646
|
+
return await __privateMethod(this, _retryTransaction, retryTransaction_fn).call(this, {
|
|
812
647
|
actionId,
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
} : {
|
|
825
|
-
...baseTransactionMeta,
|
|
826
|
-
txParams: {
|
|
827
|
-
...transactionMeta.txParams,
|
|
828
|
-
gasPrice: newGasPrice
|
|
648
|
+
estimatedBaseFee,
|
|
649
|
+
gasValues,
|
|
650
|
+
label: "speed up",
|
|
651
|
+
rate: SPEED_UP_RATE,
|
|
652
|
+
transactionId,
|
|
653
|
+
transactionType: "retry" /* retry */,
|
|
654
|
+
afterSubmit: (newTransactionMeta) => {
|
|
655
|
+
this.messagingSystem.publish(
|
|
656
|
+
`${controllerName}:speedupTransactionAdded`,
|
|
657
|
+
newTransactionMeta
|
|
658
|
+
);
|
|
829
659
|
}
|
|
830
|
-
};
|
|
831
|
-
this.addMetadata(newTransactionMeta);
|
|
832
|
-
this.messagingSystem.publish(`${controllerName}:transactionApproved`, {
|
|
833
|
-
transactionMeta: newTransactionMeta,
|
|
834
|
-
actionId
|
|
835
660
|
});
|
|
836
|
-
this.messagingSystem.publish(`${controllerName}:transactionSubmitted`, {
|
|
837
|
-
transactionMeta: newTransactionMeta,
|
|
838
|
-
actionId
|
|
839
|
-
});
|
|
840
|
-
this.messagingSystem.publish(
|
|
841
|
-
`${controllerName}:speedupTransactionAdded`,
|
|
842
|
-
newTransactionMeta
|
|
843
|
-
);
|
|
844
661
|
}
|
|
845
662
|
/**
|
|
846
663
|
* Estimates required gas for a given transaction.
|
|
@@ -2276,6 +2093,91 @@ _transactionHistoryLimit = new WeakMap();
|
|
|
2276
2093
|
_isSimulationEnabled = new WeakMap();
|
|
2277
2094
|
_testGasFeeFlows = new WeakMap();
|
|
2278
2095
|
_multichainTrackingHelper = new WeakMap();
|
|
2096
|
+
_retryTransaction = new WeakSet();
|
|
2097
|
+
retryTransaction_fn = async function({
|
|
2098
|
+
actionId,
|
|
2099
|
+
afterSubmit,
|
|
2100
|
+
estimatedBaseFee,
|
|
2101
|
+
gasValues,
|
|
2102
|
+
label,
|
|
2103
|
+
prepareTransactionParams,
|
|
2104
|
+
rate,
|
|
2105
|
+
transactionId,
|
|
2106
|
+
transactionType
|
|
2107
|
+
}) {
|
|
2108
|
+
if (this.getTransactionWithActionId(actionId)) {
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
if (gasValues) {
|
|
2112
|
+
gasValues = normalizeGasFeeValues(gasValues);
|
|
2113
|
+
validateGasValues(gasValues);
|
|
2114
|
+
}
|
|
2115
|
+
projectLogger(`Creating ${label} transaction`, transactionId, gasValues);
|
|
2116
|
+
const transactionMeta = this.getTransaction(transactionId);
|
|
2117
|
+
if (!transactionMeta) {
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
if (!this.sign) {
|
|
2121
|
+
throw new Error("No sign method defined.");
|
|
2122
|
+
}
|
|
2123
|
+
const newTxParams = getTransactionParamsWithIncreasedGasFee(
|
|
2124
|
+
transactionMeta.txParams,
|
|
2125
|
+
rate,
|
|
2126
|
+
gasValues
|
|
2127
|
+
);
|
|
2128
|
+
prepareTransactionParams?.(newTxParams);
|
|
2129
|
+
const unsignedEthTx = this.prepareUnsignedEthTx(
|
|
2130
|
+
transactionMeta.chainId,
|
|
2131
|
+
newTxParams
|
|
2132
|
+
);
|
|
2133
|
+
const signedTx = await this.sign(
|
|
2134
|
+
unsignedEthTx,
|
|
2135
|
+
transactionMeta.txParams.from
|
|
2136
|
+
);
|
|
2137
|
+
const transactionMetaWithRsv = this.updateTransactionMetaRSV(
|
|
2138
|
+
transactionMeta,
|
|
2139
|
+
signedTx
|
|
2140
|
+
);
|
|
2141
|
+
const rawTx = bufferToHex(signedTx.serialize());
|
|
2142
|
+
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
2143
|
+
const oldFee = newTxParams.maxFeePerGas ? transactionMetaWithRsv.txParams.maxFeePerGas : transactionMetaWithRsv.txParams.gasPrice;
|
|
2144
|
+
projectLogger(`Submitting ${label} transaction`, {
|
|
2145
|
+
oldFee,
|
|
2146
|
+
newFee,
|
|
2147
|
+
txParams: newTxParams
|
|
2148
|
+
});
|
|
2149
|
+
const ethQuery = __privateGet(this, _multichainTrackingHelper).getEthQuery({
|
|
2150
|
+
networkClientId: transactionMeta.networkClientId,
|
|
2151
|
+
chainId: transactionMeta.chainId
|
|
2152
|
+
});
|
|
2153
|
+
const hash = await this.publishTransactionForRetry(
|
|
2154
|
+
ethQuery,
|
|
2155
|
+
rawTx,
|
|
2156
|
+
transactionMeta
|
|
2157
|
+
);
|
|
2158
|
+
const newTransactionMeta = {
|
|
2159
|
+
...transactionMetaWithRsv,
|
|
2160
|
+
estimatedBaseFee,
|
|
2161
|
+
id: random(),
|
|
2162
|
+
time: Date.now(),
|
|
2163
|
+
hash,
|
|
2164
|
+
actionId,
|
|
2165
|
+
originalGasEstimate: transactionMeta.txParams.gas,
|
|
2166
|
+
type: transactionType,
|
|
2167
|
+
txParams: newTxParams,
|
|
2168
|
+
originalType: transactionMeta.type
|
|
2169
|
+
};
|
|
2170
|
+
this.addMetadata(newTransactionMeta);
|
|
2171
|
+
this.messagingSystem.publish(`${controllerName}:transactionApproved`, {
|
|
2172
|
+
transactionMeta: newTransactionMeta,
|
|
2173
|
+
actionId
|
|
2174
|
+
});
|
|
2175
|
+
this.messagingSystem.publish(`${controllerName}:transactionSubmitted`, {
|
|
2176
|
+
transactionMeta: newTransactionMeta,
|
|
2177
|
+
actionId
|
|
2178
|
+
});
|
|
2179
|
+
afterSubmit?.(newTransactionMeta);
|
|
2180
|
+
};
|
|
2279
2181
|
_createNonceTracker = new WeakSet();
|
|
2280
2182
|
createNonceTracker_fn = function({
|
|
2281
2183
|
provider,
|
|
@@ -2604,4 +2506,4 @@ export {
|
|
|
2604
2506
|
ApprovalState,
|
|
2605
2507
|
TransactionController
|
|
2606
2508
|
};
|
|
2607
|
-
//# sourceMappingURL=chunk-
|
|
2509
|
+
//# sourceMappingURL=chunk-XTMJ25EF.mjs.map
|