@invisi-labs/sdk 1.1.7 → 1.2.1

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 (118) hide show
  1. package/README.md +5 -0
  2. package/dist/broadcaster-3KTB4JO2.cjs +21 -0
  3. package/dist/broadcaster-3KTB4JO2.cjs.map +1 -0
  4. package/dist/broadcaster-7ZKKSTZQ.js +21 -0
  5. package/dist/broadcaster-preparation-PJ263WBL.cjs +15 -0
  6. package/dist/broadcaster-preparation-PJ263WBL.cjs.map +1 -0
  7. package/dist/broadcaster-preparation-ZQAPZAUG.js +15 -0
  8. package/dist/broadcaster-preparation-ZQAPZAUG.js.map +1 -0
  9. package/dist/{chunk-LOU7AP2B.cjs → chunk-2URICDPW.cjs} +72 -33
  10. package/dist/chunk-2URICDPW.cjs.map +1 -0
  11. package/dist/chunk-3D24ABYR.js +86 -0
  12. package/dist/chunk-3D24ABYR.js.map +1 -0
  13. package/dist/chunk-3KTQQZOW.cjs +71 -0
  14. package/dist/chunk-3KTQQZOW.cjs.map +1 -0
  15. package/dist/chunk-4SDP53YQ.cjs +765 -0
  16. package/dist/chunk-4SDP53YQ.cjs.map +1 -0
  17. package/dist/{chunk-XHKQ2BO2.js → chunk-4VI6LYGH.js} +25 -2
  18. package/dist/chunk-4VI6LYGH.js.map +1 -0
  19. package/dist/chunk-BBSRP4MH.cjs +287 -0
  20. package/dist/chunk-BBSRP4MH.cjs.map +1 -0
  21. package/dist/chunk-DGMVGFKM.js +41 -0
  22. package/dist/chunk-DGMVGFKM.js.map +1 -0
  23. package/dist/chunk-DHQEB6JR.cjs +1616 -0
  24. package/dist/chunk-DHQEB6JR.cjs.map +1 -0
  25. package/dist/chunk-FKF67XE6.js +1616 -0
  26. package/dist/chunk-FKF67XE6.js.map +1 -0
  27. package/dist/chunk-GUD3LAUO.js +765 -0
  28. package/dist/chunk-GUD3LAUO.js.map +1 -0
  29. package/dist/chunk-HCB7RQ3S.cjs +79 -0
  30. package/dist/chunk-HCB7RQ3S.cjs.map +1 -0
  31. package/dist/{chunk-GTPUYPQL.js → chunk-HKGJXQVN.js} +69 -30
  32. package/dist/chunk-HKGJXQVN.js.map +1 -0
  33. package/dist/chunk-HLH5JZD4.js +287 -0
  34. package/dist/chunk-HLH5JZD4.js.map +1 -0
  35. package/dist/chunk-J6TZZVAM.cjs +230 -0
  36. package/dist/chunk-J6TZZVAM.cjs.map +1 -0
  37. package/dist/{chunk-7F7ZZW3L.cjs → chunk-LOR6PYH5.cjs} +25 -2
  38. package/dist/chunk-LOR6PYH5.cjs.map +1 -0
  39. package/dist/chunk-MA2QZEF5.cjs +399 -0
  40. package/dist/chunk-MA2QZEF5.cjs.map +1 -0
  41. package/dist/chunk-MI4IP4ZD.cjs +86 -0
  42. package/dist/chunk-MI4IP4ZD.cjs.map +1 -0
  43. package/dist/chunk-OCZLJKIA.cjs +41 -0
  44. package/dist/chunk-OCZLJKIA.cjs.map +1 -0
  45. package/dist/chunk-R5YAOJKB.js +71 -0
  46. package/dist/chunk-R5YAOJKB.js.map +1 -0
  47. package/dist/chunk-RY4M2CIQ.js +399 -0
  48. package/dist/chunk-RY4M2CIQ.js.map +1 -0
  49. package/dist/chunk-THMD5QO2.js +79 -0
  50. package/dist/chunk-THMD5QO2.js.map +1 -0
  51. package/dist/chunk-ZD2652WH.js +230 -0
  52. package/dist/chunk-ZD2652WH.js.map +1 -0
  53. package/dist/credit.cjs +1 -0
  54. package/dist/credit.cjs.map +1 -0
  55. package/dist/credit.d.cts +12 -0
  56. package/dist/credit.d.ts +12 -0
  57. package/dist/credit.js +1 -0
  58. package/dist/credit.js.map +1 -0
  59. package/dist/ethers.cjs +2 -2
  60. package/dist/ethers.cjs.map +1 -1
  61. package/dist/ethers.d.cts +15 -4
  62. package/dist/ethers.d.ts +15 -4
  63. package/dist/ethers.js +1 -1
  64. package/dist/index-CLhGwLxZ.d.cts +42 -0
  65. package/dist/index-Crp-ZFiM.d.ts +42 -0
  66. package/dist/index.cjs +69 -38
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.d.cts +21 -14
  69. package/dist/index.d.ts +21 -14
  70. package/dist/index.js +64 -33
  71. package/dist/index.js.map +1 -1
  72. package/dist/note.cjs +11 -0
  73. package/dist/note.cjs.map +1 -0
  74. package/dist/note.d.cts +29 -0
  75. package/dist/note.d.ts +29 -0
  76. package/dist/note.js +11 -0
  77. package/dist/note.js.map +1 -0
  78. package/dist/{broadcaster-preparation-DMxxZ_1Q.d.cts → operation-bridge-CoECSxfi.d.cts} +130 -245
  79. package/dist/{broadcaster-preparation-DMxxZ_1Q.d.ts → operation-bridge-CoECSxfi.d.ts} +130 -245
  80. package/dist/preparation-HUBTVCZE.js +404 -0
  81. package/dist/preparation-HUBTVCZE.js.map +1 -0
  82. package/dist/preparation-QD3ZSYV5.cjs +404 -0
  83. package/dist/preparation-QD3ZSYV5.cjs.map +1 -0
  84. package/dist/provenance-preparation-43DN2WK7.cjs +16 -0
  85. package/dist/provenance-preparation-43DN2WK7.cjs.map +1 -0
  86. package/dist/provenance-preparation-HEZE4L5H.js +16 -0
  87. package/dist/provenance-preparation-HEZE4L5H.js.map +1 -0
  88. package/dist/provenance.cjs +59 -0
  89. package/dist/provenance.cjs.map +1 -0
  90. package/dist/provenance.d.cts +34 -0
  91. package/dist/provenance.d.ts +34 -0
  92. package/dist/provenance.js +59 -0
  93. package/dist/provenance.js.map +1 -0
  94. package/dist/{receipt-logs-m0-bhaxW.d.ts → receipt-logs-DQRJK0l8.d.cts} +84 -78
  95. package/dist/{receipt-logs-CvC951p7.d.cts → receipt-logs-fMR6Bwql.d.ts} +84 -78
  96. package/dist/session-support.cjs +28 -7
  97. package/dist/session-support.cjs.map +1 -1
  98. package/dist/session-support.d.cts +71 -39
  99. package/dist/session-support.d.ts +71 -39
  100. package/dist/session-support.js +58 -37
  101. package/dist/session-support.js.map +1 -1
  102. package/package.json +22 -6
  103. package/dist/broadcaster-preparation-RMWQFYNL.js +0 -11
  104. package/dist/broadcaster-preparation-UGOTO4SX.cjs +0 -11
  105. package/dist/broadcaster-preparation-UGOTO4SX.cjs.map +0 -1
  106. package/dist/chunk-7F7ZZW3L.cjs.map +0 -1
  107. package/dist/chunk-EHP5TBC6.js +0 -3565
  108. package/dist/chunk-EHP5TBC6.js.map +0 -1
  109. package/dist/chunk-GTPUYPQL.js.map +0 -1
  110. package/dist/chunk-ITTGBIG2.js +0 -1877
  111. package/dist/chunk-ITTGBIG2.js.map +0 -1
  112. package/dist/chunk-J2JH6HIG.cjs +0 -1877
  113. package/dist/chunk-J2JH6HIG.cjs.map +0 -1
  114. package/dist/chunk-LOU7AP2B.cjs.map +0 -1
  115. package/dist/chunk-RHNIHI4P.cjs +0 -3565
  116. package/dist/chunk-RHNIHI4P.cjs.map +0 -1
  117. package/dist/chunk-XHKQ2BO2.js.map +0 -1
  118. /package/dist/{broadcaster-preparation-RMWQFYNL.js.map → broadcaster-7ZKKSTZQ.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/wx/Workspace/invisi-lab/invisi-sdk-ts/packages/sdk/dist/chunk-4SDP53YQ.cjs","../src/payment-note/codec.ts","../src/errors.ts","../src/notes/resolve-recipient.ts","../src/payment-request/codec.ts","../src/payment-request/binary.ts","../src/payment-request/validation.ts","../src/payment-note/export.ts","../src/notes/NoteOutput.ts","../src/payment-request/match-output.ts","../src/payment-request/execution.ts"],"names":["value","MissingCapabilityError","encodeBase64","FIELD_MODULUS","decodeBase64","nonce","ReceivingAddress","hexlify"],"mappings":"AAAA;ACAA,qDAA8B;AAC9B,gCAAkF;AAGlF,SAAS,IAAA,CAAK,KAAA,EAAe,KAAA,EAA2B;AACpD,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,MAAA,EAAQ,GAAA,GAAM,MAAA,GAAS,GAAA,GAAM,MAAA,CAAO,MAAA,EAAQ,CAAC,CAAA;AAC1E,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,YAAA,EA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B,EAAA;AACJ;AAK2B;AACkC,EAAA;AACT,EAAA;AACF,EAAA;AACT,EAAA;AACS,EAAA;AAC/B,EAAA;AACwC,EAAA;AAI/C,IAAA;AAGgB,MAAA;AACxB,EAAA;AAGuB,EAAA;AAMH,IAAA;AACwB,EAAA;AACmB,IAAA;AACV,EAAA;AACZ,EAAA;AACE,EAAA;AAGjB,EAAA;AAEiC,IAAA;AAIhC,EAAA;AAG6B,IAAA;AAC/B,EAAA;AAC8B,EAAA;AACG,EAAA;AACE,IAAA;AACzB,EAAA;AAGpB,IAAA;AAOmD,MAAA;AACjC,IAAA;AAC1B,EAAA;AACiB,IAAA;AACmC,IAAA;AAGvB,IAAA;AAIqB,MAAA;AACC,IAAA;AAClC,MAAA;AAGI,IAAA;AAKyB,MAAA;AAIxC,IAAA;AAQW,MAAA;AACgC,IAAA;AACP,MAAA;AAEa,IAAA;AAGP,MAAA;AACvD,EAAA;AAII,EAAA;AAEY,IAAA;AACsB,IAAA;AACvB,IAAA;AACoB,IAAA;AACpB,IAAA;AACG,EAAA;AAEmC,IAAA;AACP,EAAA;AACjC,EAAA;AACqC,IAAA;AACvB,IAAA;AACT,MAAA;AACwC,sBAAA;AACpC,MAAA;AAClB,IAAA;AACuC,IAAA;AACrB,IAAA;AACFA,MAAAA;AACgD,QAAA;AACnC,UAAA;AAC8B,UAAA;AACtB,UAAA;AAC5B,QAAA;AACL,MAAA;AACsC,MAAA;AAC1C,IAAA;AACc,IAAA;AAClB,EAAA;AACO,EAAA;AACX;AAGgG;AACxD,EAAA;AAChB,EAAA;AACsB,IAAA;AACU,IAAA;AAC/B,IAAA;AACpB,EAAA;AACM,EAAA;AACX;ARuVmE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/wx/Workspace/invisi-lab/invisi-sdk-ts/packages/sdk/dist/chunk-4SDP53YQ.cjs","sourcesContent":[null,"import { FIELD_MODULUS } from \"@invisi-labs/primitives\";\nimport { decodeBase64, encodeBase64, getAddress, getBytes, hexlify, concat } from \"ethers\";\nimport type { PaymentNoteData } from \"./types\";\n\nfunction uint(value: bigint, bytes: number): Uint8Array {\n if (typeof value !== \"bigint\" || value < 0n || value >= 1n << BigInt(bytes * 8))\n throw new RangeError(`Invalid uint${bytes * 8} payment note field`);\n return getBytes(`0x${value.toString(16).padStart(bytes * 2, \"0\")}`);\n}\nfunction validate(value: PaymentNoteData): void {\n const keys = [\n \"chainId\",\n \"protocolAddress\",\n \"tokenAddress\",\n \"amount\",\n \"ownerAddress\",\n \"nonce\",\n \"commitment\",\n ];\n if (\n !value ||\n typeof value !== \"object\" ||\n Object.keys(value).some((key) => !keys.includes(key))\n )\n throw new TypeError(\"Invalid payment note fields\");\n uint(value.chainId, 8);\n uint(value.amount, 16);\n if (value.chainId === 0n || value.amount === 0n)\n throw new RangeError(\"Positive chainId and amount required\");\n for (const key of [\"protocolAddress\", \"ownerAddress\", \"tokenAddress\"] as const) {\n getAddress(value[key]);\n if (key !== \"tokenAddress\" && BigInt(value[key]) === 0n)\n throw new RangeError(`Invalid ${key}`);\n }\n uint(value.nonce, 32);\n if (value.nonce >= FIELD_MODULUS) throw new RangeError(\"Invalid payment note nonce\");\n if (\n !/^0x[\\da-f]{64}$/i.test(value.commitment) ||\n BigInt(value.commitment) <= 0n ||\n BigInt(value.commitment) >= FIELD_MODULUS\n )\n throw new RangeError(\"Invalid payment note commitment\");\n}\nexport function encodePaymentNote(value: PaymentNoteData): string {\n validate(value);\n const bytes = concat([\n new Uint8Array([1]),\n uint(value.chainId, 8),\n getBytes(value.protocolAddress),\n getBytes(value.tokenAddress),\n uint(value.amount, 16),\n getBytes(value.ownerAddress),\n uint(value.nonce, 32),\n getBytes(value.commitment),\n ]);\n return `ipn:${encodeBase64(bytes).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\")}`;\n}\nexport function decodePaymentNote(encoded: string): PaymentNoteData {\n if (\n typeof encoded !== \"string\" ||\n encoded.length !== 203 ||\n !/^ipn:[A-Za-z0-9_-]+$/.test(encoded)\n )\n throw new TypeError(\"Invalid payment note encoding\");\n const bytes = decodeBase64(encoded.slice(4).replace(/-/g, \"+\").replace(/_/g, \"/\") + \"=\");\n if (bytes.length !== 149 || bytes[0] !== 1)\n throw new Error(\"Unsupported payment note version or length\");\n let offset = 1;\n const take = (size: number) => {\n const value = hexlify(bytes.slice(offset, (offset += size))) as `0x${string}`;\n return value;\n };\n const value: PaymentNoteData = {\n chainId: BigInt(take(8)),\n protocolAddress: getAddress(take(20)) as `0x${string}`,\n tokenAddress: getAddress(take(20)) as `0x${string}`,\n amount: BigInt(take(16)),\n ownerAddress: getAddress(take(20)).toLowerCase() as `0x${string}`,\n nonce: BigInt(take(32)),\n commitment: take(32),\n };\n if (encodePaymentNote(value) !== encoded) throw new Error(\"Noncanonical payment note encoding\");\n return value;\n}\n","import { MissingCapabilityError } from \"@invisi-labs/primitives\";\n\n/** Stable codes returned by public SDK prepare* methods; inspect details instead of matching messages. */\nexport type InvisiErrorCode =\n /**\n * Other preparation failure, such as invalid amounts, expired deadlines,\n * or conflicting registration state. Inspect message and cause.\n */\n | \"PREPARATION_FAILED\"\n /**\n * Required infrastructure or permissions were not supplied.\n * The capability field identifies what is missing.\n */\n | \"MISSING_CAPABILITY\"\n /**\n * The recipient string is not a valid full 0i address or nonzero EVM owner address.\n * No registration lookup is attempted for this invalid string.\n */\n | \"INVALID_RECIPIENT\"\n /**\n * A successful lookup found no receiving keys for this short 0x owner\n * at the queried state. Indexed data may lag behind the latest chain state.\n * Full 0i addresses contain receiving keys and do not require registration.\n */\n | \"EVM_ADDRESS_NOT_REGISTERED\"\n /**\n * Recipient lookup failed or returned invalid keys. Inspect cause.\n * Registration status is unknown; this does not mean the owner is unregistered.\n */\n | \"RECIPIENT_LOOKUP_FAILED\";\n\nexport interface InvisiErrorDetails {\n operation?: string;\n address?: string;\n /** Zero-based index into the caller's outputs array, excluding automatic change. */\n outputIndex?: number;\n field?: string;\n capability?: string;\n cause?: unknown;\n}\n\n/** Stable application-facing preparation failure with the original cause. */\nexport class InvisiError extends Error {\n readonly code: InvisiErrorCode;\n readonly operation: string | undefined;\n readonly address: string | undefined;\n readonly outputIndex: number | undefined;\n readonly field: string | undefined;\n readonly capability: string | undefined;\n\n constructor(code: InvisiErrorCode, message: string, details: InvisiErrorDetails = {}) {\n super(message, { cause: details.cause });\n this.name = \"InvisiError\";\n this.code = code;\n this.operation = details.operation;\n this.address = details.address;\n this.outputIndex = details.outputIndex;\n this.field = details.field;\n this.capability = details.capability;\n }\n}\n\n/** Keep nested failures intact; do not infer business codes from English messages. */\nexport async function prepareWithErrors<T>(\n operation: string,\n prepare: () => Promise<T>\n): Promise<T> {\n try {\n return await prepare();\n } catch (cause) {\n if (cause instanceof InvisiError) {\n if (cause.operation) throw cause;\n throw new InvisiError(cause.code, cause.message, {\n operation,\n ...(cause.address === undefined ? {} : { address: cause.address }),\n ...(cause.outputIndex === undefined ? {} : { outputIndex: cause.outputIndex }),\n ...(cause.field === undefined ? {} : { field: cause.field }),\n ...(cause.capability === undefined ? {} : { capability: cause.capability }),\n cause: cause.cause,\n });\n }\n throw new InvisiError(\n cause instanceof MissingCapabilityError ? \"MISSING_CAPABILITY\" : \"PREPARATION_FAILED\",\n cause instanceof Error ? cause.message : \"Transaction preparation failed\",\n {\n operation,\n cause,\n ...(cause instanceof MissingCapabilityError\n ? { capability: cause.capability }\n : {}),\n }\n );\n }\n}\n","import {\n MissingCapabilityError,\n ReceivingAddress,\n type ReceivingKeyLookup,\n} from \"@invisi-labs/primitives\";\nimport { InvisiError, type InvisiErrorDetails } from \"../errors\";\n\n/** Resolve once during preparation; prepared deliveries keep this public key snapshot. */\nexport async function resolveRecipient(\n address: string,\n lookup: ReceivingKeyLookup | undefined,\n details: Pick<InvisiErrorDetails, \"field\" | \"outputIndex\"> = {}\n): Promise<ReceivingAddress> {\n const context = { ...details, address };\n let recipient: ReceivingAddress;\n try {\n recipient = ReceivingAddress.parse(address);\n } catch (cause) {\n throw new InvisiError(\"INVALID_RECIPIENT\", \"Invalid recipient address\", {\n ...context,\n cause,\n });\n }\n if (recipient.kind === \"long\") return recipient;\n if (!lookup) {\n throw new InvisiError(\"MISSING_CAPABILITY\", \"Missing registry lookup capability\", {\n ...context,\n capability: \"registry lookup\",\n });\n }\n let keys: Awaited<ReturnType<ReceivingKeyLookup>>;\n try {\n keys = await lookup(recipient.ownerAddress);\n } catch (cause) {\n if (cause instanceof MissingCapabilityError) {\n throw new InvisiError(\"MISSING_CAPABILITY\", cause.message, {\n ...context,\n cause,\n capability: cause.capability,\n });\n }\n throw new InvisiError(\"RECIPIENT_LOOKUP_FAILED\", \"Recipient registry lookup failed\", {\n ...context,\n cause,\n });\n }\n if (keys == null) {\n throw new InvisiError(\n \"EVM_ADDRESS_NOT_REGISTERED\",\n \"EVM address has no registered receiving keys\",\n context\n );\n }\n try {\n return ReceivingAddress.from({\n ownerAddress: recipient.ownerAddress,\n viewingPublicKey: keys.viewingPublicKey,\n clueKey: keys.clueKey,\n });\n } catch (cause) {\n throw new InvisiError(\n \"RECIPIENT_LOOKUP_FAILED\",\n \"Registry returned invalid receiving keys\",\n { ...context, cause }\n );\n }\n}\n","import { ReceivingAddress } from \"@invisi-labs/primitives\";\nimport { decodeBase64, encodeBase64, getBytes, hexlify } from \"ethers\";\nimport { concat, Reader, uint } from \"./binary\";\nimport type { PaymentRequest, NoteOutputRecipient } from \"./types\";\nimport { MAX_REQUEST_PAYLOAD_BYTES, validatePaymentRequest } from \"./validation\";\n\nconst PREFIX = \"ipr:\";\nconst VERSION = 1;\nconst MAX_BINARY_BYTES = 186 + MAX_REQUEST_PAYLOAD_BYTES;\nfunction base64url(data: Uint8Array): string {\n return encodeBase64(data).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\n/** Encode only the request, never the current output nonce or local registry lookup choice. */\nexport function encodePaymentRequest(request: PaymentRequest): string {\n validatePaymentRequest(request);\n const recipient = request.recipient;\n const parts = [\n new Uint8Array([\n VERSION,\n recipient.type === \"evm\" ? 1 : recipient.type === \"invisi\" ? 2 : 3,\n ]),\n uint(request.chainId, 8, \"chainId\"),\n getBytes(request.protocolAddress),\n getBytes(request.tokenAddress),\n uint(request.amount, 16, \"amount\"),\n ];\n if (recipient.type === \"identity\") parts.push(getBytes(recipient.identity));\n else {\n const parsed = ReceivingAddress.parse(recipient.address);\n parts.push(getBytes(parsed.ownerAddress));\n if (recipient.type === \"invisi\") {\n const keys = parsed.getReceivingKeys();\n parts.push(keys.viewingPublicKey, keys.clueKey);\n } else parts.push(new Uint8Array([recipient.envelope === false ? 0 : 1]));\n parts.push(new Uint8Array([recipient.nonce === undefined ? 0 : 1]));\n if (recipient.nonce !== undefined) parts.push(uint(recipient.nonce, 32, \"nonce\"));\n if (recipient.type === \"invisi\" || recipient.envelope !== false) {\n const payload = request.payload ?? new Uint8Array();\n parts.push(uint(BigInt(payload.length), 2, \"payloadLength\"), payload);\n }\n }\n return PREFIX + base64url(concat(parts));\n}\n\n/** Decode a canonical Note request offline, with exact resource and byte-layout checks. */\nexport function decodePaymentRequest(encoded: string): PaymentRequest {\n if (\n typeof encoded !== \"string\" ||\n !encoded.startsWith(PREFIX) ||\n encoded.length > 4 + Math.ceil((MAX_BINARY_BYTES * 8) / 6)\n )\n throw new Error(\"Invalid payment request encoding\");\n const text = encoded.slice(PREFIX.length);\n if (!/^[A-Za-z0-9_-]+$/.test(text) || text.length % 4 === 1)\n throw new Error(\"Invalid payment request Base64URL\");\n const data = decodeBase64(\n text.replace(/-/g, \"+\").replace(/_/g, \"/\") + \"=\".repeat((4 - (text.length % 4)) % 4)\n );\n if (base64url(data) !== text) throw new Error(\"Noncanonical payment request Base64URL\");\n const reader = new Reader(data);\n if (reader.integer(1) !== BigInt(VERSION))\n throw new Error(\"Unsupported payment request version\");\n const type = reader.integer(1);\n if (type < 1n || type > 3n) throw new Error(\"Unsupported payment request recipient type\");\n const context = {\n chainId: reader.integer(8),\n protocolAddress: hexlify(reader.take(20)) as `0x${string}`,\n tokenAddress: hexlify(reader.take(20)) as `0x${string}`,\n amount: reader.integer(16),\n };\n let recipient: NoteOutputRecipient;\n let payload: Uint8Array | undefined;\n if (type === 3n)\n recipient = { type: \"identity\", identity: hexlify(reader.take(32)) as `0x${string}` };\n else {\n const ownerAddress = hexlify(reader.take(20)) as `0x${string}`;\n let address: string;\n let envelope = true;\n if (type === 2n)\n address = ReceivingAddress.from({\n ownerAddress,\n viewingPublicKey: reader.take(33),\n clueKey: reader.take(32),\n }).toString();\n else {\n address = ReceivingAddress.fromIdentity(ownerAddress).toString();\n const value = reader.integer(1);\n if (value > 1n) throw new Error(\"Invalid envelope flag\");\n envelope = value === 1n;\n }\n const present = reader.integer(1);\n if (present > 1n) throw new Error(\"Invalid nonce presence flag\");\n const nonce = present === 1n ? reader.integer(32) : undefined;\n recipient =\n type === 2n\n ? { type: \"invisi\", address, ...(nonce === undefined ? {} : { nonce }) }\n : { type: \"evm\", address, envelope, ...(nonce === undefined ? {} : { nonce }) };\n if (envelope) {\n const length = Number(reader.integer(2));\n if (length > MAX_REQUEST_PAYLOAD_BYTES)\n throw new RangeError(\"payload exceeds funds envelope limit\");\n if (length !== 0) payload = reader.take(length);\n }\n }\n reader.done();\n const request = {\n ...context,\n recipient,\n ...(payload === undefined ? {} : { payload }),\n } as PaymentRequest;\n validatePaymentRequest(request);\n if (encodePaymentRequest(request) !== encoded) throw new Error(\"Noncanonical payment request\");\n return request;\n}\n","/** Fixed-width unsigned big-endian encoding; no runtime-specific bigint extension. */\nexport function uint(value: bigint, size: number, name: string): Uint8Array {\n if (typeof value !== \"bigint\" || value < 0n || value >= 1n << BigInt(size * 8))\n throw new RangeError(`${name} must be uint${size * 8}`);\n const result = new Uint8Array(size);\n for (let i = size - 1; i >= 0; i--) {\n result[i] = Number(value & 255n);\n value >>= 8n;\n }\n return result;\n}\nexport function concat(parts: readonly Uint8Array[]): Uint8Array {\n const result = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));\n let offset = 0;\n for (const part of parts) {\n result.set(part, offset);\n offset += part.length;\n }\n return result;\n}\nexport class Reader {\n #offset = 0;\n constructor(readonly data: Uint8Array) {}\n take(size: number): Uint8Array {\n if (this.#offset + size > this.data.length) throw new Error(\"Truncated payment request\");\n const result = this.data.slice(this.#offset, this.#offset + size);\n this.#offset += size;\n return result;\n }\n integer(size: number): bigint {\n return this.take(size).reduce((n, b) => (n << 8n) | BigInt(b), 0n);\n }\n done(): void {\n if (this.#offset !== this.data.length) throw new Error(\"Trailing payment request bytes\");\n }\n}\n","import { FIELD_MODULUS, MAX_CIPHERTEXT_BYTES, ReceivingAddress } from \"@invisi-labs/primitives\";\nimport { getAddress } from \"ethers\";\nimport { uint } from \"./binary\";\nimport type { PaymentRequest } from \"./types\";\n\n/** Funds envelope v1 consists of 160 fixed bytes plus the raw application payload. */\nexport const MAX_REQUEST_PAYLOAD_BYTES = MAX_CIPHERTEXT_BYTES - 160;\nexport function fields(value: unknown, allowed: readonly string[], name: string): void {\n if (!value || typeof value !== \"object\" || Array.isArray(value))\n throw new TypeError(`Invalid ${name}`);\n for (const key of Object.keys(value))\n if (!allowed.includes(key)) throw new TypeError(`Unsupported ${name} field ${key}`);\n}\nexport function nonce(value: bigint): bigint {\n uint(value, 32, \"nonce\");\n if (value >= FIELD_MODULUS)\n throw new RangeError(\"nonce must be a canonical BN254 field element\");\n return value;\n}\nexport function validatePaymentRequest(request: PaymentRequest): void {\n fields(\n request,\n [\"chainId\", \"protocolAddress\", \"tokenAddress\", \"amount\", \"recipient\", \"payload\"],\n \"payment request\"\n );\n uint(request.chainId, 8, \"chainId\");\n if (request.chainId === 0n) throw new RangeError(\"chainId must be positive\");\n const protocol = getAddress(request.protocolAddress);\n getAddress(request.tokenAddress);\n if (BigInt(protocol) === 0n) throw new RangeError(\"protocol address must be nonzero\");\n uint(request.amount, 16, \"amount\");\n if (request.amount === 0n) throw new RangeError(\"amount must be positive\");\n const recipient = request.recipient;\n fields(\n recipient,\n [\"type\", \"address\", \"nonce\", \"identity\", \"envelope\", \"addressLookup\"],\n \"recipient\"\n );\n if (recipient.type === \"identity\") {\n fields(recipient, [\"type\", \"identity\"], \"identity recipient\");\n if (\n typeof recipient.identity !== \"string\" ||\n !/^0x[\\da-f]{64}$/i.test(recipient.identity) ||\n BigInt(recipient.identity) <= 0n ||\n BigInt(recipient.identity) >= FIELD_MODULUS\n )\n throw new RangeError(\"identity must be a nonzero canonical BN254 field element\");\n if (request.payload !== undefined)\n throw new TypeError(\"payload requires an encrypted envelope\");\n return;\n }\n if (recipient.type !== \"evm\" && recipient.type !== \"invisi\")\n throw new TypeError(\"Invalid recipient type\");\n fields(\n recipient,\n recipient.type === \"evm\"\n ? [\"type\", \"address\", \"nonce\", \"envelope\", \"addressLookup\"]\n : [\"type\", \"address\", \"nonce\"],\n \"recipient\"\n );\n const parsed = ReceivingAddress.parse(recipient.address);\n if ((recipient.type === \"evm\") !== (parsed.kind === \"short\"))\n throw new TypeError(\"recipient address type mismatch\");\n if (BigInt(parsed.ownerAddress) === 0n) throw new RangeError(\"owner address must be nonzero\");\n if (recipient.nonce !== undefined) nonce(recipient.nonce);\n if (recipient.type === \"evm\") {\n if (recipient.envelope !== undefined && typeof recipient.envelope !== \"boolean\")\n throw new TypeError(\"evm envelope must be boolean\");\n if (\n recipient.addressLookup !== undefined &&\n ![\"chain\", \"protocol-rpc\"].includes(recipient.addressLookup)\n )\n throw new TypeError(\"Invalid recipient addressLookup\");\n if (recipient.envelope === false && request.payload !== undefined)\n throw new TypeError(\"payload requires an encrypted envelope\");\n }\n if (request.payload !== undefined && !(request.payload instanceof Uint8Array))\n throw new TypeError(\"payload must be Uint8Array\");\n if ((request.payload?.length ?? 0) > MAX_REQUEST_PAYLOAD_BYTES)\n throw new RangeError(\"payload exceeds funds envelope limit\");\n}\n","import type { PreparedOutput } from \"../transactions/operation-types\";\nimport { encodePaymentNote } from \"./codec\";\n\n/** Export the complete opening; identity-only outputs intentionally have no opening. */\nexport function exportPaymentNote(output: PreparedOutput): string {\n const note = output.note;\n if (output.recipient.type === \"identity\" || !note)\n throw new Error(\"Identity outputs cannot export an IPN\");\n return encodePaymentNote({\n chainId: note.chainId,\n protocolAddress: output.context.protocolAddress,\n tokenAddress: output.context.tokenAddress,\n amount: note.amount,\n ownerAddress: note.ownerAddress,\n nonce: note.nonce,\n commitment: output.commitment,\n });\n}\n","import { exportPaymentNote } from \"../payment-note/export\";\nimport {\n FIELD_MODULUS,\n ReceivingAddress,\n computeNoteCommitment,\n computeNoteIdentity,\n createClue,\n encryptPrivateTransferNote,\n generateNonce,\n type Note,\n type ReceivingKeyLookup,\n} from \"@invisi-labs/primitives\";\nimport type { Delivery, Hex } from \"@invisi-labs/protocol/contracts\";\nimport { AbiCoder, getAddress, hexlify, keccak256 } from \"ethers\";\nimport { InvisiError } from \"../errors\";\nimport type { PreparedOutput } from \"../transactions/operation-types\";\nimport type { AddressLookup } from \"./recipient-infrastructure\";\nimport { resolveRecipient } from \"./resolve-recipient\";\n\nimport type {\n NoteOutputContext,\n NoteOutputRecipient,\n PaymentRequest,\n NoteOutputExecutionOptions,\n} from \"../payment-request/types\";\nexport type {\n NoteOutputContext,\n NoteOutputRecipient,\n PaymentRequest,\n NoteOutputExecutionOptions,\n} from \"../payment-request/types\";\nimport { encodePaymentRequest, decodePaymentRequest } from \"../payment-request/codec\";\nimport { assertRequestMatchesOutput } from \"../payment-request/match-output\";\nimport { applyExecutionOptions } from \"../payment-request/execution\";\nfunction nonceValue(value: bigint): bigint {\n if (typeof value !== \"bigint\" || value < 0n || value >= FIELD_MODULUS)\n throw new RangeError(\"nonce must be a canonical BN254 field element\");\n return value;\n}\nfunction identityValue(value: Hex): Hex {\n if (\n typeof value !== \"string\" ||\n !/^0x[0-9a-fA-F]{64}$/.test(value) ||\n BigInt(value) <= 0n ||\n BigInt(value) >= FIELD_MODULUS\n )\n throw new RangeError(\"identity must be a nonzero canonical BN254 field element\");\n return value.toLowerCase() as Hex;\n}\nfunction payloadCopy(value?: Uint8Array): Uint8Array {\n if (value === undefined) return new Uint8Array();\n if (!(value instanceof Uint8Array)) throw new TypeError(\"payload must be Uint8Array\");\n return Uint8Array.from(value);\n}\nfunction fingerprint(delivery: Delivery): Hex {\n return keccak256(\n AbiCoder.defaultAbiCoder().encode([\"bytes\", \"bytes\"], [delivery.ciphertext, delivery.clue])\n ) as Hex;\n}\nfunction checkedContext(context: NoteOutputContext): NoteOutputContext {\n if (typeof context.chainId !== \"bigint\" || context.chainId <= 0n)\n throw new RangeError(\"chainId must be positive\");\n const protocolAddress = getAddress(context.protocolAddress) as Hex;\n const tokenAddress = getAddress(context.tokenAddress) as Hex;\n if (BigInt(protocolAddress) === 0n) throw new RangeError(\"protocol address must be nonzero\");\n return { chainId: context.chainId, protocolAddress, tokenAddress };\n}\nfunction encrypted(recipient: NoteOutputRecipient): boolean {\n return (\n recipient.type === \"invisi\" || (recipient.type === \"evm\" && recipient.envelope !== false)\n );\n}\nfunction rejectLegacy(value: object): void {\n for (const key of [\n \"expectedCommitment\",\n \"nonce\",\n \"envelope\",\n \"context\",\n \"to\",\n \"addressResolver\",\n \"addressLookup\",\n ])\n if (key in value) throw new TypeError(`${key} is not a NoteOutput create option`);\n}\nconst outputCreation = Symbol(\"NoteOutput.create\");\n\n/** Immutable output statement and optional recoverable opening. */\nexport class NoteOutput {\n readonly to: string;\n readonly ipp: string;\n readonly amount: bigint;\n readonly identity: Hex;\n readonly commitment: Hex;\n readonly deliveryFingerprint: Hex;\n /** Encrypted EVM delivery is resolved by preparation; the original offline intent stays pending. */\n readonly deliveryPending: boolean;\n declare readonly context: NoteOutputContext;\n declare readonly recipient: NoteOutputRecipient;\n declare readonly nonce: bigint | undefined;\n declare readonly payload: Uint8Array;\n declare readonly preparedOutput: PreparedOutput;\n private constructor(output: PreparedOutput, token: symbol, ipp: string) {\n if (token !== outputCreation)\n throw new TypeError(\"outputs must be created with NoteOutput.create\");\n const saved = structuredClone(output);\n this.ipp = ipp;\n this.to = saved.address;\n this.amount = saved.amount;\n this.identity = saved.identity;\n this.commitment = saved.commitment;\n this.deliveryFingerprint = fingerprint(saved.delivery);\n this.deliveryPending = saved.deliveryPending === true;\n Object.defineProperties(this, {\n context: { enumerable: true, get: () => structuredClone(saved.context) },\n recipient: { enumerable: true, get: () => structuredClone(saved.recipient) },\n nonce: { enumerable: true, get: () => saved.note?.nonce },\n payload: { enumerable: true, get: () => payloadCopy(saved.note?.payload) },\n preparedOutput: { enumerable: true, get: () => structuredClone(saved) },\n });\n Object.freeze(this);\n }\n /** Private offline delivery data; does not assert that the output has been mined. */\n exportPaymentNote(): string {\n return exportPaymentNote(this.preparedOutput);\n }\n static async create(\n input: PaymentRequest | string,\n execution: NoteOutputExecutionOptions = {}\n ): Promise<NoteOutput> {\n if (typeof input !== \"string\") rejectLegacy(input);\n const request =\n typeof input === \"string\" ? decodePaymentRequest(input) : structuredClone(input);\n rejectLegacy(request);\n const options = applyExecutionOptions(request, execution);\n if (\n typeof options.amount !== \"bigint\" ||\n options.amount <= 0n ||\n options.amount >= 1n << 128n\n )\n throw new RangeError(\"amount must be a positive uint128\");\n const context = checkedContext(options);\n const recipient = structuredClone(options.recipient);\n if (!recipient || ![\"evm\", \"invisi\", \"identity\"].includes(recipient.type))\n throw new TypeError(\"invalid recipient type\");\n if (\"expectedCommitment\" in recipient)\n throw new TypeError(\"expectedCommitment is not supported\");\n const envelope = encrypted(recipient);\n if (!envelope && options.payload !== undefined)\n throw new TypeError(\"payload requires an encrypted envelope\");\n let identity: Hex;\n let note: Note | undefined;\n let resolved: ReceivingAddress | undefined;\n let address: string;\n if (recipient.type === \"identity\") {\n if (\"nonce\" in recipient || \"envelope\" in recipient || \"addressLookup\" in recipient)\n throw new TypeError(\"identity recipient cannot specify nonce or envelope\");\n identity = identityValue(recipient.identity);\n address = identity;\n } else {\n if (\n recipient.type === \"evm\" &&\n recipient.envelope !== undefined &&\n typeof recipient.envelope !== \"boolean\"\n )\n throw new TypeError(\"evm envelope must be boolean\");\n if (recipient.type === \"invisi\" && \"envelope\" in recipient)\n throw new TypeError(\"invisi recipient is always encrypted\");\n let parsed: ReceivingAddress;\n try {\n parsed = ReceivingAddress.parse(recipient.address);\n } catch (cause) {\n throw new InvisiError(\"INVALID_RECIPIENT\", \"Invalid recipient address\", {\n address: recipient.address,\n field: \"to\",\n cause,\n });\n }\n if ((recipient.type === \"evm\") !== (parsed.kind === \"short\"))\n throw new TypeError(\"recipient address type mismatch\");\n resolved = parsed;\n if (recipient.type === \"evm\") {\n if (\n recipient.addressLookup !== undefined &&\n recipient.addressLookup !== \"chain\" &&\n recipient.addressLookup !== \"protocol-rpc\"\n )\n throw new TypeError(\"invalid recipient addressLookup\");\n recipient.addressLookup ??= \"protocol-rpc\";\n } else if (\"addressLookup\" in recipient)\n throw new TypeError(\"addressLookup only applies to EVM recipients\");\n const nonce = nonceValue(\n recipient.nonce === undefined ? generateNonce() : recipient.nonce\n );\n recipient.nonce = nonce;\n identity = await computeNoteIdentity(BigInt(resolved.ownerAddress), nonce);\n address = recipient.address;\n note = {\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n tokenAddress: BigInt(context.tokenAddress),\n ownerAddress: resolved.ownerAddress,\n amount: options.amount,\n nonce,\n payload: payloadCopy(options.payload),\n };\n }\n const commitment = await computeNoteCommitment(\n context.chainId,\n BigInt(context.protocolAddress),\n identity,\n BigInt(context.tokenAddress),\n options.amount\n );\n let delivery: Delivery = { ciphertext: \"0x\", clue: \"0x\" };\n if (envelope && recipient.type === \"invisi\") {\n const keys = resolved!.getReceivingKeys();\n delivery = {\n ciphertext: hexlify(\n await encryptPrivateTransferNote(keys.viewingPublicKey, note!, {\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n outputCommitment: commitment,\n })\n ) as Hex,\n clue: hexlify(createClue(keys.clueKey)) as Hex,\n };\n }\n const ipp = typeof input === \"string\" ? input : encodePaymentRequest(request);\n return new NoteOutput(\n {\n context,\n recipient,\n amount: options.amount,\n ...(note ? { note } : {}),\n identity,\n commitment,\n delivery,\n ...(envelope && recipient.type === \"evm\" ? { deliveryPending: true as const } : {}),\n address,\n change: false,\n },\n outputCreation,\n ipp\n );\n }\n assertCommitment(expectedHex: Hex): void {\n if (\n typeof expectedHex !== \"string\" ||\n expectedHex.toLowerCase() !== this.commitment.toLowerCase()\n )\n throw new Error(\"note output commitment mismatch\");\n }\n get note(): Note | undefined {\n return this.preparedOutput.note;\n }\n get delivery(): Delivery {\n return this.preparedOutput.delivery;\n }\n}\nexport async function materializeNoteOutput(\n payment: NoteOutput,\n context: NoteOutputContext,\n lookup?: (source: AddressLookup) => ReceivingKeyLookup\n): Promise<PreparedOutput> {\n if (\"expectedCommitment\" in payment) throw new TypeError(\"expectedCommitment is not supported\");\n const cached = (payment as Partial<NoteOutput>).preparedOutput;\n if (cached === undefined) throw new TypeError(\"outputs must be created with NoteOutput.create\");\n const output = structuredClone(cached);\n const expectedContext = checkedContext(context);\n const copied = payment as NoteOutput;\n for (const actual of [output.context, copied.context]) {\n if (\n !actual ||\n actual.chainId !== expectedContext.chainId ||\n BigInt(actual.protocolAddress) !== BigInt(expectedContext.protocolAddress) ||\n BigInt(actual.tokenAddress) !== BigInt(expectedContext.tokenAddress)\n )\n throw new Error(\"note output chain, protocol or token mismatch\");\n }\n if (\n output.amount !== payment.amount ||\n output.address !== payment.to ||\n output.identity !== copied.identity ||\n output.commitment !== copied.commitment ||\n JSON.stringify(output.recipient, (_, v) => (typeof v === \"bigint\" ? v.toString() : v)) !==\n JSON.stringify(copied.recipient, (_, v) => (typeof v === \"bigint\" ? v.toString() : v))\n )\n throw new Error(\"note output material does not match payment intent\");\n if (fingerprint(output.delivery) !== copied.deliveryFingerprint)\n throw new Error(\"note output delivery fingerprint mismatch\");\n const hasCiphertext = output.delivery.ciphertext !== \"0x\";\n const hasClue = output.delivery.clue !== \"0x\";\n const pending = output.deliveryPending === true;\n if (\n copied.deliveryPending !== pending ||\n (\"deliveryPending\" in output && output.deliveryPending !== true)\n )\n throw new Error(\"note output pending delivery mismatch\");\n if (\n hasCiphertext !== hasClue ||\n (pending\n ? hasCiphertext || output.recipient.type !== \"evm\" || !encrypted(output.recipient)\n : hasCiphertext !== encrypted(output.recipient))\n )\n throw new Error(\"note output delivery mode mismatch\");\n const recipient = output.recipient;\n if (\"expectedCommitment\" in recipient) throw new Error(\"expectedCommitment is not supported\");\n if (!encrypted(recipient) && payloadCopy(payment.payload).length !== 0)\n throw new Error(\"payload requires an encrypted envelope\");\n if (recipient.type === \"identity\") {\n if (\n !/^0x[0-9a-fA-F]{64}$/.test(output.identity) ||\n output.address !== output.identity ||\n output.note ||\n \"nonce\" in recipient ||\n \"envelope\" in recipient ||\n \"addressLookup\" in recipient ||\n recipient.identity.toLowerCase() !== output.identity.toLowerCase()\n )\n throw new Error(\"opaque identity output material mismatch\");\n identityValue(output.identity);\n } else {\n const note = output.note;\n const parsed = ReceivingAddress.parse(recipient.address);\n if (\n recipient.type === \"evm\" &&\n recipient.addressLookup !== undefined &&\n recipient.addressLookup !== \"chain\" &&\n recipient.addressLookup !== \"protocol-rpc\"\n )\n throw new Error(\"invalid recipient addressLookup\");\n if (recipient.type === \"invisi\" && \"addressLookup\" in recipient)\n throw new Error(\"addressLookup only applies to EVM recipients\");\n if (\n output.address !== recipient.address ||\n (recipient.type === \"evm\" &&\n recipient.envelope !== undefined &&\n typeof recipient.envelope !== \"boolean\") ||\n (recipient.type === \"invisi\" && \"envelope\" in recipient)\n )\n throw new Error(\"recipient material mismatch\");\n if (\n !note ||\n note.chainId !== context.chainId ||\n note.protocolAddress !== BigInt(context.protocolAddress) ||\n note.tokenAddress !== BigInt(context.tokenAddress) ||\n note.ownerAddress !== parsed.ownerAddress ||\n note.amount !== output.amount ||\n note.nonce !== recipient.nonce ||\n note.nonce !== payment.nonce ||\n hexlify(payloadCopy(note.payload)) !== hexlify(payloadCopy(payment.payload))\n )\n throw new Error(\"note output opening does not match payment intent\");\n if ((recipient.type === \"evm\") !== (parsed.kind === \"short\"))\n throw new Error(\"recipient type mismatch\");\n if (\n (await computeNoteIdentity(BigInt(note.ownerAddress), nonceValue(note.nonce))) !==\n output.identity\n )\n throw new Error(\"note output identity mismatch\");\n }\n if (\n typeof output.amount !== \"bigint\" ||\n output.amount <= 0n ||\n output.amount >= 1n << 128n ||\n (await computeNoteCommitment(\n context.chainId,\n BigInt(context.protocolAddress),\n output.identity,\n BigInt(context.tokenAddress),\n output.amount\n )) !== output.commitment\n )\n throw new Error(\"note output commitment mismatch\");\n assertRequestMatchesOutput(payment.ipp, output);\n if (pending) {\n if (recipient.type !== \"evm\") throw new Error(\"only EVM outputs may have pending delivery\");\n const resolved = await resolveRecipient(\n recipient.address,\n lookup?.(recipient.addressLookup ?? \"protocol-rpc\"),\n { field: \"to\" }\n );\n const keys = resolved.getReceivingKeys();\n output.delivery = {\n ciphertext: hexlify(\n await encryptPrivateTransferNote(keys.viewingPublicKey, output.note!, {\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n outputCommitment: output.commitment,\n })\n ) as Hex,\n clue: hexlify(createClue(keys.clueKey)) as Hex,\n };\n delete output.deliveryPending;\n }\n return output;\n}\n\n/** Retain a validated factory output's resolved delivery in a copyable operation intent. */\nexport function resolvedOutputSnapshot(payment: NoteOutput, output: PreparedOutput): NoteOutput {\n const copy = structuredClone(payment);\n Object.assign(copy, {\n preparedOutput: structuredClone(output),\n deliveryFingerprint: fingerprint(output.delivery),\n deliveryPending: false,\n });\n return copy;\n}\n","import { ReceivingAddress } from \"@invisi-labs/primitives\";\nimport { hexlify } from \"ethers\";\nimport type { PreparedOutput } from \"../transactions/operation-types\";\nimport { decodePaymentRequest } from \"./codec\";\n\n/** A copyable factory output must still satisfy its original public request. */\nexport function assertRequestMatchesOutput(ipp: string, output: PreparedOutput): void {\n const request = decodePaymentRequest(ipp);\n const expected = request.recipient;\n const actual = output.recipient;\n if (\n request.chainId !== output.context.chainId ||\n BigInt(request.protocolAddress) !== BigInt(output.context.protocolAddress) ||\n BigInt(request.tokenAddress) !== BigInt(output.context.tokenAddress) ||\n request.amount !== output.amount ||\n expected.type !== actual.type\n )\n throw new Error(\"IPR does not match output context or recipient\");\n if (expected.type === \"identity\") {\n if (actual.type !== \"identity\" || BigInt(expected.identity) !== BigInt(actual.identity))\n throw new Error(\"IPR identity mismatch\");\n return;\n }\n if (actual.type === \"identity\") throw new Error(\"IPR recipient type mismatch\");\n const parsed = ReceivingAddress.parse(expected.address);\n const resolved = ReceivingAddress.parse(actual.address);\n if (\n parsed.ownerAddress !== resolved.ownerAddress ||\n (expected.nonce !== undefined && expected.nonce !== output.note?.nonce) ||\n hexlify(request.payload ?? new Uint8Array()) !==\n hexlify(output.note?.payload ?? new Uint8Array())\n )\n throw new Error(\"IPR does not match output opening\");\n if (\n expected.type === \"evm\" &&\n actual.type === \"evm\" &&\n (expected.envelope !== false) !== (actual.envelope !== false)\n )\n throw new Error(\"IPR envelope mismatch\");\n if (expected.type === \"invisi\") {\n const a = parsed.getReceivingKeys(),\n b = resolved.getReceivingKeys();\n if (\n hexlify(a.viewingPublicKey) !== hexlify(b.viewingPublicKey) ||\n hexlify(a.clueKey) !== hexlify(b.clueKey)\n )\n throw new Error(\"IPR receiving keys mismatch\");\n }\n}\n","import type { NoteOutputExecutionOptions, PaymentRequest } from \"./types\";\nimport { fields, nonce } from \"./validation\";\n\n/** Apply payer-local decisions to a copy, without changing the encoded request. */\nexport function applyExecutionOptions(\n request: PaymentRequest,\n execution: NoteOutputExecutionOptions\n): PaymentRequest {\n fields(execution, [\"nonce\", \"addressLookup\"], \"execution options\");\n const copy = structuredClone(request);\n const recipient = copy.recipient;\n if (execution.nonce !== undefined) {\n if (recipient.type === \"identity\")\n throw new TypeError(\"identity recipient cannot specify nonce\");\n nonce(execution.nonce);\n if (recipient.nonce !== undefined && recipient.nonce !== execution.nonce)\n throw new Error(\"nonce conflicts with the fixed payment request\");\n recipient.nonce = execution.nonce;\n }\n if (execution.addressLookup !== undefined) {\n if (recipient.type !== \"evm\" || recipient.envelope === false)\n throw new TypeError(\"addressLookup requires an encrypted EVM recipient\");\n if (![\"chain\", \"protocol-rpc\"].includes(execution.addressLookup))\n throw new TypeError(\"Invalid addressLookup\");\n recipient.addressLookup = execution.addressLookup;\n }\n return copy;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  // src/integrations/ethers.ts
2
- import { ReceivingAddress } from "@invisi-labs/core/address";
2
+ import { ReceivingAddress } from "@invisi-labs/primitives/address";
3
3
  import {
4
4
  invisiAddressRegistryAbi,
5
5
  invisiFactoryAbi,
@@ -112,6 +112,29 @@ var EthersChainReader = class {
112
112
  await new Contract(instance, invisiProtocolAbi, this.client).getFunction("factory")()
113
113
  );
114
114
  }
115
+ async getCreditAllocation(context, owner, token, block) {
116
+ const result = await this.read(
117
+ context,
118
+ context.protocolAddress,
119
+ invisiProtocolAbi,
120
+ "creditAllocation",
121
+ [owner, token],
122
+ block
123
+ );
124
+ return { shard: BigInt(result[0]), slot: Number(result[1]) };
125
+ }
126
+ async getCreditRevocationBitmap(context, owner, token, shard, wordIndex, block) {
127
+ return BigInt(
128
+ await this.read(
129
+ context,
130
+ context.protocolAddress,
131
+ invisiProtocolAbi,
132
+ "creditRevocationBitmap",
133
+ [owner, token, shard, wordIndex],
134
+ block
135
+ )
136
+ );
137
+ }
115
138
  async getLatestBlockNumber() {
116
139
  return BigInt(await this.client.getBlockNumber());
117
140
  }
@@ -371,4 +394,4 @@ export {
371
394
  EthersFundingSigner,
372
395
  EthersFundingVerifier
373
396
  };
374
- //# sourceMappingURL=chunk-XHKQ2BO2.js.map
397
+ //# sourceMappingURL=chunk-4VI6LYGH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/integrations/ethers.ts"],"sourcesContent":["import { ReceivingAddress, type ReceivingKeyLookup } from \"@invisi-labs/primitives/address\";\nimport type {\n CanonicalBlock,\n CanonicalReceipt,\n ChainReader,\n DeploymentContext,\n FactoryReader,\n RegistryContext,\n} from \"@invisi-labs/protocol\";\nimport type { RegistryReader } from \"@invisi-labs/rpc\";\nimport type { Address, Hex } from \"@invisi-labs/protocol/contracts\";\nimport {\n invisiAddressRegistryAbi,\n invisiFactoryAbi,\n invisiProtocolAbi,\n} from \"@invisi-labs/protocol/contracts\";\nimport {\n Contract,\n getAddress as ethersAddress,\n getBytes,\n Interface,\n isError,\n keccak256,\n TypedDataEncoder,\n verifyTypedData,\n zeroPadValue,\n type Provider,\n type Signer,\n} from \"ethers\";\nimport type {\n FundingAuthorizationVerifier,\n FundingSigner,\n FundingTypedData,\n} from \"../transactions/operation-types\";\nconst getAddress = (value: string): Address => ethersAddress(value) as Address;\n\nconst erc1271Abi = [\n \"function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)\",\n];\nfunction fundingTypes(data: FundingTypedData) {\n const types = Object.fromEntries(\n Object.entries(data.types).map(([name, fields]) => [name, [...fields]])\n );\n check(\n TypedDataEncoder.from(types).primaryType === data.primaryType,\n \"funding typed-data primary type mismatch\"\n );\n return types;\n}\n\nfunction check(value: unknown, message: string): asserts value {\n if (!value) {\n throw new Error(message);\n }\n}\n\nasync function chain(client: Provider, expected: bigint): Promise<void> {\n check((await client.getNetwork()).chainId === expected, \"EVM client chain mismatch\");\n}\n\nfunction number(value: unknown): bigint {\n check(typeof value === \"bigint\" && value >= 0n, \"invalid chain integer\");\n return value;\n}\n\nfunction boolean(value: unknown): boolean {\n check(typeof value === \"boolean\", \"invalid chain boolean\");\n return value;\n}\n\nfunction word(value: unknown): Hex {\n check(typeof value === \"string\" && /^0x[0-9a-fA-F]{64}$/.test(value), \"invalid chain word\");\n return value.toLowerCase() as Hex;\n}\n\nfunction ownerWord(value: Hex): Hex {\n // Public owners use canonical EVM addresses; registry slots remain bytes32.\n const identity = ReceivingAddress.fromIdentity(value).ownerAddress;\n return zeroPadValue(identity, 32) as Hex;\n}\n\n/** Reads exact block numbers; higher layers additionally enforce post-read snapshot barriers. */\nexport class EthersChainReader implements ChainReader, RegistryReader, FactoryReader {\n constructor(readonly client: Provider) {}\n\n async getChainId() {\n return (await this.client.getNetwork()).chainId;\n }\n\n async isValidRegistrationSignature(\n owner: Address,\n digest: Hex,\n signature: Hex\n ): Promise<boolean> {\n try {\n const result = await this.client.call({\n to: getAddress(owner),\n data: new Interface(erc1271Abi).encodeFunctionData(\"isValidSignature\", [\n digest,\n signature,\n ]),\n });\n // SignatureChecker compares the complete first return word, including padding.\n return (\n result.length >= 66 &&\n result.slice(0, 66).toLowerCase() === \"0x1626ba7e\" + \"00\".repeat(28)\n );\n } catch (error) {\n if (isError(error, \"CALL_EXCEPTION\")) return false;\n throw error;\n }\n }\n\n async getProtocolAddressRegistry(address: Address): Promise<Address> {\n return getAddress(\n await new Contract(getAddress(address), invisiProtocolAbi, this.client).getFunction(\n \"addressRegistry\"\n )()\n );\n }\n\n async getProtocolVersion(address: Address): Promise<bigint> {\n return BigInt(\n await new Contract(getAddress(address), invisiProtocolAbi, this.client).getFunction(\n \"VERSION\"\n )()\n );\n }\n\n async getCode(address: Address): Promise<Hex> {\n return (await this.client.getCode(getAddress(address))) as Hex;\n }\n\n async getFactoryInstanceAddress(factory: Address, salt: Hex): Promise<Address> {\n return getAddress(\n await new Contract(factory, invisiFactoryAbi, this.client).getFunction(\n \"getInstanceAddress\"\n )(salt)\n );\n }\n async isFactoryInstance(factory: Address, instance: Address): Promise<boolean> {\n return boolean(\n await new Contract(factory, invisiFactoryAbi, this.client).getFunction(\"isInstance\")(\n instance\n )\n );\n }\n async getInstanceFactory(instance: Address): Promise<Address> {\n return getAddress(\n await new Contract(instance, invisiProtocolAbi, this.client).getFunction(\"factory\")()\n );\n }\n async getCreditAllocation(\n context: import(\"@invisi-labs/protocol\").DeploymentContext,\n owner: Address,\n token: Address,\n block: CanonicalBlock\n ): Promise<{ shard: bigint; slot: number }> {\n const result = (await this.read(\n context,\n context.protocolAddress,\n invisiProtocolAbi,\n \"creditAllocation\",\n [owner, token],\n block\n )) as readonly bigint[];\n return { shard: BigInt(result[0]!), slot: Number(result[1]!) };\n }\n async getCreditRevocationBitmap(\n context: import(\"@invisi-labs/protocol\").DeploymentContext,\n owner: Address,\n token: Address,\n shard: bigint,\n wordIndex: number,\n block: CanonicalBlock\n ): Promise<bigint> {\n return BigInt(\n (await this.read(\n context,\n context.protocolAddress,\n invisiProtocolAbi,\n \"creditRevocationBitmap\",\n [owner, token, shard, wordIndex],\n block\n )) as bigint\n );\n }\n async getLatestBlockNumber() {\n return BigInt(await this.client.getBlockNumber());\n }\n\n async getBlock(blockNumber: bigint): Promise<CanonicalBlock> {\n const block = await this.client.getBlock(blockNumber);\n check(\n block && BigInt(block.number) === blockNumber && block.hash && block.parentHash,\n \"invalid canonical block\"\n );\n return {\n number: BigInt(block.number),\n hash: word(block.hash),\n parentHash: word(block.parentHash),\n timestamp: number(BigInt(block.timestamp)),\n };\n }\n\n private async read(\n context: { chainId: bigint },\n address: Address,\n abi: ConstructorParameters<typeof Interface>[0],\n functionName: string,\n args: readonly unknown[],\n block?: CanonicalBlock\n ): Promise<unknown> {\n await chain(this.client, context.chainId);\n if (block) {\n check(\n (await this.getBlock(block.number)).hash === block.hash,\n \"canonical read block mismatch\"\n );\n }\n return new Contract(getAddress(address), abi, this.client).getFunction(functionName)(\n ...args,\n ...(block ? [{ blockTag: block.number }] : [])\n );\n }\n\n async getFundingNonce(context: DeploymentContext, payer: Address, block: CanonicalBlock) {\n return number(\n await this.read(\n context,\n context.protocolAddress,\n invisiProtocolAbi,\n \"nonces\",\n [getAddress(payer)],\n block\n )\n );\n }\n\n async getRegistryNonce(context: RegistryContext, ownerAddress: Hex, block: CanonicalBlock) {\n return number(\n await this.read(\n context,\n context.registryAddress,\n invisiAddressRegistryAbi,\n \"nonceOf\",\n [ownerWord(ownerAddress)],\n block\n )\n );\n }\n\n async isKnownRoot(\n context: DeploymentContext,\n treeId: bigint,\n root: Hex,\n block: CanonicalBlock\n ) {\n return boolean(\n await this.read(\n context,\n context.protocolAddress,\n invisiProtocolAbi,\n \"rootHistory\",\n [number(treeId), word(root)],\n block\n )\n );\n }\n\n async isSpent(context: DeploymentContext, nullifiers: readonly Hex[], block: CanonicalBlock) {\n const copied = nullifiers.map(word);\n const result: boolean[] = [];\n for (let offset = 0; offset < copied.length; offset += 32) {\n result.push(\n ...(await Promise.all(\n copied\n .slice(offset, offset + 32)\n .map((nf) =>\n this.read(\n context,\n context.protocolAddress,\n invisiProtocolAbi,\n \"isNullifierSpent\",\n [nf],\n block\n ).then(boolean)\n )\n ))\n );\n }\n return result;\n }\n\n async getTransaction(hash: Hex) {\n try {\n const tx = await this.client.getTransaction(word(hash));\n if (!tx?.to) {\n return null;\n }\n return {\n transactionHash: word(tx.hash),\n to: getAddress(tx.to),\n from: getAddress(tx.from),\n nonce: number(BigInt(tx.nonce)),\n data: tx.data as Hex,\n value: number(tx.value),\n };\n } catch (error) {\n if (error instanceof Error && error.name === \"TransactionNotFoundError\") {\n return null;\n }\n throw error;\n }\n }\n\n async getReceipt(hash: Hex): Promise<CanonicalReceipt | null> {\n try {\n const receipt = await this.client.getTransactionReceipt(word(hash));\n if (!receipt) return null;\n const block = await this.getBlock(BigInt(receipt.blockNumber));\n check(block.hash === receipt.blockHash, \"receipt block is no longer canonical\");\n return {\n block,\n transactionHash: word(receipt.hash),\n status: receipt.status === 1 ? \"success\" : \"reverted\",\n logs: receipt.logs.map((log) => {\n check(\n !log.removed && log.transactionHash === receipt.hash && log.index !== null,\n \"invalid receipt log\"\n );\n return {\n address: getAddress(log.address),\n data: log.data as Hex,\n topics: [...log.topics] as Hex[],\n transactionHash: word(log.transactionHash),\n logIndex: log.index,\n };\n }),\n };\n } catch (error) {\n if (error instanceof Error && error.name === \"TransactionReceiptNotFoundError\") {\n return null;\n }\n throw error;\n }\n }\n}\n\n/** Resolves only the explicitly selected registry. Validates canonical public key encodings. */\nexport class EthersAddressResolver {\n readonly #context: Readonly<RegistryContext>;\n\n constructor(\n readonly client: Provider,\n context: RegistryContext,\n readonly expectedRuntimeCodeHash?: Hex\n ) {\n this.#context = Object.freeze({\n ...context,\n registryAddress: getAddress(context.registryAddress),\n });\n check(BigInt(context.registryAddress) !== 0n, \"invalid registry address\");\n }\n\n readonly lookup: ReceivingKeyLookup = async (ownerAddress) => {\n await chain(this.client, this.#context.chainId);\n if (this.expectedRuntimeCodeHash) {\n const code = await this.client.getCode(this.#context.registryAddress);\n check(\n code !== \"0x\" && keccak256(code) === this.expectedRuntimeCodeHash,\n \"registry runtime profile mismatch\"\n );\n }\n const block = await this.client.getBlock(\"latest\");\n check(block && block.hash, \"invalid registry block\");\n const contract = new Contract(\n this.#context.registryAddress,\n invisiAddressRegistryAbi,\n this.client\n );\n const registered = await contract.getFunction(\"isRegistered\")(ownerWord(ownerAddress), {\n blockTag: block.number,\n });\n if (!registered) return null;\n const [keys] = await contract.getFunction(\"receivingKeysOf\")(ownerWord(ownerAddress), {\n blockTag: block.number,\n });\n check(\n (await this.client.getBlock(block.number))?.hash === block.hash,\n \"canonical registry read changed\"\n );\n return ReceivingAddress.from({\n ownerAddress,\n viewingPublicKey: getBytes(keys.viewingPublicKey),\n clueKey: getBytes(keys.clueKey),\n }).getReceivingKeys();\n };\n}\n\nexport class EthersFundingSigner implements FundingSigner {\n readonly address: Address;\n constructor(\n readonly signer: Signer,\n readonly chainId: bigint,\n address: Address\n ) {\n this.address = getAddress(address);\n }\n static async create(signer: Signer, chainId: bigint): Promise<EthersFundingSigner> {\n return new EthersFundingSigner(signer, chainId, getAddress(await signer.getAddress()));\n }\n async signTypedData(data: FundingTypedData): Promise<Hex> {\n const copied = structuredClone(data);\n check(\n BigInt(copied.domain.chainId as bigint) === this.chainId,\n \"funding typed-data chain mismatch\"\n );\n check(\n getAddress(await this.signer.getAddress()) === this.address,\n \"funding signer address mismatch\"\n );\n if (this.signer.provider) await chain(this.signer.provider, this.chainId);\n return (await this.signer.signTypedData(\n copied.domain,\n fundingTypes(copied),\n copied.message\n )) as Hex;\n }\n}\n\nexport class EthersFundingVerifier implements FundingAuthorizationVerifier {\n constructor(\n readonly client: Provider,\n readonly chainId: bigint\n ) {}\n async verifyTypedData(\n data: FundingTypedData & { address: Address; signature: Hex }\n ): Promise<boolean> {\n const copied = structuredClone(data);\n check(\n BigInt(copied.domain.chainId as bigint) === this.chainId,\n \"funding typed-data chain mismatch\"\n );\n await chain(this.client, this.chainId);\n const address = getAddress(copied.address);\n if ((await this.client.getCode(address)) === \"0x\") {\n try {\n return (\n getAddress(\n verifyTypedData(\n copied.domain,\n fundingTypes(copied),\n copied.message,\n copied.signature\n )\n ) === address\n );\n } catch {\n return false;\n }\n }\n try {\n return (\n (await new Contract(address, erc1271Abi, this.client).getFunction(\n \"isValidSignature\"\n )(\n TypedDataEncoder.hash(copied.domain, fundingTypes(copied), copied.message),\n copied.signature\n )) === \"0x1626ba7e\"\n );\n } catch (error) {\n if (isError(error, \"CALL_EXCEPTION\")) return false;\n throw error;\n }\n }\n}\n"],"mappings":";AAAA,SAAS,wBAAiD;AAW1D;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP;AAAA,EACI;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGG;AAMP,IAAM,aAAa,CAAC,UAA2B,cAAc,KAAK;AAElE,IAAM,aAAa;AAAA,EACf;AACJ;AACA,SAAS,aAAa,MAAwB;AAC1C,QAAM,QAAQ,OAAO;AAAA,IACjB,OAAO,QAAQ,KAAK,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AAAA,EAC1E;AACA;AAAA,IACI,iBAAiB,KAAK,KAAK,EAAE,gBAAgB,KAAK;AAAA,IAClD;AAAA,EACJ;AACA,SAAO;AACX;AAEA,SAAS,MAAM,OAAgB,SAAgC;AAC3D,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,OAAO;AAA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;AAC7C,YAAM;AAAA,IACV;AAAA,EACJ;AACJ;","names":[]}
@@ -0,0 +1,287 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkHCB7RQ3Scjs = require('./chunk-HCB7RQ3S.cjs');
4
+
5
+
6
+
7
+
8
+ var _chunkMA2QZEF5cjs = require('./chunk-MA2QZEF5.cjs');
9
+
10
+
11
+ var _chunk4SDP53YQcjs = require('./chunk-4SDP53YQ.cjs');
12
+
13
+ // src/broadcaster/intent.ts
14
+ var _protocol = require('@invisi-labs/protocol');
15
+ var _contracts = require('@invisi-labs/protocol/contracts');
16
+ var _ethers = require('ethers');
17
+ function exportBroadcasterIntent(plan) {
18
+ if (plan.statement && plan.statement.target !== "evm")
19
+ throw new Error("unsupported broadcaster operation");
20
+ if (plan.statement) _chunkHCB7RQ3Scjs.statement.call(void 0, plan);
21
+ const feeDefaults = (params) => ({
22
+ ...params,
23
+ feeRecipient: _nullishCoalesce(params.feeRecipient, () => ( "0x0000000000000000000000000000000000000000")),
24
+ feeAmount: _nullishCoalesce(params.feeAmount, () => ( 0n))
25
+ });
26
+ const funding = { ..._protocol.normalizeFunding.call(void 0, plan.funding), signature: "0x" };
27
+ let method;
28
+ let args;
29
+ if (plan.params) {
30
+ method = "transact";
31
+ args = [
32
+ "0x",
33
+ {
34
+ params: feeDefaults(plan.params),
35
+ deliveries: plan.outputs.map((o) => o.delivery),
36
+ funding
37
+ }
38
+ ];
39
+ } else if (plan.shieldParams) {
40
+ method = "shield";
41
+ args = [
42
+ feeDefaults(plan.shieldParams),
43
+ plan.shieldOutputs,
44
+ plan.outputs.map((o) => o.delivery),
45
+ funding
46
+ ];
47
+ } else if (_optionalChain([plan, 'access', _ => _.credit, 'optionalAccess', _2 => _2.creation])) {
48
+ method = "createCredit";
49
+ args = ["0x", plan.credit.creation, plan.credit.deliveries];
50
+ } else if (_optionalChain([plan, 'access', _3 => _3.credit, 'optionalAccess', _4 => _4.draw])) {
51
+ method = "creditDraw";
52
+ args = ["0x", plan.credit.draw, plan.credit.deliveries];
53
+ } else if (_optionalChain([plan, 'access', _5 => _5.credit, 'optionalAccess', _6 => _6.update])) {
54
+ method = "updateCredit";
55
+ args = ["0x", plan.credit.update, plan.credit.deliveries];
56
+ } else if (_optionalChain([plan, 'access', _7 => _7.credit, 'optionalAccess', _8 => _8.revocation])) {
57
+ const p = plan.credit.revocation;
58
+ method = "revokeCredit";
59
+ args = [
60
+ p.token,
61
+ p.owner,
62
+ p.shard,
63
+ p.slot,
64
+ p.deadline,
65
+ _nullishCoalesce(p.feeRecipient, () => ( "0x0000000000000000000000000000000000000000")),
66
+ _nullishCoalesce(p.feeAmount, () => ( 0n)),
67
+ "0x"
68
+ ];
69
+ } else throw new Error("unsupported broadcaster operation");
70
+ const abi = _contracts.invisiProtocolAbi.filter(
71
+ (item) => item.type === "function" && item.name === method && (method !== "transact" || _optionalChain([item, 'access', _9 => _9.inputs, 'access', _10 => _10[1], 'optionalAccess', _11 => _11.type]) === "tuple")
72
+ );
73
+ return {
74
+ sendable: false,
75
+ data: new (0, _ethers.Interface)(abi).encodeFunctionData(method, args)
76
+ };
77
+ }
78
+
79
+ // src/transactions/preparation/transaction-preparation.ts
80
+
81
+
82
+
83
+
84
+
85
+ var _prover = require('@invisi-labs/prover');
86
+
87
+ var TransactionPreparation = class {
88
+ constructor(context) {
89
+ this.context = context;
90
+ const complete = context.complete;
91
+ this.context = {
92
+ ...context,
93
+ complete: (plan) => {
94
+ const intent = this.#intent ? structuredClone(this.#intent) : void 0;
95
+ if (intent && (intent.kind === "transfer" || intent.kind === "shield")) {
96
+ const businessOutputs = plan.outputs.filter((output) => !output.change);
97
+ intent.options.outputs = intent.options.outputs.map(
98
+ (payment, index) => _chunk4SDP53YQcjs.resolvedOutputSnapshot.call(void 0, payment, businessOutputs[index])
99
+ );
100
+ }
101
+ return complete({ ...plan, ...intent ? { intent } : {} });
102
+ }
103
+ };
104
+ }
105
+ #intent;
106
+ runtime(tokenAddress) {
107
+ if (_ethers.getAddress.call(void 0, tokenAddress) !== _ethers.getAddress.call(void 0, this.context.options.protocol.context.tokenAddress))
108
+ throw new Error("preparation token mismatch");
109
+ return this.context;
110
+ }
111
+ get scope() {
112
+ return this.context.scope;
113
+ }
114
+ async prepareTransfer(options) {
115
+ this.#intent = { kind: "transfer", options: structuredClone(options) };
116
+ if (Object.hasOwn(options, "target") || Object.hasOwn(options, "execution")) {
117
+ throw new Error(
118
+ "prepareTransfer accepts no target or execution; choose execution in prove()"
119
+ );
120
+ }
121
+ const copied = structuredClone(options);
122
+ const runtime = this.runtime(copied.tokenAddress);
123
+ if (copied.commitments !== void 0 && copied.commitments.length === 0)
124
+ throw new Error("empty explicit input selection");
125
+ const preparation = new (0, _chunkMA2QZEF5cjs.Preparation)({
126
+ ...runtime,
127
+ ...copied.commitments !== void 0 ? { inputSelection: copied.commitments } : {}
128
+ });
129
+ const frame = await preparation.frame(copied.deadline);
130
+ if (copied.outputs.length > 190) throw new Error("transfer supports at most 190 outputs");
131
+ let withdrawalAddress = _protocol.ZERO_ADDRESS;
132
+ let withdrawalAmount = 0n;
133
+ if (copied.withdrawal !== void 0) {
134
+ withdrawalAddress = _ethers.getAddress.call(void 0, copied.withdrawal.to);
135
+ _chunkMA2QZEF5cjs.positiveAmount.call(void 0, copied.withdrawal.amount);
136
+ if (BigInt(withdrawalAddress) === 0n)
137
+ throw new Error("withdrawal destination must be nonzero");
138
+ withdrawalAmount = copied.withdrawal.amount;
139
+ }
140
+ if (copied.outputs.length === 0 && withdrawalAmount === 0n)
141
+ throw new Error("transfer requires a private output or public withdrawal");
142
+ const feeRecipient = copied.fee ? _ethers.getAddress.call(void 0, copied.fee.recipient) : _protocol.ZERO_ADDRESS;
143
+ const feeAmount = _nullishCoalesce(_optionalChain([copied, 'access', _12 => _12.fee, 'optionalAccess', _13 => _13.amount]), () => ( 0n));
144
+ if (copied.fee) {
145
+ _chunkMA2QZEF5cjs.positiveAmount.call(void 0, feeAmount);
146
+ if (BigInt(feeRecipient) === 0n) throw new Error("fee recipient must be nonzero");
147
+ }
148
+ const total = copied.outputs.reduce(
149
+ (sum, output, index) => sum + _chunkMA2QZEF5cjs.positiveOutputAmount.call(void 0, output, index),
150
+ withdrawalAmount + feeAmount
151
+ );
152
+ const funding = await preparation.funding(copied.funding, frame);
153
+ return this.funds(
154
+ copied.outputs,
155
+ total,
156
+ withdrawalAddress,
157
+ withdrawalAmount,
158
+ { recipient: feeRecipient, amount: feeAmount },
159
+ frame,
160
+ funding,
161
+ preparation
162
+ );
163
+ }
164
+ async funds(payments, total, withdrawalAddress, withdrawalAmount, fee, frame, funding, preparation) {
165
+ if (total >= 1n << 135n) {
166
+ throw new Error("transaction sum exceeds uint135");
167
+ }
168
+ const { context, block, deadline } = frame;
169
+ const selection = await preparation.selectFunds(
170
+ total - (_nullishCoalesce(funding.funding.amount, () => ( 0n))),
171
+ frame
172
+ );
173
+ const outputs = await Promise.all(
174
+ payments.map((payment, index) => preparation.output(payment, context, false, index))
175
+ );
176
+ const change = selection.amount + (_nullishCoalesce(funding.funding.amount, () => ( 0n))) - total;
177
+ if (change > 0n) {
178
+ outputs.push(await preparation.change(change, context));
179
+ }
180
+ const params = {
181
+ token: context.tokenAddress,
182
+ sources: selection.sources,
183
+ nullifiers: selection.nullifiers,
184
+ noteCommitments: outputs.map((output) => output.commitment),
185
+ withdrawalAddress,
186
+ withdrawalAmount,
187
+ deadline,
188
+ feeRecipient: fee.recipient,
189
+ feeAmount: fee.amount
190
+ };
191
+ const deliveries = outputs.map((output) => output.delivery);
192
+ const normalized = _protocol.normalizeTransactRequest.call(void 0, context, params, deliveries, funding.funding);
193
+ const statement2 = _prover.WitnessBuilder.statement(
194
+ `transact_user_slots${normalized.capacity}`,
195
+ _protocol.transactUserPublicInputs.call(void 0, context, params, deliveries, funding.funding),
196
+ "evm"
197
+ );
198
+ await preparation.assertBlock(frame);
199
+ return preparation.runtime.complete({
200
+ version: 1,
201
+ id: crypto.randomUUID(),
202
+ kind: "transfer",
203
+ context,
204
+ scope: this.scope,
205
+ preparedAt: block,
206
+ deadline,
207
+ outputs,
208
+ inputs: selection.inputs,
209
+ ...funding,
210
+ params,
211
+ capacity: normalized.capacity,
212
+ statement: statement2
213
+ });
214
+ }
215
+ async prepareShield(options) {
216
+ this.#intent = { kind: "shield", options: structuredClone(options) };
217
+ const copied = structuredClone(options);
218
+ const preparation = new (0, _chunkMA2QZEF5cjs.Preparation)(this.runtime(copied.tokenAddress));
219
+ const frame = await preparation.frame(copied.deadline);
220
+ const funding = await preparation.funding(copied.funding, frame);
221
+ if (copied.outputs.length < 1 || copied.outputs.length > 10) {
222
+ throw new Error("shield requires 1..10 outputs");
223
+ }
224
+ const outputs = await Promise.all(
225
+ copied.outputs.map(
226
+ (output, index) => preparation.output(output, frame.context, false, index)
227
+ )
228
+ );
229
+ if (outputs.reduce((sum, output) => sum + output.amount, 0n) !== (_nullishCoalesce(funding.funding.amount, () => ( 0n))) - (_nullishCoalesce(_optionalChain([copied, 'access', _14 => _14.fee, 'optionalAccess', _15 => _15.amount]), () => ( 0n)))) {
230
+ throw new Error("shield funding must equal output total");
231
+ }
232
+ await preparation.assertBlock(frame);
233
+ return preparation.runtime.complete({
234
+ version: 1,
235
+ id: crypto.randomUUID(),
236
+ kind: "shield",
237
+ context: frame.context,
238
+ scope: this.scope,
239
+ preparedAt: frame.block,
240
+ deadline: frame.deadline,
241
+ outputs,
242
+ inputs: [],
243
+ ...funding,
244
+ shieldParams: {
245
+ token: frame.context.tokenAddress,
246
+ feeRecipient: _nullishCoalesce(_optionalChain([copied, 'access', _16 => _16.fee, 'optionalAccess', _17 => _17.recipient]), () => ( _protocol.ZERO_ADDRESS)),
247
+ feeAmount: _nullishCoalesce(_optionalChain([copied, 'access', _18 => _18.fee, 'optionalAccess', _19 => _19.amount]), () => ( 0n)),
248
+ noteCommitments: outputs.map((output) => output.commitment),
249
+ deadline: frame.deadline
250
+ },
251
+ shieldOutputs: outputs.map((output) => ({
252
+ identity: output.identity,
253
+ amount: output.amount
254
+ }))
255
+ });
256
+ }
257
+ async prepareCreateCredit(options) {
258
+ const copied = structuredClone(options);
259
+ this.#intent = { kind: "create-credit", options: structuredClone(copied) };
260
+ const { CreditPreparation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./preparation-QD3ZSYV5.cjs")));
261
+ return new CreditPreparation(this.runtime(copied.tokenAddress)).create(copied);
262
+ }
263
+ async prepareDrawCredit(options) {
264
+ const copied = structuredClone(options);
265
+ this.#intent = { kind: "draw-credit", options: structuredClone(copied) };
266
+ const { CreditPreparation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./preparation-QD3ZSYV5.cjs")));
267
+ return new CreditPreparation(this.runtime(copied.tokenAddress)).draw(copied);
268
+ }
269
+ async prepareUpdateCredit(options) {
270
+ const copied = structuredClone(options);
271
+ this.#intent = { kind: "update-credit", options: structuredClone(copied) };
272
+ const { CreditPreparation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./preparation-QD3ZSYV5.cjs")));
273
+ return new CreditPreparation(this.runtime(copied.tokenAddress)).update(copied);
274
+ }
275
+ async prepareRevokeCredit(options) {
276
+ const copied = structuredClone(options);
277
+ this.#intent = { kind: "revoke-credit", options: structuredClone(copied) };
278
+ const { CreditPreparation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./preparation-QD3ZSYV5.cjs")));
279
+ return new CreditPreparation(this.runtime(copied.tokenAddress)).revoke(copied);
280
+ }
281
+ };
282
+
283
+
284
+
285
+
286
+ exports.exportBroadcasterIntent = exportBroadcasterIntent; exports.TransactionPreparation = TransactionPreparation;
287
+ //# sourceMappingURL=chunk-BBSRP4MH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/wx/Workspace/invisi-lab/invisi-sdk-ts/packages/sdk/dist/chunk-BBSRP4MH.cjs","../src/broadcaster/intent.ts","../src/transactions/preparation/transaction-preparation.ts"],"names":["statement"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACZA,iDAAiC;AAEjC,4DAAkC;AAClC,gCAA0B;AAKnB,SAAS,uBAAA,CAAwB,IAAA,EAAqB;AACzD,EAAA,GAAA,CAAI,IAAA,CAAK,UAAA,GAAa,IAAA,CAAK,SAAA,CAAU,OAAA,IAAW,KAAA;AAC5C,IAAA,MAAM,IAAI,KAAA,CAAM,mCAAmC,CAAA;AACvD,EAAA,GAAA,CAAI,IAAA,CAAK,SAAA,EAAW,yCAAA,IAAc,CAAA;AAClC,EAAA,MAAM,YAAA,EAAc,CAA0D,MAAA,EAAA,GAAA,CAAe;AAAA,IACzF,GAAG,MAAA;AAAA,IACH,YAAA,mBAAc,MAAA,CAAO,YAAA,UAAgB,8CAAA;AAAA,IACrC,SAAA,mBAAW,MAAA,CAAO,SAAA,UAAa;AAAA,EACnC,CAAA,CAAA;AACA,EAAA,MAAM,QAAA,EAAU,EAAE,GAAG,wCAAA,IAAiB,CAAK,OAAO,CAAA,EAAG,SAAA,EAAW,KAAK,CAAA;AACrE,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI,IAAA;AACJ,EAAA,GAAA,CAAI,IAAA,CAAK,MAA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A;AACW,QAAA;AACkB,QAAA;AACN,QAAA;AACH,QAAA;AACd,QAAA;AACpB,MAAA;AACwC,MAAA;AACnB,QAAA;AACF,QAAA;AACjB,MAAA;AACL,IAAA;AACL,EAAA;AAE6E,EAAA;AACnC,IAAA;AACE,IAAA;AACG,IAAA;AACD,IAAA;AAC9C,EAAA;AAEyE,EAAA;AAC/B,IAAA;AACA,IAAA;AACK,IAAA;AACD,IAAA;AAC9C,EAAA;AAE6E,EAAA;AACnC,IAAA;AACE,IAAA;AACG,IAAA;AACD,IAAA;AAC9C,EAAA;AAE6E,EAAA;AACnC,IAAA;AACE,IAAA;AACG,IAAA;AACD,IAAA;AAC9C,EAAA;AACJ;AFwCgD;AACA;AACA;AACA;AACA","file":"/Users/wx/Workspace/invisi-lab/invisi-sdk-ts/packages/sdk/dist/chunk-BBSRP4MH.cjs","sourcesContent":[null,"import { normalizeFunding } from \"@invisi-labs/protocol\";\nimport type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport { invisiProtocolAbi } from \"@invisi-labs/protocol/contracts\";\nimport { Interface } from \"ethers\";\nimport type { OperationPlan } from \"../transactions/operation-types\";\nimport { statement } from \"../transactions/signing/statement\";\n\n/** Quote-only export; callers still need the operation-specific proof or owner authorization. */\nexport function exportBroadcasterIntent(plan: OperationPlan) {\n if (plan.statement && plan.statement.target !== \"evm\")\n throw new Error(\"unsupported broadcaster operation\");\n if (plan.statement) statement(plan);\n const feeDefaults = <T extends { feeRecipient?: string; feeAmount?: bigint }>(params: T) => ({\n ...params,\n feeRecipient: params.feeRecipient ?? \"0x0000000000000000000000000000000000000000\",\n feeAmount: params.feeAmount ?? 0n,\n });\n const funding = { ...normalizeFunding(plan.funding), signature: \"0x\" };\n let method: string;\n let args: unknown[];\n if (plan.params) {\n method = \"transact\";\n args = [\n \"0x\",\n {\n params: feeDefaults(plan.params),\n deliveries: plan.outputs.map((o) => o.delivery),\n funding,\n },\n ];\n } else if (plan.shieldParams) {\n method = \"shield\";\n args = [\n feeDefaults(plan.shieldParams),\n plan.shieldOutputs,\n plan.outputs.map((o) => o.delivery),\n funding,\n ];\n } else if (plan.credit?.creation) {\n method = \"createCredit\";\n args = [\"0x\", plan.credit.creation, plan.credit.deliveries];\n } else if (plan.credit?.draw) {\n method = \"creditDraw\";\n args = [\"0x\", plan.credit.draw, plan.credit.deliveries];\n } else if (plan.credit?.update) {\n method = \"updateCredit\";\n args = [\"0x\", plan.credit.update, plan.credit.deliveries];\n } else if (plan.credit?.revocation) {\n const p = plan.credit.revocation;\n method = \"revokeCredit\";\n args = [\n p.token,\n p.owner,\n p.shard,\n p.slot,\n p.deadline,\n p.feeRecipient ?? \"0x0000000000000000000000000000000000000000\",\n p.feeAmount ?? 0n,\n \"0x\",\n ];\n } else throw new Error(\"unsupported broadcaster operation\");\n const abi = invisiProtocolAbi.filter(\n (item) =>\n item.type === \"function\" &&\n item.name === method &&\n (method !== \"transact\" || item.inputs[1]?.type === \"tuple\")\n );\n return {\n sendable: false as const,\n data: new Interface(abi).encodeFunctionData(method, args) as Hex,\n };\n}\n","import {\n normalizeTransactRequest,\n transactUserPublicInputs,\n ZERO_ADDRESS,\n} from \"@invisi-labs/protocol\";\nimport { WitnessBuilder } from \"@invisi-labs/prover\";\nimport type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport { getAddress } from \"ethers\";\nimport { NoteOutput, resolvedOutputSnapshot } from \"../../notes/NoteOutput\";\nimport type {\n RevokeCreditPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n OperationPlan,\n PreparationRuntime,\n ShieldPreparation,\n UpdateCreditPreparation,\n TransferPreparation,\n} from \"../operation-types\";\nimport {\n positiveAmount,\n positiveOutputAmount,\n Preparation,\n type PreparationFrame,\n} from \"./prepare-common\";\n\n/** Shared preparation engine for managed sessions and explicitly supplied inputs. */\nexport class TransactionPreparation<Result> {\n #intent: import(\"../../broadcaster/broadcaster-preparation\").PreparationIntent | undefined;\n constructor(readonly context: PreparationRuntime<Result>) {\n const complete = context.complete;\n this.context = {\n ...context,\n complete: (plan) => {\n const intent = this.#intent ? structuredClone(this.#intent) : undefined;\n if (intent && (intent.kind === \"transfer\" || intent.kind === \"shield\")) {\n const businessOutputs = plan.outputs.filter((output) => !output.change);\n intent.options.outputs = intent.options.outputs.map((payment, index) =>\n resolvedOutputSnapshot(payment, businessOutputs[index]!)\n );\n }\n return complete({ ...plan, ...(intent ? { intent } : {}) });\n },\n };\n }\n private runtime(tokenAddress: Hex): PreparationRuntime<Result> {\n if (\n getAddress(tokenAddress) !==\n getAddress(this.context.options.protocol.context.tokenAddress)\n )\n throw new Error(\"preparation token mismatch\");\n return this.context;\n }\n private get scope() {\n return this.context.scope;\n }\n async prepareTransfer(options: TransferPreparation): Promise<Result> {\n this.#intent = { kind: \"transfer\", options: structuredClone(options) };\n if (Object.hasOwn(options, \"target\") || Object.hasOwn(options, \"execution\")) {\n throw new Error(\n \"prepareTransfer accepts no target or execution; choose execution in prove()\"\n );\n }\n const copied = structuredClone(options);\n const runtime = this.runtime(copied.tokenAddress);\n if (copied.commitments !== undefined && copied.commitments.length === 0)\n throw new Error(\"empty explicit input selection\");\n const preparation = new Preparation({\n ...runtime,\n ...(copied.commitments !== undefined ? { inputSelection: copied.commitments } : {}),\n });\n const frame = await preparation.frame(copied.deadline);\n if (copied.outputs.length > 190) throw new Error(\"transfer supports at most 190 outputs\");\n let withdrawalAddress: Hex = ZERO_ADDRESS;\n let withdrawalAmount = 0n;\n if (copied.withdrawal !== undefined) {\n withdrawalAddress = getAddress(copied.withdrawal.to) as Hex;\n positiveAmount(copied.withdrawal.amount);\n if (BigInt(withdrawalAddress) === 0n)\n throw new Error(\"withdrawal destination must be nonzero\");\n withdrawalAmount = copied.withdrawal.amount;\n }\n if (copied.outputs.length === 0 && withdrawalAmount === 0n)\n throw new Error(\"transfer requires a private output or public withdrawal\");\n const feeRecipient = copied.fee ? (getAddress(copied.fee.recipient) as Hex) : ZERO_ADDRESS;\n const feeAmount = copied.fee?.amount ?? 0n;\n if (copied.fee) {\n positiveAmount(feeAmount);\n if (BigInt(feeRecipient) === 0n) throw new Error(\"fee recipient must be nonzero\");\n }\n const total = copied.outputs.reduce(\n (sum, output, index) => sum + positiveOutputAmount(output, index),\n withdrawalAmount + feeAmount\n );\n const funding = await preparation.funding(copied.funding, frame);\n return this.funds(\n copied.outputs,\n total,\n withdrawalAddress,\n withdrawalAmount,\n { recipient: feeRecipient, amount: feeAmount },\n frame,\n funding,\n preparation\n );\n }\n\n private async funds(\n payments: readonly NoteOutput[],\n total: bigint,\n withdrawalAddress: `0x${string}`,\n withdrawalAmount: bigint,\n fee: { recipient: Hex; amount: bigint },\n frame: PreparationFrame,\n funding: Pick<OperationPlan, \"funding\" | \"fundingMode\">,\n preparation: Preparation<Result>\n ): Promise<Result> {\n if (total >= 1n << 135n) {\n throw new Error(\"transaction sum exceeds uint135\");\n }\n const { context, block, deadline } = frame;\n const selection = await preparation.selectFunds(\n total - (funding.funding.amount ?? 0n),\n frame\n );\n const outputs = await Promise.all(\n payments.map((payment, index) => preparation.output(payment, context, false, index))\n );\n const change = selection.amount + (funding.funding.amount ?? 0n) - total;\n if (change > 0n) {\n outputs.push(await preparation.change(change, context));\n }\n const params = {\n token: context.tokenAddress,\n sources: selection.sources,\n nullifiers: selection.nullifiers,\n noteCommitments: outputs.map((output) => output.commitment),\n withdrawalAddress,\n withdrawalAmount,\n deadline,\n feeRecipient: fee.recipient,\n feeAmount: fee.amount,\n };\n const deliveries = outputs.map((output) => output.delivery);\n const normalized = normalizeTransactRequest(context, params, deliveries, funding.funding);\n const statement = WitnessBuilder.statement(\n `transact_user_slots${normalized.capacity}`,\n transactUserPublicInputs(context, params, deliveries, funding.funding),\n \"evm\"\n );\n await preparation.assertBlock(frame);\n return preparation.runtime.complete({\n version: 1,\n id: crypto.randomUUID(),\n kind: \"transfer\",\n context,\n scope: this.scope,\n preparedAt: block,\n deadline,\n outputs,\n inputs: selection.inputs,\n ...funding,\n params,\n capacity: normalized.capacity,\n statement,\n });\n }\n\n async prepareShield(options: ShieldPreparation): Promise<Result> {\n this.#intent = { kind: \"shield\", options: structuredClone(options) };\n const copied = structuredClone(options);\n const preparation = new Preparation(this.runtime(copied.tokenAddress));\n const frame = await preparation.frame(copied.deadline);\n const funding = await preparation.funding(copied.funding, frame);\n if (copied.outputs.length < 1 || copied.outputs.length > 10) {\n throw new Error(\"shield requires 1..10 outputs\");\n }\n const outputs = await Promise.all(\n copied.outputs.map((output, index) =>\n preparation.output(output, frame.context, false, index)\n )\n );\n if (\n outputs.reduce((sum, output) => sum + output.amount, 0n) !==\n (funding.funding.amount ?? 0n) - (copied.fee?.amount ?? 0n)\n ) {\n throw new Error(\"shield funding must equal output total\");\n }\n await preparation.assertBlock(frame);\n return preparation.runtime.complete({\n version: 1,\n id: crypto.randomUUID(),\n kind: \"shield\",\n context: frame.context,\n scope: this.scope,\n preparedAt: frame.block,\n deadline: frame.deadline,\n outputs,\n inputs: [],\n ...funding,\n shieldParams: {\n token: frame.context.tokenAddress,\n feeRecipient: copied.fee?.recipient ?? ZERO_ADDRESS,\n feeAmount: copied.fee?.amount ?? 0n,\n noteCommitments: outputs.map((output) => output.commitment),\n deadline: frame.deadline,\n },\n shieldOutputs: outputs.map((output) => ({\n identity: output.identity,\n amount: output.amount,\n })),\n });\n }\n\n async prepareCreateCredit(options: CreateCreditPreparation): Promise<Result> {\n const copied = structuredClone(options);\n this.#intent = { kind: \"create-credit\", options: structuredClone(copied) };\n const { CreditPreparation } = await import(\"../../credit/preparation\");\n return new CreditPreparation(this.runtime(copied.tokenAddress)).create(copied);\n }\n\n async prepareDrawCredit(options: DrawCreditPreparation): Promise<Result> {\n const copied = structuredClone(options);\n this.#intent = { kind: \"draw-credit\", options: structuredClone(copied) };\n const { CreditPreparation } = await import(\"../../credit/preparation\");\n return new CreditPreparation(this.runtime(copied.tokenAddress)).draw(copied);\n }\n\n async prepareUpdateCredit(options: UpdateCreditPreparation): Promise<Result> {\n const copied = structuredClone(options);\n this.#intent = { kind: \"update-credit\", options: structuredClone(copied) };\n const { CreditPreparation } = await import(\"../../credit/preparation\");\n return new CreditPreparation(this.runtime(copied.tokenAddress)).update(copied);\n }\n\n async prepareRevokeCredit(options: RevokeCreditPreparation): Promise<Result> {\n const copied = structuredClone(options);\n this.#intent = { kind: \"revoke-credit\", options: structuredClone(copied) };\n const { CreditPreparation } = await import(\"../../credit/preparation\");\n return new CreditPreparation(this.runtime(copied.tokenAddress)).revoke(copied);\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import {
2
+ exportPaymentNote
3
+ } from "./chunk-GUD3LAUO.js";
4
+
5
+ // src/notes/TransactionOutput.ts
6
+ var TransactionOutput = class {
7
+ #output;
8
+ constructor(output) {
9
+ this.#output = structuredClone(output);
10
+ Object.freeze(this);
11
+ }
12
+ get context() {
13
+ return structuredClone(this.#output.context);
14
+ }
15
+ get recipient() {
16
+ return structuredClone(this.#output.recipient);
17
+ }
18
+ get amount() {
19
+ return this.#output.amount;
20
+ }
21
+ get commitment() {
22
+ return this.#output.commitment;
23
+ }
24
+ get identity() {
25
+ return this.#output.identity;
26
+ }
27
+ get nonce() {
28
+ return this.#output.note?.nonce;
29
+ }
30
+ get change() {
31
+ return this.#output.change;
32
+ }
33
+ exportPaymentNote() {
34
+ return exportPaymentNote(this.#output);
35
+ }
36
+ };
37
+
38
+ export {
39
+ TransactionOutput
40
+ };
41
+ //# sourceMappingURL=chunk-DGMVGFKM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/notes/TransactionOutput.ts"],"sourcesContent":["import type { PreparedOutput } from \"../transactions/operation-types\";\nimport { exportPaymentNote } from \"../payment-note/export\";\n\n/** Detached final output snapshot, including any generated change. Contains private Note data. */\nexport class TransactionOutput {\n readonly #output: PreparedOutput;\n constructor(output: PreparedOutput) {\n this.#output = structuredClone(output);\n Object.freeze(this);\n }\n get context() {\n return structuredClone(this.#output.context);\n }\n get recipient() {\n return structuredClone(this.#output.recipient);\n }\n get amount() {\n return this.#output.amount;\n }\n get commitment() {\n return this.#output.commitment;\n }\n get identity() {\n return this.#output.identity;\n }\n get nonce() {\n return this.#output.note?.nonce;\n }\n get change() {\n return this.#output.change;\n }\n exportPaymentNote(): string {\n return exportPaymentNote(this.#output);\n }\n}\n"],"mappings":";;;;;AAIO,IAAM,oBAAN,MAAwB;AAAA,EAClB;AAAA,EACT,YAAY,QAAwB;AAChC,SAAK,UAAU,gBAAgB,MAAM;AACrC,WAAO,OAAO,IAAI;AAAA,EACtB;AAAA,EACA,IAAI,UAAU;AACV,WAAO,gBAAgB,KAAK,QAAQ,OAAO;AAAA,EAC/C;AAAA,EACA,IAAI,YAAY;AACZ,WAAO,gBAAgB,KAAK,QAAQ,SAAS;AAAA,EACjD;AAAA,EACA,IAAI,SAAS;AACT,WAAO,KAAK,QAAQ;AAAA,EACxB;AAAA,EACA,IAAI,aAAa;AACb,WAAO,KAAK,QAAQ;AAAA,EACxB;AAAA,EACA,IAAI,WAAW;AACX,WAAO,KAAK,QAAQ;AAAA,EACxB;AAAA,EACA,IAAI,QAAQ;AACR,WAAO,KAAK,QAAQ,MAAM;AAAA,EAC9B;AAAA,EACA,IAAI,SAAS;AACT,WAAO,KAAK,QAAQ;AAAA,EACxB;AAAA,EACA,oBAA4B;AACxB,WAAO,kBAAkB,KAAK,OAAO;AAAA,EACzC;AACJ;","names":[]}