@qntx/wallet-chains 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +13 -10
  2. package/dist/{account-ref-D2rW_qlI.mjs → account-ref-BFTeEyHt.mjs} +2 -2
  3. package/dist/{account-ref-D2rW_qlI.mjs.map → account-ref-BFTeEyHt.mjs.map} +1 -1
  4. package/dist/assemble-8GvNDony.mjs +405 -0
  5. package/dist/assemble-8GvNDony.mjs.map +1 -0
  6. package/dist/assemble-B3sO9Fvc.mjs +629 -0
  7. package/dist/assemble-B3sO9Fvc.mjs.map +1 -0
  8. package/dist/assemble-BdiPo0ZX.mjs +32 -0
  9. package/dist/assemble-BdiPo0ZX.mjs.map +1 -0
  10. package/dist/assets-sg2_Z3nZ.mjs +200 -0
  11. package/dist/assets-sg2_Z3nZ.mjs.map +1 -0
  12. package/dist/bitcoin-sign.d.mts +3 -0
  13. package/dist/bitcoin-sign.mjs +52 -18
  14. package/dist/bitcoin-sign.mjs.map +1 -1
  15. package/dist/bitcoin.d.mts +123 -7
  16. package/dist/bitcoin.mjs +162 -69
  17. package/dist/bitcoin.mjs.map +1 -1
  18. package/dist/evm-sign.d.mts +3 -1
  19. package/dist/evm-sign.mjs +25 -82
  20. package/dist/evm-sign.mjs.map +1 -1
  21. package/dist/evm.d.mts +252 -22
  22. package/dist/evm.mjs +2460 -448
  23. package/dist/evm.mjs.map +1 -1
  24. package/dist/families-BlgplKAJ.mjs +412 -0
  25. package/dist/families-BlgplKAJ.mjs.map +1 -0
  26. package/dist/index-CIRaHKpx.d.mts +941 -0
  27. package/dist/index.d.mts +2 -2
  28. package/dist/index.mjs +1 -1
  29. package/dist/networks.d.mts +29 -0
  30. package/dist/networks.mjs +245 -0
  31. package/dist/networks.mjs.map +1 -0
  32. package/dist/plan-wCnxHqRu.mjs +1311 -0
  33. package/dist/plan-wCnxHqRu.mjs.map +1 -0
  34. package/dist/solana-sign.d.mts +3 -0
  35. package/dist/solana-sign.mjs +23 -10
  36. package/dist/solana-sign.mjs.map +1 -1
  37. package/dist/solana.d.mts +136 -24
  38. package/dist/solana.mjs +1244 -63
  39. package/dist/solana.mjs.map +1 -1
  40. package/dist/src-CHB_z45M.mjs +387 -0
  41. package/dist/src-CHB_z45M.mjs.map +1 -0
  42. package/dist/tasks-7AFv3PQn.mjs +86 -0
  43. package/dist/tasks-7AFv3PQn.mjs.map +1 -0
  44. package/dist/token-call-DH22g8BL.mjs +914 -0
  45. package/dist/token-call-DH22g8BL.mjs.map +1 -0
  46. package/dist/tron-sign.d.mts +10 -0
  47. package/dist/tron-sign.mjs +36 -0
  48. package/dist/tron-sign.mjs.map +1 -0
  49. package/dist/tron.d.mts +328 -0
  50. package/dist/tron.mjs +1484 -0
  51. package/dist/tron.mjs.map +1 -0
  52. package/dist/typed-data-CE9h4U0F.d.mts +51 -0
  53. package/dist/typed-data-DRtKULsH.mjs +466 -0
  54. package/dist/typed-data-DRtKULsH.mjs.map +1 -0
  55. package/package.json +17 -10
  56. package/dist/index-DYwm4-Ec.d.mts +0 -256
  57. package/dist/message-ChhEZ0lx.mjs +0 -188
  58. package/dist/message-ChhEZ0lx.mjs.map +0 -1
  59. package/dist/src-8NZeEnrW.mjs +0 -67
  60. package/dist/src-8NZeEnrW.mjs.map +0 -1
  61. package/dist/typed-data-J5g2WemC.mjs +0 -227
  62. package/dist/typed-data-J5g2WemC.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-wCnxHqRu.mjs","names":[],"sources":["../src/tron/assemble.ts","../src/tron/proto.ts","../src/tron/contract-types.ts","../src/tron/raw.ts","../src/tron/message.ts","../src/strict-json.ts","../src/tron/address.ts","../src/tron/typed-data.ts","../src/tron/plan.ts"],"sourcesContent":["/**\n * /tron/assemble — the verified signature material as the 65-byte `r‖s‖v` (v = 27 + yParity), the\n * tronweb ECKeySign form. Always \"signed\".\n */\nimport * as Hex from \"ox/Hex\";\nimport * as Signature from \"ox/Signature\";\n\nimport type { Assembled } from \"../index.ts\";\nimport { acceptEcdsa, signaturesOf } from \"../tasks.ts\";\nimport type { TronSignPlan } from \"./plan.ts\";\n\nexport const assembleTron = (\n plan: TronSignPlan,\n signatures: ReadonlyArray<Uint8Array>,\n): Assembled<Uint8Array, TronSignPlan> => {\n signaturesOf(plan.tasks, signatures);\n const { r, s, yParity } = acceptEcdsa(plan.tasks[0], signatures[0] ?? new Uint8Array());\n return {\n kind: \"signed\",\n artefact: Signature.toBytes(\n Signature.from({ r: Hex.fromNumber(r), s: Hex.fromNumber(s), yParity }),\n ),\n };\n};\n","/**\n * A strict protobuf wire reader/writer for the TRON protocol messages. Unlike the google-protobuf\n * and `@bufbuild/protobuf` readers — which accept non-minimal varints, out-of-order and duplicated\n * fields — this reader enforces the canonical encoding a transaction must have: varints are minimal\n * and fit uint64, field numbers are strictly ascending (a declared repeated field may repeat\n * consecutively), and every accepted input re-encodes to itself. Every malformed input throws\n * `ChainError(\"invalid-request\", …)` — never another error type and never a loop.\n */\n// oxlint-disable eslint/no-bitwise -- varints and wire tags are decoded bit by bit\n\nimport { ChainError } from \"../index.ts\";\n\n/** Every malformed protobuf input is an invalid-request with a specific reason. */\nexport function malformed(what: string): never {\n throw new ChainError(\"invalid-request\", `malformed protobuf: ${what}`);\n}\n\n/**\n * A canonical varint: at most 10 bytes, the 10th byte carrying only bit 63 (`< 2^64`), and minimal\n * — a multi-byte varint's last byte is non-zero, so `0x80 0x00` and friends are rejected.\n */\nexport const readVarint = (\n bytes: Uint8Array,\n offset: number,\n): { readonly value: bigint; readonly next: number } => {\n let value = 0n;\n for (let i = 0; ; i++) {\n if (i === 10) {\n malformed(\"varint longer than 10 bytes\");\n }\n const at = offset + i;\n const b = bytes[at];\n if (b === undefined) {\n malformed(\"truncated varint\");\n }\n if ((b & 0x80) === 0) {\n if (i > 0 && b === 0) {\n malformed(\"non-minimal varint\");\n }\n if (i === 9 && b > 1) {\n malformed(\"varint exceeds 64 bits\");\n }\n value |= BigInt(b) << BigInt(i * 7);\n return { value, next: at + 1 };\n }\n value |= BigInt(b & 0x7f) << BigInt(i * 7);\n }\n};\n\nexport const writeVarint = (value: bigint): Uint8Array => {\n const out: number[] = [];\n let v = value;\n for (;;) {\n let b = Number(v & 0x7fn);\n v >>= 7n;\n if (v !== 0n) {\n b |= 0x80;\n }\n out.push(b);\n if (v === 0n) {\n return Uint8Array.from(out);\n }\n }\n};\n\n/** One decoded field: its wire type, the value form for wires 0/2, and the verbatim raw slice. */\nexport type ProtoField = {\n readonly field: number;\n readonly wire: 0 | 1 | 2 | 5;\n /** The whole encoded field, tag included — what the writer re-emits for unknown fields. */\n readonly bytes: Uint8Array;\n /** Wire 0. */\n readonly varint: bigint | undefined;\n /** Wire 2 payload. */\n readonly data: Uint8Array | undefined;\n};\n\nconst isWire = (wire: number): wire is 0 | 1 | 2 | 5 =>\n wire === 0 || wire === 1 || wire === 2 || wire === 5;\n\n/**\n * Iterates a message's fields in encoding order, enforcing the canonical layout: wire types are\n * varint (0), length-delimited (2) or fixed 32/64 (5, 1 — kept only to capture unknown fields);\n * groups (3/4) and the reserved types (6/7) are malformed. Field numbers ascend strictly; a field\n * may repeat only when `repeated` declares it, and only consecutively.\n */\nexport const readFields = (\n bytes: Uint8Array,\n repeated: ReadonlyArray<number> = [],\n): ReadonlyArray<ProtoField> => {\n const fields: ProtoField[] = [];\n let last = 0;\n let offset = 0;\n while (offset < bytes.length) {\n const start = offset;\n const tag = readVarint(bytes, offset);\n offset = tag.next;\n const wire = Number(tag.value & 7n);\n const field = Number(tag.value >> 3n);\n if (field === 0) {\n malformed(\"field number 0\");\n }\n if (!isWire(wire)) {\n malformed(`unsupported wire type ${wire} of field ${field}`);\n }\n if (field < last) {\n malformed(`field ${field} follows field ${last}`);\n }\n if (field === last && !repeated.includes(field)) {\n malformed(`field ${field} is not repeated`);\n }\n last = field;\n let varint: bigint | undefined;\n let data: Uint8Array | undefined;\n if (wire === 0) {\n const v = readVarint(bytes, offset);\n varint = v.value;\n offset = v.next;\n } else if (wire === 2) {\n const len = readVarint(bytes, offset);\n offset = len.next;\n if (len.value > BigInt(bytes.length - offset)) {\n malformed(`field ${field} length exceeds the message`);\n }\n data = bytes.subarray(offset, offset + Number(len.value));\n offset += Number(len.value);\n } else {\n const size = wire === 1 ? 8 : 4;\n if (bytes.length - offset < size) {\n malformed(`field ${field} is truncated`);\n }\n data = bytes.subarray(offset, offset + size);\n offset += size;\n }\n fields.push({ field, wire, bytes: bytes.subarray(start, offset), varint, data });\n }\n return fields;\n};\n\nconst concat = (parts: ReadonlyArray<Uint8Array>): Uint8Array => {\n const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));\n let at = 0;\n for (const p of parts) {\n out.set(p, at);\n at += p.length;\n }\n return out;\n};\n\nconst tag = (field: number, wire: number): Uint8Array => writeVarint(BigInt(field * 8 + wire));\n\n/**\n * One encoded field, or undefined when its value is a proto3 default (0, false, empty bytes or\n * string) and canonical encoding omits it entirely.\n */\nexport const varintField = (field: number, value: bigint | number): Uint8Array | undefined =>\n BigInt(value) === 0n ? undefined : concat([tag(field, 0), writeVarint(BigInt(value))]);\n\n/** A varint field that is emitted even when 0 — required presence, e.g. `lock = false`. */\nexport const requiredVarintField = (field: number, value: bigint | number): Uint8Array =>\n concat([tag(field, 0), writeVarint(BigInt(value))]);\n\nexport const bytesField = (field: number, data: Uint8Array): Uint8Array | undefined =>\n data.length === 0 ? undefined : requiredBytesField(field, data);\n\nexport const requiredBytesField = (field: number, data: Uint8Array): Uint8Array =>\n concat([tag(field, 2), writeVarint(BigInt(data.length)), data]);\n\nexport const stringField = (field: number, value: string): Uint8Array | undefined =>\n value === \"\" ? undefined : requiredBytesField(field, new TextEncoder().encode(value));\n\n/**\n * Emits a message from encoded field slices: the modeled fields in schema order plus any captured\n * unknown fields (`extra` slices, tag included), all merged by field number. Two slices of the same\n * field keep their relative order (consecutive repeats).\n */\nexport const encodeMessage = (\n fields: ReadonlyArray<{ readonly field: number; readonly bytes: Uint8Array | undefined }>,\n): Uint8Array => {\n const present = fields.filter(\n (f): f is { readonly field: number; readonly bytes: Uint8Array } => f.bytes !== undefined,\n );\n present.sort((a, b) => a.field - b.field);\n return concat(present.map((f) => f.bytes));\n};\n\n/** Captured unknown fields, carried verbatim for re-emission and blind-sign detection. */\nexport type ProtoExtra = ReadonlyArray<ProtoField>;\n\n/**\n * Split a read field list into the decoder's own consumption plus captured unknowns: fields not in\n * `known` are kept verbatim. Callers pass the schema's field numbers; repeated handling was already\n * validated by `readFields`.\n */\nexport const collectExtra = (\n fields: ReadonlyArray<ProtoField>,\n known: ReadonlyArray<number>,\n): ProtoExtra => fields.filter((f) => !known.includes(f.field));\n\nexport const equalBytes = (a: Uint8Array, b: Uint8Array): boolean =>\n a.length === b.length && a.every((v, i) => v === b[i]);\n","/**\n * The complete `Transaction.Contract.ContractType` table — all 41 values of the enum, in proto\n * order, from\n * https://github.com/tronprotocol/protocol/blob/8432beca98c52ba04c82aea0b48ae9f9f882c82a/core/Tron.proto#L337-L379\n * A contract type's `name` builds its `Any.type_url` (`type.googleapis.com/protocol.<name>`);\n * `treatment` decides the signing surface: \"described\" — decoded into a bounded intent;\n * \"permission-update\" — decoded in full but always blind (it hands account control to other keys);\n * \"unsupported\" — an opaque blind call.\n */\nexport type TronContractTreatment = \"described\" | \"permission-update\" | \"unsupported\";\n\nexport const TRON_CONTRACT_TYPES: ReadonlyArray<{\n readonly id: number;\n readonly name: string;\n readonly treatment: TronContractTreatment;\n}> = [\n { id: 0, name: \"AccountCreateContract\", treatment: \"unsupported\" },\n { id: 1, name: \"TransferContract\", treatment: \"described\" },\n { id: 2, name: \"TransferAssetContract\", treatment: \"described\" },\n { id: 3, name: \"VoteAssetContract\", treatment: \"unsupported\" },\n { id: 4, name: \"VoteWitnessContract\", treatment: \"described\" },\n { id: 5, name: \"WitnessCreateContract\", treatment: \"unsupported\" },\n { id: 6, name: \"AssetIssueContract\", treatment: \"unsupported\" },\n { id: 8, name: \"WitnessUpdateContract\", treatment: \"unsupported\" },\n { id: 9, name: \"ParticipateAssetIssueContract\", treatment: \"unsupported\" },\n { id: 10, name: \"AccountUpdateContract\", treatment: \"unsupported\" },\n { id: 11, name: \"FreezeBalanceContract\", treatment: \"unsupported\" },\n { id: 12, name: \"UnfreezeBalanceContract\", treatment: \"unsupported\" },\n { id: 13, name: \"WithdrawBalanceContract\", treatment: \"described\" },\n { id: 14, name: \"UnfreezeAssetContract\", treatment: \"unsupported\" },\n { id: 15, name: \"UpdateAssetContract\", treatment: \"unsupported\" },\n { id: 16, name: \"ProposalCreateContract\", treatment: \"unsupported\" },\n { id: 17, name: \"ProposalApproveContract\", treatment: \"unsupported\" },\n { id: 18, name: \"ProposalDeleteContract\", treatment: \"unsupported\" },\n { id: 19, name: \"SetAccountIdContract\", treatment: \"unsupported\" },\n { id: 20, name: \"CustomContract\", treatment: \"unsupported\" },\n { id: 30, name: \"CreateSmartContract\", treatment: \"unsupported\" },\n { id: 31, name: \"TriggerSmartContract\", treatment: \"described\" },\n { id: 32, name: \"GetContract\", treatment: \"unsupported\" },\n { id: 33, name: \"UpdateSettingContract\", treatment: \"unsupported\" },\n { id: 41, name: \"ExchangeCreateContract\", treatment: \"unsupported\" },\n { id: 42, name: \"ExchangeInjectContract\", treatment: \"unsupported\" },\n { id: 43, name: \"ExchangeWithdrawContract\", treatment: \"unsupported\" },\n { id: 44, name: \"ExchangeTransactionContract\", treatment: \"unsupported\" },\n { id: 45, name: \"UpdateEnergyLimitContract\", treatment: \"unsupported\" },\n { id: 46, name: \"AccountPermissionUpdateContract\", treatment: \"permission-update\" },\n { id: 48, name: \"ClearABIContract\", treatment: \"unsupported\" },\n { id: 49, name: \"UpdateBrokerageContract\", treatment: \"unsupported\" },\n { id: 51, name: \"ShieldedTransferContract\", treatment: \"unsupported\" },\n { id: 52, name: \"MarketSellAssetContract\", treatment: \"unsupported\" },\n { id: 53, name: \"MarketCancelOrderContract\", treatment: \"unsupported\" },\n { id: 54, name: \"FreezeBalanceV2Contract\", treatment: \"described\" },\n { id: 55, name: \"UnfreezeBalanceV2Contract\", treatment: \"described\" },\n { id: 56, name: \"WithdrawExpireUnfreezeContract\", treatment: \"described\" },\n { id: 57, name: \"DelegateResourceContract\", treatment: \"described\" },\n { id: 58, name: \"UnDelegateResourceContract\", treatment: \"described\" },\n { id: 59, name: \"CancelAllUnfreezeV2Contract\", treatment: \"described\" },\n];\n\nexport const tronContractType = (\n id: number,\n):\n | { readonly id: number; readonly name: string; readonly treatment: TronContractTreatment }\n | undefined => TRON_CONTRACT_TYPES.find((t) => t.id === id);\n\n/** `Any.type_url` for a contract type name — the only form the chain emits. */\nexport const tronTypeUrl = (name: string): string => `type.googleapis.com/protocol.${name}`;\n","/**\n * `Transaction.raw` and `Transaction` wire codec (Tron.proto:335-451). The raw message carries\n * exactly one contract — `contract` is `repeated` on the wire only for historical reasons (\"only\n * support size = 1\"), so zero or two is malformed rather than blind. TaPoS fields (`ref_block_num`,\n * `auths`, `scripts`) and any unknown field are captured verbatim in `extra` for blind\n * classification; `Contract.provider`/`ContractName` likewise on the contract. Every accepted input\n * satisfies `encodeTronRawData(decodeTronRawData(b)) == b`; a non-canonical encoding — an\n * explicitly-encoded default among them — is malformed.\n */\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n\nimport { tronContractType, tronTypeUrl } from \"./contract-types.ts\";\nimport {\n bytesField,\n collectExtra,\n encodeMessage,\n equalBytes,\n malformed,\n readFields,\n requiredBytesField,\n stringField,\n varintField,\n} from \"./proto.ts\";\nimport type { ProtoExtra, ProtoField } from \"./proto.ts\";\n\n/** One `Contract` slot: the Any's two fields unwrapped, extras captured verbatim. */\nexport type TronContractSlot = {\n readonly typeId: number;\n readonly typeUrl: string;\n readonly value: Uint8Array;\n readonly permissionId: number;\n readonly extra: ProtoExtra;\n};\n\nexport type TronRawData = {\n readonly refBlockBytes: Uint8Array;\n readonly refBlockHash: Uint8Array;\n readonly expiration: bigint;\n readonly timestamp?: bigint;\n readonly feeLimit?: bigint;\n /** Field 10 `data` — the user memo. */\n readonly memo?: Uint8Array;\n readonly contract: TronContractSlot;\n readonly extra: ProtoExtra;\n};\n\nconst utf8 = new TextDecoder(\"utf-8\", { fatal: true });\n\nconst field = (fs: ReadonlyArray<ProtoField>, n: number): ProtoField | undefined =>\n fs.find((f) => f.field === n);\n\nconst all = (fs: ReadonlyArray<ProtoField>, n: number): ReadonlyArray<ProtoField> =>\n fs.filter((f) => f.field === n);\n\nconst int64Field = (f: ProtoField | undefined, what: string): bigint => {\n if (f === undefined) {\n return 0n;\n }\n if (f.wire !== 0 || f.varint === undefined) {\n malformed(`${what} has the wrong wire type`);\n }\n if (f.varint >= 0x8000000000000000n) {\n malformed(`${what} is negative`);\n }\n return f.varint;\n};\n\nconst int32Field = (f: ProtoField | undefined, what: string): number => {\n const v = int64Field(f, what);\n if (v > 0x7fffffffn) {\n malformed(`${what} exceeds int32`);\n }\n return Number(v);\n};\n\nconst bytesFieldOf = (f: ProtoField | undefined, what: string): Uint8Array => {\n if (f === undefined || f.wire !== 2 || f.data === undefined) {\n malformed(`${what} is missing`);\n }\n return f.data;\n};\n\nconst encodeAny = (typeUrl: string, value: Uint8Array): Uint8Array =>\n encodeMessage([\n { field: 1, bytes: stringField(1, typeUrl) },\n { field: 2, bytes: bytesField(2, value) },\n ]);\n\nconst encodeContract = (contract: TronContractSlot): Uint8Array =>\n encodeMessage([\n { field: 1, bytes: varintField(1, contract.typeId) },\n { field: 2, bytes: requiredBytesField(2, encodeAny(contract.typeUrl, contract.value)) },\n ...contract.extra.map((e) => ({ field: e.field, bytes: e.bytes })),\n { field: 5, bytes: varintField(5, contract.permissionId) },\n ]);\n\nconst decodeContract = (bytes: Uint8Array): TronContractSlot => {\n const fs = readFields(bytes);\n const typeF = field(fs, 1);\n const typeId = int32Field(typeF, \"Contract.type\");\n const parameter = bytesFieldOf(field(fs, 2), \"Contract.parameter\");\n const permissionId = int32Field(field(fs, 5), \"Permission_id\");\n // google.protobuf.Any is a well-known two-field message: type_url then value, nothing else.\n const any = readFields(parameter);\n if (any.some((f) => f.field !== 1 && f.field !== 2)) {\n malformed(\"google.protobuf.Any holds a field beyond type_url and value\");\n }\n const urlBytes = bytesFieldOf(field(any, 1), \"Any.type_url\");\n const value = bytesFieldOf(field(any, 2), \"Any.value\");\n let typeUrl: string;\n try {\n typeUrl = utf8.decode(urlBytes);\n } catch {\n return malformed(\"Any.type_url is not UTF-8\");\n }\n const known = tronContractType(typeId);\n if (known !== undefined && typeUrl !== tronTypeUrl(known.name)) {\n malformed(`type_url ${typeUrl} does not name ${known.name}`);\n }\n return {\n typeId,\n typeUrl,\n value,\n permissionId,\n extra: collectExtra(fs, [1, 2, 5]),\n };\n};\n\nexport const decodeTronRawData = (bytes: Uint8Array): TronRawData => {\n const fs = readFields(bytes, [9, 11]);\n const refBlockBytes = bytesFieldOf(field(fs, 1), \"ref_block_bytes\");\n if (refBlockBytes.length !== 2) {\n malformed(\"ref_block_bytes is not 2 bytes\");\n }\n const refBlockHash = bytesFieldOf(field(fs, 4), \"ref_block_hash\");\n if (refBlockHash.length !== 8) {\n malformed(\"ref_block_hash is not 8 bytes\");\n }\n const expiration = int64Field(field(fs, 8), \"expiration\");\n if (expiration === 0n) {\n malformed(\"expiration is missing\");\n }\n const memo = field(fs, 10);\n const contracts = all(fs, 11);\n if (contracts.length !== 1) {\n malformed(`raw_data carries ${contracts.length} contracts, exactly one is supported`);\n }\n const contract = decodeContract(bytesFieldOf(contracts[0], \"contract\"));\n const timestamp = field(fs, 14);\n const feeLimit = field(fs, 18);\n const raw: TronRawData = {\n refBlockBytes,\n refBlockHash,\n expiration,\n ...(timestamp === undefined ? {} : { timestamp: int64Field(timestamp, \"timestamp\") }),\n ...(feeLimit === undefined ? {} : { feeLimit: int64Field(feeLimit, \"fee_limit\") }),\n ...(memo === undefined ? {} : { memo: bytesFieldOf(memo, \"data\") }),\n contract,\n extra: collectExtra(fs, [1, 4, 8, 10, 11, 14, 18]),\n };\n if (!equalBytes(encodeTronRawData(raw), bytes)) {\n malformed(\"non-canonical encoding\");\n }\n return raw;\n};\n\nexport const encodeTronRawData = (raw: TronRawData): Uint8Array =>\n encodeMessage([\n { field: 1, bytes: requiredBytesField(1, raw.refBlockBytes) },\n ...raw.extra.map((e) => ({ field: e.field, bytes: e.bytes })),\n { field: 4, bytes: requiredBytesField(4, raw.refBlockHash) },\n { field: 8, bytes: varintField(8, raw.expiration) },\n { field: 10, bytes: bytesField(10, raw.memo ?? new Uint8Array(0)) },\n { field: 11, bytes: requiredBytesField(11, encodeContract(raw.contract)) },\n { field: 14, bytes: varintField(14, raw.timestamp ?? 0n) },\n { field: 18, bytes: varintField(18, raw.feeLimit ?? 0n) },\n ]);\n\n/** TxID = sha256 over the canonical raw_data bytes — the transaction's only id. */\nexport const tronTransactionId = (rawData: Uint8Array): Uint8Array => sha256(rawData);\n\n/** Transaction { raw_data = 1; repeated bytes signature = 2 } — the broadcast envelope. */\nexport const encodeTronTransaction = (\n rawData: Uint8Array,\n signatures: ReadonlyArray<Uint8Array>,\n): Uint8Array =>\n encodeMessage([\n { field: 1, bytes: requiredBytesField(1, rawData) },\n ...signatures.map((s) => ({ field: 2, bytes: requiredBytesField(2, s) })),\n ]);\n","/**\n * TRON message-signing content: the TIP-191 prefix `\"\\x19TRON Signed Message:\\n\" ‖ decimal byte\n * length ‖ message`, hashed with keccak256 (tronweb src/utils/message.ts) — the 0x19 byte\n * guarantees the preimage is never a valid `Transaction.raw`. This module owns the digest rule and\n * the transaction-shape check a `tron.message` request must pass.\n */\nimport { keccak_256 } from \"@noble/hashes/sha3.js\";\n\nimport { readFields } from \"./proto.ts\";\nimport { decodeTronRawData } from \"./raw.ts\";\n\nexport const TRON_MESSAGE_PREFIX = \"\\u0019TRON Signed Message:\\n\";\n\nexport const tronMessageDigest = (message: Uint8Array): Uint8Array => {\n const head = new TextEncoder().encode(`${TRON_MESSAGE_PREFIX}${message.length}`);\n const preimage = new Uint8Array(head.length + message.length);\n preimage.set(head);\n preimage.set(message, head.length);\n return keccak_256(preimage);\n};\n\n/**\n * Whether `bytes` could be a transaction: either `Transaction.raw` itself, or a `Transaction`\n * envelope whose field 1 is raw data. A `tron.message` request matching either is refused — the\n * signature would authorise a transaction, not a message.\n */\nexport const mayBeTronTransaction = (bytes: Uint8Array): boolean => {\n try {\n decodeTronRawData(bytes);\n return true;\n } catch {\n // Not bare raw data — try the Transaction envelope.\n }\n try {\n const rawField = readFields(bytes).find((f) => f.field === 1);\n if (rawField === undefined || rawField.wire !== 2 || rawField.data === undefined) {\n return false;\n }\n decodeTronRawData(rawField.data);\n return true;\n } catch {\n return false;\n }\n};\n","/**\n * A strict JSON parser: the RFC 8259 grammar `JSON.parse` accepts, plus the two canonicality rules\n * signing inputs need — a duplicate object key and trailing text after the value are malformed\n * inputs, not silently resolved. Errors are reported through `invalid` so the caller's error type\n * carries them; `depth` bounds nesting so a deep document cannot exhaust the stack.\n */\nconst WS = new Set([\" \", \"\\t\", \"\\n\", \"\\r\"]);\nconst HEX_QUAD = /^[0-9a-fA-F]{4}$/;\n\nexport const strictJson = (\n text: string,\n invalid: (reason: string) => never,\n depth = 200,\n): unknown => {\n let at = 0;\n const fail = (reason: string): never => invalid(`${reason} at offset ${at}`);\n\n const ws = (): void => {\n while (at < text.length && WS.has(text[at] ?? \"\")) {\n at += 1;\n }\n };\n\n const string = (): string => {\n let out = \"\";\n at += 1;\n for (;;) {\n if (at >= text.length) {\n fail(\"unterminated string\");\n }\n const c = text[at] ?? \"\";\n if (c === '\"') {\n at += 1;\n return out;\n }\n if (c === \"\\\\\") {\n at += 1;\n const escape = text[at];\n switch (escape) {\n case '\"':\n case \"\\\\\":\n case \"/\":\n out += escape;\n at += 1;\n break;\n case \"b\":\n out += \"\\b\";\n at += 1;\n break;\n case \"f\":\n out += \"\\f\";\n at += 1;\n break;\n case \"n\":\n out += \"\\n\";\n at += 1;\n break;\n case \"r\":\n out += \"\\r\";\n at += 1;\n break;\n case \"t\":\n out += \"\\t\";\n at += 1;\n break;\n case \"u\": {\n const digits = text.slice(at + 1, at + 5);\n if (!HEX_QUAD.test(digits)) {\n fail(String.raw`malformed \\u escape`);\n }\n out += String.fromCodePoint(Number.parseInt(digits, 16));\n at += 5;\n break;\n }\n default:\n fail(`unknown escape \\\\${escape ?? \"?\"}`);\n }\n } else {\n if (c < \" \") {\n fail(\"control character in string\");\n }\n out += c;\n at += 1;\n }\n }\n };\n\n const number = (): number => {\n const start = at;\n if (text[at] === \"-\") {\n at += 1;\n }\n if (text[at] === \"0\") {\n at += 1;\n } else if ((text[at] ?? \"\") >= \"1\" && (text[at] ?? \"\") <= \"9\") {\n while ((text[at] ?? \"\") >= \"0\" && (text[at] ?? \"\") <= \"9\") {\n at += 1;\n }\n } else {\n fail(\"malformed number\");\n }\n if (text[at] === \".\") {\n at += 1;\n if (!((text[at] ?? \"\") >= \"0\" && (text[at] ?? \"\") <= \"9\")) {\n fail(\"malformed number\");\n }\n while ((text[at] ?? \"\") >= \"0\" && (text[at] ?? \"\") <= \"9\") {\n at += 1;\n }\n }\n if (text[at] === \"e\" || text[at] === \"E\") {\n at += 1;\n if (text[at] === \"+\" || text[at] === \"-\") {\n at += 1;\n }\n if (!((text[at] ?? \"\") >= \"0\" && (text[at] ?? \"\") <= \"9\")) {\n fail(\"malformed number\");\n }\n while ((text[at] ?? \"\") >= \"0\" && (text[at] ?? \"\") <= \"9\") {\n at += 1;\n }\n }\n return Number(text.slice(start, at));\n };\n\n const literal = (word: \"true\" | \"false\" | \"null\", value: unknown): unknown => {\n if (!text.startsWith(word, at)) {\n fail(`malformed value`);\n }\n at += word.length;\n return value;\n };\n\n const value = (level: number): unknown => {\n if (level > depth) {\n fail(\"document nests too deeply\");\n }\n ws();\n const c = text[at];\n if (c === '\"') {\n return string();\n }\n if (c === \"{\") {\n const object: Record<string, unknown> = {};\n const keys = new Set<string>();\n at += 1;\n ws();\n if (text[at] === \"}\") {\n at += 1;\n return object;\n }\n for (;;) {\n ws();\n if (text[at] !== '\"') {\n fail(\"expected a member name\");\n }\n const key = string();\n if (keys.has(key)) {\n fail(`duplicate key ${JSON.stringify(key)}`);\n }\n keys.add(key);\n ws();\n if (text[at] !== \":\") {\n fail(\"expected ':'\");\n }\n at += 1;\n const member = value(level + 1);\n Object.defineProperty(object, key, {\n value: member,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n ws();\n if (text[at] === \",\") {\n at += 1;\n continue;\n }\n if (text[at] === \"}\") {\n at += 1;\n return object;\n }\n fail(\"expected ',' or '}'\");\n }\n }\n if (c === \"[\") {\n const array: unknown[] = [];\n at += 1;\n ws();\n if (text[at] === \"]\") {\n at += 1;\n return array;\n }\n for (;;) {\n array.push(value(level + 1));\n ws();\n if (text[at] === \",\") {\n at += 1;\n continue;\n }\n if (text[at] === \"]\") {\n at += 1;\n return array;\n }\n fail(\"expected ',' or ']'\");\n }\n }\n if (c === \"t\") {\n return literal(\"true\", true);\n }\n if (c === \"f\") {\n return literal(\"false\", false);\n }\n if (c === \"n\") {\n return literal(\"null\", null);\n }\n return number();\n };\n\n const parsed = value(1);\n ws();\n if (at !== text.length) {\n fail(\"trailing text after the JSON value\");\n }\n return parsed;\n};\n","import { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { keccak_256 } from \"@noble/hashes/sha3.js\";\nimport { bytesToHex, concatBytes, hexToBytes } from \"@noble/hashes/utils.js\";\nimport { createBase58check } from \"@scure/base\";\n\nimport { checksumEvmAddress } from \"../evm/address.ts\";\nimport { ChainError } from \"../index.ts\";\n\n/** The version byte every TRON address (mainnet and testnets alike) carries. */\nexport const TRON_ADDRESS_PREFIX = 0x41;\n\nconst base58check = createBase58check(sha256);\n\n/** A 34-character base58check string whose payload is 21 bytes starting with 0x41. */\nexport const isTronAddress = (value: string): boolean => {\n if (!/^[1-9A-HJ-NP-Za-km-z]{34}$/.test(value)) {\n return false;\n }\n try {\n const decoded = base58check.decode(value);\n return decoded.length === 21 && decoded[0] === TRON_ADDRESS_PREFIX;\n } catch {\n return false;\n }\n};\n\nconst tronBytes = (address: string, what: string): Uint8Array => {\n if (!isTronAddress(address)) {\n throw new ChainError(\"invalid-address\", `not a TRON address: ${what}`);\n }\n return base58check.decode(address);\n};\n\n/** The 21 raw bytes — 0x41 version byte plus the 20-byte address body. */\nexport function tronAddressToBytes(address: string): Uint8Array {\n return tronBytes(address, \"base58check\");\n}\n\n/** Base58check encodes a 21-byte payload whose first byte is 0x41. */\nexport function tronAddressFromBytes(bytes: Uint8Array): string {\n if (bytes.length !== 21 || bytes[0] !== TRON_ADDRESS_PREFIX) {\n throw new ChainError(\"invalid-address\", \"a TRON address is 21 bytes starting with 0x41\");\n }\n return base58check.encode(bytes);\n}\n\n/** `\"41\"` plus the 20-byte body as 40 lowercase hex — the form contract fields carry. */\nexport function tronAddressToHex(address: string): string {\n return bytesToHex(tronBytes(address, \"base58check\"));\n}\n\n/** `\"41\"` plus 40 hex — the form `raw_data` contract fields and trongrid JSON carry. */\nexport function tronAddressFromHex(hex: string): string {\n if (!/^41[0-9a-fA-F]{40}$/.test(hex)) {\n throw new ChainError(\"invalid-address\", \"a TRON hex address is 41 plus 40 hex\");\n }\n return tronAddressFromBytes(hexToBytes(hex));\n}\n\nconst is0xPrefixed = (value: string): value is `0x${string}` => value.startsWith(\"0x\");\n\n/** The 20-byte body rendered as an EIP-55 checksummed 0x address (ABI/EVM tooling form). */\nexport function tronAddressToEvm(address: string): `0x${string}` {\n const checksummed = checksumEvmAddress(`0x${tronAddressToHex(address).slice(2)}`);\n if (!is0xPrefixed(checksummed)) {\n throw new ChainError(\"invalid-address\", \"EIP-55 checksum did not produce a 0x address\");\n }\n return checksummed;\n}\n\n/** 0x plus 40 hex — an EVM-style encoding of the 20-byte body. */\nexport function tronAddressFromEvm(address: string): string {\n if (!/^0x[0-9a-fA-F]{40}$/.test(address)) {\n throw new ChainError(\"invalid-address\", \"expected a 0x-prefixed 20-byte address\");\n }\n return tronAddressFromHex(`41${address.slice(2)}`);\n}\n\n/**\n * `0x41 ‖ keccak256(uncompressed[1..])[12..32]` — accepts a 33-byte compressed or 65-byte\n * uncompressed secp256k1 key.\n */\nexport function tronAddressFromPublicKey(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 tronAddressFromBytes(\n concatBytes(\n Uint8Array.of(TRON_ADDRESS_PREFIX),\n keccak_256(uncompressed.subarray(1)).subarray(12),\n ),\n );\n}\n","/**\n * TIP-712 typed data — EIP-712 with TRON's two deviations (tips/tip-712.md; the oracle is TronWeb\n * 6.5.2's TypedDataEncoder): an `address` leaf is the 20 bytes after the 0x41 version byte, and\n * `trcToken` is an atomic type encoded like `uint256`. `parseTronTypedData` validates the canonical\n * JSON — what `TypedDataEncoder.getPayload` emits — and `tronTypedDataDigest` computes\n * `keccak256(0x1901 ‖ hashStruct(EIP712Domain, domain) ‖ hashStruct(primaryType, message))`,\n * byte-identical to TronWeb's `hashTypedData` on every accepted document. Where the canonical\n * grammar is stricter than TronWeb's loose inputs (JSON booleans only, even-length `0x` hex, no\n * bare-width `uint`), the difference can only change what it hashes to, never whether it signs — so\n * strictness is a validation concern, not a compatibility one.\n */\nimport { keccak_256 } from \"@noble/hashes/sha3.js\";\nimport { bytesToHex, concatBytes, hexToBytes, utf8ToBytes } from \"@noble/hashes/utils.js\";\n\nimport { isRecord } from \"../account-ref.ts\";\nimport { MAX_TYPED_DATA_DEPTH, isTypedDataInput } from \"../evm/typed-data.ts\";\nimport type { ParsedTypedData, TypedDataInput } from \"../evm/typed-data.ts\";\nimport { ChainError } from \"../index.ts\";\nimport { strictJson } from \"../strict-json.ts\";\nimport { isTronAddress, tronAddressFromHex, tronAddressToBytes } from \"./address.ts\";\n\nconst fail = (what: string): never => {\n throw new ChainError(\"invalid-typed-data\", what);\n};\n\ntype Field = { readonly name: string; readonly type: string };\ntype Types = Record<string, ReadonlyArray<Field>>;\n\nconst INT_TYPE = /^(u?)int(\\d*)$/;\nconst FIXED_BYTES = /^bytes(\\d+)$/;\nconst ARRAY_TAIL = /^(.*)\\[(\\d*)\\]$/;\n\n/**\n * A leaf `address` value's 20-byte body: a base58check `T…` string, `41` + 40 hex, or `0x` + 40\n * hex. Bare 40-hex is refused — TronWeb's `toHex` would hash it as garbage rather than an address,\n * so accepting it could only mis-sign.\n */\nconst addressBody = (value: unknown): Uint8Array | undefined => {\n if (typeof value !== \"string\") {\n return undefined;\n }\n if (isTronAddress(value)) {\n return tronAddressToBytes(value).subarray(1);\n }\n if (/^41[0-9a-fA-F]{40}$/.test(value)) {\n return hexToBytes(value).subarray(1);\n }\n if (/^0x[0-9a-fA-F]{40}$/.test(value)) {\n return hexToBytes(value.slice(2));\n }\n return undefined;\n};\n\n/** The display form of a leaf `address` value — base58check, whichever form the document used. */\nexport const tronTypedDataBase58 = (value: unknown): string | undefined => {\n const body = addressBody(value);\n return body === undefined ? undefined : tronAddressFromHex(`41${bytesToHex(body)}`);\n};\n\nconst word = (value: bigint): Uint8Array => {\n const v = value < 0n ? 2n ** 256n + value : value;\n return hexToBytes(v.toString(16).padStart(64, \"0\"));\n};\n\nconst intBounds = (signed: boolean, bits: number): readonly [bigint, bigint] =>\n signed ? [-(2n ** BigInt(bits - 1)), 2n ** BigInt(bits - 1) - 1n] : [0n, 2n ** BigInt(bits) - 1n];\n\n/** Canonical-JSON int leaf: safe integer, decimal string (`-` only where signed), or `0x` hex. */\nconst strictInt = (value: unknown, signed: boolean): bigint | undefined => {\n if (typeof value === \"number\" && Number.isSafeInteger(value)) {\n return BigInt(value);\n }\n if (\n typeof value === \"string\" &&\n ((signed ? /^-?[0-9]+$/ : /^[0-9]+$/).test(value) || /^0x[0-9a-fA-F]+$/.test(value))\n ) {\n return BigInt(value);\n }\n return undefined;\n};\n\n/** A `tron_signTypedData` argument's int leaf — TronWeb's getBigInt forms. */\nconst looseInt = (value: unknown): bigint | undefined => {\n if (typeof value === \"bigint\") {\n return value;\n }\n /* TronWeb feeds numbers through ethers' getBigInt, which overflows on non-safe integers. */\n if (typeof value === \"number\" && Number.isSafeInteger(value)) {\n return BigInt(value);\n }\n if (typeof value === \"string\" && (/^-?[0-9]+$/.test(value) || /^0x[0-9a-fA-F]+$/.test(value))) {\n return BigInt(value);\n }\n return undefined;\n};\n\n/** A bytes leaf — canonical `0x` even-length hex, plus a `Uint8Array` in argument mode. */\nconst hexLeaf = (value: unknown, args: boolean): Uint8Array | undefined => {\n if (args && value instanceof Uint8Array) {\n return value;\n }\n return typeof value === \"string\" && /^0x([0-9a-fA-F]{2})*$/.test(value)\n ? hexToBytes(value.slice(2))\n : undefined;\n};\n\n/**\n * The encoder for one atomic type, mirroring TronWeb's `getBaseEncoder` — including its rule that a\n * base-looking name with a malformed width (`uint7`, `bytes33`, bare `uint`) is a name error, not\n * \"no such type\", so `isBaseName` below can count it against struct names. `args` relaxes leaf\n * forms to what `_signTypedData(domain, types, value)` accepts.\n */\nconst baseEncoder = (type: string, args: boolean): ((value: unknown) => Uint8Array) | undefined => {\n const int = INT_TYPE.exec(type);\n if (int !== null) {\n const signed = int[1] === \"\";\n const w = int[2] === \"\" ? Number.NaN : Number(int[2]);\n if (w % 8 !== 0 || w < 8 || w > 256 || int[2] !== String(w)) {\n fail(`invalid numeric width in type ${type}`);\n }\n const [min, max] = intBounds(signed, w);\n return (value) => {\n const parsed = args ? looseInt(value) : strictInt(value, signed);\n if (parsed === undefined || parsed < min || parsed > max) {\n return fail(`value is out of bounds for ${type}`);\n }\n return word(parsed);\n };\n }\n const fixed = FIXED_BYTES.exec(type);\n if (fixed !== null) {\n const w = Number(fixed[1]);\n if (w < 1 || w > 32 || String(w) !== fixed[1]) {\n fail(`invalid bytes width in type ${type}`);\n }\n return (value) => {\n const bytes = hexLeaf(value, args);\n if (bytes === undefined || bytes.length !== w) {\n return fail(`invalid length for ${type}`);\n }\n const out = new Uint8Array(32);\n out.set(bytes);\n return out;\n };\n }\n switch (type) {\n case \"trcToken\":\n return baseEncoder(\"uint256\", args);\n case \"address\":\n return (value) => {\n const body = addressBody(value);\n if (body === undefined) {\n return fail(\"address is not a base58, 41-hex or 0x-hex TRON address\");\n }\n return concatBytes(new Uint8Array(12), body);\n };\n case \"bool\":\n return (value) => {\n if (args) {\n const truthy = Boolean(value);\n return word(truthy ? 1n : 0n);\n }\n if (typeof value !== \"boolean\") {\n return fail(\"bool is not a JSON boolean\");\n }\n return word(value ? 1n : 0n);\n };\n case \"bytes\":\n return (value) => {\n const bytes = hexLeaf(value, args);\n if (bytes === undefined) {\n return fail(\"bytes is not 0x-prefixed even-length hex\");\n }\n return keccak_256(bytes);\n };\n case \"string\":\n return (value) => {\n if (typeof value !== \"string\") {\n return fail(\"string value is not a string\");\n }\n return keccak_256(utf8ToBytes(value));\n };\n default:\n return undefined;\n }\n};\n\n/** Mirrors TronWeb's `isBaseTypeName`: every base-looking name counts, even a malformed one. */\nconst isBaseName = (name: string): boolean =>\n INT_TYPE.test(name) ||\n FIXED_BYTES.test(name) ||\n name === \"address\" ||\n name === \"bool\" ||\n name === \"string\" ||\n name === \"bytes\" ||\n name === \"trcToken\";\n\n/** A field type's base after stripping `[]`/`[n]` suffixes; a malformed suffix stays attached. */\nconst baseName = (type: string): string => {\n let t = type;\n for (;;) {\n const tail = ARRAY_TAIL.exec(t);\n if (tail === null) {\n return t;\n }\n t = tail[1] ?? \"\";\n }\n};\n\nconst encodeTypeOf = (types: Types, name: string): string =>\n `${name}(${(types[name] ?? []).map((f) => `${f.type} ${f.name}`).join(\",\")})`;\n\n/**\n * Validates a struct-type map like TronWeb's TypedDataEncoder constructor: no base-name collisions,\n * unique field names, field types resolving to a base or a declared struct, no cycles, and exactly\n * one root — the only type nothing references, hence the primary type. Unlike TronWeb, an\n * unreachable type (it could only be part of a disconnected cycle) is also refused: it would be\n * dead weight in the document.\n */\nconst checkTypes = (\n types: Types,\n): { readonly primary: string; readonly fullTypes: ReadonlyMap<string, string> } => {\n const names = Object.keys(types);\n const links = new Map<string, Set<string>>();\n const parents = new Map<string, string[]>();\n const subtypes = new Map<string, Set<string>>();\n for (const name of names) {\n links.set(name, new Set());\n parents.set(name, []);\n subtypes.set(name, new Set());\n }\n for (const name of names) {\n if (isBaseName(name)) {\n fail(`struct type name ${JSON.stringify(name)} collides with a base type`);\n }\n const seen = new Set<string>();\n for (const field of types[name] ?? []) {\n if (seen.has(field.name)) {\n fail(`duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`);\n }\n seen.add(field.name);\n const base = baseName(field.type);\n if (base === name) {\n fail(`circular type reference to ${JSON.stringify(base)}`);\n }\n let baseIsAtomic: boolean;\n try {\n baseIsAtomic = baseEncoder(base, false) !== undefined;\n } catch (error) {\n if (error instanceof ChainError) {\n fail(`invalid field type ${JSON.stringify(field.type)}`);\n }\n throw error;\n }\n if (baseIsAtomic) {\n continue;\n }\n if (!parents.has(base)) {\n fail(`unknown type ${JSON.stringify(base)}`);\n }\n (parents.get(base) ?? []).push(name);\n (links.get(name) ?? new Set<string>()).add(base);\n }\n }\n const roots = names.filter((n) => (parents.get(n) ?? []).length === 0);\n if (roots.length === 0) {\n fail(\"missing primary type\");\n }\n if (roots.length !== 1) {\n fail(\n `ambiguous primary types or unused types: ${roots.map((r) => JSON.stringify(r)).join(\", \")}`,\n );\n }\n const primary = roots[0] ?? \"\";\n const visited = new Set<string>();\n const checkCircular = (type: string, found: Set<string>): void => {\n if (found.has(type)) {\n fail(`circular type reference to ${JSON.stringify(type)}`);\n }\n found.add(type);\n visited.add(type);\n for (const child of links.get(type) ?? new Set<string>()) {\n checkCircular(child, found);\n for (const subtype of found) {\n (subtypes.get(subtype) ?? new Set<string>()).add(child);\n }\n }\n found.delete(type);\n };\n checkCircular(primary, new Set());\n if (visited.size !== names.length) {\n fail(\"types contains types the primary type does not reach\");\n }\n const fullTypes = new Map<string, string>();\n for (const [name, set] of subtypes) {\n const st = [...set].sort();\n fullTypes.set(name, encodeTypeOf(types, name) + st.map((t) => encodeTypeOf(types, t)).join(\"\"));\n }\n return { primary, fullTypes };\n};\n\n/**\n * The encoder/walker pair over a validated type map. `hashStruct` produces TronWeb's `hashStruct`:\n * each leaf its 32-byte word, an array the keccak of its elements' encodings, a struct the keccak\n * of `typeHash ‖ fields` (a struct-typed field or element carries its own keccak). `visit` mirrors\n * `TypedDataEncoder.getPayload`'s message normalization: bytes as `0x` hex, integers decimal,\n * addresses `41`-hex, booleans `!!value`.\n */\nconst makeEncoder = (\n types: Types,\n args: boolean,\n): {\n readonly primary: string;\n readonly hashStruct: (type: string, value: unknown) => Uint8Array;\n readonly visit: (type: string, value: unknown) => unknown;\n} => {\n const { primary, fullTypes } = checkTypes(types);\n\n const encode = (type: string, value: unknown, depth: number): Uint8Array => {\n if (depth > MAX_TYPED_DATA_DEPTH) {\n fail(\"typedData nests too deeply\");\n }\n const atomic = baseEncoder(type, args);\n if (atomic !== undefined) {\n return atomic(value);\n }\n const tail = ARRAY_TAIL.exec(type);\n if (tail !== null) {\n if (!Array.isArray(value)) {\n return fail(`${type} value is not an array`);\n }\n const len = tail[2] === \"\" ? undefined : Number(tail[2]);\n if (len !== undefined && len !== value.length) {\n return fail(`array length mismatch; expected length ${len}`);\n }\n const elementType = tail[1] ?? \"\";\n const structElements = fullTypes.has(elementType);\n const encoded = value.map((v: unknown) => encode(elementType, v, depth + 1));\n return keccak_256(concatBytes(...encoded.map((e) => (structElements ? keccak_256(e) : e))));\n }\n const fields = types[type];\n if (fields !== undefined) {\n if (!isRecord(value)) {\n return fail(`${type} value is not an object`);\n }\n const typeHash = keccak_256(utf8ToBytes(fullTypes.get(type) ?? \"\"));\n const encoded = fields.map((f) => {\n const e = encode(f.type, value[f.name], depth + 1);\n return fullTypes.has(f.type) ? keccak_256(e) : e;\n });\n return concatBytes(typeHash, ...encoded);\n }\n return fail(`unknown type ${type}`);\n };\n\n const visitLeaf = (type: string, value: unknown): unknown => {\n if (/^bytes(\\d*)/.test(type)) {\n const bytes = hexLeaf(value, args);\n if (bytes === undefined) {\n return fail(`invalid bytes value for ${type}`);\n }\n return `0x${bytesToHex(bytes)}`;\n }\n if (/^u?int/.test(type) || type === \"trcToken\") {\n const v = looseInt(value);\n if (v === undefined) {\n return fail(`invalid numeric value for ${type}`);\n }\n return v.toString(10);\n }\n switch (type) {\n case \"address\": {\n const body = addressBody(value);\n if (body === undefined) {\n return fail(\"address is not a base58, 41-hex or 0x-hex TRON address\");\n }\n return `41${bytesToHex(body)}`;\n }\n case \"bool\":\n return Boolean(value);\n case \"string\":\n if (typeof value !== \"string\") {\n return fail(\"string value is not a string\");\n }\n return value;\n default:\n return fail(`unsupported type ${type}`);\n }\n };\n\n const visit = (type: string, value: unknown, depth: number): unknown => {\n if (depth > MAX_TYPED_DATA_DEPTH) {\n fail(\"typedData nests too deeply\");\n }\n if (baseEncoder(type, true) !== undefined) {\n return visitLeaf(type, value);\n }\n const tail = ARRAY_TAIL.exec(type);\n if (tail !== null) {\n if (!Array.isArray(value)) {\n return fail(`${type} value is not an array`);\n }\n const len = tail[2] === \"\" ? undefined : Number(tail[2]);\n if (len !== undefined && len !== value.length) {\n return fail(`array length mismatch; expected length ${len}`);\n }\n return value.map((v: unknown) => visit(tail[1] ?? \"\", v, depth + 1));\n }\n const fields = types[type];\n if (fields !== undefined) {\n if (!isRecord(value)) {\n return fail(`${type} value is not an object`);\n }\n return Object.fromEntries(\n fields.map((f) => [f.name, visit(f.type, value[f.name], depth + 1)]),\n );\n }\n return fail(`unknown type ${type}`);\n };\n\n return {\n primary,\n hashStruct: (type, value) => keccak_256(encode(type, value, 0)),\n visit: (type, value) => visit(type, value, 0),\n };\n};\n\n/** The five domain fields a TIP-712 document may carry, in canonical order. */\nconst DOMAIN_FIELD_TYPES: ReadonlyArray<Field> = [\n { name: \"name\", type: \"string\" },\n { name: \"version\", type: \"string\" },\n { name: \"chainId\", type: \"uint256\" },\n { name: \"verifyingContract\", type: \"address\" },\n { name: \"salt\", type: \"bytes32\" },\n];\nconst DOMAIN_NAMES = new Set(DOMAIN_FIELD_TYPES.map((f) => f.name));\n\n/** `types.EIP712Domain` exactly mirrors the domain's non-null keys, in canonical order. */\nconst domainFieldsOf = (domain: Record<string, unknown>): Field[] => {\n const fields: Field[] = [];\n for (const f of DOMAIN_FIELD_TYPES) {\n const value = domain[f.name];\n if (value !== undefined && value !== null) {\n fields.push(f);\n }\n }\n for (const key of Object.keys(domain)) {\n if (domain[key] !== undefined && domain[key] !== null && !DOMAIN_NAMES.has(key)) {\n fail(`invalid typed-data domain key ${JSON.stringify(key)}`);\n }\n }\n return fields;\n};\n\nconst sameFieldList = (declared: ReadonlyArray<Field>, expected: ReadonlyArray<Field>): boolean =>\n declared.length === expected.length &&\n declared.every((f, i) => f.name === expected[i]?.name && f.type === expected[i]?.type);\n\n/**\n * The domain's non-null entries — a `null` domain value is dropped like TronWeb's `== null` skip,\n * so `types.EIP712Domain` can still match the remaining keys.\n */\nconst domainValues = (domain: Record<string, unknown>): Record<string, unknown> =>\n Object.fromEntries(Object.entries(domain).filter(([, v]) => v !== null && v !== undefined));\n\n/**\n * Parses the canonical TIP-712 JSON. Beyond `isTypedDataInput`'s shape, the document must be strict\n * JSON (no duplicate keys, nothing after the value), `types.EIP712Domain` must be exactly the\n * domain's present keys in canonical order, the struct types must form a single root DAG naming\n * `primaryType`, and every leaf must carry its canonical value — verified by running the encoder,\n * so anything that would hash is something that validated.\n */\nexport const parseTronTypedData = (typedData: string): ParsedTypedData => {\n const json = strictJson(typedData, (reason) => fail(`typedData ${reason}`));\n if (!isTypedDataInput(json)) {\n return fail(\"typedData must be a JSON object with types, primaryType, domain and message\");\n }\n const domainFields = domainFieldsOf(json.domain);\n const declared = json.types[\"EIP712Domain\"] ?? fail(\"typedData must declare types.EIP712Domain\");\n if (!sameFieldList(declared, domainFields)) {\n fail(\"types.EIP712Domain is not the canonical field list of the domain keys present\");\n }\n tronTypedDataDigest(json);\n return { json: { ...json, domain: domainValues(json.domain) } };\n};\n\n/**\n * The domain separator and message hash of a parsed document — `hashStruct(EIP712Domain, domain)`\n * under the fields its non-null keys derive, `hashStruct(primaryType, message)` under the unique\n * root type of `types` minus `EIP712Domain`. Returned separately for signers that send the two\n * hashes to the device rather than one digest (Tron `INS_0C`).\n */\nexport const tronTypedDataHashes = (\n json: TypedDataInput,\n): { readonly domain: Uint8Array; readonly message: Uint8Array } => {\n const domainFields = domainFieldsOf(json.domain);\n const messageTypes: Types = {};\n for (const [name, fields] of Object.entries(json.types)) {\n if (name !== \"EIP712Domain\") {\n messageTypes[name] = fields;\n }\n }\n const encoder = makeEncoder(messageTypes, false);\n if (encoder.primary !== json.primaryType) {\n fail(`primaryType ${JSON.stringify(json.primaryType)} is not the unique root type`);\n }\n const domain = makeEncoder({ EIP712Domain: domainFields }, false).hashStruct(\n \"EIP712Domain\",\n json.domain,\n );\n const message = encoder.hashStruct(json.primaryType, json.message);\n return { domain, message };\n};\n\n/**\n * The signing digest of a parsed document: `keccak256(0x1901 ‖ hashStruct(EIP712Domain, domain) ‖\n * hashStruct(primaryType, message))` — `keccak256(0x1901 ‖ hashes.domain ‖ hashes.message)`.\n */\nexport const tronTypedDataDigest = (json: TypedDataInput): Uint8Array => {\n const { domain, message } = tronTypedDataHashes(json);\n return keccak_256(concatBytes(Uint8Array.of(0x19, 0x01), domain, message));\n};\n\nconst domainArg = (name: string, value: unknown): unknown => {\n switch (name) {\n case \"name\":\n case \"version\":\n if (typeof value !== \"string\") {\n return fail(`domain.${name} is not a string`);\n }\n return value;\n case \"chainId\": {\n const v = looseInt(value);\n if (v === undefined || v < 0n) {\n return fail(\"domain.chainId is not a non-negative integer\");\n }\n /* domainChecks.chainId looks like it emits a JSON number when safe\n (Number.isSafeInteger), but its input is getBigInt's bigint, so the branch is\n dead and getPayload always emits a 0x quantity. */\n return `0x${v.toString(16)}`;\n }\n case \"verifyingContract\": {\n const body = addressBody(value);\n if (body === undefined) {\n return fail(\"domain.verifyingContract is not a valid TRON address\");\n }\n return `41${bytesToHex(body)}`;\n }\n case \"salt\": {\n const bytes = hexLeaf(value, true);\n if (bytes === undefined || bytes.length !== 32) {\n return fail(\"domain.salt is not 32 bytes\");\n }\n return `0x${bytesToHex(bytes)}`;\n }\n default:\n return fail(`invalid typed-data domain key ${JSON.stringify(name)}`);\n }\n};\n\n/**\n * The `tron_signTypedData(domain, types, message)` argument form → the canonical JSON a\n * `tron.typed-data` request carries, mirroring `TypedDataEncoder.getPayload`: `EIP712Domain` is\n * derived from the domain's present keys (a supplied one must equal the derivation), `primaryType`\n * is the unique root of `types`, and message leaves normalize to `0x` hex, decimals, `41`-hex\n * addresses and booleans. The result is re-parsed before it is returned — canonical output is a\n * checked invariant, not an assumption.\n */\nexport const tronTypedDataFromArgs = (\n domain: unknown,\n types: unknown,\n message: unknown,\n): string => {\n if (!isRecord(domain)) {\n return fail(\"domain must be an object\");\n }\n const domainFields: Field[] = [];\n const values: Record<string, unknown> = {};\n for (const f of DOMAIN_FIELD_TYPES) {\n const value = domain[f.name];\n if (value === undefined || value === null) {\n continue;\n }\n domainFields.push(f);\n values[f.name] = domainArg(f.name, value);\n }\n for (const key of Object.keys(domain)) {\n if (domain[key] !== undefined && domain[key] !== null && !DOMAIN_NAMES.has(key)) {\n fail(`invalid typed-data domain key ${JSON.stringify(key)}`);\n }\n }\n if (!isRecord(types)) {\n return fail(\"types must be an object\");\n }\n const tmap: Types = {};\n for (const [name, fields] of Object.entries(types)) {\n if (!Array.isArray(fields)) {\n return fail(`types.${name} is not a list of {name, type} fields`);\n }\n const list: Field[] = [];\n for (const f of fields) {\n if (!isRecord(f) || typeof f[\"name\"] !== \"string\" || typeof f[\"type\"] !== \"string\") {\n return fail(`types.${name} is not a list of {name, type} fields`);\n }\n list.push({ name: f[\"name\"], type: f[\"type\"] });\n }\n tmap[name] = list;\n }\n const declared = tmap[\"EIP712Domain\"];\n if (declared !== undefined && !sameFieldList(declared, domainFields)) {\n fail(\"types.EIP712Domain does not match the domain fields\");\n }\n delete tmap[\"EIP712Domain\"];\n if (!isRecord(message)) {\n return fail(\"message must be an object\");\n }\n const encoder = makeEncoder(tmap, true);\n const canonical = encoder.visit(encoder.primary, message);\n const json = JSON.stringify({\n types: { ...tmap, EIP712Domain: domainFields },\n primaryType: encoder.primary,\n domain: values,\n message: canonical,\n });\n parseTronTypedData(json);\n return json;\n};\n\n/**\n * The document as an EVM-equivalent input for `recognizePermit`: every `address` leaf becomes\n * `0x`-form so the EVM recognizers' `0x`-only rules match. A document declaring `trcToken` anywhere\n * has no EVM equivalent and is not mapped.\n */\nexport const tronTypedDataToEvm = (json: TypedDataInput): TypedDataInput | undefined => {\n if (\n Object.values(json.types).some((fields) => fields.some((f) => baseName(f.type) === \"trcToken\"))\n ) {\n return undefined;\n }\n const map = (type: string, value: unknown): unknown => {\n const tail = ARRAY_TAIL.exec(type);\n if (tail !== null) {\n return Array.isArray(value) ? value.map((v: unknown) => map(tail[1] ?? \"\", v)) : value;\n }\n const struct = json.types[type];\n if (struct !== undefined) {\n return isRecord(value)\n ? Object.fromEntries(struct.map((f) => [f.name, map(f.type, value[f.name])]))\n : value;\n }\n if (type === \"address\") {\n const body = addressBody(value);\n return body === undefined ? value : `0x${bytesToHex(body)}`;\n }\n return value;\n };\n const domain = { ...json.domain };\n const verifying = addressBody(domain[\"verifyingContract\"]);\n if (verifying !== undefined) {\n domain[\"verifyingContract\"] = `0x${bytesToHex(verifying)}`;\n }\n return {\n types: json.types,\n primaryType: json.primaryType,\n domain,\n message: Object.fromEntries(\n (json.types[json.primaryType] ?? []).map((f) => [f.name, map(f.type, json.message[f.name])]),\n ),\n };\n};\n\n/**\n * The leaf-value override for `typedDataFields` on a TRON document: `address` leaves render base58\n * and `trcToken` decimal; anything else defers to the default leaf rule.\n */\nexport const tronTypedDataLeaf = (type: string, value: unknown): string | undefined => {\n if (type === \"address\") {\n return tronTypedDataBase58(value);\n }\n if (type === \"trcToken\") {\n const v = strictInt(value, false);\n const [, max] = intBounds(false, 256);\n return v === undefined || v > max ? undefined : v.toString(10);\n }\n return undefined;\n};\n","/**\n * /tron/plan — the serialisable signing plan of a normalized request: a transaction plans\n * sha256(raw_data), a message the TIP-191 digest, typed data the TIP-712 digest. No key material.\n */\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n\nimport { ChainError } from \"../index.ts\";\nimport type { EcdsaTask, SignRequest, TaskKey } from \"../index.ts\";\nimport { tronMessageDigest } from \"./message.ts\";\nimport { decodeTronRawData } from \"./raw.ts\";\nimport { parseTronTypedData, tronTypedDataDigest } from \"./typed-data.ts\";\n\nexport type TronSignPlan = {\n readonly kind: \"tron.transaction\" | \"tron.message\" | \"tron.typed-data\";\n readonly tasks: readonly [EcdsaTask];\n};\n\nconst ecdsa = (digest: Uint8Array, key: TaskKey): EcdsaTask => ({\n scheme: \"ecdsa-secp256k1\",\n path: key.path,\n publicKey: key.publicKey,\n digest,\n});\n\nexport const planTronTransaction = (rawData: Uint8Array, key: TaskKey): TronSignPlan => {\n if (rawData.length === 32) {\n throw new ChainError(\"invalid-request\", \"a bare 32-byte digest is not a TRON transaction\");\n }\n decodeTronRawData(rawData);\n return { kind: \"tron.transaction\", tasks: [ecdsa(sha256(rawData), key)] };\n};\n\nexport const planTronMessage = (message: Uint8Array, key: TaskKey): TronSignPlan => {\n if (message.length === 0) {\n throw new ChainError(\"invalid-request\", \"a TRON message is non-empty bytes\");\n }\n return { kind: \"tron.message\", tasks: [ecdsa(tronMessageDigest(message), key)] };\n};\n\nexport const planTronTypedData = (typedData: string, key: TaskKey): TronSignPlan => ({\n kind: \"tron.typed-data\",\n tasks: [ecdsa(tronTypedDataDigest(parseTronTypedData(typedData).json), key)],\n});\n\n/** The plan of a normalized request; the task keeps the request kind so the kernel can wrap it. */\nexport const planTron = (\n request: Extract<SignRequest, { kind: \"tron.transaction\" | \"tron.message\" | \"tron.typed-data\" }>,\n key: TaskKey,\n): TronSignPlan => {\n if (request.kind === \"tron.transaction\") {\n return planTronTransaction(request.rawData, key);\n }\n if (request.kind === \"tron.typed-data\") {\n return planTronTypedData(request.typedData, key);\n }\n return planTronMessage(request.message, key);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,MAAa,gBACX,MACA,eACwC;CACxC,aAAa,KAAK,OAAO,UAAU;CACnC,MAAM,EAAE,GAAG,GAAG,YAAY,YAAY,KAAK,MAAM,IAAI,WAAW,sBAAM,IAAI,WAAW,CAAC;CACtF,OAAO;EACL,MAAM;EACN,UAAU,UAAU,QAClB,UAAU,KAAK;GAAE,GAAG,IAAI,WAAW,CAAC;GAAG,GAAG,IAAI,WAAW,CAAC;GAAG;EAAQ,CAAC,CACxE;CACF;AACF;;;;;;;;;;;ACVA,SAAgB,UAAU,MAAqB;CAC7C,MAAM,IAAI,WAAW,mBAAmB,uBAAuB,MAAM;AACvE;;;;;AAMA,MAAa,cACX,OACA,WACsD;CACtD,IAAI,QAAQ;CACZ,KAAK,IAAI,IAAI,IAAK,KAAK;EACrB,IAAI,MAAM,IACR,UAAU,6BAA6B;EAEzC,MAAM,KAAK,SAAS;EACpB,MAAM,IAAI,MAAM;EAChB,IAAI,MAAM,KAAA,GACR,UAAU,kBAAkB;EAE9B,KAAK,IAAI,SAAU,GAAG;GACpB,IAAI,IAAI,KAAK,MAAM,GACjB,UAAU,oBAAoB;GAEhC,IAAI,MAAM,KAAK,IAAI,GACjB,UAAU,wBAAwB;GAEpC,SAAS,OAAO,CAAC,KAAK,OAAO,IAAI,CAAC;GAClC,OAAO;IAAE;IAAO,MAAM,KAAK;GAAE;EAC/B;EACA,SAAS,OAAO,IAAI,GAAI,KAAK,OAAO,IAAI,CAAC;CAC3C;AACF;AAEA,MAAa,eAAe,UAA8B;CACxD,MAAM,MAAgB,CAAC;CACvB,IAAI,IAAI;CACR,SAAS;EACP,IAAI,IAAI,OAAO,IAAI,IAAK;EACxB,MAA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AAC7C"}
