@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-data-DRtKULsH.mjs","names":[],"sources":["../src/evm/address.ts","../src/evm/delegation.ts","../src/evm/transaction.ts","../src/evm/typed-data.ts"],"sourcesContent":["import { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { keccak_256 } from \"@noble/hashes/sha3.js\";\nimport { bytesToHex } from \"@noble/hashes/utils.js\";\nimport * as Address from \"ox/Address\";\n\nimport { ChainError } from \"../index.ts\";\n\n/** EIP-55 checksummed address, e.g. `0x52908400098527886E0F7030069857D2E4169EE7`. */\nexport const isEvmAddress = (value: string): boolean => /^0x[0-9a-fA-F]{40}$/.test(value);\n\nexport function checksumEvmAddress(address: string): string {\n if (!isEvmAddress(address)) {\n throw new ChainError(\"invalid-address\", \"not an EVM address\");\n }\n const checksummed = Address.checksum(address);\n Address.assert(checksummed, { strict: true });\n return checksummed;\n}\n\n/** `keccak256(pubkey)[12:]` — accepts a 33-byte compressed or 65-byte uncompressed secp256k1 key. */\nexport function evmAddressFromPublicKey(pubkey: Uint8Array): string {\n const uncompressed =\n pubkey.length === 65 && pubkey[0] === 4\n ? pubkey\n : pubkey.length === 33\n ? secp256k1.Point.fromBytes(pubkey).toBytes(false)\n : undefined;\n if (uncompressed === undefined || uncompressed[0] !== 4) {\n throw new ChainError(\"invalid-address\", \"expected a compressed or uncompressed secp256k1 key\");\n }\n return checksumEvmAddress(`0x${bytesToHex(keccak_256(uncompressed.subarray(1))).slice(-40)}`);\n}\n","import * as AbiFunction from \"ox/AbiFunction\";\nimport * as AbiParameters from \"ox/AbiParameters\";\nimport * as Hex from \"ox/Hex\";\n\nimport { checksumEvmAddress, isEvmAddress } from \"./address.ts\";\n\n/**\n * MetaMask Delegation Framework EIP7702StatelessDeleGator v1.3.0 — deterministic CREATE2, the same\n * address on every chain that supports it.\n */\nexport const EVM_DELEGATOR = {\n address: \"0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B\",\n name: \"EIP7702StatelessDeleGator\",\n version: \"1.3.0\",\n} as const;\n\n/** The EIP-7702 designator byte prefix: `0xef0100 ‖ address` marks a delegated account's code. */\nexport const EVM_DELEGATION_PREFIX = \"0xef0100\";\n\n/** ERC-7821 batch-default execution mode: `0x01` followed by 31 zero bytes. */\nexport const EXECUTE_BATCH_MODE =\n \"0x0100000000000000000000000000000000000000000000000000000000000000\";\n\nexport const EXECUTE: AbiFunction.AbiFunction = AbiFunction.from(\n \"function execute(bytes32 mode, bytes executionData)\",\n);\n\nconst EXECUTIONS = [\n {\n type: \"tuple[]\",\n components: [\n { name: \"target\", type: \"address\" },\n { name: \"value\", type: \"uint256\" },\n { name: \"callData\", type: \"bytes\" },\n ],\n },\n] as const;\n\nconst hex = (v: string): `0x${string}` => {\n Hex.assert(v);\n return v;\n};\n\n/** ERC-7821 batch-default self-call payload for `execute` on the delegator. */\nexport const encodeBatchExecute = (\n calls: ReadonlyArray<{ readonly to: string; readonly value: bigint; readonly data: string }>,\n): string =>\n AbiFunction.encodeData(EXECUTE, [\n EXECUTE_BATCH_MODE,\n AbiParameters.encode(EXECUTIONS, [\n calls.map((c) => ({\n target: hex(checksumEvmAddress(c.to)),\n value: c.value,\n callData: hex(c.data),\n })),\n ]),\n ]);\n\ntype Execution = { readonly to: string; readonly value: bigint; readonly data: string };\n\nconst list = (v: unknown): ReadonlyArray<unknown> => (Array.isArray(v) ? v : []);\n\nconst isExecution = (\n e: unknown,\n): e is { readonly target: string; readonly value: bigint; readonly callData: string } =>\n typeof e === \"object\" &&\n e !== null &&\n \"target\" in e &&\n \"value\" in e &&\n \"callData\" in e &&\n typeof e.target === \"string\" &&\n isEvmAddress(e.target) &&\n typeof e.value === \"bigint\" &&\n typeof e.callData === \"string\";\n\n/** Decodes an `execute` call; undefined unless the encoding is canonical batch-default mode. */\nexport const decodeBatchExecute = (data: string): ReadonlyArray<Execution> | undefined => {\n try {\n const args = list(AbiFunction.decodeData(EXECUTE, hex(data)));\n const [mode, executionData] = args;\n if (mode !== EXECUTE_BATCH_MODE || typeof executionData !== \"string\") {\n return undefined;\n }\n const decoded: unknown = AbiParameters.decode(EXECUTIONS, hex(executionData));\n const [inner] = list(decoded);\n const executions: Execution[] = [];\n for (const e of list(inner)) {\n if (!isExecution(e)) {\n return undefined;\n }\n executions.push({\n to: checksumEvmAddress(e.target),\n value: e.value,\n data: e.callData,\n });\n }\n /* Display must equal execution: accept only the canonical encoding the delegator's own\n * calldata decoder would read — a non-canonical payload (trailing bytes, aliased offsets)\n * can decode one way here and another on-chain. */\n return encodeBatchExecute(executions).toLowerCase() === data.toLowerCase()\n ? executions\n : undefined;\n } catch {\n return undefined;\n }\n};\n","import { ChainError } from \"../index.ts\";\nimport type { EvmTransaction, EvmAccessListEntry } from \"../index.ts\";\nimport { checksumEvmAddress, isEvmAddress } from \"./address.ts\";\nimport { EVM_DELEGATOR } from \"./delegation.ts\";\n\n/** Validates a string is `0x`-hex and narrows it to the branded hex type. */\nexport function assertHex(value: string, field: string): asserts value is `0x${string}` {\n if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {\n throw new ChainError(\"invalid-quantity\", `${field} must be 0x-prefixed bytes`);\n }\n}\n\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst CANONICAL_HEX = /^0x(?:0|[1-9a-f][0-9a-f]*)$/;\n\nexport const isCanonicalHex = (value: string): boolean => CANONICAL_HEX.test(value);\n\nexport const canonicalHex = (value: bigint): string => `0x${value.toString(16)}`;\n\n/** Parses a JSON-RPC quantity: `0x` and at least one hex digit — a bare `\"0x\"` is malformed. */\nexport const quantityBigInt = (value: unknown, field: string): bigint => {\n if (typeof value !== \"string\" || !/^0x[0-9a-fA-F]+$/.test(value)) {\n throw new ChainError(\"invalid-quantity\", `${field} must be a 0x quantity`);\n }\n return BigInt(value);\n};\n\nconst safeInteger = (value: unknown, field: string): number => {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) {\n throw new ChainError(\"invalid-quantity\", `${field} must be a non-negative safe integer`);\n }\n return value;\n};\n\nconst quantity = (value: unknown, field: string): string => {\n if (typeof value !== \"string\") {\n throw new ChainError(\"invalid-quantity\", `${field} must be a 0x quantity string`);\n }\n if (CANONICAL_HEX.test(value)) {\n return value;\n }\n return canonicalHex(quantityBigInt(value, field));\n};\n\nconst hexBytes = (value: unknown, field: string): string => {\n if (typeof value !== \"string\" || !/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) {\n throw new ChainError(\"invalid-quantity\", `${field} must be 0x-prefixed bytes`);\n }\n return value.toLowerCase();\n};\n\nconst accessList = (value: unknown): ReadonlyArray<EvmAccessListEntry> => {\n if (!Array.isArray(value)) {\n throw new ChainError(\"invalid-request\", \"accessList must be an array\");\n }\n return value.map((entry): EvmAccessListEntry => {\n if (!isRecord(entry)) {\n throw new ChainError(\"invalid-address\", \"accessList entries must be objects\");\n }\n const keys = Object.keys(entry).sort();\n if (keys.length !== 2 || keys[0] !== \"address\" || keys[1] !== \"storageKeys\") {\n throw new ChainError(\n \"unknown-field\",\n `accessList entry fields must be exactly address+storageKeys, got ${keys.join(\",\")}`,\n );\n }\n const { address, storageKeys } = entry;\n if (typeof address !== \"string\" || !isEvmAddress(address)) {\n throw new ChainError(\"invalid-address\", \"accessList entry has an invalid address\");\n }\n if (!Array.isArray(storageKeys)) {\n throw new ChainError(\"invalid-quantity\", \"accessList storageKeys must be an array\");\n }\n return {\n address: checksumEvmAddress(address),\n storageKeys: storageKeys.map((k) => {\n if (typeof k !== \"string\" || !/^0x[0-9a-fA-F]{64}$/.test(k)) {\n throw new ChainError(\n \"invalid-quantity\",\n \"accessList storageKeys must be 32-byte hex strings\",\n );\n }\n return k.toLowerCase();\n }),\n };\n });\n};\n\n/** The EIP-155 part of a CAIP-2 `network` string, e.g. `eip155:1` → 1. Chain 0 does not exist. */\nexport const networkChainId = (network: string): number => {\n const match = /^eip155:([1-9]\\d*)$/.exec(network);\n const idPart = match?.[1];\n if (idPart === undefined) {\n throw new ChainError(\"chain-id-mismatch\", `network is not an eip155 CAIP-2 id: ${network}`);\n }\n const id = Number(idPart);\n if (!Number.isSafeInteger(id)) {\n throw new ChainError(\"chain-id-mismatch\", `chain id is not a safe integer: ${network}`);\n }\n return id;\n};\n\nconst REQUIRED = {\n base: [\"chainId\", \"nonce\", \"gas\", \"value\", \"data\"],\n gasPrice: [\"gasPrice\"],\n accessList: [\"accessList\"],\n eip1559: [\"maxFeePerGas\", \"maxPriorityFeePerGas\"],\n} as const;\n\nconst ALLOWED = {\n base: [\"type\", \"chainId\", \"nonce\", \"gas\", \"value\", \"data\", \"to\"],\n legacy: [\"gasPrice\"],\n eip2930: [\"gasPrice\", \"accessList\"],\n eip1559: [\"accessList\", \"maxFeePerGas\", \"maxPriorityFeePerGas\"],\n eip7702: [\"accessList\", \"maxFeePerGas\", \"maxPriorityFeePerGas\", \"authorization\"],\n} as const;\n\nconst requireFields = (input: Record<string, unknown>, fields: ReadonlyArray<string>): void => {\n for (const field of fields) {\n if (input[field] === undefined) {\n throw new ChainError(\"invalid-request\", `tx.${field} is required`);\n }\n }\n};\n\nconst rejectUnknown = (\n input: Record<string, unknown>,\n type: \"legacy\" | \"eip2930\" | \"eip1559\" | \"eip7702\",\n): void => {\n const allowed = new Set<string>([...ALLOWED.base, ...ALLOWED[type]]);\n const unknown = Object.keys(input).filter((k) => !allowed.has(k));\n if (unknown.length > 0) {\n throw new ChainError(\n \"unknown-field\",\n `tx has unknown fields for ${type}: ${unknown.sort().join(\", \")}`,\n );\n }\n};\n\n/**\n * Canonicalizes an EVM transaction: exact key sets per type, all required fields present, `0x`\n * canonical quantities, EIP-55 addresses. Idempotent.\n */\nexport const normalizeEvmTransaction = (tx: unknown): EvmTransaction => {\n if (!isRecord(tx)) {\n throw new ChainError(\"invalid-request\", \"tx must be an object\");\n }\n const { type } = tx;\n if (type !== \"legacy\" && type !== \"eip2930\" && type !== \"eip1559\" && type !== \"eip7702\") {\n throw new ChainError(\n \"unsupported\",\n `transaction type ${String(type)} is not supported (legacy, eip2930, eip1559 and eip7702 only)`,\n );\n }\n rejectUnknown(tx, type);\n requireFields(tx, REQUIRED.base);\n const chainId = safeInteger(tx[\"chainId\"], \"chainId\");\n const nonce = safeInteger(tx[\"nonce\"], \"nonce\");\n const gas = quantity(tx[\"gas\"], \"gas\");\n const value = quantity(tx[\"value\"], \"value\");\n const data = hexBytes(tx[\"data\"], \"data\");\n const toRaw = tx[\"to\"];\n const to =\n toRaw === undefined\n ? undefined\n : typeof toRaw === \"string\" && isEvmAddress(toRaw)\n ? checksumEvmAddress(toRaw)\n : undefined;\n if (toRaw !== undefined && to === undefined) {\n throw new ChainError(\"invalid-address\", \"to must be a valid EVM address\");\n }\n const base = { chainId, nonce, gas, value, data, ...(to === undefined ? {} : { to }) };\n if (type === \"legacy\") {\n requireFields(tx, REQUIRED.gasPrice);\n return { type, ...base, gasPrice: quantity(tx[\"gasPrice\"], \"gasPrice\") };\n }\n if (type === \"eip2930\") {\n requireFields(tx, [...REQUIRED.gasPrice, ...REQUIRED.accessList]);\n return {\n type,\n ...base,\n gasPrice: quantity(tx[\"gasPrice\"], \"gasPrice\"),\n accessList: accessList(tx[\"accessList\"]),\n };\n }\n requireFields(tx, [...REQUIRED.accessList, ...REQUIRED.eip1559]);\n const fees = {\n maxFeePerGas: quantity(tx[\"maxFeePerGas\"], \"maxFeePerGas\"),\n maxPriorityFeePerGas: quantity(tx[\"maxPriorityFeePerGas\"], \"maxPriorityFeePerGas\"),\n };\n if (BigInt(fees.maxPriorityFeePerGas) > BigInt(fees.maxFeePerGas)) {\n throw new ChainError(\"invalid-request\", \"maxPriorityFeePerGas exceeds maxFeePerGas\");\n }\n const list = accessList(tx[\"accessList\"]);\n if (type === \"eip1559\") {\n return { type, ...base, accessList: list, ...fees };\n }\n if (to === undefined) {\n throw new ChainError(\"invalid-request\", \"tx.to is required for eip7702\");\n }\n if (chainId < 1) {\n throw new ChainError(\n \"invalid-request\",\n \"eip7702 chainId 0 is a chain-universal authorization and is never signed\",\n );\n }\n const auth = tx[\"authorization\"];\n if (!isRecord(auth) || Object.keys(auth).length !== 1 || typeof auth[\"address\"] !== \"string\") {\n throw new ChainError(\n \"invalid-request\",\n \"tx.authorization must be an object with exactly address\",\n );\n }\n const authAddress = checksumEvmAddress(auth[\"address\"]);\n if (\n authAddress !== EVM_DELEGATOR.address &&\n authAddress !== \"0x0000000000000000000000000000000000000000\"\n ) {\n throw new ChainError(\"unsupported\", \"authorization address is not supported\");\n }\n return {\n type,\n ...base,\n to,\n accessList: list,\n ...fees,\n authorization: { address: authAddress },\n };\n};\n","import * as Hex from \"ox/Hex\";\nimport * as TypedData from \"ox/TypedData\";\n\nimport { displayExcerpt, hasHiddenCharacters, isEncodedBytes } from \"../display.ts\";\nimport { ChainError } from \"../index.ts\";\nimport type { TypedDataLeaf } from \"../index.ts\";\nimport { checksumEvmAddress } from \"./address.ts\";\nimport { isRecord } from \"./transaction.ts\";\n\ntype TypedDataField = {\n readonly name: string;\n readonly type: string;\n};\n\n/**\n * The subset of the EIP-712 document the wallet needs to see before handing it to ox's validator —\n * object with `types`, `primaryType`, `domain` and `message` of the right shapes.\n */\nexport type TypedDataInput = {\n readonly types: Record<string, ReadonlyArray<TypedDataField>>;\n readonly primaryType: string;\n readonly domain: Record<string, unknown>;\n readonly message: Record<string, unknown>;\n};\n\nconst isField = (value: unknown): value is TypedDataField =>\n isRecord(value) && typeof value[\"name\"] === \"string\" && typeof value[\"type\"] === \"string\";\n\nexport const isTypedDataInput = (value: unknown): value is TypedDataInput => {\n if (!isRecord(value)) {\n return false;\n }\n const { types, primaryType, domain, message } = value;\n if (!isRecord(types)) {\n return false;\n }\n if (typeof primaryType !== \"string\" || primaryType === \"\") {\n return false;\n }\n if (!isRecord(domain)) {\n return false;\n }\n if (!isRecord(message)) {\n return false;\n }\n return Object.values(types).every((fields) => Array.isArray(fields) && fields.every(isField));\n};\n\nexport type ParsedTypedData = { readonly json: TypedDataInput };\n\n/** A message object inside the document's `message`. */\nexport type TypedDataMessage = Readonly<Record<string, unknown>>;\n\nexport const isTypedDataMessage = (value: unknown): value is TypedDataMessage =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * The EIP-712 domain separator and message struct hash of a parsed document — the same encoder\n * `planEvmTypedData` signs (`keccak256(0x1901 | domain | message)` is the task digest). `message`\n * is `undefined` when the primary type is `EIP712Domain` itself.\n */\nexport const typedDataHashes = (\n json: TypedDataInput,\n): { readonly domain: Uint8Array; readonly message: Uint8Array | undefined } => {\n // ox encodes `0x19 ‖ 0x01 ‖ domainSeparator ‖ hashStruct(message)`; the struct hash is absent\n // when the primary type is EIP712Domain itself.\n const encoded = Hex.toBytes(\n TypedData.encode({\n domain: json.domain,\n types: json.types,\n primaryType: json.primaryType,\n message: json.message,\n }),\n );\n return {\n domain: encoded.subarray(2, 34),\n message: json.primaryType === \"EIP712Domain\" ? undefined : encoded.subarray(34),\n };\n};\n\n/** `value` is an array of message objects (empty allowed). */\nexport const typedDataMessages = (value: unknown): ReadonlyArray<TypedDataMessage> | undefined =>\n Array.isArray(value) && value.every(isTypedDataMessage) ? value : undefined;\n\n/** The `Type field,Type field` signature of struct `name` in `types`. */\nexport const typedDataSignature = (\n types: TypedDataInput[\"types\"],\n name: string,\n): string | undefined => types[name]?.map((field) => `${field.type} ${field.name}`).join(\",\");\n\n/** Struct `name` has exactly `fields`, in order, no more. */\nexport const sameFields = (\n types: TypedDataInput[\"types\"],\n name: string,\n fields: ReadonlyArray<string>,\n): boolean => typedDataSignature(types, name) === fields.join(\",\");\n\n/** A hex `address` field value, checksummed; `undefined` when malformed. */\nexport const typedDataAddress = (value: unknown): string | undefined =>\n typeof value === \"string\" && /^0x[0-9a-fA-F]{40}$/.test(value)\n ? checksumEvmAddress(value)\n : undefined;\n\n/** A uint field value (safe-integer number, decimal or `0x` hex string) ≤ `max`. */\nexport const typedDataUint = (value: unknown, max: bigint): bigint | undefined => {\n let parsed: bigint;\n if (typeof value === \"number\" && Number.isSafeInteger(value)) {\n parsed = BigInt(value);\n } else if (typeof value === \"string\" && /^(?:[0-9]+|0x[0-9a-fA-F]+)$/.test(value)) {\n parsed = BigInt(value);\n } else {\n return undefined;\n }\n return parsed >= 0n && parsed <= max ? parsed : undefined;\n};\n\n/** The largest timestamp a permit/order expiry or a Safe field is allowed to carry. */\nexport const MAX_UINT48: bigint = 2n ** 48n - 1n;\n\nconst isHexBytes = (value: unknown): value is `0x${string}` =>\n typeof value === \"string\" && /^0x(?:[0-9a-fA-F]{2})*$/.test(value);\n\n/** A `bytes` field value: `0x`-prefixed hex of even length. */\nexport const typedDataBytes = (value: unknown): `0x${string}` | undefined =>\n isHexBytes(value) ? value : undefined;\n\n/** Struct nesting allowed in a message — real protocols (Seaport, Permit2, Safe) stay under 8. */\nexport const MAX_TYPED_DATA_DEPTH = 32;\n\n/**\n * Walks `value` along `type`: every struct-typed value must be an object carrying its fields, and\n * struct/array nesting stays within MAX_TYPED_DATA_DEPTH — so a recursive type is bounded by its\n * message and a missing nested struct fails here rather than inside the encoder.\n */\nconst checkStructure = (\n types: TypedDataInput[\"types\"],\n type: string,\n value: unknown,\n depth: number,\n): void => {\n const array = /^(.+)\\[\\d*\\]$/.exec(type);\n const struct = array === null ? types[type] : undefined;\n if (array === null && struct === undefined) {\n return;\n }\n if (depth >= MAX_TYPED_DATA_DEPTH) {\n throw new ChainError(\"invalid-typed-data\", \"typedData nests too deeply\");\n }\n if (array !== null) {\n if (!Array.isArray(value)) {\n throw new ChainError(\"invalid-typed-data\", `typedData ${type} value is not an array`);\n }\n for (const item of value) {\n checkStructure(types, array[1] ?? \"\", item, depth + 1);\n }\n return;\n }\n if (!isRecord(value)) {\n throw new ChainError(\"invalid-typed-data\", `typedData ${type} value is not an object`);\n }\n for (const field of struct ?? []) {\n checkStructure(types, field.type, value[field.name], depth + 1);\n }\n};\n\n/**\n * Parses the EIP-712 JSON source and validates it with ox. `types.EIP712Domain` is required:\n * without it ox derives the domain type from the domain object while MetaMask hashes an empty\n * domain, so the same document would sign differently across wallets.\n */\nexport const parseTypedData = (typedData: string): ParsedTypedData => {\n let json: unknown;\n try {\n json = JSON.parse(typedData);\n } catch {\n throw new ChainError(\"invalid-typed-data\", \"typedData is not valid JSON\");\n }\n if (!isTypedDataInput(json)) {\n throw new ChainError(\n \"invalid-typed-data\",\n \"typedData must be a JSON object with types, primaryType, domain and message\",\n );\n }\n if (json.types[\"EIP712Domain\"] === undefined) {\n throw new ChainError(\"invalid-typed-data\", \"typedData must declare types.EIP712Domain\");\n }\n try {\n TypedData.validate(json);\n } catch {\n throw new ChainError(\"invalid-typed-data\", \"typedData failed EIP-712 validation\");\n }\n checkStructure(json.types, json.primaryType, json.message, 0);\n /* Only the domain keys `types.EIP712Domain` declares are hashed — undeclared keys are\n dropped so nothing downstream (display, recognisers, the chain-id check, signing) can\n read a field the signature does not commit to. */\n const declared = new Set((json.types[\"EIP712Domain\"] ?? []).map((field) => field.name));\n const domain = Object.fromEntries(\n Object.entries(json.domain).filter(([key]) => declared.has(key)),\n );\n return { json: { ...json, domain } };\n};\n\n/** Most leaves an unrecognised typed-data document may have and still be shown in full. */\nexport const TYPED_FIELD_BUDGET = 16;\n\n/** Longest path or value (in code points, after sanitising) one leaf line may show. */\nexport const TYPED_FIELD_CODE_POINTS = 96;\n\nconst FIXED_BYTES = /^bytes(?:[1-9]|[12][0-9]|3[0-2])$/;\nconst INT_TYPE = /^u?int([0-9]*)$/;\n\n/**\n * The display value of one atomic leaf, or `undefined` when the value is not in a form that is\n * shown exactly as it is encoded. Only the canonical forms every EIP-712 hasher agrees on are\n * accepted — anything else aborts the whole expansion.\n */\nconst leafValue = (type: string, value: unknown): string | undefined => {\n if (type === \"address\") {\n return typedDataAddress(value);\n }\n if (type === \"bool\") {\n return typeof value === \"boolean\" ? (value ? \"true\" : \"false\") : undefined;\n }\n if (type === \"string\") {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const excerpt = displayExcerpt(value, 1, TYPED_FIELD_CODE_POINTS);\n return excerpt.omitted === 0 ? (excerpt.lines[0] ?? \"\") : undefined;\n }\n if (type === \"bytes\" || FIXED_BYTES.test(type)) {\n return typeof value === \"string\" &&\n /^0x([0-9a-fA-F]{2})*$/.test(value) &&\n value.length <= TYPED_FIELD_CODE_POINTS\n ? value.toLowerCase()\n : undefined;\n }\n const int = INT_TYPE.exec(type);\n if (int !== null) {\n const bits = int[1] === \"\" ? 256 : Number(int[1]);\n if (bits % 8 !== 0 || bits < 8 || bits > 256) {\n return undefined;\n }\n const signed = !type.startsWith(\"u\");\n let parsed: bigint;\n if (typeof value === \"number\" && Number.isSafeInteger(value)) {\n parsed = BigInt(value);\n } else if (\n typeof value === \"string\" &&\n ((signed ? /^-?[0-9]+$/ : /^[0-9]+$/).test(value) || /^0x[0-9a-fA-F]+$/.test(value))\n ) {\n parsed = BigInt(value);\n } else {\n return undefined;\n }\n const min = signed ? -(2n ** BigInt(bits - 1)) : 0n;\n const max = signed ? 2n ** BigInt(bits - 1) - 1n : 2n ** BigInt(bits) - 1n;\n return parsed >= min && parsed <= max ? parsed.toString(10) : undefined;\n }\n return undefined;\n};\n\n/**\n * Whether the atomic leaf of `type` holding `value` is a commitment: `bytesN` always is — the\n * signature commits to raw bytes the owner cannot read — as is a non-empty `bytes` or a `string`\n * that is just an encoded-bytes rendering of ≥ 32 bytes. `\"0x\"` and an empty-array leaf (\"[]\")\n * carry nothing and are not.\n */\nconst isCommitmentLeaf = (type: string, value: unknown): boolean =>\n (type === \"bytes\" && value !== \"0x\") ||\n FIXED_BYTES.test(type) ||\n (type === \"string\" && typeof value === \"string\" && isEncodedBytes(value));\n\n/**\n * Every leaf of `message` under `primaryType`, in EIP-712 encoding order (each struct's fields in\n * declaration order, arrays element by element), as display lines, and whether any leaf is a\n * commitment; `undefined` when there are more than TYPED_FIELD_BUDGET leaves or any leaf cannot be\n * shown exactly as it is encoded. `leaf` may override an atomic leaf's display — a string return is\n * used verbatim (commitment flags still apply) and `undefined` falls back to the default rule,\n * which aborts the expansion when it cannot show the leaf exactly.\n */\nexport const typedDataFields = (\n json: TypedDataInput,\n leaf?: (type: string, value: unknown) => string | undefined,\n):\n | { readonly fields: ReadonlyArray<TypedDataLeaf>; readonly hasCommitment: boolean }\n | undefined => {\n const leaves: TypedDataLeaf[] = [];\n let hasCommitment = false;\n const push = (path: string, value: string, commits: boolean): boolean => {\n const excerpt = displayExcerpt(path, 1, TYPED_FIELD_CODE_POINTS);\n if (excerpt.omitted !== 0) {\n return false;\n }\n leaves.push({ path: excerpt.lines[0] ?? \"\", value });\n hasCommitment = hasCommitment || commits;\n return leaves.length <= TYPED_FIELD_BUDGET;\n };\n const walk = (type: string, value: unknown, path: string): boolean => {\n const array = /^(.+)\\[\\d*\\]$/.exec(type);\n if (array !== null) {\n if (!Array.isArray(value)) {\n return false;\n }\n return value.length === 0\n ? push(path, \"[]\", false)\n : value.every((item, index) => walk(array[1] ?? \"\", item, `${path}[${index}]`));\n }\n const struct = json.types[type];\n if (struct !== undefined) {\n return (\n isTypedDataMessage(value) &&\n struct.every((field) =>\n walk(field.type, value[field.name], path === \"\" ? field.name : `${path}.${field.name}`),\n )\n );\n }\n const display = leaf?.(type, value) ?? leafValue(type, value);\n return display !== undefined && push(path, display, isCommitmentLeaf(type, value));\n };\n return walk(json.primaryType, json.message, \"\") ? { fields: leaves, hasCommitment } : undefined;\n};\n\n/**\n * Whether any `string` leaf of the document carries characters the text rule hides — domain fields\n * under `types.EIP712Domain` (or the fields ox derives when it is not declared) and message fields\n * under `primaryType`, walked through structs and arrays — or the type encoding's own strings do:\n * `primaryType`, every key of `types`, and every field's `name` and `type` are hashed into the\n * signature, so a deceptive code point there is blind for the same reason as hidden message bytes.\n * All declared types are scanned, not only the ones the primary type reaches. A key the type does\n * not declare is not signed and is ignored. Never throws: a branch it cannot walk counts as no\n * hidden text — malformed documents are refused by the validator.\n */\nexport const typedDataHasHiddenText = (json: TypedDataInput): boolean => {\n const hidden = (type: string, value: unknown, depth: number): boolean => {\n if (depth >= MAX_TYPED_DATA_DEPTH) {\n return false;\n }\n const array = /^(.+)\\[\\d*\\]$/.exec(type);\n if (array !== null) {\n return Array.isArray(value) && value.some((item) => hidden(array[1] ?? \"\", item, depth + 1));\n }\n const struct = json.types[type];\n if (struct !== undefined) {\n return (\n isRecord(value) && struct.some((field) => hidden(field.type, value[field.name], depth + 1))\n );\n }\n return type === \"string\" && typeof value === \"string\" && hasHiddenCharacters(value);\n };\n const domainFields =\n json.types[\"EIP712Domain\"] ?? TypedData.extractEip712DomainTypes(json.domain);\n const namesHidden =\n hasHiddenCharacters(json.primaryType) ||\n Object.entries(json.types).some(\n ([name, struct]) =>\n hasHiddenCharacters(name) ||\n struct.some((field) => hasHiddenCharacters(field.name) || hasHiddenCharacters(field.type)),\n ) ||\n domainFields.some(\n (field) => hasHiddenCharacters(field.name) || hasHiddenCharacters(field.type),\n );\n return (\n namesHidden ||\n domainFields.some((field) => hidden(field.type, json.domain[field.name], 0)) ||\n hidden(json.primaryType, json.message, 0)\n );\n};\n\n/**\n * `domain.chainId` as a number, when present: a safe non-negative integer given as a JSON number, a\n * decimal string or a `0x` hex string.\n */\nexport const domainChainId = (domain: Record<string, unknown>): number | undefined => {\n const { chainId } = domain;\n if (chainId === undefined) {\n return undefined;\n }\n const numeric =\n typeof chainId === \"number\"\n ? chainId\n : typeof chainId === \"string\" && /^(?:[0-9]+|0x[0-9a-fA-F]+)$/.test(chainId)\n ? Number(chainId)\n : Number.NaN;\n if (!Number.isSafeInteger(numeric) || numeric < 0) {\n throw new ChainError(\"invalid-typed-data\", \"typed-data domain.chainId is malformed\");\n }\n return numeric;\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,gBAAgB,UAA2B,sBAAsB,KAAK,KAAK;AAExF,SAAgB,mBAAmB,SAAyB;CAC1D,IAAI,CAAC,aAAa,OAAO,GACvB,MAAM,IAAI,WAAW,mBAAmB,oBAAoB;CAE9D,MAAM,cAAc,QAAQ,SAAS,OAAO;CAC5C,QAAQ,OAAO,aAAa,EAAE,QAAQ,KAAK,CAAC;CAC5C,OAAO;AACT;;AAGA,SAAgB,wBAAwB,QAA4B;CAClE,MAAM,eACJ,OAAO,WAAW,MAAM,OAAO,OAAO,IAClC,SACA,OAAO,WAAW,KAChB,UAAU,MAAM,UAAU,MAAM,CAAC,CAAC,QAAQ,KAAK,IAC/C,KAAA;CACR,IAAI,iBAAiB,KAAA,KAAa,aAAa,OAAO,GACpD,MAAM,IAAI,WAAW,mBAAmB,qDAAqD;CAE/F,OAAO,mBAAmB,KAAK,WAAW,WAAW,aAAa,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG;AAC9F;;;;;;ACrBA,MAAa,gBAAgB;CAC3B,SAAS;CACT,MAAM;CACN,SAAS;AACX;;AAG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K,MAAM,mBAAmB,UAAU,yBAAyB,KAAK,MAAM;CAW9E,OATE,oBAAoB,KAAK,WAAW,KACpC,OAAO,QAAQ,KAAK,KAAK,CAAC,CAAC,MACxB,CAAC,MAAM,YACN,oBAAoB,IAAI,KACxB,OAAO,MAAM,UAAU,oBAAoB,MAAM,IAAI,KAAK,oBAAoB,MAAM,IAAI,CAAC,CAC7F,KACA,aAAa,MACV,UAAU,oBAAoB,MAAM,IAAI,KAAK,oBAAoB,MAAM,IAAI,CAC9E,KAGA,aAAa,MAAM,UAAU,OAAO,MAAM,MAAM,KAAK,OAAO,MAAM,OAAO,CAAC,CAAC,KAC3E,OAAO,KAAK,aAAa,KAAK,SAAS,CAAC;AAE5C;;;;;AAMA,MAAa,iBAAiB,WAAwD;CACpF,MAAM,EAAE,YAAY;CACpB,IAAI,YAAY,KAAA,GACd;CAEF,MAAM,UACJ,OAAO,YAAY,WACf,UACA,OAAO,YAAY,YAAY,8BAA8B,KAAK,OAAO,IACvE,OAAO,OAAO,IACd;CACR,IAAI,CAAC,OAAO,cAAc,OAAO,KAAK,UAAU,GAC9C,MAAM,IAAI,WAAW,sBAAsB,wCAAwC;CAErF,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qntx/wallet-chains",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "qntx/wallet chain semantics: SignRequest codecs, display decoding, verifiability and signing for EVM, Solana and Bitcoin",
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "qntx/wallet chain semantics: SignRequest codecs, display decoding, verifiability and signing for EVM, Solana, TRON and Bitcoin",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "QuantX <x@qntx.org>",
|
|
7
7
|
"repository": {
|
|
@@ -46,6 +46,18 @@
|
|
|
46
46
|
"types": "./dist/bitcoin-sign.d.mts",
|
|
47
47
|
"default": "./dist/bitcoin-sign.mjs"
|
|
48
48
|
},
|
|
49
|
+
"./tron/sign": {
|
|
50
|
+
"types": "./dist/tron-sign.d.mts",
|
|
51
|
+
"default": "./dist/tron-sign.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./tron": {
|
|
54
|
+
"types": "./dist/tron.d.mts",
|
|
55
|
+
"default": "./dist/tron.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./networks": {
|
|
58
|
+
"types": "./dist/networks.d.mts",
|
|
59
|
+
"default": "./dist/networks.mjs"
|
|
60
|
+
},
|
|
49
61
|
"./package.json": "./package.json"
|
|
50
62
|
},
|
|
51
63
|
"publishConfig": {
|
|
@@ -55,9 +67,10 @@
|
|
|
55
67
|
"build": "vp pack",
|
|
56
68
|
"test": "vp test && bun scripts/size-check.ts",
|
|
57
69
|
"test:coverage": "vp test --coverage",
|
|
70
|
+
"fuzz": "vp test fuzz --testTimeout 1800000",
|
|
58
71
|
"typecheck": "tsc --noEmit",
|
|
59
72
|
"smoke:hermes": "bun scripts/hermes-smoke.ts",
|
|
60
|
-
"check:pkg": "vp pack && bun ../../scripts/check-dist-deps.ts . && publint && attw --pack . --profile esm-only"
|
|
73
|
+
"check:pkg": "vp pack && bun ../../scripts/check-dist-deps.ts . && bun ../../scripts/check-api.ts . && publint && attw --pack . --profile esm-only"
|
|
61
74
|
},
|
|
62
75
|
"dependencies": {
|
|
63
76
|
"@noble/curves": "2.4.0",
|
|
@@ -69,6 +82,7 @@
|
|
|
69
82
|
"@solana/addresses": "8.5.0",
|
|
70
83
|
"@solana/codecs": "8.5.0",
|
|
71
84
|
"@solana/transaction-messages": "8.5.0",
|
|
85
|
+
"@solana/transactions": "8.5.0",
|
|
72
86
|
"ox": "1.8.12"
|
|
73
87
|
},
|
|
74
88
|
"devDependencies": {
|
|
@@ -92,13 +106,6 @@
|
|
|
92
106
|
"viem": "2.57.12",
|
|
93
107
|
"vite-plus": "1.4.0"
|
|
94
108
|
},
|
|
95
|
-
"devEngines": {
|
|
96
|
-
"packageManager": {
|
|
97
|
-
"name": "bun",
|
|
98
|
-
"version": "1.4.0",
|
|
99
|
-
"onFail": "ignore"
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
109
|
"engines": {
|
|
103
110
|
"node": ">=20.19.0"
|
|
104
111
|
}
|
|
@@ -1,354 +0,0 @@
|
|
|
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
|
-
/** The BIP-44/49/84/86 account-level templates a bitcoin.psbt input may sign under. */
|
|
29
|
-
type BitcoinTemplate = "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
|
|
30
|
-
type SignRequest = {
|
|
31
|
-
readonly kind: "bitcoin.psbt";
|
|
32
|
-
readonly network: string;
|
|
33
|
-
/** The wallet group whose keys sign; each signed input names its template. */
|
|
34
|
-
readonly account: {
|
|
35
|
-
readonly kind: "hd";
|
|
36
|
-
readonly walletId: string;
|
|
37
|
-
readonly groupIndex: number;
|
|
38
|
-
};
|
|
39
|
-
readonly psbt: Uint8Array;
|
|
40
|
-
/** Inputs to sign — non-empty, unique, ascending by index, in range; each with its template. */
|
|
41
|
-
readonly sign: ReadonlyArray<{
|
|
42
|
-
readonly index: number;
|
|
43
|
-
readonly template: BitcoinTemplate;
|
|
44
|
-
}>;
|
|
45
|
-
} | {
|
|
46
|
-
readonly kind: "bitcoin.message";
|
|
47
|
-
readonly network: string;
|
|
48
|
-
readonly account: AccountRef;
|
|
49
|
-
readonly address: string;
|
|
50
|
-
readonly message: string;
|
|
51
|
-
readonly format: "bip322-simple" | "legacy";
|
|
52
|
-
/** Account change chain and index the address is derived at (0 = receive, 1 = change). */
|
|
53
|
-
readonly change: 0 | 1;
|
|
54
|
-
readonly index: number;
|
|
55
|
-
} | {
|
|
56
|
-
readonly kind: "solana.transaction";
|
|
57
|
-
readonly network: string;
|
|
58
|
-
readonly account: AccountRef;
|
|
59
|
-
/** Compiled wire message (legacy or v0). */
|
|
60
|
-
readonly message: Uint8Array;
|
|
61
|
-
readonly lookupTables?: ReadonlyArray<{
|
|
62
|
-
readonly address: string;
|
|
63
|
-
readonly addresses: ReadonlyArray<string>;
|
|
64
|
-
}>;
|
|
65
|
-
} | {
|
|
66
|
-
readonly kind: "solana.message";
|
|
67
|
-
readonly network: string;
|
|
68
|
-
readonly account: AccountRef;
|
|
69
|
-
readonly message: Uint8Array;
|
|
70
|
-
/** Only "raw" exists in this layer; offchain formats land with C7. */
|
|
71
|
-
readonly format: "raw";
|
|
72
|
-
} | {
|
|
73
|
-
readonly kind: "evm.transaction";
|
|
74
|
-
readonly network: string;
|
|
75
|
-
readonly account: AccountRef;
|
|
76
|
-
readonly tx: EvmTransaction;
|
|
77
|
-
} | {
|
|
78
|
-
readonly kind: "evm.personal-message";
|
|
79
|
-
readonly network: string;
|
|
80
|
-
readonly account: AccountRef;
|
|
81
|
-
readonly message: Uint8Array;
|
|
82
|
-
} | {
|
|
83
|
-
readonly kind: "evm.typed-data";
|
|
84
|
-
readonly network: string;
|
|
85
|
-
readonly account: AccountRef;
|
|
86
|
-
readonly typedData: string;
|
|
87
|
-
};
|
|
88
|
-
type EvmAccessListEntry = {
|
|
89
|
-
readonly address: string;
|
|
90
|
-
readonly storageKeys: ReadonlyArray<string>;
|
|
91
|
-
};
|
|
92
|
-
type EvmTransactionBase = {
|
|
93
|
-
readonly chainId: number;
|
|
94
|
-
readonly nonce: number;
|
|
95
|
-
readonly gas: string;
|
|
96
|
-
readonly value: string;
|
|
97
|
-
readonly data: string;
|
|
98
|
-
readonly to?: string;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* A complete transaction — every field the signer needs is present; `to` absent means contract
|
|
102
|
-
* creation.
|
|
103
|
-
*/
|
|
104
|
-
type EvmTransaction = (EvmTransactionBase & {
|
|
105
|
-
readonly type: "legacy";
|
|
106
|
-
readonly gasPrice: string;
|
|
107
|
-
}) | (EvmTransactionBase & {
|
|
108
|
-
readonly type: "eip2930";
|
|
109
|
-
readonly gasPrice: string;
|
|
110
|
-
readonly accessList: ReadonlyArray<EvmAccessListEntry>;
|
|
111
|
-
}) | (EvmTransactionBase & {
|
|
112
|
-
readonly type: "eip1559";
|
|
113
|
-
readonly accessList: ReadonlyArray<EvmAccessListEntry>;
|
|
114
|
-
readonly maxFeePerGas: string;
|
|
115
|
-
readonly maxPriorityFeePerGas: string;
|
|
116
|
-
}) | (Omit<EvmTransactionBase, "to"> & {
|
|
117
|
-
readonly type: "eip7702";
|
|
118
|
-
readonly to: string;
|
|
119
|
-
readonly accessList: ReadonlyArray<EvmAccessListEntry>;
|
|
120
|
-
readonly maxFeePerGas: string;
|
|
121
|
-
readonly maxPriorityFeePerGas: string;
|
|
122
|
-
/**
|
|
123
|
-
* One self-sponsored authorization: its chain id is the transaction's chain id and its nonce
|
|
124
|
-
* is `tx.nonce + 1`, so multi-tuple or nonce-mismatched authorizations are unrepresentable.
|
|
125
|
-
* The zero address revokes an existing delegation.
|
|
126
|
-
*/
|
|
127
|
-
readonly authorization: {
|
|
128
|
-
readonly address: string;
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
type Verifiability = "full" | "partial" | "opaque";
|
|
132
|
-
type IntentSummary = "transfer" | "approve" | "contract-call" | "swap" | "message" | "authorization" | "batch" | "stake" | "bridge";
|
|
133
|
-
type AssetAmount = {
|
|
134
|
-
readonly asset: string;
|
|
135
|
-
readonly amount: string;
|
|
136
|
-
readonly decimals?: number;
|
|
137
|
-
readonly symbol?: string;
|
|
138
|
-
/** NFT flows only: the decimal token id; `amount` is then the unit count. */
|
|
139
|
-
readonly tokenId?: string;
|
|
140
|
-
};
|
|
141
|
-
type AssetFlow = {
|
|
142
|
-
readonly to: string;
|
|
143
|
-
readonly amount: AssetAmount;
|
|
144
|
-
readonly verified: boolean;
|
|
145
|
-
/** The ENS name the recipient was resolved from; attached by the engine, never decoded. */
|
|
146
|
-
readonly name?: string;
|
|
147
|
-
};
|
|
148
|
-
type ApprovalChange = {
|
|
149
|
-
/** A fungible-token allowance: on the token itself, or on Permit2 when `via` is "permit2". */
|
|
150
|
-
readonly kind: "allowance";
|
|
151
|
-
readonly spender: string;
|
|
152
|
-
/** The token and amount (base units); symbol/decimals when the token is in the built-in table. */
|
|
153
|
-
readonly amount: AssetAmount;
|
|
154
|
-
/**
|
|
155
|
-
* `set`: the allowance becomes `amount`; `increase`/`decrease`: it changes by `amount`;
|
|
156
|
-
* `transfer`: a one-time right to take up to `amount` before `expiration` (Permit2
|
|
157
|
-
* SignatureTransfer).
|
|
158
|
-
*/
|
|
159
|
-
readonly change: "set" | "increase" | "decrease" | "transfer";
|
|
160
|
-
/** `amount` is the type's maximum (uint256; uint160 for Permit2). */
|
|
161
|
-
readonly unlimited: boolean;
|
|
162
|
-
/** Unix seconds after which the allowance lapses (Permit2), when it has one. */
|
|
163
|
-
readonly expiration?: number;
|
|
164
|
-
readonly via?: "permit2" | "allowance-holder";
|
|
165
|
-
/** The token is in the built-in table. */
|
|
166
|
-
readonly verified: boolean;
|
|
167
|
-
} | {
|
|
168
|
-
/** ERC-721/1155 `setApprovalForAll`: `spender` may move every token of `asset`. */
|
|
169
|
-
readonly kind: "operator";
|
|
170
|
-
readonly asset: string;
|
|
171
|
-
readonly spender: string;
|
|
172
|
-
/** `false` revokes. */
|
|
173
|
-
readonly approved: boolean;
|
|
174
|
-
readonly verified: false;
|
|
175
|
-
} | {
|
|
176
|
-
/**
|
|
177
|
-
* A Solana stake account's staker or withdrawer role handed to a key other than the signer —
|
|
178
|
-
* by an `Authorize`/`AuthorizeChecked` instruction, or by `Initialize` naming a non-signer.
|
|
179
|
-
*/
|
|
180
|
-
readonly kind: "stake-authority";
|
|
181
|
-
/** The stake account the role applies to. */
|
|
182
|
-
readonly account: string;
|
|
183
|
-
readonly role: "staker" | "withdrawer";
|
|
184
|
-
/** The key receiving the role. */
|
|
185
|
-
readonly authority: string;
|
|
186
|
-
readonly verified: false;
|
|
187
|
-
};
|
|
188
|
-
/** One staking operation shown on the signing surface. */
|
|
189
|
-
type StakeAction = {
|
|
190
|
-
readonly kind: "create";
|
|
191
|
-
readonly account: string;
|
|
192
|
-
readonly lamports: string;
|
|
193
|
-
} | {
|
|
194
|
-
readonly kind: "delegate";
|
|
195
|
-
readonly account: string;
|
|
196
|
-
readonly validator: string;
|
|
197
|
-
} | {
|
|
198
|
-
readonly kind: "deactivate";
|
|
199
|
-
readonly account: string;
|
|
200
|
-
} | {
|
|
201
|
-
readonly kind: "withdraw";
|
|
202
|
-
readonly account: string;
|
|
203
|
-
readonly to: string;
|
|
204
|
-
readonly lamports: string;
|
|
205
|
-
} |
|
|
206
|
-
/** Lido `submit` on Ethereum mainnet: ETH in, approximately `receive` stETH back. */
|
|
207
|
-
{
|
|
208
|
-
readonly kind: "lido-submit";
|
|
209
|
-
readonly amount: AssetAmount;
|
|
210
|
-
readonly receive: AssetAmount;
|
|
211
|
-
} |
|
|
212
|
-
/** Lido withdrawal request on Ethereum mainnet; `owner` gets the claim NFT. */
|
|
213
|
-
{
|
|
214
|
-
readonly kind: "lido-request";
|
|
215
|
-
readonly token: string;
|
|
216
|
-
readonly amount: AssetAmount;
|
|
217
|
-
readonly owner: string;
|
|
218
|
-
} |
|
|
219
|
-
/** Lido claim of finalised withdrawal requests on Ethereum mainnet (ETH to the caller). */
|
|
220
|
-
{
|
|
221
|
-
readonly kind: "lido-claim";
|
|
222
|
-
readonly requestIds: ReadonlyArray<string>;
|
|
223
|
-
};
|
|
224
|
-
type IntentWarning = {
|
|
225
|
-
readonly kind: string;
|
|
226
|
-
readonly message: string;
|
|
227
|
-
};
|
|
228
|
-
/** One item a Seaport order offers or requests; recognized from EIP-712 `itemType` 0–5. */
|
|
229
|
-
type SeaportItem = {
|
|
230
|
-
readonly kind: "native" | "erc20" | "erc721" | "erc1155" | "erc721-criteria" | "erc1155-criteria";
|
|
231
|
-
/** The item's contract (EIP-55 checksummed; the zero address for `native`). */
|
|
232
|
-
readonly token: string;
|
|
233
|
-
/** `identifierOrCriteria` as a decimal string; a criteria root for the criteria kinds. */
|
|
234
|
-
readonly identifier: string;
|
|
235
|
-
readonly startAmount: AssetAmount;
|
|
236
|
-
readonly endAmount: AssetAmount;
|
|
237
|
-
};
|
|
238
|
-
/** A recognized Seaport `OrderComponents` message. */
|
|
239
|
-
type SeaportOrder = {
|
|
240
|
-
readonly offerer: string;
|
|
241
|
-
readonly zone: string;
|
|
242
|
-
readonly startTime: number | undefined;
|
|
243
|
-
readonly endTime: number | undefined;
|
|
244
|
-
readonly offer: ReadonlyArray<SeaportItem>;
|
|
245
|
-
readonly consideration: ReadonlyArray<SeaportItem & {
|
|
246
|
-
readonly recipient: string;
|
|
247
|
-
}>;
|
|
248
|
-
};
|
|
249
|
-
/** A recognized Safe `SafeTx` message. */
|
|
250
|
-
type SafeTransaction = {
|
|
251
|
-
readonly safe: string;
|
|
252
|
-
/** The Safe nonce as a decimal string. */
|
|
253
|
-
readonly nonce: string;
|
|
254
|
-
readonly operation: "call" | "delegatecall";
|
|
255
|
-
readonly to: string;
|
|
256
|
-
/** Wei, decimal. */
|
|
257
|
-
readonly value: string;
|
|
258
|
-
readonly data: string;
|
|
259
|
-
/** The inner call(s) decoded with the transaction rules (no fee); one per MultiSend entry. */
|
|
260
|
-
readonly calls: ReadonlyArray<DisplayIntent>;
|
|
261
|
-
/** The gas-refund terms, present when `gasPrice` is not zero. */
|
|
262
|
-
readonly refund?: {
|
|
263
|
-
readonly gasPrice: string;
|
|
264
|
-
readonly gasToken: string;
|
|
265
|
-
readonly refundReceiver: string;
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
/** The EIP-712 domain fields a wallet shows. */
|
|
269
|
-
type TypedDataDomain = {
|
|
270
|
-
readonly name?: string;
|
|
271
|
-
readonly version?: string;
|
|
272
|
-
readonly chainId?: number;
|
|
273
|
-
/** EIP-55 checksummed. */
|
|
274
|
-
readonly verifyingContract?: string;
|
|
275
|
-
readonly salt?: string;
|
|
276
|
-
};
|
|
277
|
-
/** What a message request signs. */
|
|
278
|
-
type MessageContent = {
|
|
279
|
-
readonly kind: "text";
|
|
280
|
-
readonly text: string;
|
|
281
|
-
readonly signIn?: SignInParse;
|
|
282
|
-
} | {
|
|
283
|
-
readonly kind: "bytes";
|
|
284
|
-
readonly hex: string;
|
|
285
|
-
} | {
|
|
286
|
-
readonly kind: "typed-data";
|
|
287
|
-
readonly primaryType: string;
|
|
288
|
-
readonly domain: TypedDataDomain;
|
|
289
|
-
readonly data: Readonly<Record<string, unknown>>;
|
|
290
|
-
/** A recognized Seaport order; only the exact `OrderComponents` shape populates it. */
|
|
291
|
-
readonly seaport?: SeaportOrder;
|
|
292
|
-
/** A recognized Safe transaction; only the exact `SafeTx` shape populates it. */
|
|
293
|
-
readonly safe?: SafeTransaction;
|
|
294
|
-
};
|
|
295
|
-
type DisplayIntent = {
|
|
296
|
-
readonly family: ChainFamily;
|
|
297
|
-
readonly network: string;
|
|
298
|
-
readonly summary: IntentSummary;
|
|
299
|
-
readonly outflows: ReadonlyArray<AssetFlow>;
|
|
300
|
-
readonly approvals: ReadonlyArray<ApprovalChange>;
|
|
301
|
-
/**
|
|
302
|
-
* The minimums the settlement contracts enforce on-chain for recognised swaps — each
|
|
303
|
-
* `minAmountOut` a Settler requires its own balance to reach before paying the recipient, not an
|
|
304
|
-
* estimate. Present only when non-empty; a batch concatenates its calls' lists like the others.
|
|
305
|
-
*/
|
|
306
|
-
readonly minimumReceived?: ReadonlyArray<{
|
|
307
|
-
readonly to: string;
|
|
308
|
-
readonly amount: AssetAmount;
|
|
309
|
-
}>;
|
|
310
|
-
/**
|
|
311
|
-
* `l1Data`: OP Stack L1 data fee plus operator fee, estimated by the engine and charged on top of
|
|
312
|
-
* `max`; not decodable from the transaction, so the kernel's own decode never sets it.
|
|
313
|
-
*/
|
|
314
|
-
readonly fee: {
|
|
315
|
-
readonly max: AssetAmount;
|
|
316
|
-
readonly l1Data?: AssetAmount;
|
|
317
|
-
} | undefined;
|
|
318
|
-
/**
|
|
319
|
-
* Recognized Solana stake operations — create, delegate, deactivate, withdraw — one per
|
|
320
|
-
* instruction, in order. Present only when non-empty.
|
|
321
|
-
*/
|
|
322
|
-
readonly staking?: ReadonlyArray<StakeAction>;
|
|
323
|
-
/**
|
|
324
|
-
* A recognized Across SpokePool deposit: the calldata-stated destination chain, the fill deadline
|
|
325
|
-
* after which an unfilled deposit refunds `refundTo` on this chain.
|
|
326
|
-
*/
|
|
327
|
-
readonly bridge?: {
|
|
328
|
-
readonly destinationNetwork: string;
|
|
329
|
-
readonly fillDeadline: number;
|
|
330
|
-
readonly refundTo: string;
|
|
331
|
-
};
|
|
332
|
-
readonly warnings: ReadonlyArray<IntentWarning>;
|
|
333
|
-
/** What a message request signs; absent for transactions. */
|
|
334
|
-
readonly message?: MessageContent;
|
|
335
|
-
readonly verifiability: Verifiability;
|
|
336
|
-
/** Present iff the transaction carries an EIP-7702 authorization. */
|
|
337
|
-
readonly delegation?: {
|
|
338
|
-
readonly kind: "set";
|
|
339
|
-
readonly delegator: string;
|
|
340
|
-
readonly name: string;
|
|
341
|
-
readonly version: string;
|
|
342
|
-
} | {
|
|
343
|
-
readonly kind: "revoke";
|
|
344
|
-
};
|
|
345
|
-
/** The decoded inner calls of a recognized ERC-7821 batch execute. */
|
|
346
|
-
readonly calls?: ReadonlyArray<DisplayIntent>;
|
|
347
|
-
};
|
|
348
|
-
type ChainErrorCode = "unknown-field" | "chain-id-mismatch" | "fee-payer-mismatch" | "invalid-quantity" | "invalid-address" | "invalid-typed-data" | "invalid-request" | "unsupported";
|
|
349
|
-
declare class ChainError extends Error {
|
|
350
|
-
readonly code: ChainErrorCode;
|
|
351
|
-
constructor(code: ChainErrorCode, message: string);
|
|
352
|
-
}
|
|
353
|
-
export { parseSignIn as C, SignInParse as S, SeaportOrder as _, BitcoinTemplate as a, TypedDataDomain as b, ChainFamily as c, EvmTransaction as d, IntentSummary as f, SeaportItem as g, SafeTransaction as h, AssetFlow as i, DisplayIntent as l, MessageContent as m, ApprovalChange as n, ChainError as o, IntentWarning as p, AssetAmount as r, ChainErrorCode as s, AccountRef as t, EvmAccessListEntry as u, SignRequest as v, Verifiability as x, StakeAction as y };
|
|
354
|
-
//# sourceMappingURL=index-DpL5hvPl.d.mts.map
|