viem-tx-sim 0.1.0 → 0.2.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.
Files changed (39) hide show
  1. package/README.md +103 -34
  2. package/contracts/TxSimulator.sol +83 -20
  3. package/dist/generated/txSimulatorBytecode.d.ts +1 -1
  4. package/dist/generated/txSimulatorBytecode.d.ts.map +1 -1
  5. package/dist/generated/txSimulatorBytecode.js +1 -1
  6. package/dist/generated/txSimulatorBytecode.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/internal/queryDiscovery.d.ts +8 -0
  10. package/dist/internal/queryDiscovery.d.ts.map +1 -0
  11. package/dist/internal/queryDiscovery.js +38 -0
  12. package/dist/internal/queryDiscovery.js.map +1 -0
  13. package/dist/internal/requirements.d.ts +2 -1
  14. package/dist/internal/requirements.d.ts.map +1 -1
  15. package/dist/internal/requirements.js +2 -1
  16. package/dist/internal/requirements.js.map +1 -1
  17. package/dist/internal/simulator.d.ts +19 -3
  18. package/dist/internal/simulator.d.ts.map +1 -1
  19. package/dist/internal/simulator.js +12 -16
  20. package/dist/internal/simulator.js.map +1 -1
  21. package/dist/internal/slots.d.ts +4 -2
  22. package/dist/internal/slots.d.ts.map +1 -1
  23. package/dist/internal/slots.js +4 -2
  24. package/dist/internal/slots.js.map +1 -1
  25. package/dist/txSimulator.d.ts +64 -40
  26. package/dist/txSimulator.d.ts.map +1 -1
  27. package/dist/txSimulator.js +64 -16
  28. package/dist/txSimulator.js.map +1 -1
  29. package/dist/types.d.ts +47 -16
  30. package/dist/types.d.ts.map +1 -1
  31. package/package.json +17 -28
  32. package/src/generated/txSimulatorBytecode.ts +1 -1
  33. package/src/index.ts +3 -1
  34. package/src/internal/queryDiscovery.ts +49 -0
  35. package/src/internal/requirements.ts +3 -1
  36. package/src/internal/simulator.ts +28 -24
  37. package/src/internal/slots.ts +5 -2
  38. package/src/txSimulator.ts +160 -63
  39. package/src/types.ts +50 -17
package/README.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # viem-tx-sim
2
2
 
