@qntx/wallet-chains 0.13.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.
- package/README.md +13 -10
- package/dist/{account-ref-D2rW_qlI.mjs → account-ref-BFTeEyHt.mjs} +2 -2
- package/dist/{account-ref-D2rW_qlI.mjs.map → account-ref-BFTeEyHt.mjs.map} +1 -1
- package/dist/assemble-8GvNDony.mjs +405 -0
- package/dist/assemble-8GvNDony.mjs.map +1 -0
- package/dist/assemble-B3sO9Fvc.mjs +629 -0
- package/dist/assemble-B3sO9Fvc.mjs.map +1 -0
- package/dist/assemble-BdiPo0ZX.mjs +32 -0
- package/dist/assemble-BdiPo0ZX.mjs.map +1 -0
- package/dist/assets-sg2_Z3nZ.mjs +200 -0
- package/dist/assets-sg2_Z3nZ.mjs.map +1 -0
- package/dist/bitcoin-sign.d.mts +3 -0
- package/dist/bitcoin-sign.mjs +52 -18
- package/dist/bitcoin-sign.mjs.map +1 -1
- package/dist/bitcoin.d.mts +123 -7
- package/dist/bitcoin.mjs +162 -69
- package/dist/bitcoin.mjs.map +1 -1
- package/dist/evm-sign.d.mts +3 -1
- package/dist/evm-sign.mjs +25 -108
- package/dist/evm-sign.mjs.map +1 -1
- package/dist/evm.d.mts +152 -28
- package/dist/evm.mjs +2216 -753
- package/dist/evm.mjs.map +1 -1
- package/dist/families-BlgplKAJ.mjs +412 -0
- package/dist/families-BlgplKAJ.mjs.map +1 -0
- package/dist/index-CIRaHKpx.d.mts +941 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/networks.d.mts +29 -0
- package/dist/networks.mjs +245 -0
- package/dist/networks.mjs.map +1 -0
- package/dist/plan-wCnxHqRu.mjs +1311 -0
- package/dist/plan-wCnxHqRu.mjs.map +1 -0
- package/dist/solana-sign.d.mts +3 -0
- package/dist/solana-sign.mjs +23 -10
- package/dist/solana-sign.mjs.map +1 -1
- package/dist/solana.d.mts +117 -34
- package/dist/solana.mjs +796 -99
- package/dist/solana.mjs.map +1 -1
- package/dist/src-CHB_z45M.mjs +387 -0
- package/dist/src-CHB_z45M.mjs.map +1 -0
- package/dist/tasks-7AFv3PQn.mjs +86 -0
- package/dist/tasks-7AFv3PQn.mjs.map +1 -0
- package/dist/token-call-DH22g8BL.mjs +914 -0
- package/dist/token-call-DH22g8BL.mjs.map +1 -0
- package/dist/tron-sign.d.mts +10 -0
- package/dist/tron-sign.mjs +36 -0
- package/dist/tron-sign.mjs.map +1 -0
- package/dist/tron.d.mts +328 -0
- package/dist/tron.mjs +1484 -0
- package/dist/tron.mjs.map +1 -0
- package/dist/typed-data-CE9h4U0F.d.mts +51 -0
- package/dist/{typed-data-B4PJ1v8F.mjs → typed-data-DRtKULsH.mjs} +158 -10
- package/dist/typed-data-DRtKULsH.mjs.map +1 -0
- package/package.json +17 -10
- package/dist/index-DpL5hvPl.d.mts +0 -354
- package/dist/message-zf3XHwwc.mjs +0 -188
- package/dist/message-zf3XHwwc.mjs.map +0 -1
- package/dist/src-8NZeEnrW.mjs +0 -67
- package/dist/src-8NZeEnrW.mjs.map +0 -1
- package/dist/typed-data-B4PJ1v8F.mjs.map +0 -1
package/dist/evm.mjs
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as requestBase } from "./account-ref-
|
|
3
|
-
import {
|
|
1
|
+
import { i as messageContent, r as messageBlindReason, s as displayExcerpt, t as ChainError } from "./src-CHB_z45M.mjs";
|
|
2
|
+
import { n as requestBase } from "./account-ref-BFTeEyHt.mjs";
|
|
3
|
+
import { n as evmTokenTable, r as lookupEvmToken, t as EVM_NATIVE_ASSET } from "./assets-sg2_Z3nZ.mjs";
|
|
4
|
+
import { a as decodeZeroX, c as orderAmount, d as PERMIT2_ADDRESS, f as allowanceChange, i as ZEROX_CHAINS, l as MAX_UINT160, n as recognizePermit, o as isZeroExSettler, r as ALLOWANCE_HOLDER, s as ORDER_ITEMS, t as decodeTokenCall, u as MAX_UINT256 } from "./token-call-DH22g8BL.mjs";
|
|
5
|
+
import { C as EVM_DELEGATION_PREFIX, D as checksumEvmAddress, E as encodeBatchExecute, O as evmAddressFromPublicKey, S as quantityBigInt, T as decodeBatchExecute, _ as canonicalHex, b as networkChainId, c as sameFields, d as typedDataFields, f as typedDataHasHiddenText, g as assertHex, h as typedDataUint, i as domainChainId, k as isEvmAddress, l as typedDataAddress, m as typedDataMessages, n as TYPED_FIELD_BUDGET, o as isTypedDataMessage, p as typedDataHashes, r as TYPED_FIELD_CODE_POINTS, s as parseTypedData, t as MAX_UINT48, u as typedDataBytes, v as isCanonicalHex, w as EVM_DELEGATOR, x as normalizeEvmTransaction, y as isRecord } from "./typed-data-DRtKULsH.mjs";
|
|
6
|
+
import { c as evmSigningPreimage, d as fiat24SessionMessage, f as fiat24Spender, l as FIAT24_CHAIN, m as isFiat24Contract, n as planEvm, o as evmAuthorization, p as hasFiat24Selector, s as evmEnvelope, t as assembleEvm, u as decodeFiat24 } from "./assemble-B3sO9Fvc.mjs";
|
|
7
|
+
import { withNativeAmountMeta } from "./networks.mjs";
|
|
8
|
+
import { t as RECOGNISED_FAMILIES } from "./families-BlgplKAJ.mjs";
|
|
4
9
|
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
5
|
-
import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
|
|
10
|
+
import { bytesToHex, hexToBytes, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
6
11
|
import * as AbiFunction from "ox/AbiFunction";
|
|
12
|
+
import * as AbiParameters from "ox/AbiParameters";
|
|
7
13
|
import * as Hex from "ox/Hex";
|
|
8
14
|
import * as TypedData from "ox/TypedData";
|
|
15
|
+
import * as ContractAddress from "ox/ContractAddress";
|
|
9
16
|
import * as Authorization from "ox/Authorization";
|
|
10
17
|
import * as PersonalMessage from "ox/PersonalMessage";
|
|
11
18
|
import * as Secp256k1 from "ox/Secp256k1";
|
|
@@ -14,62 +21,6 @@ import * as TxEnvelopeEip1559 from "ox/TxEnvelopeEip1559";
|
|
|
14
21
|
import * as TxEnvelopeEip2930 from "ox/TxEnvelopeEip2930";
|
|
15
22
|
import * as TxEnvelopeEip7702 from "ox/TxEnvelopeEip7702";
|
|
16
23
|
import * as TxEnvelopeLegacy from "ox/TxEnvelopeLegacy";
|
|
17
|
-
// src/evm/assets.ts
|
|
18
|
-
/** The native asset id in `AssetFlow` and simulated asset changes. */
|
|
19
|
-
const EVM_NATIVE_ASSET = "native";
|
|
20
|
-
// src/evm/tokens.ts
|
|
21
|
-
const USDC = Object.freeze({
|
|
22
|
-
symbol: "USDC",
|
|
23
|
-
decimals: 6,
|
|
24
|
-
name: "USD Coin"
|
|
25
|
-
});
|
|
26
|
-
const USDT = Object.freeze({
|
|
27
|
-
symbol: "USDT",
|
|
28
|
-
decimals: 6,
|
|
29
|
-
name: "Tether USD"
|
|
30
|
-
});
|
|
31
|
-
/** The built-in table. */
|
|
32
|
-
const evmTokenTable = Object.freeze({
|
|
33
|
-
"1": Object.freeze({
|
|
34
|
-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": USDC,
|
|
35
|
-
"0xdAC17F958D2ee523a2206206994597C13D831ec7": USDT
|
|
36
|
-
}),
|
|
37
|
-
"10": Object.freeze({ "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85": USDC }),
|
|
38
|
-
"137": Object.freeze({ "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359": USDC }),
|
|
39
|
-
"999": Object.freeze({ "0xb88339CB7199b77E23DB6E890353E22632Ba630f": USDC }),
|
|
40
|
-
"8453": Object.freeze({ "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": USDC }),
|
|
41
|
-
"42161": Object.freeze({ "0xaf88d065e77c8cC2239327C5EDb3A432268e5831": USDC }),
|
|
42
|
-
"43114": Object.freeze({
|
|
43
|
-
"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E": USDC,
|
|
44
|
-
"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7": USDT
|
|
45
|
-
})
|
|
46
|
-
});
|
|
47
|
-
const lookupEvmToken = (table, chainId, address) => table[String(chainId)]?.[address];
|
|
48
|
-
// src/evm/approval.ts
|
|
49
|
-
const MAX_UINT256 = 2n ** 256n - 1n;
|
|
50
|
-
const MAX_UINT160 = 2n ** 160n - 1n;
|
|
51
|
-
/** The canonical Permit2 deployment (the same address on every supported chain). */
|
|
52
|
-
const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
53
|
-
/** A fungible-token allowance; `max` is the type's maximum, which marks it unlimited. */
|
|
54
|
-
const allowanceChange = (token, spender, value, change, max, chainId, table, extra = {}) => {
|
|
55
|
-
const known = lookupEvmToken(table, chainId, token);
|
|
56
|
-
return {
|
|
57
|
-
kind: "allowance",
|
|
58
|
-
spender,
|
|
59
|
-
amount: {
|
|
60
|
-
asset: token,
|
|
61
|
-
amount: value.toString(10),
|
|
62
|
-
...known === void 0 ? {} : {
|
|
63
|
-
symbol: known.symbol,
|
|
64
|
-
decimals: known.decimals
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
change,
|
|
68
|
-
unlimited: change !== "decrease" && value === max,
|
|
69
|
-
...extra,
|
|
70
|
-
verified: known !== void 0
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
24
|
// src/evm/across.ts
|
|
74
25
|
/**
|
|
75
26
|
* Across SpokePool proxies per origin chain — UUPS upgradeable, so the kernel recognises them by
|
|
@@ -98,94 +49,1426 @@ const ACROSS_WRAPPED_NATIVE = {
|
|
|
98
49
|
43114: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
|
|
99
50
|
11155111: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
|
|
100
51
|
};
|
|
101
|
-
const DEPOSIT = AbiFunction.from("function deposit(bytes32 depositor, bytes32 recipient, bytes32 inputToken, bytes32 outputToken, uint256 inputAmount, uint256 outputAmount, uint256 destinationChainId, bytes32 exclusiveRelayer, uint32 quoteTimestamp, uint32 fillDeadline, uint32 exclusivityParameter, bytes message)");
|
|
102
|
-
const DEPOSIT_V3 = AbiFunction.from("function depositV3(address depositor, address recipient, address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 destinationChainId, address exclusiveRelayer, uint32 quoteTimestamp, uint32 fillDeadline, uint32 exclusivityDeadline, bytes message)");
|
|
103
|
-
/** Canonical-encoding decode like `tryCall` in decode.ts — undefined on any mismatch. */
|
|
104
|
-
const tryCall$
|
|
105
|
-
const selector = AbiFunction.getSelector(fn);
|
|
106
|
-
if (!data.toLowerCase().startsWith(selector)) return;
|
|
52
|
+
const DEPOSIT$1 = AbiFunction.from("function deposit(bytes32 depositor, bytes32 recipient, bytes32 inputToken, bytes32 outputToken, uint256 inputAmount, uint256 outputAmount, uint256 destinationChainId, bytes32 exclusiveRelayer, uint32 quoteTimestamp, uint32 fillDeadline, uint32 exclusivityParameter, bytes message)");
|
|
53
|
+
const DEPOSIT_V3 = AbiFunction.from("function depositV3(address depositor, address recipient, address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 destinationChainId, address exclusiveRelayer, uint32 quoteTimestamp, uint32 fillDeadline, uint32 exclusivityDeadline, bytes message)");
|
|
54
|
+
/** Canonical-encoding decode like `tryCall` in decode.ts — undefined on any mismatch. */
|
|
55
|
+
const tryCall$4 = (fn, data) => {
|
|
56
|
+
const selector = AbiFunction.getSelector(fn);
|
|
57
|
+
if (!data.toLowerCase().startsWith(selector)) return;
|
|
58
|
+
try {
|
|
59
|
+
assertHex(data, "data");
|
|
60
|
+
const args = AbiFunction.decodeData(fn, data);
|
|
61
|
+
if (!Array.isArray(args)) return;
|
|
62
|
+
const reencoded = AbiFunction.encodeData(fn, args).toLowerCase();
|
|
63
|
+
return data.toLowerCase().startsWith(reencoded) ? args : void 0;
|
|
64
|
+
} catch {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/** A bytes32 carrying an EVM address must be left-padded; anything else is a non-EVM target. */
|
|
69
|
+
const paddedAddress$1 = (value) => {
|
|
70
|
+
if (typeof value !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(value)) return;
|
|
71
|
+
if (value.slice(2, 26) !== "000000000000000000000000") return;
|
|
72
|
+
return checksumEvmAddress(`0x${value.slice(26)}`);
|
|
73
|
+
};
|
|
74
|
+
const tokenAmount$1 = (table, chainId, token, amount) => {
|
|
75
|
+
const meta = table === void 0 ? void 0 : lookupEvmToken(table, chainId, token);
|
|
76
|
+
return meta === void 0 ? {
|
|
77
|
+
asset: token,
|
|
78
|
+
amount: amount.toString(10)
|
|
79
|
+
} : {
|
|
80
|
+
asset: token,
|
|
81
|
+
amount: amount.toString(10),
|
|
82
|
+
decimals: meta.decimals,
|
|
83
|
+
symbol: meta.symbol
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const argUint$2 = (args, index) => {
|
|
87
|
+
const v = args[index];
|
|
88
|
+
return typeof v === "bigint" ? v : typeof v === "number" ? BigInt(v) : void 0;
|
|
89
|
+
};
|
|
90
|
+
const argAddress$2 = (args, index) => {
|
|
91
|
+
const v = args[index];
|
|
92
|
+
return typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v) ? checksumEvmAddress(v) : void 0;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Decodes a `deposit`/`depositV3` to the chain's SpokePool — empty `message` only; bytes32 fields
|
|
96
|
+
* must carry left-padded EVM addresses (non-EVM destinations are not recognised). The deposit
|
|
97
|
+
* guarantees `outputAmount` on the destination chain or a refund to `depositor` after
|
|
98
|
+
* `fillDeadline`, so the intent's `minimumReceived` and `bridge` fields carry those terms.
|
|
99
|
+
*/
|
|
100
|
+
const decodeAcross = (chainId, call, table) => {
|
|
101
|
+
const pool = ACROSS_SPOKEPOOLS[chainId];
|
|
102
|
+
if (pool === void 0 || call.to === void 0 || call.to.toLowerCase() !== pool.toLowerCase()) return;
|
|
103
|
+
const v4 = tryCall$4(DEPOSIT$1, call.data);
|
|
104
|
+
const v3 = v4 === void 0 ? tryCall$4(DEPOSIT_V3, call.data) : void 0;
|
|
105
|
+
if (v4 === void 0 && v3 === void 0) return;
|
|
106
|
+
const args = v4 ?? v3 ?? [];
|
|
107
|
+
const [depositor, recipient, inputToken, outputToken] = [
|
|
108
|
+
0,
|
|
109
|
+
1,
|
|
110
|
+
2,
|
|
111
|
+
3
|
|
112
|
+
].map((i) => v4 === void 0 ? argAddress$2(args, i) : paddedAddress$1(args[i]));
|
|
113
|
+
if (depositor === void 0 || recipient === void 0 || inputToken === void 0 || outputToken === void 0) return;
|
|
114
|
+
const inputAmount = argUint$2(args, 4);
|
|
115
|
+
const outputAmount = argUint$2(args, 5);
|
|
116
|
+
const destinationChainId = argUint$2(args, 6);
|
|
117
|
+
const fillDeadline = argUint$2(args, 9);
|
|
118
|
+
const message = args.at(11);
|
|
119
|
+
if (inputAmount === void 0 || outputAmount === void 0 || destinationChainId === void 0 || fillDeadline === void 0 || message !== "0x") return;
|
|
120
|
+
const native = call.value > 0n && inputToken.toLowerCase() === (ACROSS_WRAPPED_NATIVE[chainId] ?? "").toLowerCase();
|
|
121
|
+
if (call.value > 0n && (!native || call.value !== inputAmount)) return;
|
|
122
|
+
return {
|
|
123
|
+
outflows: [{
|
|
124
|
+
to: pool,
|
|
125
|
+
amount: native ? {
|
|
126
|
+
asset: EVM_NATIVE_ASSET,
|
|
127
|
+
amount: call.value.toString(10)
|
|
128
|
+
} : tokenAmount$1(table, chainId, inputToken, inputAmount),
|
|
129
|
+
verified: true
|
|
130
|
+
}],
|
|
131
|
+
minimumReceived: [{
|
|
132
|
+
to: recipient,
|
|
133
|
+
amount: tokenAmount$1(table, Number(destinationChainId), outputToken, outputAmount),
|
|
134
|
+
verified: true
|
|
135
|
+
}],
|
|
136
|
+
bridge: {
|
|
137
|
+
destinationNetwork: `eip155:${destinationChainId.toString(10)}`,
|
|
138
|
+
fillDeadline: Number(fillDeadline),
|
|
139
|
+
refundTo: depositor
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
// src/evm/hyperliquid.ts
|
|
144
|
+
/**
|
|
145
|
+
* Recognition of Hyperliquid user-signed actions: EIP-712 documents under the
|
|
146
|
+
* `HyperliquidSignTransaction` domain (version "1", zero verifying contract) whose only struct is
|
|
147
|
+
* one `HyperliquidTransaction:<X>` type with exactly the field list nktkas's `<X>Types` constants
|
|
148
|
+
* declare (`src/api/exchange/_methods/*.ts` in @nktkas/hyperliquid 0.33.3; python `signing.py`'s
|
|
149
|
+
* `*_SIGN_TYPES` agree). Every signed field must parse strictly, else the document is left
|
|
150
|
+
* unclaimed and the family table blinds it as `typed-data-variant`.
|
|
151
|
+
*
|
|
152
|
+
* The user-signed types left unclaimed on purpose — all blind `typed-data-variant` via the
|
|
153
|
+
* "Hyperliquid" family row:
|
|
154
|
+
*
|
|
155
|
+
* - `ConvertToMultiSigUser` — hands account authority to a signer set given as JSON text (nktkas
|
|
156
|
+
* convertToMultiSigUser.ts:124)
|
|
157
|
+
* - `LinkStakingUser` (linkStakingUser.ts:106) and `StakingLinkDisableTradingUser`
|
|
158
|
+
* (stakingLinkDisableTradingUser.ts:105) — rebind trading authority to another address
|
|
159
|
+
* - `SendToEvmWithData` — carries an arbitrary `data` call (sendToEvmWithData.ts:110)
|
|
160
|
+
* - `UserDexAbstraction` (userDexAbstraction.ts:100), `UserPortfolioMargin`
|
|
161
|
+
* (userPortfolioMargin.ts:98) and `UserSetAbstraction` (userSetAbstraction.ts:101) — change how
|
|
162
|
+
* the account's orders and transfers are routed
|
|
163
|
+
* - `SendMultiSig` — the envelope signs only a bytes32 hash of the real action (python signing.py
|
|
164
|
+
* `MULTI_SIG_ENVELOPE_SIGN_TYPES`), the same commitment problem as L1
|
|
165
|
+
* - Any type with `payloadMultiSigUser`/`outerSigner` injected for inner multi-sig signatures — the
|
|
166
|
+
* field-list check fails (nktkas _userSigned.ts `signUserSignedInner`)
|
|
167
|
+
*
|
|
168
|
+
* The L1 trading actions are not user-signed data: they sign `Agent{source,connectionId}` under the
|
|
169
|
+
* `Exchange` domain where `connectionId` is a keccak of the msgpack action (nktkas _l1.ts) — a
|
|
170
|
+
* commitment no prompt can bound, blind `typed-data-commitment` via the "Hyperliquid L1" row.
|
|
171
|
+
*/
|
|
172
|
+
const ZERO_ADDRESS$1 = "0x0000000000000000000000000000000000000000";
|
|
173
|
+
const MAX_UINT64 = 2n ** 64n - 1n;
|
|
174
|
+
const EIP712_DOMAIN$1 = [
|
|
175
|
+
"string name",
|
|
176
|
+
"string version",
|
|
177
|
+
"uint256 chainId",
|
|
178
|
+
"address verifyingContract"
|
|
179
|
+
];
|
|
180
|
+
const PREFIX = "HyperliquidTransaction:";
|
|
181
|
+
const AMOUNT = /^[0-9]{1,15}(\.[0-9]{1,8})?$/;
|
|
182
|
+
const STRING_ADDRESS = /^0x[0-9a-f]{40}$/;
|
|
183
|
+
const TOKEN = /^[A-Za-z0-9]{1,16}:0x[0-9a-f]{32}$/;
|
|
184
|
+
const DEX_NAME = /^[A-Za-z0-9]{0,16}$/;
|
|
185
|
+
const FEE_RATE = /^[0-9]{1,3}(\.[0-9]{1,6})?%$/;
|
|
186
|
+
const AGENT_EXPIRY = / valid_until (\d{1,16})$/;
|
|
187
|
+
const amount$1 = (value) => typeof value === "string" && AMOUNT.test(value) ? value : void 0;
|
|
188
|
+
const stringAddress = (value) => typeof value === "string" && STRING_ADDRESS.test(value) ? checksumEvmAddress(value) : void 0;
|
|
189
|
+
const token = (value) => typeof value === "string" && TOKEN.test(value) ? value : void 0;
|
|
190
|
+
const dexName = (value) => typeof value === "string" && DEX_NAME.test(value) ? value : void 0;
|
|
191
|
+
const uint64 = (value) => typedDataUint(value, MAX_UINT64);
|
|
192
|
+
const boolean = (value) => typeof value === "boolean" ? value : void 0;
|
|
193
|
+
/**
|
|
194
|
+
* The agent name with its ` valid_until <ms>` suffix split off. The base must fit on one safe line
|
|
195
|
+
* — it is shown verbatim — at most 16 code points (the exchange's limit), free of unsafe code
|
|
196
|
+
* points and without "valid_until" inside it; `""` is a valid unnamed agent.
|
|
197
|
+
*/
|
|
198
|
+
const agentName = (value) => {
|
|
199
|
+
if (typeof value !== "string") return;
|
|
200
|
+
const expiry = AGENT_EXPIRY.exec(value);
|
|
201
|
+
const base = expiry === null ? value : value.slice(0, expiry.index);
|
|
202
|
+
const excerpt = displayExcerpt(base, 1, 16);
|
|
203
|
+
if (excerpt.omitted !== 0 || (excerpt.lines[0] ?? "") !== base || base.includes("valid_until")) return;
|
|
204
|
+
if (expiry === null) return { name: base };
|
|
205
|
+
const validUntil = Number(expiry[1]);
|
|
206
|
+
return validUntil <= Number.MAX_SAFE_INTEGER ? {
|
|
207
|
+
name: base,
|
|
208
|
+
validUntil
|
|
209
|
+
} : void 0;
|
|
210
|
+
};
|
|
211
|
+
const transferFields = (chain, message, kind) => {
|
|
212
|
+
const destination = stringAddress(message["destination"]);
|
|
213
|
+
const value = amount$1(message["amount"]);
|
|
214
|
+
return destination === void 0 || value === void 0 || uint64(message["time"]) === void 0 ? void 0 : {
|
|
215
|
+
kind,
|
|
216
|
+
chain,
|
|
217
|
+
destination,
|
|
218
|
+
amount: value
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
const stakingFields = (chain, message, kind) => {
|
|
222
|
+
const wei = uint64(message["wei"]);
|
|
223
|
+
return wei === void 0 || uint64(message["nonce"]) === void 0 ? void 0 : {
|
|
224
|
+
kind,
|
|
225
|
+
chain,
|
|
226
|
+
wei: wei.toString(10)
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
const DESCRIBED = [
|
|
230
|
+
{
|
|
231
|
+
suffix: "UsdSend",
|
|
232
|
+
fields: [
|
|
233
|
+
"string hyperliquidChain",
|
|
234
|
+
"string destination",
|
|
235
|
+
"string amount",
|
|
236
|
+
"uint64 time"
|
|
237
|
+
],
|
|
238
|
+
summary: "transfer",
|
|
239
|
+
verifiability: "full",
|
|
240
|
+
build: (chain, message) => transferFields(chain, message, "usd-send")
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
suffix: "Withdraw",
|
|
244
|
+
fields: [
|
|
245
|
+
"string hyperliquidChain",
|
|
246
|
+
"string destination",
|
|
247
|
+
"string amount",
|
|
248
|
+
"uint64 time"
|
|
249
|
+
],
|
|
250
|
+
summary: "transfer",
|
|
251
|
+
verifiability: "partial",
|
|
252
|
+
build: (chain, message) => transferFields(chain, message, "withdraw")
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
suffix: "SpotSend",
|
|
256
|
+
fields: [
|
|
257
|
+
"string hyperliquidChain",
|
|
258
|
+
"string destination",
|
|
259
|
+
"string token",
|
|
260
|
+
"string amount",
|
|
261
|
+
"uint64 time"
|
|
262
|
+
],
|
|
263
|
+
summary: "transfer",
|
|
264
|
+
verifiability: "partial",
|
|
265
|
+
build: (chain, message) => {
|
|
266
|
+
const destination = stringAddress(message["destination"]);
|
|
267
|
+
const asset = token(message["token"]);
|
|
268
|
+
const value = amount$1(message["amount"]);
|
|
269
|
+
return destination === void 0 || asset === void 0 || value === void 0 || uint64(message["time"]) === void 0 ? void 0 : {
|
|
270
|
+
kind: "spot-send",
|
|
271
|
+
chain,
|
|
272
|
+
destination,
|
|
273
|
+
token: asset,
|
|
274
|
+
amount: value
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
suffix: "UsdClassTransfer",
|
|
280
|
+
fields: [
|
|
281
|
+
"string hyperliquidChain",
|
|
282
|
+
"string amount",
|
|
283
|
+
"bool toPerp",
|
|
284
|
+
"uint64 nonce"
|
|
285
|
+
],
|
|
286
|
+
summary: "transfer",
|
|
287
|
+
verifiability: "full",
|
|
288
|
+
build: (chain, message) => {
|
|
289
|
+
const value = amount$1(message["amount"]);
|
|
290
|
+
const toPerp = boolean(message["toPerp"]);
|
|
291
|
+
return value === void 0 || toPerp === void 0 || uint64(message["nonce"]) === void 0 ? void 0 : {
|
|
292
|
+
kind: "usd-class-transfer",
|
|
293
|
+
chain,
|
|
294
|
+
amount: value,
|
|
295
|
+
toPerp
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
suffix: "SendAsset",
|
|
301
|
+
fields: [
|
|
302
|
+
"string hyperliquidChain",
|
|
303
|
+
"string destination",
|
|
304
|
+
"string sourceDex",
|
|
305
|
+
"string destinationDex",
|
|
306
|
+
"string token",
|
|
307
|
+
"string amount",
|
|
308
|
+
"string fromSubAccount",
|
|
309
|
+
"uint64 nonce"
|
|
310
|
+
],
|
|
311
|
+
summary: "transfer",
|
|
312
|
+
verifiability: "partial",
|
|
313
|
+
build: (chain, message) => {
|
|
314
|
+
const destination = stringAddress(message["destination"]);
|
|
315
|
+
const sourceDex = dexName(message["sourceDex"]);
|
|
316
|
+
const destinationDex = dexName(message["destinationDex"]);
|
|
317
|
+
const asset = token(message["token"]);
|
|
318
|
+
const value = amount$1(message["amount"]);
|
|
319
|
+
const subAccount = message["fromSubAccount"];
|
|
320
|
+
const fromSubAccount = subAccount === "" ? "" : stringAddress(subAccount);
|
|
321
|
+
return destination === void 0 || sourceDex === void 0 || destinationDex === void 0 || asset === void 0 || value === void 0 || fromSubAccount === void 0 || uint64(message["nonce"]) === void 0 ? void 0 : {
|
|
322
|
+
kind: "send-asset",
|
|
323
|
+
chain,
|
|
324
|
+
destination,
|
|
325
|
+
sourceDex,
|
|
326
|
+
destinationDex,
|
|
327
|
+
token: asset,
|
|
328
|
+
amount: value,
|
|
329
|
+
...fromSubAccount === "" ? {} : { fromSubAccount }
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
suffix: "CDeposit",
|
|
335
|
+
fields: [
|
|
336
|
+
"string hyperliquidChain",
|
|
337
|
+
"uint64 wei",
|
|
338
|
+
"uint64 nonce"
|
|
339
|
+
],
|
|
340
|
+
summary: "stake",
|
|
341
|
+
verifiability: "full",
|
|
342
|
+
build: (chain, message) => stakingFields(chain, message, "staking-deposit")
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
suffix: "CWithdraw",
|
|
346
|
+
fields: [
|
|
347
|
+
"string hyperliquidChain",
|
|
348
|
+
"uint64 wei",
|
|
349
|
+
"uint64 nonce"
|
|
350
|
+
],
|
|
351
|
+
summary: "stake",
|
|
352
|
+
verifiability: "full",
|
|
353
|
+
build: (chain, message) => stakingFields(chain, message, "staking-withdraw")
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
suffix: "TokenDelegate",
|
|
357
|
+
fields: [
|
|
358
|
+
"string hyperliquidChain",
|
|
359
|
+
"address validator",
|
|
360
|
+
"uint64 wei",
|
|
361
|
+
"bool isUndelegate",
|
|
362
|
+
"uint64 nonce"
|
|
363
|
+
],
|
|
364
|
+
summary: "stake",
|
|
365
|
+
verifiability: "partial",
|
|
366
|
+
build: (chain, message) => {
|
|
367
|
+
const validator = typedDataAddress(message["validator"]);
|
|
368
|
+
const wei = uint64(message["wei"]);
|
|
369
|
+
const undelegate = boolean(message["isUndelegate"]);
|
|
370
|
+
return validator === void 0 || wei === void 0 || undelegate === void 0 || uint64(message["nonce"]) === void 0 ? void 0 : {
|
|
371
|
+
kind: "token-delegate",
|
|
372
|
+
chain,
|
|
373
|
+
validator,
|
|
374
|
+
wei: wei.toString(10),
|
|
375
|
+
undelegate
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
suffix: "ApproveAgent",
|
|
381
|
+
fields: [
|
|
382
|
+
"string hyperliquidChain",
|
|
383
|
+
"address agentAddress",
|
|
384
|
+
"string agentName",
|
|
385
|
+
"uint64 nonce"
|
|
386
|
+
],
|
|
387
|
+
summary: "approve",
|
|
388
|
+
verifiability: "partial",
|
|
389
|
+
build: (chain, message) => {
|
|
390
|
+
const agent = typedDataAddress(message["agentAddress"]);
|
|
391
|
+
const name = agentName(message["agentName"]);
|
|
392
|
+
return agent === void 0 || name === void 0 || uint64(message["nonce"]) === void 0 ? void 0 : {
|
|
393
|
+
kind: "approve-agent",
|
|
394
|
+
chain,
|
|
395
|
+
agent,
|
|
396
|
+
name: name.name,
|
|
397
|
+
...name.validUntil === void 0 ? {} : { validUntil: name.validUntil }
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
suffix: "ApproveBuilderFee",
|
|
403
|
+
fields: [
|
|
404
|
+
"string hyperliquidChain",
|
|
405
|
+
"string maxFeeRate",
|
|
406
|
+
"address builder",
|
|
407
|
+
"uint64 nonce"
|
|
408
|
+
],
|
|
409
|
+
summary: "approve",
|
|
410
|
+
verifiability: "partial",
|
|
411
|
+
build: (chain, message) => {
|
|
412
|
+
const { maxFeeRate } = message;
|
|
413
|
+
const builder = typedDataAddress(message["builder"]);
|
|
414
|
+
return typeof maxFeeRate !== "string" || !FEE_RATE.test(maxFeeRate) || builder === void 0 || uint64(message["nonce"]) === void 0 ? void 0 : {
|
|
415
|
+
kind: "approve-builder-fee",
|
|
416
|
+
chain,
|
|
417
|
+
builder,
|
|
418
|
+
maxFeeRate
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
];
|
|
423
|
+
/**
|
|
424
|
+
* The Hyperliquid user-signed action a typed-data document signs, or `undefined` when the document
|
|
425
|
+
* is not exactly the described shape — every extra type, renamed or reordered field and unparsable
|
|
426
|
+
* value rejects the whole document, so what is described is exactly what is hashed. Message keys
|
|
427
|
+
* the type does not declare (the SDKs' `type`, `signatureChainId`) are not signed and are ignored
|
|
428
|
+
* here.
|
|
429
|
+
*/
|
|
430
|
+
function recognizeHyperliquid(json) {
|
|
431
|
+
const { types, primaryType, domain, message } = json;
|
|
432
|
+
if (domain["name"] !== "HyperliquidSignTransaction" || domain["version"] !== "1" || domainChainId(domain) === void 0 || typedDataAddress(domain["verifyingContract"])?.toLowerCase() !== ZERO_ADDRESS$1 || !sameFields(types, "EIP712Domain", EIP712_DOMAIN$1) || Object.keys(types).length !== 2 || types[primaryType] === void 0 || !primaryType.startsWith(PREFIX)) return;
|
|
433
|
+
const described = DESCRIBED.find((entry) => entry.suffix === primaryType.slice(23));
|
|
434
|
+
const chain = message["hyperliquidChain"];
|
|
435
|
+
if (described === void 0 || !sameFields(types, primaryType, described.fields) || chain !== "Mainnet" && chain !== "Testnet") return;
|
|
436
|
+
const action = described.build(chain, message);
|
|
437
|
+
return action === void 0 ? void 0 : {
|
|
438
|
+
action,
|
|
439
|
+
summary: described.summary,
|
|
440
|
+
verifiability: described.verifiability
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
// src/evm/polymarket.ts
|
|
444
|
+
const MAX_UINT256$1 = 2n ** 256n - 1n;
|
|
445
|
+
const ZERO_BYTES32 = `0x${"0".repeat(64)}`;
|
|
446
|
+
const EXCHANGES = [
|
|
447
|
+
{
|
|
448
|
+
chainId: 137,
|
|
449
|
+
address: "0xE111180000d2663C0091e4f400237545B87B996B",
|
|
450
|
+
version: "2",
|
|
451
|
+
name: "CTF Exchange",
|
|
452
|
+
outcomeToken: "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
chainId: 137,
|
|
456
|
+
address: "0xe2222d279d744050d28e00520010520000310F59",
|
|
457
|
+
version: "2",
|
|
458
|
+
name: "Neg Risk CTF Exchange",
|
|
459
|
+
outcomeToken: "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
chainId: 137,
|
|
463
|
+
address: "0xe3333700cA9d93003F00f0F71f8515005F6c00Aa",
|
|
464
|
+
version: "3",
|
|
465
|
+
name: "Exchange V3",
|
|
466
|
+
outcomeToken: "0x006F54F7f9A22e0000CC2AB60031000000ae9fEF"
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
chainId: 80002,
|
|
470
|
+
address: "0xE111180000d2663C0091e4f400237545B87B996B",
|
|
471
|
+
version: "2",
|
|
472
|
+
name: "CTF Exchange",
|
|
473
|
+
outcomeToken: "0x69308FB512518e39F9b16112fA8d994F4e2Bf8bB"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
chainId: 80002,
|
|
477
|
+
address: "0xe2222d279d744050d28e00520010520000310F59",
|
|
478
|
+
version: "2",
|
|
479
|
+
name: "Neg Risk CTF Exchange",
|
|
480
|
+
outcomeToken: "0x69308FB512518e39F9b16112fA8d994F4e2Bf8bB"
|
|
481
|
+
}
|
|
482
|
+
];
|
|
483
|
+
const PUSD = "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB";
|
|
484
|
+
const DECIMALS = 6;
|
|
485
|
+
const EIP712_DOMAIN = [
|
|
486
|
+
"string name",
|
|
487
|
+
"string version",
|
|
488
|
+
"uint256 chainId",
|
|
489
|
+
"address verifyingContract"
|
|
490
|
+
];
|
|
491
|
+
const EIP712_DOMAIN_AUTH = [
|
|
492
|
+
"string name",
|
|
493
|
+
"string version",
|
|
494
|
+
"uint256 chainId"
|
|
495
|
+
];
|
|
496
|
+
const ORDER_FIELDS$2 = [
|
|
497
|
+
"uint256 salt",
|
|
498
|
+
"address maker",
|
|
499
|
+
"address signer",
|
|
500
|
+
"uint256 tokenId",
|
|
501
|
+
"uint256 makerAmount",
|
|
502
|
+
"uint256 takerAmount",
|
|
503
|
+
"uint8 side",
|
|
504
|
+
"uint8 signatureType",
|
|
505
|
+
"uint256 timestamp",
|
|
506
|
+
"bytes32 metadata",
|
|
507
|
+
"bytes32 builder"
|
|
508
|
+
];
|
|
509
|
+
const TYPED_DATA_SIGN_FIELDS = [
|
|
510
|
+
"Order contents",
|
|
511
|
+
"string name",
|
|
512
|
+
"string version",
|
|
513
|
+
"uint256 chainId",
|
|
514
|
+
"address verifyingContract",
|
|
515
|
+
"bytes32 salt"
|
|
516
|
+
];
|
|
517
|
+
const CLOB_AUTH_FIELDS = [
|
|
518
|
+
"address address",
|
|
519
|
+
"string timestamp",
|
|
520
|
+
"uint256 nonce",
|
|
521
|
+
"string message"
|
|
522
|
+
];
|
|
523
|
+
const BATCH_FIELDS = [
|
|
524
|
+
"address wallet",
|
|
525
|
+
"uint256 nonce",
|
|
526
|
+
"uint256 deadline",
|
|
527
|
+
"Call[] calls"
|
|
528
|
+
];
|
|
529
|
+
const CALL_FIELDS = [
|
|
530
|
+
"address target",
|
|
531
|
+
"uint256 value",
|
|
532
|
+
"bytes data"
|
|
533
|
+
];
|
|
534
|
+
const CLOB_AUTH_MESSAGE = "This message attests that I control the given wallet";
|
|
535
|
+
const BATCH_CALLS_MAX = 8;
|
|
536
|
+
const BYTES32 = /^0x[0-9a-fA-F]{64}$/;
|
|
537
|
+
const bytes32 = (value) => typeof value === "string" && BYTES32.test(value) ? value.toLowerCase() : void 0;
|
|
538
|
+
const nonZero = (hex) => hex === ZERO_BYTES32 ? void 0 : hex;
|
|
539
|
+
const uint = (value) => typedDataUint(value, MAX_UINT256$1);
|
|
540
|
+
const sameAddress = (a, b) => a !== void 0 && b !== void 0 && a.toLowerCase() === b.toLowerCase();
|
|
541
|
+
/** The strict parse both `Order` and `TypedDataSign.contents` share. */
|
|
542
|
+
const orderValues = (message) => {
|
|
543
|
+
const maker = typedDataAddress(message["maker"]);
|
|
544
|
+
const signer = typedDataAddress(message["signer"]);
|
|
545
|
+
const tokenId = uint(message["tokenId"]);
|
|
546
|
+
const makerAmount = uint(message["makerAmount"]);
|
|
547
|
+
const takerAmount = uint(message["takerAmount"]);
|
|
548
|
+
const side = uint(message["side"]);
|
|
549
|
+
const signatureType = uint(message["signatureType"]);
|
|
550
|
+
const metadata = bytes32(message["metadata"]);
|
|
551
|
+
const builder = bytes32(message["builder"]);
|
|
552
|
+
if (maker === void 0 || signer === void 0 || tokenId === void 0 || makerAmount === void 0 || makerAmount === 0n || takerAmount === void 0 || takerAmount === 0n || side === void 0 || side > 1n || signatureType === void 0 || signatureType > 3n || uint(message["salt"]) === void 0 || uint(message["timestamp"]) === void 0 || metadata === void 0 || builder === void 0) return;
|
|
553
|
+
const meta = nonZero(metadata);
|
|
554
|
+
const code = nonZero(builder);
|
|
555
|
+
return {
|
|
556
|
+
maker,
|
|
557
|
+
signer,
|
|
558
|
+
tokenId: tokenId.toString(10),
|
|
559
|
+
side: side === 0n ? "buy" : "sell",
|
|
560
|
+
signatureType,
|
|
561
|
+
makerAmount,
|
|
562
|
+
takerAmount,
|
|
563
|
+
...meta === void 0 ? {} : { metadata: meta },
|
|
564
|
+
...code === void 0 ? {} : { builder: code }
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
const orderContent = (order, exchange, wallet) => {
|
|
568
|
+
const buy = order.side === "buy";
|
|
569
|
+
const pusd = {
|
|
570
|
+
asset: PUSD,
|
|
571
|
+
decimals: DECIMALS,
|
|
572
|
+
symbol: "pUSD"
|
|
573
|
+
};
|
|
574
|
+
const shares = {
|
|
575
|
+
asset: exchange.outcomeToken,
|
|
576
|
+
decimals: DECIMALS,
|
|
577
|
+
tokenId: order.tokenId
|
|
578
|
+
};
|
|
579
|
+
const give = buy ? {
|
|
580
|
+
...pusd,
|
|
581
|
+
amount: order.makerAmount.toString(10)
|
|
582
|
+
} : {
|
|
583
|
+
...shares,
|
|
584
|
+
amount: order.makerAmount.toString(10)
|
|
585
|
+
};
|
|
586
|
+
const receive = buy ? {
|
|
587
|
+
...shares,
|
|
588
|
+
amount: order.takerAmount.toString(10)
|
|
589
|
+
} : {
|
|
590
|
+
...pusd,
|
|
591
|
+
amount: order.takerAmount.toString(10)
|
|
592
|
+
};
|
|
593
|
+
const collateral = buy ? order.makerAmount : order.takerAmount;
|
|
594
|
+
const amount = buy ? order.takerAmount : order.makerAmount;
|
|
595
|
+
const price = collateral * 10n ** BigInt(DECIMALS) / amount;
|
|
596
|
+
return {
|
|
597
|
+
kind: "order",
|
|
598
|
+
exchange: {
|
|
599
|
+
address: exchange.address,
|
|
600
|
+
name: exchange.name,
|
|
601
|
+
version: exchange.version
|
|
602
|
+
},
|
|
603
|
+
side: order.side,
|
|
604
|
+
tokenId: order.tokenId,
|
|
605
|
+
maker: order.maker,
|
|
606
|
+
signer: order.signer,
|
|
607
|
+
wallet,
|
|
608
|
+
give,
|
|
609
|
+
receive,
|
|
610
|
+
price: {
|
|
611
|
+
amount: price.toString(10),
|
|
612
|
+
exact: price * amount === collateral * 10n ** BigInt(DECIMALS)
|
|
613
|
+
},
|
|
614
|
+
...order.builder === void 0 ? {} : { builder: order.builder },
|
|
615
|
+
...order.metadata === void 0 ? {} : { metadata: order.metadata }
|
|
616
|
+
};
|
|
617
|
+
};
|
|
618
|
+
/** The "Polymarket CTF Exchange" domain against the exchange allow-list. */
|
|
619
|
+
const exchangeDomain = (json) => {
|
|
620
|
+
const { domain, types } = json;
|
|
621
|
+
const chainId = domainChainId(domain);
|
|
622
|
+
if (domain["name"] !== "Polymarket CTF Exchange" || chainId === void 0 || !sameFields(types, "EIP712Domain", EIP712_DOMAIN)) return;
|
|
623
|
+
const verifying = typedDataAddress(domain["verifyingContract"]);
|
|
624
|
+
return EXCHANGES.find((row) => row.chainId === chainId && row.address.toLowerCase() === verifying?.toLowerCase() && row.version === domain["version"]);
|
|
625
|
+
};
|
|
626
|
+
const typeSet = (types, names) => Object.keys(types).length === names.length && names.every((name) => types[name] !== void 0);
|
|
627
|
+
const orderResult = (json, exchange, context) => {
|
|
628
|
+
if (json.primaryType !== "Order" || !typeSet(json.types, ["EIP712Domain", "Order"]) || !sameFields(json.types, "Order", ORDER_FIELDS$2)) return;
|
|
629
|
+
const order = orderValues(json.message);
|
|
630
|
+
if (order === void 0 || order.signatureType > 2n || !sameAddress(order.signer, context.signer) || order.signatureType === 0n && !sameAddress(order.maker, order.signer)) return;
|
|
631
|
+
const wallet = order.signatureType === 0n ? "account" : order.signatureType === 1n ? "proxy" : "safe";
|
|
632
|
+
const content = orderContent(order, exchange, wallet);
|
|
633
|
+
return {
|
|
634
|
+
content: { polymarket: content },
|
|
635
|
+
summary: "swap",
|
|
636
|
+
outflows: [{
|
|
637
|
+
to: exchange.address,
|
|
638
|
+
amount: content.give,
|
|
639
|
+
verified: content.give.asset === PUSD
|
|
640
|
+
}],
|
|
641
|
+
approvals: [],
|
|
642
|
+
verifiability: "partial"
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
const typedDataSignResult = (json, exchange) => {
|
|
646
|
+
if (json.primaryType !== "TypedDataSign" || !typeSet(json.types, [
|
|
647
|
+
"EIP712Domain",
|
|
648
|
+
"TypedDataSign",
|
|
649
|
+
"Order"
|
|
650
|
+
]) || !sameFields(json.types, "TypedDataSign", TYPED_DATA_SIGN_FIELDS) || !sameFields(json.types, "Order", ORDER_FIELDS$2)) return;
|
|
651
|
+
const { message } = json;
|
|
652
|
+
const wallet = typedDataAddress(message["verifyingContract"]);
|
|
653
|
+
const { contents } = message;
|
|
654
|
+
if (message["name"] !== "DepositWallet" || message["version"] !== "1" || wallet === void 0 || message["salt"] !== ZERO_BYTES32 || uint(message["chainId"]) !== BigInt(exchange.chainId) || !isTypedDataMessage(contents)) return;
|
|
655
|
+
const order = orderValues(contents);
|
|
656
|
+
if (order === void 0 || order.signatureType !== 3n || !sameAddress(order.signer, wallet) || !sameAddress(order.maker, wallet)) return;
|
|
657
|
+
const content = orderContent(order, exchange, "deposit-wallet");
|
|
658
|
+
return {
|
|
659
|
+
content: { polymarket: content },
|
|
660
|
+
summary: "swap",
|
|
661
|
+
outflows: [{
|
|
662
|
+
to: exchange.address,
|
|
663
|
+
amount: content.give,
|
|
664
|
+
verified: content.give.asset === PUSD
|
|
665
|
+
}],
|
|
666
|
+
approvals: [],
|
|
667
|
+
verifiability: "partial"
|
|
668
|
+
};
|
|
669
|
+
};
|
|
670
|
+
const clobAuthResult = (json, context) => {
|
|
671
|
+
const { types, domain, message } = json;
|
|
672
|
+
const chainId = domainChainId(domain);
|
|
673
|
+
if (json.primaryType !== "ClobAuth" || domain["name"] !== "ClobAuthDomain" || domain["version"] !== "1" || chainId !== 137 && chainId !== 80002 || !sameFields(types, "EIP712Domain", EIP712_DOMAIN_AUTH) || !typeSet(types, ["EIP712Domain", "ClobAuth"]) || !sameFields(types, "ClobAuth", CLOB_AUTH_FIELDS)) return;
|
|
674
|
+
const address = typedDataAddress(message["address"]);
|
|
675
|
+
const { timestamp } = message;
|
|
676
|
+
const nonce = uint(message["nonce"]);
|
|
677
|
+
if (address === void 0 || !sameAddress(address, context.signer) || message["message"] !== CLOB_AUTH_MESSAGE || typeof timestamp !== "string" || !/^[0-9]{1,12}$/.test(timestamp) || nonce === void 0) return;
|
|
678
|
+
return {
|
|
679
|
+
content: { polymarket: {
|
|
680
|
+
kind: "auth",
|
|
681
|
+
address,
|
|
682
|
+
timestamp: Number(timestamp),
|
|
683
|
+
nonce: nonce.toString(10)
|
|
684
|
+
} },
|
|
685
|
+
summary: "message",
|
|
686
|
+
outflows: [],
|
|
687
|
+
approvals: [],
|
|
688
|
+
verifiability: "partial"
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
const batchResult = (json, decodeCall) => {
|
|
692
|
+
const { types, domain, message } = json;
|
|
693
|
+
const chainId = domainChainId(domain);
|
|
694
|
+
const wallet = typedDataAddress(domain["verifyingContract"]);
|
|
695
|
+
if (json.primaryType !== "Batch" || domain["name"] !== "DepositWallet" || domain["version"] !== "1" || chainId !== 137 && chainId !== 80002 || wallet === void 0 || !sameFields(types, "EIP712Domain", EIP712_DOMAIN) || !typeSet(types, [
|
|
696
|
+
"EIP712Domain",
|
|
697
|
+
"Batch",
|
|
698
|
+
"Call"
|
|
699
|
+
]) || !sameFields(types, "Batch", BATCH_FIELDS) || !sameFields(types, "Call", CALL_FIELDS) || !sameAddress(typedDataAddress(message["wallet"]), wallet)) return;
|
|
700
|
+
const nonce = uint(message["nonce"]);
|
|
701
|
+
const deadline = typedDataUint(message["deadline"], MAX_UINT48);
|
|
702
|
+
const calls = typedDataMessages(message["calls"]);
|
|
703
|
+
if (nonce === void 0 || deadline === void 0 || calls === void 0 || calls.length === 0) return;
|
|
704
|
+
const batch = (decoded, blind) => ({
|
|
705
|
+
content: { polymarket: {
|
|
706
|
+
kind: "batch",
|
|
707
|
+
wallet,
|
|
708
|
+
nonce: nonce.toString(10),
|
|
709
|
+
deadline: Number(deadline),
|
|
710
|
+
calls: decoded
|
|
711
|
+
} },
|
|
712
|
+
summary: "batch",
|
|
713
|
+
outflows: decoded.flatMap((call) => call.outflows),
|
|
714
|
+
approvals: decoded.flatMap((call) => call.approvals),
|
|
715
|
+
verifiability: decoded.length === 0 || decoded.some((call) => call.verifiability === "opaque") ? "opaque" : decoded.some((call) => call.verifiability === "partial") ? "partial" : "full",
|
|
716
|
+
...blind === void 0 ? {} : { blind }
|
|
717
|
+
});
|
|
718
|
+
if (calls.length > BATCH_CALLS_MAX) return batch([], "typed-data-oversize");
|
|
719
|
+
const decoded = [];
|
|
720
|
+
for (const call of calls) {
|
|
721
|
+
const target = typedDataAddress(call["target"]);
|
|
722
|
+
const value = uint(call["value"]);
|
|
723
|
+
const data = typedDataBytes(call["data"]);
|
|
724
|
+
if (target === void 0 || value === void 0 || data === void 0) return;
|
|
725
|
+
decoded.push(decodeCall({
|
|
726
|
+
to: target,
|
|
727
|
+
value,
|
|
728
|
+
data
|
|
729
|
+
}, wallet));
|
|
730
|
+
}
|
|
731
|
+
return batch(decoded, decoded.find((call) => call.blind !== void 0)?.blind);
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* The Polymarket request a typed-data document signs, or `undefined` when the document is not one
|
|
735
|
+
* of the described shapes — the family rows then make it blind `typed-data-variant`.
|
|
736
|
+
*/
|
|
737
|
+
function recognizePolymarket(json, context, decodeCall) {
|
|
738
|
+
if (json.primaryType === "ClobAuth") return clobAuthResult(json, context);
|
|
739
|
+
if (json.primaryType === "Batch") return batchResult(json, decodeCall);
|
|
740
|
+
const exchange = exchangeDomain(json);
|
|
741
|
+
if (exchange === void 0) return;
|
|
742
|
+
return json.primaryType === "TypedDataSign" ? typedDataSignResult(json, exchange) : orderResult(json, exchange, context);
|
|
743
|
+
}
|
|
744
|
+
// src/evm/apps.ts
|
|
745
|
+
const recognizeApp = (json, context, decodeCall) => {
|
|
746
|
+
const hyperliquid = recognizeHyperliquid(json);
|
|
747
|
+
if (hyperliquid !== void 0) return {
|
|
748
|
+
content: { hyperliquid: hyperliquid.action },
|
|
749
|
+
summary: hyperliquid.summary,
|
|
750
|
+
outflows: [],
|
|
751
|
+
approvals: [],
|
|
752
|
+
warnings: [],
|
|
753
|
+
verifiability: hyperliquid.verifiability
|
|
754
|
+
};
|
|
755
|
+
const polymarket = recognizePolymarket(json, context, decodeCall);
|
|
756
|
+
return polymarket === void 0 ? void 0 : {
|
|
757
|
+
content: polymarket.content,
|
|
758
|
+
summary: polymarket.summary,
|
|
759
|
+
outflows: polymarket.outflows,
|
|
760
|
+
approvals: polymarket.approvals,
|
|
761
|
+
warnings: [],
|
|
762
|
+
verifiability: polymarket.verifiability,
|
|
763
|
+
...polymarket.blind === void 0 ? {} : { blind: polymarket.blind }
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
// src/evm/authority.ts
|
|
767
|
+
/**
|
|
768
|
+
* Recognition of account-authority documents — Morpho Blue `Authorization` and Aave v3
|
|
769
|
+
* `DelegationWithSig` — typed data that hands someone else power over the signer's account.
|
|
770
|
+
*
|
|
771
|
+
* Morpho Blue (morpho-org/morpho-blue@339a885 `src/libraries/ConstantsLib.sol`:
|
|
772
|
+
* `Authorization(address authorizer,address authorized,bool isAuthorized,uint256 nonce,uint256
|
|
773
|
+
* deadline)` under `EIP712Domain(uint256 chainId,address verifyingContract)`): `Morpho.sol`'s
|
|
774
|
+
* `setAuthorizationWithSig` recovers the signatory with ecrecover and requires
|
|
775
|
+
* `authorization.authorizer == signatory`, so the decoder requires `authorizer` to be the signer;
|
|
776
|
+
* an authorized account can withdraw, borrow and withdrawCollateral on the signer's behalf with an
|
|
777
|
+
* arbitrary receiver. The document decodes on ANY verifyingContract — the `verified` flag tells the
|
|
778
|
+
* prompt whether it is a deployment of the table below.
|
|
779
|
+
*
|
|
780
|
+
* Aave v3 (aave-dao/aave-v3-origin@8305565 `DebtTokenBase.sol`: `DelegationWithSig(address
|
|
781
|
+
* delegatee,uint256 value,uint256 nonce,uint256 deadline)` under the four-field domain at version
|
|
782
|
+
* `"1"`): `delegationWithSig` recovers the delegator from the signature — the signer is the
|
|
783
|
+
* delegator by construction — and sets `_borrowAllowances[delegator][delegatee] = value`. A
|
|
784
|
+
* variable-debt token of the table below is verified and its amount displayed in the underlying
|
|
785
|
+
* asset's units; any other contract is unverified and the amount stays raw.
|
|
786
|
+
*/
|
|
787
|
+
const MORPHO_BLUE = {
|
|
788
|
+
"1": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
789
|
+
"10": "0xce95AfbB8EA029495c66020883F87aaE8864AF92",
|
|
790
|
+
"14": "0xF4346F5132e810f80a28487a79c7559d9797E8B0",
|
|
791
|
+
"25": "0xDF9a1DC07e5dEe5ccCCaBeC35e446C70fAF7434e",
|
|
792
|
+
"56": "0x01b0Bd309AA75547f7a37Ad7B1219A898E67a83a",
|
|
793
|
+
"100": "0xB74D4dd451E250bC325AFF0556D717e4E2351c66",
|
|
794
|
+
"130": "0x8f5ae9CddB9f68de460C77730b018Ae7E04a140A",
|
|
795
|
+
"137": "0x1bF0c2541F820E775182832f06c0B7Fc27A25f67",
|
|
796
|
+
"143": "0xD5D960E8C380B724a48AC59E2DfF1b2CB4a1eAee",
|
|
797
|
+
"146": "0xd6c916eB7542D0Ad3f18AEd0FCBD50C582cfa95f",
|
|
798
|
+
"196": "0xeb00C490E888286357dC5B0a35D37D9260D11Ab5",
|
|
799
|
+
"252": "0xa6030627d724bA78a59aCf43Be7550b4C5a0653b",
|
|
800
|
+
"480": "0xE741BC7c34758b4caE05062794E8Ae24978AF432",
|
|
801
|
+
"999": "0x68e37dE8d93d3496ae143F2E900490f6280C57cD",
|
|
802
|
+
"1329": "0xc9cDAc20FCeAAF616f7EB0bb6Cd2c69dcfa9094c",
|
|
803
|
+
"1672": "0x18573fA18fd17dDfD790B4a5B5b2977aad3b4Efb",
|
|
804
|
+
"1868": "0xE75Fc5eA6e74B824954349Ca351eb4e671ADA53a",
|
|
805
|
+
"43114": "0x895383274303AA19fe978AFB4Ac55C7f094f982C",
|
|
806
|
+
"42220": "0xd24ECdD8C1e0E57a4E26B1a7bbeAa3e95466A569",
|
|
807
|
+
"4326": "0x18120312A7cf44DcfEc6dCe5632a431579ED9100",
|
|
808
|
+
"8453": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
809
|
+
"9745": "0x2fF74A46536f5c67ef5A42FD5B4e2Ed8A2cee249",
|
|
810
|
+
"57073": "0x857f3EefE8cbda3Bc49367C996cd664A880d3042",
|
|
811
|
+
"59144": "0x6B0D716aC0A45536172308e08fC2C40387262c9F",
|
|
812
|
+
"747474": "0xD50F2DffFd62f94Ee4AEd9ca05C61d0753268aBc",
|
|
813
|
+
"534352": "0x2d012EdbAdc37eDc2BC62791B666f9193FDF5a55",
|
|
814
|
+
"84532": "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb",
|
|
815
|
+
"11155111": "0xd011EE229E7459ba1ddd22631eF7bF528d424A14"
|
|
816
|
+
};
|
|
817
|
+
const AAVE_DEBT_TOKENS = {
|
|
818
|
+
"1": {
|
|
819
|
+
"0xeA51d7853EEFb32b6ee06b1C12E6dcCA88Be0fFE": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
820
|
+
"0x72E95b8931767C79bA4EeE721354d6E99a61D004": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
821
|
+
"0x6df1C1E379bC5a00a7b4C6e67A203333772f45A8": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
822
|
+
"0x9355032d747f1e08F8720CD01950E652eE15cdB7": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
823
|
+
"0x4139EcBe83d78ef5EFF0A6eDA6f894Be9D590FC7": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
824
|
+
"0x91b7d78BF92db564221f6B5AeE744D1727d1Dd1e": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
825
|
+
"0xeD90dE2D824Ee766c6Fd22E90b12e598f681dc9F": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
|
826
|
+
},
|
|
827
|
+
"10": {
|
|
828
|
+
"0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351": "0x4200000000000000000000000000000000000006",
|
|
829
|
+
"0x5D557B07776D12967914379C71a1310e917C7555": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"
|
|
830
|
+
},
|
|
831
|
+
"56": { "0x0E76414d433ddfe8004d2A7505d218874875a996": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" },
|
|
832
|
+
"137": {
|
|
833
|
+
"0x4a1c3aD6Ed28a636ee1751C69071f6be75DEb8B8": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
834
|
+
"0xE701126012EC0290822eEA17B794454d1AF8b030": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
|
|
835
|
+
},
|
|
836
|
+
"143": { "0x9F555aB84C4e0a531B50283f09Dba7A97134c4e4": "0x754704Bc059F8C67012fEd69BC8A327a5aafb603" },
|
|
837
|
+
"146": {
|
|
838
|
+
"0x2273caBAd63b7D247A6b107E723c803fc49953A0": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
|
|
839
|
+
"0xF6089B790Fbf8F4812a79a31CFAbeB00B06BA7BD": "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"
|
|
840
|
+
},
|
|
841
|
+
"196": { "0x585Eb919387F82bc9B2B440C4F3D8615B079465A": "0xB6CEceAB302E2E4948951eE7843FC24E92933061" },
|
|
842
|
+
"324": { "0x0049250D15A8550c5a14Baa5AF5B662a93a525B9": "0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4" },
|
|
843
|
+
"4326": { "0x09ADCCC7AF2aBD356c18A4CadF2e5cC250f300E9": "0x4200000000000000000000000000000000000006" },
|
|
844
|
+
"1868": { "0xC52375A5A04C0ABe5a6Ca5F3a344be2415EF54dB": "0x4200000000000000000000000000000000000006" },
|
|
845
|
+
"8453": {
|
|
846
|
+
"0x24e6e0795b3c7c71D965fCc4f371803d1c1DcA1E": "0x4200000000000000000000000000000000000006",
|
|
847
|
+
"0x59dca05b6c26dbd64b5381374aAaC5CD05644C28": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
848
|
+
},
|
|
849
|
+
"42161": {
|
|
850
|
+
"0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
851
|
+
"0xf611aEb5013fD2c0511c9CD55c7dc5C1140741A6": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
|
|
852
|
+
},
|
|
853
|
+
"42220": {
|
|
854
|
+
"0xDbe517c0FA6467873B684eCcbED77217E471E862": "0xcebA9300f2b948710d2653dD7B07f33A8B32118C",
|
|
855
|
+
"0xE15324a9887999803b931Ac45aa89a94A9750052": "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",
|
|
856
|
+
"0xaEa37B42955De2Ba2E4AF6581E46349bCD3Ea2d6": "0x471EcE3750Da237f93B8E339c536989b8978a438"
|
|
857
|
+
},
|
|
858
|
+
"43114": {
|
|
859
|
+
"0xFCCf3cAbbe80101232d343252614b6A3eE81C989": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
860
|
+
"0xfb00AC187a8Eb5AFAE4eACE434F493Eb62672df7": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
|
|
861
|
+
"0x4a1c3aD6Ed28a636ee1751C69071f6be75DEb8B8": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"
|
|
862
|
+
},
|
|
863
|
+
"57073": {
|
|
864
|
+
"0xc1457AcfBaD2332b07B7651A4Da3176E8F3Bc9E4": "0x4200000000000000000000000000000000000006",
|
|
865
|
+
"0x305c03f74DBb8C6052b7667AaBEE21dC7c1f0B29": "0x2D270e6886d130D724215A266106e6832161EAEd"
|
|
866
|
+
},
|
|
867
|
+
"59144": { "0x63aB166e6E1b6Fb705b6ca23686FaD9705EB3534": "0x176211869cA2b568f2A7D4EE941E073a821EE1ff" },
|
|
868
|
+
"534352": { "0xfD7344CeB1Df9Cf238EcD667f4A6F99c6Ef44a56": "0x5300000000000000000000000000000000000004" }
|
|
869
|
+
};
|
|
870
|
+
/** `address` is the Morpho Blue deployment of `chainId` (the `morpho-blue` family claim). */
|
|
871
|
+
const isMorphoBlue = (chainId, address) => MORPHO_BLUE[String(chainId)]?.toLowerCase() === address.toLowerCase();
|
|
872
|
+
const MORPHO_DOMAIN = ["uint256 chainId", "address verifyingContract"];
|
|
873
|
+
const MORPHO_FIELDS = [
|
|
874
|
+
"address authorizer",
|
|
875
|
+
"address authorized",
|
|
876
|
+
"bool isAuthorized",
|
|
877
|
+
"uint256 nonce",
|
|
878
|
+
"uint256 deadline"
|
|
879
|
+
];
|
|
880
|
+
const AAVE_DOMAIN = [
|
|
881
|
+
"string name",
|
|
882
|
+
"string version",
|
|
883
|
+
"uint256 chainId",
|
|
884
|
+
"address verifyingContract"
|
|
885
|
+
];
|
|
886
|
+
const AAVE_FIELDS = [
|
|
887
|
+
"address delegatee",
|
|
888
|
+
"uint256 value",
|
|
889
|
+
"uint256 nonce",
|
|
890
|
+
"uint256 deadline"
|
|
891
|
+
];
|
|
892
|
+
const parseUint$1 = (value) => typedDataUint(value, MAX_UINT256);
|
|
893
|
+
const result$1 = (authority) => ({
|
|
894
|
+
content: { authority },
|
|
895
|
+
summary: "authorization",
|
|
896
|
+
outflows: [],
|
|
897
|
+
verifiability: "partial"
|
|
898
|
+
});
|
|
899
|
+
/**
|
|
900
|
+
* The authority the document grants, or `undefined` when the shape is not exactly a Morpho Blue
|
|
901
|
+
* `Authorization` bound to the signer or an Aave `DelegationWithSig` on `chainId`.
|
|
902
|
+
*/
|
|
903
|
+
function recognizeAuthority(json, chainId, table, signer) {
|
|
904
|
+
const { types, primaryType, message, domain } = json;
|
|
905
|
+
if (Object.keys(types).length !== 2 || domainChainId(domain) !== chainId) return;
|
|
906
|
+
const contract = typedDataAddress(domain["verifyingContract"]);
|
|
907
|
+
if (contract === void 0) return;
|
|
908
|
+
if (primaryType === "Authorization") {
|
|
909
|
+
if (!sameFields(types, "EIP712Domain", MORPHO_DOMAIN) || !sameFields(types, "Authorization", MORPHO_FIELDS)) return;
|
|
910
|
+
const authorizer = typedDataAddress(message["authorizer"]);
|
|
911
|
+
const authorized = typedDataAddress(message["authorized"]);
|
|
912
|
+
const { isAuthorized } = message;
|
|
913
|
+
const nonce = parseUint$1(message["nonce"]);
|
|
914
|
+
const deadline = parseUint$1(message["deadline"]);
|
|
915
|
+
if (authorizer === void 0 || authorizer.toLowerCase() !== signer.toLowerCase() || authorized === void 0 || typeof isAuthorized !== "boolean" || nonce === void 0 || deadline === void 0) return;
|
|
916
|
+
return result$1({
|
|
917
|
+
kind: "morpho",
|
|
918
|
+
contract,
|
|
919
|
+
verified: isMorphoBlue(chainId, contract),
|
|
920
|
+
authorized,
|
|
921
|
+
grant: isAuthorized,
|
|
922
|
+
...deadline <= MAX_UINT48 ? { deadline: Number(deadline) } : {}
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
if (primaryType === "DelegationWithSig") {
|
|
926
|
+
if (!sameFields(types, "EIP712Domain", AAVE_DOMAIN) || !sameFields(types, "DelegationWithSig", AAVE_FIELDS) || typeof domain["name"] !== "string" || domain["version"] !== "1") return;
|
|
927
|
+
const delegatee = typedDataAddress(message["delegatee"]);
|
|
928
|
+
const value = parseUint$1(message["value"]);
|
|
929
|
+
const nonce = parseUint$1(message["nonce"]);
|
|
930
|
+
const deadline = parseUint$1(message["deadline"]);
|
|
931
|
+
if (delegatee === void 0 || value === void 0 || nonce === void 0 || deadline === void 0) return;
|
|
932
|
+
const underlying = AAVE_DEBT_TOKENS[String(chainId)]?.[contract];
|
|
933
|
+
const listed = underlying === void 0 ? void 0 : lookupEvmToken(table, chainId, underlying);
|
|
934
|
+
const amount = underlying === void 0 ? {
|
|
935
|
+
asset: contract,
|
|
936
|
+
amount: value.toString()
|
|
937
|
+
} : {
|
|
938
|
+
asset: underlying,
|
|
939
|
+
amount: value.toString(),
|
|
940
|
+
...listed === void 0 ? {} : {
|
|
941
|
+
symbol: listed.symbol,
|
|
942
|
+
decimals: listed.decimals
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
return result$1({
|
|
946
|
+
kind: "aave-credit",
|
|
947
|
+
contract,
|
|
948
|
+
verified: underlying !== void 0,
|
|
949
|
+
delegatee,
|
|
950
|
+
amount,
|
|
951
|
+
unlimited: value === MAX_UINT256,
|
|
952
|
+
...deadline <= MAX_UINT48 ? { deadline: Number(deadline) } : {}
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
// src/evm/cctp.ts
|
|
957
|
+
/**
|
|
958
|
+
* CCTP TokenMessengerV2 `depositForBurnWithHook` deposits USDC into Hyperliquid via Circle's
|
|
959
|
+
* CctpForwarder on HyperEVM (destination domain 19). Only the Hyperliquid route is described — a
|
|
960
|
+
* call to the messenger on these chains that does not match it exactly is blind
|
|
961
|
+
* (`cctp-destination`): an unrecognised hook could send the burn anywhere.
|
|
962
|
+
*
|
|
963
|
+
* Verified on chain 2026-11-21 (code present).
|
|
964
|
+
*/
|
|
965
|
+
const CCTP_MESSENGERS = {
|
|
966
|
+
42161: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
967
|
+
421614: "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA"
|
|
968
|
+
};
|
|
969
|
+
const CCTP_USDC = {
|
|
970
|
+
42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
971
|
+
421614: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"
|
|
972
|
+
};
|
|
973
|
+
/** Circle's CctpForwarder on HyperEVM (999 mainnet, 998 testnet) — the mint recipient on domain 19. */
|
|
974
|
+
const CCTP_FORWARDERS = {
|
|
975
|
+
42161: "0xb21D281DEdb17AE5B501F6AA8256fe38C4e45757",
|
|
976
|
+
421614: "0x02e39ECb8368b41bF68FF99ff351aC9864e5E2a2"
|
|
977
|
+
};
|
|
978
|
+
const HYPERLIQUID_DOMAIN = 19;
|
|
979
|
+
const DEPOSIT_WITH_HOOK = AbiFunction.from("function depositForBurnWithHook(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold, bytes hookData)");
|
|
980
|
+
/** `call.to` is this chain's TokenMessengerV2 — the call is CCTP territory, described or blind. */
|
|
981
|
+
const isCctpMessenger = (chainId, to) => to !== void 0 && to.toLowerCase() === CCTP_MESSENGERS[chainId]?.toLowerCase();
|
|
982
|
+
/** Strict canonical decode — unlike Across, no calldata suffix is tolerated. */
|
|
983
|
+
const tryCall$3 = (fn, data) => {
|
|
984
|
+
if (!data.toLowerCase().startsWith(AbiFunction.getSelector(fn))) return;
|
|
985
|
+
try {
|
|
986
|
+
assertHex(data, "data");
|
|
987
|
+
const args = AbiFunction.decodeData(fn, data);
|
|
988
|
+
if (!Array.isArray(args)) return;
|
|
989
|
+
return AbiFunction.encodeData(fn, args).toLowerCase() === data.toLowerCase() ? args : void 0;
|
|
990
|
+
} catch {
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
const paddedAddress = (value) => {
|
|
995
|
+
if (typeof value !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(value)) return;
|
|
996
|
+
if (value.slice(2, 26) !== "000000000000000000000000") return;
|
|
997
|
+
return checksumEvmAddress(`0x${value.slice(26)}`);
|
|
998
|
+
};
|
|
999
|
+
const FORWARD_PREFIX_HEX = "636374702d666f7277617264";
|
|
1000
|
+
/** The 56-byte Hyperliquid forward hook: tag, zeros, version 0, length 24, recipient, dex. */
|
|
1001
|
+
const decodeHook = (value, from) => {
|
|
1002
|
+
if (typeof value !== "string" || !/^0x[0-9a-fA-F]{112}$/.test(value)) return;
|
|
1003
|
+
const hex = value.slice(2);
|
|
1004
|
+
if (!hex.startsWith(FORWARD_PREFIX_HEX)) return;
|
|
1005
|
+
if (hex.slice(24, 48) !== "000000000000000000000000") return;
|
|
1006
|
+
if (hex.slice(48, 56) !== "00000000" || hex.slice(56, 64) !== "00000018") return;
|
|
1007
|
+
const recipient = checksumEvmAddress(`0x${hex.slice(64, 104)}`);
|
|
1008
|
+
if (recipient.toLowerCase() !== from.toLowerCase()) return;
|
|
1009
|
+
const dex = hex.slice(104, 112);
|
|
1010
|
+
if (dex !== "00000000" && dex !== "ffffffff") return;
|
|
1011
|
+
return {
|
|
1012
|
+
recipient,
|
|
1013
|
+
dex: dex === "00000000" ? "perps" : "spot"
|
|
1014
|
+
};
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* A fully described Hyperliquid deposit: the burn is bounded by `amount` USDC to this chain's
|
|
1018
|
+
* verified TokenMessengerV2, routed to the forwarder on domain 19, and the hook commits the
|
|
1019
|
+
* depositor's own address plus a perps/spot dex and a `maxFee` strictly below the amount.
|
|
1020
|
+
*/
|
|
1021
|
+
const decodeCctp = (chainId, call, from, table) => {
|
|
1022
|
+
const messenger = CCTP_MESSENGERS[chainId];
|
|
1023
|
+
const usdc = CCTP_USDC[chainId];
|
|
1024
|
+
const forwarder = CCTP_FORWARDERS[chainId];
|
|
1025
|
+
if (messenger === void 0 || usdc === void 0 || forwarder === void 0 || !isCctpMessenger(chainId, call.to) || call.value !== 0n) return;
|
|
1026
|
+
const args = tryCall$3(DEPOSIT_WITH_HOOK, call.data);
|
|
1027
|
+
if (args === void 0) return;
|
|
1028
|
+
const [amount, domain, mintRecipient, burnToken, destinationCaller, maxFee] = args;
|
|
1029
|
+
const burn = typeof burnToken === "string" && /^0x[0-9a-fA-F]{40}$/.test(burnToken) ? checksumEvmAddress(burnToken) : void 0;
|
|
1030
|
+
if (typeof amount !== "bigint" || typeof maxFee !== "bigint" || domain !== 19 || burn === void 0 || burn.toLowerCase() !== usdc.toLowerCase() || paddedAddress(mintRecipient)?.toLowerCase() !== forwarder.toLowerCase() || paddedAddress(destinationCaller)?.toLowerCase() !== forwarder.toLowerCase() || maxFee <= 0n || maxFee >= amount) return;
|
|
1031
|
+
const hook = decodeHook(args.at(7), from);
|
|
1032
|
+
if (hook === void 0) return;
|
|
1033
|
+
const meta = table === void 0 ? void 0 : lookupEvmToken(table, chainId, usdc);
|
|
1034
|
+
const amountOf = (v) => meta === void 0 ? {
|
|
1035
|
+
asset: usdc,
|
|
1036
|
+
amount: v.toString(10)
|
|
1037
|
+
} : {
|
|
1038
|
+
asset: usdc,
|
|
1039
|
+
amount: v.toString(10),
|
|
1040
|
+
decimals: meta.decimals,
|
|
1041
|
+
symbol: meta.symbol
|
|
1042
|
+
};
|
|
1043
|
+
return {
|
|
1044
|
+
outflows: [{
|
|
1045
|
+
to: messenger,
|
|
1046
|
+
amount: amountOf(amount),
|
|
1047
|
+
verified: true
|
|
1048
|
+
}],
|
|
1049
|
+
hyperliquidDeposit: {
|
|
1050
|
+
recipient: hook.recipient,
|
|
1051
|
+
dex: hook.dex,
|
|
1052
|
+
maxFee: amountOf(maxFee)
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* The chains the settlement's `domainSeparator()` was verified on
|
|
1058
|
+
* (vectors/chains/order-protocols.json).
|
|
1059
|
+
*/
|
|
1060
|
+
const GPV2_CHAINS = /* @__PURE__ */ new Set([
|
|
1061
|
+
1,
|
|
1062
|
+
10,
|
|
1063
|
+
56,
|
|
1064
|
+
100,
|
|
1065
|
+
130,
|
|
1066
|
+
137,
|
|
1067
|
+
143,
|
|
1068
|
+
5e3,
|
|
1069
|
+
8453,
|
|
1070
|
+
9745,
|
|
1071
|
+
42161,
|
|
1072
|
+
43114,
|
|
1073
|
+
59144
|
|
1074
|
+
]);
|
|
1075
|
+
/** `Order`'s field list, verbatim from `GPv2Order.sol`'s TYPE_HASH comment. */
|
|
1076
|
+
const ORDER_FIELDS$1 = [
|
|
1077
|
+
"address sellToken",
|
|
1078
|
+
"address buyToken",
|
|
1079
|
+
"address receiver",
|
|
1080
|
+
"uint256 sellAmount",
|
|
1081
|
+
"uint256 buyAmount",
|
|
1082
|
+
"uint32 validTo",
|
|
1083
|
+
"bytes32 appData",
|
|
1084
|
+
"uint256 feeAmount",
|
|
1085
|
+
"string kind",
|
|
1086
|
+
"bool partiallyFillable",
|
|
1087
|
+
"string sellTokenBalance",
|
|
1088
|
+
"string buyTokenBalance"
|
|
1089
|
+
];
|
|
1090
|
+
const ZERO$2 = "0x0000000000000000000000000000000000000000";
|
|
1091
|
+
const BUY_ETH = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
1092
|
+
const KINDS = /* @__PURE__ */ new Set(["sell", "buy"]);
|
|
1093
|
+
const SELL_BALANCES = /* @__PURE__ */ new Set([
|
|
1094
|
+
"erc20",
|
|
1095
|
+
"external",
|
|
1096
|
+
"internal"
|
|
1097
|
+
]);
|
|
1098
|
+
const BUY_BALANCES = /* @__PURE__ */ new Set(["erc20", "internal"]);
|
|
1099
|
+
/** The order under the exact GPv2 signing domain, or `undefined` — a near miss of the claim. */
|
|
1100
|
+
const recognizeCow = (json, chainId, signer, table) => {
|
|
1101
|
+
const { domain, types, primaryType, message } = json;
|
|
1102
|
+
const verifying = typedDataAddress(domain["verifyingContract"]);
|
|
1103
|
+
if (domain["name"] !== "Gnosis Protocol" || domain["version"] !== "v2" || domainChainId(domain) !== chainId || verifying === void 0 || verifying.toLowerCase() !== "0x9008d19f58aabd9ed0d60971565aa8510560ab41" || !GPV2_CHAINS.has(chainId) || primaryType !== "Order" || Object.keys(types).length !== 2 || !sameFields(types, "EIP712Domain", [
|
|
1104
|
+
"string name",
|
|
1105
|
+
"string version",
|
|
1106
|
+
"uint256 chainId",
|
|
1107
|
+
"address verifyingContract"
|
|
1108
|
+
]) || !sameFields(types, "Order", ORDER_FIELDS$1) || typeof message["kind"] !== "string" || !KINDS.has(message["kind"]) || typeof message["sellTokenBalance"] !== "string" || !SELL_BALANCES.has(message["sellTokenBalance"]) || typeof message["buyTokenBalance"] !== "string" || !BUY_BALANCES.has(message["buyTokenBalance"]) || typeof message["partiallyFillable"] !== "boolean") return;
|
|
1109
|
+
const sellToken = typedDataAddress(message["sellToken"]);
|
|
1110
|
+
const buyToken = typedDataAddress(message["buyToken"]);
|
|
1111
|
+
const receiver = typedDataAddress(message["receiver"]);
|
|
1112
|
+
const sellAmount = typedDataUint(message["sellAmount"], MAX_UINT256);
|
|
1113
|
+
const buyAmount = typedDataUint(message["buyAmount"], MAX_UINT256);
|
|
1114
|
+
const feeAmount = typedDataUint(message["feeAmount"], MAX_UINT256);
|
|
1115
|
+
const validTo = typedDataUint(message["validTo"], 2n ** 32n - 1n);
|
|
1116
|
+
if (sellToken === void 0 || buyToken === void 0 || sellToken.toLowerCase() === ZERO$2 || sellToken.toLowerCase() === BUY_ETH || buyToken.toLowerCase() === ZERO$2 || receiver === void 0 || sellAmount === void 0 || buyAmount === void 0 || feeAmount === void 0 || validTo === void 0 || sellAmount + feeAmount > MAX_UINT256) return;
|
|
1117
|
+
return {
|
|
1118
|
+
protocol: "cow",
|
|
1119
|
+
maker: checksumEvmAddress(signer),
|
|
1120
|
+
give: orderAmount(sellToken, sellAmount + feeAmount, chainId, table),
|
|
1121
|
+
receive: [{
|
|
1122
|
+
recipient: receiver.toLowerCase() === ZERO$2 ? checksumEvmAddress(signer) : receiver,
|
|
1123
|
+
amount: orderAmount(buyToken, buyAmount, chainId, table, BUY_ETH)
|
|
1124
|
+
}],
|
|
1125
|
+
expiry: Number(validTo),
|
|
1126
|
+
partialFill: message["partiallyFillable"]
|
|
1127
|
+
};
|
|
1128
|
+
};
|
|
1129
|
+
// src/evm/eip3009.ts
|
|
1130
|
+
/**
|
|
1131
|
+
* Recognition of EIP-3009 authorizations — `TransferWithAuthorization`, `ReceiveWithAuthorization`
|
|
1132
|
+
* and `CancelAuthorization` as emitted by FiatToken (circlefin/stablecoin-evm@fc85788
|
|
1133
|
+
* `contracts/v2/EIP3009.sol`: the three TYPEHASH field lists).
|
|
1134
|
+
*
|
|
1135
|
+
* Binding rules beyond the field list: `types` is exactly `EIP712Domain` plus the one primary type,
|
|
1136
|
+
* the domain carries a `verifyingContract` (the token itself) and a `chainId` equal to the request
|
|
1137
|
+
* network's, and `from`/`authorizer` is the signer — FiatToken v2.2 checks the authorization with
|
|
1138
|
+
* `SignatureChecker.isValidSignatureNow(from, …)`, so a `from` that is an ERC-1271 contract wallet
|
|
1139
|
+
* could spend that contract's funds on this EOA's signature; anything else is a near miss
|
|
1140
|
+
* (`typed-data-variant`).
|
|
1141
|
+
*
|
|
1142
|
+
* `nonce` is a bytes32 one-time id the family owns — not a commitment, and not shown (the ERC-7730
|
|
1143
|
+
* registry descriptor marks it `visible: never`) except on `CancelAuthorization`, where it names
|
|
1144
|
+
* the authorization being cancelled.
|
|
1145
|
+
*/
|
|
1146
|
+
const TRANSFER_FIELDS = [
|
|
1147
|
+
"address from",
|
|
1148
|
+
"address to",
|
|
1149
|
+
"uint256 value",
|
|
1150
|
+
"uint256 validAfter",
|
|
1151
|
+
"uint256 validBefore",
|
|
1152
|
+
"bytes32 nonce"
|
|
1153
|
+
];
|
|
1154
|
+
const CANCEL_FIELDS = ["address authorizer", "bytes32 nonce"];
|
|
1155
|
+
const MAX_UINT48_SECONDS = 2n ** 48n;
|
|
1156
|
+
/**
|
|
1157
|
+
* The authorization the document grants, or `undefined` when the shape is not exactly one of the
|
|
1158
|
+
* FiatToken EIP-3009 primary types bound to the signer on `chainId`.
|
|
1159
|
+
*/
|
|
1160
|
+
function recognizeEip3009(json, chainId, table, signer) {
|
|
1161
|
+
const { types, primaryType, message, domain } = json;
|
|
1162
|
+
if (Object.keys(types).length !== 2 || domainChainId(domain) !== chainId) return;
|
|
1163
|
+
const token = typedDataAddress(domain["verifyingContract"]);
|
|
1164
|
+
if (token === void 0) return;
|
|
1165
|
+
const listed = lookupEvmToken(table, chainId, token);
|
|
1166
|
+
const amount = (value) => listed === void 0 ? {
|
|
1167
|
+
asset: token,
|
|
1168
|
+
amount: value.toString()
|
|
1169
|
+
} : {
|
|
1170
|
+
asset: token,
|
|
1171
|
+
amount: value.toString(),
|
|
1172
|
+
symbol: listed.symbol,
|
|
1173
|
+
decimals: listed.decimals
|
|
1174
|
+
};
|
|
1175
|
+
const isSigner = (candidate) => candidate !== void 0 && candidate.toLowerCase() === signer.toLowerCase();
|
|
1176
|
+
if (primaryType === "TransferWithAuthorization" || primaryType === "ReceiveWithAuthorization") {
|
|
1177
|
+
if (!sameFields(types, primaryType, TRANSFER_FIELDS)) return;
|
|
1178
|
+
const from = typedDataAddress(message["from"]);
|
|
1179
|
+
const to = typedDataAddress(message["to"]);
|
|
1180
|
+
const value = typedDataUint(message["value"], MAX_UINT256);
|
|
1181
|
+
const validAfter = typedDataUint(message["validAfter"], MAX_UINT256);
|
|
1182
|
+
const validBefore = typedDataUint(message["validBefore"], MAX_UINT256);
|
|
1183
|
+
const nonce = typedDataBytes(message["nonce"]);
|
|
1184
|
+
if (!isSigner(from) || to === void 0 || value === void 0 || validAfter === void 0 || validAfter >= MAX_UINT48_SECONDS || validBefore === void 0 || nonce === void 0 || nonce.length !== 66) return;
|
|
1185
|
+
return {
|
|
1186
|
+
content: { authorization: {
|
|
1187
|
+
kind: primaryType === "TransferWithAuthorization" ? "transfer" : "receive",
|
|
1188
|
+
to,
|
|
1189
|
+
amount: amount(value),
|
|
1190
|
+
validAfter: Number(validAfter),
|
|
1191
|
+
...validBefore < MAX_UINT48_SECONDS ? { validBefore: Number(validBefore) } : {}
|
|
1192
|
+
} },
|
|
1193
|
+
summary: "transfer",
|
|
1194
|
+
outflows: [{
|
|
1195
|
+
to,
|
|
1196
|
+
amount: amount(value),
|
|
1197
|
+
verified: listed !== void 0
|
|
1198
|
+
}],
|
|
1199
|
+
verifiability: listed === void 0 ? "partial" : "full"
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
if (primaryType === "CancelAuthorization") {
|
|
1203
|
+
if (!sameFields(types, primaryType, CANCEL_FIELDS)) return;
|
|
1204
|
+
const authorizer = typedDataAddress(message["authorizer"]);
|
|
1205
|
+
const nonce = typedDataBytes(message["nonce"]);
|
|
1206
|
+
if (!isSigner(authorizer) || nonce === void 0 || nonce.length !== 66) return;
|
|
1207
|
+
return {
|
|
1208
|
+
content: { authorization: {
|
|
1209
|
+
kind: "cancel",
|
|
1210
|
+
token,
|
|
1211
|
+
nonce: nonce.toLowerCase()
|
|
1212
|
+
} },
|
|
1213
|
+
summary: "message",
|
|
1214
|
+
outflows: [],
|
|
1215
|
+
verifiability: "full"
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
// src/evm/seaport.ts
|
|
1220
|
+
/** Seaport 1.5 and 1.6 deployments, lowercase for a checksum-insensitive compare. */
|
|
1221
|
+
const SEAPORT_CONTRACTS = /* @__PURE__ */ new Set(["0x0000000000000068f116a894984e2db1123eb395", "0x00000000000000adc04c56bf30ac9d3c0aaf14dc"]);
|
|
1222
|
+
/** Seaport `itemType` values 0–5; an item type outside the list is not recognized. */
|
|
1223
|
+
const ITEM_KINDS = [
|
|
1224
|
+
"native",
|
|
1225
|
+
"erc20",
|
|
1226
|
+
"erc721",
|
|
1227
|
+
"erc1155",
|
|
1228
|
+
"erc721-criteria",
|
|
1229
|
+
"erc1155-criteria"
|
|
1230
|
+
];
|
|
1231
|
+
const ITEM_FIELDS = [
|
|
1232
|
+
"uint8 itemType",
|
|
1233
|
+
"address token",
|
|
1234
|
+
"uint256 identifierOrCriteria",
|
|
1235
|
+
"uint256 startAmount",
|
|
1236
|
+
"uint256 endAmount"
|
|
1237
|
+
];
|
|
1238
|
+
const typesMatch = (types) => Object.keys(types).filter((name) => name !== "EIP712Domain").length === 3 && sameFields(types, "OrderComponents", [
|
|
1239
|
+
"address offerer",
|
|
1240
|
+
"address zone",
|
|
1241
|
+
"OfferItem[] offer",
|
|
1242
|
+
"ConsiderationItem[] consideration",
|
|
1243
|
+
"uint8 orderType",
|
|
1244
|
+
"uint256 startTime",
|
|
1245
|
+
"uint256 endTime",
|
|
1246
|
+
"bytes32 zoneHash",
|
|
1247
|
+
"uint256 salt",
|
|
1248
|
+
"bytes32 conduitKey",
|
|
1249
|
+
"uint256 counter"
|
|
1250
|
+
]) && sameFields(types, "OfferItem", ITEM_FIELDS) && sameFields(types, "ConsiderationItem", [...ITEM_FIELDS, "address recipient"]);
|
|
1251
|
+
const amount = (kind, token, value, identifier, chainId, table) => {
|
|
1252
|
+
if (kind === "native") return {
|
|
1253
|
+
asset: EVM_NATIVE_ASSET,
|
|
1254
|
+
amount: value.toString(10)
|
|
1255
|
+
};
|
|
1256
|
+
if (kind === "erc20") {
|
|
1257
|
+
const found = lookupEvmToken(table, chainId, token);
|
|
1258
|
+
return {
|
|
1259
|
+
asset: token,
|
|
1260
|
+
amount: value.toString(10),
|
|
1261
|
+
...found === void 0 ? {} : {
|
|
1262
|
+
symbol: found.symbol,
|
|
1263
|
+
decimals: found.decimals
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
if (kind === "erc721" || kind === "erc1155") return {
|
|
1268
|
+
asset: token,
|
|
1269
|
+
amount: value.toString(10),
|
|
1270
|
+
tokenId: identifier.toString(10)
|
|
1271
|
+
};
|
|
1272
|
+
return {
|
|
1273
|
+
asset: token,
|
|
1274
|
+
amount: value.toString(10)
|
|
1275
|
+
};
|
|
1276
|
+
};
|
|
1277
|
+
const item = (message, chainId, table) => {
|
|
1278
|
+
const itemType = typedDataUint(message["itemType"], 255n);
|
|
1279
|
+
const token = typedDataAddress(message["token"]);
|
|
1280
|
+
const identifier = typedDataUint(message["identifierOrCriteria"], MAX_UINT256);
|
|
1281
|
+
const start = typedDataUint(message["startAmount"], MAX_UINT256);
|
|
1282
|
+
const end = typedDataUint(message["endAmount"], MAX_UINT256);
|
|
1283
|
+
const kind = itemType === void 0 ? void 0 : ITEM_KINDS[Number(itemType)];
|
|
1284
|
+
if (token === void 0 || identifier === void 0 || start === void 0 || end === void 0 || kind === void 0) return;
|
|
1285
|
+
return {
|
|
1286
|
+
kind,
|
|
1287
|
+
token,
|
|
1288
|
+
identifier: identifier.toString(10),
|
|
1289
|
+
startAmount: amount(kind, token, start, identifier, chainId, table),
|
|
1290
|
+
endAmount: amount(kind, token, end, identifier, chainId, table)
|
|
1291
|
+
};
|
|
1292
|
+
};
|
|
1293
|
+
const all = (list, build) => {
|
|
1294
|
+
const built = list?.map(build);
|
|
1295
|
+
return built === void 0 || built.some((entry) => entry === void 0) ? void 0 : built.filter((entry) => entry !== void 0);
|
|
1296
|
+
};
|
|
1297
|
+
/**
|
|
1298
|
+
* The Seaport order a typed-data document signs, or `undefined` when its shape is not exactly the
|
|
1299
|
+
* recognized one. `chainId` is the request network's, used for the built-in token table.
|
|
1300
|
+
*/
|
|
1301
|
+
function recognizeSeaport(json, chainId, table) {
|
|
1302
|
+
const { types, primaryType, message, domain } = json;
|
|
1303
|
+
if (primaryType !== "OrderComponents" || !typesMatch(types)) return;
|
|
1304
|
+
const verifying = typedDataAddress(domain["verifyingContract"]);
|
|
1305
|
+
if (domain["name"] !== "Seaport" || verifying === void 0 || !SEAPORT_CONTRACTS.has(verifying.toLowerCase())) return;
|
|
1306
|
+
const offerer = typedDataAddress(message["offerer"]);
|
|
1307
|
+
const zone = typedDataAddress(message["zone"]);
|
|
1308
|
+
const startTime = typedDataUint(message["startTime"], MAX_UINT256);
|
|
1309
|
+
const endTime = typedDataUint(message["endTime"], MAX_UINT256);
|
|
1310
|
+
const offer = all(typedDataMessages(message["offer"]), (entry) => item(entry, chainId, table));
|
|
1311
|
+
const consideration = all(typedDataMessages(message["consideration"]), (entry) => {
|
|
1312
|
+
const base = item(entry, chainId, table);
|
|
1313
|
+
const recipient = typedDataAddress(entry["recipient"]);
|
|
1314
|
+
return base === void 0 || recipient === void 0 ? void 0 : {
|
|
1315
|
+
...base,
|
|
1316
|
+
recipient
|
|
1317
|
+
};
|
|
1318
|
+
});
|
|
1319
|
+
if (offerer === void 0 || zone === void 0 || startTime === void 0 || endTime === void 0 || offer === void 0 || consideration === void 0) return;
|
|
1320
|
+
return {
|
|
1321
|
+
offerer,
|
|
1322
|
+
zone,
|
|
1323
|
+
startTime: startTime <= MAX_UINT48 ? Number(startTime) : void 0,
|
|
1324
|
+
endTime: endTime <= MAX_UINT48 ? Number(endTime) : void 0,
|
|
1325
|
+
offer,
|
|
1326
|
+
consideration
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
// src/evm/families.ts
|
|
1330
|
+
/**
|
|
1331
|
+
* The EVM interpreters of the family-claim table (src/families.ts): a request a decoded family
|
|
1332
|
+
* claims but which the decoder did not decode is blind with the row's reason.
|
|
1333
|
+
*/
|
|
1334
|
+
/**
|
|
1335
|
+
* The claim an undecoded call into `to` makes on `chainId`: the Fiat24 row's callee is a pinned
|
|
1336
|
+
* contract or a Fiat24-specific selector in `data`; a listed token's claim is the token table.
|
|
1337
|
+
*/
|
|
1338
|
+
const callNearMiss = (to, chainId, table, data) => RECOGNISED_FAMILIES.find((row) => {
|
|
1339
|
+
if (row.claim.surface !== "evm.call") return false;
|
|
1340
|
+
return row.claim.callee === "fiat24" ? isFiat24Contract(chainId, to) || hasFiat24Selector(data) : lookupEvmToken(table, chainId, to) !== void 0;
|
|
1341
|
+
})?.nearMiss;
|
|
1342
|
+
/**
|
|
1343
|
+
* The claim a personal message's text makes: an exact, case-sensitive leading sentence of a
|
|
1344
|
+
* family's grant message. A grant-shaped text claims the family even though the wallet builds
|
|
1345
|
+
* grants only through its own structured request.
|
|
1346
|
+
*/
|
|
1347
|
+
const personalMessageNearMiss = (text) => RECOGNISED_FAMILIES.find((row) => row.claim.surface === "evm.personal-message" && row.claim.prefixes.some((prefix) => text.startsWith(prefix)))?.nearMiss;
|
|
1348
|
+
/**
|
|
1349
|
+
* The claim an unrecognised typed-data document makes: a family primary type, or a verifying
|
|
1350
|
+
* contract of Permit2, a canonical Seaport deployment or a listed token (case-insensitive).
|
|
1351
|
+
*/
|
|
1352
|
+
const typedDataNearMiss = (json, chainId, table) => {
|
|
1353
|
+
const verifying = typedDataAddress(json.domain["verifyingContract"]);
|
|
1354
|
+
return RECOGNISED_FAMILIES.find((row) => {
|
|
1355
|
+
const { claim } = row;
|
|
1356
|
+
if (claim.surface !== "evm.typed-data") return false;
|
|
1357
|
+
if ("contracts" in claim) {
|
|
1358
|
+
const contract = verifying?.toLowerCase();
|
|
1359
|
+
return json.domain["name"] === claim.domainName || contract !== void 0 && claim.contracts.some((address) => address.toLowerCase() === contract);
|
|
1360
|
+
}
|
|
1361
|
+
if ("domainName" in claim) return json.domain["name"] === claim.domainName && (claim.primaryType === void 0 || claim.primaryType.test(json.primaryType));
|
|
1362
|
+
if ("primaryType" in claim) return claim.primaryType.test(json.primaryType);
|
|
1363
|
+
if (verifying === void 0) return false;
|
|
1364
|
+
const contract = verifying.toLowerCase();
|
|
1365
|
+
return claim.verifyingContract === "permit2" && contract === "0x000000000022D473030F116dDEE9F6B43aC78BA3".toLowerCase() || claim.verifyingContract === "seaport" && SEAPORT_CONTRACTS.has(contract) || claim.verifyingContract === "morpho-blue" && isMorphoBlue(chainId, contract) || claim.verifyingContract === "token-table" && lookupEvmToken(table, chainId, verifying) !== void 0;
|
|
1366
|
+
})?.nearMiss;
|
|
1367
|
+
};
|
|
1368
|
+
const FARCASTER_CHAIN_ID = 10;
|
|
1369
|
+
const DOMAIN_FIELDS$1 = [
|
|
1370
|
+
"string name",
|
|
1371
|
+
"string version",
|
|
1372
|
+
"uint256 chainId",
|
|
1373
|
+
"address verifyingContract"
|
|
1374
|
+
];
|
|
1375
|
+
const ADD_FIELDS = [
|
|
1376
|
+
"address owner",
|
|
1377
|
+
"uint32 keyType",
|
|
1378
|
+
"bytes key",
|
|
1379
|
+
"uint8 metadataType",
|
|
1380
|
+
"bytes metadata",
|
|
1381
|
+
"uint256 nonce",
|
|
1382
|
+
"uint256 deadline"
|
|
1383
|
+
];
|
|
1384
|
+
const REQUEST_FIELDS = [
|
|
1385
|
+
"uint256 requestFid",
|
|
1386
|
+
"bytes key",
|
|
1387
|
+
"uint256 deadline"
|
|
1388
|
+
];
|
|
1389
|
+
const KEY_METADATA = [{
|
|
1390
|
+
type: "tuple",
|
|
1391
|
+
components: [
|
|
1392
|
+
{
|
|
1393
|
+
name: "requestFid",
|
|
1394
|
+
type: "uint256"
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
name: "requestSigner",
|
|
1398
|
+
type: "address"
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
name: "signature",
|
|
1402
|
+
type: "bytes"
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
name: "deadline",
|
|
1406
|
+
type: "uint256"
|
|
1407
|
+
}
|
|
1408
|
+
]
|
|
1409
|
+
}];
|
|
1410
|
+
const isUint = (value, max, expected) => typedDataUint(value, max) === expected;
|
|
1411
|
+
const parseUint = (value) => typedDataUint(value, 2n ** 256n - 1n);
|
|
1412
|
+
const isKey = (value) => {
|
|
1413
|
+
const bytes = typedDataBytes(value);
|
|
1414
|
+
return bytes !== void 0 && Hex.size(bytes) === 32;
|
|
1415
|
+
};
|
|
1416
|
+
const isKeyMetadata = (value) => typeof value === "object" && value !== null && "requestFid" in value && typeof value.requestFid === "bigint" && "requestSigner" in value && typedDataAddress(value.requestSigner) !== void 0 && "signature" in value && typedDataBytes(value.signature) !== void 0 && "deadline" in value && typeof value.deadline === "bigint";
|
|
1417
|
+
const decodeKeyMetadata = (bytes) => {
|
|
107
1418
|
try {
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
if (!
|
|
111
|
-
|
|
112
|
-
return data.toLowerCase().startsWith(reencoded) ? args : void 0;
|
|
1419
|
+
const decoded = AbiParameters.decode(KEY_METADATA, bytes);
|
|
1420
|
+
const tuple = Array.isArray(decoded) ? decoded[0] : void 0;
|
|
1421
|
+
if (!isKeyMetadata(tuple) || AbiParameters.encode(KEY_METADATA, [tuple]).toLowerCase() !== bytes.toLowerCase()) return;
|
|
1422
|
+
return tuple;
|
|
113
1423
|
} catch {
|
|
114
1424
|
return;
|
|
115
1425
|
}
|
|
116
1426
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
const tokenAmount$2 = (table, chainId, token, amount) => {
|
|
124
|
-
const meta = table === void 0 ? void 0 : lookupEvmToken(table, chainId, token);
|
|
125
|
-
return meta === void 0 ? {
|
|
126
|
-
asset: token,
|
|
127
|
-
amount: amount.toString(10)
|
|
128
|
-
} : {
|
|
129
|
-
asset: token,
|
|
130
|
-
amount: amount.toString(10),
|
|
131
|
-
decimals: meta.decimals,
|
|
132
|
-
symbol: meta.symbol
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
const argUint$1 = (args, index) => {
|
|
136
|
-
const v = args[index];
|
|
137
|
-
return typeof v === "bigint" ? v : typeof v === "number" ? BigInt(v) : void 0;
|
|
138
|
-
};
|
|
139
|
-
const argAddress$2 = (args, index) => {
|
|
140
|
-
const v = args[index];
|
|
141
|
-
return typeof v === "string" && /^0x[0-9a-fA-F]{40}$/.test(v) ? checksumEvmAddress(v) : void 0;
|
|
142
|
-
};
|
|
1427
|
+
const result = (farcaster, summary) => ({
|
|
1428
|
+
content: { farcaster },
|
|
1429
|
+
summary,
|
|
1430
|
+
outflows: [],
|
|
1431
|
+
verifiability: "partial"
|
|
1432
|
+
});
|
|
143
1433
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* guarantees `outputAmount` on the destination chain or a refund to `depositor` after
|
|
147
|
-
* `fillDeadline`, so the intent's `minimumReceived` and `bridge` fields carry those terms.
|
|
1434
|
+
* The Farcaster signer-key document, or `undefined` when the shape is not exactly a KeyGateway
|
|
1435
|
+
* `Add` bound to the signer or a `SignedKeyRequest` — on the OP Mainnet deployment.
|
|
148
1436
|
*/
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
destinationNetwork: `eip155:${destinationChainId.toString(10)}`,
|
|
185
|
-
fillDeadline: Number(fillDeadline),
|
|
186
|
-
refundTo: depositor
|
|
187
|
-
}
|
|
188
|
-
};
|
|
1437
|
+
const recognizeFarcaster = (json, chainId, signer) => {
|
|
1438
|
+
const { types, primaryType, domain, message } = json;
|
|
1439
|
+
if (chainId !== FARCASTER_CHAIN_ID || domainChainId(domain) !== chainId || domain["version"] !== "1" || Object.keys(domain).length !== 4 || Object.keys(types).length !== 2 || !sameFields(types, "EIP712Domain", DOMAIN_FIELDS$1)) return;
|
|
1440
|
+
const contract = typedDataAddress(domain["verifyingContract"]);
|
|
1441
|
+
if (contract === void 0) return;
|
|
1442
|
+
if (primaryType === "Add" && domain["name"] === "Farcaster KeyGateway" && contract === "0x00000000fC56947c7E7183f8Ca4B62398CaAdf0B") {
|
|
1443
|
+
if (!sameFields(types, "Add", ADD_FIELDS)) return;
|
|
1444
|
+
const owner = typedDataAddress(message["owner"]);
|
|
1445
|
+
const { key } = message;
|
|
1446
|
+
const metadata = typedDataBytes(message["metadata"]);
|
|
1447
|
+
const nonce = parseUint(message["nonce"]);
|
|
1448
|
+
const deadline = parseUint(message["deadline"]);
|
|
1449
|
+
if (owner === void 0 || owner.toLowerCase() !== signer.toLowerCase() || !isUint(message["keyType"], 2n ** 32n - 1n, 1n) || !isKey(key) || !isUint(message["metadataType"], 2n ** 8n - 1n, 1n) || metadata === void 0 || nonce === void 0 || deadline === void 0) return;
|
|
1450
|
+
const app = decodeKeyMetadata(metadata);
|
|
1451
|
+
if (app === void 0) return;
|
|
1452
|
+
return result({
|
|
1453
|
+
kind: "add",
|
|
1454
|
+
key,
|
|
1455
|
+
requestFid: app.requestFid.toString(),
|
|
1456
|
+
...deadline <= MAX_UINT48 ? { deadline: Number(deadline) } : {}
|
|
1457
|
+
}, "authorization");
|
|
1458
|
+
}
|
|
1459
|
+
if (primaryType === "SignedKeyRequest" && domain["name"] === "Farcaster SignedKeyRequestValidator" && contract === "0x00000000FC700472606ED4fA22623Acf62c60553") {
|
|
1460
|
+
if (!sameFields(types, "SignedKeyRequest", REQUEST_FIELDS)) return;
|
|
1461
|
+
const requestFid = parseUint(message["requestFid"]);
|
|
1462
|
+
const { key } = message;
|
|
1463
|
+
const deadline = parseUint(message["deadline"]);
|
|
1464
|
+
if (requestFid === void 0 || !isKey(key) || deadline === void 0) return;
|
|
1465
|
+
return result({
|
|
1466
|
+
kind: "request",
|
|
1467
|
+
key,
|
|
1468
|
+
requestFid: requestFid.toString(),
|
|
1469
|
+
...deadline <= MAX_UINT48 ? { deadline: Number(deadline) } : {}
|
|
1470
|
+
}, "message");
|
|
1471
|
+
}
|
|
189
1472
|
};
|
|
190
1473
|
// src/evm/grants.ts
|
|
191
1474
|
/** MetaMask Delegation Framework v1.3.0 DelegationManager — the same address on every chain. */
|
|
@@ -218,9 +1501,9 @@ const REQUEST_WSTETH = AbiFunction.from("function requestWithdrawalsWstETH(uint2
|
|
|
218
1501
|
const REQUEST_PERMIT = AbiFunction.from("function requestWithdrawalsWithPermit(uint256[] amounts, address owner, (uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) permit)");
|
|
219
1502
|
const REQUEST_WSTETH_PERMIT = AbiFunction.from("function requestWithdrawalsWstETHWithPermit(uint256[] amounts, address owner, (uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) permit)");
|
|
220
1503
|
const CLAIM = AbiFunction.from("function claimWithdrawals(uint256[] requestIds, uint256[] hints)");
|
|
221
|
-
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
1504
|
+
const ZERO$1 = "0x0000000000000000000000000000000000000000";
|
|
222
1505
|
/** Canonical-encoding decode like `tryCall` in decode.ts — undefined on any mismatch. */
|
|
223
|
-
const tryCall$
|
|
1506
|
+
const tryCall$2 = (fn, data) => {
|
|
224
1507
|
const selector = AbiFunction.getSelector(fn);
|
|
225
1508
|
if (!data.toLowerCase().startsWith(selector)) return;
|
|
226
1509
|
try {
|
|
@@ -242,7 +1525,7 @@ const argList$1 = (args, index) => {
|
|
|
242
1525
|
if (!Array.isArray(value) || !value.every((v) => typeof v === "bigint")) throw new ChainError("invalid-request", "decoded argument is not a uint256 array");
|
|
243
1526
|
return value;
|
|
244
1527
|
};
|
|
245
|
-
const tokenAmount
|
|
1528
|
+
const tokenAmount = (token, amount, table) => {
|
|
246
1529
|
const known = lookupEvmToken(table, 1, token);
|
|
247
1530
|
return {
|
|
248
1531
|
asset: token,
|
|
@@ -253,21 +1536,23 @@ const tokenAmount$1 = (token, amount, table) => {
|
|
|
253
1536
|
}
|
|
254
1537
|
};
|
|
255
1538
|
};
|
|
256
|
-
const tokenFlow
|
|
1539
|
+
const tokenFlow = (token, to, amount, table) => ({
|
|
257
1540
|
to,
|
|
258
|
-
amount: tokenAmount
|
|
1541
|
+
amount: tokenAmount(token, amount, table),
|
|
259
1542
|
verified: lookupEvmToken(table, 1, token) !== void 0
|
|
260
1543
|
});
|
|
261
1544
|
/**
|
|
262
1545
|
* Lido staking on Ethereum mainnet: `submit` to stETH, the four withdrawal-request forms and
|
|
263
1546
|
* `claimWithdrawals` on the queue. The minted stETH shares and the checkpointed claim amounts
|
|
264
|
-
* cannot be read exactly from calldata, so every recognised call is verifiability-partial.
|
|
1547
|
+
* cannot be read exactly from calldata, so every recognised call is verifiability-partial. `caller`
|
|
1548
|
+
* is the account the call runs as — msg.sender at the queue (the signer for a transaction, the Safe
|
|
1549
|
+
* or deposit wallet for an inner call); a zero owner resolves to it.
|
|
265
1550
|
*/
|
|
266
|
-
const decodeLido = (chainId, call,
|
|
1551
|
+
const decodeLido = (chainId, call, caller, table) => {
|
|
267
1552
|
if (chainId !== 1 || call.to === void 0) return;
|
|
268
1553
|
const to = call.to.toLowerCase();
|
|
269
1554
|
if (to === "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84".toLowerCase() && call.value > 0n) {
|
|
270
|
-
if (tryCall$
|
|
1555
|
+
if (tryCall$2(SUBMIT, call.data) !== void 0) return {
|
|
271
1556
|
outflows: [{
|
|
272
1557
|
to: LIDO_STETH,
|
|
273
1558
|
amount: {
|
|
@@ -282,7 +1567,7 @@ const decodeLido = (chainId, call, signer, table) => {
|
|
|
282
1567
|
asset: EVM_NATIVE_ASSET,
|
|
283
1568
|
amount: call.value.toString(10)
|
|
284
1569
|
},
|
|
285
|
-
receive: tokenAmount
|
|
1570
|
+
receive: tokenAmount(LIDO_STETH, call.value, table)
|
|
286
1571
|
}]
|
|
287
1572
|
};
|
|
288
1573
|
return;
|
|
@@ -294,23 +1579,23 @@ const decodeLido = (chainId, call, signer, table) => {
|
|
|
294
1579
|
[REQUEST_PERMIT, LIDO_STETH],
|
|
295
1580
|
[REQUEST_WSTETH_PERMIT, LIDO_WSTETH]
|
|
296
1581
|
]) {
|
|
297
|
-
const args = tryCall$
|
|
1582
|
+
const args = tryCall$2(fn, call.data);
|
|
298
1583
|
if (args === void 0) continue;
|
|
299
1584
|
const total = argList$1(args, 0).reduce((sum, amount) => sum + amount, 0n);
|
|
300
1585
|
const raw = argAddress$1(args, 1);
|
|
301
|
-
const owner = raw === ZERO ?
|
|
1586
|
+
const owner = raw === ZERO$1 ? caller : raw;
|
|
302
1587
|
const action = {
|
|
303
1588
|
kind: "lido-request",
|
|
304
1589
|
token,
|
|
305
|
-
amount: tokenAmount
|
|
1590
|
+
amount: tokenAmount(token, total, table),
|
|
306
1591
|
owner
|
|
307
1592
|
};
|
|
308
1593
|
return {
|
|
309
|
-
outflows: owner.toLowerCase() ===
|
|
1594
|
+
outflows: owner.toLowerCase() === caller.toLowerCase() ? [] : [tokenFlow(token, owner, total, table)],
|
|
310
1595
|
staking: [action]
|
|
311
1596
|
};
|
|
312
1597
|
}
|
|
313
|
-
const claimArgs = tryCall$
|
|
1598
|
+
const claimArgs = tryCall$2(CLAIM, call.data);
|
|
314
1599
|
if (claimArgs !== void 0) {
|
|
315
1600
|
const requestIds = argList$1(claimArgs, 0).map((id) => id.toString(10));
|
|
316
1601
|
argList$1(claimArgs, 1);
|
|
@@ -323,126 +1608,98 @@ const decodeLido = (chainId, call, signer, table) => {
|
|
|
323
1608
|
};
|
|
324
1609
|
}
|
|
325
1610
|
};
|
|
326
|
-
// src/evm/
|
|
327
|
-
const isMessage = isTypedDataMessage;
|
|
328
|
-
const address = typedDataAddress;
|
|
329
|
-
const uint = typedDataUint;
|
|
330
|
-
const DETAILS = [
|
|
331
|
-
"address token",
|
|
332
|
-
"uint160 amount",
|
|
333
|
-
"uint48 expiration",
|
|
334
|
-
"uint48 nonce"
|
|
335
|
-
];
|
|
336
|
-
const PERMISSIONS = ["address token", "uint256 amount"];
|
|
337
|
-
const WITNESS_WARNING = {
|
|
338
|
-
kind: "permit2-witness",
|
|
339
|
-
message: "the permit carries a witness with further terms"
|
|
340
|
-
};
|
|
341
|
-
const entries = (value) => Array.isArray(value) && value.length > 0 && value.every(isMessage) ? value : void 0;
|
|
342
|
-
const permit = (...approvals) => ({
|
|
343
|
-
approvals,
|
|
344
|
-
warnings: []
|
|
345
|
-
});
|
|
1611
|
+
// src/evm/oneinch.ts
|
|
346
1612
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
1613
|
+
* Decoding of 1inch Limit Order Protocol v4 orders signed at an Aggregation Router v6. The `Order`
|
|
1614
|
+
* type is verbatim from `contracts/OrderLib.sol` in 1inch/limit-order-protocol at tag 4.0.0
|
|
1615
|
+
* (https://github.com/1inch/limit-order-protocol/blob/c8be9c67247880bd6ec88cf7ad2e040a16a483f2/contracts/OrderLib.sol);
|
|
1616
|
+
* the router domains `{name: "1inch Aggregation Router", version: "6", chainId, verifyingContract}`
|
|
1617
|
+
* were verified by on-chain `eip712Domain()` probed in vectors/chains/order-protocols.json. The LOP
|
|
1618
|
+
* signs only ERC-20 assets — the zero address and the `0xeeee…` pseudo-address other protocols use
|
|
1619
|
+
* as a native marker are malformed here.
|
|
1620
|
+
*
|
|
1621
|
+
* `makerTraits` (bit layout in `contracts/libraries/MakerTraitsLib.sol`) decides whether anything
|
|
1622
|
+
* unsigned can change the order's bounds. Rejected — anything set makes the document a near miss:
|
|
1623
|
+
* HAS_EXTENSION (249) and PRE_/POST_INTERACTION_CALL (252/251), which let an extension hidden in
|
|
1624
|
+
* `salt` run arbitrary code (Fusion orders always carry an extension, so they stay blind);
|
|
1625
|
+
* UNWRAP_WETH (247), which changes what the receiver actually gets; the spare bit 253 and the
|
|
1626
|
+
* undefined range 200..246. The remaining flags (NO_PARTIAL_FILLS, ALLOW_MULTIPLE_FILLS,
|
|
1627
|
+
* NEED_CHECK_EPOCH_MANAGER, USE_PERMIT2) only constrain how the order fills, not its bounds.
|
|
349
1628
|
*/
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
"
|
|
424
|
-
"uint256 nonce",
|
|
425
|
-
"uint256 deadline"
|
|
426
|
-
] : [
|
|
427
|
-
"TokenPermissions permitted",
|
|
428
|
-
"address spender",
|
|
429
|
-
"uint256 nonce",
|
|
430
|
-
"uint256 deadline"
|
|
431
|
-
];
|
|
432
|
-
if (primaryType !== `Permit${batch ? "Batch" : ""}${witness ? "Witness" : ""}TransferFrom`) return;
|
|
433
|
-
const own = types[primaryType];
|
|
434
|
-
const last = own?.at(-1);
|
|
435
|
-
const fieldsOk = witness ? sameFields({
|
|
436
|
-
...types,
|
|
437
|
-
[primaryType]: own?.slice(0, -1) ?? []
|
|
438
|
-
}, primaryType, expected) && last?.name === "witness" && types[last.type] !== void 0 : sameFields(types, primaryType, expected);
|
|
439
|
-
const deadline = uint(message["deadline"], MAX_UINT256);
|
|
440
|
-
if (!fieldsOk || !sameFields(types, "TokenPermissions", PERMISSIONS) || deadline === void 0) return;
|
|
441
|
-
const { permitted } = message;
|
|
442
|
-
const result = batch ? all(entries(permitted), (item) => transfer(item, deadline)) : isMessage(permitted) ? all([permitted], (item) => transfer(item, deadline)) : void 0;
|
|
443
|
-
return result === void 0 || !witness ? result : {
|
|
444
|
-
approvals: result.approvals,
|
|
445
|
-
warnings: [WITNESS_WARNING]
|
|
1629
|
+
/** `Order`'s field list, verbatim from OrderLib.sol. */
|
|
1630
|
+
const ORDER_FIELDS = [
|
|
1631
|
+
"uint256 salt",
|
|
1632
|
+
"address maker",
|
|
1633
|
+
"address receiver",
|
|
1634
|
+
"address makerAsset",
|
|
1635
|
+
"address takerAsset",
|
|
1636
|
+
"uint256 makingAmount",
|
|
1637
|
+
"uint256 takingAmount",
|
|
1638
|
+
"uint256 makerTraits"
|
|
1639
|
+
];
|
|
1640
|
+
const V6_ROUTER = "0x111111125421ca6dc452d289314280a0f8842a65";
|
|
1641
|
+
const V6_ZKSYNC_ROUTER = "0x6fd4383cb451173d5f9304f041c7bcbf27d561ff";
|
|
1642
|
+
const V6_CHAINS = /* @__PURE__ */ new Set([
|
|
1643
|
+
1,
|
|
1644
|
+
10,
|
|
1645
|
+
25,
|
|
1646
|
+
56,
|
|
1647
|
+
100,
|
|
1648
|
+
130,
|
|
1649
|
+
137,
|
|
1650
|
+
143,
|
|
1651
|
+
146,
|
|
1652
|
+
8217,
|
|
1653
|
+
8453,
|
|
1654
|
+
42161,
|
|
1655
|
+
43114,
|
|
1656
|
+
59144
|
|
1657
|
+
]);
|
|
1658
|
+
const v6Router = (chainId) => chainId === 324 ? V6_ZKSYNC_ROUTER : V6_CHAINS.has(chainId) ? V6_ROUTER : void 0;
|
|
1659
|
+
const UNWRAP_WETH = 1n << 247n;
|
|
1660
|
+
const HAS_EXTENSION = 1n << 249n;
|
|
1661
|
+
const POST_INTERACTION_CALL = 1n << 251n;
|
|
1662
|
+
const PRE_INTERACTION_CALL = 1n << 252n;
|
|
1663
|
+
const SPARE_BIT_253 = 1n << 253n;
|
|
1664
|
+
const UNDEFINED_200_246 = (1n << 47n) - 1n << 200n;
|
|
1665
|
+
const REJECTED = UNWRAP_WETH | HAS_EXTENSION | POST_INTERACTION_CALL | PRE_INTERACTION_CALL | SPARE_BIT_253 | UNDEFINED_200_246;
|
|
1666
|
+
const NO_PARTIAL_FILLS = 1n << 255n;
|
|
1667
|
+
const ALLOWED_SENDER = (1n << 80n) - 1n;
|
|
1668
|
+
const EXPIRATION = (1n << 40n) - 1n << 80n;
|
|
1669
|
+
const ZERO = "0x0000000000000000000000000000000000000000";
|
|
1670
|
+
const PSEUDO_NATIVE = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
1671
|
+
/** The order under the exact Aggregation Router v6 domain, or `undefined` — a near miss. */
|
|
1672
|
+
const recognizeOneinch = (json, chainId, table) => {
|
|
1673
|
+
const { domain, types, primaryType, message } = json;
|
|
1674
|
+
const verifying = typedDataAddress(domain["verifyingContract"]);
|
|
1675
|
+
const router = v6Router(chainId);
|
|
1676
|
+
if (domain["name"] !== "1inch Aggregation Router" || domain["version"] !== "6" || domainChainId(domain) !== chainId || router === void 0 || verifying === void 0 || verifying.toLowerCase() !== router || primaryType !== "Order" || Object.keys(types).length !== 2 || !sameFields(types, "EIP712Domain", [
|
|
1677
|
+
"string name",
|
|
1678
|
+
"string version",
|
|
1679
|
+
"uint256 chainId",
|
|
1680
|
+
"address verifyingContract"
|
|
1681
|
+
]) || !sameFields(types, "Order", ORDER_FIELDS)) return;
|
|
1682
|
+
const maker = typedDataAddress(message["maker"]);
|
|
1683
|
+
const receiver = typedDataAddress(message["receiver"]);
|
|
1684
|
+
const makerAsset = typedDataAddress(message["makerAsset"]);
|
|
1685
|
+
const takerAsset = typedDataAddress(message["takerAsset"]);
|
|
1686
|
+
const makingAmount = typedDataUint(message["makingAmount"], MAX_UINT256);
|
|
1687
|
+
const takingAmount = typedDataUint(message["takingAmount"], MAX_UINT256);
|
|
1688
|
+
const traits = typedDataUint(message["makerTraits"], MAX_UINT256);
|
|
1689
|
+
if (maker === void 0 || receiver === void 0 || makerAsset === void 0 || takerAsset === void 0 || makingAmount === void 0 || takingAmount === void 0 || traits === void 0 || typedDataUint(message["salt"], MAX_UINT256) === void 0 || makerAsset.toLowerCase() === ZERO || makerAsset.toLowerCase() === PSEUDO_NATIVE || takerAsset.toLowerCase() === ZERO || takerAsset.toLowerCase() === PSEUDO_NATIVE || (traits & REJECTED) !== 0n) return;
|
|
1690
|
+
const expiry = (traits & EXPIRATION) >> 80n;
|
|
1691
|
+
const allowed = traits & ALLOWED_SENDER;
|
|
1692
|
+
return {
|
|
1693
|
+
protocol: "1inch",
|
|
1694
|
+
maker,
|
|
1695
|
+
give: orderAmount(makerAsset, makingAmount, chainId, table),
|
|
1696
|
+
receive: [{
|
|
1697
|
+
recipient: receiver.toLowerCase() === ZERO ? maker : receiver,
|
|
1698
|
+
amount: orderAmount(takerAsset, takingAmount, chainId, table)
|
|
1699
|
+
}],
|
|
1700
|
+
...expiry === 0n ? {} : { expiry: Number(expiry) },
|
|
1701
|
+
partialFill: (traits & NO_PARTIAL_FILLS) === 0n,
|
|
1702
|
+
...allowed === 0n ? {} : { allowedSender: `0x${allowed.toString(16).padStart(20, "0")}` }
|
|
446
1703
|
};
|
|
447
1704
|
};
|
|
448
1705
|
// src/evm/safe.ts
|
|
@@ -474,6 +1731,8 @@ const SAFE_TX = [
|
|
|
474
1731
|
"uint256 nonce"
|
|
475
1732
|
];
|
|
476
1733
|
const MULTISEND = AbiFunction.from("function multiSend(bytes transactions)");
|
|
1734
|
+
/** The zero address: `gasToken` zero pays the refund in the chain's native asset. */
|
|
1735
|
+
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
477
1736
|
/**
|
|
478
1737
|
* Packed MultiSend entries (`uint8 operation, address to, uint256 value, uint256 dataLength, bytes
|
|
479
1738
|
* data` repeated). `undefined` when `data` is not a `multiSend(bytes)` call, a byte is truncated or
|
|
@@ -514,9 +1773,10 @@ const multiSendEntries = (data) => {
|
|
|
514
1773
|
/**
|
|
515
1774
|
* The Safe transaction a typed-data document signs, or `undefined` when its shape is not exactly
|
|
516
1775
|
* the recognized one. `decode` decodes one inner call (the transaction rules without a fee); the
|
|
517
|
-
* caller injects it bound to the request's network and token table
|
|
1776
|
+
* caller injects it bound to the request's network and token table, and receives the Safe address —
|
|
1777
|
+
* a call to it runs the Safe's own code.
|
|
518
1778
|
*/
|
|
519
|
-
function recognizeSafe(json, decode) {
|
|
1779
|
+
function recognizeSafe(json, context, decode) {
|
|
520
1780
|
const { types, primaryType, message, domain } = json;
|
|
521
1781
|
if (primaryType !== "SafeTx" || !sameFields(types, "SafeTx", SAFE_TX)) return;
|
|
522
1782
|
const safe = typedDataAddress(domain["verifyingContract"]);
|
|
@@ -532,11 +1792,41 @@ function recognizeSafe(json, decode) {
|
|
|
532
1792
|
const nonce = typedDataUint(message["nonce"], MAX_UINT256);
|
|
533
1793
|
if (safe === void 0 || to === void 0 || value === void 0 || data === void 0 || operation === void 0 || operation > 1n || safeTxGas === void 0 || baseGas === void 0 || gasPrice === void 0 || gasToken === void 0 || refundReceiver === void 0 || nonce === void 0) return;
|
|
534
1794
|
const inner = operation === 1n && SAFE_MULTISEND_CALL_ONLY.has(to.toLowerCase()) ? multiSendEntries(data) : void 0;
|
|
535
|
-
const calls =
|
|
1795
|
+
const calls = operation === 1n && inner === void 0 ? [{
|
|
1796
|
+
family: "evm",
|
|
1797
|
+
network: context.network,
|
|
1798
|
+
summary: "contract-call",
|
|
1799
|
+
outflows: [],
|
|
1800
|
+
approvals: [],
|
|
1801
|
+
fee: void 0,
|
|
1802
|
+
warnings: [],
|
|
1803
|
+
verifiability: "opaque",
|
|
1804
|
+
blind: "safe-delegatecall",
|
|
1805
|
+
contract: {
|
|
1806
|
+
address: to,
|
|
1807
|
+
created: false,
|
|
1808
|
+
selector: data.slice(0, 10).toLowerCase()
|
|
1809
|
+
}
|
|
1810
|
+
}] : (inner ?? [{
|
|
536
1811
|
to,
|
|
537
1812
|
value,
|
|
538
1813
|
data
|
|
539
|
-
}]).map(decode);
|
|
1814
|
+
}]).map((call) => decode(call, safe));
|
|
1815
|
+
const refundAsset = (v) => {
|
|
1816
|
+
if (gasToken === ZERO_ADDRESS) return {
|
|
1817
|
+
asset: EVM_NATIVE_ASSET,
|
|
1818
|
+
amount: v.toString(10)
|
|
1819
|
+
};
|
|
1820
|
+
const found = lookupEvmToken(context.table, context.chainId, gasToken);
|
|
1821
|
+
return {
|
|
1822
|
+
asset: gasToken,
|
|
1823
|
+
amount: v.toString(10),
|
|
1824
|
+
...found === void 0 ? {} : {
|
|
1825
|
+
symbol: found.symbol,
|
|
1826
|
+
decimals: found.decimals
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
};
|
|
540
1830
|
return {
|
|
541
1831
|
safe: {
|
|
542
1832
|
safe,
|
|
@@ -547,314 +1837,141 @@ function recognizeSafe(json, decode) {
|
|
|
547
1837
|
data,
|
|
548
1838
|
calls,
|
|
549
1839
|
...gasPrice > 0n ? { refund: {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
1840
|
+
...refundReceiver === ZERO_ADDRESS ? {} : { receiver: refundReceiver },
|
|
1841
|
+
gasPrice: refundAsset(gasPrice),
|
|
1842
|
+
amount: refundAsset((baseGas + safeTxGas) * gasPrice)
|
|
553
1843
|
} } : {}
|
|
554
1844
|
},
|
|
555
1845
|
multisend: inner !== void 0
|
|
556
1846
|
};
|
|
557
1847
|
}
|
|
558
|
-
// src/evm/
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
"
|
|
564
|
-
"
|
|
565
|
-
"erc721",
|
|
566
|
-
"erc1155",
|
|
567
|
-
"erc721-criteria",
|
|
568
|
-
"erc1155-criteria"
|
|
1848
|
+
// src/evm/snapshot.ts
|
|
1849
|
+
const DOMAIN_FIELDS = ["string name", "string version"];
|
|
1850
|
+
const VOTE_FIELDS = [
|
|
1851
|
+
"string from",
|
|
1852
|
+
"string space",
|
|
1853
|
+
"uint64 timestamp",
|
|
1854
|
+
"string proposal"
|
|
569
1855
|
];
|
|
570
|
-
const
|
|
571
|
-
"
|
|
572
|
-
"
|
|
573
|
-
"
|
|
574
|
-
"uint256 startAmount",
|
|
575
|
-
"uint256 endAmount"
|
|
1856
|
+
const VOTE_TAIL = [
|
|
1857
|
+
"string reason",
|
|
1858
|
+
"string app",
|
|
1859
|
+
"string metadata"
|
|
576
1860
|
];
|
|
577
|
-
const
|
|
578
|
-
"
|
|
579
|
-
"
|
|
580
|
-
"
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
"
|
|
584
|
-
"
|
|
585
|
-
"
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
]
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return {
|
|
600
|
-
asset: token,
|
|
601
|
-
amount: value.toString(10),
|
|
602
|
-
...found === void 0 ? {} : {
|
|
603
|
-
symbol: found.symbol,
|
|
604
|
-
decimals: found.decimals
|
|
605
|
-
}
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
return {
|
|
609
|
-
asset: token,
|
|
610
|
-
amount: value.toString(10)
|
|
611
|
-
};
|
|
612
|
-
};
|
|
613
|
-
const item = (message, chainId, table) => {
|
|
614
|
-
const itemType = typedDataUint(message["itemType"], 255n);
|
|
615
|
-
const token = typedDataAddress(message["token"]);
|
|
616
|
-
const identifier = typedDataUint(message["identifierOrCriteria"], MAX_UINT256);
|
|
617
|
-
const start = typedDataUint(message["startAmount"], MAX_UINT256);
|
|
618
|
-
const end = typedDataUint(message["endAmount"], MAX_UINT256);
|
|
619
|
-
const kind = itemType === void 0 ? void 0 : ITEM_KINDS[Number(itemType)];
|
|
620
|
-
if (token === void 0 || identifier === void 0 || start === void 0 || end === void 0 || kind === void 0) return;
|
|
621
|
-
return {
|
|
622
|
-
kind,
|
|
623
|
-
token,
|
|
624
|
-
identifier: identifier.toString(10),
|
|
625
|
-
startAmount: amount(kind, token, start, chainId, table),
|
|
626
|
-
endAmount: amount(kind, token, end, chainId, table)
|
|
627
|
-
};
|
|
628
|
-
};
|
|
629
|
-
const all = (list, build) => {
|
|
630
|
-
const built = list?.map(build);
|
|
631
|
-
return built === void 0 || built.some((entry) => entry === void 0) ? void 0 : built.filter((entry) => entry !== void 0);
|
|
632
|
-
};
|
|
633
|
-
/**
|
|
634
|
-
* The Seaport order a typed-data document signs, or `undefined` when its shape is not exactly the
|
|
635
|
-
* recognized one. `chainId` is the request network's, used for the built-in token table.
|
|
636
|
-
*/
|
|
637
|
-
function recognizeSeaport(json, chainId, table) {
|
|
638
|
-
const { types, primaryType, message, domain } = json;
|
|
639
|
-
if (primaryType !== "OrderComponents" || !typesMatch(types)) return;
|
|
640
|
-
const verifying = typedDataAddress(domain["verifyingContract"]);
|
|
641
|
-
if (domain["name"] !== "Seaport" || verifying === void 0 || !SEAPORT_CONTRACTS.has(verifying.toLowerCase())) return;
|
|
642
|
-
const offerer = typedDataAddress(message["offerer"]);
|
|
643
|
-
const zone = typedDataAddress(message["zone"]);
|
|
644
|
-
const startTime = typedDataUint(message["startTime"], MAX_UINT256);
|
|
645
|
-
const endTime = typedDataUint(message["endTime"], MAX_UINT256);
|
|
646
|
-
const offer = all(typedDataMessages(message["offer"]), (entry) => item(entry, chainId, table));
|
|
647
|
-
const consideration = all(typedDataMessages(message["consideration"]), (entry) => {
|
|
648
|
-
const base = item(entry, chainId, table);
|
|
649
|
-
const recipient = typedDataAddress(entry["recipient"]);
|
|
650
|
-
return base === void 0 || recipient === void 0 ? void 0 : {
|
|
651
|
-
...base,
|
|
652
|
-
recipient
|
|
653
|
-
};
|
|
654
|
-
});
|
|
655
|
-
if (offerer === void 0 || zone === void 0 || startTime === void 0 || endTime === void 0 || offer === void 0 || consideration === void 0) return;
|
|
656
|
-
return {
|
|
657
|
-
offerer,
|
|
658
|
-
zone,
|
|
659
|
-
startTime: startTime <= MAX_UINT48 ? Number(startTime) : void 0,
|
|
660
|
-
endTime: endTime <= MAX_UINT48 ? Number(endTime) : void 0,
|
|
661
|
-
offer,
|
|
662
|
-
consideration
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
// src/evm/zerox.ts
|
|
666
|
-
/**
|
|
667
|
-
* The 0x AllowanceHolder (`exec`) is deployed at the same address on every chain the taker Settler
|
|
668
|
-
* supports. `exec` grants the caller a one-time allowance of `amount` of `token` to `operator`,
|
|
669
|
-
* then calls `target` with `data` (forwarding `msg.value`).
|
|
670
|
-
*/
|
|
671
|
-
const ALLOWANCE_HOLDER = "0x0000000000001fF3684f28c67538d4D072C22734";
|
|
672
|
-
/** Chains whose AllowanceHolder + Settler deployment this decoder recognises. */
|
|
673
|
-
const ZEROX_CHAINS = /* @__PURE__ */ new Set([
|
|
674
|
-
1,
|
|
675
|
-
10,
|
|
676
|
-
56,
|
|
677
|
-
137,
|
|
678
|
-
8453,
|
|
679
|
-
999,
|
|
680
|
-
42161,
|
|
681
|
-
43114,
|
|
682
|
-
11155111
|
|
683
|
-
]);
|
|
684
|
-
const ZEROX_DEPLOYER = "0x00000000000004533Fe15556B1E086BB1A72cEae";
|
|
685
|
-
const SHIM_INIT_CODE_HASH = "0x3bf3f97f0be1e2c00023033eefeb4fc062ac552ff36778b17060d90b6764902f";
|
|
686
|
-
/** The native-token sentinel 0x uses in `exec`, and the bare zero address (same meaning). */
|
|
687
|
-
const NATIVE_SENTINEL = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
688
|
-
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
689
|
-
const EXEC = AbiFunction.from("function exec(address operator, address token, uint256 amount, address payable target, bytes data)");
|
|
690
|
-
const SETTLER_EXECUTE = AbiFunction.from("function execute((address recipient, address buyToken, uint256 minAmountOut) slippage, bytes[] actions, bytes32 zid)");
|
|
691
|
-
const last20 = (hex) => `0x${hex.slice(-40)}`;
|
|
692
|
-
const addressBytes = (address) => hexToBytes(address.slice(2));
|
|
693
|
-
const bigIntBytes32 = (value) => hexToBytes(value.toString(16).padStart(64, "0"));
|
|
694
|
-
const keccakHex = (parts) => {
|
|
695
|
-
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
696
|
-
const flat = new Uint8Array(total);
|
|
697
|
-
let offset = 0;
|
|
698
|
-
for (const part of parts) {
|
|
699
|
-
flat.set(part, offset);
|
|
700
|
-
offset += part.length;
|
|
701
|
-
}
|
|
702
|
-
return `0x${bytesToHex(keccak_256(flat))}`;
|
|
703
|
-
};
|
|
704
|
-
const FEATURE_TAKER = 2n;
|
|
705
|
-
/**
|
|
706
|
-
* Whether `address` is a taker-feature (2) 0x Settler on `chainId`. Settlers deploy as a CREATE2
|
|
707
|
-
* shim whose CREATE child is the contract: `salt = (feature << 128) | (chainId << 64) | nonce`,
|
|
708
|
-
* `shim = CREATE2(deployer, salt, initHash)`, `settler = CREATE(shim, 1)`. Settler is redeployed
|
|
709
|
-
* roughly monthly, so nonces 1..256 leave decades of headroom; the loop runs 512 keccaks and is
|
|
710
|
-
* only reached for an AllowanceHolder `exec`. Feature 5 (bridge) is deliberately not matched.
|
|
711
|
-
*/
|
|
712
|
-
const isZeroExSettler = (chainId, address) => {
|
|
713
|
-
const want = address.toLowerCase();
|
|
714
|
-
const deployer = addressBytes(ZEROX_DEPLOYER);
|
|
715
|
-
const initHash = hexToBytes(SHIM_INIT_CODE_HASH.slice(2));
|
|
716
|
-
for (let nonce = 1; nonce <= 256; nonce++) {
|
|
717
|
-
const salt = bigIntBytes32(FEATURE_TAKER * 2n ** 128n + BigInt(chainId) * 2n ** 64n + BigInt(nonce));
|
|
718
|
-
const shim = addressBytes(last20(keccakHex([
|
|
719
|
-
new Uint8Array([255]),
|
|
720
|
-
deployer,
|
|
721
|
-
salt,
|
|
722
|
-
initHash
|
|
723
|
-
])));
|
|
724
|
-
if (last20(keccakHex([
|
|
725
|
-
new Uint8Array([214, 148]),
|
|
726
|
-
shim,
|
|
727
|
-
new Uint8Array([1])
|
|
728
|
-
])) === want) return true;
|
|
729
|
-
}
|
|
730
|
-
return false;
|
|
731
|
-
};
|
|
732
|
-
/** The canonical-decoded `exec` arguments, or `undefined` (selector mismatch or non-canonical). */
|
|
733
|
-
const decodeExec = (data) => {
|
|
734
|
-
if (!data.toLowerCase().startsWith("0x2213bc0b")) return;
|
|
735
|
-
try {
|
|
736
|
-
assertHex(data, "data");
|
|
737
|
-
const args = AbiFunction.decodeData(EXEC, data);
|
|
738
|
-
if (!Array.isArray(args) || args.length !== 5) return;
|
|
739
|
-
if (AbiFunction.encodeData(EXEC, args).toLowerCase() !== data.toLowerCase()) return;
|
|
740
|
-
const [operator, token, amount, target, inner] = args;
|
|
741
|
-
if (typeof operator !== "string" || typeof token !== "string" || typeof amount !== "bigint" || typeof target !== "string" || typeof inner !== "string") return;
|
|
1861
|
+
const VOTE_CHOICE = [
|
|
1862
|
+
"uint32 choice",
|
|
1863
|
+
"uint32[] choice",
|
|
1864
|
+
"string choice"
|
|
1865
|
+
];
|
|
1866
|
+
const ALIAS_FIELDS = [
|
|
1867
|
+
"address from",
|
|
1868
|
+
"address alias",
|
|
1869
|
+
"uint64 timestamp"
|
|
1870
|
+
];
|
|
1871
|
+
const recognizeSnapshot = (json, signer) => {
|
|
1872
|
+
const { types, primaryType, domain, message } = json;
|
|
1873
|
+
if (domain["name"] !== "snapshot" || domain["version"] !== "0.1.4" || Object.keys(domain).length !== 2 || Object.keys(types).length !== 2 || !sameFields(types, "EIP712Domain", DOMAIN_FIELDS)) return;
|
|
1874
|
+
if (primaryType === "Vote" && VOTE_CHOICE.some((choice) => sameFields(types, "Vote", [
|
|
1875
|
+
...VOTE_FIELDS,
|
|
1876
|
+
choice,
|
|
1877
|
+
...VOTE_TAIL
|
|
1878
|
+
]))) return { kind: "vote" };
|
|
1879
|
+
if (primaryType === "Alias" && sameFields(types, "Alias", ALIAS_FIELDS)) {
|
|
1880
|
+
const from = typedDataAddress(message["from"]);
|
|
1881
|
+
const alias = typedDataAddress(message["alias"]);
|
|
1882
|
+
if (from === void 0 || from.toLowerCase() !== signer.toLowerCase() || alias === void 0) return;
|
|
742
1883
|
return {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
1884
|
+
kind: "alias",
|
|
1885
|
+
content: { authority: {
|
|
1886
|
+
kind: "snapshot-alias",
|
|
1887
|
+
alias
|
|
1888
|
+
} },
|
|
1889
|
+
summary: "authorization",
|
|
1890
|
+
outflows: [],
|
|
1891
|
+
verifiability: "partial"
|
|
748
1892
|
};
|
|
749
|
-
} catch {
|
|
750
|
-
return;
|
|
751
1893
|
}
|
|
752
1894
|
};
|
|
753
|
-
|
|
1895
|
+
// src/evm/wrapped-native.ts
|
|
754
1896
|
/**
|
|
755
|
-
*
|
|
756
|
-
*
|
|
1897
|
+
* Wrapped natives — WETH9-style contracts listed in the token table with role "wrapped-native".
|
|
1898
|
+
* `deposit()` mints the token to the caller for exactly msg.value and `withdraw(uint256)` burns the
|
|
1899
|
+
* token and returns the coin, so both describe as a swap whose other side is exact — verifiability
|
|
1900
|
+
* "full".
|
|
757
1901
|
*/
|
|
758
|
-
const
|
|
759
|
-
|
|
1902
|
+
const DEPOSIT = AbiFunction.from("function deposit() payable");
|
|
1903
|
+
const WITHDRAW = AbiFunction.from("function withdraw(uint256 wad)");
|
|
1904
|
+
/** Canonical-encoding decode like `tryCall` in lido.ts — undefined on any mismatch. */
|
|
1905
|
+
const tryCall$1 = (fn, data) => {
|
|
1906
|
+
const selector = AbiFunction.getSelector(fn);
|
|
1907
|
+
if (!data.toLowerCase().startsWith(selector)) return;
|
|
760
1908
|
try {
|
|
761
1909
|
assertHex(data, "data");
|
|
762
|
-
const args = AbiFunction.decodeData(
|
|
763
|
-
if (!Array.isArray(args)
|
|
764
|
-
|
|
765
|
-
const [slippage] = args;
|
|
766
|
-
if (!isSlippage(slippage)) return;
|
|
767
|
-
return slippage;
|
|
1910
|
+
const args = AbiFunction.decodeData(fn, data);
|
|
1911
|
+
if (!Array.isArray(args)) return;
|
|
1912
|
+
return AbiFunction.encodeData(fn, args).toLowerCase() === data.toLowerCase() ? args : void 0;
|
|
768
1913
|
} catch {
|
|
769
1914
|
return;
|
|
770
1915
|
}
|
|
771
1916
|
};
|
|
772
|
-
const
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
return
|
|
776
|
-
asset: checksumEvmAddress(token),
|
|
777
|
-
amount: amount.toString(10),
|
|
778
|
-
...known === void 0 ? {} : {
|
|
779
|
-
symbol: known.symbol,
|
|
780
|
-
decimals: known.decimals
|
|
781
|
-
}
|
|
782
|
-
};
|
|
1917
|
+
const argUint$1 = (args, index) => {
|
|
1918
|
+
const value = args[index];
|
|
1919
|
+
if (typeof value !== "bigint") throw new ChainError("invalid-request", "decoded argument is not an integer");
|
|
1920
|
+
return value;
|
|
783
1921
|
};
|
|
784
|
-
const nativeMinimum = (amount) => ({
|
|
785
|
-
asset: EVM_NATIVE_ASSET,
|
|
786
|
-
amount: amount.toString(10)
|
|
787
|
-
});
|
|
788
1922
|
/**
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
* call is not to AllowanceHolder or not `exec`.
|
|
1923
|
+
* `caller` is the account the call runs as — msg.sender at `call.to`: the signer for a transaction
|
|
1924
|
+
* or batch call, the Safe or deposit wallet for an inner call. Minted or withdrawn assets go to
|
|
1925
|
+
* it.
|
|
793
1926
|
*/
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
if (
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
if (operator.toLowerCase() === target.toLowerCase() && isZeroExSettler(chainId, target) && slippage !== void 0 && slippage !== void 0) {
|
|
801
|
-
let outflow;
|
|
802
|
-
if (isNativeToken(token)) {
|
|
803
|
-
if (amount === call.value && call.value > 0n) outflow = {
|
|
804
|
-
to: target,
|
|
805
|
-
amount: {
|
|
806
|
-
asset: EVM_NATIVE_ASSET,
|
|
807
|
-
amount: call.value.toString(10)
|
|
808
|
-
},
|
|
809
|
-
verified: true
|
|
810
|
-
};
|
|
811
|
-
} else if (call.value === 0n) outflow = {
|
|
812
|
-
to: target,
|
|
813
|
-
amount: tokenAmount(token, amount, chainId, table),
|
|
814
|
-
verified: lookupEvmToken(table, chainId, token) !== void 0
|
|
815
|
-
};
|
|
816
|
-
if (outflow !== void 0) {
|
|
817
|
-
const buyNative = isNativeToken(slippage.buyToken);
|
|
818
|
-
return {
|
|
819
|
-
summary: "swap",
|
|
820
|
-
outflows: [outflow],
|
|
821
|
-
approvals: [],
|
|
822
|
-
minimumReceived: [{
|
|
823
|
-
to: slippage.recipient,
|
|
824
|
-
amount: buyNative ? nativeMinimum(slippage.minAmountOut) : tokenAmount(slippage.buyToken, slippage.minAmountOut, chainId, table)
|
|
825
|
-
}],
|
|
826
|
-
verifiability: "partial"
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
const approvals = isNativeToken(token) ? [] : [allowanceChange(checksumEvmAddress(token), operator, amount, "transfer", MAX_UINT256, chainId, table, { via: "allowance-holder" })];
|
|
831
|
-
return {
|
|
832
|
-
summary: "contract-call",
|
|
833
|
-
outflows: call.value === 0n ? [] : [{
|
|
834
|
-
to: target,
|
|
1927
|
+
const decodeWrappedNative = (chainId, call, caller, table) => {
|
|
1928
|
+
const token = call.to === void 0 ? void 0 : lookupEvmToken(table, chainId, call.to);
|
|
1929
|
+
if (call.to === void 0 || token?.role !== "wrapped-native") return;
|
|
1930
|
+
if (call.data.toLowerCase() === AbiFunction.getSelector(DEPOSIT)) return {
|
|
1931
|
+
outflows: [{
|
|
1932
|
+
to: call.to,
|
|
835
1933
|
amount: {
|
|
836
1934
|
asset: EVM_NATIVE_ASSET,
|
|
837
1935
|
amount: call.value.toString(10)
|
|
838
1936
|
},
|
|
839
1937
|
verified: true
|
|
840
1938
|
}],
|
|
841
|
-
|
|
842
|
-
|
|
1939
|
+
minimumReceived: [{
|
|
1940
|
+
to: caller,
|
|
1941
|
+
amount: {
|
|
1942
|
+
asset: call.to,
|
|
1943
|
+
amount: call.value.toString(10),
|
|
1944
|
+
symbol: token.symbol,
|
|
1945
|
+
decimals: token.decimals
|
|
1946
|
+
}
|
|
1947
|
+
}]
|
|
1948
|
+
};
|
|
1949
|
+
const args = tryCall$1(WITHDRAW, call.data);
|
|
1950
|
+
if (args === void 0 || call.value !== 0n) return;
|
|
1951
|
+
const wad = argUint$1(args, 0);
|
|
1952
|
+
return {
|
|
1953
|
+
outflows: [{
|
|
1954
|
+
to: call.to,
|
|
1955
|
+
amount: {
|
|
1956
|
+
asset: call.to,
|
|
1957
|
+
amount: wad.toString(10),
|
|
1958
|
+
symbol: token.symbol,
|
|
1959
|
+
decimals: token.decimals
|
|
1960
|
+
},
|
|
1961
|
+
verified: true
|
|
1962
|
+
}],
|
|
1963
|
+
minimumReceived: [{
|
|
1964
|
+
to: caller,
|
|
1965
|
+
amount: {
|
|
1966
|
+
asset: EVM_NATIVE_ASSET,
|
|
1967
|
+
amount: wad.toString(10)
|
|
1968
|
+
}
|
|
1969
|
+
}]
|
|
843
1970
|
};
|
|
844
1971
|
};
|
|
845
1972
|
// src/evm/decode.ts
|
|
846
|
-
const ERC20_TRANSFER = AbiFunction.from("function transfer(address to, uint256 amount)");
|
|
847
|
-
const ERC20_APPROVE = AbiFunction.from("function approve(address spender, uint256 amount)");
|
|
848
|
-
const ERC20_INCREASE = AbiFunction.from("function increaseAllowance(address spender, uint256 amount)");
|
|
849
|
-
const ERC20_DECREASE = AbiFunction.from("function decreaseAllowance(address spender, uint256 subtractedValue)");
|
|
850
|
-
const SET_APPROVAL_FOR_ALL = AbiFunction.from("function setApprovalForAll(address operator, bool approved)");
|
|
851
1973
|
const PERMIT2_APPROVE = AbiFunction.from("function approve(address token, address spender, uint160 amount, uint48 expiration)");
|
|
852
1974
|
const PERMIT2_LOCKDOWN = AbiFunction.from("function lockdown((address token, address spender)[] approvals)");
|
|
853
|
-
const ERC721_SAFE_FROM_DATA = AbiFunction.from("function safeTransferFrom(address from, address to, uint256 tokenId, bytes data)");
|
|
854
|
-
const ERC1155_SAFE_BATCH_FROM = AbiFunction.from("function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data)");
|
|
855
|
-
const ERC721_TRANSFER_FROM = AbiFunction.from("function transferFrom(address from, address to, uint256 tokenId)");
|
|
856
|
-
const ERC721_SAFE_FROM = AbiFunction.from("function safeTransferFrom(address from, address to, uint256 tokenId)");
|
|
857
|
-
const ERC1155_SAFE_FROM = AbiFunction.from("function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data)");
|
|
858
1975
|
const argAddress = (args, index) => {
|
|
859
1976
|
const value = args[index];
|
|
860
1977
|
if (typeof value !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(value)) throw new ChainError("invalid-request", "decoded argument is not an address");
|
|
@@ -894,29 +2011,6 @@ const nativeOutflow = (value, to) => [{
|
|
|
894
2011
|
amount: weiAmount(value),
|
|
895
2012
|
verified: true
|
|
896
2013
|
}];
|
|
897
|
-
const tokenFlow = (target, to, amount, chainId, table) => {
|
|
898
|
-
const token = lookupEvmToken(table, chainId, target);
|
|
899
|
-
return {
|
|
900
|
-
flows: [{
|
|
901
|
-
to,
|
|
902
|
-
amount: {
|
|
903
|
-
asset: target,
|
|
904
|
-
amount: amount.toString(10),
|
|
905
|
-
...token === void 0 ? {} : {
|
|
906
|
-
symbol: token.symbol,
|
|
907
|
-
decimals: token.decimals
|
|
908
|
-
}
|
|
909
|
-
},
|
|
910
|
-
verified: token !== void 0
|
|
911
|
-
}],
|
|
912
|
-
verified: token !== void 0
|
|
913
|
-
};
|
|
914
|
-
};
|
|
915
|
-
const argBool = (args, index) => {
|
|
916
|
-
const value = args[index];
|
|
917
|
-
if (typeof value !== "boolean") throw new ChainError("invalid-request", "decoded argument is not a bool");
|
|
918
|
-
return value;
|
|
919
|
-
};
|
|
920
2014
|
const argList = (args, index) => {
|
|
921
2015
|
const value = args[index];
|
|
922
2016
|
if (!Array.isArray(value)) throw new ChainError("invalid-request", "decoded argument is not an array");
|
|
@@ -929,44 +2023,40 @@ const argSeconds = (args, index) => {
|
|
|
929
2023
|
};
|
|
930
2024
|
const pairField = (pair, key) => {
|
|
931
2025
|
const value = typeof pair === "object" && pair !== null ? Reflect.get(pair, key) : "";
|
|
932
|
-
|
|
2026
|
+
if (typeof value !== "string" || !/^0x[0-9a-fA-F]{40}$/.test(value)) throw new ChainError("invalid-request", "decoded argument is not an address");
|
|
2027
|
+
return checksumEvmAddress(value);
|
|
933
2028
|
};
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
amount: {
|
|
937
|
-
asset,
|
|
938
|
-
amount: value.toString(10),
|
|
939
|
-
tokenId: id.toString(10)
|
|
940
|
-
},
|
|
941
|
-
verified: false
|
|
942
|
-
}];
|
|
943
|
-
/**
|
|
944
|
-
* The call rules shared by a whole transaction and a Safe's inner calls: the same selector table
|
|
945
|
-
* produces the intent; `fee` is `undefined` for a call that is not itself a transaction.
|
|
946
|
-
*/
|
|
947
|
-
const decodeCall = (call, network, fee, table, signer) => {
|
|
2029
|
+
/** A call into a protocol the decoder models in full, native value included. */
|
|
2030
|
+
const protocolIntent = (call, { network, fee, table, signer, self }) => {
|
|
948
2031
|
const chainId = networkChainId(network);
|
|
949
|
-
const data = call.data.toLowerCase();
|
|
950
2032
|
const base = {
|
|
951
2033
|
family: "evm",
|
|
952
2034
|
network,
|
|
953
2035
|
approvals: [],
|
|
954
2036
|
warnings: []
|
|
955
2037
|
};
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
2038
|
+
const fiat24 = decodeFiat24(chainId, call, table);
|
|
2039
|
+
if (fiat24 !== void 0) {
|
|
2040
|
+
if (fiat24 === "claimed") {
|
|
2041
|
+
const reason = callNearMiss(call.to ?? "", chainId, table, call.data);
|
|
2042
|
+
return {
|
|
2043
|
+
...base,
|
|
2044
|
+
summary: "contract-call",
|
|
2045
|
+
outflows: call.value > 0n ? nativeOutflow(call.value, call.to ?? "") : [],
|
|
2046
|
+
fee,
|
|
2047
|
+
verifiability: "opaque",
|
|
2048
|
+
...reason === void 0 ? {} : { blind: reason }
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
const { decoded } = fiat24;
|
|
964
2052
|
return {
|
|
965
2053
|
...base,
|
|
966
|
-
summary:
|
|
967
|
-
outflows:
|
|
2054
|
+
summary: decoded.summary,
|
|
2055
|
+
outflows: decoded.outflows,
|
|
2056
|
+
warnings: decoded.warnings,
|
|
2057
|
+
...decoded.fiat24 === void 0 ? {} : { fiat24: decoded.fiat24 },
|
|
968
2058
|
fee,
|
|
969
|
-
verifiability: "
|
|
2059
|
+
verifiability: "partial"
|
|
970
2060
|
};
|
|
971
2061
|
}
|
|
972
2062
|
const zeroX = decodeZeroX(chainId, call, table);
|
|
@@ -992,7 +2082,26 @@ const decodeCall = (call, network, fee, table, signer) => {
|
|
|
992
2082
|
fee,
|
|
993
2083
|
verifiability: "partial"
|
|
994
2084
|
};
|
|
995
|
-
|
|
2085
|
+
if (isCctpMessenger(chainId, call.to)) {
|
|
2086
|
+
const cctp = decodeCctp(chainId, call, signer, table);
|
|
2087
|
+
if (cctp !== void 0) return {
|
|
2088
|
+
...base,
|
|
2089
|
+
summary: "transfer",
|
|
2090
|
+
outflows: cctp.outflows,
|
|
2091
|
+
hyperliquidDeposit: cctp.hyperliquidDeposit,
|
|
2092
|
+
fee,
|
|
2093
|
+
verifiability: "partial"
|
|
2094
|
+
};
|
|
2095
|
+
return {
|
|
2096
|
+
...base,
|
|
2097
|
+
summary: "contract-call",
|
|
2098
|
+
outflows: call.value > 0n ? nativeOutflow(call.value, call.to ?? "") : [],
|
|
2099
|
+
fee,
|
|
2100
|
+
verifiability: "opaque",
|
|
2101
|
+
blind: "cctp-destination"
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
const lido = decodeLido(chainId, call, self, table);
|
|
996
2105
|
if (lido !== void 0) return {
|
|
997
2106
|
...base,
|
|
998
2107
|
summary: "stake",
|
|
@@ -1001,17 +2110,27 @@ const decodeCall = (call, network, fee, table, signer) => {
|
|
|
1001
2110
|
fee,
|
|
1002
2111
|
verifiability: "partial"
|
|
1003
2112
|
};
|
|
1004
|
-
const
|
|
1005
|
-
if (
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
2113
|
+
const wrapped = decodeWrappedNative(chainId, call, self, table);
|
|
2114
|
+
if (wrapped !== void 0) return {
|
|
2115
|
+
...base,
|
|
2116
|
+
summary: "swap",
|
|
2117
|
+
outflows: wrapped.outflows,
|
|
2118
|
+
approvals: [],
|
|
2119
|
+
minimumReceived: wrapped.minimumReceived,
|
|
2120
|
+
fee,
|
|
2121
|
+
verifiability: "full"
|
|
2122
|
+
};
|
|
2123
|
+
};
|
|
2124
|
+
/** The token-standard selectors, else an opaque call. None of them accounts for native value. */
|
|
2125
|
+
const standardIntent = (call, { network, fee, table }) => {
|
|
2126
|
+
const chainId = networkChainId(network);
|
|
2127
|
+
const data = call.data.toLowerCase();
|
|
2128
|
+
const base = {
|
|
2129
|
+
family: "evm",
|
|
2130
|
+
network,
|
|
2131
|
+
approvals: [],
|
|
2132
|
+
warnings: []
|
|
2133
|
+
};
|
|
1015
2134
|
const partial = (summary, outflows, approvals) => ({
|
|
1016
2135
|
...base,
|
|
1017
2136
|
summary,
|
|
@@ -1033,44 +2152,15 @@ const decodeCall = (call, network, fee, table, signer) => {
|
|
|
1033
2152
|
const lockdownArgs = tryCall(PERMIT2_LOCKDOWN, data);
|
|
1034
2153
|
if (lockdownArgs !== void 0) return partial("approve", [], argList(lockdownArgs, 0).map((pair) => allowanceChange(pairField(pair, "token"), pairField(pair, "spender"), 0n, "set", MAX_UINT160, chainId, table, { via: "permit2" })));
|
|
1035
2154
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
if (operatorArgs !== void 0) return partial("approve", [], [{
|
|
1046
|
-
kind: "operator",
|
|
1047
|
-
asset: token,
|
|
1048
|
-
spender: argAddress(operatorArgs, 0),
|
|
1049
|
-
approved: argBool(operatorArgs, 1),
|
|
1050
|
-
verified: false
|
|
1051
|
-
}]);
|
|
1052
|
-
const transferFromArgs = tryCall(ERC721_TRANSFER_FROM, data);
|
|
1053
|
-
if (transferFromArgs !== void 0) {
|
|
1054
|
-
const to = argAddress(transferFromArgs, 1);
|
|
1055
|
-
const id = argUint(transferFromArgs, 2);
|
|
1056
|
-
if (lookupEvmToken(table, chainId, token) !== void 0) return partial("transfer", tokenFlow(token, to, id, chainId, table).flows, []);
|
|
1057
|
-
return partial("transfer", nftFlow(token, to, id), []);
|
|
1058
|
-
}
|
|
1059
|
-
for (const fn of [ERC721_SAFE_FROM, ERC721_SAFE_FROM_DATA]) {
|
|
1060
|
-
const args = tryCall(fn, data);
|
|
1061
|
-
if (args !== void 0) return partial("transfer", nftFlow(token, argAddress(args, 1), argUint(args, 2)), []);
|
|
1062
|
-
}
|
|
1063
|
-
const erc1155Args = tryCall(ERC1155_SAFE_FROM, data);
|
|
1064
|
-
if (erc1155Args !== void 0) return partial("transfer", nftFlow(token, argAddress(erc1155Args, 1), argUint(erc1155Args, 2), argUint(erc1155Args, 3)), []);
|
|
1065
|
-
const batchArgs = tryCall(ERC1155_SAFE_BATCH_FROM, data);
|
|
1066
|
-
if (batchArgs !== void 0) {
|
|
1067
|
-
const ids = argList(batchArgs, 2);
|
|
1068
|
-
const values = argList(batchArgs, 3);
|
|
1069
|
-
if (ids.length > 0 && ids.length === values.length) {
|
|
1070
|
-
const to = argAddress(batchArgs, 1);
|
|
1071
|
-
return partial("transfer", ids.flatMap((id, i) => nftFlow(token, to, argUint([id], 0), argUint([values[i] ?? 0n], 0))), []);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
2155
|
+
const tokenCall = decodeTokenCall(token, data, chainId, table);
|
|
2156
|
+
if (tokenCall !== void 0) return {
|
|
2157
|
+
...base,
|
|
2158
|
+
summary: tokenCall.summary,
|
|
2159
|
+
outflows: tokenCall.outflows,
|
|
2160
|
+
approvals: tokenCall.approvals,
|
|
2161
|
+
fee,
|
|
2162
|
+
verifiability: tokenCall.verifiability
|
|
2163
|
+
};
|
|
1074
2164
|
return {
|
|
1075
2165
|
...base,
|
|
1076
2166
|
summary: "contract-call",
|
|
@@ -1079,6 +2169,89 @@ const decodeCall = (call, network, fee, table, signer) => {
|
|
|
1079
2169
|
verifiability: "opaque"
|
|
1080
2170
|
};
|
|
1081
2171
|
};
|
|
2172
|
+
/**
|
|
2173
|
+
* Labels allowance approvals whose spender is a Fiat24 contract and raises the card-pull and
|
|
2174
|
+
* unlimited warnings. Runs on every decoded call, so batch and Safe inner calls get labelled the
|
|
2175
|
+
* same way.
|
|
2176
|
+
*/
|
|
2177
|
+
const labelFiat24Spenders = (intent, chainId) => {
|
|
2178
|
+
const extra = [];
|
|
2179
|
+
let labelled = false;
|
|
2180
|
+
const approvals = intent.approvals.map((change) => {
|
|
2181
|
+
if (change.kind !== "allowance") return change;
|
|
2182
|
+
const role = fiat24Spender(chainId, change.spender);
|
|
2183
|
+
if (role === void 0) return change;
|
|
2184
|
+
if (role === "card" && change.change !== "decrease" && BigInt(change.amount.amount) > 0n) extra.push({
|
|
2185
|
+
kind: "fiat24-card-pull",
|
|
2186
|
+
message: "card"
|
|
2187
|
+
});
|
|
2188
|
+
if (change.unlimited) extra.push({
|
|
2189
|
+
kind: "fiat24-unlimited-approval",
|
|
2190
|
+
level: "danger",
|
|
2191
|
+
message: role
|
|
2192
|
+
});
|
|
2193
|
+
labelled = true;
|
|
2194
|
+
return {
|
|
2195
|
+
...change,
|
|
2196
|
+
fiat24Spender: role
|
|
2197
|
+
};
|
|
2198
|
+
});
|
|
2199
|
+
return labelled ? {
|
|
2200
|
+
...intent,
|
|
2201
|
+
approvals,
|
|
2202
|
+
warnings: [...intent.warnings, ...extra]
|
|
2203
|
+
} : intent;
|
|
2204
|
+
};
|
|
2205
|
+
/**
|
|
2206
|
+
* The call rules shared by a whole transaction and a Safe's inner calls: the same selector table
|
|
2207
|
+
* produces the intent; `fee` is `undefined` for a call that is not itself a transaction. Native
|
|
2208
|
+
* value sent along with calldata is always an outflow to the contract that receives it.
|
|
2209
|
+
*/
|
|
2210
|
+
const decodeCall = (call, context) => {
|
|
2211
|
+
if (call.data === "0x" && call.to !== void 0) return {
|
|
2212
|
+
family: "evm",
|
|
2213
|
+
network: context.network,
|
|
2214
|
+
summary: "transfer",
|
|
2215
|
+
outflows: nativeOutflow(call.value, call.to),
|
|
2216
|
+
approvals: [],
|
|
2217
|
+
fee: context.fee,
|
|
2218
|
+
warnings: [],
|
|
2219
|
+
verifiability: "full"
|
|
2220
|
+
};
|
|
2221
|
+
const address = call.to ?? call.created;
|
|
2222
|
+
const token = call.to === void 0 ? void 0 : lookupEvmToken(context.table, networkChainId(context.network), call.to);
|
|
2223
|
+
const contract = address === void 0 ? {} : { contract: {
|
|
2224
|
+
address,
|
|
2225
|
+
created: call.to === void 0,
|
|
2226
|
+
...call.to === void 0 ? {} : { selector: call.data.slice(0, 10).toLowerCase() },
|
|
2227
|
+
...token === void 0 ? {} : { symbol: token.symbol }
|
|
2228
|
+
} };
|
|
2229
|
+
if (call.to !== void 0 && call.to.toLowerCase() === context.self.toLowerCase()) return {
|
|
2230
|
+
family: "evm",
|
|
2231
|
+
network: context.network,
|
|
2232
|
+
summary: "contract-call",
|
|
2233
|
+
outflows: call.value > 0n ? nativeOutflow(call.value, call.to ?? "") : [],
|
|
2234
|
+
approvals: [],
|
|
2235
|
+
fee: context.fee,
|
|
2236
|
+
warnings: [],
|
|
2237
|
+
verifiability: "opaque",
|
|
2238
|
+
blind: "account-code",
|
|
2239
|
+
...contract
|
|
2240
|
+
};
|
|
2241
|
+
const protocol = protocolIntent(call, context);
|
|
2242
|
+
if (protocol !== void 0) return labelFiat24Spenders({
|
|
2243
|
+
...protocol,
|
|
2244
|
+
...contract
|
|
2245
|
+
}, networkChainId(context.network));
|
|
2246
|
+
const standard = standardIntent(call, context);
|
|
2247
|
+
const nearMiss = standard.verifiability === "opaque" && call.to !== void 0 ? callNearMiss(call.to, networkChainId(context.network), context.table, call.data) : void 0;
|
|
2248
|
+
return labelFiat24Spenders({
|
|
2249
|
+
...standard,
|
|
2250
|
+
...contract,
|
|
2251
|
+
...nearMiss === void 0 ? {} : { blind: nearMiss },
|
|
2252
|
+
outflows: call.value > 0n && address !== void 0 ? [...nativeOutflow(call.value, address), ...standard.outflows] : standard.outflows
|
|
2253
|
+
}, networkChainId(context.network));
|
|
2254
|
+
};
|
|
1082
2255
|
/** The delegation field a request carries, present iff the transaction is eip7702. */
|
|
1083
2256
|
const delegationOf = (tx) => {
|
|
1084
2257
|
if (tx.type !== "eip7702") return;
|
|
@@ -1090,6 +2263,14 @@ const delegationOf = (tx) => {
|
|
|
1090
2263
|
};
|
|
1091
2264
|
};
|
|
1092
2265
|
const weakest = (intents) => intents.some((i) => i.verifiability === "opaque") ? "opaque" : intents.some((i) => i.verifiability === "partial") ? "partial" : "full";
|
|
2266
|
+
/** The address a contract creation from `signer` at `nonce` deploys to (CREATE). */
|
|
2267
|
+
const createdAddress = (signer, nonce) => {
|
|
2268
|
+
assertHex(signer, "signer");
|
|
2269
|
+
return checksumEvmAddress(ContractAddress.fromCreate({
|
|
2270
|
+
from: signer,
|
|
2271
|
+
nonce: BigInt(nonce)
|
|
2272
|
+
}));
|
|
2273
|
+
};
|
|
1093
2274
|
const decodeTransaction = (request, signer, table) => {
|
|
1094
2275
|
const { tx } = request;
|
|
1095
2276
|
const fee = { max: weiAmount(feeWei(tx)) };
|
|
@@ -1107,21 +2288,25 @@ const decodeTransaction = (request, signer, table) => {
|
|
|
1107
2288
|
summary: tx.type === "eip7702" ? "authorization" : "transfer"
|
|
1108
2289
|
};
|
|
1109
2290
|
const calls = isSelf ? decodeBatchExecute(tx.data) : void 0;
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
2291
|
+
const context = {
|
|
2292
|
+
network: request.network,
|
|
2293
|
+
table,
|
|
2294
|
+
signer,
|
|
2295
|
+
self: signer
|
|
2296
|
+
};
|
|
1115
2297
|
if (calls !== void 0 && calls.length > 0) {
|
|
1116
|
-
const decoded = calls.map((call) => decodeCall({
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
}, request.network, void 0, table, signer));
|
|
2298
|
+
const decoded = calls.map((call) => decodeCall(call, {
|
|
2299
|
+
...context,
|
|
2300
|
+
fee: void 0
|
|
2301
|
+
}));
|
|
1121
2302
|
const minimumReceived = decoded.flatMap((d) => d.minimumReceived ?? []);
|
|
1122
2303
|
const staking = decoded.flatMap((d) => d.staking ?? []);
|
|
2304
|
+
const blind = decoded.find((call) => call.blind !== void 0)?.blind;
|
|
1123
2305
|
return {
|
|
1124
|
-
|
|
2306
|
+
family: "evm",
|
|
2307
|
+
network: request.network,
|
|
2308
|
+
warnings: decoded.flatMap((d) => d.warnings),
|
|
2309
|
+
fee,
|
|
1125
2310
|
summary: "batch",
|
|
1126
2311
|
calls: decoded,
|
|
1127
2312
|
outflows: decoded.flatMap((d) => d.outflows),
|
|
@@ -1129,11 +2314,20 @@ const decodeTransaction = (request, signer, table) => {
|
|
|
1129
2314
|
...staking.length === 0 ? {} : { staking },
|
|
1130
2315
|
...minimumReceived.length === 0 ? {} : { minimumReceived },
|
|
1131
2316
|
verifiability: weakest(decoded),
|
|
2317
|
+
...blind === void 0 ? {} : { blind },
|
|
1132
2318
|
...delegation === void 0 ? {} : { delegation }
|
|
1133
2319
|
};
|
|
1134
2320
|
}
|
|
1135
2321
|
return {
|
|
1136
|
-
...
|
|
2322
|
+
...decodeCall({
|
|
2323
|
+
to: tx.to,
|
|
2324
|
+
...tx.to === void 0 ? { created: createdAddress(signer, tx.nonce) } : {},
|
|
2325
|
+
value: quantityBigInt(tx.value, "tx.value"),
|
|
2326
|
+
data: tx.data
|
|
2327
|
+
}, {
|
|
2328
|
+
...context,
|
|
2329
|
+
fee
|
|
2330
|
+
}),
|
|
1137
2331
|
...delegation === void 0 ? {} : { delegation }
|
|
1138
2332
|
};
|
|
1139
2333
|
};
|
|
@@ -1149,25 +2343,17 @@ const displayDomain = (domain) => {
|
|
|
1149
2343
|
...typeof salt === "string" ? { salt } : {}
|
|
1150
2344
|
};
|
|
1151
2345
|
};
|
|
1152
|
-
/**
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
signIn
|
|
1164
|
-
};
|
|
1165
|
-
} catch {
|
|
1166
|
-
return {
|
|
1167
|
-
kind: "bytes",
|
|
1168
|
-
hex: `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
2346
|
+
/**
|
|
2347
|
+
* The blind reason for a typed-data request, if any. Shown content is never truncated — an order
|
|
2348
|
+
* with more items than the prompt lists, or a document over the leaf budget, would silently
|
|
2349
|
+
* authorise what it hides, so it blinds the request instead. `unclaimed` is the blind the caller
|
|
2350
|
+
* computed for a document no recognised family decoded.
|
|
2351
|
+
*/
|
|
2352
|
+
const typedDataBlind = (safe, seaport, app, unclaimed) => {
|
|
2353
|
+
if (safe !== void 0) return safe.safe.calls.find((call) => call.blind !== void 0)?.blind ?? (safe.safe.refund === void 0 ? void 0 : "safe-refund-unbounded");
|
|
2354
|
+
if (seaport !== void 0) return seaport.offer.length > 8 || seaport.consideration.length > 8 ? "typed-data-oversize" : void 0;
|
|
2355
|
+
if (app !== void 0) return app.blind;
|
|
2356
|
+
return unclaimed;
|
|
1171
2357
|
};
|
|
1172
2358
|
/** What the signer can guarantee about this request (WD-065). */
|
|
1173
2359
|
const verifiabilityEvm = (request, signer) => decodeEvm(request, signer).verifiability;
|
|
@@ -1176,51 +2362,116 @@ const verifiabilityEvm = (request, signer) => decodeEvm(request, signer).verifia
|
|
|
1176
2362
|
* account; the token table parameter is for tests.
|
|
1177
2363
|
*/
|
|
1178
2364
|
const decodeEvm = (request, signer, table = evmTokenTable) => {
|
|
1179
|
-
if (request.kind === "evm.transaction") return decodeTransaction(request, signer, table);
|
|
1180
|
-
if (request.kind === "evm.personal-message")
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
2365
|
+
if (request.kind === "evm.transaction") return withNativeAmountMeta(decodeTransaction(request, signer, table), request.network, EVM_NATIVE_ASSET, 18);
|
|
2366
|
+
if (request.kind === "evm.personal-message") {
|
|
2367
|
+
const content = messageContent(request.message, "evm");
|
|
2368
|
+
const blind = (content.kind === "text" ? personalMessageNearMiss(content.text) : void 0) ?? messageBlindReason(content);
|
|
2369
|
+
return {
|
|
2370
|
+
family: "evm",
|
|
2371
|
+
network: request.network,
|
|
2372
|
+
summary: "message",
|
|
2373
|
+
outflows: [],
|
|
2374
|
+
approvals: [],
|
|
2375
|
+
fee: void 0,
|
|
2376
|
+
warnings: [],
|
|
2377
|
+
message: content,
|
|
2378
|
+
verifiability: "opaque",
|
|
2379
|
+
...blind === void 0 ? {} : { blind }
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
if (request.kind === "evm.fiat24-session") {
|
|
2383
|
+
const chainId = networkChainId(request.network);
|
|
2384
|
+
return {
|
|
2385
|
+
family: "evm",
|
|
2386
|
+
network: request.network,
|
|
2387
|
+
summary: "message",
|
|
2388
|
+
outflows: [],
|
|
2389
|
+
approvals: [],
|
|
2390
|
+
fee: void 0,
|
|
2391
|
+
warnings: [],
|
|
2392
|
+
message: {
|
|
2393
|
+
kind: "text",
|
|
2394
|
+
text: fiat24SessionMessage(chainId, request.tokenId, request.deadline)
|
|
2395
|
+
},
|
|
2396
|
+
fiat24: {
|
|
2397
|
+
kind: "session-grant",
|
|
2398
|
+
account: request.tokenId,
|
|
2399
|
+
deadline: request.deadline
|
|
2400
|
+
},
|
|
2401
|
+
verifiability: "partial"
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
1191
2404
|
if (request.kind !== "evm.typed-data") throw new ChainError("unsupported", `unsupported sign request kind: ${request.kind}`);
|
|
1192
2405
|
const { json } = parseTypedData(request.typedData);
|
|
1193
2406
|
assertNoExecutionGrant(json.domain, signer);
|
|
1194
2407
|
const chainId = networkChainId(request.network);
|
|
1195
|
-
const permit = recognizePermit(json, chainId, table);
|
|
1196
|
-
const
|
|
1197
|
-
const
|
|
2408
|
+
const permit = recognizePermit(json, chainId, table, signer);
|
|
2409
|
+
const claimed = permit === void 0 ? recognizeEip3009(json, chainId, table, signer) ?? recognizeAuthority(json, chainId, table, signer) ?? recognizeFarcaster(json, chainId, signer) : void 0;
|
|
2410
|
+
const seaport = permit === void 0 && claimed === void 0 ? recognizeSeaport(json, chainId, table) : void 0;
|
|
2411
|
+
const safe = permit === void 0 && claimed === void 0 && seaport === void 0 ? recognizeSafe(json, {
|
|
2412
|
+
network: request.network,
|
|
2413
|
+
chainId,
|
|
2414
|
+
table
|
|
2415
|
+
}, (call, safeAddress) => decodeCall(call, {
|
|
2416
|
+
network: request.network,
|
|
2417
|
+
fee: void 0,
|
|
2418
|
+
table,
|
|
2419
|
+
signer,
|
|
2420
|
+
self: safeAddress
|
|
2421
|
+
})) : void 0;
|
|
2422
|
+
const app = permit === void 0 && claimed === void 0 && seaport === void 0 && safe === void 0 ? recognizeApp(json, {
|
|
2423
|
+
network: request.network,
|
|
2424
|
+
chainId,
|
|
2425
|
+
table,
|
|
2426
|
+
signer
|
|
2427
|
+
}, (call, self) => decodeCall(call, {
|
|
2428
|
+
network: request.network,
|
|
2429
|
+
fee: void 0,
|
|
2430
|
+
table,
|
|
2431
|
+
signer,
|
|
2432
|
+
self
|
|
2433
|
+
})) : void 0;
|
|
2434
|
+
const order = permit === void 0 && claimed === void 0 ? seaport === void 0 && safe === void 0 && app === void 0 ? recognizeCow(json, chainId, signer, table) ?? recognizeOneinch(json, chainId, table) : void 0 : permit?.order;
|
|
2435
|
+
const snapshot = permit === void 0 && claimed === void 0 && seaport === void 0 && safe === void 0 && app === void 0 && order === void 0 ? recognizeSnapshot(json, signer) : void 0;
|
|
2436
|
+
const unclaimed = permit === void 0 && claimed === void 0 && seaport === void 0 && safe === void 0 && app === void 0 && order === void 0 && snapshot === void 0;
|
|
2437
|
+
const recognized = claimed ?? (snapshot?.kind === "alias" ? snapshot : void 0);
|
|
2438
|
+
const nearMiss = unclaimed ? typedDataNearMiss(json, chainId, table) : void 0;
|
|
2439
|
+
const shown = unclaimed || snapshot?.kind === "vote" ? typedDataFields(json) : void 0;
|
|
2440
|
+
const fields = shown?.fields;
|
|
2441
|
+
const unclaimedBlind = nearMiss ?? (unclaimed || snapshot?.kind === "vote" ? shown === void 0 ? "typed-data-oversize" : unclaimed && shown.hasCommitment ? "typed-data-commitment" : void 0 : void 0);
|
|
2442
|
+
const blind = permit?.blind ?? typedDataBlind(safe, seaport, app, unclaimedBlind) ?? (typedDataHasHiddenText(json) ? "message-bytes" : void 0);
|
|
1198
2443
|
const message = {
|
|
1199
2444
|
kind: "typed-data",
|
|
1200
2445
|
primaryType: json.primaryType,
|
|
1201
2446
|
domain: displayDomain(json.domain),
|
|
1202
2447
|
data: json.message,
|
|
1203
2448
|
...seaport === void 0 ? {} : { seaport },
|
|
1204
|
-
...
|
|
2449
|
+
...order === void 0 ? {} : { order },
|
|
2450
|
+
...safe === void 0 ? {} : { safe: safe.safe },
|
|
2451
|
+
...app === void 0 ? {} : app.content,
|
|
2452
|
+
...recognized === void 0 ? {} : recognized.content,
|
|
2453
|
+
...fields === void 0 ? {} : { fields },
|
|
2454
|
+
...permit?.fields === void 0 ? {} : { fields: permit.fields }
|
|
1205
2455
|
};
|
|
1206
|
-
const summary = seaport
|
|
1207
|
-
return {
|
|
2456
|
+
const summary = recognized?.summary ?? (order !== void 0 || seaport !== void 0 ? "swap" : safe === void 0 ? permit === void 0 ? app?.summary ?? "message" : "approve" : safe.multisend ? "batch" : safe.safe.calls[0]?.summary ?? "contract-call");
|
|
2457
|
+
return withNativeAmountMeta({
|
|
1208
2458
|
family: "evm",
|
|
1209
2459
|
network: request.network,
|
|
1210
2460
|
summary,
|
|
1211
|
-
outflows: [],
|
|
1212
|
-
approvals: permit?.approvals ?? [],
|
|
2461
|
+
outflows: recognized?.outflows ?? app?.outflows ?? [],
|
|
2462
|
+
approvals: permit?.approvals ?? app?.approvals ?? [],
|
|
1213
2463
|
fee: void 0,
|
|
1214
|
-
warnings: permit?.warnings ?? [],
|
|
2464
|
+
warnings: permit?.warnings ?? app?.warnings ?? [],
|
|
1215
2465
|
message,
|
|
1216
|
-
verifiability: permit === void 0 ? "opaque" : "partial"
|
|
1217
|
-
|
|
2466
|
+
verifiability: recognized?.verifiability ?? app?.verifiability ?? (permit === void 0 && order === void 0 ? "opaque" : "partial"),
|
|
2467
|
+
...blind === void 0 ? {} : { blind }
|
|
2468
|
+
}, request.network, EVM_NATIVE_ASSET, 18);
|
|
1218
2469
|
};
|
|
1219
2470
|
// src/evm/recover.ts
|
|
1220
2471
|
/**
|
|
1221
|
-
* Signer recovery for `chain.sign` results: the host re-derives the signer address
|
|
1222
|
-
*
|
|
1223
|
-
* kernel returning someone else's signature fails closed.
|
|
2472
|
+
* Signer recovery for `chain.sign` results: the host re-derives the signer address of the requested
|
|
2473
|
+
* transaction, message or typed data and compares it with the account's `wallet.accounts` address —
|
|
2474
|
+
* a kernel returning someone else's signature, or a signature over other content, fails closed.
|
|
1224
2475
|
*/
|
|
1225
2476
|
function assertEip1559Hex(hex) {
|
|
1226
2477
|
if (!hex.startsWith("0x02")) throw new ChainError("invalid-request", "unrecognized signed transaction envelope");
|
|
@@ -1240,64 +2491,59 @@ const signatureOf = (env) => {
|
|
|
1240
2491
|
yParity
|
|
1241
2492
|
});
|
|
1242
2493
|
};
|
|
1243
|
-
/**
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
2494
|
+
/**
|
|
2495
|
+
* The transaction signature and, for EIP-7702, the authorization signature a signed envelope
|
|
2496
|
+
* carries.
|
|
2497
|
+
*/
|
|
2498
|
+
const signaturesOf = (hex) => {
|
|
2499
|
+
if (hex.startsWith("0x04")) {
|
|
1248
2500
|
assertEip7702Hex(hex);
|
|
1249
2501
|
const env = TxEnvelopeEip7702.deserialize(hex);
|
|
1250
|
-
const payload = TxEnvelopeEip7702.getSignPayload(env);
|
|
1251
|
-
const signer = Secp256k1.recoverAddress({
|
|
1252
|
-
payload,
|
|
1253
|
-
signature: signatureOf(env)
|
|
1254
|
-
});
|
|
1255
2502
|
const auths = env.authorizationList ?? [];
|
|
1256
2503
|
const [auth] = auths;
|
|
1257
|
-
if (
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
payload: Authorization.getSignPayload({
|
|
1263
|
-
address,
|
|
1264
|
-
chainId,
|
|
1265
|
-
nonce
|
|
1266
|
-
}),
|
|
1267
|
-
signature: Signature.from(auth)
|
|
1268
|
-
}).toLowerCase() !== signer.toLowerCase()) throw new ChainError("invalid-request", "authorization signer is not the account");
|
|
1269
|
-
return signer;
|
|
2504
|
+
if (auths.length !== 1 || auth === void 0) throw new ChainError("invalid-request", "authorization does not match the request");
|
|
2505
|
+
return {
|
|
2506
|
+
signature: signatureOf(env),
|
|
2507
|
+
authorization: Signature.from(auth)
|
|
2508
|
+
};
|
|
1270
2509
|
}
|
|
1271
|
-
if (
|
|
2510
|
+
if (hex.startsWith("0x02")) {
|
|
1272
2511
|
assertEip1559Hex(hex);
|
|
1273
|
-
|
|
1274
|
-
const payload = TxEnvelopeEip1559.getSignPayload(env);
|
|
1275
|
-
return Secp256k1.recoverAddress({
|
|
1276
|
-
payload,
|
|
1277
|
-
signature: signatureOf(env)
|
|
1278
|
-
});
|
|
2512
|
+
return { signature: signatureOf(TxEnvelopeEip1559.deserialize(hex)) };
|
|
1279
2513
|
}
|
|
1280
|
-
if (
|
|
2514
|
+
if (hex.startsWith("0x01")) {
|
|
1281
2515
|
assertEip2930Hex(hex);
|
|
1282
|
-
|
|
1283
|
-
const payload = TxEnvelopeEip2930.getSignPayload(env);
|
|
1284
|
-
return Secp256k1.recoverAddress({
|
|
1285
|
-
payload,
|
|
1286
|
-
signature: signatureOf(env)
|
|
1287
|
-
});
|
|
2516
|
+
return { signature: signatureOf(TxEnvelopeEip2930.deserialize(hex)) };
|
|
1288
2517
|
}
|
|
1289
2518
|
try {
|
|
1290
|
-
|
|
1291
|
-
const payload = TxEnvelopeLegacy.getSignPayload(env);
|
|
1292
|
-
return Secp256k1.recoverAddress({
|
|
1293
|
-
payload,
|
|
1294
|
-
signature: signatureOf(env)
|
|
1295
|
-
});
|
|
2519
|
+
return { signature: signatureOf(TxEnvelopeLegacy.deserialize(hex)) };
|
|
1296
2520
|
} catch {
|
|
1297
2521
|
throw new ChainError("invalid-request", "unrecognized signed transaction envelope");
|
|
1298
2522
|
}
|
|
1299
2523
|
};
|
|
1300
2524
|
/**
|
|
2525
|
+
* The signer of `signedTransaction`, which must be exactly `request.tx` under its signature: the
|
|
2526
|
+
* envelope is rebuilt from the request, re-serialized with the returned signatures and compared
|
|
2527
|
+
* byte for byte, so a valid signature by the account over any other transaction is refused.
|
|
2528
|
+
*/
|
|
2529
|
+
const signerFromEnvelope = (signedTransaction, request) => {
|
|
2530
|
+
const hex = Hex.fromBytes(signedTransaction);
|
|
2531
|
+
const { signature, authorization } = signaturesOf(hex);
|
|
2532
|
+
const expected = evmEnvelope(request.tx, authorization);
|
|
2533
|
+
if (expected.serialize(signature).toLowerCase() !== hex) throw new ChainError("invalid-request", "the signed transaction does not match the request");
|
|
2534
|
+
const signer = Secp256k1.recoverAddress({
|
|
2535
|
+
payload: expected.payload,
|
|
2536
|
+
signature
|
|
2537
|
+
});
|
|
2538
|
+
if (request.tx.type === "eip7702" && authorization !== void 0) {
|
|
2539
|
+
if (Secp256k1.recoverAddress({
|
|
2540
|
+
payload: Authorization.getSignPayload(evmAuthorization(request.tx)),
|
|
2541
|
+
signature: authorization
|
|
2542
|
+
}).toLowerCase() !== signer.toLowerCase()) throw new ChainError("invalid-request", "authorization signer is not the account");
|
|
2543
|
+
}
|
|
2544
|
+
return signer;
|
|
2545
|
+
};
|
|
2546
|
+
/**
|
|
1301
2547
|
* The EIP-55 address that produced `result` for `request` — a `chain.sign` round-trip check
|
|
1302
2548
|
* (`{kind:"evm.transaction",signedTransaction}` | `{kind,signature}`).
|
|
1303
2549
|
*/
|
|
@@ -1315,6 +2561,14 @@ const recoverEvmSigner = (request, result) => {
|
|
|
1315
2561
|
signature
|
|
1316
2562
|
});
|
|
1317
2563
|
}
|
|
2564
|
+
if (request.kind === "evm.fiat24-session") {
|
|
2565
|
+
const message = fiat24SessionMessage(networkChainId(request.network), request.tokenId, request.deadline);
|
|
2566
|
+
const payload = PersonalMessage.getSignPayload(Hex.fromBytes(utf8ToBytes(message)));
|
|
2567
|
+
return Secp256k1.recoverAddress({
|
|
2568
|
+
payload,
|
|
2569
|
+
signature
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
1318
2572
|
if (request.kind === "evm.typed-data") {
|
|
1319
2573
|
const { json } = parseTypedData(request.typedData);
|
|
1320
2574
|
const payload = TypedData.getSignPayload(json);
|
|
@@ -1325,6 +2579,202 @@ const recoverEvmSigner = (request, result) => {
|
|
|
1325
2579
|
}
|
|
1326
2580
|
throw new ChainError("unsupported", `cannot recover a signer for ${request.kind}`);
|
|
1327
2581
|
};
|
|
2582
|
+
// src/evm/msgpack.ts
|
|
2583
|
+
const utf8 = new TextEncoder();
|
|
2584
|
+
function concat(...chunks) {
|
|
2585
|
+
let length = 0;
|
|
2586
|
+
for (const chunk of chunks) length += chunk.length;
|
|
2587
|
+
const out = new Uint8Array(length);
|
|
2588
|
+
let offset = 0;
|
|
2589
|
+
for (const chunk of chunks) {
|
|
2590
|
+
out.set(chunk, offset);
|
|
2591
|
+
offset += chunk.length;
|
|
2592
|
+
}
|
|
2593
|
+
return out;
|
|
2594
|
+
}
|
|
2595
|
+
const u16be = (value) => {
|
|
2596
|
+
const out = /* @__PURE__ */ new Uint8Array(2);
|
|
2597
|
+
new DataView(out.buffer).setUint16(0, value);
|
|
2598
|
+
return out;
|
|
2599
|
+
};
|
|
2600
|
+
const u32be = (value) => {
|
|
2601
|
+
const out = /* @__PURE__ */ new Uint8Array(4);
|
|
2602
|
+
new DataView(out.buffer).setUint32(0, value);
|
|
2603
|
+
return out;
|
|
2604
|
+
};
|
|
2605
|
+
const i64be = (value) => {
|
|
2606
|
+
const out = /* @__PURE__ */ new Uint8Array(8);
|
|
2607
|
+
new DataView(out.buffer).setBigInt64(0, value);
|
|
2608
|
+
return out;
|
|
2609
|
+
};
|
|
2610
|
+
const u64be = (value) => {
|
|
2611
|
+
const out = /* @__PURE__ */ new Uint8Array(8);
|
|
2612
|
+
new DataView(out.buffer).setBigUint64(0, value);
|
|
2613
|
+
return out;
|
|
2614
|
+
};
|
|
2615
|
+
/** Safe integers only — the L1 schemas bound every numeric field well inside them. */
|
|
2616
|
+
function packInt(value) {
|
|
2617
|
+
if (!Number.isSafeInteger(value)) throw new ChainError("invalid-request", "unreachable: non-integer msgpack field");
|
|
2618
|
+
if (value >= 0) {
|
|
2619
|
+
if (value <= 127) return new Uint8Array([value]);
|
|
2620
|
+
if (value <= 255) return new Uint8Array([204, value]);
|
|
2621
|
+
if (value <= 65535) return concat(new Uint8Array([205]), u16be(value));
|
|
2622
|
+
if (value <= 4294967295) return concat(new Uint8Array([206]), u32be(value));
|
|
2623
|
+
return concat(new Uint8Array([207]), u64be(BigInt(value)));
|
|
2624
|
+
}
|
|
2625
|
+
if (value >= -32) return new Uint8Array([value + 256]);
|
|
2626
|
+
if (value >= -128) return new Uint8Array([208, value + 256]);
|
|
2627
|
+
if (value >= -32768) return concat(new Uint8Array([209]), u16be(value + 65536));
|
|
2628
|
+
if (value >= -2147483648) return concat(new Uint8Array([210]), u32be(value + 4294967296));
|
|
2629
|
+
return concat(new Uint8Array([211]), i64be(BigInt(value)));
|
|
2630
|
+
}
|
|
2631
|
+
function packStr(value) {
|
|
2632
|
+
const bytes = utf8.encode(value);
|
|
2633
|
+
const { length } = bytes;
|
|
2634
|
+
if (length < 32) return concat(new Uint8Array([160 | length]), bytes);
|
|
2635
|
+
if (length < 256) return concat(new Uint8Array([217, length]), bytes);
|
|
2636
|
+
if (length < 65536) return concat(new Uint8Array([218]), u16be(length), bytes);
|
|
2637
|
+
return concat(new Uint8Array([219]), u32be(length), bytes);
|
|
2638
|
+
}
|
|
2639
|
+
function packBool(value) {
|
|
2640
|
+
return new Uint8Array([value ? 195 : 194]);
|
|
2641
|
+
}
|
|
2642
|
+
function packArray(items) {
|
|
2643
|
+
return concat(items.length < 16 ? new Uint8Array([144 | items.length]) : items.length < 65536 ? concat(new Uint8Array([220]), u16be(items.length)) : (() => {
|
|
2644
|
+
throw new ChainError("invalid-request", "unreachable: msgpack array over 65535 items");
|
|
2645
|
+
})(), ...items);
|
|
2646
|
+
}
|
|
2647
|
+
function packMap(entries) {
|
|
2648
|
+
return concat(entries.length < 16 ? new Uint8Array([128 | entries.length]) : entries.length < 65536 ? concat(new Uint8Array([222]), u16be(entries.length)) : (() => {
|
|
2649
|
+
throw new ChainError("invalid-request", "unreachable: msgpack map over 65535 entries");
|
|
2650
|
+
})(), ...entries.flatMap(([key, value]) => [packStr(key), value]));
|
|
2651
|
+
}
|
|
2652
|
+
// src/evm/hyperliquid-l1.ts
|
|
2653
|
+
/** The order-wire map, H2-T order: a,b,p,s,r,t,c? — `c` only when present. */
|
|
2654
|
+
const orderWire = (order) => {
|
|
2655
|
+
const t = "limit" in order.t ? packMap([["limit", packMap([["tif", packStr(order.t.limit.tif)]])]]) : packMap([["trigger", packMap([
|
|
2656
|
+
["isMarket", packBool(order.t.trigger.isMarket)],
|
|
2657
|
+
["triggerPx", packStr(order.t.trigger.triggerPx)],
|
|
2658
|
+
["tpsl", packStr(order.t.trigger.tpsl)]
|
|
2659
|
+
])]]);
|
|
2660
|
+
const entries = [
|
|
2661
|
+
["a", packInt(order.a)],
|
|
2662
|
+
["b", packBool(order.b)],
|
|
2663
|
+
["p", packStr(order.p)],
|
|
2664
|
+
["s", packStr(order.s)],
|
|
2665
|
+
["r", packBool(order.r)],
|
|
2666
|
+
["t", t]
|
|
2667
|
+
];
|
|
2668
|
+
if (order.c !== void 0) entries.push(["c", packStr(order.c)]);
|
|
2669
|
+
return packMap(entries);
|
|
2670
|
+
};
|
|
2671
|
+
const packOid = (oid) => typeof oid === "number" ? packInt(oid) : packStr(oid);
|
|
2672
|
+
const optFlag = (entries, key, flag) => {
|
|
2673
|
+
if (flag !== void 0) entries.push([key, packBool(flag)]);
|
|
2674
|
+
return packMap(entries);
|
|
2675
|
+
};
|
|
2676
|
+
function encodeL1Action(action) {
|
|
2677
|
+
switch (action.type) {
|
|
2678
|
+
case "order": {
|
|
2679
|
+
const entries = [
|
|
2680
|
+
["type", packStr("order")],
|
|
2681
|
+
["orders", packArray(action.orders.map(orderWire))],
|
|
2682
|
+
["grouping", packStr(action.grouping)]
|
|
2683
|
+
];
|
|
2684
|
+
if (action.builder !== void 0) entries.push(["builder", packMap([["b", packStr(action.builder.b)], ["f", packInt(action.builder.f)]])]);
|
|
2685
|
+
return packMap(entries);
|
|
2686
|
+
}
|
|
2687
|
+
case "cancel": {
|
|
2688
|
+
const entries = [["type", packStr("cancel")], ["cancels", packArray(action.cancels.map((cancel) => packMap([["a", packInt(cancel.a)], ["o", packInt(cancel.o)]])))]];
|
|
2689
|
+
return optFlag(entries, "f", action.f);
|
|
2690
|
+
}
|
|
2691
|
+
case "cancelByCloid": {
|
|
2692
|
+
const entries = [["type", packStr("cancelByCloid")], ["cancels", packArray(action.cancels.map((cancel) => packMap([["asset", packInt(cancel.asset)], ["cloid", packStr(cancel.cloid)]])))]];
|
|
2693
|
+
return optFlag(entries, "f", action.f);
|
|
2694
|
+
}
|
|
2695
|
+
case "modify": {
|
|
2696
|
+
const entries = [
|
|
2697
|
+
["type", packStr("modify")],
|
|
2698
|
+
["oid", packOid(action.oid)],
|
|
2699
|
+
["order", orderWire(action.order)]
|
|
2700
|
+
];
|
|
2701
|
+
return optFlag(entries, "a", action.a);
|
|
2702
|
+
}
|
|
2703
|
+
case "batchModify": {
|
|
2704
|
+
const entries = [["type", packStr("batchModify")], ["modifies", packArray(action.modifies.map((modify) => packMap([["oid", packOid(modify.oid)], ["order", orderWire(modify.order)]])))]];
|
|
2705
|
+
return optFlag(entries, "a", action.a);
|
|
2706
|
+
}
|
|
2707
|
+
case "updateLeverage": return packMap([
|
|
2708
|
+
["type", packStr("updateLeverage")],
|
|
2709
|
+
["asset", packInt(action.asset)],
|
|
2710
|
+
["isCross", packBool(action.isCross)],
|
|
2711
|
+
["leverage", packInt(action.leverage)]
|
|
2712
|
+
]);
|
|
2713
|
+
case "updateIsolatedMargin": return packMap([
|
|
2714
|
+
["type", packStr("updateIsolatedMargin")],
|
|
2715
|
+
["asset", packInt(action.asset)],
|
|
2716
|
+
["isBuy", packBool(action.isBuy)],
|
|
2717
|
+
["ntli", packInt(action.ntli)]
|
|
2718
|
+
]);
|
|
2719
|
+
case "twapCancel": return packMap([
|
|
2720
|
+
["type", packStr("twapCancel")],
|
|
2721
|
+
["a", packInt(action.a)],
|
|
2722
|
+
["t", packInt(action.t)]
|
|
2723
|
+
]);
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
function l1ConnectionId(args) {
|
|
2727
|
+
const packed = encodeL1Action(args.action);
|
|
2728
|
+
const vault = args.vaultAddress === void 0 ? new Uint8Array([0]) : concat(new Uint8Array([1]), hexToBytes(args.vaultAddress.slice(2)));
|
|
2729
|
+
const expiry = args.expiresAfter === void 0 ? /* @__PURE__ */ new Uint8Array(0) : concat(new Uint8Array([0]), u64be(BigInt(args.expiresAfter)));
|
|
2730
|
+
return keccak_256(concat(packed, u64be(BigInt(args.nonce)), vault, expiry));
|
|
2731
|
+
}
|
|
2732
|
+
function phantomAgentTypedData(connectionId, network) {
|
|
2733
|
+
return JSON.stringify({
|
|
2734
|
+
types: {
|
|
2735
|
+
EIP712Domain: [
|
|
2736
|
+
{
|
|
2737
|
+
name: "name",
|
|
2738
|
+
type: "string"
|
|
2739
|
+
},
|
|
2740
|
+
{
|
|
2741
|
+
name: "version",
|
|
2742
|
+
type: "string"
|
|
2743
|
+
},
|
|
2744
|
+
{
|
|
2745
|
+
name: "chainId",
|
|
2746
|
+
type: "uint256"
|
|
2747
|
+
},
|
|
2748
|
+
{
|
|
2749
|
+
name: "verifyingContract",
|
|
2750
|
+
type: "address"
|
|
2751
|
+
}
|
|
2752
|
+
],
|
|
2753
|
+
Agent: [{
|
|
2754
|
+
name: "source",
|
|
2755
|
+
type: "string"
|
|
2756
|
+
}, {
|
|
2757
|
+
name: "connectionId",
|
|
2758
|
+
type: "bytes32"
|
|
2759
|
+
}]
|
|
2760
|
+
},
|
|
2761
|
+
primaryType: "Agent",
|
|
2762
|
+
domain: {
|
|
2763
|
+
name: "Exchange",
|
|
2764
|
+
version: "1",
|
|
2765
|
+
chainId: 1337,
|
|
2766
|
+
verifyingContract: "0x0000000000000000000000000000000000000000"
|
|
2767
|
+
},
|
|
2768
|
+
message: {
|
|
2769
|
+
source: network === "Mainnet" ? "a" : "b",
|
|
2770
|
+
connectionId: `0x${bytesToHex(connectionId)}`
|
|
2771
|
+
}
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
/** The phantom-agent typed-data JSON an L1 `params` signs, shared by kernel and host. */
|
|
2775
|
+
function hyperliquidL1Document(params, network) {
|
|
2776
|
+
return phantomAgentTypedData(l1ConnectionId(params), network);
|
|
2777
|
+
}
|
|
1328
2778
|
// src/evm/index.ts
|
|
1329
2779
|
/**
|
|
1330
2780
|
* Normalizes a SignRequest for the EVM family: exact key sets, chainId vs the CAIP-2 `network`,
|
|
@@ -1354,6 +2804,19 @@ const normalizeEvm = (request) => {
|
|
|
1354
2804
|
message
|
|
1355
2805
|
};
|
|
1356
2806
|
}
|
|
2807
|
+
if (request["kind"] === "evm.fiat24-session") {
|
|
2808
|
+
if (chainId !== 42161) throw new ChainError("unsupported", `fiat24 sessions exist only on eip155:${FIAT24_CHAIN}`);
|
|
2809
|
+
const { tokenId, deadline } = request;
|
|
2810
|
+
if (typeof tokenId !== "string" || !/^[1-9][0-9]*$/.test(tokenId) || BigInt(tokenId) > MAX_UINT256) throw new ChainError("invalid-request", "fiat24-session tokenId is not a canonical id");
|
|
2811
|
+
if (typeof deadline !== "number" || !Number.isSafeInteger(deadline) || deadline < 1) throw new ChainError("invalid-request", "fiat24-session deadline must be a positive integer");
|
|
2812
|
+
return {
|
|
2813
|
+
kind: "evm.fiat24-session",
|
|
2814
|
+
network,
|
|
2815
|
+
account,
|
|
2816
|
+
tokenId,
|
|
2817
|
+
deadline
|
|
2818
|
+
};
|
|
2819
|
+
}
|
|
1357
2820
|
if (request["kind"] === "evm.typed-data") {
|
|
1358
2821
|
const { typedData } = request;
|
|
1359
2822
|
if (typeof typedData !== "string") throw new ChainError("invalid-request", "typed-data payload must be the JSON source string");
|
|
@@ -1369,6 +2832,6 @@ const normalizeEvm = (request) => {
|
|
|
1369
2832
|
}
|
|
1370
2833
|
throw new ChainError("unsupported", `unsupported sign request kind: ${request["kind"]}`);
|
|
1371
2834
|
};
|
|
1372
|
-
export { ACROSS_SPOKEPOOLS, ACROSS_WRAPPED_NATIVE, ALLOWANCE_HOLDER, DELEGATION_MANAGER, ENTRY_POINT_V08, EVM_DELEGATION_PREFIX, EVM_DELEGATOR, EVM_NATIVE_ASSET, LIDO_CHAIN, LIDO_QUEUE, LIDO_STETH, LIDO_WSTETH, MAX_UINT256, PERMIT2_ADDRESS, SAFE_MULTISEND_CALL_ONLY, ZEROX_CHAINS, assertNoExecutionGrant, canonicalHex, checksumEvmAddress, decodeAcross, decodeBatchExecute, decodeEvm, decodeZeroX, encodeBatchExecute, evmAddressFromPublicKey, evmTokenTable, isCanonicalHex, isEvmAddress, isZeroExSettler, lookupEvmToken, networkChainId, normalizeEvm, normalizeEvmTransaction, parseTypedData, recoverEvmSigner, verifiabilityEvm };
|
|
2835
|
+
export { ACROSS_SPOKEPOOLS, ACROSS_WRAPPED_NATIVE, ALLOWANCE_HOLDER, CCTP_FORWARDERS, CCTP_MESSENGERS, CCTP_USDC, DELEGATION_MANAGER, ENTRY_POINT_V08, EVM_DELEGATION_PREFIX, EVM_DELEGATOR, EVM_NATIVE_ASSET, FIAT24_CHAIN, HYPERLIQUID_DOMAIN, LIDO_CHAIN, LIDO_QUEUE, LIDO_STETH, LIDO_WSTETH, MAX_UINT256, ORDER_ITEMS, PERMIT2_ADDRESS, SAFE_MULTISEND_CALL_ONLY, TYPED_FIELD_BUDGET, TYPED_FIELD_CODE_POINTS, ZEROX_CHAINS, assembleEvm, assertNoExecutionGrant, canonicalHex, checksumEvmAddress, decodeAcross, decodeBatchExecute, decodeEvm, decodeZeroX, encodeBatchExecute, evmAddressFromPublicKey, evmSigningPreimage, evmTokenTable, fiat24SessionMessage, hyperliquidL1Document, isCanonicalHex, isEvmAddress, isZeroExSettler, lookupEvmToken, networkChainId, normalizeEvm, normalizeEvmTransaction, parseTypedData, planEvm, recoverEvmSigner, typedDataFields, typedDataHashes, verifiabilityEvm };
|
|
1373
2836
|
|
|
1374
2837
|
//# sourceMappingURL=evm.mjs.map
|