@qntx/wallet-chains 0.12.0 → 0.14.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 (62) hide show
  1. package/README.md +13 -10
  2. package/dist/{account-ref-D2rW_qlI.mjs → account-ref-BFTeEyHt.mjs} +2 -2
  3. package/dist/{account-ref-D2rW_qlI.mjs.map → account-ref-BFTeEyHt.mjs.map} +1 -1
  4. package/dist/assemble-8GvNDony.mjs +405 -0
  5. package/dist/assemble-8GvNDony.mjs.map +1 -0
  6. package/dist/assemble-B3sO9Fvc.mjs +629 -0
  7. package/dist/assemble-B3sO9Fvc.mjs.map +1 -0
  8. package/dist/assemble-BdiPo0ZX.mjs +32 -0
  9. package/dist/assemble-BdiPo0ZX.mjs.map +1 -0
  10. package/dist/assets-sg2_Z3nZ.mjs +200 -0
  11. package/dist/assets-sg2_Z3nZ.mjs.map +1 -0
  12. package/dist/bitcoin-sign.d.mts +3 -0
  13. package/dist/bitcoin-sign.mjs +52 -18
  14. package/dist/bitcoin-sign.mjs.map +1 -1
  15. package/dist/bitcoin.d.mts +123 -7
  16. package/dist/bitcoin.mjs +162 -69
  17. package/dist/bitcoin.mjs.map +1 -1
  18. package/dist/evm-sign.d.mts +3 -1
  19. package/dist/evm-sign.mjs +25 -82
  20. package/dist/evm-sign.mjs.map +1 -1
  21. package/dist/evm.d.mts +252 -22
  22. package/dist/evm.mjs +2460 -448
  23. package/dist/evm.mjs.map +1 -1
  24. package/dist/families-BlgplKAJ.mjs +412 -0
  25. package/dist/families-BlgplKAJ.mjs.map +1 -0
  26. package/dist/index-CIRaHKpx.d.mts +941 -0
  27. package/dist/index.d.mts +2 -2
  28. package/dist/index.mjs +1 -1
  29. package/dist/networks.d.mts +29 -0
  30. package/dist/networks.mjs +245 -0
  31. package/dist/networks.mjs.map +1 -0
  32. package/dist/plan-wCnxHqRu.mjs +1311 -0
  33. package/dist/plan-wCnxHqRu.mjs.map +1 -0
  34. package/dist/solana-sign.d.mts +3 -0
  35. package/dist/solana-sign.mjs +23 -10
  36. package/dist/solana-sign.mjs.map +1 -1
  37. package/dist/solana.d.mts +136 -24
  38. package/dist/solana.mjs +1244 -63
  39. package/dist/solana.mjs.map +1 -1
  40. package/dist/src-CHB_z45M.mjs +387 -0
  41. package/dist/src-CHB_z45M.mjs.map +1 -0
  42. package/dist/tasks-7AFv3PQn.mjs +86 -0
  43. package/dist/tasks-7AFv3PQn.mjs.map +1 -0
  44. package/dist/token-call-DH22g8BL.mjs +914 -0
  45. package/dist/token-call-DH22g8BL.mjs.map +1 -0
  46. package/dist/tron-sign.d.mts +10 -0
  47. package/dist/tron-sign.mjs +36 -0
  48. package/dist/tron-sign.mjs.map +1 -0
  49. package/dist/tron.d.mts +328 -0
  50. package/dist/tron.mjs +1484 -0
  51. package/dist/tron.mjs.map +1 -0
  52. package/dist/typed-data-CE9h4U0F.d.mts +51 -0
  53. package/dist/typed-data-DRtKULsH.mjs +466 -0
  54. package/dist/typed-data-DRtKULsH.mjs.map +1 -0
  55. package/package.json +17 -10
  56. package/dist/index-DYwm4-Ec.d.mts +0 -256
  57. package/dist/message-ChhEZ0lx.mjs +0 -188
  58. package/dist/message-ChhEZ0lx.mjs.map +0 -1
  59. package/dist/src-8NZeEnrW.mjs +0 -67
  60. package/dist/src-8NZeEnrW.mjs.map +0 -1
  61. package/dist/typed-data-J5g2WemC.mjs +0 -227
  62. package/dist/typed-data-J5g2WemC.mjs.map +0 -1