3
+ - [Motivation](#motivation)
4
+ - [Mental model](#mental-model)
5
+ - [API at a glance](#api-at-a-glance)
6
+ - [Getting started](#getting-started)
7
+ - [Preparing balance and allowance overrides](#preparing-balance-and-allowance-overrides)
8
+ - [Estimating asset requirements (optional)](#estimating-asset-requirements-optional)
9
+ - [Debugging](#debugging)
10
+ - [Decoding Reverts](#decoding-reverts)
11
+ - [Known limitations](#known-limitations)
12
+ - [Development](#development)
13
+ - [Scope](#scope)
14
+
3
15
  RPC-only transaction simulation helpers for [viem](https://viem.sh) applications: preview the asset changes of a transaction (or an ERC-5792 batch) before anyone signs it, using nothing but standard JSON-RPC.
4
16
 
5
17
  ## Motivation
@@ -8,10 +20,43 @@ Credit to the [apoorv X thread](https://x.com/apoorveth/status/20415440704814492
8
20
 
9
21
  Every wallet shows "asset changes" before you sign. Most do it by sending your data to a centralized simulation API — a single point of failure and a privacy leak. viem-tx-sim makes the EVM do the work itself:
10
22
 
11
- 1. `eth_createAccessList` dry-runs each call and returns every contract the transaction touches those become candidate tokens, with no token lists or indexers.
12
- 2. One `eth_call` with state overrides injects a never-deployed `TxSimulator` contract **at the user's own address** and executes the calls. Because the simulator runs as the user, `address(this)` and `msg.sender` are the real account, so balance reads, allowance checks, and `msg.sender`-gated logic behave exactly as they would in the real transaction. Batch calls run sequentially in one EVM context, so an approval in call 1 is visible to a swap in call 2.
23
+ 1. For wallet-style previews, `sim.balanceQueries.forUser()` can dry-run each call with `eth_createAccessList` and filter touched contracts into token balance queries, with no token lists or indexers.
24
+ 2. `sim.simulate()` takes explicit balance queries and performs one `eth_call` with state overrides, injecting a never-deployed `TxSimulator` contract **at the user's own address**. Because the simulator runs as the user, `address(this)` and `msg.sender` are the real account, so balance reads, allowance checks, and `msg.sender`-gated logic behave exactly as they would in the real transaction. Batch calls run sequentially in one EVM context, so an approval in call 1 is visible to a swap in call 2.
25
+
26
+ The core simulation is one RPC call when you already know what to observe. The wallet discovery flow is N access lists + one token-filter call + one simulation for an N-call batch. Zero servers, zero trust assumptions. See [docs/motivation.md](https://github.com/frontier159/viem-tx-sim/blob/main/docs/motivation.md) for the design's origin story, including how Permit2's ERC-1271 path and proxy-token storage are handled.
27
+
28
+ ## Mental model
29
+
30
+ Everything passed to `sim.simulate()` is one of three explicit inputs: `calls` are what executes, `balanceQueries` are what you observe, and `tokenSlotOverrides` are the state assumptions you want to forge. `simulate()` does not discover tokens, retry, or forge balances by itself. The helper namespaces only build those data inputs: `balanceQueries.*` builds observations, and `tokenOverrides.*` builds assumptions.
31
+
32
+ ## API at a glance
33
+
34
+ ```ts
35
+ const sim = TxSimulator.create({ client, gas, debug, errorAbi });
36
+
37
+ const result = await sim.simulate({
38
+ from,
39
+ calls, // SimulatedCall[]
40
+ balanceQueries, // BalanceQuery[]
41
+ tokenSlotOverrides, // TokenSlotOverride[] | undefined
42
+ gas,
43
+ debug,
44
+ errorAbi,
45
+ blockNumber,
46
+ blockTag,
47
+ });
48
+ // success -> { status: "success", balanceDeltas, unresolved }
49
+ // reverted -> success fields + { revertData, failingCallIndex, revertReason?, revertError? }
50
+
51
+ await sim.balanceQueries.forUser({ from, calls }); // BalanceQuery[]
52
+ await sim.balanceQueries.discoverErc20s({ from, calls }); // Address[]
53
+ await sim.tokenOverrides.forBalances({ from, tokens }); // PreparedBalanceOverrides
54
+ await sim.tokenOverrides.forAllowances({ from, pairs }); // PreparedAllowanceOverrides
55
+ await sim.tokenOverrides.estimateRequirements({ from, calls }); // EstimatedAssetRequirements
13
56
 
14
- That is two RPC calls for a single-call transaction, or N + 1 calls for an N-call batch. Zero servers, zero trust assumptions. See [docs/motivation.md](https://github.com/frontier159/viem-tx-sim/blob/main/docs/motivation.md) for the design's origin story, including how Permit2's ERC-1271 path and proxy-token storage are handled.
57
+ // Exports: DEFAULT_SIMULATION_GAS_LIMIT, OVERRIDE_TOKEN_AMOUNT, TxSimError,
58
+ // AccessListUnsupportedError, StateOverrideUnsupportedError, InvalidSimulationInputError.
59
+ ```
15
60
 
16
61
  ## Getting started
17
62
 
@@ -39,39 +84,59 @@ const sim = TxSimulator.create({ client, gas: DEFAULT_SIMULATION_GAS_LIMIT });
39
84
  const user = "0xYourAddress"; // no key or signing involved — any address can be simulated
40
85
  const assets = parseUnits("1000", 18);
41
86
 
87
+ const calls = [
88
+ {
89
+ to: USDS,
90
+ data: encodeFunctionData({
91
+ abi: parseAbi(["function approve(address spender, uint256 amount) returns (bool)"]),
92
+ functionName: "approve",
93
+ args: [SUSDS, assets],
94
+ }),
95
+ },
96
+ {
97
+ to: SUSDS,
98
+ data: encodeFunctionData({
99
+ abi: parseAbi(["function deposit(uint256 assets, address receiver) returns (uint256 shares)"]),
100
+ functionName: "deposit",
101
+ args: [assets, user],
102
+ }),
103
+ },
104
+ ];
105
+ const balanceQueries = await sim.balanceQueries.forUser({ from: user, calls });
42
106
  const result = await sim.simulate({
43
107
  from: user,
44
- calls: [
45
- {
46
- to: USDS,
47
- data: encodeFunctionData({
48
- abi: parseAbi(["function approve(address spender, uint256 amount) returns (bool)"]),
49
- functionName: "approve",
50
- args: [SUSDS, assets],
51
- }),
52
- },
53
- {
54
- to: SUSDS,
55
- data: encodeFunctionData({
56
- abi: parseAbi(["function deposit(uint256 assets, address receiver) returns (uint256 shares)"]),
57
- functionName: "deposit",
58
- args: [assets, user],
59
- }),
60
- },
61
- ],
108
+ calls,
109
+ balanceQueries,
62
110
  });
63
111
 
64
112
  console.log(result.status); // "success"
65
- console.log(result.assetBalanceDeltas);
113
+ console.log(result.balanceDeltas);
66
114
  // [
67
- // { asset: "0xdC03...384F", delta: -1000000000000000000000n }, // 1,000 USDS out
68
- // { asset: "0xa393...7fbD", delta: 9xx...n }, // sUSDS shares in
115
+ // { asset: "native", account: user, before: 1n..., after: 1n..., delta: 0n, byCall: [0n, 0n] },
116
+ // { asset: "0xdC03...384F", account: user, before: 1000n..., after: 0n, delta: -1000n..., byCall: [0n, -1000n...] },
117
+ // { asset: "0xa393...7fbD", account: user, before: 0n, after: 9xx...n, delta: 9xx...n, byCall: [0n, 9xx...n] },
69
118
  // ]
70
119
  ```
71
120
 
72
- Deltas are raw `bigint` amounts in each token's own units, observed from chain state alone. A revert is returned as `status: "reverted"`, never thrown; checking `status` gives typed access to `revertData` and `failingCallIndex`.
121
+ `balanceDeltas` mirror your `balanceQueries` in order, including zero deltas, with raw `bigint` amounts in each asset's own units. `byCall` is index-aligned with `calls`, sums to `delta`, and entries from a failing call onward are `0n` on a returned revert. A revert is returned as `status: "reverted"`, never thrown; checking `status` gives typed access to `revertData` and `failingCallIndex`.
122
+
123
+ `sim.simulate()` observes only the balances you ask for and does not retry or forge state by itself. If `user` doesn't actually hold 1,000 USDS (say you're previewing for a view-only address), prepare and pass a balance override — see the next section. Query the tokens you forge if you want to observe them. `DEFAULT_SIMULATION_GAS_LIMIT` is exported for callers that want to pass or display the default 16M simulation gas budget.
124
+
125
+ If your dapp already knows what it needs to inspect, skip wallet discovery and pass explicit queries. This can observe any account, not just `from`:
126
+
127
+ ```ts
128
+ const balanceQueries = tokens.map((asset) => ({ asset, account: pluginAddress }));
129
+ const result = await sim.simulate({
130
+ from: user,
131
+ calls: partialBundle,
132
+ balanceQueries,
133
+ });
134
+ const leftoverAfterZap = result.balanceDeltas.find(
135
+ (delta) => delta.asset === flashToken && delta.account === pluginAddress,
136
+ )?.byCall[0];
137
+ ```
73
138
 
74
- `sim.simulate()` runs against the account's real balances and does not retry or forge state by itself. If `user` doesn't actually hold 1,000 USDS (say you're previewing for a view-only address), prepare and pass a balance override — see the next section. `DEFAULT_SIMULATION_GAS_LIMIT` is exported for callers that want to pass or display the default 16M simulation gas budget.
139
+ For approvals, either include an `approve` / `permit` call in `calls` so later calls see it, or use `sim.tokenOverrides.forAllowances()` when you need to simulate already-approved state without sending an approval call.
75
140
 
76
141
  ## Preparing balance and allowance overrides
77
142
 
@@ -81,11 +146,11 @@ Override preparation is explicit and cacheable. Preparation returns ready-to-use
81
146
  import { TxSimulator } from "viem-tx-sim";
82
147
 
83
148
  const sim = TxSimulator.create({ client });
84
- const balanceOverrides = await sim.prepareBalanceOverrides({
149
+ const balanceOverrides = await sim.tokenOverrides.forBalances({
85
150
  from,
86
151
  tokens: [token],
87
152
  });
88
- const allowanceOverrides = await sim.prepareAllowanceOverrides({
153
+ const allowanceOverrides = await sim.tokenOverrides.forAllowances({
89
154
  from,
90
155
  pairs: [{ token, spender }],
91
156
  });
@@ -93,6 +158,7 @@ const allowanceOverrides = await sim.prepareAllowanceOverrides({
93
158
  const result = await sim.simulate({
94
159
  from,
95
160
  calls: [{ to, data }],
161
+ balanceQueries: [{ asset: token, account: from }],
96
162
  tokenSlotOverrides: [...balanceOverrides.slots, ...allowanceOverrides.slots],
97
163
  });
98
164
  ```
@@ -101,13 +167,13 @@ Prepared balance overrides are reusable per token/owner, and prepared allowance
101
167
 
102
168
  ## Estimating asset requirements (optional)
103
169
 
104
- When you don't already know which balances and approvals a transaction needs, `sim.estimateAssetRequirements()` measures them by forging generous state and observing per-call balance and allowance changes. Returned amounts are estimates measured under forged state and should be padded; pairs whose allowance is set inside the batch (approve or permit) are excluded, and measured allowance decreases are sanity-bounded by the token's gross outflow. Measurements discarded by that bound are reported under `unresolved.allowances`.
170
+ When you don't already know which balances and approvals a transaction needs, `sim.tokenOverrides.estimateRequirements()` measures them by forging generous state and observing per-call balance and allowance changes. Returned amounts are estimates measured under forged state and should be padded; pairs whose allowance is set inside the batch (approve or permit) are excluded, and measured allowance decreases are sanity-bounded by the token's gross outflow. Measurements discarded by that bound are reported under `unresolved.allowances`.
105
171
 
106
172
  ```ts
107
173
  import { TxSimulator } from "viem-tx-sim";
108
174
 
109
175
  const sim = TxSimulator.create({ client });
110
- const requirements = await sim.estimateAssetRequirements({ from, calls });
176
+ const requirements = await sim.tokenOverrides.estimateRequirements({ from, calls });
111
177
  // requirements.allowances -> [{ token, spender, amount }]
112
178
  // requirements.balances -> [{ token, amount }]
113
179
  // requirements.slots -> feed to sim.simulate({ ..., tokenSlotOverrides })
@@ -115,6 +181,7 @@ const requirements = await sim.estimateAssetRequirements({ from, calls });
115
181
  const result = await sim.simulate({
116
182
  from,
117
183
  calls,
184
+ balanceQueries: await sim.balanceQueries.forUser({ from, calls }),
118
185
  tokenSlotOverrides: requirements.slots,
119
186
  });
120
187
  ```
@@ -130,6 +197,7 @@ const sim = TxSimulator.create({ client });
130
197
  const result = await sim.simulate({
131
198
  from,
132
199
  calls: [{ to, data, value: 0n }],
200
+ balanceQueries: [],
133
201
  debug: true,
134
202
  });
135
203
  ```
@@ -140,6 +208,7 @@ Or pass a callback to collect structured events:
140
208
  await sim.simulate({
141
209
  from,
142
210
  calls: [{ to, data }],
211
+ balanceQueries: [],
143
212
  debug: (event) => {
144
213
  console.debug(event.method, event.step, event.phase, event.durationMs);
145
214
  },
@@ -171,13 +240,13 @@ Situations the simulation does not cover, or where the preview can differ from r
171
240
 
172
241
  **An adversarial contract can detect it is being simulated** — via the code at `from`, the recognizable forged balances, or `eth_call` context — and behave differently in the real transaction. This is inherent to state-override simulation (centralized simulation APIs share it). Treat the preview as best-effort insight, not a security guarantee against malicious contracts.
173
242
 
174
- **Results are estimates against one block's state.** Deltas and estimated asset requirements reflect the chosen block; prices, liquidity, and allowances move before the real transaction lands. Pad amounts accordingly. Amounts from `sim.estimateAssetRequirements()` are additionally measured under forged (very large) balances, so contracts that branch on the account's real balance can be measured on the wrong branch.
243
+ **Results are estimates against one block's state.** Deltas and estimated asset requirements reflect the chosen block; prices, liquidity, and allowances move before the real transaction lands. Pad amounts accordingly. Amounts from `sim.tokenOverrides.estimateRequirements()` are additionally measured under forged (very large) balances, so contracts that branch on the account's real balance can be measured on the wrong branch.
175
244
 
176
245
  **Asset coverage is native + `balanceOf(address)`.** Deltas track ETH and anything answering ERC-20-style `balanceOf` (an ERC-721 shows up as a count delta, without token IDs). ERC-1155 balances (`balanceOf(address,uint256)`) are not tracked. Tokens whose balance is computed rather than stored in one slot per holder (rebasing/share-based tokens like stETH) cannot be forged — override preparation verifies slots before writing and reports them in the `unresolved` list.
177
246
 
178
- **Candidate discovery follows the dry run.** Token candidates come from `eth_createAccessList` on the *unforged* calls; if that dry run reverts early, contracts that would only be touched later are not discovered, and their deltas are missed. Forging (or `estimateAssetRequirements()`, which measures after forging) avoids most of this.
247
+ **Wallet discovery follows the dry run.** `sim.balanceQueries.forUser()` token candidates come from `eth_createAccessList` on the *unforged* calls; if that dry run reverts early, contracts that would only be touched later are not discovered. Explicit `balanceQueries` avoid this when your app already knows the assets or accounts to observe.
179
248
 
180
- **RPC provider requirements.** The provider must support `eth_createAccessList` (including returning the access list for reverting calls) and `eth_call` with state overrides. Missing support surfaces as `AccessListUnsupportedError` / `StateOverrideUnsupportedError`.
249
+ **RPC provider requirements.** `sim.simulate()` requires `eth_call` with state overrides. `sim.balanceQueries.forUser()`, `sim.balanceQueries.discoverErc20s()`, `sim.tokenOverrides.*`, and asset-requirement estimation also require `eth_createAccessList` (including returning the access list for reverting calls). Missing support surfaces as `AccessListUnsupportedError` / `StateOverrideUnsupportedError`.
181
250
 
182
251
  **Not a gas estimator.** The simulation runs under `DEFAULT_SIMULATION_GAS_LIMIT` by default and the injected code changes gas accounting; use `eth_estimateGas` on the real transaction for gas.
183
252
 
@@ -225,4 +294,4 @@ Set `MAINNET_BLOCK_NUMBER` to override the pinned default block.
225
294
 
226
295
  ## Scope
227
296
 
228
- V1 returns raw balance deltas only. Token metadata, token lists, indexers, centralized simulation APIs, approval UX, and price enrichment are intentionally out of scope.
297
+ The library returns explicit raw balance observations only. Token metadata, token lists, indexers, centralized simulation APIs, approval UX, and price enrichment are intentionally out of scope. The library never constructs or signs permits or EIP-712 payloads; callers bring fully signed calldata, and already-signed permit calls simulate as ordinary calls.
@@ -21,6 +21,11 @@ contract TxSimulator is IERC1271Like {
21
21
  address spender;
22
22
  }
23
23
 
24
+ struct BalanceProbe {
25
+ address token;
26
+ address account;
27
+ }
28
+
24
29
  struct SimulationResult {
25
30
  bool success;
26
31
  uint256 failingCallIndex;
@@ -32,6 +37,8 @@ contract TxSimulator is IERC1271Like {
32
37
  uint256[] maxTokenOutflows;
33
38
  uint256 maxNativeOutflow;
34
39
  uint256[] allowanceCheckpoints;
40
+ uint256[] balanceCheckpoints;
41
+ bool[] balanceProbeOk;
35
42
  }
36
43
 
37
44
  struct TokenState {
@@ -45,27 +52,36 @@ contract TxSimulator is IERC1271Like {
45
52
  struct ExecutionState {
46
53
  bool[] isToken;
47
54
  uint256[] minBalances;
48
- uint256[] checkpoints;
55
+ uint256[] allowanceCheckpoints;
56
+ uint256[] balanceCheckpoints;
57
+ bool[] balanceProbeOk;
49
58
  uint256 stride;
50
59
  }
51
60
 
52
- function simulate(SimulatedCall[] calldata calls, address[] calldata candidates, AllowanceProbe[] calldata probes)
53
- external
54
- returns (SimulationResult memory result)
55
- {
61
+ function simulate(
62
+ SimulatedCall[] calldata calls,
63
+ address[] calldata candidates,
64
+ AllowanceProbe[] calldata probes,
65
+ BalanceProbe[] calldata balanceProbes
66
+ ) external returns (SimulationResult memory result) {
56
67
  uint256 nativeBefore = address(this).balance;
57
68
  TokenState memory tokenState = _snapshotTokens(candidates);
69
+ uint256 stride = calls.length + 1;
70
+ result.balanceCheckpoints = new uint256[](balanceProbes.length * stride);
71
+ result.balanceProbeOk = new bool[](balanceProbes.length);
58
72
 
59
- result.allowanceCheckpoints = new uint256[](probes.length * (calls.length + 1));
73
+ result.allowanceCheckpoints = new uint256[](probes.length * stride);
60
74
  ExecutionState memory executionState = ExecutionState({
61
75
  isToken: tokenState.isToken,
62
76
  minBalances: tokenState.minBalances,
63
- checkpoints: result.allowanceCheckpoints,
64
- stride: calls.length + 1
77
+ allowanceCheckpoints: result.allowanceCheckpoints,
78
+ balanceCheckpoints: result.balanceCheckpoints,
79
+ balanceProbeOk: result.balanceProbeOk,
80
+ stride: stride
65
81
  });
66
82
  uint256 nativeMin;
67
83
  (result.success, result.failingCallIndex, result.revertData, nativeMin) =
68
- _executeCalls(calls, candidates, probes, executionState, nativeBefore);
84
+ _executeCalls(calls, candidates, probes, balanceProbes, executionState);
69
85
 
70
86
  result.nativeDelta = _signedDelta(address(this).balance, nativeBefore);
71
87
  result.observedTokens = _trimAddresses(tokenState.observedScratch, tokenState.observedCount);
@@ -148,24 +164,38 @@ contract TxSimulator is IERC1271Like {
148
164
  SimulatedCall[] calldata calls,
149
165
  address[] calldata candidates,
150
166
  AllowanceProbe[] calldata probes,
151
- ExecutionState memory executionState,
152
- uint256 nativeBefore
167
+ BalanceProbe[] calldata balanceProbes,
168
+ ExecutionState memory executionState
153
169
  ) internal returns (bool success, uint256 failingCallIndex, bytes memory revertData, uint256 nativeMin) {
154
170
  success = true;
155
171
  failingCallIndex = type(uint256).max;
156
- nativeMin = nativeBefore;
172
+ nativeMin = address(this).balance;
157
173
  if (probes.length > 0) {
158
- _recordAllowanceCheckpoints(probes, executionState.stride, 0, executionState.checkpoints);
174
+ _recordAllowanceCheckpoints(probes, executionState.stride, 0, executionState.allowanceCheckpoints);
175
+ }
176
+ if (balanceProbes.length > 0) {
177
+ _recordBalanceCheckpoints(
178
+ balanceProbes,
179
+ executionState.stride,
180
+ 0,
181
+ executionState.balanceCheckpoints,
182
+ executionState.balanceProbeOk
183
+ );
159
184
  }
160
185
 
161
186
  for (uint256 i = 0; i < calls.length; ++i) {
162
- (bool ok, bytes memory callRevertData) = _executeCall(calls[i]);
163
- if (!ok) {
164
- success = false;
187
+ (success, revertData) = _executeCall(calls[i]);
188
+ if (!success) {
165
189
  failingCallIndex = i;
166
- revertData = callRevertData;
167
190
  if (probes.length > 0) {
168
- _fillRemainingCheckpoints(probes.length, executionState.stride, i, executionState.checkpoints);
191
+ _fillRemainingCheckpoints(
192
+ probes.length, executionState.stride, i, executionState.allowanceCheckpoints
193
+ );
194
+ }
195
+ if (balanceProbes.length > 0) {
196
+ _fillRemainingCheckpoints(
197
+ balanceProbes.length, executionState.stride, i, executionState.balanceCheckpoints
198
+ );
169
199
  }
170
200
  break;
171
201
  }
@@ -174,14 +204,24 @@ contract TxSimulator is IERC1271Like {
174
204
  if (nativeAfter < nativeMin) nativeMin = nativeAfter;
175
205
  _updateMinBalances(candidates, executionState.isToken, executionState.minBalances);
176
206
  if (probes.length > 0) {
177
- _recordAllowanceCheckpoints(probes, executionState.stride, i + 1, executionState.checkpoints);
207
+ _recordAllowanceCheckpoints(probes, executionState.stride, i + 1, executionState.allowanceCheckpoints);
208
+ }
209
+ if (balanceProbes.length > 0) {
210
+ _recordBalanceCheckpoints(
211
+ balanceProbes,
212
+ executionState.stride,
213
+ i + 1,
214
+ executionState.balanceCheckpoints,
215
+ executionState.balanceProbeOk
216
+ );
178
217
  }
179
218
  }
180
219
  }
181
220
 
182
221
  function _executeCall(SimulatedCall calldata call_) internal returns (bool ok, bytes memory revertData) {
183
222
  // forge-lint: disable-next-line(low-level-calls, arbitrary-send-eth, calls-loop)
184
- return call_.to.call{value: call_.value}(call_.data);
223
+ (ok, revertData) = call_.to.call{value: call_.value}(call_.data);
224
+ if (ok) revertData = "";
185
225
  }
186
226
 
187
227
  function _updateMinBalances(address[] calldata candidates, bool[] memory isToken, uint256[] memory minBalances)
@@ -208,6 +248,20 @@ contract TxSimulator is IERC1271Like {
208
248
  }
209
249
  }
210
250
 
251
+ function _recordBalanceCheckpoints(
252
+ BalanceProbe[] calldata probes,
253
+ uint256 stride,
254
+ uint256 offset,
255
+ uint256[] memory checkpoints,
256
+ bool[] memory ok
257
+ ) internal view {
258
+ for (uint256 i = 0; i < probes.length; ++i) {
259
+ (bool readOk, uint256 balance) = _readBalanceProbe(probes[i]);
260
+ checkpoints[i * stride + offset] = readOk ? balance : 0;
261
+ ok[i] = offset == 0 ? readOk : ok[i] && readOk;
262
+ }
263
+ }
264
+
211
265
  function _fillRemainingCheckpoints(
212
266
  uint256 probeCount,
213
267
  uint256 stride,
@@ -230,6 +284,15 @@ contract TxSimulator is IERC1271Like {
230
284
  balance = abi.decode(data, (uint256));
231
285
  }
232
286
 
287
+ function _readBalanceProbe(BalanceProbe calldata probe) internal view returns (bool ok, uint256 balance) {
288
+ if (probe.token == address(0)) {
289
+ ok = true;
290
+ balance = probe.account.balance;
291
+ return (ok, balance);
292
+ }
293
+ return _tryBalanceOf(probe.token, probe.account);
294
+ }
295
+
233
296
  function _tryAllowance(address token, address owner, address spender)
234
297
  internal
235
298
  view
@@ -1,2 +1,2 @@
1
- export declare const txSimulatorRuntimeBytecode: "0x60806040526004361061004c575f3560e01c8063150b7a02146100575780631626ba7e146100a0578063bc197c81146100bf578063cb8935e9146100ed578063f23a6e6114610119575f80fd5b3661005357005b5f80fd5b348015610062575f80fd5b506100826100713660046110ac565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100ab575f80fd5b506100826100ba366004611115565b610145565b3480156100ca575f80fd5b506100826100d936600461119c565b63bc197c8160e01b98975050505050505050565b3480156100f8575f80fd5b5061010c61010736600461124e565b610181565b60405161009791906113cb565b348015610124575f80fd5b506100826101333660046114b9565b63f23a6e6160e01b9695505050505050565b5f30610152858585610300565b6001600160a01b03161461016e576001600160e01b0319610177565b630b135d3f60e11b5b90505b9392505050565b6101d56040518061014001604052805f151581526020015f8152602001606081526020015f8152602001606081526020016060815260200160608152602001606081526020015f8152602001606081525090565b475f6101e18787610456565b90506101ee88600161153f565b6101f89085611552565b6001600160401b0381111561020f5761020f611569565b604051908082528060200260200182016040528015610238578160200160208202803683370190505b50610120840190815260408051608081018252838201518152602080850151908201529151908201525f90606081016102728b600161153f565b905290505f6102878b8b8b8b8b8b888b6106d5565b60408901919091526020880191909152901515865290506102a847856107cd565b8560600181815250506102c383606001518460800151610844565b6080860152808410156102d6575f6102e0565b6102e0818561157d565b6101008601526102f2898985886108e0565b505050509695505050505050565b5f60418290036103bb578235602084013560408501355f1a601b81101561032f5761032c601b82611590565b90505b8060ff16601b1415801561034757508060ff16601c14155b15610357575f935050505061017a565b604080515f81526020810180835289905260ff831691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa1580156103a7573d5f803e3d5ffd5b50505060206040510351935050505061017a565b604082900361044d57823560208401356001600160ff1b0381165f6103e560ff84901c601b61153f565b604080515f8152602081018083528b905260ff831691810191909152606081018690526080810184905290915060019060a0016020604051602081039080840390855afa158015610438573d5f803e3d5ffd5b5050506020604051035194505050505061017a565b505f9392505050565b6104876040518060a00160405280606081526020016060815260200160608152602001606081526020015f81525090565b816001600160401b0381111561049f5761049f611569565b6040519080825280602002602001820160405280156104c8578160200160208202803683370190505b508152816001600160401b038111156104e3576104e3611569565b60405190808252806020026020018201604052801561050c578160200160208202803683370190505b506020820152816001600160401b0381111561052a5761052a611569565b604051908082528060200260200182016040528015610553578160200160208202803683370190505b506040820152816001600160401b0381111561057157610571611569565b60405190808252806020026020018201604052801561059a578160200160208202803683370190505b5060608201525f5b828110156106ce575f806105dc8686858181106105c1576105c16115a9565b90506020020160208101906105d691906115bd565b30610b97565b9150915081156106c4576001846040015184815181106105fe576105fe6115a9565b60200260200101901515908115158152505080845f01518481518110610626576106266115a9565b6020026020010181815250508084602001518481518110610649576106496115a9565b602002602001018181525050858584818110610667576106676115a9565b905060200201602081019061067c91906115bd565b606085015160808601805190610691826115d6565b9052815181106106a3576106a36115a9565b60200260200101906001600160a01b031690816001600160a01b0316815250505b50506001016105a2565b5092915050565b60015f1960608386156106f7576106f7888888606001515f8a60400151610c6f565b5f5b8b8110156107bd575f8061072f8f8f85818110610718576107186115a9565b905060200281019061072a91906115ee565b610d2a565b9150915081610768575f96509194509092508390838915610761576107618b8b90508a60600151858c60400151610dac565b50506107bd565b4784811015610775578094505b6107888e8e8c5f01518d60200151610e4b565b8a156107af576107af8c8c8c606001518760016107a5919061153f565b8e60400151610c6f565b5050508060010190506106f9565b5098509850985098945050505050565b5f818310610808575f6107e0838561157d565b90506001600160ff1b03811115610801576001600160ff1b0391505061083e565b905061083e565b5f610813848461157d565b90506001600160ff1b0381111561083157600160ff1b91505061083e565b61083a8161160c565b9150505b92915050565b6060816001600160401b0381111561085e5761085e611569565b604051908082528060200260200182016040528015610887578160200160208202803683370190505b5090505f5b828110156106ce578381815181106108a6576108a66115a9565b60200260200101518282815181106108c0576108c06115a9565b6001600160a01b039092166020928302919091019091015260010161088c565b826001600160401b038111156108f8576108f8611569565b604051908082528060200260200182016040528015610921578160200160208202803683370190505b5060e08201525f836001600160401b0381111561094057610940611569565b604051908082528060200260200182016040528015610969578160200160208202803683370190505b5090505f846001600160401b0381111561098557610985611569565b6040519080825280602002602001820160405280156109ae578160200160208202803683370190505b5090505f805b86811015610b6c57856040015181815181106109d2576109d26115a9565b602002602001015115610b6457856020015181815181106109f5576109f56115a9565b6020026020010151865f01518281518110610a1257610a126115a9565b602002602001015110610a875785602001518181518110610a3557610a356115a9565b6020026020010151865f01518281518110610a5257610a526115a9565b6020026020010151610a64919061157d565b8560e001518281518110610a7a57610a7a6115a9565b6020026020010181815250505b5f80610a9e8a8a858181106105c1576105c16115a9565b9150915081610aae575050610b64565b5f610ad5828a5f01518681518110610ac857610ac86115a9565b60200260200101516107cd565b90508015610b60578a8a85818110610aef57610aef6115a9565b9050602002016020810190610b0491906115bd565b878681518110610b1657610b166115a9565b60200260200101906001600160a01b031690816001600160a01b03168152505080868681518110610b4957610b496115a9565b6020908102919091010152610b5d856115d6565b94505b5050505b6001016109b4565b50610b778382610844565b60a0850152610b868282610ee4565b8460c0018190525050505050505050565b604080516001600160a01b0383811660248084019190915283518084039091018152604490920183526020820180516001600160e01b03166370a0823160e01b17905291515f92839283928392881691610bf091611626565b5f60405180830381855afa9150503d805f8114610c28576040519150601f19603f3d011682016040523d82523d5f602084013e610c2d565b606091505b5091509150811580610c40575060208151105b15610c4c575050610c68565b81935080806020019051810190610c639190611637565b925050505b9250929050565b5f5b84811015610d22575f80610cd6888885818110610c9057610c906115a9565b610ca692602060409092020190810191506115bd565b308a8a87818110610cb957610cb96115a9565b9050604002016020016020810190610cd191906115bd565b610f73565b9150915081610ce5575f610ce7565b805b8486610cf38987611552565b610cfd919061153f565b81518110610d0d57610d0d6115a9565b60209081029190910101525050600101610c71565b505050505050565b5f6060610d3a60208401846115bd565b6001600160a01b03166020840135610d55604086018661164e565b604051610d63929190611690565b5f6040518083038185875af1925050503d805f8114610d9d576040519150601f19603f3d011682016040523d82523d5f602084013e610da2565b606091505b5091509150915091565b5f5b84811015610e44575f8284610dc38785611552565b610dcd919061153f565b81518110610ddd57610ddd6115a9565b602002602001015190505f846001610df5919061153f565b90505b85811015610e3a57818482610e0d8987611552565b610e17919061153f565b81518110610e2757610e276115a9565b6020908102919091010152600101610df8565b5050600101610dae565b5050505050565b5f5b83811015610e4457828181518110610e6757610e676115a9565b602002602001015115610edc575f80610e8b8787858181106105c1576105c16115a9565b91509150818015610eb45750838381518110610ea957610ea96115a9565b602002602001015181105b15610ed95780848481518110610ecc57610ecc6115a9565b6020026020010181815250505b50505b600101610e4d565b6060816001600160401b03811115610efe57610efe611569565b604051908082528060200260200182016040528015610f27578160200160208202803683370190505b5090505f5b828110156106ce57838181518110610f4657610f466115a9565b6020026020010151828281518110610f6057610f606115a9565b6020908102919091010152600101610f2c565b604080516001600160a01b03848116602483015283811660448084019190915283518084039091018152606490920183526020820180516001600160e01b0316636eb1769f60e11b17905291515f92839283928392891691610fd491611626565b5f60405180830381855afa9150503d805f811461100c576040519150601f19603f3d011682016040523d82523d5f602084013e611011565b606091505b5091509150811580611024575060208151105b1561103057505061104c565b819350808060200190518101906110479190611637565b925050505b935093915050565b80356001600160a01b038116811461106a575f80fd5b919050565b5f8083601f84011261107f575f80fd5b5081356001600160401b03811115611095575f80fd5b602083019150836020828501011115610c68575f80fd5b5f805f805f608086880312156110c0575f80fd5b6110c986611054565b94506110d760208701611054565b93506040860135925060608601356001600160401b038111156110f8575f80fd5b6111048882890161106f565b969995985093965092949392505050565b5f805f60408486031215611127575f80fd5b8335925060208401356001600160401b03811115611143575f80fd5b61114f8682870161106f565b9497909650939450505050565b5f8083601f84011261116c575f80fd5b5081356001600160401b03811115611182575f80fd5b6020830191508360208260051b8501011115610c68575f80fd5b5f805f805f805f8060a0898b0312156111b3575f80fd5b6111bc89611054565b97506111ca60208a01611054565b965060408901356001600160401b03808211156111e5575f80fd5b6111f18c838d0161115c565b909850965060608b0135915080821115611209575f80fd5b6112158c838d0161115c565b909650945060808b013591508082111561122d575f80fd5b5061123a8b828c0161106f565b999c989b5096995094979396929594505050565b5f805f805f8060608789031215611263575f80fd5b86356001600160401b0380821115611279575f80fd5b6112858a838b0161115c565b9098509650602089013591508082111561129d575f80fd5b6112a98a838b0161115c565b909650945060408901359150808211156112c1575f80fd5b818901915089601f8301126112d4575f80fd5b8135818111156112e2575f80fd5b8a60208260061b85010111156112f6575f80fd5b6020830194508093505050509295509295509295565b5f5b8381101561132657818101518382015260200161130e565b50505f910152565b5f815180845261134581602086016020860161130c565b601f01601f19169290920160200192915050565b5f815180845260208085019450602084015f5b838110156113915781516001600160a01b03168752958201959082019060010161136c565b509495945050505050565b5f815180845260208085019450602084015f5b83811015611391578151875295820195908201906001016113af565b602081526113de60208201835115159052565b602082015160408201525f604083015161014080606085015261140561016085018361132e565b9150606085015160808501526080850151601f19808685030160a087015261142d8483611359565b935060a08701519150808685030160c087015261144a8483611359565b935060c08701519150808685030160e0870152611467848361139c565b935060e08701519150610100818786030181880152611486858461139c565b908801516101208881019190915288015187820390920184880152935090506114af838261139c565b9695505050505050565b5f805f805f8060a087890312156114ce575f80fd5b6114d787611054565b95506114e560208801611054565b9450604087013593506060870135925060808701356001600160401b0381111561150d575f80fd5b61151989828a0161106f565b979a9699509497509295939492505050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561083e5761083e61152b565b808202811582820484141761083e5761083e61152b565b634e487b7160e01b5f52604160045260245ffd5b8181038181111561083e5761083e61152b565b60ff818116838216019081111561083e5761083e61152b565b634e487b7160e01b5f52603260045260245ffd5b5f602082840312156115cd575f80fd5b61017a82611054565b5f600182016115e7576115e761152b565b5060010190565b5f8235605e19833603018112611602575f80fd5b9190910192915050565b5f600160ff1b82016116205761162061152b565b505f0390565b5f825161160281846020870161130c565b5f60208284031215611647575f80fd5b5051919050565b5f808335601e19843603018112611663575f80fd5b8301803591506001600160401b0382111561167c575f80fd5b602001915036819003821315610c68575f80fd5b818382375f910190815291905056fea2646970667358221220c9adb57984fec989769acf8df499b49fd3aadd781fd0b128ec026480393cb0a764736f6c63430008180033";
1
+ export declare const txSimulatorRuntimeBytecode: "0x60806040526004361061004c575f3560e01c8063150b7a02146100575780631626ba7e146100a05780639b093492146100bf578063bc197c81146100eb578063f23a6e6114610119575f80fd5b3661005357005b5f80fd5b348015610062575f80fd5b50610082610071366004611316565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100ab575f80fd5b506100826100ba36600461137f565b610145565b3480156100ca575f80fd5b506100de6100d9366004611446565b610181565b60405161009791906115f0565b3480156100f6575f80fd5b5061008261010536600461171e565b63bc197c8160e01b98975050505050505050565b348015610124575f80fd5b506100826101333660046117bc565b63f23a6e6160e01b9695505050505050565b5f306101528585856103b6565b6001600160a01b03161461016e576001600160e01b0319610177565b630b135d3f60e11b5b90505b9392505050565b6101e36040518061018001604052805f151581526020015f8152602001606081526020015f8152602001606081526020016060815260200160608152602001606081526020015f81526020016060815260200160608152602001606081525090565b475f6101ef898961050c565b90505f6101fd8b6001611842565b90506102098186611855565b6001600160401b038111156102205761022061186c565b604051908082528060200260200182016040528015610249578160200160208202803683370190505b50610140850152846001600160401b038111156102685761026861186c565b604051908082528060200260200182016040528015610291578160200160208202803683370190505b506101608501526102a28188611855565b6001600160401b038111156102b9576102b961186c565b6040519080825280602002602001820160405280156102e2578160200160208202803683370190505b5061012085019081526040805160c081018252848201518152602080860151908201529151908201526101408501516060820152610160850151608082015260a081018290525f61033a8e8e8e8e8e8e8e8e8a61078b565b60408a019190915260208901919091529015158752905061035b47866108dc565b86606001818152505061037684606001518560800151610953565b608087015280851015610389575f610393565b6103938186611880565b6101008701526103a58c8c86896109ef565b505050505098975050505050505050565b5f6041829003610471578235602084013560408501355f1a601b8110156103e5576103e2601b82611893565b90505b8060ff16601b141580156103fd57508060ff16601c14155b1561040d575f935050505061017a565b604080515f81526020810180835289905260ff831691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa15801561045d573d5f803e3d5ffd5b50505060206040510351935050505061017a565b604082900361050357823560208401356001600160ff1b0381165f61049b60ff84901c601b611842565b604080515f8152602081018083528b905260ff831691810191909152606081018690526080810184905290915060019060a0016020604051602081039080840390855afa1580156104ee573d5f803e3d5ffd5b5050506020604051035194505050505061017a565b505f9392505050565b61053d6040518060a00160405280606081526020016060815260200160608152602001606081526020015f81525090565b816001600160401b038111156105555761055561186c565b60405190808252806020026020018201604052801561057e578160200160208202803683370190505b508152816001600160401b038111156105995761059961186c565b6040519080825280602002602001820160405280156105c2578160200160208202803683370190505b506020820152816001600160401b038111156105e0576105e061186c565b604051908082528060200260200182016040528015610609578160200160208202803683370190505b506040820152816001600160401b038111156106275761062761186c565b604051908082528060200260200182016040528015610650578160200160208202803683370190505b5060608201525f5b82811015610784575f80610692868685818110610677576106776118ac565b905060200201602081019061068c91906118c0565b30610ca6565b91509150811561077a576001846040015184815181106106b4576106b46118ac565b60200260200101901515908115158152505080845f015184815181106106dc576106dc6118ac565b60200260200101818152505080846020015184815181106106ff576106ff6118ac565b60200260200101818152505085858481811061071d5761071d6118ac565b905060200201602081019061073291906118c0565b606085015160808601805190610747826118d9565b905281518110610759576107596118ac565b60200260200101906001600160a01b031690816001600160a01b0316815250505b5050600101610658565b5092915050565b60015f1960604787156107ad576107ad89898760a001515f8960400151610d7e565b85156107cd576107cd87878760a001515f89606001518a60800151610e39565b5f5b8c8110156108cb576108038e8e838181106107ec576107ec6118ac565b90506020028101906107fe91906118f1565b610f0c565b90955092508461084f57925082881561082d5761082d8a8a90508760a00151838960400151610fa5565b861561084a5761084a888890508760a00151838960600151610fa5565b6108cb565b478281101561085c578092505b61086f8d8d895f01518a60200151611044565b8915610896576108968b8b8960a0015185600161088c9190611842565b8b60400151610d7e565b87156108c2576108c289898960a001518560016108b39190611842565b8b606001518c60800151610e39565b506001016107cf565b509950995099509995505050505050565b5f818310610917575f6108ef8385611880565b90506001600160ff1b03811115610910576001600160ff1b0391505061094d565b905061094d565b5f6109228484611880565b90506001600160ff1b0381111561094057600160ff1b91505061094d565b6109498161190f565b9150505b92915050565b6060816001600160401b0381111561096d5761096d61186c565b604051908082528060200260200182016040528015610996578160200160208202803683370190505b5090505f5b82811015610784578381815181106109b5576109b56118ac565b60200260200101518282815181106109cf576109cf6118ac565b6001600160a01b039092166020928302919091019091015260010161099b565b826001600160401b03811115610a0757610a0761186c565b604051908082528060200260200182016040528015610a30578160200160208202803683370190505b5060e08201525f836001600160401b03811115610a4f57610a4f61186c565b604051908082528060200260200182016040528015610a78578160200160208202803683370190505b5090505f846001600160401b03811115610a9457610a9461186c565b604051908082528060200260200182016040528015610abd578160200160208202803683370190505b5090505f805b86811015610c7b5785604001518181518110610ae157610ae16118ac565b602002602001015115610c735785602001518181518110610b0457610b046118ac565b6020026020010151865f01518281518110610b2157610b216118ac565b602002602001015110610b965785602001518181518110610b4457610b446118ac565b6020026020010151865f01518281518110610b6157610b616118ac565b6020026020010151610b739190611880565b8560e001518281518110610b8957610b896118ac565b6020026020010181815250505b5f80610bad8a8a85818110610677576106776118ac565b9150915081610bbd575050610c73565b5f610be4828a5f01518681518110610bd757610bd76118ac565b60200260200101516108dc565b90508015610c6f578a8a85818110610bfe57610bfe6118ac565b9050602002016020810190610c1391906118c0565b878681518110610c2557610c256118ac565b60200260200101906001600160a01b031690816001600160a01b03168152505080868681518110610c5857610c586118ac565b6020908102919091010152610c6c856118d9565b94505b5050505b600101610ac3565b50610c868382610953565b60a0850152610c9582826110dd565b8460c0018190525050505050505050565b604080516001600160a01b0383811660248084019190915283518084039091018152604490920183526020820180516001600160e01b03166370a0823160e01b17905291515f92839283928392881691610cff91611929565b5f60405180830381855afa9150503d805f8114610d37576040519150601f19603f3d011682016040523d82523d5f602084013e610d3c565b606091505b5091509150811580610d4f575060208151105b15610d5b575050610d77565b81935080806020019051810190610d72919061193a565b925050505b9250929050565b5f5b84811015610e31575f80610de5888885818110610d9f57610d9f6118ac565b610db592602060409092020190810191506118c0565b308a8a87818110610dc857610dc86118ac565b9050604002016020016020810190610de091906118c0565b61116c565b9150915081610df4575f610df6565b805b8486610e028987611855565b610e0c9190611842565b81518110610e1c57610e1c6118ac565b60209081029190910101525050600101610d80565b505050505050565b5f5b85811015610f03575f80610e65898985818110610e5a57610e5a6118ac565b90506040020161124d565b9150915081610e74575f610e76565b805b8587610e828a87611855565b610e8c9190611842565b81518110610e9c57610e9c6118ac565b60209081029190910101528515610ed557838381518110610ebf57610ebf6118ac565b60200260200101518015610ed05750815b610ed7565b815b848481518110610ee957610ee96118ac565b911515602092830291909101909101525050600101610e3b565b50505050505050565b5f6060610f1c60208401846118c0565b6001600160a01b03166020840135610f376040860186611951565b604051610f45929190611993565b5f6040518083038185875af1925050503d805f8114610f7f576040519150601f19603f3d011682016040523d82523d5f602084013e610f84565b606091505b5090925090508115610fa0575060408051602081019091525f81525b915091565b5f5b8481101561103d575f8284610fbc8785611855565b610fc69190611842565b81518110610fd657610fd66118ac565b602002602001015190505f846001610fee9190611842565b90505b85811015611033578184826110068987611855565b6110109190611842565b81518110611020576110206118ac565b6020908102919091010152600101610ff1565b5050600101610fa7565b5050505050565b5f5b8381101561103d57828181518110611060576110606118ac565b6020026020010151156110d5575f80611084878785818110610677576106776118ac565b915091508180156110ad57508383815181106110a2576110a26118ac565b602002602001015181105b156110d257808484815181106110c5576110c56118ac565b6020026020010181815250505b50505b600101611046565b6060816001600160401b038111156110f7576110f761186c565b604051908082528060200260200182016040528015611120578160200160208202803683370190505b5090505f5b828110156107845783818151811061113f5761113f6118ac565b6020026020010151828281518110611159576111596118ac565b6020908102919091010152600101611125565b604080516001600160a01b03848116602483015283811660448084019190915283518084039091018152606490920183526020820180516001600160e01b0316636eb1769f60e11b17905291515f928392839283928916916111cd91611929565b5f60405180830381855afa9150503d805f8114611205576040519150601f19603f3d011682016040523d82523d5f602084013e61120a565b606091505b509150915081158061121d575060208151105b15611229575050611245565b81935080806020019051810190611240919061193a565b925050505b935093915050565b5f808061125d60208501856118c0565b6001600160a01b031603611290576001915061127f60408401602085016118c0565b6001600160a01b0316319050915091565b6112b56112a060208501856118c0565b6112b060408601602087016118c0565b610ca6565b91509150915091565b80356001600160a01b03811681146112d4575f80fd5b919050565b5f8083601f8401126112e9575f80fd5b5081356001600160401b038111156112ff575f80fd5b602083019150836020828501011115610d77575f80fd5b5f805f805f6080868803121561132a575f80fd5b611333866112be565b9450611341602087016112be565b93506040860135925060608601356001600160401b03811115611362575f80fd5b61136e888289016112d9565b969995985093965092949392505050565b5f805f60408486031215611391575f80fd5b8335925060208401356001600160401b038111156113ad575f80fd5b6113b9868287016112d9565b9497909650939450505050565b5f8083601f8401126113d6575f80fd5b5081356001600160401b038111156113ec575f80fd5b6020830191508360208260051b8501011115610d77575f80fd5b5f8083601f840112611416575f80fd5b5081356001600160401b0381111561142c575f80fd5b6020830191508360208260061b8501011115610d77575f80fd5b5f805f805f805f806080898b03121561145d575f80fd5b88356001600160401b0380821115611473575f80fd5b61147f8c838d016113c6565b909a50985060208b0135915080821115611497575f80fd5b6114a38c838d016113c6565b909850965060408b01359150808211156114bb575f80fd5b6114c78c838d01611406565b909650945060608b01359150808211156114df575f80fd5b506114ec8b828c01611406565b999c989b5096995094979396929594505050565b5f5b8381101561151a578181015183820152602001611502565b50505f910152565b5f8151808452611539816020860160208601611500565b601f01601f19169290920160200192915050565b5f815180845260208085019450602084015f5b838110156115855781516001600160a01b031687529582019590820190600101611560565b509495945050505050565b5f815180845260208085019450602084015f5b83811015611585578151875295820195908201906001016115a3565b5f815180845260208085019450602084015f5b838110156115855781511515875295820195908201906001016115d2565b6020815261160360208201835115159052565b602082015160408201525f604083015161018080606085015261162a6101a0850183611522565b9150606085015160808501526080850151601f19808685030160a0870152611652848361154d565b935060a08701519150808685030160c087015261166f848361154d565b935060c08701519150808685030160e087015261168c8483611590565b935060e087015191506101008187860301818801526116ab8584611590565b9450808801519250506101208281880152808801519250506101408187860301818801526116d98584611590565b9450808801519250506101608187860301818801526116f88584611590565b90880151878203909201848801529350905061171483826115bf565b9695505050505050565b5f805f805f805f8060a0898b031215611735575f80fd5b61173e896112be565b975061174c60208a016112be565b965060408901356001600160401b0380821115611767575f80fd5b6117738c838d016113c6565b909850965060608b013591508082111561178b575f80fd5b6117978c838d016113c6565b909650945060808b01359150808211156117af575f80fd5b506114ec8b828c016112d9565b5f805f805f8060a087890312156117d1575f80fd5b6117da876112be565b95506117e8602088016112be565b9450604087013593506060870135925060808701356001600160401b03811115611810575f80fd5b61181c89828a016112d9565b979a9699509497509295939492505050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561094d5761094d61182e565b808202811582820484141761094d5761094d61182e565b634e487b7160e01b5f52604160045260245ffd5b8181038181111561094d5761094d61182e565b60ff818116838216019081111561094d5761094d61182e565b634e487b7160e01b5f52603260045260245ffd5b5f602082840312156118d0575f80fd5b61017a826112be565b5f600182016118ea576118ea61182e565b5060010190565b5f8235605e19833603018112611905575f80fd5b9190910192915050565b5f600160ff1b82016119235761192361182e565b505f0390565b5f8251611905818460208701611500565b5f6020828403121561194a575f80fd5b5051919050565b5f808335601e19843603018112611966575f80fd5b8301803591506001600160401b0382111561197f575f80fd5b602001915036819003821315610d77575f80fd5b818382375f910190815291905056fea26469706673582212204c77b0c567d34ad97024dab0976d2c9adabfbedde5c906937beb807267751de464736f6c63430008180033";
2
2
  //# sourceMappingURL=txSimulatorBytecode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"txSimulatorBytecode.d.ts","sourceRoot":"","sources":["../../src/generated/txSimulatorBytecode.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B,g7WACg6W,CAAC"}
1
+ {"version":3,"file":"txSimulatorBytecode.d.ts","sourceRoot":"","sources":["../../src/generated/txSimulatorBytecode.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B,s7ZACs6Z,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/generate-txsim-bytecode.mjs.
2
- export const txSimulatorRuntimeBytecode = "0x60806040526004361061004c575f3560e01c8063150b7a02146100575780631626ba7e146100a0578063bc197c81146100bf578063cb8935e9146100ed578063f23a6e6114610119575f80fd5b3661005357005b5f80fd5b348015610062575f80fd5b506100826100713660046110ac565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100ab575f80fd5b506100826100ba366004611115565b610145565b3480156100ca575f80fd5b506100826100d936600461119c565b63bc197c8160e01b98975050505050505050565b3480156100f8575f80fd5b5061010c61010736600461124e565b610181565b60405161009791906113cb565b348015610124575f80fd5b506100826101333660046114b9565b63f23a6e6160e01b9695505050505050565b5f30610152858585610300565b6001600160a01b03161461016e576001600160e01b0319610177565b630b135d3f60e11b5b90505b9392505050565b6101d56040518061014001604052805f151581526020015f8152602001606081526020015f8152602001606081526020016060815260200160608152602001606081526020015f8152602001606081525090565b475f6101e18787610456565b90506101ee88600161153f565b6101f89085611552565b6001600160401b0381111561020f5761020f611569565b604051908082528060200260200182016040528015610238578160200160208202803683370190505b50610120840190815260408051608081018252838201518152602080850151908201529151908201525f90606081016102728b600161153f565b905290505f6102878b8b8b8b8b8b888b6106d5565b60408901919091526020880191909152901515865290506102a847856107cd565b8560600181815250506102c383606001518460800151610844565b6080860152808410156102d6575f6102e0565b6102e0818561157d565b6101008601526102f2898985886108e0565b505050509695505050505050565b5f60418290036103bb578235602084013560408501355f1a601b81101561032f5761032c601b82611590565b90505b8060ff16601b1415801561034757508060ff16601c14155b15610357575f935050505061017a565b604080515f81526020810180835289905260ff831691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa1580156103a7573d5f803e3d5ffd5b50505060206040510351935050505061017a565b604082900361044d57823560208401356001600160ff1b0381165f6103e560ff84901c601b61153f565b604080515f8152602081018083528b905260ff831691810191909152606081018690526080810184905290915060019060a0016020604051602081039080840390855afa158015610438573d5f803e3d5ffd5b5050506020604051035194505050505061017a565b505f9392505050565b6104876040518060a00160405280606081526020016060815260200160608152602001606081526020015f81525090565b816001600160401b0381111561049f5761049f611569565b6040519080825280602002602001820160405280156104c8578160200160208202803683370190505b508152816001600160401b038111156104e3576104e3611569565b60405190808252806020026020018201604052801561050c578160200160208202803683370190505b506020820152816001600160401b0381111561052a5761052a611569565b604051908082528060200260200182016040528015610553578160200160208202803683370190505b506040820152816001600160401b0381111561057157610571611569565b60405190808252806020026020018201604052801561059a578160200160208202803683370190505b5060608201525f5b828110156106ce575f806105dc8686858181106105c1576105c16115a9565b90506020020160208101906105d691906115bd565b30610b97565b9150915081156106c4576001846040015184815181106105fe576105fe6115a9565b60200260200101901515908115158152505080845f01518481518110610626576106266115a9565b6020026020010181815250508084602001518481518110610649576106496115a9565b602002602001018181525050858584818110610667576106676115a9565b905060200201602081019061067c91906115bd565b606085015160808601805190610691826115d6565b9052815181106106a3576106a36115a9565b60200260200101906001600160a01b031690816001600160a01b0316815250505b50506001016105a2565b5092915050565b60015f1960608386156106f7576106f7888888606001515f8a60400151610c6f565b5f5b8b8110156107bd575f8061072f8f8f85818110610718576107186115a9565b905060200281019061072a91906115ee565b610d2a565b9150915081610768575f96509194509092508390838915610761576107618b8b90508a60600151858c60400151610dac565b50506107bd565b4784811015610775578094505b6107888e8e8c5f01518d60200151610e4b565b8a156107af576107af8c8c8c606001518760016107a5919061153f565b8e60400151610c6f565b5050508060010190506106f9565b5098509850985098945050505050565b5f818310610808575f6107e0838561157d565b90506001600160ff1b03811115610801576001600160ff1b0391505061083e565b905061083e565b5f610813848461157d565b90506001600160ff1b0381111561083157600160ff1b91505061083e565b61083a8161160c565b9150505b92915050565b6060816001600160401b0381111561085e5761085e611569565b604051908082528060200260200182016040528015610887578160200160208202803683370190505b5090505f5b828110156106ce578381815181106108a6576108a66115a9565b60200260200101518282815181106108c0576108c06115a9565b6001600160a01b039092166020928302919091019091015260010161088c565b826001600160401b038111156108f8576108f8611569565b604051908082528060200260200182016040528015610921578160200160208202803683370190505b5060e08201525f836001600160401b0381111561094057610940611569565b604051908082528060200260200182016040528015610969578160200160208202803683370190505b5090505f846001600160401b0381111561098557610985611569565b6040519080825280602002602001820160405280156109ae578160200160208202803683370190505b5090505f805b86811015610b6c57856040015181815181106109d2576109d26115a9565b602002602001015115610b6457856020015181815181106109f5576109f56115a9565b6020026020010151865f01518281518110610a1257610a126115a9565b602002602001015110610a875785602001518181518110610a3557610a356115a9565b6020026020010151865f01518281518110610a5257610a526115a9565b6020026020010151610a64919061157d565b8560e001518281518110610a7a57610a7a6115a9565b6020026020010181815250505b5f80610a9e8a8a858181106105c1576105c16115a9565b9150915081610aae575050610b64565b5f610ad5828a5f01518681518110610ac857610ac86115a9565b60200260200101516107cd565b90508015610b60578a8a85818110610aef57610aef6115a9565b9050602002016020810190610b0491906115bd565b878681518110610b1657610b166115a9565b60200260200101906001600160a01b031690816001600160a01b03168152505080868681518110610b4957610b496115a9565b6020908102919091010152610b5d856115d6565b94505b5050505b6001016109b4565b50610b778382610844565b60a0850152610b868282610ee4565b8460c0018190525050505050505050565b604080516001600160a01b0383811660248084019190915283518084039091018152604490920183526020820180516001600160e01b03166370a0823160e01b17905291515f92839283928392881691610bf091611626565b5f60405180830381855afa9150503d805f8114610c28576040519150601f19603f3d011682016040523d82523d5f602084013e610c2d565b606091505b5091509150811580610c40575060208151105b15610c4c575050610c68565b81935080806020019051810190610c639190611637565b925050505b9250929050565b5f5b84811015610d22575f80610cd6888885818110610c9057610c906115a9565b610ca692602060409092020190810191506115bd565b308a8a87818110610cb957610cb96115a9565b9050604002016020016020810190610cd191906115bd565b610f73565b9150915081610ce5575f610ce7565b805b8486610cf38987611552565b610cfd919061153f565b81518110610d0d57610d0d6115a9565b60209081029190910101525050600101610c71565b505050505050565b5f6060610d3a60208401846115bd565b6001600160a01b03166020840135610d55604086018661164e565b604051610d63929190611690565b5f6040518083038185875af1925050503d805f8114610d9d576040519150601f19603f3d011682016040523d82523d5f602084013e610da2565b606091505b5091509150915091565b5f5b84811015610e44575f8284610dc38785611552565b610dcd919061153f565b81518110610ddd57610ddd6115a9565b602002602001015190505f846001610df5919061153f565b90505b85811015610e3a57818482610e0d8987611552565b610e17919061153f565b81518110610e2757610e276115a9565b6020908102919091010152600101610df8565b5050600101610dae565b5050505050565b5f5b83811015610e4457828181518110610e6757610e676115a9565b602002602001015115610edc575f80610e8b8787858181106105c1576105c16115a9565b91509150818015610eb45750838381518110610ea957610ea96115a9565b602002602001015181105b15610ed95780848481518110610ecc57610ecc6115a9565b6020026020010181815250505b50505b600101610e4d565b6060816001600160401b03811115610efe57610efe611569565b604051908082528060200260200182016040528015610f27578160200160208202803683370190505b5090505f5b828110156106ce57838181518110610f4657610f466115a9565b6020026020010151828281518110610f6057610f606115a9565b6020908102919091010152600101610f2c565b604080516001600160a01b03848116602483015283811660448084019190915283518084039091018152606490920183526020820180516001600160e01b0316636eb1769f60e11b17905291515f92839283928392891691610fd491611626565b5f60405180830381855afa9150503d805f811461100c576040519150601f19603f3d011682016040523d82523d5f602084013e611011565b606091505b5091509150811580611024575060208151105b1561103057505061104c565b819350808060200190518101906110479190611637565b925050505b935093915050565b80356001600160a01b038116811461106a575f80fd5b919050565b5f8083601f84011261107f575f80fd5b5081356001600160401b03811115611095575f80fd5b602083019150836020828501011115610c68575f80fd5b5f805f805f608086880312156110c0575f80fd5b6110c986611054565b94506110d760208701611054565b93506040860135925060608601356001600160401b038111156110f8575f80fd5b6111048882890161106f565b969995985093965092949392505050565b5f805f60408486031215611127575f80fd5b8335925060208401356001600160401b03811115611143575f80fd5b61114f8682870161106f565b9497909650939450505050565b5f8083601f84011261116c575f80fd5b5081356001600160401b03811115611182575f80fd5b6020830191508360208260051b8501011115610c68575f80fd5b5f805f805f805f8060a0898b0312156111b3575f80fd5b6111bc89611054565b97506111ca60208a01611054565b965060408901356001600160401b03808211156111e5575f80fd5b6111f18c838d0161115c565b909850965060608b0135915080821115611209575f80fd5b6112158c838d0161115c565b909650945060808b013591508082111561122d575f80fd5b5061123a8b828c0161106f565b999c989b5096995094979396929594505050565b5f805f805f8060608789031215611263575f80fd5b86356001600160401b0380821115611279575f80fd5b6112858a838b0161115c565b9098509650602089013591508082111561129d575f80fd5b6112a98a838b0161115c565b909650945060408901359150808211156112c1575f80fd5b818901915089601f8301126112d4575f80fd5b8135818111156112e2575f80fd5b8a60208260061b85010111156112f6575f80fd5b6020830194508093505050509295509295509295565b5f5b8381101561132657818101518382015260200161130e565b50505f910152565b5f815180845261134581602086016020860161130c565b601f01601f19169290920160200192915050565b5f815180845260208085019450602084015f5b838110156113915781516001600160a01b03168752958201959082019060010161136c565b509495945050505050565b5f815180845260208085019450602084015f5b83811015611391578151875295820195908201906001016113af565b602081526113de60208201835115159052565b602082015160408201525f604083015161014080606085015261140561016085018361132e565b9150606085015160808501526080850151601f19808685030160a087015261142d8483611359565b935060a08701519150808685030160c087015261144a8483611359565b935060c08701519150808685030160e0870152611467848361139c565b935060e08701519150610100818786030181880152611486858461139c565b908801516101208881019190915288015187820390920184880152935090506114af838261139c565b9695505050505050565b5f805f805f8060a087890312156114ce575f80fd5b6114d787611054565b95506114e560208801611054565b9450604087013593506060870135925060808701356001600160401b0381111561150d575f80fd5b61151989828a0161106f565b979a9699509497509295939492505050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561083e5761083e61152b565b808202811582820484141761083e5761083e61152b565b634e487b7160e01b5f52604160045260245ffd5b8181038181111561083e5761083e61152b565b60ff818116838216019081111561083e5761083e61152b565b634e487b7160e01b5f52603260045260245ffd5b5f602082840312156115cd575f80fd5b61017a82611054565b5f600182016115e7576115e761152b565b5060010190565b5f8235605e19833603018112611602575f80fd5b9190910192915050565b5f600160ff1b82016116205761162061152b565b505f0390565b5f825161160281846020870161130c565b5f60208284031215611647575f80fd5b5051919050565b5f808335601e19843603018112611663575f80fd5b8301803591506001600160401b0382111561167c575f80fd5b602001915036819003821315610c68575f80fd5b818382375f910190815291905056fea2646970667358221220c9adb57984fec989769acf8df499b49fd3aadd781fd0b128ec026480393cb0a764736f6c63430008180033";
2
+ export const txSimulatorRuntimeBytecode = "0x60806040526004361061004c575f3560e01c8063150b7a02146100575780631626ba7e146100a05780639b093492146100bf578063bc197c81146100eb578063f23a6e6114610119575f80fd5b3661005357005b5f80fd5b348015610062575f80fd5b50610082610071366004611316565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b3480156100ab575f80fd5b506100826100ba36600461137f565b610145565b3480156100ca575f80fd5b506100de6100d9366004611446565b610181565b60405161009791906115f0565b3480156100f6575f80fd5b5061008261010536600461171e565b63bc197c8160e01b98975050505050505050565b348015610124575f80fd5b506100826101333660046117bc565b63f23a6e6160e01b9695505050505050565b5f306101528585856103b6565b6001600160a01b03161461016e576001600160e01b0319610177565b630b135d3f60e11b5b90505b9392505050565b6101e36040518061018001604052805f151581526020015f8152602001606081526020015f8152602001606081526020016060815260200160608152602001606081526020015f81526020016060815260200160608152602001606081525090565b475f6101ef898961050c565b90505f6101fd8b6001611842565b90506102098186611855565b6001600160401b038111156102205761022061186c565b604051908082528060200260200182016040528015610249578160200160208202803683370190505b50610140850152846001600160401b038111156102685761026861186c565b604051908082528060200260200182016040528015610291578160200160208202803683370190505b506101608501526102a28188611855565b6001600160401b038111156102b9576102b961186c565b6040519080825280602002602001820160405280156102e2578160200160208202803683370190505b5061012085019081526040805160c081018252848201518152602080860151908201529151908201526101408501516060820152610160850151608082015260a081018290525f61033a8e8e8e8e8e8e8e8e8a61078b565b60408a019190915260208901919091529015158752905061035b47866108dc565b86606001818152505061037684606001518560800151610953565b608087015280851015610389575f610393565b6103938186611880565b6101008701526103a58c8c86896109ef565b505050505098975050505050505050565b5f6041829003610471578235602084013560408501355f1a601b8110156103e5576103e2601b82611893565b90505b8060ff16601b141580156103fd57508060ff16601c14155b1561040d575f935050505061017a565b604080515f81526020810180835289905260ff831691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa15801561045d573d5f803e3d5ffd5b50505060206040510351935050505061017a565b604082900361050357823560208401356001600160ff1b0381165f61049b60ff84901c601b611842565b604080515f8152602081018083528b905260ff831691810191909152606081018690526080810184905290915060019060a0016020604051602081039080840390855afa1580156104ee573d5f803e3d5ffd5b5050506020604051035194505050505061017a565b505f9392505050565b61053d6040518060a00160405280606081526020016060815260200160608152602001606081526020015f81525090565b816001600160401b038111156105555761055561186c565b60405190808252806020026020018201604052801561057e578160200160208202803683370190505b508152816001600160401b038111156105995761059961186c565b6040519080825280602002602001820160405280156105c2578160200160208202803683370190505b506020820152816001600160401b038111156105e0576105e061186c565b604051908082528060200260200182016040528015610609578160200160208202803683370190505b506040820152816001600160401b038111156106275761062761186c565b604051908082528060200260200182016040528015610650578160200160208202803683370190505b5060608201525f5b82811015610784575f80610692868685818110610677576106776118ac565b905060200201602081019061068c91906118c0565b30610ca6565b91509150811561077a576001846040015184815181106106b4576106b46118ac565b60200260200101901515908115158152505080845f015184815181106106dc576106dc6118ac565b60200260200101818152505080846020015184815181106106ff576106ff6118ac565b60200260200101818152505085858481811061071d5761071d6118ac565b905060200201602081019061073291906118c0565b606085015160808601805190610747826118d9565b905281518110610759576107596118ac565b60200260200101906001600160a01b031690816001600160a01b0316815250505b5050600101610658565b5092915050565b60015f1960604787156107ad576107ad89898760a001515f8960400151610d7e565b85156107cd576107cd87878760a001515f89606001518a60800151610e39565b5f5b8c8110156108cb576108038e8e838181106107ec576107ec6118ac565b90506020028101906107fe91906118f1565b610f0c565b90955092508461084f57925082881561082d5761082d8a8a90508760a00151838960400151610fa5565b861561084a5761084a888890508760a00151838960600151610fa5565b6108cb565b478281101561085c578092505b61086f8d8d895f01518a60200151611044565b8915610896576108968b8b8960a0015185600161088c9190611842565b8b60400151610d7e565b87156108c2576108c289898960a001518560016108b39190611842565b8b606001518c60800151610e39565b506001016107cf565b509950995099509995505050505050565b5f818310610917575f6108ef8385611880565b90506001600160ff1b03811115610910576001600160ff1b0391505061094d565b905061094d565b5f6109228484611880565b90506001600160ff1b0381111561094057600160ff1b91505061094d565b6109498161190f565b9150505b92915050565b6060816001600160401b0381111561096d5761096d61186c565b604051908082528060200260200182016040528015610996578160200160208202803683370190505b5090505f5b82811015610784578381815181106109b5576109b56118ac565b60200260200101518282815181106109cf576109cf6118ac565b6001600160a01b039092166020928302919091019091015260010161099b565b826001600160401b03811115610a0757610a0761186c565b604051908082528060200260200182016040528015610a30578160200160208202803683370190505b5060e08201525f836001600160401b03811115610a4f57610a4f61186c565b604051908082528060200260200182016040528015610a78578160200160208202803683370190505b5090505f846001600160401b03811115610a9457610a9461186c565b604051908082528060200260200182016040528015610abd578160200160208202803683370190505b5090505f805b86811015610c7b5785604001518181518110610ae157610ae16118ac565b602002602001015115610c735785602001518181518110610b0457610b046118ac565b6020026020010151865f01518281518110610b2157610b216118ac565b602002602001015110610b965785602001518181518110610b4457610b446118ac565b6020026020010151865f01518281518110610b6157610b616118ac565b6020026020010151610b739190611880565b8560e001518281518110610b8957610b896118ac565b6020026020010181815250505b5f80610bad8a8a85818110610677576106776118ac565b9150915081610bbd575050610c73565b5f610be4828a5f01518681518110610bd757610bd76118ac565b60200260200101516108dc565b90508015610c6f578a8a85818110610bfe57610bfe6118ac565b9050602002016020810190610c1391906118c0565b878681518110610c2557610c256118ac565b60200260200101906001600160a01b031690816001600160a01b03168152505080868681518110610c5857610c586118ac565b6020908102919091010152610c6c856118d9565b94505b5050505b600101610ac3565b50610c868382610953565b60a0850152610c9582826110dd565b8460c0018190525050505050505050565b604080516001600160a01b0383811660248084019190915283518084039091018152604490920183526020820180516001600160e01b03166370a0823160e01b17905291515f92839283928392881691610cff91611929565b5f60405180830381855afa9150503d805f8114610d37576040519150601f19603f3d011682016040523d82523d5f602084013e610d3c565b606091505b5091509150811580610d4f575060208151105b15610d5b575050610d77565b81935080806020019051810190610d72919061193a565b925050505b9250929050565b5f5b84811015610e31575f80610de5888885818110610d9f57610d9f6118ac565b610db592602060409092020190810191506118c0565b308a8a87818110610dc857610dc86118ac565b9050604002016020016020810190610de091906118c0565b61116c565b9150915081610df4575f610df6565b805b8486610e028987611855565b610e0c9190611842565b81518110610e1c57610e1c6118ac565b60209081029190910101525050600101610d80565b505050505050565b5f5b85811015610f03575f80610e65898985818110610e5a57610e5a6118ac565b90506040020161124d565b9150915081610e74575f610e76565b805b8587610e828a87611855565b610e8c9190611842565b81518110610e9c57610e9c6118ac565b60209081029190910101528515610ed557838381518110610ebf57610ebf6118ac565b60200260200101518015610ed05750815b610ed7565b815b848481518110610ee957610ee96118ac565b911515602092830291909101909101525050600101610e3b565b50505050505050565b5f6060610f1c60208401846118c0565b6001600160a01b03166020840135610f376040860186611951565b604051610f45929190611993565b5f6040518083038185875af1925050503d805f8114610f7f576040519150601f19603f3d011682016040523d82523d5f602084013e610f84565b606091505b5090925090508115610fa0575060408051602081019091525f81525b915091565b5f5b8481101561103d575f8284610fbc8785611855565b610fc69190611842565b81518110610fd657610fd66118ac565b602002602001015190505f846001610fee9190611842565b90505b85811015611033578184826110068987611855565b6110109190611842565b81518110611020576110206118ac565b6020908102919091010152600101610ff1565b5050600101610fa7565b5050505050565b5f5b8381101561103d57828181518110611060576110606118ac565b6020026020010151156110d5575f80611084878785818110610677576106776118ac565b915091508180156110ad57508383815181106110a2576110a26118ac565b602002602001015181105b156110d257808484815181106110c5576110c56118ac565b6020026020010181815250505b50505b600101611046565b6060816001600160401b038111156110f7576110f761186c565b604051908082528060200260200182016040528015611120578160200160208202803683370190505b5090505f5b828110156107845783818151811061113f5761113f6118ac565b6020026020010151828281518110611159576111596118ac565b6020908102919091010152600101611125565b604080516001600160a01b03848116602483015283811660448084019190915283518084039091018152606490920183526020820180516001600160e01b0316636eb1769f60e11b17905291515f928392839283928916916111cd91611929565b5f60405180830381855afa9150503d805f8114611205576040519150601f19603f3d011682016040523d82523d5f602084013e61120a565b606091505b509150915081158061121d575060208151105b15611229575050611245565b81935080806020019051810190611240919061193a565b925050505b935093915050565b5f808061125d60208501856118c0565b6001600160a01b031603611290576001915061127f60408401602085016118c0565b6001600160a01b0316319050915091565b6112b56112a060208501856118c0565b6112b060408601602087016118c0565b610ca6565b91509150915091565b80356001600160a01b03811681146112d4575f80fd5b919050565b5f8083601f8401126112e9575f80fd5b5081356001600160401b038111156112ff575f80fd5b602083019150836020828501011115610d77575f80fd5b5f805f805f6080868803121561132a575f80fd5b611333866112be565b9450611341602087016112be565b93506040860135925060608601356001600160401b03811115611362575f80fd5b61136e888289016112d9565b969995985093965092949392505050565b5f805f60408486031215611391575f80fd5b8335925060208401356001600160401b038111156113ad575f80fd5b6113b9868287016112d9565b9497909650939450505050565b5f8083601f8401126113d6575f80fd5b5081356001600160401b038111156113ec575f80fd5b6020830191508360208260051b8501011115610d77575f80fd5b5f8083601f840112611416575f80fd5b5081356001600160401b0381111561142c575f80fd5b6020830191508360208260061b8501011115610d77575f80fd5b5f805f805f805f806080898b03121561145d575f80fd5b88356001600160401b0380821115611473575f80fd5b61147f8c838d016113c6565b909a50985060208b0135915080821115611497575f80fd5b6114a38c838d016113c6565b909850965060408b01359150808211156114bb575f80fd5b6114c78c838d01611406565b909650945060608b01359150808211156114df575f80fd5b506114ec8b828c01611406565b999c989b5096995094979396929594505050565b5f5b8381101561151a578181015183820152602001611502565b50505f910152565b5f8151808452611539816020860160208601611500565b601f01601f19169290920160200192915050565b5f815180845260208085019450602084015f5b838110156115855781516001600160a01b031687529582019590820190600101611560565b509495945050505050565b5f815180845260208085019450602084015f5b83811015611585578151875295820195908201906001016115a3565b5f815180845260208085019450602084015f5b838110156115855781511515875295820195908201906001016115d2565b6020815261160360208201835115159052565b602082015160408201525f604083015161018080606085015261162a6101a0850183611522565b9150606085015160808501526080850151601f19808685030160a0870152611652848361154d565b935060a08701519150808685030160c087015261166f848361154d565b935060c08701519150808685030160e087015261168c8483611590565b935060e087015191506101008187860301818801526116ab8584611590565b9450808801519250506101208281880152808801519250506101408187860301818801526116d98584611590565b9450808801519250506101608187860301818801526116f88584611590565b90880151878203909201848801529350905061171483826115bf565b9695505050505050565b5f805f805f805f8060a0898b031215611735575f80fd5b61173e896112be565b975061174c60208a016112be565b965060408901356001600160401b0380821115611767575f80fd5b6117738c838d016113c6565b909850965060608b013591508082111561178b575f80fd5b6117978c838d016113c6565b909650945060808b01359150808211156117af575f80fd5b506114ec8b828c016112d9565b5f805f805f8060a087890312156117d1575f80fd5b6117da876112be565b95506117e8602088016112be565b9450604087013593506060870135925060808701356001600160401b03811115611810575f80fd5b61181c89828a016112d9565b979a9699509497509295939492505050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561094d5761094d61182e565b808202811582820484141761094d5761094d61182e565b634e487b7160e01b5f52604160045260245ffd5b8181038181111561094d5761094d61182e565b60ff818116838216019081111561094d5761094d61182e565b634e487b7160e01b5f52603260045260245ffd5b5f602082840312156118d0575f80fd5b61017a826112be565b5f600182016118ea576118ea61182e565b5060010190565b5f8235605e19833603018112611905575f80fd5b9190910192915050565b5f600160ff1b82016119235761192361182e565b505f0390565b5f8251611905818460208701611500565b5f6020828403121561194a575f80fd5b5051919050565b5f808335601e19843603018112611966575f80fd5b8301803591506001600160401b0382111561197f575f80fd5b602001915036819003821315610d77575f80fd5b818382375f910190815291905056fea26469706673582212204c77b0c567d34ad97024dab0976d2c9adabfbedde5c906937beb807267751de464736f6c63430008180033";
3
3
  //# sourceMappingURL=txSimulatorBytecode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"txSimulatorBytecode.js","sourceRoot":"","sources":["../../src/generated/txSimulatorBytecode.ts"],"names":[],"mappings":"AAEA,oDAAoD;AACpD,MAAM,CAAC,MAAM,0BAA0B,GACrC,86WAAq8W,CAAC"}
1
+ {"version":3,"file":"txSimulatorBytecode.js","sourceRoot":"","sources":["../../src/generated/txSimulatorBytecode.ts"],"names":[],"mappings":"AAEA,oDAAoD;AACpD,MAAM,CAAC,MAAM,0BAA0B,GACrC,o7ZAA28Z,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { DEFAULT_SIMULATION_GAS_LIMIT, OVERRIDE_TOKEN_AMOUNT } from "./constants.js";
2
2
  export { TxSimulator } from "./txSimulator.js";
3
3
  export { AccessListUnsupportedError, InvalidSimulationInputError, StateOverrideUnsupportedError, TxSimError, } from "./errors.js";
4
- export type { AllowanceSlot, PreparedAllowanceOverrides, AllowanceSlotPair, AssetBalanceDelta, PreparedBalanceOverrides, PrepareAllowanceOverridesArgs, PrepareBalanceOverridesArgs, EstimatedAssetRequirements, EstimatedAssetRequirementsReverted, EstimatedAssetRequirementsSuccess, EstimateAssetRequirementsArgs, SimulateArgs, SimulatedCall, SimulationDebug, SimulationDebugEvent, SimulationDebugLogger, RequiredAllowance, RequiredBalance, RevertError, SimulationReverted, SimulationResult, SimulationSuccess, TokenSlotOverride, TxSimulatorConfig, } from "./types.js";
4
+ export type { AllowanceSlot, BalanceDelta, BalanceQuery, PreparedAllowanceOverrides, AllowanceSlotPair, PreparedBalanceOverrides, ForUserBalanceQueriesArgs, PrepareAllowanceOverridesArgs, PrepareBalanceOverridesArgs, EstimatedAssetRequirements, EstimatedAssetRequirementsReverted, EstimatedAssetRequirementsSuccess, EstimateAssetRequirementsArgs, SimulateArgs, SimulatedCall, SimulationDebug, SimulationDebugEvent, SimulationDebugLogger, RequiredAllowance, RequiredBalance, RevertError, SimulationReverted, SimulationResult, SimulationSuccess, TokenSlotOverride, TxSimulatorConfig, } from "./types.js";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC7B,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,aAAa,EACb,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,iCAAiC,EACjC,6BAA6B,EAC7B,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC7B,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,iCAAiC,EACjC,6BAA6B,EAC7B,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Address } from "viem";
2
+ import type { BalanceQuery, ForUserBalanceQueriesArgs } from "../types.js";
3
+ import type { ClientArgs } from "./rpc.js";
4
+ /** @internal Implements {@link TxSimulator.balanceQueries.forUser}. Prefer the instance API from the package root. */
5
+ export declare function forUserBalanceQueries(args: ForUserBalanceQueriesArgs & ClientArgs): Promise<BalanceQuery[]>;
6
+ /** @internal Implements {@link TxSimulator.balanceQueries.discoverErc20s}. Prefer the instance API from the package root. */
7
+ export declare function discoverErc20s(args: ForUserBalanceQueriesArgs & ClientArgs): Promise<Address[]>;
8
+ //# sourceMappingURL=queryDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryDiscovery.d.ts","sourceRoot":"","sources":["../../src/internal/queryDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAiB,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,sHAAsH;AACtH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,yBAAyB,GAAG,UAAU,GAC3C,OAAO,CAAC,YAAY,EAAE,CAAC,CAOzB;AAED,6HAA6H;AAC7H,wBAAsB,cAAc,CAClC,IAAI,EAAE,yBAAyB,GAAG,UAAU,GAC3C,OAAO,CAAC,OAAO,EAAE,CAAC,CA0BpB"}
@@ -0,0 +1,38 @@
1
+ import { blockOptionsSpread } from "./rpc.js";
2
+ import { discoverCandidateAddresses, runSimulator } from "./simulator.js";
3
+ /** @internal Implements {@link TxSimulator.balanceQueries.forUser}. Prefer the instance API from the package root. */
4
+ export async function forUserBalanceQueries(args) {
5
+ const tokens = await discoverErc20s(args);
6
+ return [
7
+ { asset: "native", account: args.from },
8
+ ...tokens.map((asset) => ({ asset, account: args.from })),
9
+ ];
10
+ }
11
+ /** @internal Implements {@link TxSimulator.balanceQueries.discoverErc20s}. Prefer the instance API from the package root. */
12
+ export async function discoverErc20s(args) {
13
+ const calls = args.calls.map((call) => ({
14
+ to: call.to,
15
+ data: call.data,
16
+ value: call.value ?? 0n,
17
+ }));
18
+ const candidates = await discoverCandidateAddresses({
19
+ client: args.client,
20
+ from: args.from,
21
+ calls,
22
+ gas: args.gas,
23
+ debug: args.debug,
24
+ ...blockOptionsSpread(args),
25
+ });
26
+ const result = await runSimulator({
27
+ client: args.client,
28
+ from: args.from,
29
+ calls: [],
30
+ candidates,
31
+ debug: args.debug,
32
+ debugStep: "balanceQueries.tokenFilter",
33
+ gas: args.gas,
34
+ ...blockOptionsSpread(args),
35
+ });
36
+ return result.probeData.observedTokens;
37
+ }
38
+ //# sourceMappingURL=queryDiscovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryDiscovery.js","sourceRoot":"","sources":["../../src/internal/queryDiscovery.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE1E,sHAAsH;AACtH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA4C;IAE5C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,OAAO;QACL,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE;QACvC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED,6HAA6H;AAC7H,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAA4C;IAE5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;KACxB,CAAC,CAA2B,CAAC;IAC9B,MAAM,UAAU,GAAG,MAAM,0BAA0B,CAAC;QAClD,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK;QACL,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,kBAAkB,CAAC,IAAI,CAAC;KAC5B,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC;QAChC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,EAAE;QACT,UAAU;QACV,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,4BAA4B;QACvC,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,kBAAkB,CAAC,IAAI,CAAC;KAC5B,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACzC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { EstimatedAssetRequirements, EstimateAssetRequirementsArgs } from "../types.js";
2
2
  import type { ClientArgs } from "./rpc.js";
3
- /** @internal Implements {@link TxSimulator.estimateAssetRequirements}. Prefer the instance API from the package root. */
3
+ /** @internal Implements {@link TxSimulator.tokenOverrides.estimateRequirements}. Prefer the instance API from the package root. */
4
4
  export declare function estimateAssetRequirements(args: EstimateAssetRequirementsArgs & ClientArgs): Promise<EstimatedAssetRequirements>;
5
+ export declare const estimateTokenOverrideRequirements: typeof estimateAssetRequirements;
5
6
  //# sourceMappingURL=requirements.d.ts.map