@@ -1,3 +1,6 @@
1
+ import { L as SignTask } from "./index-CIRaHKpx.mjs";
2
+ /** Signs one task with a raw Ed25519 seed: deterministic, 64 bytes. */
3
+ export declare const signSolanaTask: (task: SignTask, privateKey: Uint8Array) => Uint8Array;
1
4
  /** Signs `message` with a 32-byte Ed25519 seed; returns the 64-byte signature. */
2
5
  export declare const signSolanaMessage: (message: Uint8Array, privateKey: Uint8Array) => Uint8Array;
3
6
  //# sourceMappingURL=solana-sign.d.mts.map
@@ -1,19 +1,32 @@
1
- import { t as ChainError } from "./src-8NZeEnrW.mjs";
1
+ import { t as ChainError } from "./src-CHB_z45M.mjs";
2
+ import { i as signLocally } from "./tasks-7AFv3PQn.mjs";
3
+ import { r as planSolanaMessage, t as assembleSolana } from "./assemble-BdiPo0ZX.mjs";
2
4
  import { ed25519 } from "@noble/curves/ed25519.js";
3
5
  // src/solana/sign.ts
4
6
  /**
5
- * /solana/sign — deterministic Ed25519 signing over the compiled message or raw offchain bytes.
6
- * Inputs must already be normalized: the kernel calls `normalizeSolana` first. No key caching; the
7
- * caller wipes key bytes.
7
+ * /solana/sign — the only file holding private-key code for the family: the local task signer, plus
8
+ * the raw-key API reimplemented as `plan → signSolanaTask → assembleSolana`. Inputs must already be
9
+ * normalized: the kernel calls `normalizeSolana` first. No key caching; the caller wipes key
10
+ * bytes.
8
11
  */
