1
1
diff --git a/dist/TransactionController.cjs b/dist/TransactionController.cjs
2
- index 5f244a7192ebc9b39ba230d92ee3bf36b47a36cd..247aac66bc90f29d2168e2dfcebfe3523b77a64c 100644
2
+ index 5f244a7192ebc9b39ba230d92ee3bf36b47a36cd..bad32607ec183eaeeed2fb24ffca1810ed1975e7 100644
3
3
--- a/dist/TransactionController.cjs
4
4
+++ b/dist/TransactionController.cjs
5
5
@@ -559,7 +559,12 @@ class TransactionController extends base_controller_1.BaseController {
@@ -30,7 +30,25 @@ index 5f244a7192ebc9b39ba230d92ee3bf36b47a36cd..247aac66bc90f29d2168e2dfcebfe352
30
30
const gas = (0, gas_1.addGasBuffer)(estimatedGas, blockGasLimit, multiplier);
31
31
return {
32
32
gas,
33
- @@ -2097,6 +2107,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
33
+ @@ -2012,6 +2022,9 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
34
+ tokenBalanceChanges: [],
35
+ };
36
+ if (__classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
37
+ + const authorizationAddress = txParams?.authorizationList?.[0]?.address;
38
+ + const senderCode = authorizationAddress &&
39
+ + (eip7702_1.DELEGATION_PREFIX + (0, utils_1.remove0x)(authorizationAddress));
40
+ simulationData = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0, simulation_1.getSimulationData)({
41
+ chainId,
42
+ from: from,
43
+ @@ -2020,6 +2033,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
44
+ data: data,
45
+ }, {
46
+ blockTime,
47
+ + senderCode,
48
+ }));
49
+ if (blockTime &&
50
+ prevSimulationData &&
51
+ @@ -2097,6 +2111,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
34
52
chainId,
35
53
ethQuery,
36
54
isCustomNetwork,
@@ -39,9 +57,27 @@ index 5f244a7192ebc9b39ba230d92ee3bf36b47a36cd..247aac66bc90f29d2168e2dfcebfe352
39
57
});
40
58
}, _TransactionController_deleteTransaction = function _TransactionController_deleteTransaction(transactionId) {
41
59
diff --git a/dist/TransactionController.mjs b/dist/TransactionController.mjs
42
- index 3ecb211958f31624677c0db41c0e87b2cdb4cf76..92d1d34182a3b319253ee11cef27e385c04c1945 100644
60
+ index 3ecb211958f31624677c0db41c0e87b2cdb4cf76..060d60eddb796c74e79cac8014b92b8971871119 100644
43
61
--- a/dist/TransactionController.mjs
44
62
+++ b/dist/TransactionController.mjs
63
+ @@ -23,7 +23,7 @@ const EthQuery = $importDefault($EthQuery);
64
+ import { NetworkClientType } from "@metamask/network-controller";
65
+ import { NonceTracker } from "@metamask/nonce-tracker";
66
+ import { errorCodes, rpcErrors, providerErrors } from "@metamask/rpc-errors";
67
+ - import { add0x, hexToNumber } from "@metamask/utils";
68
+ + import { add0x, hexToNumber, remove0x } from "@metamask/utils";
69
+ import { Mutex } from "async-mutex";
70
+ // This package purposefully relies on Node's EventEmitter module.
71
+ // eslint-disable-next-line import-x/no-nodejs-modules
72
+ @@ -47,7 +47,7 @@ import { ResimulateHelper, hasSimulationDataChanged, shouldResimulate } from "./
73
+ import { projectLogger as log } from "./logger.mjs";
74
+ import { TransactionEnvelopeType, TransactionType, TransactionStatus, SimulationErrorCode } from "./types.mjs";
75
+ import { addTransactionBatch, isAtomicBatchSupported } from "./utils/batch.mjs";
76
+ - import { generateEIP7702BatchTransaction, getDelegationAddress, signAuthorizationList } from "./utils/eip7702.mjs";
77
+ + import { DELEGATION_PREFIX, generateEIP7702BatchTransaction, getDelegationAddress, signAuthorizationList } from "./utils/eip7702.mjs";
78
+ import { validateConfirmedExternalTransaction } from "./utils/external-transactions.mjs";
79
+ import { addGasBuffer, estimateGas, updateGas } from "./utils/gas.mjs";
80
+ import { updateGasFees } from "./utils/gas-fees.mjs";
45
81
@@ -561,7 +561,12 @@ export class TransactionController extends BaseController {
46
82
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
47
83
networkClientId,
@@ -70,7 +106,25 @@ index 3ecb211958f31624677c0db41c0e87b2cdb4cf76..92d1d34182a3b319253ee11cef27e385
70
106
const gas = addGasBuffer(estimatedGas, blockGasLimit, multiplier);
71
107
return {
72
108
gas,
73
- @@ -2098,6 +2108,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
109
+ @@ -2013,6 +2023,9 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
110
+ tokenBalanceChanges: [],
111
+ };
112
+ if (__classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
113
+ + const authorizationAddress = txParams?.authorizationList?.[0]?.address;
114
+ + const senderCode = authorizationAddress &&
115
+ + (DELEGATION_PREFIX + remove0x(authorizationAddress));
116
+ simulationData = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => getSimulationData({
117
+ chainId,
118
+ from: from,
119
+ @@ -2021,6 +2034,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
120
+ data: data,
121
+ }, {
122
+ blockTime,
123
+ + senderCode,
124
+ }));
125
+ if (blockTime &&
126
+ prevSimulationData &&
127
+ @@ -2098,6 +2112,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
74
128
chainId,
75
129
ethQuery,
76
130
isCustomNetwork,
@@ -893,3 +947,129 @@ index 79e872fa72634f9d8be17a6b975dd782d19bb048..76233aefdabbc960641a3ce21864a9ab
893
947
/** Changes to the blockchain state. */
894
948
stateDiff?: {
895
949
/** Initial blockchain state before the transaction. */
950
+ diff --git a/dist/utils/simulation.cjs b/dist/utils/simulation.cjs
951
+ index cf035672bdccadfb4338b7822609a3dfe6b9f898..3658ba7dbb370f27c23de70393324e6de422a44f 100644
952
+ --- a/dist/utils/simulation.cjs
953
+ +++ b/dist/utils/simulation.cjs
954
+ @@ -64,7 +64,7 @@ const REVERTED_ERRORS = ['execution reverted', 'insufficient funds for gas'];
955
+ */
956
+ async function getSimulationData(request, options = {}) {
957
+ const { chainId, from, to, value, data } = request;
958
+ - const { blockTime } = options;
959
+ + const { blockTime, senderCode } = options;
960
+ log('Getting simulation data', request);
961
+ try {
962
+ const response = await (0, simulation_api_1.simulateTransactions)(chainId, {
963
+ @@ -85,6 +85,13 @@ async function getSimulationData(request, options = {}) {
964
+ time: (0, controller_utils_1.toHex)(blockTime),
965
+ },
966
+ }),
967
+ + ...(senderCode && {
968
+ + overrides: {
969
+ + [from]: {
970
+ + code: senderCode,
971
+ + },
972
+ + },
973
+ + }),
974
+ });
975
+ const transactionError = response.transactions?.[0]?.error;
976
+ if (transactionError) {
977
+ @@ -220,7 +227,8 @@ function normalizeEventArgValue(value) {
978
+ * @returns An array of token balance changes.
979
+ */
980
+ async function getTokenBalanceChanges(request, events, options) {
981
+ - const { blockTime } = options;
982
+ + const { from } = request;
983
+ + const { blockTime, senderCode } = options;
984
+ const balanceTxs = getTokenBalanceTransactions(request, events);
985
+ log('Generated balance transactions', [...balanceTxs.after.values()]);
986
+ const transactions = [
987
+ @@ -238,6 +246,13 @@ async function getTokenBalanceChanges(request, events, options) {
988
+ time: (0, controller_utils_1.toHex)(blockTime),
989
+ },
990
+ }),
991
+ + ...(senderCode && {
992
+ + overrides: {
993
+ + [from]: {
994
+ + code: senderCode,
995
+ + },
996
+ + },
997
+ + }),
998
+ });
999
+ log('Balance simulation response', response);
1000
+ if (response.transactions.length !== transactions.length) {
1001
+ diff --git a/dist/utils/simulation.d.cts b/dist/utils/simulation.d.cts
1002
+ index 5a9e3d8278c356e87529c5ce0b79d0545b2e5cf9..f91b1f0a00cd27649aec0dbfbe4fd9f45b05f71e 100644
1003
+ --- a/dist/utils/simulation.d.cts
1004
+ +++ b/dist/utils/simulation.d.cts
1005
+ @@ -27,6 +27,7 @@ type ParsedEvent = {
1006
+ };
1007
+ type GetSimulationDataOptions = {
1008
+ blockTime?: number;
1009
+ + senderCode?: Hex;
1010
+ };
1011
+ /**
1012
+ * Generate simulation data for a transaction.
1013
+ diff --git a/dist/utils/simulation.d.mts b/dist/utils/simulation.d.mts
1014
+ index df6666435463b9891bda1d6ee09ca80333380507..9e08d1c88e65990a44bdb662324835e00929e4a5 100644
1015
+ --- a/dist/utils/simulation.d.mts
1016
+ +++ b/dist/utils/simulation.d.mts
1017
+ @@ -27,6 +27,7 @@ type ParsedEvent = {
1018
+ };
1019
+ type GetSimulationDataOptions = {
1020
+ blockTime?: number;
1021
+ + senderCode?: Hex;
1022
+ };
1023
+ /**
1024
+ * Generate simulation data for a transaction.
1025
+ diff --git a/dist/utils/simulation.mjs b/dist/utils/simulation.mjs
1026
+ index 0c1d340a5981f29525c23af13bbcc6a913a1449a..619dca98ce27f7d88d8032ecba61701f5b298a21 100644
1027
+ --- a/dist/utils/simulation.mjs
1028
+ +++ b/dist/utils/simulation.mjs
1029
+ @@ -61,7 +61,7 @@ const REVERTED_ERRORS = ['execution reverted', 'insufficient funds for gas'];
1030
+ */
1031
+ export async function getSimulationData(request, options = {}) {
1032
+ const { chainId, from, to, value, data } = request;
1033
+ - const { blockTime } = options;
1034
+ + const { blockTime, senderCode } = options;
1035
+ log('Getting simulation data', request);
1036
+ try {
1037
+ const response = await simulateTransactions(chainId, {
1038
+ @@ -82,6 +82,13 @@ export async function getSimulationData(request, options = {}) {
1039
+ time: toHex(blockTime),
1040
+ },
1041
+ }),
1042
+ + ...(senderCode && {
1043
+ + overrides: {
1044
+ + [from]: {
1045
+ + code: senderCode,
1046
+ + },
1047
+ + },
1048
+ + }),
1049
+ });
1050
+ const transactionError = response.transactions?.[0]?.error;
1051
+ if (transactionError) {
1052
+ @@ -215,7 +222,8 @@ function normalizeEventArgValue(value) {
1053
+ * @returns An array of token balance changes.
1054
+ */
1055
+ async function getTokenBalanceChanges(request, events, options) {
1056
+ - const { blockTime } = options;
1057
+ + const { from } = request;
1058
+ + const { blockTime, senderCode } = options;
1059
+ const balanceTxs = getTokenBalanceTransactions(request, events);
1060
+ log('Generated balance transactions', [...balanceTxs.after.values()]);
1061
+ const transactions = [
1062
+ @@ -233,6 +241,13 @@ async function getTokenBalanceChanges(request, events, options) {
1063
+ time: toHex(blockTime),
1064
+ },
1065
+ }),
1066
+ + ...(senderCode && {
1067
+ + overrides: {
1068
+ + [from]: {
1069
+ + code: senderCode,
1070
+ + },
1071
+ + },
1072
+ + }),
1073
+ });
1074
+ log('Balance simulation response', response);
1075
+ if (response.transactions.length !== transactions.length) {
0 commit comments