@@ -0,0 +1,914 @@
1
+ import { t as ChainError } from "./src-CHB_z45M.mjs";
2
+ import { r as lookupEvmToken, t as EVM_NATIVE_ASSET } from "./assets-sg2_Z3nZ.mjs";
3
+ import { D as checksumEvmAddress, c as sameFields, d as typedDataFields, g as assertHex$1, h as typedDataUint, i as domainChainId, l as typedDataAddress, o as isTypedDataMessage, t as MAX_UINT48, u as typedDataBytes } from "./typed-data-DRtKULsH.mjs";
4
+ import { keccak_256 } from "@noble/hashes/sha3.js";
5
+ import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
6
+ import * as AbiFunction from "ox/AbiFunction";
7
+ // src/evm/approval.ts
8
+ const MAX_UINT256 = 2n ** 256n - 1n;
9
+ const MAX_UINT160 = 2n ** 160n - 1n;
10
+ /** The canonical Permit2 deployment (the same address on every supported chain). */
11
+ const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
12
+ /** A fungible-token allowance; `max` is the type's maximum, which marks it unlimited. */
13
+ const allowanceChange = (token, spender, value, change, max, chainId, table, extra = {}) => {
14
+ const known = lookupEvmToken(table, chainId, token);
15
+ return {
16
+ kind: "allowance",
17
+ spender,
18
+ amount: {
19
+ asset: token,
20
+ amount: value.toString(10),
21
+ ...known === void 0 ? {} : {
22
+ symbol: known.symbol,
23
+ decimals: known.decimals
24
+ }
25
+ },
26
+ change,
27
+ unlimited: change !== "decrease" && value === max,
28
+ ...extra,
29
+ verified: known !== void 0
30
+ };
31
+ };
32
+ // src/evm/order.ts
33
+ /** Shared pieces of the off-chain order decoders (1inch LOP, UniswapX, CoW GPv2). */
34
+ /**
35
+ * The most items any side of an order may carry before the document is too large to show in full:
36
+ * Seaport offer/consideration, UniswapX outputs. Over the limit the decoder blinds the document
37
+ * with `typed-data-oversize` rather than let the prompt truncate what it signs.
38
+ */
39
+ const ORDER_ITEMS = 8;
40
+ /**
41
+ * An order leg amount: the chain's native asset when `token` matches `nativeMarker` — each protocol
42
+ * names its own marker and the leg it applies to (UniswapX: the zero address, outputs only —
43
+ * `CurrencyLibrary.NATIVE = address(0)`; CoW: `BUY_ETH_ADDRESS`, the buy token only); with no
44
+ * marker every address is an ERC-20 (1inch signs no native asset). The native symbol/decimals are
45
+ * attached by `withNativeAmountMeta` like every native amount; an ERC-20 gets symbol/decimals when
46
+ * the token is in the built-in table.
47
+ */
48
+ const orderAmount = (token, amount, chainId, table, nativeMarker) => {
49
+ if (nativeMarker !== void 0 && token.toLowerCase() === nativeMarker) return {
50
+ asset: EVM_NATIVE_ASSET,
51
+ amount: amount.toString(10)
52
+ };
53
+ const found = lookupEvmToken(table, chainId, token);
54
+ return {
55
+ asset: token,
56
+ amount: amount.toString(10),
57
+ ...found === void 0 ? {} : {
58
+ symbol: found.symbol,
59
+ decimals: found.decimals
60
+ }
61
+ };
62
+ };
63
+ // src/evm/uniswapx.ts
64
+ const ORDER_INFO = [
65
+ "address reactor",
66
+ "address swapper",
67
+ "uint256 nonce",
68
+ "uint256 deadline",
69
+ "address additionalValidationContract",
70
+ "bytes additionalValidationData"
71
+ ];
72
+ const DUTCH_OUTPUT = [
73
+ "address token",
74
+ "uint256 startAmount",
75
+ "uint256 endAmount",
76
+ "address recipient"
77
+ ];
78
+ const ORDER_TYPES = {
79
+ ExclusiveDutchOrder: {
80
+ ExclusiveDutchOrder: [
81
+ "OrderInfo info",
82
+ "uint256 decayStartTime",
83
+ "uint256 decayEndTime",
84
+ "address exclusiveFiller",
85
+ "uint256 exclusivityOverrideBps",
86
+ "address inputToken",
87
+ "uint256 inputStartAmount",
88
+ "uint256 inputEndAmount",
89
+ "DutchOutput[] outputs"
90
+ ],
91
+ OrderInfo: ORDER_INFO,
92
+ DutchOutput: DUTCH_OUTPUT
93
+ },
94
+ V2DutchOrder: {
95
+ V2DutchOrder: [
96
+ "OrderInfo info",
97
+ "address cosigner",
98
+ "address baseInputToken",
99
+ "uint256 baseInputStartAmount",
100
+ "uint256 baseInputEndAmount",
101
+ "DutchOutput[] baseOutputs"
102
+ ],
103
+ OrderInfo: ORDER_INFO,
104
+ DutchOutput: DUTCH_OUTPUT
105
+ },
106
+ V3DutchOrder: {
107
+ V3DutchOrder: [
108
+ "OrderInfo info",
109
+ "address cosigner",
110
+ "uint256 startingBaseFee",
111
+ "V3DutchInput baseInput",
112
+ "V3DutchOutput[] baseOutputs"
113
+ ],
114
+ OrderInfo: ORDER_INFO,
115
+ V3DutchInput: [
116
+ "address token",
117
+ "uint256 startAmount",
118
+ "NonlinearDutchDecay curve",
119
+ "uint256 maxAmount",
120
+ "uint256 adjustmentPerGweiBaseFee"
121
+ ],
122
+ V3DutchOutput: [
123
+ "address token",
124
+ "uint256 startAmount",
125
+ "NonlinearDutchDecay curve",
126
+ "address recipient",
127
+ "uint256 minAmount",
128
+ "uint256 adjustmentPerGweiBaseFee"
129
+ ],
130
+ NonlinearDutchDecay: ["uint256 relativeBlocks", "int256[] relativeAmounts"]
131
+ },
132
+ PriorityOrder: {
133
+ PriorityOrder: [
134
+ "OrderInfo info",
135
+ "address cosigner",
136
+ "uint256 auctionStartBlock",
137
+ "uint256 baselinePriorityFeeWei",
138
+ "PriorityInput input",
139
+ "PriorityOutput[] outputs"
140
+ ],
141
+ OrderInfo: ORDER_INFO,
142
+ PriorityInput: [
143
+ "address token",
144
+ "uint256 amount",
145
+ "uint256 mpsPerPriorityFeeWei"
146
+ ],
147
+ PriorityOutput: [
148
+ "address token",
149
+ "uint256 amount",
150
+ "uint256 mpsPerPriorityFeeWei",
151
+ "address recipient"
152
+ ]
153
+ }
154
+ };
155
+ const PERMIT2_TYPES = {
156
+ EIP712Domain: [
157
+ "string name",
158
+ "uint256 chainId",
159
+ "address verifyingContract"
160
+ ],
161
+ TokenPermissions: ["address token", "uint256 amount"]
162
+ };
163
+ /**
164
+ * The reactors verified for each chain and order type (UniswapX README "Deployment Addresses" at
165
+ * eb7ce077036258b9510b42ad37aa920cf3aaf308; probed on-chain — code present, `permit2()` = the
166
+ * Permit2 address — in vectors/chains/order-protocols.json). Chains whose deployment could not be
167
+ * verified are left out, so their orders fall back.
168
+ */
169
+ const REACTORS = {
170
+ 1: {
171
+ ExclusiveDutchOrder: "0x6000da47483062a0d734ba3dc7576ce6a0b645c4",
172
+ V2DutchOrder: "0x00000011f84b9aa48e5f8aa8b9897600006289be",
173
+ V3DutchOrder: "0x0000000015757c461808ea25eb309638b62681cf"
174
+ },
175
+ 10: { V3DutchOrder: "0x000000000923439a92dae8930613568824108631" },
176
+ 56: { V3DutchOrder: "0x00000000a55e50c71b70db3c8b58749cd1e18eb2" },
177
+ 130: { V3DutchOrder: "0x000000005af66799d1a6317714d66800f9ca1406" },
178
+ 137: { V3DutchOrder: "0x00000000bab6e234db8ad638b6a6395b7c499bc4" },
179
+ 143: { V3DutchOrder: "0x000000000ac008f7e07210cfb6648e40249232c2" },
180
+ 196: { V3DutchOrder: "0x000000005af66799d1a6317714d66800f9ca1406" },
181
+ 480: { V3DutchOrder: "0x00000000d714ea34028930b762e96bfbe50f42c2" },
182
+ 1868: { V3DutchOrder: "0x000000005af66799d1a6317714d66800f9ca1406" },
183
+ 57073: { V3DutchOrder: "0x000000007a1c8e570011eedf86a2a35593013cba" },
184
+ 8453: {
185
+ V3DutchOrder: "0x000000008a8330b5d1f43a62bf4c673a49f27ba0",
186
+ PriorityOrder: "0x000000001ec5656dcdb24d90dfa42742738de729"
187
+ },
188
+ 42161: { V3DutchOrder: "0xb274d5f4b833b61b340b654d600a864fb604a87c" },
189
+ 42220: { V3DutchOrder: "0x00000000b8077fdf2281a80be96f6c282b5d943a" },
190
+ 43114: { V3DutchOrder: "0x00000000862ccf095823fc7576fa6c7e6b7385ef" },
191
+ 7777777: { V3DutchOrder: "0x000000002c9a3812e15cf233190992e9a57edb56" }
192
+ };
193
+ const ZERO = "0x0000000000000000000000000000000000000000";
194
+ const isWitnessType = (type) => Object.hasOwn(ORDER_TYPES, type);
195
+ const address$1 = (message, key) => typedDataAddress(message[key]);
196
+ const uint$1 = (message, key) => typedDataUint(message[key], MAX_UINT256);
197
+ /** The witness decoded per its order type, or `undefined` when any needed value is malformed. */
198
+ const parse = (type, witness) => {
199
+ const { info } = witness;
200
+ if (!isTypedDataMessage(info)) return;
201
+ const output = (item, amount) => {
202
+ if (!isTypedDataMessage(item)) return;
203
+ const token = address$1(item, "token");
204
+ const value = amount(item);
205
+ const recipient = address$1(item, "recipient");
206
+ return token === void 0 || value === void 0 || recipient === void 0 ? void 0 : {
207
+ token,
208
+ amount: value,
209
+ recipient
210
+ };
211
+ };
212
+ const outputsOf = (key, amount) => {
213
+ const raw = witness[key];
214
+ if (!Array.isArray(raw) || raw.length === 0) return;
215
+ const outputs = [];
216
+ for (const item of raw) {
217
+ const parsed = output(item, amount);
218
+ if (parsed === void 0) return;
219
+ outputs.push(parsed);
220
+ }
221
+ return outputs;
222
+ };
223
+ const dutch = (m) => {
224
+ const start = uint$1(m, "startAmount");
225
+ const end = uint$1(m, "endAmount");
226
+ return start === void 0 || end === void 0 ? void 0 : start < end ? start : end;
227
+ };
228
+ if (type === "ExclusiveDutchOrder" || type === "V2DutchOrder") {
229
+ const exclusive = type === "ExclusiveDutchOrder";
230
+ const prefix = exclusive ? "input" : "baseInput";
231
+ const inputToken = address$1(witness, `${prefix}Token`);
232
+ const start = uint$1(witness, `${prefix}StartAmount`);
233
+ const end = uint$1(witness, `${prefix}EndAmount`);
234
+ const outputs = outputsOf(exclusive ? "outputs" : "baseOutputs", (m) => dutch(m));
235
+ const filler = exclusive ? address$1(witness, "exclusiveFiller") : void 0;
236
+ const decayed = uint$1(witness, "decayStartTime") !== void 0 && uint$1(witness, "decayEndTime") !== void 0 && uint$1(witness, "exclusivityOverrideBps") !== void 0;
237
+ const cosigned = exclusive || address$1(witness, "cosigner") !== void 0;
238
+ if (inputToken === void 0 || start === void 0 || end === void 0 || outputs === void 0 || exclusive && (!decayed || filler === void 0) || !cosigned) return;
239
+ return {
240
+ info,
241
+ inputToken,
242
+ giveAmount: start > end ? start : end,
243
+ outputs,
244
+ ...exclusive && filler !== void 0 && filler.toLowerCase() !== ZERO ? { exclusiveFiller: filler } : {}
245
+ };
246
+ }
247
+ if (type === "V3DutchOrder") {
248
+ const input = witness["baseInput"];
249
+ if (!isTypedDataMessage(input) || !isTypedDataMessage(input["curve"]) || address$1(witness, "cosigner") === void 0 || uint$1(witness, "startingBaseFee") === void 0) return;
250
+ const inputToken = address$1(input, "token");
251
+ const maxAmount = uint$1(input, "maxAmount");
252
+ const outputs = outputsOf("baseOutputs", (m) => isTypedDataMessage(m["curve"]) ? uint$1(m, "minAmount") : void 0);
253
+ return inputToken === void 0 || maxAmount === void 0 || outputs === void 0 ? void 0 : {
254
+ info,
255
+ inputToken,
256
+ giveAmount: maxAmount,
257
+ outputs
258
+ };
259
+ }
260
+ const { input } = witness;
261
+ if (!isTypedDataMessage(input) || address$1(witness, "cosigner") === void 0 || uint$1(witness, "auctionStartBlock") === void 0 || uint$1(witness, "baselinePriorityFeeWei") === void 0 || uint$1(input, "mpsPerPriorityFeeWei") === void 0) return;
262
+ const inputToken = address$1(input, "token");
263
+ const amount = uint$1(input, "amount");
264
+ const outputs = outputsOf("outputs", (m) => uint$1(m, "mpsPerPriorityFeeWei") === void 0 ? void 0 : uint$1(m, "amount"));
265
+ return inputToken === void 0 || amount === void 0 || outputs === void 0 ? void 0 : {
266
+ info,
267
+ inputToken,
268
+ giveAmount: amount,
269
+ outputs
270
+ };
271
+ };
272
+ /**
273
+ * The UniswapX order a Permit2 witness document signs, `oversize` when its outputs cannot all be
274
+ * shown, or `undefined` — the caller then falls back to the opaque-witness path.
275
+ */
276
+ const recognizeUniswapX = (json, signer, chainId, table) => {
277
+ const { types, primaryType, message, domain } = json;
278
+ if (primaryType !== "PermitWitnessTransferFrom") return;
279
+ const witnessField = types[primaryType]?.at(-1);
280
+ const witnessType = witnessField?.name === "witness" ? witnessField.type : void 0;
281
+ if (witnessType === void 0 || !isWitnessType(witnessType)) return;
282
+ const expected = {
283
+ ...PERMIT2_TYPES,
284
+ PermitWitnessTransferFrom: [
285
+ "TokenPermissions permitted",
286
+ "address spender",
287
+ "uint256 nonce",
288
+ "uint256 deadline",
289
+ `${witnessType} witness`
290
+ ],
291
+ ...ORDER_TYPES[witnessType]
292
+ };
293
+ if (Object.keys(types).length !== Object.keys(expected).length || !Object.entries(expected).every(([name, fields]) => sameFields(types, name, fields)) || domainChainId(domain) !== chainId) return;
294
+ const { permitted } = message;
295
+ const { witness } = message;
296
+ const spender = address$1(message, "spender");
297
+ const permittedToken = isTypedDataMessage(permitted) ? address$1(permitted, "token") : void 0;
298
+ const permittedAmount = isTypedDataMessage(permitted) ? uint$1(permitted, "amount") : void 0;
299
+ const parsed = isTypedDataMessage(witness) ? parse(witnessType, witness) : void 0;
300
+ if (spender === void 0 || permittedToken === void 0 || permittedAmount === void 0 || parsed === void 0 || parsed.inputToken.toLowerCase() !== permittedToken.toLowerCase()) return;
301
+ const { info } = parsed;
302
+ const reactor = address$1(info, "reactor");
303
+ const swapper = address$1(info, "swapper");
304
+ const nonce = uint$1(info, "nonce");
305
+ const deadline = uint$1(info, "deadline");
306
+ if (reactor === void 0 || reactor.toLowerCase() !== spender.toLowerCase() || reactor.toLowerCase() !== REACTORS[chainId]?.[witnessType] || swapper === void 0 || swapper.toLowerCase() !== signer.toLowerCase() || nonce === void 0 || deadline === void 0 || deadline > BigInt(Number.MAX_SAFE_INTEGER) || address$1(info, "additionalValidationContract") === void 0 || typedDataBytes(info["additionalValidationData"]) === void 0) return;
307
+ if (parsed.outputs.length > 8) return { kind: "oversize" };
308
+ const maker = checksumEvmAddress(signer);
309
+ const giveAmount = parsed.giveAmount < permittedAmount ? parsed.giveAmount : permittedAmount;
310
+ return {
311
+ kind: "order",
312
+ order: {
313
+ protocol: "uniswapx",
314
+ maker,
315
+ give: orderAmount(parsed.inputToken, giveAmount, chainId, table),
316
+ receive: parsed.outputs.map((o) => ({
317
+ recipient: o.recipient,
318
+ amount: orderAmount(o.token, o.amount, chainId, table, ZERO)
319
+ })),
320
+ expiry: Number(deadline),
321
+ partialFill: false,
322
+ ...parsed.exclusiveFiller === void 0 ? {} : { exclusiveFiller: parsed.exclusiveFiller }
323
+ }
324
+ };
325
+ };
326
+ // src/evm/zerox.ts
327
+ /**
328
+ * The 0x AllowanceHolder (`exec`) is deployed at the same address on every chain the taker Settler
329
+ * supports. `exec` grants the caller a one-time allowance of `amount` of `token` to `operator`,
330
+ * then calls `target` with `data` (forwarding `msg.value`).
331
+ */
332
+ const ALLOWANCE_HOLDER = "0x0000000000001fF3684f28c67538d4D072C22734";
333
+ /** Chains whose AllowanceHolder + Settler deployment this decoder recognises. */
334
+ const ZEROX_CHAINS = /* @__PURE__ */ new Set([
335
+ 1,
336
+ 10,
337
+ 56,
338
+ 137,
339
+ 8453,
340
+ 999,
341
+ 42161,
342
+ 43114,
343
+ 11155111
344
+ ]);
345
+ const ZEROX_DEPLOYER = "0x00000000000004533Fe15556B1E086BB1A72cEae";
346
+ const SHIM_INIT_CODE_HASH = "0x3bf3f97f0be1e2c00023033eefeb4fc062ac552ff36778b17060d90b6764902f";
347
+ /** The native-token sentinel 0x uses in `exec`, and the bare zero address (same meaning). */
348
+ const NATIVE_SENTINEL = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
349
+ const ZERO_ADDRESS$1 = "0x0000000000000000000000000000000000000000";
350
+ const EXEC = AbiFunction.from("function exec(address operator, address token, uint256 amount, address payable target, bytes data)");
351
+ const SETTLER_EXECUTE = AbiFunction.from("function execute((address recipient, address buyToken, uint256 minAmountOut) slippage, bytes[] actions, bytes32 zid)");
352
+ const last20 = (hex) => `0x${hex.slice(-40)}`;
353
+ const addressBytes = (address) => hexToBytes(address.slice(2));
354
+ const bigIntBytes32 = (value) => hexToBytes(value.toString(16).padStart(64, "0"));
355
+ const keccakHex = (parts) => {
356
+ const total = parts.reduce((sum, part) => sum + part.length, 0);
357
+ const flat = new Uint8Array(total);
358
+ let offset = 0;
359
+ for (const part of parts) {
360
+ flat.set(part, offset);
361
+ offset += part.length;
362
+ }
363
+ return `0x${bytesToHex(keccak_256(flat))}`;
364
+ };
365
+ const FEATURE_TAKER = 2n;
366
+ const FEATURE_METATXN = 3n;
367
+ /**
368
+ * Whether `address` is a `feature` 0x Settler on `chainId` — 2 taker, 3 MetaTxn (Deployer.sol's
369
+ * `ownerOf(tokenId)`). Settlers deploy as a CREATE2 shim whose CREATE child is the contract: `salt
370
+ * = (feature << 128) | (chainId << 64) | nonce`, `shim = CREATE2(deployer, salt, initHash)`,
371
+ * `settler = CREATE(shim, 1)`. Settler is redeployed roughly monthly, so nonces 1..256 leave
372
+ * decades of headroom; the loop runs 512 keccaks and is only reached for an AllowanceHolder `exec`
373
+ * or a Permit2 `slippageAndActions` witness. Feature 5 (bridge) is deliberately not matched.
374
+ */
375
+ const isZeroExSettler = (chainId, address, feature = FEATURE_TAKER) => {
376
+ const want = address.toLowerCase();
377
+ const deployer = addressBytes(ZEROX_DEPLOYER);
378
+ const initHash = hexToBytes(SHIM_INIT_CODE_HASH.slice(2));
379
+ for (let nonce = 1; nonce <= 256; nonce++) {
380
+ const salt = bigIntBytes32(feature * 2n ** 128n + BigInt(chainId) * 2n ** 64n + BigInt(nonce));
381
+ const shim = addressBytes(last20(keccakHex([
382
+ new Uint8Array([255]),
383
+ deployer,
384
+ salt,
385
+ initHash
386
+ ])));
387
+ if (last20(keccakHex([
388
+ new Uint8Array([214, 148]),
389
+ shim,
390
+ new Uint8Array([1])
391
+ ])) === want) return true;
392
+ }
393
+ return false;
394
+ };
395
+ /** The canonical-decoded `exec` arguments, or `undefined` (selector mismatch or non-canonical). */
396
+ const decodeExec = (data) => {
397
+ if (!data.toLowerCase().startsWith("0x2213bc0b")) return;
398
+ try {
399
+ assertHex$1(data, "data");
400
+ const args = AbiFunction.decodeData(EXEC, data);
401
+ if (!Array.isArray(args) || args.length !== 5) return;
402
+ if (AbiFunction.encodeData(EXEC, args).toLowerCase() !== data.toLowerCase()) return;
403
+ const [operator, token, amount, target, inner] = args;
404
+ if (typeof operator !== "string" || typeof token !== "string" || typeof amount !== "bigint" || typeof target !== "string" || typeof inner !== "string") return;
405
+ return {
406
+ operator,
407
+ token,
408
+ amount,
409
+ target,
410
+ data: inner
411
+ };
412
+ } catch {
413
+ return;
414
+ }
415
+ };
416
+ const isSlippage = (value) => typeof value === "object" && value !== null && "recipient" in value && typeof value.recipient === "string" && "buyToken" in value && typeof value.buyToken === "string" && "minAmountOut" in value && typeof value.minAmountOut === "bigint";
417
+ /**
418
+ * The canonical-decoded `execute` slippage tuple, or `undefined` when the call is not a Settler
419
+ * execute.
420
+ */
421
+ const decodeSettlerExecute = (data) => {
422
+ if (!data.toLowerCase().startsWith("0x1fff991f")) return;
423
+ try {
424
+ assertHex$1(data, "data");
425
+ const args = AbiFunction.decodeData(SETTLER_EXECUTE, data);
426
+ if (!Array.isArray(args) || args.length !== 3) return;
427
+ if (AbiFunction.encodeData(SETTLER_EXECUTE, args).toLowerCase() !== data.toLowerCase()) return;
428
+ const [slippage] = args;
429
+ if (!isSlippage(slippage)) return;
430
+ return slippage;
431
+ } catch {
432
+ return;
433
+ }
434
+ };
435
+ const isNativeToken = (token) => token.toLowerCase() === NATIVE_SENTINEL || token.toLowerCase() === ZERO_ADDRESS$1;
436
+ const tokenAmount = (token, amount, chainId, table) => {
437
+ const known = lookupEvmToken(table, chainId, token);
438
+ return {
439
+ asset: checksumEvmAddress(token),
440
+ amount: amount.toString(10),
441
+ ...known === void 0 ? {} : {
442
+ symbol: known.symbol,
443
+ decimals: known.decimals
444
+ }
445
+ };
446
+ };
447
+ const nativeMinimum = (amount) => ({
448
+ asset: EVM_NATIVE_ASSET,
449
+ amount: amount.toString(10)
450
+ });
451
+ /**
452
+ * The `DisplayIntent` for a call to AllowanceHolder `exec` on a chain this decoder covers: a swap
453
+ * when the operator calls the taker Settler's own `execute` (operator == target, an on-chain
454
+ * Settler, a canonical inner call) and a generic one-time allowance otherwise. `undefined` when the
455
+ * call is not to AllowanceHolder or not `exec`.
456
+ */
457
+ const decodeZeroX = (chainId, call, table) => {
458
+ if (call.to === void 0 || call.to.toLowerCase() !== "0x0000000000001fF3684f28c67538d4D072C22734".toLowerCase() || !ZEROX_CHAINS.has(chainId)) return;
459
+ const exec = decodeExec(call.data);
460
+ if (exec === void 0) return;
461
+ const { operator, token, amount, target, data: inner } = exec;
462
+ const slippage = decodeSettlerExecute(inner);
463
+ if (operator.toLowerCase() === target.toLowerCase() && isZeroExSettler(chainId, target) && slippage !== void 0 && slippage !== void 0) {
464
+ let outflow;
465
+ if (isNativeToken(token)) {
466
+ if (amount === call.value && call.value > 0n) outflow = {
467
+ to: target,
468
+ amount: {
469
+ asset: EVM_NATIVE_ASSET,
470
+ amount: call.value.toString(10)
471
+ },
472
+ verified: true
473
+ };
474
+ } else if (call.value === 0n) outflow = {
475
+ to: target,
476
+ amount: tokenAmount(token, amount, chainId, table),
477
+ verified: lookupEvmToken(table, chainId, token) !== void 0
478
+ };
479
+ if (outflow !== void 0) {
480
+ const buyNative = isNativeToken(slippage.buyToken);
481
+ return {
482
+ summary: "swap",
483
+ outflows: [outflow],
484
+ approvals: [],
485
+ minimumReceived: [{
486
+ to: slippage.recipient,
487
+ amount: buyNative ? nativeMinimum(slippage.minAmountOut) : tokenAmount(slippage.buyToken, slippage.minAmountOut, chainId, table)
488
+ }],
489
+ verifiability: "partial"
490
+ };
491
+ }
492
+ }
493
+ const approvals = isNativeToken(token) ? [] : [allowanceChange(checksumEvmAddress(token), operator, amount, "transfer", MAX_UINT256, chainId, table, { via: "allowance-holder" })];
494
+ return {
495
+ summary: "contract-call",
496
+ outflows: call.value === 0n ? [] : [{
497
+ to: target,
498
+ amount: {
499
+ asset: EVM_NATIVE_ASSET,
500
+ amount: call.value.toString(10)
501
+ },
502
+ verified: true
503
+ }],
504
+ approvals,
505
+ verifiability: "partial"
506
+ };
507
+ };
508
+ const METATXN_DOMAIN = [
509
+ "string name",
510
+ "uint256 chainId",
511
+ "address verifyingContract"
512
+ ];
513
+ const METATXN_PERMIT = [
514
+ "TokenPermissions permitted",
515
+ "address spender",
516
+ "uint256 nonce",
517
+ "uint256 deadline",
518
+ "SlippageAndActions slippageAndActions"
519
+ ];
520
+ const METATXN_SLIPPAGE = [
521
+ "address recipient",
522
+ "address buyToken",
523
+ "uint256 minAmountOut",
524
+ "bytes[] actions"
525
+ ];
526
+ /**
527
+ * The gasless order a 0x Settler MetaTxn Permit2 witness signs (0xProject/0x-settler@ad7c844
528
+ * `src/SettlerMetaTxn.sol` + `src/core/Permit2Payment.sol`): the meta-transaction's first action
529
+ * must consume this witness's Permit2 transfer, and `_checkSlippageAndTransfer` requires the
530
+ * Settler to hold at least `minAmountOut` of `buyToken` and sends its whole balance to `recipient`
531
+ * — `minAmountOut` is the least the recipient gets (a 0 bound skips the check only together with a
532
+ * zero `buyToken`, and would bind nothing, so the decoder requires a positive bound). `spender`
533
+ * must be the MetaTxn-feature Settler of the request's chain — `permit.ts` is already gated to the
534
+ * Permit2 verifying contract.
535
+ */
536
+ const recognizeZeroXMetaTxn = (json, signer, chainId, table) => {
537
+ const { types, primaryType, domain, message } = json;
538
+ if (primaryType !== "PermitWitnessTransferFrom" || Object.keys(types).length !== 4 || !sameFields(types, "EIP712Domain", METATXN_DOMAIN) || !sameFields(types, "TokenPermissions", ["address token", "uint256 amount"]) || !sameFields(types, "SlippageAndActions", METATXN_SLIPPAGE) || !sameFields(types, "PermitWitnessTransferFrom", METATXN_PERMIT) || !ZEROX_CHAINS.has(chainId) || domainChainId(domain) !== chainId) return;
539
+ const { permitted, slippageAndActions } = message;
540
+ const spender = typedDataAddress(message["spender"]);
541
+ const permittedToken = isTypedDataMessage(permitted) ? typedDataAddress(permitted["token"]) : void 0;
542
+ const permittedAmount = isTypedDataMessage(permitted) ? typedDataUint(permitted["amount"], MAX_UINT256) : void 0;
543
+ const nonce = typedDataUint(message["nonce"], MAX_UINT256);
544
+ const deadline = typedDataUint(message["deadline"], MAX_UINT256);
545
+ const recipient = isTypedDataMessage(slippageAndActions) ? typedDataAddress(slippageAndActions["recipient"]) : void 0;
546
+ const buyToken = isTypedDataMessage(slippageAndActions) ? typedDataAddress(slippageAndActions["buyToken"]) : void 0;
547
+ const minAmountOut = isTypedDataMessage(slippageAndActions) ? typedDataUint(slippageAndActions["minAmountOut"], MAX_UINT256) : void 0;
548
+ const actions = isTypedDataMessage(slippageAndActions) ? slippageAndActions["actions"] : void 0;
549
+ if (spender === void 0 || !isZeroExSettler(chainId, spender, FEATURE_METATXN) || permittedToken === void 0 || permittedAmount === void 0 || nonce === void 0 || deadline === void 0 || recipient === void 0 || buyToken === void 0 || minAmountOut === void 0 || minAmountOut === 0n || !Array.isArray(actions) || actions.some((action) => typedDataBytes(action) === void 0)) return;
550
+ return {
551
+ protocol: "0x",
552
+ maker: checksumEvmAddress(signer),
553
+ give: orderAmount(permittedToken, permittedAmount, chainId, table),
554
+ receive: [{
555
+ recipient,
556
+ amount: orderAmount(buyToken, minAmountOut, chainId, table, NATIVE_SENTINEL)
557
+ }],
558
+ ...deadline <= MAX_UINT48 ? { expiry: Number(deadline) } : {},
559
+ partialFill: false
560
+ };
561
+ };
562
+ // src/evm/permit.ts
563
+ const isMessage = isTypedDataMessage;
564
+ const address = typedDataAddress;
565
+ const uint = typedDataUint;
566
+ const DETAILS = [
567
+ "address token",
568
+ "uint160 amount",
569
+ "uint48 expiration",
570
+ "uint48 nonce"
571
+ ];
572
+ const PERMISSIONS = ["address token", "uint256 amount"];
573
+ const WITNESS_WARNING = {
574
+ kind: "permit2-witness",
575
+ message: "the permit carries a witness with further terms"
576
+ };
577
+ const entries = (value) => Array.isArray(value) && value.length > 0 && value.every(isMessage) ? value : void 0;
578
+ const permit = (...approvals) => ({
579
+ approvals,
580
+ warnings: []
581
+ });
582
+ /**
583
+ * The permit a typed-data document grants, or `undefined` when its shape is not exactly one of the
584
+ * recognized ones. `chainId` is the request network's, used for the built-in token table. `signer`
585
+ * lets a witness be checked against the account it binds (UniswapX `info.swapper`).
586
+ */
587
+ function recognizePermit(json, chainId, table, signer, permit2 = PERMIT2_ADDRESS) {
588
+ const { types, primaryType, message, domain } = json;
589
+ const verifying = address(domain["verifyingContract"]);
590
+ if (verifying === void 0) return;
591
+ const spender = address(message["spender"]);
592
+ if (spender === void 0) return;
593
+ const allow = (token, value, change, max, extra = {}) => allowanceChange(token, spender, value, change, max, chainId, table, extra);
594
+ if (primaryType === "Permit") {
595
+ if (sameFields(types, "Permit", [
596
+ "address owner",
597
+ "address spender",
598
+ "uint256 value",
599
+ "uint256 nonce",
600
+ "uint256 deadline"
601
+ ])) {
602
+ const value = uint(message["value"], MAX_UINT256);
603
+ return value === void 0 ? void 0 : permit(allow(verifying, value, "set", MAX_UINT256));
604
+ }
605
+ if (sameFields(types, "Permit", [
606
+ "address holder",
607
+ "address spender",
608
+ "uint256 nonce",
609
+ "uint256 expiry",
610
+ "bool allowed"
611
+ ])) {
612
+ const { allowed } = message;
613
+ return typeof allowed === "boolean" ? permit(allow(verifying, allowed ? MAX_UINT256 : 0n, "set", MAX_UINT256)) : void 0;
614
+ }
615
+ return;
616
+ }
617
+ if (permit2 === "" || verifying.toLowerCase() !== permit2.toLowerCase()) return;
618
+ return recognizePermit2(json, allow, signer, chainId, table);
619
+ }
620
+ const all = (list, build) => {
621
+ const built = list?.map(build);
622
+ return built === void 0 || built.some((a) => a === void 0) ? void 0 : permit(...built.filter((a) => a !== void 0));
623
+ };
624
+ const recognizePermit2 = (json, allow, signer, chainId, table) => {
625
+ const { types, primaryType, message } = json;
626
+ const via = "permit2";
627
+ const allowance = (details) => {
628
+ const token = address(details["token"]);
629
+ const amount = uint(details["amount"], MAX_UINT160);
630
+ const expiration = uint(details["expiration"], MAX_UINT48);
631
+ return token === void 0 || amount === void 0 || expiration === void 0 ? void 0 : allow(token, amount, "set", MAX_UINT160, {
632
+ via,
633
+ expiration: Number(expiration)
634
+ });
635
+ };
636
+ const transfer = (permitted, deadline) => {
637
+ const token = address(permitted["token"]);
638
+ const amount = uint(permitted["amount"], MAX_UINT256);
639
+ return token === void 0 || amount === void 0 ? void 0 : allow(token, amount, "transfer", MAX_UINT256, {
640
+ via,
641
+ ...deadline <= MAX_UINT48 ? { expiration: Number(deadline) } : {}
642
+ });
643
+ };
644
+ if (primaryType === "PermitSingle") {
645
+ const { details } = message;
646
+ return sameFields(types, primaryType, [
647
+ "PermitDetails details",
648
+ "address spender",
649
+ "uint256 sigDeadline"
650
+ ]) && sameFields(types, "PermitDetails", DETAILS) && isMessage(details) ? all([details], allowance) : void 0;
651
+ }
652
+ if (primaryType === "PermitBatch") return sameFields(types, primaryType, [
653
+ "PermitDetails[] details",
654
+ "address spender",
655
+ "uint256 sigDeadline"
656
+ ]) && sameFields(types, "PermitDetails", DETAILS) ? all(entries(message["details"]), allowance) : void 0;
657
+ const witness = primaryType.includes("Witness");
658
+ const batch = primaryType.includes("Batch");
659
+ const expected = batch ? [
660
+ "TokenPermissions[] permitted",
661
+ "address spender",
662
+ "uint256 nonce",
663
+ "uint256 deadline"
664
+ ] : [
665
+ "TokenPermissions permitted",
666
+ "address spender",
667
+ "uint256 nonce",
668
+ "uint256 deadline"
669
+ ];
670
+ if (primaryType !== `Permit${batch ? "Batch" : ""}${witness ? "Witness" : ""}TransferFrom`) return;
671
+ const own = types[primaryType];
672
+ const last = own?.at(-1);
673
+ const fieldsOk = witness ? sameFields({
674
+ ...types,
675
+ [primaryType]: own?.slice(0, -1) ?? []
676
+ }, primaryType, expected) && (last?.name === "witness" || last?.name === "slippageAndActions") && types[last.type] !== void 0 : sameFields(types, primaryType, expected);
677
+ const deadline = uint(message["deadline"], MAX_UINT256);
678
+ if (!fieldsOk || !sameFields(types, "TokenPermissions", PERMISSIONS) || deadline === void 0) return;
679
+ const { permitted } = message;
680
+ const result = batch ? all(entries(permitted), (item) => transfer(item, deadline)) : isMessage(permitted) ? all([permitted], (item) => transfer(item, deadline)) : void 0;
681
+ return result === void 0 || !witness ? result : witnessOutcome(result, json, signer, chainId, table);
682
+ };
683
+ /**
684
+ * What a witness carries when the permit itself decoded: a recognised UniswapX order (the take-once
685
+ * approval stays; no further warning), or the witness subtree's leaves with the warning. A subtree
686
+ * that cannot be shown in full — too many leaves, a leaf not exactly encodable — or a recognised
687
+ * order over the item limit blinds the document; a commitment leaf blinds it too.
688
+ */
689
+ const witnessOutcome = (result, json, signer, chainId, table) => {
690
+ if (json.types[json.primaryType]?.at(-1)?.name === "slippageAndActions") {
691
+ const order = recognizeZeroXMetaTxn(json, signer, chainId, table);
692
+ return order === void 0 ? void 0 : {
693
+ approvals: result.approvals,
694
+ warnings: [],
695
+ order
696
+ };
697
+ }
698
+ const uniswapx = recognizeUniswapX(json, signer, chainId, table);
699
+ if (uniswapx?.kind === "order") return {
700
+ approvals: result.approvals,
701
+ warnings: [],
702
+ order: uniswapx.order
703
+ };
704
+ const witnessType = json.types[json.primaryType]?.at(-1)?.type;
705
+ const { witness } = json.message;
706
+ const subtree = uniswapx === void 0 && witnessType !== void 0 && isMessage(witness) ? typedDataFields({
707
+ types: json.types,
708
+ primaryType: witnessType,
709
+ domain: {},
710
+ message: witness
711
+ }) : void 0;
712
+ return {
713
+ approvals: result.approvals,
714
+ warnings: [WITNESS_WARNING],
715
+ ...subtree === void 0 ? {} : { fields: subtree.fields.map((leaf) => ({
716
+ ...leaf,
717
+ path: `witness.${leaf.path}`
718
+ })) },
719
+ ...subtree === void 0 ? { blind: "typed-data-oversize" } : subtree.hasCommitment ? { blind: "typed-data-commitment" } : {}
720
+ };
721
+ };
722
+ // src/evm/token-call.ts
723
+ /**
724
+ * The ERC-20/721/1155 selector table shared with TRON's TRC-20 decoding — its own module so the
725
+ * TRON bundle does not pull the rest of the EVM decoder (0x, Across, Lido, Seaport, Safe,
726
+ * typed-data). Permit2's approve/lockdown stay in decode.ts: they are gated on the Permit2 address,
727
+ * which a TRC-20 callee never is.
728
+ */
729
+ const ERC20_TRANSFER = AbiFunction.from("function transfer(address to, uint256 amount)");
730
+ const ERC20_APPROVE = AbiFunction.from("function approve(address spender, uint256 amount)");
731
+ const ERC20_INCREASE = AbiFunction.from("function increaseAllowance(address spender, uint256 amount)");
732
+ const ERC20_DECREASE = AbiFunction.from("function decreaseAllowance(address spender, uint256 subtractedValue)");
733
+ const SET_APPROVAL_FOR_ALL = AbiFunction.from("function setApprovalForAll(address operator, bool approved)");
734
+ const ERC721_SAFE_FROM_DATA = AbiFunction.from("function safeTransferFrom(address from, address to, uint256 tokenId, bytes data)");
735
+ const ERC1155_SAFE_BATCH_FROM = AbiFunction.from("function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data)");
736
+ const ERC721_TRANSFER_FROM = AbiFunction.from("function transferFrom(address from, address to, uint256 tokenId)");
737
+ const ERC721_SAFE_FROM = AbiFunction.from("function safeTransferFrom(address from, address to, uint256 tokenId)");
738
+ const ERC1155_SAFE_FROM = AbiFunction.from("function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data)");
739
+ function assertHex(data) {
740
+ if (!/^0x[0-9a-fA-F]*$/.test(data)) throw new ChainError("invalid-request", "call data is not 0x-prefixed hex");
741
+ }
742
+ const argAddress = (args, index) => {
743
+ const value = args[index];
744
+ if (typeof value !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(value)) throw new ChainError("invalid-request", "decoded argument is not an address");
745
+ return checksumEvmAddress(value);
746
+ };
747
+ const argUint = (args, index) => {
748
+ const value = args[index];
749
+ if (typeof value !== "bigint") throw new ChainError("invalid-request", "decoded argument is not a uint256");
750
+ return value;
751
+ };
752
+ /**
753
+ * Decodes `data` as `fn` and verifies the encoding is canonical (re-encoding the decoded args
754
+ * reproduces the input byte-for-byte). Returns undefined on selector mismatch, decode failure or a
755
+ * non-canonical encoding — the caller falls through to the next candidate or the opaque class.
756
+ */
757
+ const tryCall = (fn, data) => {
758
+ const selector = AbiFunction.getSelector(fn);
759
+ if (!data.toLowerCase().startsWith(selector)) return;
760
+ try {
761
+ assertHex(data);
762
+ const args = AbiFunction.decodeData(fn, data);
763
+ if (!Array.isArray(args)) return;
764
+ return AbiFunction.encodeData(fn, args).toLowerCase() === data.toLowerCase() ? args : void 0;
765
+ } catch {
766
+ return;
767
+ }
768
+ };
769
+ const tokenFlow = (target, to, amount, chainId, table) => {
770
+ const token = lookupEvmToken(table, chainId, target);
771
+ return {
772
+ flows: [{
773
+ to,
774
+ amount: {
775
+ asset: target,
776
+ amount: amount.toString(10),
777
+ ...token === void 0 ? {} : {
778
+ symbol: token.symbol,
779
+ decimals: token.decimals
780
+ }
781
+ },
782
+ verified: token !== void 0
783
+ }],
784
+ verified: token !== void 0
785
+ };
786
+ };
787
+ const argBool = (args, index) => {
788
+ const value = args[index];
789
+ if (typeof value !== "boolean") throw new ChainError("invalid-request", "decoded argument is not a bool");
790
+ return value;
791
+ };
792
+ const argList = (args, index) => {
793
+ const value = args[index];
794
+ if (!Array.isArray(value)) throw new ChainError("invalid-request", "decoded argument is not an array");
795
+ return value;
796
+ };
797
+ const nftFlow = (asset, to, id, value = 1n) => [{
798
+ to,
799
+ amount: {
800
+ asset,
801
+ amount: value.toString(10),
802
+ tokenId: id.toString(10)
803
+ },
804
+ verified: false
805
+ }];
806
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
807
+ /**
808
+ * The token-standard selectors, in the same order the EVM decoder tries them: transfer,
809
+ * approve/increaseAllowance/decreaseAllowance, setApprovalForAll, transferFrom, the two ERC-721
810
+ * safeTransferFrom forms, then ERC-1155 single and batch. `token` is the callee, `data` 0x hex.
811
+ */
812
+ const decodeTokenCall = (token, data, chainId, table) => {
813
+ const transferArgs = tryCall(ERC20_TRANSFER, data);
814
+ if (transferArgs !== void 0) {
815
+ const { flows, verified } = tokenFlow(token, argAddress(transferArgs, 0), argUint(transferArgs, 1), chainId, table);
816
+ return {
817
+ summary: "transfer",
818
+ outflows: flows,
819
+ approvals: [],
820
+ verifiability: verified ? "full" : "partial"
821
+ };
822
+ }
823
+ for (const [fn, change] of [
824
+ [ERC20_APPROVE, "set"],
825
+ [ERC20_INCREASE, "increase"],
826
+ [ERC20_DECREASE, "decrease"]
827
+ ]) {
828
+ const args = tryCall(fn, data);
829
+ if (args !== void 0) {
830
+ const spender = argAddress(args, 0);
831
+ const amount = argUint(args, 1);
832
+ if (change === "set" && spender === ZERO_ADDRESS) return {
833
+ summary: "approve",
834
+ outflows: [],
835
+ approvals: [{
836
+ kind: "approval-cleared",
837
+ asset: token,
838
+ value: amount.toString(10),
839
+ verified: false
840
+ }],
841
+ verifiability: "partial"
842
+ };
843
+ return {
844
+ summary: "approve",
845
+ outflows: [],
846
+ approvals: [allowanceChange(token, spender, amount, change, MAX_UINT256, chainId, table)],
847
+ verifiability: "partial"
848
+ };
849
+ }
850
+ }
851
+ const operatorArgs = tryCall(SET_APPROVAL_FOR_ALL, data);
852
+ if (operatorArgs !== void 0) return {
853
+ summary: "approve",
854
+ outflows: [],
855
+ approvals: [{
856
+ kind: "operator",
857
+ asset: token,
858
+ spender: argAddress(operatorArgs, 0),
859
+ approved: argBool(operatorArgs, 1),
860
+ verified: false
861
+ }],
862
+ verifiability: "partial"
863
+ };
864
+ const transferFromArgs = tryCall(ERC721_TRANSFER_FROM, data);
865
+ if (transferFromArgs !== void 0) {
866
+ const to = argAddress(transferFromArgs, 1);
867
+ const id = argUint(transferFromArgs, 2);
868
+ if (lookupEvmToken(table, chainId, token) !== void 0) return {
869
+ summary: "transfer",
870
+ outflows: tokenFlow(token, to, id, chainId, table).flows,
871
+ approvals: [],
872
+ verifiability: "partial"
873
+ };
874
+ return {
875
+ summary: "transfer",
876
+ outflows: nftFlow(token, to, id),
877
+ approvals: [],
878
+ verifiability: "partial"
879
+ };
880
+ }
881
+ for (const fn of [ERC721_SAFE_FROM, ERC721_SAFE_FROM_DATA]) {
882
+ const args = tryCall(fn, data);
883
+ if (args !== void 0) return {
884
+ summary: "transfer",
885
+ outflows: nftFlow(token, argAddress(args, 1), argUint(args, 2)),
886
+ approvals: [],
887
+ verifiability: "partial"
888
+ };
889
+ }
890
+ const erc1155Args = tryCall(ERC1155_SAFE_FROM, data);
891
+ if (erc1155Args !== void 0) return {
892
+ summary: "transfer",
893
+ outflows: nftFlow(token, argAddress(erc1155Args, 1), argUint(erc1155Args, 2), argUint(erc1155Args, 3)),
894
+ approvals: [],
895
+ verifiability: "partial"
896
+ };
897
+ const batchArgs = tryCall(ERC1155_SAFE_BATCH_FROM, data);
898
+ if (batchArgs !== void 0) {
899
+ const ids = argList(batchArgs, 2);
900
+ const values = argList(batchArgs, 3);
901
+ if (ids.length > 0 && ids.length === values.length) {
902
+ const to = argAddress(batchArgs, 1);
903
+ return {
904
+ summary: "transfer",
905
+ outflows: ids.flatMap((id, i) => nftFlow(token, to, argUint([id], 0), argUint([values[i] ?? 0n], 0))),
906
+ approvals: [],
907
+ verifiability: "partial"
908
+ };
909
+ }
910
+ }
911
+ };
912
+ export { decodeZeroX as a, orderAmount as c, PERMIT2_ADDRESS as d, allowanceChange as f, ZEROX_CHAINS as i, MAX_UINT160 as l, recognizePermit as n, isZeroExSettler as o, ALLOWANCE_HOLDER as r, ORDER_ITEMS as s, decodeTokenCall as t, MAX_UINT256 as u };
913
+
914
+ //# sourceMappingURL=token-call-DH22g8BL.mjs.map