12
+ const checkKey = (privateKey) => {
13
+ if (privateKey.length !== 32) throw new ChainError("invalid-request", "private key must be a 32-byte seed");
14
+ };
15
+ /** Signs one task with a raw Ed25519 seed: deterministic, 64 bytes. */
16
+ const signSolanaTask = (task, privateKey) => {
17
+ checkKey(privateKey);
18
+ if (task.scheme !== "ed25519") throw new ChainError("unsupported", `solana cannot sign ${task.scheme} tasks`);
19
+ return ed25519.sign(task.message, privateKey);
20
+ };
9
21
  /** Signs `message` with a 32-byte Ed25519 seed; returns the 64-byte signature. */
10
22
  const signSolanaMessage = (message, privateKey) => {
11
- if (privateKey.length !== 32) throw new ChainError("invalid-request", "private key must be a 32-byte seed");
12
- if (message.length === 0) throw new ChainError("invalid-request", "message must not be empty");
13
- const signature = ed25519.sign(message, privateKey);
14
- if (signature.length !== 64) throw new ChainError("invalid-request", "ed25519 produced a malformed signature");
15
- return signature;
23
+ checkKey(privateKey);
24
+ const key = {
25
+ path: [],
26
+ publicKey: ed25519.getPublicKey(privateKey)
27
+ };
28
+ return signLocally(planSolanaMessage("solana.message", message, key), (task) => signSolanaTask(task, privateKey), assembleSolana);
16
29
  };
