@metamask/transaction-controller 25.3.0 → 26.0.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 +23 -1
- package/dist/TransactionController.js +20 -18
- package/dist/TransactionController.mjs +19 -17
- package/dist/{chunk-UVKK5JBJ.mjs → chunk-35MG26Y3.mjs} +13 -12
- package/dist/chunk-35MG26Y3.mjs.map +1 -0
- package/dist/{chunk-R7NJVDWN.js → chunk-5WFLNKCL.js} +7 -6
- package/dist/chunk-5WFLNKCL.js.map +1 -0
- package/dist/{chunk-US7NQPYE.js → chunk-6V2LR6JL.js} +7 -7
- package/dist/{chunk-CSQPJCBP.mjs → chunk-7HNSDVVO.mjs} +3 -3
- package/dist/{chunk-BYBPZUHS.mjs → chunk-A4P4B3OF.mjs} +14 -6
- package/dist/chunk-A4P4B3OF.mjs.map +1 -0
- package/dist/{chunk-M6Q3DVMJ.mjs → chunk-APJWB5VY.mjs} +61 -26
- package/dist/chunk-APJWB5VY.mjs.map +1 -0
- package/dist/{chunk-F3CMU2DM.js → chunk-C3UHJPYJ.js} +6 -6
- package/dist/{chunk-Z3HHSD5I.mjs → chunk-DTMKGTYC.mjs} +3 -2
- package/dist/chunk-DTMKGTYC.mjs.map +1 -0
- package/dist/{chunk-MXQLW52B.js → chunk-FK7AP6SH.js} +10 -2
- package/dist/chunk-FK7AP6SH.js.map +1 -0
- package/dist/{chunk-ZQFMTLZJ.mjs → chunk-FTB6MCSH.mjs} +39 -24
- package/dist/chunk-FTB6MCSH.mjs.map +1 -0
- package/dist/{chunk-7QOACSQU.js → chunk-GASIS3QH.js} +74 -39
- package/dist/chunk-GASIS3QH.js.map +1 -0
- package/dist/{chunk-RQKICZYP.js → chunk-GRQB2ARK.js} +3 -3
- package/dist/{chunk-XKNFL657.mjs → chunk-HLG525BC.mjs} +2 -2
- package/dist/chunk-HMOSP33F.js +36 -0
- package/dist/chunk-HMOSP33F.js.map +1 -0
- package/dist/chunk-HQSNKCXI.mjs +36 -0
- package/dist/chunk-HQSNKCXI.mjs.map +1 -0
- package/dist/{chunk-7YLATOE4.js → chunk-HUVOOFOM.js} +15 -14
- package/dist/chunk-HUVOOFOM.js.map +1 -0
- package/dist/{chunk-NRWEI43Q.js → chunk-I7VD6IET.js} +40 -25
- package/dist/chunk-I7VD6IET.js.map +1 -0
- package/dist/chunk-JW6P2G5A.mjs +132 -0
- package/dist/chunk-JW6P2G5A.mjs.map +1 -0
- package/dist/{chunk-6XMG522E.mjs → chunk-K4KOSAGM.mjs} +8 -3
- package/dist/chunk-K4KOSAGM.mjs.map +1 -0
- package/dist/{chunk-PVO55HHW.mjs → chunk-KKCD5UMP.mjs} +3 -3
- package/dist/{chunk-GE57YNGX.js → chunk-KT6UAKBB.js} +8 -3
- package/dist/chunk-KT6UAKBB.js.map +1 -0
- package/dist/chunk-QG2WVQE3.js +132 -0
- package/dist/chunk-QG2WVQE3.js.map +1 -0
- package/dist/{chunk-5OQ373JS.js → chunk-QTQSCTQA.js} +10 -10
- package/dist/{chunk-VEREDMI2.mjs → chunk-RIYIJTEU.mjs} +2 -2
- package/dist/{chunk-IZI7FQIN.mjs → chunk-RU6NJIUD.mjs} +3 -3
- package/dist/{chunk-3D3SA6PY.mjs → chunk-TJXPMOA6.mjs} +2 -2
- package/dist/{chunk-HXPG3DIX.mjs → chunk-TWND5SFD.mjs} +2 -2
- package/dist/{chunk-Z4FIWEAJ.mjs → chunk-TZEAWUXE.mjs} +3 -3
- package/dist/{chunk-GQYELPS3.js → chunk-UH7FNVKS.js} +4 -4
- package/dist/{chunk-SSYRMQ63.js → chunk-UUSYJGGQ.js} +5 -5
- package/dist/{chunk-GC77BSQZ.js → chunk-V5X6MZHN.js} +16 -8
- package/dist/chunk-V5X6MZHN.js.map +1 -0
- package/dist/{chunk-CXXGL43K.js → chunk-VP2DBWOT.js} +3 -3
- package/dist/{chunk-KFL2GGZC.mjs → chunk-W3CS5GRD.mjs} +7 -6
- package/dist/chunk-W3CS5GRD.mjs.map +1 -0
- package/dist/{chunk-ITDY6AIZ.js → chunk-WIZVJM2B.js} +3 -2
- package/dist/chunk-WIZVJM2B.js.map +1 -0
- package/dist/{chunk-CWJBSWH3.js → chunk-XZILQVNW.js} +6 -6
- package/dist/{chunk-LADOJTK4.mjs → chunk-YEJJKWT2.mjs} +10 -2
- package/dist/chunk-YEJJKWT2.mjs.map +1 -0
- package/dist/constants.js +2 -2
- package/dist/constants.mjs +1 -1
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +15 -0
- package/dist/errors.mjs.map +1 -0
- 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/OptimismLayer1GasFeeFlow.js +10 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +10 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.js +5 -5
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +4 -4
- package/dist/helpers/GasFeePoller.js +5 -5
- package/dist/helpers/GasFeePoller.mjs +4 -4
- package/dist/helpers/MultichainTrackingHelper.js +6 -6
- package/dist/helpers/MultichainTrackingHelper.mjs +5 -5
- package/dist/helpers/PendingTransactionTracker.js +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +1 -1
- package/dist/index.js +24 -20
- package/dist/index.mjs +23 -19
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts +8 -0
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/errors.d.ts +15 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts +10 -0
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +1 -0
- package/dist/types/helpers/GasFeePoller.d.ts +4 -5
- package/dist/types/helpers/GasFeePoller.d.ts.map +1 -1
- package/dist/types/helpers/MultichainTrackingHelper.d.ts +4 -0
- package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +10 -6
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/layer1-gas-fee-flow.d.ts +11 -2
- package/dist/types/utils/layer1-gas-fee-flow.d.ts.map +1 -1
- package/dist/types/utils/simulation-api.d.ts.map +1 -1
- package/dist/types/utils/simulation.d.ts.map +1 -1
- package/dist/types.js +4 -2
- package/dist/types.mjs +3 -1
- package/dist/utils/etherscan.js +3 -3
- package/dist/utils/etherscan.mjs +2 -2
- 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/gas.js +3 -3
- package/dist/utils/gas.mjs +2 -2
- package/dist/utils/layer1-gas-fee-flow.js +4 -2
- package/dist/utils/layer1-gas-fee-flow.mjs +3 -1
- package/dist/utils/simulation-api.js +4 -2
- package/dist/utils/simulation-api.mjs +3 -1
- package/dist/utils/simulation.js +5 -4
- package/dist/utils/simulation.mjs +4 -3
- 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 +1 -1
- package/dist/utils/utils.mjs +1 -1
- package/dist/utils/validation.js +1 -1
- package/dist/utils/validation.mjs +1 -1
- package/package.json +6 -4
- package/dist/chunk-6XMG522E.mjs.map +0 -1
- package/dist/chunk-7QOACSQU.js.map +0 -1
- package/dist/chunk-7YLATOE4.js.map +0 -1
- package/dist/chunk-BYBPZUHS.mjs.map +0 -1
- package/dist/chunk-GC77BSQZ.js.map +0 -1
- package/dist/chunk-GE57YNGX.js.map +0 -1
- package/dist/chunk-ITDY6AIZ.js.map +0 -1
- package/dist/chunk-KFL2GGZC.mjs.map +0 -1
- package/dist/chunk-LADOJTK4.mjs.map +0 -1
- package/dist/chunk-M6Q3DVMJ.mjs.map +0 -1
- package/dist/chunk-MXQLW52B.js.map +0 -1
- package/dist/chunk-NRWEI43Q.js.map +0 -1
- package/dist/chunk-R7NJVDWN.js.map +0 -1
- package/dist/chunk-UVKK5JBJ.mjs.map +0 -1
- package/dist/chunk-Z3HHSD5I.mjs.map +0 -1
- package/dist/chunk-ZQFMTLZJ.mjs.map +0 -1
- /package/dist/{chunk-US7NQPYE.js.map → chunk-6V2LR6JL.js.map} +0 -0
- /package/dist/{chunk-CSQPJCBP.mjs.map → chunk-7HNSDVVO.mjs.map} +0 -0
- /package/dist/{chunk-F3CMU2DM.js.map → chunk-C3UHJPYJ.js.map} +0 -0
- /package/dist/{chunk-RQKICZYP.js.map → chunk-GRQB2ARK.js.map} +0 -0
- /package/dist/{chunk-XKNFL657.mjs.map → chunk-HLG525BC.mjs.map} +0 -0
- /package/dist/{chunk-PVO55HHW.mjs.map → chunk-KKCD5UMP.mjs.map} +0 -0
- /package/dist/{chunk-5OQ373JS.js.map → chunk-QTQSCTQA.js.map} +0 -0
- /package/dist/{chunk-VEREDMI2.mjs.map → chunk-RIYIJTEU.mjs.map} +0 -0
- /package/dist/{chunk-IZI7FQIN.mjs.map → chunk-RU6NJIUD.mjs.map} +0 -0
- /package/dist/{chunk-3D3SA6PY.mjs.map → chunk-TJXPMOA6.mjs.map} +0 -0
- /package/dist/{chunk-HXPG3DIX.mjs.map → chunk-TWND5SFD.mjs.map} +0 -0
- /package/dist/{chunk-Z4FIWEAJ.mjs.map → chunk-TZEAWUXE.mjs.map} +0 -0
- /package/dist/{chunk-GQYELPS3.js.map → chunk-UH7FNVKS.js.map} +0 -0
- /package/dist/{chunk-SSYRMQ63.js.map → chunk-UUSYJGGQ.js.map} +0 -0
- /package/dist/{chunk-CXXGL43K.js.map → chunk-VP2DBWOT.js.map} +0 -0
- /package/dist/{chunk-CWJBSWH3.js.map → chunk-XZILQVNW.js.map} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkUGFBA4GVjs = require('./chunk-UGFBA4GV.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkWIZVJM2Bjs = require('./chunk-WIZVJM2B.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -57,15 +57,15 @@ var ZKSYNC_ERA_SWAPS_TOKEN_OBJECT = {
|
|
|
57
57
|
...ETH_SWAPS_TOKEN_OBJECT
|
|
58
58
|
};
|
|
59
59
|
var SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {
|
|
60
|
-
[
|
|
60
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.MAINNET]: ETH_SWAPS_TOKEN_OBJECT,
|
|
61
61
|
[SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT,
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
62
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.BSC]: BNB_SWAPS_TOKEN_OBJECT,
|
|
63
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.POLYGON]: MATIC_SWAPS_TOKEN_OBJECT,
|
|
64
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.GOERLI]: GOERLI_SWAPS_TOKEN_OBJECT,
|
|
65
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.AVALANCHE]: AVAX_SWAPS_TOKEN_OBJECT,
|
|
66
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.OPTIMISM]: OPTIMISM_SWAPS_TOKEN_OBJECT,
|
|
67
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.ARBITRUM]: ARBITRUM_SWAPS_TOKEN_OBJECT,
|
|
68
|
+
[_chunkWIZVJM2Bjs.CHAIN_IDS.ZKSYNC_ERA]: ZKSYNC_ERA_SWAPS_TOKEN_OBJECT
|
|
69
69
|
};
|
|
70
70
|
var SWAP_TRANSACTION_TYPES = [
|
|
71
71
|
"swap" /* swap */,
|
|
@@ -208,4 +208,4 @@ function sleep(ms) {
|
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
exports.UPDATE_POST_TX_BALANCE_TIMEOUT = UPDATE_POST_TX_BALANCE_TIMEOUT; exports.UPDATE_POST_TX_BALANCE_ATTEMPTS = UPDATE_POST_TX_BALANCE_ATTEMPTS; exports.DEFAULT_TOKEN_ADDRESS = DEFAULT_TOKEN_ADDRESS; exports.SWAPS_CHAINID_DEFAULT_TOKEN_MAP = SWAPS_CHAINID_DEFAULT_TOKEN_MAP; exports.SWAP_TRANSACTION_TYPES = SWAP_TRANSACTION_TYPES; exports.updateSwapsTransaction = updateSwapsTransaction; exports.updatePostTransactionBalance = updatePostTransactionBalance;
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-QTQSCTQA.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ETHERSCAN_SUPPORTED_NETWORKS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DTMKGTYC.mjs";
|
|
4
4
|
import {
|
|
5
5
|
incomingTransactionsLogger
|
|
6
6
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -82,4 +82,4 @@ export {
|
|
|
82
82
|
fetchEtherscanTokenTransactions,
|
|
83
83
|
getEtherscanApiHost
|
|
84
84
|
};
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-RIYIJTEU.mjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchEtherscanTokenTransactions,
|
|
3
3
|
fetchEtherscanTransactions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RIYIJTEU.mjs";
|
|
5
5
|
import {
|
|
6
6
|
ETHERSCAN_SUPPORTED_NETWORKS
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DTMKGTYC.mjs";
|
|
8
8
|
import {
|
|
9
9
|
incomingTransactionsLogger
|
|
10
10
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -167,4 +167,4 @@ normalizeTransactionBase_fn = function(txMeta, currentChainId) {
|
|
|
167
167
|
export {
|
|
168
168
|
EtherscanRemoteTransactionSource
|
|
169
169
|
};
|
|
170
|
-
//# sourceMappingURL=chunk-
|
|
170
|
+
//# sourceMappingURL=chunk-RU6NJIUD.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-J56A7UCK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CHAIN_IDS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DTMKGTYC.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createModuleLogger,
|
|
9
9
|
projectLogger
|
|
@@ -208,4 +208,4 @@ export {
|
|
|
208
208
|
updateSwapsTransaction,
|
|
209
209
|
updatePostTransactionBalance
|
|
210
210
|
};
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-TJXPMOA6.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GasFeeEstimateLevel
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YEJJKWT2.mjs";
|
|
4
4
|
|
|
5
5
|
// src/utils/gas-flow.ts
|
|
6
6
|
import { weiHexToGweiDec } from "@metamask/controller-utils";
|
|
@@ -59,4 +59,4 @@ export {
|
|
|
59
59
|
getGasFeeFlow,
|
|
60
60
|
mergeGasFeeEstimates
|
|
61
61
|
};
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-TWND5SFD.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SWAP_TRANSACTION_TYPES
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TJXPMOA6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getGasFeeFlow
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TWND5SFD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
projectLogger
|
|
9
9
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -205,4 +205,4 @@ export {
|
|
|
205
205
|
updateGasFees,
|
|
206
206
|
gweiDecimalToWeiHex
|
|
207
207
|
};
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-TZEAWUXE.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkFK7AP6SHjs = require('./chunk-FK7AP6SH.js');
|
|
4
4
|
|
|
5
5
|
// src/utils/gas-flow.ts
|
|
6
6
|
var _controllerutils = require('@metamask/controller-utils');
|
|
@@ -18,7 +18,7 @@ function mergeGasFeeEstimates({
|
|
|
18
18
|
transactionGasFeeEstimates
|
|
19
19
|
}) {
|
|
20
20
|
if (gasFeeControllerEstimateType === _gasfeecontroller.GAS_ESTIMATE_TYPES.FEE_MARKET) {
|
|
21
|
-
return Object.values(
|
|
21
|
+
return Object.values(_chunkFK7AP6SHjs.GasFeeEstimateLevel).reduce(
|
|
22
22
|
(result, level) => ({
|
|
23
23
|
...result,
|
|
24
24
|
[level]: mergeFeeMarketEstimate(
|
|
@@ -30,7 +30,7 @@ function mergeGasFeeEstimates({
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
if (gasFeeControllerEstimateType === _gasfeecontroller.GAS_ESTIMATE_TYPES.LEGACY) {
|
|
33
|
-
return Object.values(
|
|
33
|
+
return Object.values(_chunkFK7AP6SHjs.GasFeeEstimateLevel).reduce(
|
|
34
34
|
(result, level) => ({
|
|
35
35
|
...result,
|
|
36
36
|
[level]: getLegacyEstimate(transactionGasFeeEstimates[level])
|
|
@@ -59,4 +59,4 @@ function getLegacyEstimate(transactionGasFeeEstimate) {
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
exports.getGasFeeFlow = getGasFeeFlow; exports.mergeGasFeeEstimates = mergeGasFeeEstimates;
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-UH7FNVKS.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQTQSCTQAjs = require('./chunk-QTQSCTQA.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkUH7FNVKSjs = require('./chunk-UH7FNVKS.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -20,7 +20,7 @@ var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger,
|
|
|
20
20
|
async function updateGasFees(request) {
|
|
21
21
|
const { txMeta } = request;
|
|
22
22
|
const initialParams = { ...txMeta.txParams };
|
|
23
|
-
const isSwap =
|
|
23
|
+
const isSwap = _chunkQTQSCTQAjs.SWAP_TRANSACTION_TYPES.includes(
|
|
24
24
|
txMeta.type
|
|
25
25
|
);
|
|
26
26
|
const savedGasFees = isSwap ? void 0 : request.getSavedGasFees(txMeta.chainId);
|
|
@@ -185,7 +185,7 @@ async function getSuggestedGasFees(request) {
|
|
|
185
185
|
if (!eip1559 && txMeta.txParams.gasPrice || eip1559 && txMeta.txParams.maxFeePerGas && txMeta.txParams.maxPriorityFeePerGas) {
|
|
186
186
|
return {};
|
|
187
187
|
}
|
|
188
|
-
const gasFeeFlow =
|
|
188
|
+
const gasFeeFlow = _chunkUH7FNVKSjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
|
|
189
189
|
try {
|
|
190
190
|
const response = await gasFeeFlow.getGasFees({
|
|
191
191
|
ethQuery,
|
|
@@ -205,4 +205,4 @@ async function getSuggestedGasFees(request) {
|
|
|
205
205
|
|
|
206
206
|
|
|
207
207
|
exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-UUSYJGGQ.js.map
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKT6UAKBBjs = require('./chunk-KT6UAKBB.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkHMOSP33Fjs = require('./chunk-HMOSP33F.js');
|
|
4
9
|
|
|
5
10
|
|
|
6
11
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -11,11 +16,12 @@ var _controllerutils = require('@metamask/controller-utils');
|
|
|
11
16
|
var _metamaskethabis = require('@metamask/metamask-eth-abis');
|
|
12
17
|
var _utils = require('@metamask/utils');
|
|
13
18
|
var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger, "simulation");
|
|
19
|
+
var REVERTED_ERRORS = ["execution reverted", "insufficient funds for gas"];
|
|
14
20
|
async function getSimulationData(request) {
|
|
15
21
|
const { chainId, from, to, value, data } = request;
|
|
16
22
|
log("Getting simulation data", request);
|
|
17
23
|
try {
|
|
18
|
-
const response = await
|
|
24
|
+
const response = await _chunkKT6UAKBBjs.simulateTransactions.call(void 0, chainId, {
|
|
19
25
|
transactions: [
|
|
20
26
|
{
|
|
21
27
|
data,
|
|
@@ -30,8 +36,11 @@ async function getSimulationData(request) {
|
|
|
30
36
|
withLogs: true
|
|
31
37
|
});
|
|
32
38
|
const transactionError = response.transactions?.[0]?.error;
|
|
39
|
+
if (REVERTED_ERRORS.some((error) => transactionError?.includes(error))) {
|
|
40
|
+
throw new (0, _chunkHMOSP33Fjs.SimulationRevertedError)();
|
|
41
|
+
}
|
|
33
42
|
if (transactionError) {
|
|
34
|
-
throw
|
|
43
|
+
throw new (0, _chunkHMOSP33Fjs.SimulationError)(transactionError);
|
|
35
44
|
}
|
|
36
45
|
const nativeBalanceChange = getNativeBalanceChange(request.from, response);
|
|
37
46
|
const events = getEvents(response);
|
|
@@ -48,8 +57,7 @@ async function getSimulationData(request) {
|
|
|
48
57
|
tokenBalanceChanges: [],
|
|
49
58
|
error: {
|
|
50
59
|
code: rawError.code,
|
|
51
|
-
message: rawError.message
|
|
52
|
-
isReverted: rawError.message?.includes("execution reverted") ?? false
|
|
60
|
+
message: rawError.message
|
|
53
61
|
}
|
|
54
62
|
};
|
|
55
63
|
}
|
|
@@ -125,12 +133,12 @@ async function getTokenBalanceChanges(request, events) {
|
|
|
125
133
|
if (!balanceTransactions.length) {
|
|
126
134
|
return [];
|
|
127
135
|
}
|
|
128
|
-
const response = await
|
|
136
|
+
const response = await _chunkKT6UAKBBjs.simulateTransactions.call(void 0, request.chainId, {
|
|
129
137
|
transactions: [...balanceTransactions, request, ...balanceTransactions]
|
|
130
138
|
});
|
|
131
139
|
log("Balance simulation response", response);
|
|
132
140
|
if (response.transactions.length !== balanceTransactions.length * 2 + 1) {
|
|
133
|
-
throw new
|
|
141
|
+
throw new (0, _chunkHMOSP33Fjs.SimulationInvalidResponseError)();
|
|
134
142
|
}
|
|
135
143
|
return [...balanceTransactionsByToken.keys()].map((token, index) => {
|
|
136
144
|
const previousBalance = normalizeReturnValue(
|
|
@@ -262,4 +270,4 @@ function normalizeReturnValue(value) {
|
|
|
262
270
|
|
|
263
271
|
|
|
264
272
|
exports.getSimulationData = getSimulationData;
|
|
265
|
-
//# sourceMappingURL=chunk-
|
|
273
|
+
//# sourceMappingURL=chunk-V5X6MZHN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/simulation.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,aAAa;AAC/B,SAAS,UAAU,WAAW,kBAAkB;AAChD,SAAS,0BAAoC;AAuB7C,IAAM,MAAM,mBAAmB,eAAe,YAAY;AAE1D,IAAM,kBAAkB,CAAC,sBAAsB,4BAA4B;AA8B3E,eAAsB,kBACpB,SACyB;AACzB,QAAM,EAAE,SAAS,MAAM,IAAI,OAAO,KAAK,IAAI;AAE3C,MAAI,2BAA2B,OAAO;AAEtC,MAAI;AACF,UAAM,WAAW,MAAM,qBAAqB,SAAS;AAAA,MACnD,cAAc;AAAA,QACZ;AAAA,UACE;AAAA,UACA;AAAA,UACA,cAAc;AAAA,UACd,sBAAsB;AAAA,UACtB;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,MACA,eAAe;AAAA,MACf,UAAU;AAAA,IACZ,CAAC;AAED,UAAM,mBAAmB,SAAS,eAAe,CAAC,GAAG;AAErD,QAAI,gBAAgB,KAAK,CAAC,UAAU,kBAAkB,SAAS,KAAK,CAAC,GAAG;AACtE,YAAM,IAAI,wBAAwB;AAAA,IACpC;AAEA,QAAI,kBAAkB;AACpB,YAAM,IAAI,gBAAgB,gBAAgB;AAAA,IAC5C;AAEA,UAAM,sBAAsB,uBAAuB,QAAQ,MAAM,QAAQ;AACzE,UAAM,SAAS,UAAU,QAAQ;AAEjC,QAAI,iBAAiB,MAAM;AAE3B,UAAM,sBAAsB,MAAM,uBAAuB,SAAS,M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AAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAOA,SAAS,qBAAqB,OAAiB;AAC7C,SAAO,MAAM,QAAQ,KAAK,CAAC;AAC7B","sourcesContent":["import type { Fragment, LogDescription, Result } from '@ethersproject/abi';\nimport { Interface } from '@ethersproject/abi';\nimport { hexToBN, toHex } from '@metamask/controller-utils';\nimport { abiERC20, abiERC721, abiERC1155 } from '@metamask/metamask-eth-abis';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\n\nimport {\n SimulationError,\n SimulationInvalidResponseError,\n SimulationRevertedError,\n} from '../errors';\nimport { projectLogger } from '../logger';\nimport type {\n SimulationBalanceChange,\n SimulationData,\n SimulationTokenBalanceChange,\n SimulationToken,\n} from '../types';\nimport { SimulationTokenStandard } from '../types';\nimport { simulateTransactions } from './simulation-api';\nimport type {\n SimulationResponseLog,\n SimulationRequestTransaction,\n SimulationResponse,\n SimulationResponseCallTrace,\n} from './simulation-api';\n\nconst log = createModuleLogger(projectLogger, 'simulation');\n\nconst REVERTED_ERRORS = ['execution reverted', 'insufficient funds for gas'];\n\ntype ABI = Fragment[];\n\nexport type GetSimulationDataRequest = {\n chainId: Hex;\n from: Hex;\n to?: Hex;\n value?: Hex;\n data?: Hex;\n};\n\ntype ParsedEvent = {\n contractAddress: Hex;\n tokenStandard: SimulationTokenStandard;\n name: string;\n args: Record<string, Hex | Hex[]>;\n abi: ABI;\n};\n\n/**\n * Generate simulation data for a transaction.\n * @param request - The transaction to simulate.\n * @param request.chainId - The chain ID of the transaction.\n * @param request.from - The sender of the transaction.\n * @param request.to - The recipient of the transaction.\n * @param request.value - The value of the transaction.\n * @param request.data - The data of the transaction.\n * @returns The simulation data.\n */\nexport async function getSimulationData(\n request: GetSimulationDataRequest,\n): Promise<SimulationData> {\n const { chainId, from, to, value, data } = request;\n\n log('Getting simulation data', request);\n\n try {\n const response = await simulateTransactions(chainId, {\n transactions: [\n {\n data,\n from,\n maxFeePerGas: '0x0',\n maxPriorityFeePerGas: '0x0',\n to,\n value,\n },\n ],\n withCallTrace: true,\n withLogs: true,\n });\n\n const transactionError = response.transactions?.[0]?.error;\n\n if (REVERTED_ERRORS.some((error) => transactionError?.includes(error))) {\n throw new SimulationRevertedError();\n }\n\n if (transactionError) {\n throw new SimulationError(transactionError);\n }\n\n const nativeBalanceChange = getNativeBalanceChange(request.from, response);\n const events = getEvents(response);\n\n log('Parsed events', events);\n\n const tokenBalanceChanges = await getTokenBalanceChanges(request, events);\n\n return {\n nativeBalanceChange,\n tokenBalanceChanges,\n };\n } catch (error) {\n log('Failed to get simulation data', error, request);\n\n const rawError = error as { code?: number; message?: string };\n\n return {\n tokenBalanceChanges: [],\n error: {\n code: rawError.code,\n message: rawError.message,\n },\n };\n }\n}\n\n/**\n * Extract the native balance change from a simulation response.\n * @param userAddress - The user's account address.\n * @param response - The simulation response.\n * @returns The native balance change or undefined if unchanged.\n */\nfunction getNativeBalanceChange(\n userAddress: Hex,\n response: SimulationResponse,\n): SimulationBalanceChange | undefined {\n const transactionResponse = response.transactions[0];\n\n /* istanbul ignore next */\n if (!transactionResponse) {\n return undefined;\n }\n\n const { stateDiff } = transactionResponse;\n const previousBalance = stateDiff?.pre?.[userAddress]?.balance;\n const newBalance = stateDiff?.post?.[userAddress]?.balance;\n\n if (!previousBalance || !newBalance) {\n return undefined;\n }\n\n return getSimulationBalanceChange(previousBalance, newBalance);\n}\n\n/**\n * Extract events from a simulation response.\n * @param response - The simulation response.\n * @returns The parsed events.\n */\nfunction getEvents(response: SimulationResponse): ParsedEvent[] {\n /* istanbul ignore next */\n const logs = extractLogs(\n response.transactions[0]?.callTrace ?? ({} as SimulationResponseCallTrace),\n );\n\n log('Extracted logs', logs);\n\n const erc20Interface = new Interface(abiERC20);\n const erc721Interface = new Interface(abiERC721);\n const erc1155Interface = new Interface(abiERC1155);\n\n return logs\n .map((currentLog) => {\n const event = parseLog(\n currentLog,\n erc20Interface,\n erc721Interface,\n erc1155Interface,\n );\n\n if (!event) {\n log('Failed to parse log', currentLog);\n return undefined;\n }\n\n /* istanbul ignore next */\n const inputs = event.abi.find((e) => e.name === event.name)?.inputs;\n\n /* istanbul ignore if */\n if (!inputs) {\n log('Failed to find inputs for event', event);\n return undefined;\n }\n\n const args = parseEventArgs(event.args, inputs);\n\n return {\n contractAddress: currentLog.address,\n tokenStandard: event.standard,\n name: event.name,\n args,\n abi: event.abi,\n };\n })\n .filter((e) => e !== undefined) as ParsedEvent[];\n}\n\n/**\n * Parse event arguments using ABI input definitions.\n * @param args - The raw event arguments.\n * @param abiInputs - The ABI input definitions.\n * @returns The parsed event arguments.\n */\nfunction parseEventArgs(\n args: Result,\n abiInputs: { name: string }[],\n): Record<string, Hex | Hex[]> {\n return args.reduce((result, arg, index) => {\n const name = abiInputs[index].name.replace('_', '');\n const value = parseEventArgValue(arg);\n\n result[name] = value;\n\n return result;\n }, {});\n}\n\n/**\n * Parse an event argument value.\n * @param value - The event argument value.\n * @returns The parsed event argument value.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction parseEventArgValue(value: any): Hex | Hex[] {\n if (Array.isArray(value)) {\n return value.map(parseEventArgValue) as Hex[];\n }\n\n return (value.toHexString?.() ?? value).toLowerCase();\n}\n\n/**\n * Generate token balance changes from parsed events.\n * @param request - The transaction that was simulated.\n * @param events - The parsed events.\n * @returns An array of token balance changes.\n */\nasync function getTokenBalanceChanges(\n request: GetSimulationDataRequest,\n events: ParsedEvent[],\n): Promise<SimulationTokenBalanceChange[]> {\n const balanceTransactionsByToken = getTokenBalanceTransactions(\n request,\n events,\n );\n\n const balanceTransactions = [...balanceTransactionsByToken.values()];\n\n log('Generated balance transactions', balanceTransactions);\n\n if (!balanceTransactions.length) {\n return [];\n }\n\n const response = await simulateTransactions(request.chainId as Hex, {\n transactions: [...balanceTransactions, request, ...balanceTransactions],\n });\n\n log('Balance simulation response', response);\n\n if (response.transactions.length !== balanceTransactions.length * 2 + 1) {\n throw new SimulationInvalidResponseError();\n }\n\n return [...balanceTransactionsByToken.keys()]\n .map((token, index) => {\n const previousBalance = normalizeReturnValue(\n response.transactions[index].return,\n );\n\n const newBalance = normalizeReturnValue(\n response.transactions[index + balanceTransactions.length + 1].return,\n );\n\n const balanceChange = getSimulationBalanceChange(\n previousBalance,\n newBalance,\n );\n\n if (!balanceChange) {\n return undefined;\n }\n\n return {\n ...token,\n ...balanceChange,\n };\n })\n .filter((change) => change !== undefined) as SimulationTokenBalanceChange[];\n}\n\n/**\n * Generate transactions to check token balances.\n * @param request - The transaction that was simulated.\n * @param events - The parsed events.\n * @returns A map of token balance transactions keyed by token.\n */\nfunction getTokenBalanceTransactions(\n request: GetSimulationDataRequest,\n events: ParsedEvent[],\n): Map<SimulationToken, SimulationRequestTransaction> {\n const tokenKeys = new Set();\n\n return events.reduce((result, event) => {\n if (\n !['Transfer', 'TransferSingle', 'TransferBatch'].includes(event.name) ||\n ![event.args.from, event.args.to].includes(request.from)\n ) {\n log('Ignoring event', event);\n return result;\n }\n\n // ERC-20 does not have a token ID so default to undefined.\n let tokenIds: (Hex | undefined)[] = [undefined];\n\n if (event.tokenStandard === SimulationTokenStandard.erc721) {\n tokenIds = [event.args.tokenId as Hex];\n }\n\n if (\n event.tokenStandard === SimulationTokenStandard.erc1155 &&\n event.name === 'TransferSingle'\n ) {\n tokenIds = [event.args.id as Hex];\n }\n\n if (\n event.tokenStandard === SimulationTokenStandard.erc1155 &&\n event.name === 'TransferBatch'\n ) {\n tokenIds = event.args.ids as Hex[];\n }\n\n log('Extracted token ids', tokenIds);\n\n for (const tokenId of tokenIds) {\n const simulationToken: SimulationToken = {\n address: event.contractAddress,\n standard: event.tokenStandard,\n id: tokenId,\n };\n\n const tokenKey = JSON.stringify(simulationToken);\n\n if (tokenKeys.has(tokenKey)) {\n log(\n 'Ignoring additional event with same contract and token ID',\n simulationToken,\n );\n continue;\n }\n\n tokenKeys.add(tokenKey);\n\n const parameters = [request.from];\n\n if (event.tokenStandard === SimulationTokenStandard.erc1155) {\n parameters.push(tokenId as Hex);\n }\n\n result.set(simulationToken, {\n from: request.from,\n to: event.contractAddress,\n data: new Interface(event.abi).encodeFunctionData(\n 'balanceOf',\n parameters,\n ) as Hex,\n });\n }\n\n return result;\n }, new Map<SimulationToken, SimulationRequestTransaction>());\n}\n\n/**\n * Parse a raw event log using known ABIs.\n * @param eventLog - The raw event log.\n * @param erc20 - The ERC-20 ABI interface.\n * @param erc721 - The ERC-721 ABI interface.\n * @param erc1155 - The ERC-1155 ABI interface.\n * @returns The parsed event log or undefined if it could not be parsed.\n */\nfunction parseLog(\n eventLog: SimulationResponseLog,\n erc20: Interface,\n erc721: Interface,\n erc1155: Interface,\n):\n | (LogDescription & { abi: ABI; standard: SimulationTokenStandard })\n | undefined {\n const abisByStandard = [\n {\n abi: abiERC20,\n contractInterface: erc20,\n standard: SimulationTokenStandard.erc20,\n },\n {\n abi: abiERC721,\n contractInterface: erc721,\n standard: SimulationTokenStandard.erc721,\n },\n {\n abi: abiERC1155,\n contractInterface: erc1155,\n standard: SimulationTokenStandard.erc1155,\n },\n ];\n\n for (const { abi, contractInterface, standard } of abisByStandard) {\n try {\n return {\n ...contractInterface.parseLog(eventLog),\n abi,\n standard,\n };\n } catch (e) {\n continue;\n }\n }\n\n return undefined;\n}\n\n/**\n * Extract all logs from a call trace tree.\n * @param call - The root call trace.\n * @returns An array of logs.\n */\nfunction extractLogs(\n call: SimulationResponseCallTrace,\n): SimulationResponseLog[] {\n /* istanbul ignore next */\n const logs = call.logs ?? [];\n\n /* istanbul ignore next */\n const nestedCalls = call.calls ?? [];\n\n return [\n ...logs,\n ...nestedCalls.map((nestedCall) => extractLogs(nestedCall)).flat(),\n ];\n}\n\n/**\n * Generate balance change data from previous and new balances.\n * @param previousBalance - The previous balance.\n * @param newBalance - The new balance.\n * @returns The balance change data or undefined if unchanged.\n */\nfunction getSimulationBalanceChange(\n previousBalance: Hex,\n newBalance: Hex,\n): SimulationBalanceChange | undefined {\n const differenceBN = hexToBN(newBalance).sub(hexToBN(previousBalance));\n const isDecrease = differenceBN.isNeg();\n const difference = toHex(differenceBN.abs());\n\n if (differenceBN.isZero()) {\n log('Balance change is zero');\n return undefined;\n }\n\n return {\n previousBalance,\n newBalance,\n difference,\n isDecrease,\n };\n}\n\n/**\n * Normalize a return value.\n * @param value - The return value to normalize.\n * @returns The normalized return value.\n */\nfunction normalizeReturnValue(value: Hex): Hex {\n return toHex(hexToBN(value));\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWIZVJM2Bjs = require('./chunk-WIZVJM2B.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -70,7 +70,7 @@ function getEtherscanApiUrl(chainId, urlParams) {
|
|
|
70
70
|
return url;
|
|
71
71
|
}
|
|
72
72
|
function getEtherscanApiHost(chainId) {
|
|
73
|
-
const networkInfo =
|
|
73
|
+
const networkInfo = _chunkWIZVJM2Bjs.ETHERSCAN_SUPPORTED_NETWORKS[chainId];
|
|
74
74
|
if (!networkInfo) {
|
|
75
75
|
throw new Error(`Etherscan does not support chain with ID: ${chainId}`);
|
|
76
76
|
}
|
|
@@ -82,4 +82,4 @@ function getEtherscanApiHost(chainId) {
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
exports.fetchEtherscanTransactions = fetchEtherscanTransactions; exports.fetchEtherscanTokenTransactions = fetchEtherscanTokenTransactions; exports.getEtherscanApiHost = getEtherscanApiHost;
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-VP2DBWOT.js.map
|
|
@@ -18,9 +18,9 @@ function getLayer1GasFeeFlow(transactionMeta, layer1GasFeeFlows) {
|
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
async function getTransactionLayer1GasFee({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
layer1GasFeeFlows,
|
|
22
|
+
provider,
|
|
23
|
+
transactionMeta
|
|
24
24
|
}) {
|
|
25
25
|
const layer1GasFeeFlow = getLayer1GasFeeFlow(
|
|
26
26
|
transactionMeta,
|
|
@@ -32,7 +32,7 @@ async function getTransactionLayer1GasFee({
|
|
|
32
32
|
}
|
|
33
33
|
try {
|
|
34
34
|
const { layer1Fee } = await layer1GasFeeFlow.getLayer1Fee({
|
|
35
|
-
|
|
35
|
+
provider,
|
|
36
36
|
transactionMeta
|
|
37
37
|
});
|
|
38
38
|
return layer1Fee;
|
|
@@ -43,6 +43,7 @@ async function getTransactionLayer1GasFee({
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export {
|
|
46
|
-
updateTransactionLayer1GasFee
|
|
46
|
+
updateTransactionLayer1GasFee,
|
|
47
|
+
getTransactionLayer1GasFee
|
|
47
48
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-W3CS5GRD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/layer1-gas-fee-flow.ts"],"sourcesContent":["import type { Provider } from '@metamask/network-controller';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type { Layer1GasFeeFlow, TransactionMeta } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'layer-1-gas-fee-flow');\n\nexport type UpdateLayer1GasFeeRequest = {\n layer1GasFeeFlows: Layer1GasFeeFlow[];\n provider: Provider;\n transactionMeta: TransactionMeta;\n};\n\n/**\n * Updates the given transactionMeta with the layer 1 gas fee.\n * @param request - The request to use when getting the layer 1 gas fee.\n * @param request.provider - Provider used to create a new underlying EthQuery instance\n * @param request.transactionMeta - The transaction to get the layer 1 gas fee for.\n * @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.\n */\nexport async function updateTransactionLayer1GasFee(\n request: UpdateLayer1GasFeeRequest,\n) {\n const layer1GasFee = await getTransactionLayer1GasFee(request);\n\n if (layer1GasFee) {\n const { transactionMeta } = request;\n transactionMeta.layer1GasFee = layer1GasFee;\n }\n}\n\n/**\n * Get the layer 1 gas fee flow for a transaction.\n * @param transactionMeta - The transaction to get the layer 1 gas fee flow for.\n * @param layer1GasFeeFlows - The layer 1 gas fee flows to search.\n * @returns The layer 1 gas fee flow for the transaction, or undefined if none match.\n */\nfunction getLayer1GasFeeFlow(\n transactionMeta: TransactionMeta,\n layer1GasFeeFlows: Layer1GasFeeFlow[],\n): Layer1GasFeeFlow | undefined {\n return layer1GasFeeFlows.find((layer1GasFeeFlow) =>\n layer1GasFeeFlow.matchesTransaction(transactionMeta),\n );\n}\n\n/**\n * Get the layer 1 gas fee for a transaction and return the layer1Fee.\n * @param request - The request to use when getting the layer 1 gas fee.\n * @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.\n * @param request.provider - The provider to use to get the layer 1 gas fee.\n * @param request.transactionMeta - The transaction to get the layer 1 gas fee for.\n */\nexport async function getTransactionLayer1GasFee({\n layer1GasFeeFlows,\n provider,\n transactionMeta,\n}: UpdateLayer1GasFeeRequest): Promise<Hex | undefined> {\n const layer1GasFeeFlow = getLayer1GasFeeFlow(\n transactionMeta,\n layer1GasFeeFlows,\n );\n if (!layer1GasFeeFlow) {\n log('Layer 1 gas fee flow not found', transactionMeta.id);\n return undefined;\n }\n\n try {\n const { layer1Fee } = await layer1GasFeeFlow.getLayer1Fee({\n provider,\n transactionMeta,\n });\n return layer1Fee;\n } catch (error) {\n log('Failed to get layer 1 gas fee', transactionMeta.id, error);\n return undefined;\n }\n}\n"],"mappings":";;;;;AACA,SAAS,0BAAoC;AAK7C,IAAM,MAAM,mBAAmB,eAAe,sBAAsB;AAepE,eAAsB,8BACpB,SACA;AACA,QAAM,eAAe,MAAM,2BAA2B,OAAO;AAE7D,MAAI,cAAc;AAChB,UAAM,EAAE,gBAAgB,IAAI;AAC5B,oBAAgB,eAAe;AAAA,EACjC;AACF;AAQA,SAAS,oBACP,iBACA,mBAC8B;AAC9B,SAAO,kBAAkB;AAAA,IAAK,CAAC,qBAC7B,iBAAiB,mBAAmB,eAAe;AAAA,EACrD;AACF;AASA,eAAsB,2BAA2B;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AACF,GAAwD;AACtD,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,MAAI,CAAC,kBAAkB;AACrB,QAAI,kCAAkC,gBAAgB,EAAE;AACxD,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,EAAE,UAAU,IAAI,MAAM,iBAAiB,aAAa;AAAA,MACxD;AAAA,MACA;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI,iCAAiC,gBAAgB,IAAI,KAAK;AAC9D,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -26,7 +26,8 @@ var CHAIN_IDS = {
|
|
|
26
26
|
MOONRIVER: "0x505",
|
|
27
27
|
GNOSIS: "0x64",
|
|
28
28
|
ARBITRUM: "0xa4b1",
|
|
29
|
-
ZKSYNC_ERA: "0x144"
|
|
29
|
+
ZKSYNC_ERA: "0x144",
|
|
30
|
+
ZORA: "0x76adf1"
|
|
30
31
|
};
|
|
31
32
|
var DEFAULT_ETHERSCAN_DOMAIN = "etherscan.io";
|
|
32
33
|
var DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = "api";
|
|
@@ -124,4 +125,4 @@ var GAS_BUFFER_CHAIN_OVERRIDES = {
|
|
|
124
125
|
|
|
125
126
|
|
|
126
127
|
exports.CHAIN_IDS = CHAIN_IDS; exports.DEFAULT_ETHERSCAN_DOMAIN = DEFAULT_ETHERSCAN_DOMAIN; exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX; exports.ETHERSCAN_SUPPORTED_NETWORKS = ETHERSCAN_SUPPORTED_NETWORKS; exports.GAS_BUFFER_CHAIN_OVERRIDES = GAS_BUFFER_CHAIN_OVERRIDES;
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
128
|
+
//# sourceMappingURL=chunk-WIZVJM2B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"names":[],"mappings":";AAAO,IAAM,YAAY;AAAA,EACvB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,cAAc;AAAA,EACd,KAAK;AAAA,EACL,aAAa;AAAA,EACb,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,cAAc;AAAA,EACd,eAAe;AAAA,EACf,eAAe;AAAA,EACf,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,MAAM;AACR;AAEO,IAAM,2BAA2B;AACjC,IAAM,qCAAqC;AAE3C,IAAM,+BAA+B;AAAA,EAC1C,CAAC,UAAU,MAAM,GAAG;AAAA,IAClB,QAAQ;AAAA,IACR,WAAW,GAAG,kCAAkC;AAAA,EAClD;AAAA,EACA,CAAC,UAAU,OAAO,GAAG;AAAA,IACnB,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAAA,EACA,CAAC,UAAU,OAAO,GAAG;AAAA,IACnB,QAAQ;AAAA,IACR,WAAW,GAAG,kCAAkC;AAAA,EAClD;AAAA,EACA,CAAC,UAAU,YAAY,GAAG;AAAA,IACxB,QAAQ;AAAA,IACR,WAAW,GAAG,kCAAkC;AAAA,EAClD;AAAA,EACA,CAAC,UAAU,a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;AAAA,IACR,WAAW,GAAG,kCAAkC;AAAA,EAClD;AAAA,EACA,CAAC,UAAU,SAAS,GAAG;AAAA,IACrB,QAAQ;AAAA,IACR,WAAW,GAAG,kCAAkC;AAAA,EAClD;AAAA,EACA,CAAC,UAAU,MAAM,GAAG;AAAA,IAClB,QAAQ;AAAA,IACR,WAAW,GAAG,kCAAkC;AAAA,EAClD;AACF;AAEO,IAAM,6BAA6B;AAAA,EACxC,CAAC,UAAU,QAAQ,GAAG;AAAA,EACtB,CAAC,UAAU,gBAAgB,GAAG;AAChC","sourcesContent":["export const CHAIN_IDS = {\n MAINNET: '0x1',\n GOERLI: '0x5',\n BASE: '0x2105',\n BASE_TESTNET: '0x14a33',\n BSC: '0x38',\n BSC_TESTNET: '0x61',\n OPTIMISM: '0xa',\n OPTIMISM_TESTNET: '0x1a4',\n OPBNB: '0xcc',\n OPBNB_TESTNET: '0x15eb',\n OPTIMISM_SEPOLIA: '0xaa37dc',\n POLYGON: '0x89',\n POLYGON_TESTNET: '0x13881',\n AVALANCHE: '0xa86a',\n AVALANCHE_TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_SEPOLIA: '0xe705',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n ARBITRUM: '0xa4b1',\n ZKSYNC_ERA: '0x144',\n ZORA: '0x76adf1',\n} as const;\n\nexport const DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io';\nexport const DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api';\n\nexport const ETHERSCAN_SUPPORTED_NETWORKS = {\n [CHAIN_IDS.GOERLI]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,\n },\n [CHAIN_IDS.MAINNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.SEPOLIA]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,\n },\n [CHAIN_IDS.LINEA_GOERLI]: {\n domain: 'lineascan.build',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,\n },\n [CHAIN_IDS.LINEA_SEPOLIA]: {\n domain: 'lineascan.build',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,\n },\n [CHAIN_IDS.LINEA_MAINNET]: {\n domain: 'lineascan.build',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC]: {\n domain: 'bscscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC_TESTNET]: {\n domain: 'bscscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.OPTIMISM]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,\n },\n [CHAIN_IDS.OPTIMISM_SEPOLIA]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia-optimistic`,\n },\n [CHAIN_IDS.POLYGON]: {\n domain: 'polygonscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.POLYGON_TESTNET]: {\n domain: 'polygonscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,\n },\n [CHAIN_IDS.AVALANCHE]: {\n domain: 'snowtrace.io',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.AVALANCHE_TESTNET]: {\n domain: 'snowtrace.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.FANTOM]: {\n domain: 'ftmscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.FANTOM_TESTNET]: {\n domain: 'ftmscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.MOONBEAM]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,\n },\n [CHAIN_IDS.MOONBEAM_TESTNET]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,\n },\n [CHAIN_IDS.MOONRIVER]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,\n },\n [CHAIN_IDS.GNOSIS]: {\n domain: 'gnosisscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,\n },\n};\n\nexport const GAS_BUFFER_CHAIN_OVERRIDES = {\n [CHAIN_IDS.OPTIMISM]: 1,\n [CHAIN_IDS.OPTIMISM_SEPOLIA]: 1,\n};\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk6V2LR6JLjs = require('./chunk-6V2LR6JL.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkFK7AP6SHjs = require('./chunk-FK7AP6SH.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -48,7 +48,7 @@ var LineaGasFeeFlow = class {
|
|
|
48
48
|
return await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLineaGasFees, getLineaGasFees_fn).call(this, request);
|
|
49
49
|
} catch (error) {
|
|
50
50
|
log("Using default flow as fallback due to error", error);
|
|
51
|
-
return new (0,
|
|
51
|
+
return new (0, _chunk6V2LR6JLjs.DefaultGasFeeFlow)().getGasFees(request);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
};
|
|
@@ -63,7 +63,7 @@ getLineaGasFees_fn = async function(request) {
|
|
|
63
63
|
log("Generated priority fees", _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _feesToString, feesToString_fn).call(this, priorityFees));
|
|
64
64
|
const maxFees = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getMaxFees, getMaxFees_fn).call(this, baseFees, priorityFees);
|
|
65
65
|
log("Generated max fees", _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _feesToString, feesToString_fn).call(this, maxFees));
|
|
66
|
-
const estimates = Object.values(
|
|
66
|
+
const estimates = Object.values(_chunkFK7AP6SHjs.GasFeeEstimateLevel).reduce(
|
|
67
67
|
(result, level) => ({
|
|
68
68
|
...result,
|
|
69
69
|
[level]: {
|
|
@@ -110,7 +110,7 @@ getMaxFees_fn = function(baseFees, priorityFees) {
|
|
|
110
110
|
};
|
|
111
111
|
_feesToString = new WeakSet();
|
|
112
112
|
feesToString_fn = function(fees) {
|
|
113
|
-
return Object.values(
|
|
113
|
+
return Object.values(_chunkFK7AP6SHjs.GasFeeEstimateLevel).map(
|
|
114
114
|
(level) => fees[level].toString(10)
|
|
115
115
|
);
|
|
116
116
|
};
|
|
@@ -118,4 +118,4 @@ feesToString_fn = function(fees) {
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
exports.LineaGasFeeFlow = LineaGasFeeFlow;
|
|
121
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-XZILQVNW.js.map
|
|
@@ -64,6 +64,13 @@ var SimulationTokenStandard = /* @__PURE__ */ ((SimulationTokenStandard2) => {
|
|
|
64
64
|
SimulationTokenStandard2["erc1155"] = "erc1155";
|
|
65
65
|
return SimulationTokenStandard2;
|
|
66
66
|
})(SimulationTokenStandard || {});
|
|
67
|
+
var SimulationErrorCode = /* @__PURE__ */ ((SimulationErrorCode2) => {
|
|
68
|
+
SimulationErrorCode2["ChainNotSupported"] = "chain-not-supported";
|
|
69
|
+
SimulationErrorCode2["Disabled"] = "disabled";
|
|
70
|
+
SimulationErrorCode2["InvalidResponse"] = "invalid-response";
|
|
71
|
+
SimulationErrorCode2["Reverted"] = "reverted";
|
|
72
|
+
return SimulationErrorCode2;
|
|
73
|
+
})(SimulationErrorCode || {});
|
|
67
74
|
|
|
68
75
|
export {
|
|
69
76
|
TransactionStatus,
|
|
@@ -72,6 +79,7 @@ export {
|
|
|
72
79
|
TransactionEnvelopeType,
|
|
73
80
|
UserFeeLevel,
|
|
74
81
|
GasFeeEstimateLevel,
|
|
75
|
-
SimulationTokenStandard
|
|
82
|
+
SimulationTokenStandard,
|
|
83
|
+
SimulationErrorCode
|
|
76
84
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-YEJJKWT2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { AccessList } from '@ethereumjs/tx';\nimport type EthQuery from '@metamask/eth-query';\nimport type {\n FetchGasFeeEstimateOptions,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type { NetworkClientId, Provider } from '@metamask/network-controller';\nimport type { Hex, Json } from '@metamask/utils';\nimport type { Operation } from 'fast-json-patch';\n\n/**\n * Given a record, ensures that each property matches the `Json` type.\n */\ntype MakeJsonCompatible<T> = T extends Json\n ? T\n : {\n [K in keyof T]: T[K] extends Json ? T[K] : never;\n };\n\n/**\n * `Json` from `@metamask/utils` is defined as a recursive type alias, but\n * `Operation` is defined as an interface, and the two are not compatible with\n * each other. Therefore, this is a variant of Operation from `fast-json-patch`\n * which is guaranteed to be type-compatible with `Json`.\n */\ntype JsonCompatibleOperation = MakeJsonCompatible<Operation>;\n\n/**\n * Representation of transaction metadata.\n */\nexport type TransactionMeta = TransactionMetaBase &\n (\n | {\n status: Exclude<TransactionStatus, TransactionStatus.failed>;\n }\n | {\n status: TransactionStatus.failed;\n error: TransactionError;\n }\n );\n\n/**\n * Information about a single transaction such as status and block number.\n */\ntype TransactionMetaBase = {\n /**\n * ID of the transaction that approved the swap token transfer.\n */\n approvalTxId?: string;\n\n /**\n * Unique ID to prevent duplicate requests.\n */\n actionId?: string;\n\n /**\n * Base fee of the block as a hex value, introduced in EIP-1559.\n */\n baseFeePerGas?: Hex;\n\n /**\n * Number of the block where the transaction has been included.\n */\n blockNumber?: string;\n\n /**\n * The timestamp for when the block was collated.\n */\n blockTimestamp?: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId: Hex;\n\n /**\n * A string representing a name of transaction contract method.\n */\n contractMethodName?: string;\n\n /**\n * The balance of the token that is being sent.\n */\n currentTokenBalance?: string;\n\n /**\n * Unique ID for custodian transaction.\n */\n custodyId?: string;\n\n /**\n * Custodian transaction status.\n */\n custodyStatus?: string;\n\n /** The optional custom nonce override as a decimal string. */\n customNonceValue?: string;\n\n /**\n * The custom token amount is the amount set by the user.\n */\n customTokenAmount?: string;\n\n /**\n * The dapp proposed token amount.\n */\n dappProposedTokenAmount?: string;\n\n /**\n * Gas values provided by the dApp.\n */\n dappSuggestedGasFees?: DappSuggestedGasFees;\n\n /**\n * The initial gas values set when the transaction was first created.\n */\n defaultGasEstimates?: DefaultGasEstimates;\n\n /**\n * String to indicate what device the transaction was confirmed on.\n */\n deviceConfirmedOn?: WalletDevice;\n\n /**\n * The address of the token being received of swap transaction.\n */\n destinationTokenAddress?: string;\n\n /**\n * The decimals of the token being received of swap transaction.\n */\n destinationTokenDecimals?: number;\n\n /**\n * The symbol of the token being received with swap.\n */\n destinationTokenSymbol?: string;\n\n /**\n * The estimated base fee of the transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * The chosen amount which will be the same as the originally proposed token\n * amount if the user does not edit the amount or will be a custom token\n * amount set by the user.\n */\n finalApprovalAmount?: string;\n\n /**\n * The number of the latest block when the transaction submit was first retried.\n */\n firstRetryBlockNumber?: string;\n\n /** Alternate EIP-1559 gas fee estimates for multiple priority levels. */\n gasFeeEstimates?: GasFeeEstimates;\n\n /** Whether the gas fee estimates have been checked at least once. */\n gasFeeEstimatesLoaded?: boolean;\n\n /**\n * A hex string of the transaction hash, used to identify the transaction on the network.\n */\n hash?: string;\n\n /**\n * A history of mutations to TransactionMeta.\n */\n history?: TransactionHistory;\n\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Whether the transaction is a transfer.\n */\n isTransfer?: boolean;\n\n /**\n * Whether the transaction entry is generated from a user operation.\n */\n isUserOperation?: boolean;\n\n /**\n * Additional gas fees to cover the cost of persisting data on layer 1 for layer 2 networks.\n */\n layer1GasFee?: Hex;\n\n /**\n * The ID of the network client used by the transaction.\n */\n networkClientId?: NetworkClientId;\n\n /**\n * Network code as per EIP-155 for this transaction\n *\n * @deprecated Use `chainId` instead.\n */\n readonly networkID?: string;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * The original dapp proposed token approval amount before edit by user.\n */\n originalApprovalAmount?: string;\n\n /**\n * The original gas estimation of the transaction.\n */\n originalGasEstimate?: string;\n\n /**\n * When we speed up a transaction, we set the type as Retry and we lose\n * information about type of transaction that is being set up, so we use\n * original type to track that information.\n */\n originalType?: TransactionType;\n\n /**\n * Account transaction balance after swap.\n */\n postTxBalance?: string;\n\n /**\n * Account transaction balance before swap.\n */\n preTxBalance?: string;\n\n /**\n * The previous gas properties before they were updated.\n */\n previousGas?: {\n /**\n * Maxmimum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n };\n\n /**\n * The transaction's 'r' value as a hex string.\n */\n r?: string;\n\n /**\n * Hex representation of the underlying transaction.\n */\n rawTx?: string;\n\n /**\n * When the transaction is dropped, this is the replacement transaction hash.\n */\n replacedBy?: string;\n\n /**\n * When the transaction is dropped, this is the replacement transaction ID.\n */\n replacedById?: string;\n\n /**\n * The number of times that the transaction submit has been retried.\n */\n retryCount?: number;\n\n /**\n * The transaction's 's' value as a hex string.\n */\n s?: string;\n\n /**\n * Response from security validator.\n */\n securityAlertResponse?: SecurityAlertResponse;\n\n /**\n * Response from security provider.\n */\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n securityProviderResponse?: Record<string, any>;\n\n /**\n * An array of entries that describe the user's journey through the send flow.\n * This is purely attached to state logs for troubleshooting and support.\n */\n sendFlowHistory?: SendFlowHistoryEntry[];\n\n /**\n * Simulation data for the transaction used to predict its outcome.\n */\n simulationData?: SimulationData;\n\n /**\n * If the gas estimation fails, an object containing error and block information.\n */\n simulationFails?: {\n reason?: string;\n errorKey?: string;\n debug: {\n blockNumber?: string;\n blockGasLimit?: string;\n };\n };\n\n /**\n * The time the transaction was submitted to the network, in Unix epoch time (ms).\n */\n submittedTime?: number;\n\n /**\n * The symbol of the token being swapped.\n */\n sourceTokenSymbol?: string;\n\n /**\n * The metadata of the swap transaction.\n */\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swapMetaData?: Record<string, any>;\n\n /**\n * The value of the token being swapped.\n */\n swapTokenValue?: string;\n\n /**\n * Timestamp associated with this transaction.\n */\n time: number;\n\n /**\n * Whether transaction recipient is a smart contract.\n */\n toSmartContract?: boolean;\n\n /**\n * Additional transfer information.\n */\n transferInformation?: {\n contractAddress: string;\n decimals: number;\n symbol: string;\n };\n\n /**\n * Underlying Transaction object.\n */\n txParams: TransactionParams;\n\n /**\n * Transaction receipt.\n */\n txReceipt?: TransactionReceipt;\n\n /**\n * The type of transaction such as `cancel` or `swap`.\n */\n type?: TransactionType;\n\n /**\n * The gas limit supplied by user.\n */\n userEditedGasLimit?: boolean;\n\n /**\n * Estimate level user selected.\n */\n userFeeLevel?: string;\n\n /**\n * The transaction's 'v' value as a hex string.\n */\n v?: string;\n\n /**\n * Whether the transaction is verified on the blockchain.\n */\n verifiedOnBlockchain?: boolean;\n\n /**\n * Warning information for the transaction.\n */\n warning?: {\n error: string;\n message: string;\n };\n};\n\nexport type SendFlowHistoryEntry = {\n /**\n * String to indicate user interaction information.\n */\n entry: string;\n\n /**\n * Timestamp associated with this entry.\n */\n timestamp: number;\n};\n\n/**\n * The status of the transaction. Each status represents the state of the transaction internally\n * in the wallet. Some of these correspond with the state of the transaction on the network, but\n * some are wallet-specific.\n */\nexport enum TransactionStatus {\n approved = 'approved',\n /** @deprecated Determined by the clients using the transaction type. No longer used. */\n cancelled = 'cancelled',\n confirmed = 'confirmed',\n dropped = 'dropped',\n failed = 'failed',\n rejected = 'rejected',\n signed = 'signed',\n submitted = 'submitted',\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n MM_MOBILE = 'metamask_mobile',\n MM_EXTENSION = 'metamask_extension',\n OTHER = 'other_device',\n}\n\n/**\n * The type of the transaction.\n */\nexport enum TransactionType {\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n cancel = 'cancel',\n\n /**\n * A transaction that is interacting with a smart contract's methods that we\n * have not treated as a special case, such as approve, transfer, and\n * transferfrom.\n */\n contractInteraction = 'contractInteraction',\n\n /**\n * A transaction that deployed a smart contract.\n */\n deployContract = 'contractDeployment',\n\n /**\n * A transaction for Ethereum decryption.\n */\n ethDecrypt = 'eth_decrypt',\n\n /**\n * A transaction for getting an encryption public key.\n */\n ethGetEncryptionPublicKey = 'eth_getEncryptionPublicKey',\n\n /**\n * An incoming (deposit) transaction.\n */\n incoming = 'incoming',\n\n /**\n * A transaction for personal sign.\n */\n personalSign = 'personal_sign',\n\n /**\n * When a transaction is failed it can be retried by\n * resubmitting the same transaction with a higher gas fee. This type is also used\n * to speed up pending transactions. This is accomplished by creating a new tx with\n * the same nonce and higher gas fees.\n */\n retry = 'retry',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n simpleSend = 'simpleSend',\n\n /**\n * A transaction that is signing a message.\n */\n sign = 'eth_sign',\n\n /**\n * A transaction that is signing typed data.\n */\n signTypedData = 'eth_signTypedData',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n smart = 'smart',\n\n /**\n * A transaction swapping one token for another through MetaMask Swaps.\n */\n swap = 'swap',\n\n /**\n * Similar to the approve type, a swap approval is a special case of ERC20\n * approve method that requests an allowance of the token to spend on behalf\n * of the user for the MetaMask Swaps contract. The first swap for any token\n * will have an accompanying swapApproval transaction.\n */\n swapApproval = 'swapApproval',\n\n /**\n * A token transaction requesting an allowance of the token to spend on\n * behalf of the user.\n */\n tokenMethodApprove = 'approve',\n\n /**\n * A token transaction transferring tokens from an account that the sender\n * has an allowance of. The method is prefixed with safe because when calling\n * this method the contract checks to ensure that the receiver is an address\n * capable of handling the token being sent.\n */\n tokenMethodSafeTransferFrom = 'safetransferfrom',\n\n /**\n * A token transaction where the user is sending tokens that they own to\n * another address.\n */\n tokenMethodTransfer = 'transfer',\n\n /**\n * A token transaction transferring tokens from an account that the sender\n * has an allowance of. For more information on allowances, see the approve\n * type.\n */\n tokenMethodTransferFrom = 'transferfrom',\n\n /**\n * A token transaction requesting an allowance of all of a user's tokens to\n * spend on behalf of the user.\n */\n tokenMethodSetApprovalForAll = 'setapprovalforall',\n\n /**\n * Increase the allowance by a given increment\n */\n tokenMethodIncreaseAllowance = 'increaseAllowance',\n}\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport type TransactionParams = {\n /**\n * A list of addresses and storage keys that the transaction plans to access.\n */\n accessList?: AccessList;\n\n /**\n * Network ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * same as gasLimit?\n */\n gas?: string;\n\n /**\n * Maxmimum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Price per gas for legacy txs\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority\n * fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n\n /**\n * Type of transaction.\n * 0x0 indicates a legacy transaction.\n */\n type?: string;\n};\n\n/**\n * Standard data concerning a transaction processed by the blockchain.\n */\nexport type TransactionReceipt = {\n /**\n * The block hash of the block that this transaction was included in.\n */\n blockHash?: string;\n\n /**\n * The block number of the block that this transaction was included in.\n */\n blockNumber?: string;\n\n /**\n * Effective gas price the transaction was charged at.\n */\n effectiveGasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Total used gas in hex.\n */\n l1Fee?: string;\n\n /**\n * All the logs emitted by this transaction.\n */\n logs?: Log[];\n\n /**\n * The status of the transaction.\n */\n status?: string;\n\n /**\n * The hexadecimal index of this transaction in the list of transactions included in the block this transaction was mined in.\n */\n transactionIndex?: string;\n};\n\n/**\n * Represents an event that has been included in a transaction using the EVM `LOG` opcode.\n */\nexport type Log = {\n /**\n * Address of the contract that generated log.\n */\n address?: string;\n /**\n * List of topics for log.\n */\n topics?: string;\n};\n\n/**\n * The configuration required to fetch transaction data from a RemoteTransactionSource.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface RemoteTransactionSourceRequest {\n /**\n * The address of the account to fetch transactions for.\n */\n address: string;\n\n /**\n * The chainId of the current network.\n */\n currentChainId: Hex;\n\n /**\n * Block number to start fetching transactions from.\n */\n fromBlock?: number;\n\n /**\n * Maximum number of transactions to retrieve.\n */\n limit?: number;\n}\n\n/**\n * An object capable of fetching transaction data from a remote source.\n * Used by the IncomingTransactionHelper to retrieve remote transaction data.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface RemoteTransactionSource {\n /**\n * @param chainId - The chainId of the current network.\n * @returns Whether the remote transaction source supports the specified network.\n */\n isSupportedNetwork: (chainId: Hex) => boolean;\n\n /**\n * @returns An array of additional keys to use when caching the last fetched block number.\n */\n getLastBlockVariations?: () => string[];\n\n /**\n * @param request - A request object containing data such as the address and chain ID.\n * @returns An array of transaction metadata for the retrieved transactions.\n */\n fetchTransactions: (\n request: RemoteTransactionSourceRequest,\n ) => Promise<TransactionMeta[]>;\n}\n\n/**\n * Gas values initially suggested by the dApp.\n */\nexport type DappSuggestedGasFees = {\n gas?: string;\n gasPrice?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n};\n\n/**\n * Gas values saved by the user for a specific chain.\n */\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface SavedGasFees {\n maxBaseFee: string;\n priorityFee: string;\n}\n\n/**\n * A transaction history operation that includes a note and timestamp.\n */\ntype ExtendedHistoryOperation = JsonCompatibleOperation & {\n note?: string;\n timestamp?: number;\n};\n\n/**\n * A transaction history entry that includes the ExtendedHistoryOperation as the first element.\n */\nexport type TransactionHistoryEntry = [\n ExtendedHistoryOperation,\n ...JsonCompatibleOperation[],\n];\n\n/**\n * A transaction history that includes the transaction meta as the first element.\n * And the rest of the elements are the operation arrays that were applied to the transaction meta.\n */\nexport type TransactionHistory = [\n TransactionMeta,\n ...TransactionHistoryEntry[],\n];\n\n/**\n * Result of inferring the transaction type.\n */\nexport type InferTransactionTypeResult = {\n /**\n * The contract code, in hex format if it exists. '0x0' or\n * '0x' are also indicators of non-existent contract code.\n */\n getCodeResponse?: string | null;\n\n /**\n * The type of transaction\n */\n type: TransactionType;\n};\n\n/**\n * A function for verifying a transaction, whether it is malicious or not.\n */\nexport type SecurityProviderRequest = (\n requestData: TransactionMeta,\n messageType: string,\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => Promise<any>;\n\n/**\n * Specifies the shape of the base transaction parameters.\n * Added in EIP-2718.\n */\nexport enum TransactionEnvelopeType {\n /**\n * A legacy transaction, the very first type.\n */\n legacy = '0x0',\n\n /**\n * EIP-2930 defined the access list transaction type that allowed for\n * specifying the state that a transaction would act upon in advance and\n * theoretically save on gas fees.\n */\n accessList = '0x1',\n\n /**\n * The type introduced comes from EIP-1559, Fee Market describes the addition\n * of a baseFee to blocks that will be burned instead of distributed to\n * miners. Transactions of this type have both a maxFeePerGas (maximum total\n * amount in gwei per gas to spend on the transaction) which is inclusive of\n * the maxPriorityFeePerGas (maximum amount of gwei per gas from the\n * transaction fee to distribute to miner).\n */\n feeMarket = '0x2',\n}\n\n/**\n * The source of the gas fee parameters on a transaction.\n */\nexport enum UserFeeLevel {\n CUSTOM = 'custom',\n DAPP_SUGGESTED = 'dappSuggested',\n MEDIUM = 'medium',\n}\n\n/**\n * Initial gas values set when the transaction was first created.\n */\nexport type DefaultGasEstimates = {\n /**\n * Source of the gas fee values, such as `dappSuggested` or `medium`.\n */\n estimateType?: string;\n\n /**\n * Maxmimum number of units of gas to use for this transaction.\n */\n gas?: string;\n\n /**\n * Price per gas for legacy transactions.\n */\n gasPrice?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n};\n\n/**\n * Data concerning an error while processing a transaction.\n */\nexport type TransactionError = {\n /**\n * A descriptive error name.\n */\n name: string;\n\n /**\n * A descriptive error message providing details about the encountered error.\n */\n message: string;\n\n /**\n * The stack trace associated with the error, if available.\n */\n stack?: string;\n\n /**\n * An optional error code associated with the error.\n */\n code?: string;\n\n /**\n * The rpc property holds additional information related to the error.\n */\n // We are intentionally using `any` here instead of `Json` because it causes\n // `WritableDraft<TransactionMeta>` from Immer to cause TypeScript to error\n // with \"Type instantiation is excessively deep and possibly infinite\". See:\n // <https://github.com/immerjs/immer/issues/839>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rpc?: any;\n};\n\n/**\n * Type for security alert response from transaction validator.\n */\nexport type SecurityAlertResponse = {\n reason: string;\n features?: string[];\n result_type: string;\n providerRequestsCount?: Record<string, number>;\n};\n\n/** Gas fee estimates for a specific priority level. */\nexport type GasFeeEstimatesForLevel = {\n /** Maximum amount to pay per gas. */\n maxFeePerGas: Hex;\n\n /** Maximum amount per gas to give to the validator as an incentive. */\n maxPriorityFeePerGas: Hex;\n};\n\n/** Alternate priority levels for which values are provided in gas fee estimates. */\nexport enum GasFeeEstimateLevel {\n low = 'low',\n medium = 'medium',\n high = 'high',\n}\n\n/** Gas fee estimates for a transaction. */\nexport type GasFeeEstimates = {\n /** The gas fee estimate for a low priority transaction. */\n [GasFeeEstimateLevel.low]: GasFeeEstimatesForLevel;\n\n /** The gas fee estimate for a medium priority transaction. */\n [GasFeeEstimateLevel.medium]: GasFeeEstimatesForLevel;\n\n /** The gas fee estimate for a high priority transaction. */\n [GasFeeEstimateLevel.high]: GasFeeEstimatesForLevel;\n};\n\n/** Request to a gas fee flow to obtain gas fee estimates. */\nexport type GasFeeFlowRequest = {\n /** An EthQuery instance to enable queries to the associated RPC provider. */\n ethQuery: EthQuery;\n\n /** Callback to get the GasFeeController estimates. */\n getGasFeeControllerEstimates: (\n options: FetchGasFeeEstimateOptions,\n ) => Promise<GasFeeState>;\n\n /** The metadata of the transaction to obtain estimates for. */\n transactionMeta: TransactionMeta;\n};\n\n/** Response from a gas fee flow containing gas fee estimates. */\nexport type GasFeeFlowResponse = {\n /** The gas fee estimates for the transaction. */\n estimates: GasFeeEstimates;\n};\n\n/** A method of obtaining gas fee estimates for a specific transaction. */\nexport type GasFeeFlow = {\n /**\n * Determine if the gas fee flow supports the specified transaction.\n * @param transactionMeta - The transaction metadata.\n * @returns Whether the gas fee flow supports the transaction.\n */\n matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n /**\n * Get gas fee estimates for a specific transaction.\n * @param request - The gas fee flow request.\n * @returns The gas fee flow response containing the gas fee estimates.\n */\n getGasFees: (request: GasFeeFlowRequest) => Promise<GasFeeFlowResponse>;\n};\n\n/** Request to a layer 1 gas fee flow to obtain layer 1 fee estimate. */\nexport type Layer1GasFeeFlowRequest = {\n /** RPC Provider instance. */\n provider: Provider;\n\n /** The metadata of the transaction to obtain estimates for. */\n transactionMeta: TransactionMeta;\n};\n\n/** Response from a layer 1 gas fee flow containing layer 1 fee estimate. */\nexport type Layer1GasFeeFlowResponse = {\n /** The gas fee estimates for the transaction. */\n layer1Fee: Hex;\n};\n\n/** A method of obtaining layer 1 gas fee estimates for a specific transaction. */\nexport type Layer1GasFeeFlow = {\n /**\n * Determine if the gas fee flow supports the specified transaction.\n * @param transactionMeta - The transaction metadata.\n * @returns Whether the layer1 gas fee flow supports the transaction.\n */\n matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n /**\n * Get layer 1 gas fee estimates for a specific transaction.\n * @param request - The gas fee flow request.\n * @returns The gas fee flow response containing the layer 1 gas fee estimate.\n */\n getLayer1Fee: (\n request: Layer1GasFeeFlowRequest,\n ) => Promise<Layer1GasFeeFlowResponse>;\n};\n\n/** Simulation data concerning an update to a native or token balance. */\nexport type SimulationBalanceChange = {\n /** The balance before the transaction. */\n previousBalance: Hex;\n\n /** The balance after the transaction. */\n newBalance: Hex;\n\n /** The difference in balance. */\n difference: Hex;\n\n /** Whether the balance is increasing or decreasing. */\n isDecrease: boolean;\n};\n\n/** Token standards supported by simulation. */\nexport enum SimulationTokenStandard {\n erc20 = 'erc20',\n erc721 = 'erc721',\n erc1155 = 'erc1155',\n}\n\n/** Simulation data concerning an updated token. */\nexport type SimulationToken = {\n /** The token's contract address. */\n address: Hex;\n\n /** The standard of the token. */\n standard: SimulationTokenStandard;\n\n /** The ID of the token if supported by the standard. */\n id?: Hex;\n};\n\n/** Simulation data concerning a change to the a token balance. */\nexport type SimulationTokenBalanceChange = SimulationToken &\n SimulationBalanceChange;\n\nexport enum SimulationErrorCode {\n ChainNotSupported = 'chain-not-supported',\n Disabled = 'disabled',\n InvalidResponse = 'invalid-response',\n Reverted = 'reverted',\n}\n\n/** Error data for a failed simulation. */\nexport type SimulationError = {\n /** Error code to identify the error type. */\n code?: string | number;\n\n /** Error message to describe the error. */\n message?: string;\n};\n\n/** Simulation data for a transaction. */\nexport type SimulationData = {\n /** Error data if the simulation failed or the transaction reverted. */\n error?: SimulationError;\n\n /** Data concerning a change to the user's native balance. */\n nativeBalanceChange?: SimulationBalanceChange;\n\n /** Data concerning a change to the user's token balances. */\n tokenBalanceChanges: SimulationTokenBalanceChange[];\n};\n"],"mappings":";AAgbO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,mBAAA,cAAW;AAEX,EAAAA,mBAAA,eAAY;AACZ,EAAAA,mBAAA,eAAY;AACZ,EAAAA,mBAAA,aAAU;AACV,EAAAA,mBA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,qBAAA,SAAM;AACN,EAAAA,qBAAA,YAAS;AACT,EAAAA,qBAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAyGL,IAAK,0BAAL,kBAAKC,6BAAL;AACL,EAAAA,yBAAA,WAAQ;AACR,EAAAA,yBAAA,YAAS;AACT,EAAAA,yBAAA,aAAU;AAHA,SAAAA;AAAA,GAAA;AAsBL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,qBAAA,uBAAoB;AACpB,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,qBAAkB;AAClB,EAAAA,qBAAA,cAAW;AAJD,SAAAA;AAAA,GAAA;","names":["TransactionStatus","WalletDevice","TransactionType","TransactionEnvelopeType","UserFeeLevel","GasFeeEstimateLevel","SimulationTokenStandard","SimulationErrorCode"]}
|
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkWIZVJM2Bjs = require('./chunk-WIZVJM2B.js');
|
|
8
8
|
require('./chunk-Z4BLTVTB.js');
|
|
9
9
|
|
|
10
10
|
|
|
@@ -12,5 +12,5 @@ require('./chunk-Z4BLTVTB.js');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.CHAIN_IDS =
|
|
15
|
+
exports.CHAIN_IDS = _chunkWIZVJM2Bjs.CHAIN_IDS; exports.DEFAULT_ETHERSCAN_DOMAIN = _chunkWIZVJM2Bjs.DEFAULT_ETHERSCAN_DOMAIN; exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = _chunkWIZVJM2Bjs.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX; exports.ETHERSCAN_SUPPORTED_NETWORKS = _chunkWIZVJM2Bjs.ETHERSCAN_SUPPORTED_NETWORKS; exports.GAS_BUFFER_CHAIN_OVERRIDES = _chunkWIZVJM2Bjs.GAS_BUFFER_CHAIN_OVERRIDES;
|
|
16
16
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.mjs
CHANGED
package/dist/errors.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkHMOSP33Fjs = require('./chunk-HMOSP33F.js');
|
|
7
|
+
require('./chunk-FK7AP6SH.js');
|
|
8
|
+
require('./chunk-Z4BLTVTB.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.SimulationChainNotSupportedError = _chunkHMOSP33Fjs.SimulationChainNotSupportedError; exports.SimulationError = _chunkHMOSP33Fjs.SimulationError; exports.SimulationInvalidResponseError = _chunkHMOSP33Fjs.SimulationInvalidResponseError; exports.SimulationRevertedError = _chunkHMOSP33Fjs.SimulationRevertedError;
|
|
15
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimulationChainNotSupportedError,
|
|
3
|
+
SimulationError,
|
|
4
|
+
SimulationInvalidResponseError,
|
|
5
|
+
SimulationRevertedError
|
|
6
|
+
} from "./chunk-HQSNKCXI.mjs";
|
|
7
|
+
import "./chunk-YEJJKWT2.mjs";
|
|
8
|
+
import "./chunk-XUI43LEZ.mjs";
|
|
9
|
+
export {
|
|
10
|
+
SimulationChainNotSupportedError,
|
|
11
|
+
SimulationError,
|
|
12
|
+
SimulationInvalidResponseError,
|
|
13
|
+
SimulationRevertedError
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|