@qntx/wallet-chains 0.9.0 → 0.11.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/dist/{account-ref-C2qrDbVT.mjs → account-ref-D2rW_qlI.mjs} +2 -2
- package/dist/{account-ref-C2qrDbVT.mjs.map → account-ref-D2rW_qlI.mjs.map} +1 -1
- package/dist/bitcoin-sign.mjs +5 -4
- package/dist/bitcoin-sign.mjs.map +1 -1
- package/dist/bitcoin.d.mts +1 -1
- package/dist/bitcoin.mjs +22 -8
- package/dist/bitcoin.mjs.map +1 -1
- package/dist/evm-sign.d.mts +1 -1
- package/dist/evm-sign.mjs +3 -3
- package/dist/evm-sign.mjs.map +1 -1
- package/dist/evm.d.mts +19 -17
- package/dist/evm.mjs +526 -64
- package/dist/evm.mjs.map +1 -1
- package/dist/index-QxoxkD5m.d.mts +246 -0
- package/dist/index.d.mts +2 -140
- package/dist/index.mjs +1 -12
- package/dist/{message-Dv18g8ii.mjs → message-ChhEZ0lx.mjs} +2 -2
- package/dist/{message-Dv18g8ii.mjs.map → message-ChhEZ0lx.mjs.map} +1 -1
- package/dist/solana-sign.mjs +1 -1
- package/dist/solana.d.mts +1 -1
- package/dist/solana.mjs +20 -9
- package/dist/solana.mjs.map +1 -1
- package/dist/src-8NZeEnrW.mjs +67 -0
- package/dist/src-8NZeEnrW.mjs.map +1 -0
- package/dist/{typed-data-Cf1g7JVv.mjs → typed-data-J5g2WemC.mjs} +44 -16
- package/dist/typed-data-J5g2WemC.mjs.map +1 -0
- package/package.json +5 -2
- package/dist/index.mjs.map +0 -1
- package/dist/typed-data-Cf1g7JVv.mjs.map +0 -1
package/dist/evm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.mjs","names":[],"sources":["../src/evm/assets.ts","../src/evm/tokens.ts","../src/evm/decode.ts","../src/evm/recover.ts","../src/evm/index.ts"],"sourcesContent":["/** The native asset id in `AssetFlow` and simulated asset changes. */\nexport const EVM_NATIVE_ASSET = \"native\";\n","/**\n * Built-in ERC-20 token table, keyed by `chainId` then checksummed address. An entry here makes an\n * ERC-20 `transfer` `full`-verifiable (WD-065), so every entry must come from the issuer's own\n * published list and be reviewed against it; the source is recorded per issuer below.\n */\n\nexport type EvmToken = {\n readonly symbol: string;\n readonly decimals: number;\n readonly name?: string;\n};\n\nexport type EvmTokenTable = Readonly<Record<string, Readonly<Record<string, EvmToken>>>>;\n\n// Circle USDC (native issuance, 6 decimals), from\n// https://developers.circle.com/stablecoins/usdc-contract-addresses (reviewed 2026-10-30). BNB\n// Chain has no Circle-issued USDC (the Binance-pegged token is a different issuer), so it is absent.\nconst USDC: EvmToken = Object.freeze({ symbol: \"USDC\", decimals: 6, name: \"USD Coin\" });\n\n// Tether USDT (6 decimals), from https://tether.to/en/supported-protocols/ (reviewed 2026-10-31):\n// Tether lists USD₮ on Ethereum and Avalanche among our networks; bridged or third-party USDT on\n// other chains is a different issuer and is absent.\nconst USDT: EvmToken = Object.freeze({ symbol: \"USDT\", decimals: 6, name: \"Tether USD\" });\n\n/** The built-in table. */\nexport const evmTokenTable: EvmTokenTable = Object.freeze({\n \"1\": Object.freeze({\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": USDC,\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\": USDT,\n }),\n \"10\": Object.freeze({ \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\": USDC }),\n \"137\": Object.freeze({ \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\": USDC }),\n \"999\": Object.freeze({ \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\": USDC }),\n \"8453\": Object.freeze({ \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\": USDC }),\n \"42161\": Object.freeze({ \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\": USDC }),\n \"43114\": Object.freeze({\n \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\": USDC,\n \"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7\": USDT,\n }),\n});\n\nexport const lookupEvmToken = (\n table: EvmTokenTable,\n chainId: number,\n address: string,\n): EvmToken | undefined => table[String(chainId)]?.[address];\n","import * as AbiFunction from \"ox/AbiFunction\";\n\nimport { ChainError } from \"../index.ts\";\nimport type {\n ApprovalChange,\n AssetFlow,\n DisplayIntent,\n EvmTransaction,\n SignRequest,\n Verifiability,\n} from \"../index.ts\";\nimport { checksumEvmAddress } from \"./address.ts\";\nimport { EVM_NATIVE_ASSET } from \"./assets.ts\";\nimport { lookupEvmToken, evmTokenTable } from \"./tokens.ts\";\nimport type { EvmTokenTable } from \"./tokens.ts\";\nimport { assertHex, networkChainId } from \"./transaction.ts\";\nimport { parseTypedData, typedDataWarnings } from \"./typed-data.ts\";\n\nconst ERC20_TRANSFER = AbiFunction.from(\"function transfer(address to, uint256 amount)\");\nconst ERC20_APPROVE = AbiFunction.from(\"function approve(address spender, uint256 amount)\");\nconst ERC20_INCREASE = AbiFunction.from(\n \"function increaseAllowance(address spender, uint256 amount)\",\n);\nconst ERC721_TRANSFER_FROM = AbiFunction.from(\n \"function transferFrom(address from, address to, uint256 tokenId)\",\n);\nconst ERC721_SAFE_FROM = AbiFunction.from(\n \"function safeTransferFrom(address from, address to, uint256 tokenId)\",\n);\nconst ERC1155_SAFE_FROM = AbiFunction.from(\n \"function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data)\",\n);\n\nconst MAX_UINT256 = 2n ** 256n - 1n;\n\nconst argAddress = (args: ReadonlyArray<unknown>, index: number): string => {\n const value = args[index];\n if (typeof value !== \"string\" || !/^0x[0-9a-fA-F]{40}$/.test(value)) {\n throw new ChainError(\"invalid-request\", \"decoded argument is not an address\");\n }\n return checksumEvmAddress(value);\n};\n\nconst argUint = (args: ReadonlyArray<unknown>, index: number): bigint => {\n const value = args[index];\n if (typeof value !== \"bigint\") {\n throw new ChainError(\"invalid-request\", \"decoded argument is not a uint256\");\n }\n return value;\n};\n\n/**\n * Decodes `data` as `fn` and verifies the encoding is canonical (re-encoding the decoded args\n * reproduces the input byte-for-byte). Returns undefined on selector mismatch, decode failure or a\n * non-canonical encoding — the caller falls through to the next candidate or the opaque class.\n */\nconst tryCall = (fn: AbiFunction.AbiFunction, data: string): ReadonlyArray<unknown> | undefined => {\n const selector = AbiFunction.getSelector(fn);\n if (!data.toLowerCase().startsWith(selector)) {\n return undefined;\n }\n try {\n assertHex(data, \"data\");\n const args: unknown = AbiFunction.decodeData(fn, data);\n if (!Array.isArray(args)) {\n return undefined;\n }\n const reencoded = AbiFunction.encodeData(fn, args);\n return reencoded.toLowerCase() === data.toLowerCase() ? args : undefined;\n } catch {\n return undefined;\n }\n};\n\nconst weiAmount = (wei: bigint, symbol?: string, decimals?: number) => ({\n asset: EVM_NATIVE_ASSET,\n amount: wei.toString(10),\n ...(symbol === undefined ? {} : { symbol }),\n ...(decimals === undefined ? {} : { decimals }),\n});\n\nconst feeWei = (tx: EvmTransaction): bigint =>\n BigInt(tx.gas) * (tx.type === \"eip1559\" ? BigInt(tx.maxFeePerGas) : BigInt(tx.gasPrice));\n\nconst nativeOutflow = (tx: EvmTransaction, to: string): ReadonlyArray<AssetFlow> => [\n { to, amount: weiAmount(BigInt(tx.value)), verified: true },\n];\n\nconst tokenFlow = (\n tx: EvmTransaction,\n to: string,\n amount: bigint,\n chainId: number,\n table: EvmTokenTable,\n): { flows: ReadonlyArray<AssetFlow>; verified: boolean } => {\n const token = lookupEvmToken(table, chainId, tx.to ?? \"\");\n return {\n flows: [\n {\n to,\n amount: {\n asset: tx.to ?? \"\",\n amount: amount.toString(10),\n ...(token === undefined ? {} : { symbol: token.symbol, decimals: token.decimals }),\n },\n verified: token !== undefined,\n },\n ],\n verified: token !== undefined,\n };\n};\n\nconst approvalChange = (tx: EvmTransaction, spender: string, amount: bigint): ApprovalChange => ({\n asset: tx.to ?? \"\",\n spender,\n amount: amount.toString(10),\n unlimited: amount === MAX_UINT256,\n verified: false,\n});\n\nconst nftFlow = (asset: string, to: string, id: bigint): ReadonlyArray<AssetFlow> => [\n { to, amount: { asset, amount: id.toString(10) }, verified: false },\n];\n\nconst decodeTransaction = (\n request: Extract<SignRequest, { kind: \"evm.transaction\" }>,\n table: EvmTokenTable,\n): DisplayIntent => {\n const { tx } = request;\n const chainId = networkChainId(request.network);\n const data = tx.data.toLowerCase();\n const fee = { max: weiAmount(feeWei(tx)) };\n const base = { family: \"evm\" as const, network: request.network, approvals: [], warnings: [] };\n\n if (data === \"0x\") {\n if (tx.to === undefined) {\n return { ...base, summary: \"contract-call\", outflows: [], fee, verifiability: \"opaque\" };\n }\n return {\n ...base,\n summary: \"transfer\",\n outflows: nativeOutflow(tx, tx.to),\n fee,\n verifiability: \"full\",\n };\n }\n\n const transferArgs = tryCall(ERC20_TRANSFER, data);\n if (transferArgs !== undefined) {\n const { flows, verified } = tokenFlow(\n tx,\n argAddress(transferArgs, 0),\n argUint(transferArgs, 1),\n chainId,\n table,\n );\n return {\n ...base,\n summary: \"transfer\",\n outflows: flows,\n fee,\n verifiability: verified ? \"full\" : \"partial\",\n };\n }\n const approveArgs = tryCall(ERC20_APPROVE, data);\n if (approveArgs !== undefined) {\n return {\n ...base,\n summary: \"approve\",\n outflows: [],\n approvals: [approvalChange(tx, argAddress(approveArgs, 0), argUint(approveArgs, 1))],\n fee,\n verifiability: \"partial\",\n };\n }\n const increaseArgs = tryCall(ERC20_INCREASE, data);\n if (increaseArgs !== undefined) {\n return {\n ...base,\n summary: \"approve\",\n outflows: [],\n approvals: [approvalChange(tx, argAddress(increaseArgs, 0), argUint(increaseArgs, 1))],\n fee,\n verifiability: \"partial\",\n };\n }\n for (const fn of [ERC721_TRANSFER_FROM, ERC721_SAFE_FROM]) {\n const args = tryCall(fn, data);\n if (args !== undefined) {\n return {\n ...base,\n summary: \"transfer\",\n outflows: nftFlow(tx.to ?? \"\", argAddress(args, 1), argUint(args, 2)),\n fee,\n verifiability: \"partial\",\n };\n }\n }\n const erc1155Args = tryCall(ERC1155_SAFE_FROM, data);\n if (erc1155Args !== undefined) {\n return {\n ...base,\n summary: \"transfer\",\n outflows: nftFlow(tx.to ?? \"\", argAddress(erc1155Args, 1), argUint(erc1155Args, 2)),\n fee,\n verifiability: \"partial\",\n };\n }\n return { ...base, summary: \"contract-call\", outflows: [], fee, verifiability: \"opaque\" };\n};\n\n/** What the signer can guarantee about this request (WD-065). */\nexport const verifiabilityEvm = (request: SignRequest): Verifiability =>\n decodeEvm(request).verifiability;\n\n/**\n * Decodes a normalized request into a DisplayIntent. The token table parameter is for tests;\n * production callers use the built-in table.\n */\nexport const decodeEvm = (\n request: SignRequest,\n table: EvmTokenTable = evmTokenTable,\n): DisplayIntent => {\n if (request.kind === \"evm.transaction\") {\n return decodeTransaction(request, table);\n }\n if (request.kind === \"evm.personal-message\") {\n return {\n family: \"evm\",\n network: request.network,\n summary: \"message\",\n outflows: [],\n approvals: [],\n fee: undefined,\n warnings: [],\n verifiability: \"opaque\",\n };\n }\n if (request.kind !== \"evm.typed-data\") {\n throw new ChainError(\"unsupported\", `unsupported sign request kind: ${request.kind}`);\n }\n const parsed = parseTypedData(request.typedData, request.network);\n return {\n family: \"evm\",\n network: request.network,\n summary: \"message\",\n outflows: [],\n approvals: [],\n fee: undefined,\n warnings: typedDataWarnings(parsed),\n verifiability: \"opaque\",\n };\n};\n","/**\n * Signer recovery for `chain.sign` results: the host re-derives the signer address from a signed\n * envelope or a 65-byte signature and compares it with the account's `wallet.accounts` address — a\n * kernel returning someone else's signature fails closed.\n */\nimport * as Hex from \"ox/Hex\";\nimport * as PersonalMessage from \"ox/PersonalMessage\";\nimport * as Secp256k1 from \"ox/Secp256k1\";\nimport * as Signature from \"ox/Signature\";\nimport * as TxEnvelopeEip1559 from \"ox/TxEnvelopeEip1559\";\nimport * as TxEnvelopeEip2930 from \"ox/TxEnvelopeEip2930\";\nimport * as TxEnvelopeLegacy from \"ox/TxEnvelopeLegacy\";\nimport * as TypedData from \"ox/TypedData\";\n\nimport { ChainError } from \"../index.ts\";\nimport type { SignRequest } from \"../index.ts\";\nimport { parseTypedData } from \"./typed-data.ts\";\n\nfunction assertEip1559Hex(hex: `0x${string}`): asserts hex is `0x02${string}` {\n if (!hex.startsWith(\"0x02\")) {\n throw new ChainError(\"invalid-request\", \"unrecognized signed transaction envelope\");\n }\n}\nfunction assertEip2930Hex(hex: `0x${string}`): asserts hex is `0x01${string}` {\n if (!hex.startsWith(\"0x01\")) {\n throw new ChainError(\"invalid-request\", \"unrecognized signed transaction envelope\");\n }\n}\n\ntype EnvelopeFields = {\n readonly r?: `0x${string}` | undefined;\n readonly s?: `0x${string}` | undefined;\n readonly yParity?: number | undefined;\n};\n\nconst signatureOf = (env: EnvelopeFields) => {\n const { r, s, yParity } = env;\n if (r === undefined || s === undefined || yParity === undefined) {\n throw new ChainError(\"invalid-request\", \"envelope carries no signature\");\n }\n return Signature.from({ r, s, yParity });\n};\n\n/** Recover the signer's EIP-55 address from a serialized signed transaction envelope. */\nconst signerFromEnvelope = (signedTransaction: Uint8Array): string => {\n const hex = Hex.fromBytes(signedTransaction);\n const [tag] = signedTransaction;\n if (tag === 0x02) {\n assertEip1559Hex(hex);\n const env = TxEnvelopeEip1559.deserialize(hex);\n const payload = TxEnvelopeEip1559.getSignPayload(env);\n return Secp256k1.recoverAddress({ payload, signature: signatureOf(env) });\n }\n if (tag === 0x01) {\n assertEip2930Hex(hex);\n const env = TxEnvelopeEip2930.deserialize(hex);\n const payload = TxEnvelopeEip2930.getSignPayload(env);\n return Secp256k1.recoverAddress({ payload, signature: signatureOf(env) });\n }\n try {\n const env = TxEnvelopeLegacy.deserialize(hex);\n const payload = TxEnvelopeLegacy.getSignPayload(env);\n return Secp256k1.recoverAddress({ payload, signature: signatureOf(env) });\n } catch {\n throw new ChainError(\"invalid-request\", \"unrecognized signed transaction envelope\");\n }\n};\n\n/**\n * The EIP-55 address that produced `result` for `request` — a `chain.sign` round-trip check\n * (`{kind:\"evm.transaction\",signedTransaction}` | `{kind,signature}`).\n */\nexport const recoverEvmSigner = (\n request: Extract<SignRequest, { network: string }>,\n result: { readonly signedTransaction?: Uint8Array; readonly signature?: Uint8Array },\n): string => {\n if (request.kind === \"evm.transaction\") {\n if (result.signedTransaction === undefined) {\n throw new ChainError(\"invalid-request\", \"expected a signed transaction\");\n }\n return signerFromEnvelope(result.signedTransaction);\n }\n if (result.signature === undefined || result.signature.length !== 65) {\n throw new ChainError(\"invalid-request\", \"expected a 65-byte signature\");\n }\n const signature = Signature.from(result.signature);\n if (request.kind === \"evm.personal-message\") {\n const payload = PersonalMessage.getSignPayload(Hex.fromBytes(request.message));\n return Secp256k1.recoverAddress({ payload, signature });\n }\n if (request.kind === \"evm.typed-data\") {\n const { json } = parseTypedData(request.typedData, request.network);\n const payload = TypedData.getSignPayload(json);\n return Secp256k1.recoverAddress({ payload, signature });\n }\n throw new ChainError(\"unsupported\", `cannot recover a signer for ${request.kind}`);\n};\n","import { requestBase } from \"../account-ref.ts\";\nimport { ChainError } from \"../index.ts\";\nimport type { SignRequest } from \"../index.ts\";\nimport { isRecord, networkChainId, normalizeEvmTransaction } from \"./transaction.ts\";\nimport { parseTypedData } from \"./typed-data.ts\";\n\nexport { EVM_NATIVE_ASSET } from \"./assets.ts\";\nexport { isEvmAddress, checksumEvmAddress, evmAddressFromPublicKey } from \"./address.ts\";\nexport {\n networkChainId,\n normalizeEvmTransaction,\n canonicalHex,\n isCanonicalHex,\n} from \"./transaction.ts\";\nexport { decodeEvm, verifiabilityEvm } from \"./decode.ts\";\nexport { recoverEvmSigner } from \"./recover.ts\";\nexport { parseTypedData } from \"./typed-data.ts\";\nexport { evmTokenTable, lookupEvmToken } from \"./tokens.ts\";\nexport type { EvmToken, EvmTokenTable } from \"./tokens.ts\";\n\n/**\n * Normalizes a SignRequest for the EVM family: exact key sets, chainId vs the CAIP-2 `network`,\n * canonical quantities and EIP-55 addresses. Idempotent.\n */\nexport const normalizeEvm = (request: unknown): SignRequest => {\n if (!isRecord(request) || typeof request[\"kind\"] !== \"string\") {\n throw new ChainError(\"invalid-request\", \"request must be an object with a kind\");\n }\n const { network, account } = requestBase(request);\n const chainId = networkChainId(network);\n if (request[\"kind\"] === \"evm.transaction\") {\n const tx = normalizeEvmTransaction(request[\"tx\"]);\n if (tx.chainId !== chainId) {\n throw new ChainError(\n \"chain-id-mismatch\",\n `tx.chainId ${tx.chainId} does not match network ${network}`,\n );\n }\n return { kind: \"evm.transaction\", network, account, tx };\n }\n if (request[\"kind\"] === \"evm.personal-message\") {\n const { message } = request;\n if (!(message instanceof Uint8Array)) {\n throw new ChainError(\"invalid-request\", \"personal-message payload must be bytes\");\n }\n return { kind: \"evm.personal-message\", network, account, message };\n }\n if (request[\"kind\"] === \"evm.typed-data\") {\n const { typedData } = request;\n if (typeof typedData !== \"string\") {\n throw new ChainError(\"invalid-request\", \"typed-data payload must be the JSON source string\");\n }\n parseTypedData(typedData, network);\n return { kind: \"evm.typed-data\", network, account, typedData };\n }\n throw new ChainError(\"unsupported\", `unsupported sign request kind: ${request[\"kind\"]}`);\n};\n"],"mappings":";;;;;;;;;;;;;;AACA,MAAa,mBAAmB;;ACgBhC,MAAM,OAAiB,OAAO,OAAO;CAAE,QAAQ;CAAQ,UAAU;CAAG,MAAM;AAAW,CAAC;AAKtF,MAAM,OAAiB,OAAO,OAAO;CAAE,QAAQ;CAAQ,UAAU;CAAG,MAAM;AAAa,CAAC;;AAGxF,MAAa,gBAA+B,OAAO,OAAO;CACxD,KAAK,OAAO,OAAO;EACjB,8CAA8C;EAC9C,8CAA8C;CAChD,CAAC;CACD,MAAM,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC1E,OAAO,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC3E,OAAO,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC3E,QAAQ,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC5E,SAAS,OAAO,OAAO,EAAE,8CA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/evm/permit.ts","../src/evm/safe.ts","../src/evm/seaport.ts","../src/evm/decode.ts","../src/evm/recover.ts","../src/evm/index.ts"],"sourcesContent":["/** The native asset id in `AssetFlow` and simulated asset changes. */\nexport const EVM_NATIVE_ASSET = \"native\";\n","/**\n * Built-in ERC-20 token table, keyed by `chainId` then checksummed address. An entry here makes an\n * ERC-20 `transfer` `full`-verifiable (WD-065), so every entry must come from the issuer's own\n * published list and be reviewed against it; the source is recorded per issuer below.\n */\n\nexport type EvmToken = {\n readonly symbol: string;\n readonly decimals: number;\n readonly name?: string;\n};\n\nexport type EvmTokenTable = Readonly<Record<string, Readonly<Record<string, EvmToken>>>>;\n\n// Circle USDC (native issuance, 6 decimals), from\n// https://developers.circle.com/stablecoins/usdc-contract-addresses (reviewed 2026-10-30). BNB\n// Chain has no Circle-issued USDC (the Binance-pegged token is a different issuer), so it is absent.\nconst USDC: EvmToken = Object.freeze({ symbol: \"USDC\", decimals: 6, name: \"USD Coin\" });\n\n// Tether USDT (6 decimals), from https://tether.to/en/supported-protocols/ (reviewed 2026-10-31):\n// Tether lists USD₮ on Ethereum and Avalanche among our networks; bridged or third-party USDT on\n// other chains is a different issuer and is absent.\nconst USDT: EvmToken = Object.freeze({ symbol: \"USDT\", decimals: 6, name: \"Tether USD\" });\n\n/** The built-in table. */\nexport const evmTokenTable: EvmTokenTable = Object.freeze({\n \"1\": Object.freeze({\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": USDC,\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\": USDT,\n }),\n \"10\": Object.freeze({ \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\": USDC }),\n \"137\": Object.freeze({ \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\": USDC }),\n \"999\": Object.freeze({ \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\": USDC }),\n \"8453\": Object.freeze({ \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\": USDC }),\n \"42161\": Object.freeze({ \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\": USDC }),\n \"43114\": Object.freeze({\n \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\": USDC,\n \"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7\": USDT,\n }),\n});\n\nexport const lookupEvmToken = (\n table: EvmTokenTable,\n chainId: number,\n address: string,\n): EvmToken | undefined => table[String(chainId)]?.[address];\n","import type { ApprovalChange } from \"../index.ts\";\nimport { lookupEvmToken } from \"./tokens.ts\";\nimport type { EvmTokenTable } from \"./tokens.ts\";\n\nexport const MAX_UINT256: bigint = 2n ** 256n - 1n;\nexport const MAX_UINT160: bigint = 2n ** 160n - 1n;\n\n/** The canonical Permit2 deployment (the same address on every supported chain). */\nexport const PERMIT2_ADDRESS = \"0x000000000022D473030F116dDEE9F6B43aC78BA3\";\n\n/** A fungible-token allowance; `max` is the type's maximum, which marks it unlimited. */\nexport const allowanceChange = (\n token: string,\n spender: string,\n value: bigint,\n change: \"set\" | \"increase\" | \"decrease\" | \"transfer\",\n max: bigint,\n chainId: number,\n table: EvmTokenTable,\n extra: { readonly expiration?: number; readonly via?: \"permit2\" } = {},\n): ApprovalChange => {\n const known = lookupEvmToken(table, chainId, token);\n return {\n kind: \"allowance\",\n spender,\n amount: {\n asset: token,\n amount: value.toString(10),\n ...(known === undefined ? {} : { symbol: known.symbol, decimals: known.decimals }),\n },\n change,\n unlimited: change !== \"decrease\" && value === max,\n ...extra,\n verified: known !== undefined,\n };\n};\n","/**\n * Recognition of EIP-712 permits: EIP-2612 `Permit`, DAI `Permit` and the Permit2 allowance and\n * signature-transfer types. A document is recognized only when the primary type and every struct it\n * references have exactly the canonical field lists; any other shape stays an opaque message.\n */\nimport type { ApprovalChange, IntentWarning } from \"../index.ts\";\nimport { MAX_UINT160, MAX_UINT256, PERMIT2_ADDRESS, allowanceChange } from \"./approval.ts\";\nimport type { EvmTokenTable } from \"./tokens.ts\";\nimport {\n MAX_UINT48,\n isTypedDataMessage,\n sameFields,\n typedDataAddress,\n typedDataUint,\n} from \"./typed-data.ts\";\nimport type { TypedDataInput, TypedDataMessage } from \"./typed-data.ts\";\n\nexport type Permit = {\n readonly approvals: ReadonlyArray<ApprovalChange>;\n readonly warnings: ReadonlyArray<IntentWarning>;\n};\n\ntype Types = TypedDataInput[\"types\"];\ntype Message = TypedDataMessage;\n\nconst isMessage = isTypedDataMessage;\nconst address = typedDataAddress;\nconst uint = typedDataUint;\n\nconst DETAILS = [\"address token\", \"uint160 amount\", \"uint48 expiration\", \"uint48 nonce\"];\nconst PERMISSIONS = [\"address token\", \"uint256 amount\"];\n\nconst WITNESS_WARNING: IntentWarning = {\n kind: \"permit2-witness\",\n message: \"the permit carries a witness with further terms\",\n};\n\nconst entries = (value: unknown): ReadonlyArray<Message> | undefined =>\n Array.isArray(value) && value.length > 0 && value.every(isMessage) ? value : undefined;\n\nconst permit = (...approvals: ApprovalChange[]): Permit => ({ approvals, warnings: [] });\n\n/**\n * The permit a typed-data document grants, or `undefined` when its shape is not exactly one of the\n * recognized ones. `chainId` is the request network's, used for the built-in token table.\n */\nexport function recognizePermit(\n json: TypedDataInput,\n chainId: number,\n table: EvmTokenTable,\n): Permit | undefined {\n const { types, primaryType, message, domain } = json;\n const verifying = address(domain[\"verifyingContract\"]);\n if (verifying === undefined) {\n return undefined;\n }\n const spender = address(message[\"spender\"]);\n if (spender === undefined) {\n return undefined;\n }\n const allow = (\n token: string,\n value: bigint,\n change: \"set\" | \"transfer\",\n max: bigint,\n extra: { readonly expiration?: number; readonly via?: \"permit2\" } = {},\n ): ApprovalChange => allowanceChange(token, spender, value, change, max, chainId, table, extra);\n\n if (primaryType === \"Permit\") {\n if (\n sameFields(types, \"Permit\", [\n \"address owner\",\n \"address spender\",\n \"uint256 value\",\n \"uint256 nonce\",\n \"uint256 deadline\",\n ])\n ) {\n const value = uint(message[\"value\"], MAX_UINT256);\n return value === undefined ? undefined : permit(allow(verifying, value, \"set\", MAX_UINT256));\n }\n if (\n sameFields(types, \"Permit\", [\n \"address holder\",\n \"address spender\",\n \"uint256 nonce\",\n \"uint256 expiry\",\n \"bool allowed\",\n ])\n ) {\n const { allowed } = message;\n return typeof allowed === \"boolean\"\n ? permit(allow(verifying, allowed ? MAX_UINT256 : 0n, \"set\", MAX_UINT256))\n : undefined;\n }\n return undefined;\n }\n if (verifying.toLowerCase() !== PERMIT2_ADDRESS.toLowerCase()) {\n return undefined;\n }\n return recognizePermit2(types, primaryType, message, allow);\n}\n\ntype Allow = (\n token: string,\n value: bigint,\n change: \"set\" | \"transfer\",\n max: bigint,\n extra?: { readonly expiration?: number; readonly via?: \"permit2\" },\n) => ApprovalChange;\n\nconst recognizePermit2 = (\n types: Types,\n primaryType: string,\n message: Message,\n allow: Allow,\n): Permit | undefined => {\n const via = \"permit2\" as const;\n const allowance = (details: Message): ApprovalChange | undefined => {\n const token = address(details[\"token\"]);\n const amount = uint(details[\"amount\"], MAX_UINT160);\n const expiration = uint(details[\"expiration\"], MAX_UINT48);\n return token === undefined || amount === undefined || expiration === undefined\n ? undefined\n : allow(token, amount, \"set\", MAX_UINT160, { via, expiration: Number(expiration) });\n };\n const transfer = (permitted: Message, deadline: bigint): ApprovalChange | undefined => {\n const token = address(permitted[\"token\"]);\n const amount = uint(permitted[\"amount\"], MAX_UINT256);\n return token === undefined || amount === undefined\n ? undefined\n : allow(token, amount, \"transfer\", MAX_UINT256, {\n via,\n ...(deadline <= MAX_UINT48 ? { expiration: Number(deadline) } : {}),\n });\n };\n const all = (\n list: ReadonlyArray<Message> | undefined,\n build: (item: Message) => ApprovalChange | undefined,\n ): Permit | undefined => {\n const built = list?.map(build);\n return built === undefined || built.some((a) => a === undefined)\n ? undefined\n : permit(...built.filter((a): a is ApprovalChange => a !== undefined));\n };\n\n if (primaryType === \"PermitSingle\") {\n const { details } = message;\n return sameFields(types, primaryType, [\n \"PermitDetails details\",\n \"address spender\",\n \"uint256 sigDeadline\",\n ]) &&\n sameFields(types, \"PermitDetails\", DETAILS) &&\n isMessage(details)\n ? all([details], allowance)\n : undefined;\n }\n if (primaryType === \"PermitBatch\") {\n return sameFields(types, primaryType, [\n \"PermitDetails[] details\",\n \"address spender\",\n \"uint256 sigDeadline\",\n ]) && sameFields(types, \"PermitDetails\", DETAILS)\n ? all(entries(message[\"details\"]), allowance)\n : undefined;\n }\n\n const witness = primaryType.includes(\"Witness\");\n const batch = primaryType.includes(\"Batch\");\n const expected = batch\n ? [\"TokenPermissions[] permitted\", \"address spender\", \"uint256 nonce\", \"uint256 deadline\"]\n : [\"TokenPermissions permitted\", \"address spender\", \"uint256 nonce\", \"uint256 deadline\"];\n const name = `Permit${batch ? \"Batch\" : \"\"}${witness ? \"Witness\" : \"\"}TransferFrom`;\n if (primaryType !== name) {\n return undefined;\n }\n const own = types[primaryType];\n const last = own?.at(-1);\n const fieldsOk = witness\n ? sameFields({ ...types, [primaryType]: own?.slice(0, -1) ?? [] }, primaryType, expected) &&\n last?.name === \"witness\" &&\n types[last.type] !== undefined\n : sameFields(types, primaryType, expected);\n const deadline = uint(message[\"deadline\"], MAX_UINT256);\n if (!fieldsOk || !sameFields(types, \"TokenPermissions\", PERMISSIONS) || deadline === undefined) {\n return undefined;\n }\n const { permitted } = message;\n const result = batch\n ? all(entries(permitted), (item) => transfer(item, deadline))\n : isMessage(permitted)\n ? all([permitted], (item) => transfer(item, deadline))\n : undefined;\n return result === undefined || !witness\n ? result\n : { approvals: result.approvals, warnings: [WITNESS_WARNING] };\n};\n","/**\n * Recognition of Safe `SafeTx` typed data. A document is recognized only when the primary type is\n * `SafeTx` with exactly the canonical field list and the domain names a `verifyingContract` (the\n * Safe); any other shape stays an opaque message. A `delegatecall` to a canonical MultiSendCallOnly\n * contract is unpacked into its inner calls; anything else stays a single opaque call.\n */\nimport * as AbiFunction from \"ox/AbiFunction\";\n\nimport type { DisplayIntent, SafeTransaction } from \"../index.ts\";\nimport { checksumEvmAddress } from \"./address.ts\";\nimport { MAX_UINT256 } from \"./approval.ts\";\nimport { sameFields, typedDataAddress, typedDataBytes, typedDataUint } from \"./typed-data.ts\";\nimport type { TypedDataInput } from \"./typed-data.ts\";\n\n/**\n * Canonical MultiSendCallOnly deployments (safe-global/safe-deployments): 1.3.0, the 1.3.0 eip155\n * variant and 1.4.1, lowercase for a checksum-insensitive compare.\n */\nexport const SAFE_MULTISEND_CALL_ONLY: ReadonlySet<string> = new Set([\n \"0x40a2accbd92bca938b02010e17a5b8929b49130d\",\n \"0xa1dabef33b3b82c7814b6d82a79e50f4ac44102b\",\n \"0x9641d764fc13c8b624c04430c7356c1c7c8102e2\",\n]);\n\nconst SAFE_TX = [\n \"address to\",\n \"uint256 value\",\n \"bytes data\",\n \"uint8 operation\",\n \"uint256 safeTxGas\",\n \"uint256 baseGas\",\n \"uint256 gasPrice\",\n \"address gasToken\",\n \"address refundReceiver\",\n \"uint256 nonce\",\n];\n\nconst MULTISEND = AbiFunction.from(\"function multiSend(bytes transactions)\");\n\ntype Call = {\n readonly to: string | undefined;\n readonly value: bigint;\n readonly data: `0x${string}`;\n};\n\nexport type SafeRecognition = {\n readonly safe: SafeTransaction;\n /** `data` decoded as `multiSend(bytes)` and unpacked; the intent's summary is `batch`. */\n readonly multisend: boolean;\n};\n\n/**\n * Packed MultiSend entries (`uint8 operation, address to, uint256 value, uint256 dataLength, bytes\n * data` repeated). `undefined` when `data` is not a `multiSend(bytes)` call, a byte is truncated or\n * trailing, or an entry's operation is not 0 — the caller falls back to one opaque call.\n */\nconst multiSendEntries = (data: `0x${string}`): ReadonlyArray<Call> | undefined => {\n if (!data.toLowerCase().startsWith(\"0x8d80ff0a\")) {\n return undefined;\n }\n let packed: string;\n try {\n const decoded: unknown = AbiFunction.decodeData(MULTISEND, data);\n const first: unknown = Array.isArray(decoded) ? decoded[0] : undefined;\n if (typeof first !== \"string\") {\n return undefined;\n }\n packed = first;\n } catch {\n return undefined;\n }\n if (!packed.startsWith(\"0x\")) {\n return undefined;\n }\n const hex = packed.slice(2).toLowerCase();\n const calls: Call[] = [];\n let offset = 0;\n while (offset < hex.length) {\n if (hex.length - offset < 170) {\n return undefined;\n }\n const operation = Number.parseInt(hex.slice(offset, offset + 2), 16);\n if (operation !== 0) {\n return undefined;\n }\n const to = `0x${hex.slice(offset + 2, offset + 42)}`;\n const value = BigInt(`0x${hex.slice(offset + 42, offset + 106)}`);\n const length = BigInt(`0x${hex.slice(offset + 106, offset + 170)}`);\n offset += 170;\n if (length * 2n > BigInt(hex.length - offset)) {\n return undefined;\n }\n calls.push({\n to: checksumEvmAddress(to),\n value,\n data: `0x${hex.slice(offset, offset + Number(length) * 2)}`,\n });\n offset += Number(length) * 2;\n }\n return calls;\n};\n\n/**\n * The Safe transaction a typed-data document signs, or `undefined` when its shape is not exactly\n * the recognized one. `decode` decodes one inner call (the transaction rules without a fee); the\n * caller injects it bound to the request's network and token table.\n */\nexport function recognizeSafe(\n json: TypedDataInput,\n decode: (call: Call) => DisplayIntent,\n): SafeRecognition | undefined {\n const { types, primaryType, message, domain } = json;\n if (primaryType !== \"SafeTx\" || !sameFields(types, \"SafeTx\", SAFE_TX)) {\n return undefined;\n }\n const safe = typedDataAddress(domain[\"verifyingContract\"]);\n const to = typedDataAddress(message[\"to\"]);\n const value = typedDataUint(message[\"value\"], MAX_UINT256);\n const data = typedDataBytes(message[\"data\"]);\n const operation = typedDataUint(message[\"operation\"], 255n);\n const safeTxGas = typedDataUint(message[\"safeTxGas\"], MAX_UINT256);\n const baseGas = typedDataUint(message[\"baseGas\"], MAX_UINT256);\n const gasPrice = typedDataUint(message[\"gasPrice\"], MAX_UINT256);\n const gasToken = typedDataAddress(message[\"gasToken\"]);\n const refundReceiver = typedDataAddress(message[\"refundReceiver\"]);\n const nonce = typedDataUint(message[\"nonce\"], MAX_UINT256);\n if (\n safe === undefined ||\n to === undefined ||\n value === undefined ||\n data === undefined ||\n operation === undefined ||\n operation > 1n ||\n safeTxGas === undefined ||\n baseGas === undefined ||\n gasPrice === undefined ||\n gasToken === undefined ||\n refundReceiver === undefined ||\n nonce === undefined\n ) {\n return undefined;\n }\n const inner =\n operation === 1n && SAFE_MULTISEND_CALL_ONLY.has(to.toLowerCase())\n ? multiSendEntries(data)\n : undefined;\n const calls = (inner ?? [{ to, value, data }]).map(decode);\n return {\n safe: {\n safe,\n nonce: nonce.toString(10),\n operation: operation === 0n ? \"call\" : \"delegatecall\",\n to,\n value: value.toString(10),\n data,\n calls,\n ...(gasPrice > 0n\n ? {\n refund: {\n gasPrice: gasPrice.toString(10),\n gasToken,\n refundReceiver,\n },\n }\n : {}),\n },\n multisend: inner !== undefined,\n };\n}\n","/**\n * Recognition of Seaport `OrderComponents` typed data. A document is recognized only when the\n * domain names Seaport, the verifying contract is a canonical Seaport deployment (1.5 or 1.6), the\n * primary type is `OrderComponents` and every referenced struct has exactly the seaport-js field\n * lists; `BulkOrder` and any other shape stays an opaque message.\n */\nimport type { AssetAmount, SeaportItem, SeaportOrder } from \"../index.ts\";\nimport { MAX_UINT256 } from \"./approval.ts\";\nimport { EVM_NATIVE_ASSET } from \"./assets.ts\";\nimport { lookupEvmToken } from \"./tokens.ts\";\nimport type { EvmTokenTable } from \"./tokens.ts\";\nimport {\n MAX_UINT48,\n sameFields,\n typedDataAddress,\n typedDataMessages,\n typedDataUint,\n} from \"./typed-data.ts\";\nimport type { TypedDataInput, TypedDataMessage } from \"./typed-data.ts\";\n\n/** Seaport 1.5 and 1.6 deployments, lowercase for a checksum-insensitive compare. */\nconst SEAPORT_CONTRACTS = new Set([\n \"0x0000000000000068f116a894984e2db1123eb395\",\n \"0x00000000000000adc04c56bf30ac9d3c0aaf14dc\",\n]);\n\n/** Seaport `itemType` values 0–5; an item type outside the list is not recognized. */\nconst ITEM_KINDS = [\n \"native\",\n \"erc20\",\n \"erc721\",\n \"erc1155\",\n \"erc721-criteria\",\n \"erc1155-criteria\",\n] as const;\n\nconst ITEM_FIELDS = [\n \"uint8 itemType\",\n \"address token\",\n \"uint256 identifierOrCriteria\",\n \"uint256 startAmount\",\n \"uint256 endAmount\",\n];\n\nconst typesMatch = (types: TypedDataInput[\"types\"]): boolean =>\n Object.keys(types).length === 3 &&\n sameFields(types, \"OrderComponents\", [\n \"address offerer\",\n \"address zone\",\n \"OfferItem[] offer\",\n \"ConsiderationItem[] consideration\",\n \"uint8 orderType\",\n \"uint256 startTime\",\n \"uint256 endTime\",\n \"bytes32 zoneHash\",\n \"uint256 salt\",\n \"bytes32 conduitKey\",\n \"uint256 counter\",\n ]) &&\n sameFields(types, \"OfferItem\", ITEM_FIELDS) &&\n sameFields(types, \"ConsiderationItem\", [...ITEM_FIELDS, \"address recipient\"]);\n\nconst amount = (\n kind: SeaportItem[\"kind\"],\n token: string,\n value: bigint,\n chainId: number,\n table: EvmTokenTable,\n): AssetAmount => {\n if (kind === \"native\") {\n return { asset: EVM_NATIVE_ASSET, amount: value.toString(10), symbol: \"ETH\", decimals: 18 };\n }\n if (kind === \"erc20\") {\n const found = lookupEvmToken(table, chainId, token);\n return {\n asset: token,\n amount: value.toString(10),\n ...(found === undefined ? {} : { symbol: found.symbol, decimals: found.decimals }),\n };\n }\n return { asset: token, amount: value.toString(10) };\n};\n\nconst item = (\n message: TypedDataMessage,\n chainId: number,\n table: EvmTokenTable,\n): SeaportItem | undefined => {\n const itemType = typedDataUint(message[\"itemType\"], 255n);\n const token = typedDataAddress(message[\"token\"]);\n const identifier = typedDataUint(message[\"identifierOrCriteria\"], MAX_UINT256);\n const start = typedDataUint(message[\"startAmount\"], MAX_UINT256);\n const end = typedDataUint(message[\"endAmount\"], MAX_UINT256);\n const kind = itemType === undefined ? undefined : ITEM_KINDS[Number(itemType)];\n if (\n token === undefined ||\n identifier === undefined ||\n start === undefined ||\n end === undefined ||\n kind === undefined\n ) {\n return undefined;\n }\n return {\n kind,\n token,\n identifier: identifier.toString(10),\n startAmount: amount(kind, token, start, chainId, table),\n endAmount: amount(kind, token, end, chainId, table),\n };\n};\n\nconst all = <T>(\n list: ReadonlyArray<TypedDataMessage> | undefined,\n build: (entry: TypedDataMessage) => T | undefined,\n): ReadonlyArray<T> | undefined => {\n const built = list?.map(build);\n return built === undefined || built.some((entry) => entry === undefined)\n ? undefined\n : built.filter((entry): entry is T => entry !== undefined);\n};\n\n/**\n * The Seaport order a typed-data document signs, or `undefined` when its shape is not exactly the\n * recognized one. `chainId` is the request network's, used for the built-in token table.\n */\nexport function recognizeSeaport(\n json: TypedDataInput,\n chainId: number,\n table: EvmTokenTable,\n): SeaportOrder | undefined {\n const { types, primaryType, message, domain } = json;\n if (primaryType !== \"OrderComponents\" || !typesMatch(types)) {\n return undefined;\n }\n const verifying = typedDataAddress(domain[\"verifyingContract\"]);\n if (\n domain[\"name\"] !== \"Seaport\" ||\n verifying === undefined ||\n !SEAPORT_CONTRACTS.has(verifying.toLowerCase())\n ) {\n return undefined;\n }\n const offerer = typedDataAddress(message[\"offerer\"]);\n const zone = typedDataAddress(message[\"zone\"]);\n const startTime = typedDataUint(message[\"startTime\"], MAX_UINT256);\n const endTime = typedDataUint(message[\"endTime\"], MAX_UINT256);\n const offer = all(typedDataMessages(message[\"offer\"]), (entry) => item(entry, chainId, table));\n const consideration = all(typedDataMessages(message[\"consideration\"]), (entry) => {\n const base = item(entry, chainId, table);\n const recipient = typedDataAddress(entry[\"recipient\"]);\n return base === undefined || recipient === undefined ? undefined : { ...base, recipient };\n });\n if (\n offerer === undefined ||\n zone === undefined ||\n startTime === undefined ||\n endTime === undefined ||\n offer === undefined ||\n consideration === undefined\n ) {\n return undefined;\n }\n return {\n offerer,\n zone,\n startTime: startTime <= MAX_UINT48 ? Number(startTime) : undefined,\n endTime: endTime <= MAX_UINT48 ? Number(endTime) : undefined,\n offer,\n consideration,\n };\n}\n","import * as AbiFunction from \"ox/AbiFunction\";\n\nimport { ChainError } from \"../index.ts\";\nimport type {\n ApprovalChange,\n AssetFlow,\n DisplayIntent,\n EvmTransaction,\n MessageContent,\n TypedDataDomain,\n SignRequest,\n Verifiability,\n} from \"../index.ts\";\nimport { parseSignIn } from \"../sign-in.ts\";\nimport { checksumEvmAddress } from \"./address.ts\";\nimport { MAX_UINT160, MAX_UINT256, PERMIT2_ADDRESS, allowanceChange } from \"./approval.ts\";\nimport { EVM_NATIVE_ASSET } from \"./assets.ts\";\nimport { recognizePermit } from \"./permit.ts\";\nimport { recognizeSafe } from \"./safe.ts\";\nimport { recognizeSeaport } from \"./seaport.ts\";\nimport { lookupEvmToken, evmTokenTable } from \"./tokens.ts\";\nimport type { EvmTokenTable } from \"./tokens.ts\";\nimport { quantityBigInt, assertHex, networkChainId } from \"./transaction.ts\";\nimport { domainChainId, parseTypedData } from \"./typed-data.ts\";\nimport type { TypedDataInput } from \"./typed-data.ts\";\n\nconst ERC20_TRANSFER = AbiFunction.from(\"function transfer(address to, uint256 amount)\");\nconst ERC20_APPROVE = AbiFunction.from(\"function approve(address spender, uint256 amount)\");\nconst ERC20_INCREASE = AbiFunction.from(\n \"function increaseAllowance(address spender, uint256 amount)\",\n);\nconst ERC20_DECREASE = AbiFunction.from(\n \"function decreaseAllowance(address spender, uint256 subtractedValue)\",\n);\nconst SET_APPROVAL_FOR_ALL = AbiFunction.from(\n \"function setApprovalForAll(address operator, bool approved)\",\n);\nconst PERMIT2_APPROVE = AbiFunction.from(\n \"function approve(address token, address spender, uint160 amount, uint48 expiration)\",\n);\nconst PERMIT2_LOCKDOWN = AbiFunction.from(\n \"function lockdown((address token, address spender)[] approvals)\",\n);\nconst ERC721_SAFE_FROM_DATA = AbiFunction.from(\n \"function safeTransferFrom(address from, address to, uint256 tokenId, bytes data)\",\n);\nconst ERC1155_SAFE_BATCH_FROM = AbiFunction.from(\n \"function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data)\",\n);\nconst ERC721_TRANSFER_FROM = AbiFunction.from(\n \"function transferFrom(address from, address to, uint256 tokenId)\",\n);\nconst ERC721_SAFE_FROM = AbiFunction.from(\n \"function safeTransferFrom(address from, address to, uint256 tokenId)\",\n);\nconst ERC1155_SAFE_FROM = AbiFunction.from(\n \"function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data)\",\n);\n\nconst argAddress = (args: ReadonlyArray<unknown>, index: number): string => {\n const value = args[index];\n if (typeof value !== \"string\" || !/^0x[0-9a-fA-F]{40}$/.test(value)) {\n throw new ChainError(\"invalid-request\", \"decoded argument is not an address\");\n }\n return checksumEvmAddress(value);\n};\n\nconst argUint = (args: ReadonlyArray<unknown>, index: number): bigint => {\n const value = args[index];\n if (typeof value !== \"bigint\") {\n throw new ChainError(\"invalid-request\", \"decoded argument is not a uint256\");\n }\n return value;\n};\n\n/**\n * Decodes `data` as `fn` and verifies the encoding is canonical (re-encoding the decoded args\n * reproduces the input byte-for-byte). Returns undefined on selector mismatch, decode failure or a\n * non-canonical encoding — the caller falls through to the next candidate or the opaque class.\n */\nconst tryCall = (fn: AbiFunction.AbiFunction, data: string): ReadonlyArray<unknown> | undefined => {\n const selector = AbiFunction.getSelector(fn);\n if (!data.toLowerCase().startsWith(selector)) {\n return undefined;\n }\n try {\n assertHex(data, \"data\");\n const args: unknown = AbiFunction.decodeData(fn, data);\n if (!Array.isArray(args)) {\n return undefined;\n }\n const reencoded = AbiFunction.encodeData(fn, args);\n return reencoded.toLowerCase() === data.toLowerCase() ? args : undefined;\n } catch {\n return undefined;\n }\n};\n\nconst weiAmount = (wei: bigint, symbol?: string, decimals?: number) => ({\n asset: EVM_NATIVE_ASSET,\n amount: wei.toString(10),\n ...(symbol === undefined ? {} : { symbol }),\n ...(decimals === undefined ? {} : { decimals }),\n});\n\nconst feeWei = (tx: EvmTransaction): bigint =>\n quantityBigInt(tx.gas, \"tx.gas\") *\n (tx.type === \"eip1559\"\n ? quantityBigInt(tx.maxFeePerGas, \"tx.maxFeePerGas\")\n : quantityBigInt(tx.gasPrice, \"tx.gasPrice\"));\n\nconst nativeOutflow = (value: bigint, to: string): ReadonlyArray<AssetFlow> => [\n { to, amount: weiAmount(value), verified: true },\n];\n\nconst tokenFlow = (\n target: string,\n to: string,\n amount: bigint,\n chainId: number,\n table: EvmTokenTable,\n): { flows: ReadonlyArray<AssetFlow>; verified: boolean } => {\n const token = lookupEvmToken(table, chainId, target);\n return {\n flows: [\n {\n to,\n amount: {\n asset: target,\n amount: amount.toString(10),\n ...(token === undefined ? {} : { symbol: token.symbol, decimals: token.decimals }),\n },\n verified: token !== undefined,\n },\n ],\n verified: token !== undefined,\n };\n};\n\nconst argBool = (args: ReadonlyArray<unknown>, index: number): boolean => {\n const value = args[index];\n if (typeof value !== \"boolean\") {\n throw new ChainError(\"invalid-request\", \"decoded argument is not a bool\");\n }\n return value;\n};\n\nconst argList = (args: ReadonlyArray<unknown>, index: number): ReadonlyArray<unknown> => {\n const value = args[index];\n if (!Array.isArray(value)) {\n throw new ChainError(\"invalid-request\", \"decoded argument is not an array\");\n }\n return value;\n};\n\nconst argSeconds = (args: ReadonlyArray<unknown>, index: number): number => {\n const value = args[index];\n if (typeof value !== \"number\" && typeof value !== \"bigint\") {\n throw new ChainError(\"invalid-request\", \"decoded argument is not an integer\");\n }\n return Number(value);\n};\n\nconst pairField = (pair: unknown, key: \"token\" | \"spender\"): string => {\n const value: unknown = typeof pair === \"object\" && pair !== null ? Reflect.get(pair, key) : \"\";\n return argAddress([value], 0);\n};\n\nconst nftFlow = (asset: string, to: string, id: bigint): ReadonlyArray<AssetFlow> => [\n { to, amount: { asset, amount: id.toString(10) }, verified: false },\n];\n\n/** One EVM call, `to` absent for contract creation; `value` and `data` are always present. */\ntype EvmCall = {\n readonly to: string | undefined;\n readonly value: bigint;\n readonly data: string;\n};\n\n/**\n * The call rules shared by a whole transaction and a Safe's inner calls: the same selector table\n * produces the intent; `fee` is `undefined` for a call that is not itself a transaction.\n */\nconst decodeCall = (\n call: EvmCall,\n network: string,\n fee: DisplayIntent[\"fee\"],\n table: EvmTokenTable,\n): DisplayIntent => {\n const chainId = networkChainId(network);\n const data = call.data.toLowerCase();\n const base = { family: \"evm\" as const, network, approvals: [], warnings: [] };\n\n if (data === \"0x\") {\n if (call.to === undefined) {\n return { ...base, summary: \"contract-call\", outflows: [], fee, verifiability: \"opaque\" };\n }\n return {\n ...base,\n summary: \"transfer\",\n outflows: nativeOutflow(call.value, call.to),\n fee,\n verifiability: \"full\",\n };\n }\n\n const transferArgs = tryCall(ERC20_TRANSFER, data);\n if (transferArgs !== undefined) {\n const { flows, verified } = tokenFlow(\n call.to ?? \"\",\n argAddress(transferArgs, 0),\n argUint(transferArgs, 1),\n chainId,\n table,\n );\n return {\n ...base,\n summary: \"transfer\",\n outflows: flows,\n fee,\n verifiability: verified ? \"full\" : \"partial\",\n };\n }\n const partial = (\n summary: \"approve\" | \"transfer\",\n outflows: ReadonlyArray<AssetFlow>,\n approvals: ReadonlyArray<ApprovalChange>,\n ): DisplayIntent => ({\n ...base,\n summary,\n outflows,\n approvals,\n fee,\n verifiability: \"partial\",\n });\n const token = call.to ?? \"\";\n\n if (token.toLowerCase() === PERMIT2_ADDRESS.toLowerCase()) {\n const permitArgs = tryCall(PERMIT2_APPROVE, data);\n if (permitArgs !== undefined) {\n const amount = argUint(permitArgs, 2);\n return partial(\n \"approve\",\n [],\n [\n allowanceChange(\n argAddress(permitArgs, 0),\n argAddress(permitArgs, 1),\n amount,\n \"set\",\n MAX_UINT160,\n chainId,\n table,\n { via: \"permit2\", expiration: argSeconds(permitArgs, 3) },\n ),\n ],\n );\n }\n const lockdownArgs = tryCall(PERMIT2_LOCKDOWN, data);\n if (lockdownArgs !== undefined) {\n return partial(\n \"approve\",\n [],\n argList(lockdownArgs, 0).map((pair) =>\n allowanceChange(\n pairField(pair, \"token\"),\n pairField(pair, \"spender\"),\n 0n,\n \"set\",\n MAX_UINT160,\n chainId,\n table,\n { via: \"permit2\" },\n ),\n ),\n );\n }\n }\n for (const [fn, change] of [\n [ERC20_APPROVE, \"set\"],\n [ERC20_INCREASE, \"increase\"],\n [ERC20_DECREASE, \"decrease\"],\n ] as const) {\n const args = tryCall(fn, data);\n if (args !== undefined) {\n return partial(\n \"approve\",\n [],\n [\n allowanceChange(\n token,\n argAddress(args, 0),\n argUint(args, 1),\n change,\n MAX_UINT256,\n chainId,\n table,\n ),\n ],\n );\n }\n }\n const operatorArgs = tryCall(SET_APPROVAL_FOR_ALL, data);\n if (operatorArgs !== undefined) {\n return partial(\n \"approve\",\n [],\n [\n {\n kind: \"operator\",\n asset: token,\n spender: argAddress(operatorArgs, 0),\n approved: argBool(operatorArgs, 1),\n verified: false,\n },\n ],\n );\n }\n const transferFromArgs = tryCall(ERC721_TRANSFER_FROM, data);\n if (transferFromArgs !== undefined) {\n const to = argAddress(transferFromArgs, 1);\n const id = argUint(transferFromArgs, 2);\n if (lookupEvmToken(table, chainId, token) !== undefined) {\n return partial(\"transfer\", tokenFlow(token, to, id, chainId, table).flows, []);\n }\n return partial(\"transfer\", nftFlow(token, to, id), []);\n }\n for (const fn of [ERC721_SAFE_FROM, ERC721_SAFE_FROM_DATA]) {\n const args = tryCall(fn, data);\n if (args !== undefined) {\n return partial(\"transfer\", nftFlow(token, argAddress(args, 1), argUint(args, 2)), []);\n }\n }\n const erc1155Args = tryCall(ERC1155_SAFE_FROM, data);\n if (erc1155Args !== undefined) {\n return partial(\n \"transfer\",\n nftFlow(token, argAddress(erc1155Args, 1), argUint(erc1155Args, 2)),\n [],\n );\n }\n const batchArgs = tryCall(ERC1155_SAFE_BATCH_FROM, data);\n if (batchArgs !== undefined) {\n const ids = argList(batchArgs, 2);\n if (ids.length > 0 && ids.length === argList(batchArgs, 3).length) {\n const to = argAddress(batchArgs, 1);\n return partial(\n \"transfer\",\n ids.flatMap((id) => nftFlow(token, to, argUint([id], 0))),\n [],\n );\n }\n }\n return { ...base, summary: \"contract-call\", outflows: [], fee, verifiability: \"opaque\" };\n};\n\nconst decodeTransaction = (\n request: Extract<SignRequest, { kind: \"evm.transaction\" }>,\n table: EvmTokenTable,\n): DisplayIntent => {\n const { tx } = request;\n return decodeCall(\n { to: tx.to, value: quantityBigInt(tx.value, \"tx.value\"), data: tx.data },\n request.network,\n { max: weiAmount(feeWei(tx)) },\n table,\n );\n};\n\n/** The five EIP-712 domain fields a wallet shows; anything malformed is left out. */\nconst displayDomain = (domain: TypedDataInput[\"domain\"]): TypedDataDomain => {\n const { name, version, verifyingContract, salt } = domain;\n const chainId = domainChainId(domain);\n return {\n ...(typeof name === \"string\" ? { name } : {}),\n ...(typeof version === \"string\" ? { version } : {}),\n ...(chainId === undefined ? {} : { chainId }),\n ...(typeof verifyingContract === \"string\" && /^0x[0-9a-fA-F]{40}$/.test(verifyingContract)\n ? { verifyingContract: checksumEvmAddress(verifyingContract) }\n : {}),\n ...(typeof salt === \"string\" ? { salt } : {}),\n };\n};\n\n/** Strict UTF-8 text with any sign-in recognition, else the raw bytes as hex. */\nconst messageContent = (bytes: Uint8Array): MessageContent => {\n try {\n const text = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n const signIn = parseSignIn(text, \"evm\");\n return signIn === undefined ? { kind: \"text\", text } : { kind: \"text\", text, signIn };\n } catch {\n return {\n kind: \"bytes\",\n hex: `0x${[...bytes].map((b) => b.toString(16).padStart(2, \"0\")).join(\"\")}`,\n };\n }\n};\n\n/** What the signer can guarantee about this request (WD-065). */\nexport const verifiabilityEvm = (request: SignRequest): Verifiability =>\n decodeEvm(request).verifiability;\n\n/**\n * Decodes a normalized request into a DisplayIntent. The token table parameter is for tests;\n * production callers use the built-in table.\n */\nexport const decodeEvm = (\n request: SignRequest,\n table: EvmTokenTable = evmTokenTable,\n): DisplayIntent => {\n if (request.kind === \"evm.transaction\") {\n return decodeTransaction(request, table);\n }\n if (request.kind === \"evm.personal-message\") {\n return {\n family: \"evm\",\n network: request.network,\n summary: \"message\",\n outflows: [],\n approvals: [],\n fee: undefined,\n warnings: [],\n message: messageContent(request.message),\n verifiability: \"opaque\",\n };\n }\n if (request.kind !== \"evm.typed-data\") {\n throw new ChainError(\"unsupported\", `unsupported sign request kind: ${request.kind}`);\n }\n const { json } = parseTypedData(request.typedData);\n const chainId = networkChainId(request.network);\n const permit = recognizePermit(json, chainId, table);\n const seaport = permit === undefined ? recognizeSeaport(json, chainId, table) : undefined;\n const safe =\n permit === undefined && seaport === undefined\n ? recognizeSafe(json, (call) => decodeCall(call, request.network, undefined, table))\n : undefined;\n const message: MessageContent = {\n kind: \"typed-data\",\n primaryType: json.primaryType,\n domain: displayDomain(json.domain),\n data: json.message,\n ...(seaport === undefined ? {} : { seaport }),\n ...(safe === undefined ? {} : { safe: safe.safe }),\n };\n const summary =\n seaport === undefined\n ? safe === undefined\n ? permit === undefined\n ? \"message\"\n : \"approve\"\n : safe.multisend\n ? \"batch\"\n : (safe.safe.calls[0]?.summary ?? \"contract-call\")\n : \"swap\";\n return {\n family: \"evm\",\n network: request.network,\n summary,\n outflows: [],\n approvals: permit?.approvals ?? [],\n fee: undefined,\n warnings: permit?.warnings ?? [],\n message,\n verifiability: permit === undefined ? \"opaque\" : \"partial\",\n };\n};\n","/**\n * Signer recovery for `chain.sign` results: the host re-derives the signer address from a signed\n * envelope or a 65-byte signature and compares it with the account's `wallet.accounts` address — a\n * kernel returning someone else's signature fails closed.\n */\nimport * as Hex from \"ox/Hex\";\nimport * as PersonalMessage from \"ox/PersonalMessage\";\nimport * as Secp256k1 from \"ox/Secp256k1\";\nimport * as Signature from \"ox/Signature\";\nimport * as TxEnvelopeEip1559 from \"ox/TxEnvelopeEip1559\";\nimport * as TxEnvelopeEip2930 from \"ox/TxEnvelopeEip2930\";\nimport * as TxEnvelopeLegacy from \"ox/TxEnvelopeLegacy\";\nimport * as TypedData from \"ox/TypedData\";\n\nimport { ChainError } from \"../index.ts\";\nimport type { SignRequest } from \"../index.ts\";\nimport { parseTypedData } from \"./typed-data.ts\";\n\nfunction assertEip1559Hex(hex: `0x${string}`): asserts hex is `0x02${string}` {\n if (!hex.startsWith(\"0x02\")) {\n throw new ChainError(\"invalid-request\", \"unrecognized signed transaction envelope\");\n }\n}\nfunction assertEip2930Hex(hex: `0x${string}`): asserts hex is `0x01${string}` {\n if (!hex.startsWith(\"0x01\")) {\n throw new ChainError(\"invalid-request\", \"unrecognized signed transaction envelope\");\n }\n}\n\ntype EnvelopeFields = {\n readonly r?: `0x${string}` | undefined;\n readonly s?: `0x${string}` | undefined;\n readonly yParity?: number | undefined;\n};\n\nconst signatureOf = (env: EnvelopeFields) => {\n const { r, s, yParity } = env;\n if (r === undefined || s === undefined || yParity === undefined) {\n throw new ChainError(\"invalid-request\", \"envelope carries no signature\");\n }\n return Signature.from({ r, s, yParity });\n};\n\n/** Recover the signer's EIP-55 address from a serialized signed transaction envelope. */\nconst signerFromEnvelope = (signedTransaction: Uint8Array): string => {\n const hex = Hex.fromBytes(signedTransaction);\n const [tag] = signedTransaction;\n if (tag === 0x02) {\n assertEip1559Hex(hex);\n const env = TxEnvelopeEip1559.deserialize(hex);\n const payload = TxEnvelopeEip1559.getSignPayload(env);\n return Secp256k1.recoverAddress({ payload, signature: signatureOf(env) });\n }\n if (tag === 0x01) {\n assertEip2930Hex(hex);\n const env = TxEnvelopeEip2930.deserialize(hex);\n const payload = TxEnvelopeEip2930.getSignPayload(env);\n return Secp256k1.recoverAddress({ payload, signature: signatureOf(env) });\n }\n try {\n const env = TxEnvelopeLegacy.deserialize(hex);\n const payload = TxEnvelopeLegacy.getSignPayload(env);\n return Secp256k1.recoverAddress({ payload, signature: signatureOf(env) });\n } catch {\n throw new ChainError(\"invalid-request\", \"unrecognized signed transaction envelope\");\n }\n};\n\n/**\n * The EIP-55 address that produced `result` for `request` — a `chain.sign` round-trip check\n * (`{kind:\"evm.transaction\",signedTransaction}` | `{kind,signature}`).\n */\nexport const recoverEvmSigner = (\n request: Extract<SignRequest, { network: string }>,\n result: { readonly signedTransaction?: Uint8Array; readonly signature?: Uint8Array },\n): string => {\n if (request.kind === \"evm.transaction\") {\n if (result.signedTransaction === undefined) {\n throw new ChainError(\"invalid-request\", \"expected a signed transaction\");\n }\n return signerFromEnvelope(result.signedTransaction);\n }\n if (result.signature === undefined || result.signature.length !== 65) {\n throw new ChainError(\"invalid-request\", \"expected a 65-byte signature\");\n }\n const signature = Signature.from(result.signature);\n if (request.kind === \"evm.personal-message\") {\n const payload = PersonalMessage.getSignPayload(Hex.fromBytes(request.message));\n return Secp256k1.recoverAddress({ payload, signature });\n }\n if (request.kind === \"evm.typed-data\") {\n const { json } = parseTypedData(request.typedData);\n const payload = TypedData.getSignPayload(json);\n return Secp256k1.recoverAddress({ payload, signature });\n }\n throw new ChainError(\"unsupported\", `cannot recover a signer for ${request.kind}`);\n};\n","import { requestBase } from \"../account-ref.ts\";\nimport { ChainError } from \"../index.ts\";\nimport type { SignRequest } from \"../index.ts\";\nimport { isRecord, networkChainId, normalizeEvmTransaction } from \"./transaction.ts\";\nimport { domainChainId, parseTypedData } from \"./typed-data.ts\";\n\nexport { EVM_NATIVE_ASSET } from \"./assets.ts\";\nexport { isEvmAddress, checksumEvmAddress, evmAddressFromPublicKey } from \"./address.ts\";\nexport {\n networkChainId,\n normalizeEvmTransaction,\n canonicalHex,\n isCanonicalHex,\n} from \"./transaction.ts\";\nexport { PERMIT2_ADDRESS } from \"./approval.ts\";\nexport { decodeEvm, verifiabilityEvm } from \"./decode.ts\";\nexport { SAFE_MULTISEND_CALL_ONLY } from \"./safe.ts\";\nexport { recoverEvmSigner } from \"./recover.ts\";\nexport { parseTypedData } from \"./typed-data.ts\";\nexport { evmTokenTable, lookupEvmToken } from \"./tokens.ts\";\nexport type { EvmToken, EvmTokenTable } from \"./tokens.ts\";\n\n/**\n * Normalizes a SignRequest for the EVM family: exact key sets, chainId vs the CAIP-2 `network`,\n * canonical quantities and EIP-55 addresses. Idempotent.\n */\nexport const normalizeEvm = (request: unknown): SignRequest => {\n if (!isRecord(request) || typeof request[\"kind\"] !== \"string\") {\n throw new ChainError(\"invalid-request\", \"request must be an object with a kind\");\n }\n const { network, account } = requestBase(request);\n const chainId = networkChainId(network);\n if (request[\"kind\"] === \"evm.transaction\") {\n const tx = normalizeEvmTransaction(request[\"tx\"]);\n if (tx.chainId !== chainId) {\n throw new ChainError(\n \"chain-id-mismatch\",\n `tx.chainId ${tx.chainId} does not match network ${network}`,\n );\n }\n return { kind: \"evm.transaction\", network, account, tx };\n }\n if (request[\"kind\"] === \"evm.personal-message\") {\n const { message } = request;\n if (!(message instanceof Uint8Array)) {\n throw new ChainError(\"invalid-request\", \"personal-message payload must be bytes\");\n }\n return { kind: \"evm.personal-message\", network, account, message };\n }\n if (request[\"kind\"] === \"evm.typed-data\") {\n const { typedData } = request;\n if (typeof typedData !== \"string\") {\n throw new ChainError(\"invalid-request\", \"typed-data payload must be the JSON source string\");\n }\n const { json } = parseTypedData(typedData);\n const domainChain = domainChainId(json.domain);\n if (domainChain !== undefined && domainChain !== chainId) {\n throw new ChainError(\n \"chain-id-mismatch\",\n `typed-data domain.chainId ${domainChain} does not match network ${network}`,\n );\n }\n return { kind: \"evm.typed-data\", network, account, typedData };\n }\n throw new ChainError(\"unsupported\", `unsupported sign request kind: ${request[\"kind\"]}`);\n};\n"],"mappings":";;;;;;;;;;;;;;AACA,MAAa,mBAAmB;;ACgBhC,MAAM,OAAiB,OAAO,OAAO;CAAE,QAAQ;CAAQ,UAAU;CAAG,MAAM;AAAW,CAAC;AAKtF,MAAM,OAAiB,OAAO,OAAO;CAAE,QAAQ;CAAQ,UAAU;CAAG,MAAM;AAAa,CAAC;;AAGxF,MAAa,gBAA+B,OAAO,OAAO;CACxD,KAAK,OAAO,OAAO;EACjB,8CAA8C;EAC9C,8CAA8C;CAChD,CAAC;CACD,MAAM,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC1E,OAAO,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC3E,OAAO,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC3E,QAAQ,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC5E,SAAS,OAAO,OAAO,EAAE,8CAA8C,KAAK,CAAC;CAC7E,SAAS,OAAO,OAAO;EACrB,8CAA8C;EAC9C,8CAA8C;CAChD,CA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EAAE,mBAAmB,aACvB,MAAM,IAAI,WAAW,mBAAmB,wCAAwC;EAElF,OAAO;GAAE,MAAM;GAAwB;GAAS;GAAS;EAAQ;CACnE;CACA,IAAI,QAAQ,YAAY,kBAAkB;EACxC,MAAM,EAAE,cAAc;EACtB,IAAI,OAAO,cAAc,UACvB,MAAM,IAAI,WAAW,mBAAmB,mDAAmD;EAE7F,MAAM,EAAE,SAAS,eAAe,SAAS;EACzC,MAAM,cAAc,cAAc,KAAK,MAAM;EAC7C,IAAI,gBAAgB,KAAA,KAAa,gBAAgB,SAC/C,MAAM,IAAI,WACR,qBACA,6BAA6B,YAAY,0BAA0B,SACrE;EAEF,OAAO;GAAE,MAAM;GAAkB;GAAS;GAAS;EAAU;CAC/D;CACA,MAAM,IAAI,WAAW,eAAe,kCAAkC,QAAQ,SAAS;AACzF"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { MessageFields } from "@qntx/siwx";
|
|
2
|
+
/** A Sign-In with X message found in signed text (ERC-4361 / SIWS). */
|
|
3
|
+
type SignInParse = {
|
|
4
|
+
readonly status: "valid";
|
|
5
|
+
readonly fields: MessageFields;
|
|
6
|
+
} |
|
|
7
|
+
/** The text contains the sign-in preamble but is not a conforming message for this chain family. */
|
|
8
|
+
{
|
|
9
|
+
readonly status: "malformed";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Finds a Sign-In with X message in `text` for the chain `family`. `undefined` when the text has no
|
|
13
|
+
* sign-in preamble; `malformed` when it has one but is not a conforming message for the family
|
|
14
|
+
* (ERC-4361: wallets should warn about that shape).
|
|
15
|
+
*/
|
|
16
|
+
declare function parseSignIn(text: string, family: "evm" | "solana"): SignInParse | undefined;
|
|
17
|
+
type ChainFamily = "evm" | "solana" | "bitcoin";
|
|
18
|
+
type AccountRef = {
|
|
19
|
+
readonly kind: "hd";
|
|
20
|
+
readonly walletId: string;
|
|
21
|
+
readonly groupIndex: number;
|
|
22
|
+
readonly template: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: "imported";
|
|
25
|
+
readonly keyId: string;
|
|
26
|
+
readonly family: ChainFamily;
|
|
27
|
+
};
|
|
28
|
+
type SignRequest = {
|
|
29
|
+
readonly kind: "bitcoin.psbt";
|
|
30
|
+
readonly network: string;
|
|
31
|
+
readonly account: AccountRef;
|
|
32
|
+
readonly psbt: Uint8Array;
|
|
33
|
+
/** Input indices to sign — non-empty, unique, ascending, in range. */
|
|
34
|
+
readonly sign: ReadonlyArray<number>;
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: "bitcoin.message";
|
|
37
|
+
readonly network: string;
|
|
38
|
+
readonly account: AccountRef;
|
|
39
|
+
readonly address: string;
|
|
40
|
+
readonly message: string;
|
|
41
|
+
readonly format: "bip322-simple" | "legacy";
|
|
42
|
+
/** Account change chain and index the address is derived at (0 = receive, 1 = change). */
|
|
43
|
+
readonly change: 0 | 1;
|
|
44
|
+
readonly index: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: "solana.transaction";
|
|
47
|
+
readonly network: string;
|
|
48
|
+
readonly account: AccountRef;
|
|
49
|
+
/** Compiled wire message (legacy or v0). */
|
|
50
|
+
readonly message: Uint8Array;
|
|
51
|
+
readonly lookupTables?: ReadonlyArray<{
|
|
52
|
+
readonly address: string;
|
|
53
|
+
readonly addresses: ReadonlyArray<string>;
|
|
54
|
+
}>;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: "solana.message";
|
|
57
|
+
readonly network: string;
|
|
58
|
+
readonly account: AccountRef;
|
|
59
|
+
readonly message: Uint8Array;
|
|
60
|
+
/** Only "raw" exists in this layer; offchain formats land with C7. */
|
|
61
|
+
readonly format: "raw";
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "evm.transaction";
|
|
64
|
+
readonly network: string;
|
|
65
|
+
readonly account: AccountRef;
|
|
66
|
+
readonly tx: EvmTransaction;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: "evm.personal-message";
|
|
69
|
+
readonly network: string;
|
|
70
|
+
readonly account: AccountRef;
|
|
71
|
+
readonly message: Uint8Array;
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: "evm.typed-data";
|
|
74
|
+
readonly network: string;
|
|
75
|
+
readonly account: AccountRef;
|
|
76
|
+
readonly typedData: string;
|
|
77
|
+
};
|
|
78
|
+
type EvmAccessListEntry = {
|
|
79
|
+
readonly address: string;
|
|
80
|
+
readonly storageKeys: ReadonlyArray<string>;
|
|
81
|
+
};
|
|
82
|
+
type EvmTransactionBase = {
|
|
83
|
+
readonly chainId: number;
|
|
84
|
+
readonly nonce: number;
|
|
85
|
+
readonly gas: string;
|
|
86
|
+
readonly value: string;
|
|
87
|
+
readonly data: string;
|
|
88
|
+
readonly to?: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* A complete transaction — every field the signer needs is present; `to` absent means contract
|
|
92
|
+
* creation.
|
|
93
|
+
*/
|
|
94
|
+
type EvmTransaction = (EvmTransactionBase & {
|
|
95
|
+
readonly type: "legacy";
|
|
96
|
+
readonly gasPrice: string;
|
|
97
|
+
}) | (EvmTransactionBase & {
|
|
98
|
+
readonly type: "eip2930";
|
|
99
|
+
readonly gasPrice: string;
|
|
100
|
+
readonly accessList: ReadonlyArray<EvmAccessListEntry>;
|
|
101
|
+
}) | (EvmTransactionBase & {
|
|
102
|
+
readonly type: "eip1559";
|
|
103
|
+
readonly accessList: ReadonlyArray<EvmAccessListEntry>;
|
|
104
|
+
readonly maxFeePerGas: string;
|
|
105
|
+
readonly maxPriorityFeePerGas: string;
|
|
106
|
+
});
|
|
107
|
+
type Verifiability = "full" | "partial" | "opaque";
|
|
108
|
+
type IntentSummary = "transfer" | "approve" | "contract-call" | "swap" | "message" | "authorization" | "batch";
|
|
109
|
+
type AssetAmount = {
|
|
110
|
+
readonly asset: string;
|
|
111
|
+
readonly amount: string;
|
|
112
|
+
readonly decimals?: number;
|
|
113
|
+
readonly symbol?: string;
|
|
114
|
+
};
|
|
115
|
+
type AssetFlow = {
|
|
116
|
+
readonly to: string;
|
|
117
|
+
readonly amount: AssetAmount;
|
|
118
|
+
readonly verified: boolean;
|
|
119
|
+
/** The ENS name the recipient was resolved from; attached by the engine, never decoded. */
|
|
120
|
+
readonly name?: string;
|
|
121
|
+
};
|
|
122
|
+
type ApprovalChange = {
|
|
123
|
+
/** A fungible-token allowance: on the token itself, or on Permit2 when `via` is "permit2". */
|
|
124
|
+
readonly kind: "allowance";
|
|
125
|
+
readonly spender: string;
|
|
126
|
+
/** The token and amount (base units); symbol/decimals when the token is in the built-in table. */
|
|
127
|
+
readonly amount: AssetAmount;
|
|
128
|
+
/**
|
|
129
|
+
* `set`: the allowance becomes `amount`; `increase`/`decrease`: it changes by `amount`;
|
|
130
|
+
* `transfer`: a one-time right to take up to `amount` before `expiration` (Permit2
|
|
131
|
+
* SignatureTransfer).
|
|
132
|
+
*/
|
|
133
|
+
readonly change: "set" | "increase" | "decrease" | "transfer";
|
|
134
|
+
/** `amount` is the type's maximum (uint256; uint160 for Permit2). */
|
|
135
|
+
readonly unlimited: boolean;
|
|
136
|
+
/** Unix seconds after which the allowance lapses (Permit2), when it has one. */
|
|
137
|
+
readonly expiration?: number;
|
|
138
|
+
readonly via?: "permit2";
|
|
139
|
+
/** The token is in the built-in table. */
|
|
140
|
+
readonly verified: boolean;
|
|
141
|
+
} | {
|
|
142
|
+
/** ERC-721/1155 `setApprovalForAll`: `spender` may move every token of `asset`. */
|
|
143
|
+
readonly kind: "operator";
|
|
144
|
+
readonly asset: string;
|
|
145
|
+
readonly spender: string;
|
|
146
|
+
/** `false` revokes. */
|
|
147
|
+
readonly approved: boolean;
|
|
148
|
+
readonly verified: false;
|
|
149
|
+
};
|
|
150
|
+
type IntentWarning = {
|
|
151
|
+
readonly kind: string;
|
|
152
|
+
readonly message: string;
|
|
153
|
+
};
|
|
154
|
+
/** One item a Seaport order offers or requests; recognized from EIP-712 `itemType` 0–5. */
|
|
155
|
+
type SeaportItem = {
|
|
156
|
+
readonly kind: "native" | "erc20" | "erc721" | "erc1155" | "erc721-criteria" | "erc1155-criteria";
|
|
157
|
+
/** The item's contract (EIP-55 checksummed; the zero address for `native`). */
|
|
158
|
+
readonly token: string;
|
|
159
|
+
/** `identifierOrCriteria` as a decimal string; a criteria root for the criteria kinds. */
|
|
160
|
+
readonly identifier: string;
|
|
161
|
+
readonly startAmount: AssetAmount;
|
|
162
|
+
readonly endAmount: AssetAmount;
|
|
163
|
+
};
|
|
164
|
+
/** A recognized Seaport `OrderComponents` message. */
|
|
165
|
+
type SeaportOrder = {
|
|
166
|
+
readonly offerer: string;
|
|
167
|
+
readonly zone: string;
|
|
168
|
+
readonly startTime: number | undefined;
|
|
169
|
+
readonly endTime: number | undefined;
|
|
170
|
+
readonly offer: ReadonlyArray<SeaportItem>;
|
|
171
|
+
readonly consideration: ReadonlyArray<SeaportItem & {
|
|
172
|
+
readonly recipient: string;
|
|
173
|
+
}>;
|
|
174
|
+
};
|
|
175
|
+
/** A recognized Safe `SafeTx` message. */
|
|
176
|
+
type SafeTransaction = {
|
|
177
|
+
readonly safe: string;
|
|
178
|
+
/** The Safe nonce as a decimal string. */
|
|
179
|
+
readonly nonce: string;
|
|
180
|
+
readonly operation: "call" | "delegatecall";
|
|
181
|
+
readonly to: string;
|
|
182
|
+
/** Wei, decimal. */
|
|
183
|
+
readonly value: string;
|
|
184
|
+
readonly data: string;
|
|
185
|
+
/** The inner call(s) decoded with the transaction rules (no fee); one per MultiSend entry. */
|
|
186
|
+
readonly calls: ReadonlyArray<DisplayIntent>;
|
|
187
|
+
/** The gas-refund terms, present when `gasPrice` is not zero. */
|
|
188
|
+
readonly refund?: {
|
|
189
|
+
readonly gasPrice: string;
|
|
190
|
+
readonly gasToken: string;
|
|
191
|
+
readonly refundReceiver: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
/** The EIP-712 domain fields a wallet shows. */
|
|
195
|
+
type TypedDataDomain = {
|
|
196
|
+
readonly name?: string;
|
|
197
|
+
readonly version?: string;
|
|
198
|
+
readonly chainId?: number;
|
|
199
|
+
/** EIP-55 checksummed. */
|
|
200
|
+
readonly verifyingContract?: string;
|
|
201
|
+
readonly salt?: string;
|
|
202
|
+
};
|
|
203
|
+
/** What a message request signs. */
|
|
204
|
+
type MessageContent = {
|
|
205
|
+
readonly kind: "text";
|
|
206
|
+
readonly text: string;
|
|
207
|
+
readonly signIn?: SignInParse;
|
|
208
|
+
} | {
|
|
209
|
+
readonly kind: "bytes";
|
|
210
|
+
readonly hex: string;
|
|
211
|
+
} | {
|
|
212
|
+
readonly kind: "typed-data";
|
|
213
|
+
readonly primaryType: string;
|
|
214
|
+
readonly domain: TypedDataDomain;
|
|
215
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
216
|
+
/** A recognized Seaport order; only the exact `OrderComponents` shape populates it. */
|
|
217
|
+
readonly seaport?: SeaportOrder;
|
|
218
|
+
/** A recognized Safe transaction; only the exact `SafeTx` shape populates it. */
|
|
219
|
+
readonly safe?: SafeTransaction;
|
|
220
|
+
};
|
|
221
|
+
type DisplayIntent = {
|
|
222
|
+
readonly family: ChainFamily;
|
|
223
|
+
readonly network: string;
|
|
224
|
+
readonly summary: IntentSummary;
|
|
225
|
+
readonly outflows: ReadonlyArray<AssetFlow>;
|
|
226
|
+
readonly approvals: ReadonlyArray<ApprovalChange>;
|
|
227
|
+
/**
|
|
228
|
+
* `l1Data`: OP Stack L1 data fee plus operator fee, estimated by the engine and charged on top of
|
|
229
|
+
* `max`; not decodable from the transaction, so the kernel's own decode never sets it.
|
|
230
|
+
*/
|
|
231
|
+
readonly fee: {
|
|
232
|
+
readonly max: AssetAmount;
|
|
233
|
+
readonly l1Data?: AssetAmount;
|
|
234
|
+
} | undefined;
|
|
235
|
+
readonly warnings: ReadonlyArray<IntentWarning>;
|
|
236
|
+
/** What a message request signs; absent for transactions. */
|
|
237
|
+
readonly message?: MessageContent;
|
|
238
|
+
readonly verifiability: Verifiability;
|
|
239
|
+
};
|
|
240
|
+
type ChainErrorCode = "unknown-field" | "chain-id-mismatch" | "fee-payer-mismatch" | "invalid-quantity" | "invalid-address" | "invalid-typed-data" | "invalid-request" | "unsupported";
|
|
241
|
+
declare class ChainError extends Error {
|
|
242
|
+
readonly code: ChainErrorCode;
|
|
243
|
+
constructor(code: ChainErrorCode, message: string);
|
|
244
|
+
}
|
|
245
|
+
export { SignRequest as _, ChainError as a, SignInParse as b, DisplayIntent as c, IntentSummary as d, IntentWarning as f, SeaportOrder as g, SeaportItem as h, AssetFlow as i, EvmAccessListEntry as l, SafeTransaction as m, ApprovalChange as n, ChainErrorCode as o, MessageContent as p, AssetAmount as r, ChainFamily as s, AccountRef as t, EvmTransaction as u, TypedDataDomain as v, parseSignIn as x, Verifiability as y };
|
|
246
|
+
//# sourceMappingURL=index-QxoxkD5m.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,140 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Types here are wire-safe: values crossing the main↔kernel protocol are
|
|
4
|
-
* Uint8Array, safe integers, strings, booleans, arrays and plain objects.
|
|
5
|
-
* Quantities are canonical `0x` hex (lowercase, no leading zeros, `0x0` for
|
|
6
|
-
* zero), token amounts are decimal strings of the smallest unit.
|
|
7
|
-
*/
|
|
8
|
-
export type ChainFamily = "evm" | "solana" | "bitcoin";
|
|
9
|
-
export type AccountRef = {
|
|
10
|
-
readonly kind: "hd";
|
|
11
|
-
readonly walletId: string;
|
|
12
|
-
readonly groupIndex: number;
|
|
13
|
-
readonly template: string;
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: "imported";
|
|
16
|
-
readonly keyId: string;
|
|
17
|
-
readonly family: ChainFamily;
|
|
18
|
-
};
|
|
19
|
-
export type SignRequest = {
|
|
20
|
-
readonly kind: "bitcoin.psbt";
|
|
21
|
-
readonly network: string;
|
|
22
|
-
readonly account: AccountRef;
|
|
23
|
-
readonly psbt: Uint8Array;
|
|
24
|
-
/** Input indices to sign — non-empty, unique, ascending, in range. */
|
|
25
|
-
readonly sign: ReadonlyArray<number>;
|
|
26
|
-
} | {
|
|
27
|
-
readonly kind: "bitcoin.message";
|
|
28
|
-
readonly network: string;
|
|
29
|
-
readonly account: AccountRef;
|
|
30
|
-
readonly address: string;
|
|
31
|
-
readonly message: string;
|
|
32
|
-
readonly format: "bip322-simple" | "legacy";
|
|
33
|
-
/** Account change chain and index the address is derived at (0 = receive, 1 = change). */
|
|
34
|
-
readonly change: 0 | 1;
|
|
35
|
-
readonly index: number;
|
|
36
|
-
} | {
|
|
37
|
-
readonly kind: "solana.transaction";
|
|
38
|
-
readonly network: string;
|
|
39
|
-
readonly account: AccountRef;
|
|
40
|
-
/** Compiled wire message (legacy or v0). */
|
|
41
|
-
readonly message: Uint8Array;
|
|
42
|
-
readonly lookupTables?: ReadonlyArray<{
|
|
43
|
-
readonly address: string;
|
|
44
|
-
readonly addresses: ReadonlyArray<string>;
|
|
45
|
-
}>;
|
|
46
|
-
} | {
|
|
47
|
-
readonly kind: "solana.message";
|
|
48
|
-
readonly network: string;
|
|
49
|
-
readonly account: AccountRef;
|
|
50
|
-
readonly message: Uint8Array;
|
|
51
|
-
/** Only "raw" exists in this layer; offchain formats land with C7. */
|
|
52
|
-
readonly format: "raw";
|
|
53
|
-
} | {
|
|
54
|
-
readonly kind: "evm.transaction";
|
|
55
|
-
readonly network: string;
|
|
56
|
-
readonly account: AccountRef;
|
|
57
|
-
readonly tx: EvmTransaction;
|
|
58
|
-
} | {
|
|
59
|
-
readonly kind: "evm.personal-message";
|
|
60
|
-
readonly network: string;
|
|
61
|
-
readonly account: AccountRef;
|
|
62
|
-
readonly message: Uint8Array;
|
|
63
|
-
} | {
|
|
64
|
-
readonly kind: "evm.typed-data";
|
|
65
|
-
readonly network: string;
|
|
66
|
-
readonly account: AccountRef;
|
|
67
|
-
readonly typedData: string;
|
|
68
|
-
};
|
|
69
|
-
export type EvmAccessListEntry = {
|
|
70
|
-
readonly address: string;
|
|
71
|
-
readonly storageKeys: ReadonlyArray<string>;
|
|
72
|
-
};
|
|
73
|
-
type EvmTransactionBase = {
|
|
74
|
-
readonly chainId: number;
|
|
75
|
-
readonly nonce: number;
|
|
76
|
-
readonly gas: string;
|
|
77
|
-
readonly value: string;
|
|
78
|
-
readonly data: string;
|
|
79
|
-
readonly to?: string;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* A complete transaction — every field the signer needs is present; `to` absent means contract
|
|
83
|
-
* creation.
|
|
84
|
-
*/
|
|
85
|
-
export type EvmTransaction = (EvmTransactionBase & {
|
|
86
|
-
readonly type: "legacy";
|
|
87
|
-
readonly gasPrice: string;
|
|
88
|
-
}) | (EvmTransactionBase & {
|
|
89
|
-
readonly type: "eip2930";
|
|
90
|
-
readonly gasPrice: string;
|
|
91
|
-
readonly accessList: ReadonlyArray<EvmAccessListEntry>;
|
|
92
|
-
}) | (EvmTransactionBase & {
|
|
93
|
-
readonly type: "eip1559";
|
|
94
|
-
readonly accessList: ReadonlyArray<EvmAccessListEntry>;
|
|
95
|
-
readonly maxFeePerGas: string;
|
|
96
|
-
readonly maxPriorityFeePerGas: string;
|
|
97
|
-
});
|
|
98
|
-
export type Verifiability = "full" | "partial" | "opaque";
|
|
99
|
-
export type IntentSummary = "transfer" | "approve" | "contract-call" | "swap" | "message" | "authorization" | "batch";
|
|
100
|
-
export type AssetAmount = {
|
|
101
|
-
readonly asset: string;
|
|
102
|
-
readonly amount: string;
|
|
103
|
-
readonly decimals?: number;
|
|
104
|
-
readonly symbol?: string;
|
|
105
|
-
};
|
|
106
|
-
export type AssetFlow = {
|
|
107
|
-
readonly to: string;
|
|
108
|
-
readonly amount: AssetAmount;
|
|
109
|
-
readonly verified: boolean;
|
|
110
|
-
};
|
|
111
|
-
export type ApprovalChange = {
|
|
112
|
-
readonly asset: string;
|
|
113
|
-
readonly spender: string;
|
|
114
|
-
readonly amount: string;
|
|
115
|
-
readonly unlimited: boolean;
|
|
116
|
-
readonly verified: boolean;
|
|
117
|
-
};
|
|
118
|
-
export type IntentWarning = {
|
|
119
|
-
readonly kind: string;
|
|
120
|
-
readonly message: string;
|
|
121
|
-
};
|
|
122
|
-
export type DisplayIntent = {
|
|
123
|
-
readonly family: ChainFamily;
|
|
124
|
-
readonly network: string;
|
|
125
|
-
readonly summary: IntentSummary;
|
|
126
|
-
readonly outflows: ReadonlyArray<AssetFlow>;
|
|
127
|
-
readonly approvals: ReadonlyArray<ApprovalChange>;
|
|
128
|
-
readonly fee: {
|
|
129
|
-
readonly max: AssetAmount;
|
|
130
|
-
} | undefined;
|
|
131
|
-
readonly warnings: ReadonlyArray<IntentWarning>;
|
|
132
|
-
readonly verifiability: Verifiability;
|
|
133
|
-
};
|
|
134
|
-
export type ChainErrorCode = "unknown-field" | "chain-id-mismatch" | "fee-payer-mismatch" | "invalid-quantity" | "invalid-address" | "invalid-typed-data" | "invalid-request" | "unsupported";
|
|
135
|
-
export declare class ChainError extends Error {
|
|
136
|
-
readonly code: ChainErrorCode;
|
|
137
|
-
constructor(code: ChainErrorCode, message: string);
|
|
138
|
-
}
|
|
139
|
-
export {};
|
|
140
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { _ as SignRequest, a as ChainError, b as SignInParse, c as DisplayIntent, d as IntentSummary, f as IntentWarning, g as SeaportOrder, h as SeaportItem, i as AssetFlow, l as EvmAccessListEntry, m as SafeTransaction, n as ApprovalChange, o as ChainErrorCode, p as MessageContent, r as AssetAmount, s as ChainFamily, t as AccountRef, u as EvmTransaction, v as TypedDataDomain, x as parseSignIn, y as Verifiability } from "./index-QxoxkD5m.mjs";
|
|
2
|
+
export { AccountRef, ApprovalChange, AssetAmount, AssetFlow, ChainError, ChainErrorCode, ChainFamily, DisplayIntent, EvmAccessListEntry, EvmTransaction, IntentSummary, IntentWarning, MessageContent, SafeTransaction, SeaportItem, SeaportOrder, type SignInParse, SignRequest, TypedDataDomain, Verifiability, parseSignIn };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var ChainError = class extends Error {
|
|
3
|
-
code;
|
|
4
|
-
constructor(code, message) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.name = "ChainError";
|
|
7
|
-
this.code = code;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
export { ChainError };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export { t as ChainError, n as parseSignIn } from "./src-8NZeEnrW.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainError } from "./
|
|
1
|
+
import { t as ChainError } from "./src-8NZeEnrW.mjs";
|
|
2
2
|
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
3
3
|
import { NETWORK, TEST_NETWORK } from "@scure/btc-signer/utils.js";
|
|
4
4
|
import { SigHash, Transaction } from "@scure/btc-signer/transaction.js";
|
|
@@ -185,4 +185,4 @@ const signLegacyMessage = (message, privateKey) => {
|
|
|
185
185
|
};
|
|
186
186
|
export { bitcoinNetwork as a, BITCOIN_NETWORKS as i, signBip322Simple as n, signLegacyMessage as r, bip322ToSpendTxid as t };
|
|
187
187
|
|
|
188
|
-
//# sourceMappingURL=message-
|
|
188
|
+
//# sourceMappingURL=message-ChhEZ0lx.mjs.map
|