17
- export { signSolanaMessage };
30
+ export { signSolanaMessage, signSolanaTask };
18
31
 
19
32
  //# sourceMappingURL=solana-sign.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana-sign.mjs","names":[],"sources":["../src/solana/sign.ts"],"sourcesContent":["/**\n * /solana/sign — deterministic Ed25519 signing over the compiled message or raw offchain bytes.\n * Inputs must already be normalized: the kernel calls `normalizeSolana` first. No key caching; the\n * caller wipes key bytes.\n */\nimport { ed25519 } from \"@noble/curves/ed25519.js\";\n\nimport { ChainError } from \"../index.ts\";\n\n/** Signs `message` with a 32-byte Ed25519 seed; returns the 64-byte signature. */\nexport const signSolanaMessage = (message: Uint8Array, privateKey: Uint8Array): Uint8Array => {\n if (privateKey.length !== 32) {\n throw new ChainError(\"invalid-request\", \"private key must be a 32-byte seed\");\n }\n if (message.length === 0) {\n throw new ChainError(\"invalid-request\", \"message must not be empty\");\n }\n const signature = ed25519.sign(message, privateKey);\n if (signature.length !== 64) {\n throw new ChainError(\"invalid-request\", \"ed25519 produced a malformed signature\");\n }\n return signature;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,qBAAqB,SAAqB,eAAuC;CAC5F,IAAI,WAAW,WAAW,IACxB,MAAM,IAAI,WAAW,mBAAmB,oCAAoC;CAE9E,IAAI,QAAQ,WAAW,GACrB,MAAM,IAAI,WAAW,mBAAmB,2BAA2B;CAErE,MAAM,YAAY,QAAQ,KAAK,SAAS,UAAU;CAClD,IAAI,UAAU,WAAW,IACvB,MAAM,IAAI,WAAW,mBAAmB,wCAAwC;CAElF,OAAO;AACT"}
1
+ {"version":3,"file":"solana-sign.mjs","names":[],"sources":["../src/solana/sign.ts"],"sourcesContent":["/**\n * /solana/sign — the only file holding private-key code for the family: the local task signer, plus\n * the raw-key API reimplemented as `plan → signSolanaTask → assembleSolana`. Inputs must already be\n * normalized: the kernel calls `normalizeSolana` first. No key caching; the caller wipes key\n * bytes.\n */\nimport { ed25519 } from \"@noble/curves/ed25519.js\";\n\nimport { ChainError } from \"../index.ts\";\nimport type { SignTask, TaskKey } from \"../index.ts\";\nimport { signLocally } from \"../tasks.ts\";\nimport { assembleSolana } from \"./assemble.ts\";\nimport { planSolanaMessage } from \"./plan.ts\";\n\nconst checkKey = (privateKey: Uint8Array): void => {\n if (privateKey.length !== 32) {\n throw new ChainError(\"invalid-request\", \"private key must be a 32-byte seed\");\n }\n};\n\n/** Signs one task with a raw Ed25519 seed: deterministic, 64 bytes. */\nexport const signSolanaTask = (task: SignTask, privateKey: Uint8Array): Uint8Array => {\n checkKey(privateKey);\n if (task.scheme !== \"ed25519\") {\n throw new ChainError(\"unsupported\", `solana cannot sign ${task.scheme} tasks`);\n }\n return ed25519.sign(task.message, privateKey);\n};\n\n/** Signs `message` with a 32-byte Ed25519 seed; returns the 64-byte signature. */\nexport const signSolanaMessage = (message: Uint8Array, privateKey: Uint8Array): Uint8Array => {\n checkKey(privateKey);\n const key: TaskKey = { path: [], publicKey: ed25519.getPublicKey(privateKey) };\n return signLocally(\n planSolanaMessage(\"solana.message\", message, key),\n (task) => signSolanaTask(task, privateKey),\n assembleSolana,\n );\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,YAAY,eAAiC;CACjD,IAAI,WAAW,WAAW,IACxB,MAAM,IAAI,WAAW,mBAAmB,oCAAoC;AAEhF;;AAGA,MAAa,kBAAkB,MAAgB,eAAuC;CACpF,SAAS,UAAU;CACnB,IAAI,KAAK,WAAW,WAClB,MAAM,IAAI,WAAW,eAAe,sBAAsB,KAAK,OAAO,OAAO;CAE/E,OAAO,QAAQ,KAAK,KAAK,SAAS,UAAU;AAC9C;;AAGA,MAAa,qBAAqB,SAAqB,eAAuC;CAC5F,SAAS,UAAU;CACnB,MAAM,MAAe;EAAE,MAAM,CAAC;EAAG,WAAW,QAAQ,aAAa,UAAU;CAAE;CAC7E,OAAO,YACL,kBAAkB,kBAAkB,SAAS,GAAG,IAC/C,SAAS,eAAe,MAAM,UAAU,GACzC,cACF;AACF"}
package/dist/solana.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { b as Verifiability, l as DisplayIntent, v as SignRequest } from "./index-DYwm4-Ec.mjs";
1
+ import { F as SignRequest, G as Verifiability, h as Ed25519Task, i as Assembled, p as DisplayIntent, z as TaskKey } from "./index-CIRaHKpx.mjs";
2
2
  /** Well-known Solana program ids (base58, 32 bytes) — frozen constants. */
3
3
  export declare const PROGRAM_IDS: Readonly<{
4
4
  system: string;
@@ -7,6 +7,9 @@ export declare const PROGRAM_IDS: Readonly<{
7
7
  token: string;
8
8
  token2022: string;
9
9
  stake: string;
10
+ ed25519: string;
11
+ secp256k1: string;
12
+ secp256r1: string;
10
13
  }>;
11
14
  /**
12
15
  * CAIP-2 ids the wallet knows. The wire message itself carries no network marker — `network` is the
@@ -16,6 +19,72 @@ export declare const SOLANA_NETWORKS: ReadonlyArray<string>;
16
19
  export declare const isSolanaAddress: (value: string) => boolean;
17
20
  /** Base58-encoded address for a 32-byte ed25519 public key. */
18
21
  export declare function solanaAddressFromPublicKey(pubkey: Uint8Array): string;
22
+ type CompiledIx = {
23
+ readonly programAddressIndex: number;
24
+ readonly accountIndices: ReadonlyArray<number>;
25
+ readonly data: Uint8Array;
26
+ };
27
+ /** The resource limits and priority fee a v1 message's config mask declares (SIMD-0385). */
28
+ type SolanaTransactionConfig = {
29
+ /** Bits 0+1: the total priority fee in lamports (not a per-unit price). */
30
+ readonly priorityFeeLamports?: bigint;
31
+ /** Bit 2: compute-unit limit. */
32
+ readonly computeUnitLimit?: number;
33
+ /** Bit 3: loaded-accounts-data-size limit. */
34
+ readonly loadedAccountsDataSizeLimit?: number;
35
+ /** Bit 4: heap size in bytes. */
36
+ readonly heapSize?: number;
37
+ };
38
+ type ParsedSolanaMessageBase = {
39
+ readonly numRequiredSignatures: number;
40
+ readonly numReadonlySignerAccounts: number;
41
+ readonly numReadonlyNonSignerAccounts: number;
42
+ readonly staticAccounts: ReadonlyArray<string>;
43
+ /** The lifetime specifier (recent blockhash) as base58 — every version carries it. */
44
+ readonly lifetimeToken: string;
45
+ readonly instructions: ReadonlyArray<CompiledIx>;
46
+ readonly lookups: ReadonlyArray<LookupReference>;
47
+ };
48
+ type ParsedSolanaMessage = ParsedSolanaMessageBase & ({
49
+ readonly version: "legacy" | 0;
50
+ } | {
51
+ readonly version: 1;
52
+ readonly config: SolanaTransactionConfig;
53
+ });
54
+ /** One address-table lookup: the table and which of its entries the message references. */
55
+ type LookupReference = {
56
+ readonly address: string;
57
+ readonly writableIndexes: ReadonlyArray<number>;
58
+ readonly readonlyIndexes: ReadonlyArray<number>;
59
+ };
60
+ /**
61
+ * Whether a cluster could accept `bytes` as the message of a transaction — signing them as a raw
62
+ * message would authorise it.
63
+ */
64
+ export declare const mayBeTransactionMessage: (bytes: Uint8Array) => boolean;
65
+ /**
66
+ * Decodes a compiled wire message; rejects trailing bytes and the transaction size limit (1232 for
67
+ * legacy/v0, 4096 including signatures for v1). The fee payer is `staticAccounts[0]` — every valid
68
+ * transaction signs it.
69
+ */
70
+ export declare const parseCompiledMessage: (bytes: Uint8Array) => ParsedSolanaMessage;
71
+ /**
72
+ * Whether the account `index` is writable in the message: a static signer index is writable below
73
+ * `numRequiredSignatures - numReadonlySignerAccounts`, a static non-signer index below
74
+ * `staticAccounts.length - numReadonlyNonSignerAccounts`, and a loaded index is writable exactly in
75
+ * the leading writable section of the loaded addresses.
76
+ */
77
+ export declare const isWritableIndex: (parsed: ParsedSolanaMessage, index: number) => boolean;
78
+ /**
79
+ * The accounts a decoded intent names to the user — recipients, owners, authorities, delegates,
80
+ * mints, stake and vote accounts — must be static keys: the signature binds only the message bytes,
81
+ * never the caller-declared table contents an index resolves through. `at` therefore treats a
82
+ * loaded index as unresolvable and records the address the caller's table substituted.
83
+ */
84
+ type NamedAccounts = {
85
+ readonly at: (index: number) => string | undefined;
86
+ readonly fromTable: ReadonlySet<string>;
87
+ };
19
88
  /**
20
89
  * Built-in SPL token table, keyed by `network` then mint address. An entry makes a
21
90
  * `transferChecked` `full`-verifiable (WD-065), so every entry must come from the issuer's own
@@ -28,6 +97,17 @@ type SolanaToken = {
28
97
  };
29
98
  type SolanaTokenTable = Readonly<Record<string, Readonly<Record<string, SolanaToken>>>>;
30
99
  export declare const solanaTokenTable: SolanaTokenTable;
100
+ /** The most writable accounts a signer-taking unknown program may reach before it is blind. */
101
+ export declare const PROGRAM_AUTHORITY_ACCOUNTS = 12;
102
+ /**
103
+ * The resolved addresses a decoded intent would name to the user that come from caller-supplied
104
+ * lookup-table contents — the set a transaction builder must keep as static keys so the intent it
105
+ * signs is verifiable.
106
+ */
107
+ export declare const namedTableAccounts: (parsed: ParsedSolanaMessage, lookups: ReadonlyArray<{
108
+ address: string;
109
+ addresses: ReadonlyArray<string>;
110
+ }> | undefined) => ReadonlyArray<string>;
31
111
  /** What the signer can guarantee about this request (WD-065). */
32
112
  export declare const verifiabilitySolana: (request: Extract<SignRequest, {
33
113
  kind: "solana.transaction";
@@ -79,37 +159,69 @@ export declare const parseMintExtensions: (data: Uint8Array, epoch: bigint) => M
79
159
  export declare const netAfterTransferFee: (amount: bigint, bps: number, max: bigint) => bigint;
80
160
  /** The native asset id in `AssetFlow` and simulated asset changes. */
81
161
  export declare const SOLANA_NATIVE_ASSET = "lamports";
82
- type CompiledIx = {
83
- readonly programAddressIndex: number;
162
+ /**
163
+ * Sync Associated Token Account derivation for the kernel: `findAssociatedTokenPda` is async, so
164
+ * the decoder derives `sha256(owner ‖ tokenProgram ‖ mint ‖ bump ‖ ata ‖ "ProgramDerivedAddress")`
165
+ * over bump 255→0 and takes the first hash off the ed25519 curve — matching the on-chain rule.
166
+ */
167
+ export declare const associatedTokenAddress: (owner: string, mint: string, tokenProgram: string) => string;
168
+ /** Metaplex Core — recognised by program id; the transfer authority is verified on-chain. */
169
+ export declare const MPL_CORE_PROGRAM = "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d";
170
+ type CoreTransfer = {
171
+ readonly authority: string;
172
+ readonly asset: string;
173
+ readonly newOwner: string;
174
+ };
175
+ /**
176
+ * `TransferV1` with the accounts `[asset, collection, payer, authority, newOwner, systemProgram,
177
+ * logWrapper]` — omitted optionals carry the program id itself (the Shank convention). The
178
+ * authority slot resolves to the payer when it is the placeholder; it must be the signer for the
179
+ * call to count as a transfer the wallet is doing.
180
+ */
181
+ export declare const decodeCoreIx: (ix: {
84
182
  readonly accountIndices: ReadonlyArray<number>;
85
183
  readonly data: Uint8Array;
86
- };
87
- type ParsedSolanaMessage = {
88
- readonly version: "legacy" | 0;
89
- readonly numRequiredSignatures: number;
90
- readonly staticAccounts: ReadonlyArray<string>;
91
- readonly instructions: ReadonlyArray<CompiledIx>;
92
- readonly lookups: ReadonlyArray<LookupReference>;
93
- };
94
- /** One address-table lookup: the table and which of its entries the message references. */
95
- type LookupReference = {
96
- readonly address: string;
97
- readonly writableIndexes: ReadonlyArray<number>;
98
- readonly readonlyIndexes: ReadonlyArray<number>;
184
+ }, named: NamedAccounts) => CoreTransfer | undefined;
185
+ /** Jupiter's swap program — recognised by program id like Lido's upgradeable proxies. */
186
+ export declare const JUPITER_PROGRAM = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
187
+ export declare const WSOL_MINT = "So11111111111111111111111111111111111111112";
188
+ /** A serialized transaction read for one of its required signers. */
189
+ type SolanaTransactionForSigner = {
190
+ /** The compiled message the signer signs. */
191
+ readonly message: Uint8Array;
192
+ /** Required signers other than `signer` whose signature slot is still all zeros, in slot order. */
193
+ readonly unsigned: ReadonlyArray<string>;
99
194
  };
100
195
  /**
101
- * Decodes a compiled wire message; rejects trailing bytes and the 1232-byte transaction limit. The
102
- * fee payer is `staticAccounts[0]` — every valid transaction signs it.
196
+ * Reads the serialized transaction `wire` as the Wallet Standard passes it for `signer`: the
197
+ * compiled message the signer signs, and which other required signers have not signed yet. Every
198
+ * non-empty signature slot must verify over the message — one that cannot land is refused.
103
199
  */
104
- export declare const parseCompiledMessage: (bytes: Uint8Array) => ParsedSolanaMessage;
200
+ export declare const decodeSolanaTransaction: (wire: Uint8Array, signer: string) => SolanaTransactionForSigner;
201
+ /**
202
+ * `wire` with `signer`'s slot set to `signature`; every other byte unchanged — the other signatures
203
+ * and their order are preserved byte for byte (a v1 wire keeps the message first).
204
+ */
205
+ export declare const addSolanaSignature: (wire: Uint8Array, signer: string, signature: Uint8Array) => Uint8Array;
105
206
  /** Whether `signature` is a valid ed25519 signature of `message` by the key behind `address`. */
106
207
  export declare const verifySolanaSignature: (message: Uint8Array, signature: Uint8Array, accountAddress: string) => boolean;
208
+ type SolanaSignPlan = {
209
+ readonly kind: "solana.transaction" | "solana.message";
210
+ readonly tasks: readonly [Ed25519Task];
211
+ };
212
+ /** The plan of a normalized request; the task keeps the request kind so the kernel can wrap it. */
213
+ export declare const planSolana: (request: Extract<SignRequest, {
214
+ kind: "solana.transaction" | "solana.message";
215
+ }>, key: TaskKey) => SolanaSignPlan;
216
+ export declare const assembleSolana: (plan: SolanaSignPlan, signatures: ReadonlyArray<Uint8Array>) => Assembled<Uint8Array, SolanaSignPlan>;
107
217
  /**
108
- * Normalizes a Solana sign request. `signer` is the fee payer the wallet is about to sign for — the
109
- * message must declare it as the first static account. A raw `solana.message` must not decode as a
110
- * transaction message (chains.mdx rule — a bytes-to-sign path that produces a transaction signature
111
- * is a wallet-drainer). Idempotent.
218
+ * Normalizes a Solana sign request. `signer` is a required signer the wallet is about to sign for —
219
+ * the message must declare it among the first `numRequiredSignatures` static accounts.
220
+ * `lookupTables` may only accompany a v0 message — v1 has no address lookup tables (SIMD-0385). A
221
+ * raw `solana.message` must not decode as a transaction message (chains.mdx rule — a bytes-to-sign
222
+ * path that produces a transaction signature is a wallet-drainer): bytes a cluster could accept as
223
+ * a transaction message of any version are never signed as a raw message. Idempotent.
112
224
  */
113
225
  export declare const normalizeSolana: (request: unknown, signer: string) => SignRequest;
114
- export type { LookupReference, MintExtensionSummary, ParsedSolanaMessage, SolanaTokenTable };
226
+ export type { LookupReference, MintExtensionSummary, NamedAccounts, ParsedSolanaMessage, SolanaSignPlan, SolanaTokenTable, SolanaTransactionConfig, SolanaTransactionForSigner };
115
227
  //# sourceMappingURL=solana.d.mts.map