@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
package/dist/index.cjs CHANGED
@@ -5,8 +5,12 @@
5
5
 
6
6
 
7
7
 
8
+ var _chunkDHQEB6JRcjs = require('./chunk-DHQEB6JR.cjs');
9
+ require('./chunk-BBSRP4MH.cjs');
10
+ require('./chunk-HCB7RQ3S.cjs');
8
11
 
9
12
 
13
+ var _chunkOCZLJKIAcjs = require('./chunk-OCZLJKIA.cjs');
10
14
 
11
15
 
12
16
 
@@ -15,22 +19,22 @@
15
19
 
16
20
 
17
21
 
18
- var _chunkRHNIHI4Pcjs = require('./chunk-RHNIHI4P.cjs');
19
22
 
23
+ var _chunk3KTQQZOWcjs = require('./chunk-3KTQQZOW.cjs');
24
+ require('./chunk-MA2QZEF5.cjs');
20
25
 
21
26
 
22
27
 
23
28
 
24
29
 
25
30
 
26
- var _chunkJ2JH6HIGcjs = require('./chunk-J2JH6HIG.cjs');
27
31
 
32
+ var _chunk4SDP53YQcjs = require('./chunk-4SDP53YQ.cjs');
28
33
 
29
- var _chunk7F7ZZW3Lcjs = require('./chunk-7F7ZZW3L.cjs');
30
-
31
- // src/index.ts
32
34
 
35
+ var _chunkLOR6PYH5cjs = require('./chunk-LOR6PYH5.cjs');
33
36
 
37
+ // src/index.ts
34
38
 
35
39
 
36
40
 
@@ -46,8 +50,8 @@ var _chunk7F7ZZW3Lcjs = require('./chunk-7F7ZZW3L.cjs');
46
50
 
47
51
 
48
52
 
49
- var _core = require('@invisi-labs/core');
50
- var _protocol = require('@invisi-labs/protocol');
53
+ var _primitives = require('@invisi-labs/primitives');
54
+ var _rpc = require('@invisi-labs/rpc');
51
55
 
52
56
  // src/disclosure/DisclosureVerifier.ts
53
57
  function check(value, message) {
@@ -82,7 +86,7 @@ var DisclosureVerifier = class {
82
86
  "invalid disclosure confirmations"
83
87
  );
84
88
  this.#protocol = options.protocol;
85
- this.#reader = "provider" in options ? new (0, _chunk7F7ZZW3Lcjs.EthersChainReader)(options.provider) : options.reader;
89
+ this.#reader = "provider" in options ? new (0, _chunkLOR6PYH5cjs.EthersChainReader)(options.provider) : options.reader;
86
90
  this.#confirmations = BigInt(confirmations);
87
91
  Object.freeze(this);
88
92
  }
@@ -121,8 +125,8 @@ var DisclosureVerifier = class {
121
125
  "invalid disclosure receipt block"
122
126
  );
123
127
  const { context } = this.#protocol;
124
- const logs = _chunkRHNIHI4Pcjs.readProtocolLogs.call(void 0, receipt, context.protocolAddress);
125
- const candidates = _chunkRHNIHI4Pcjs.extractDeliveryCandidates.call(void 0, logs, context, receipt.block.number).filter(
128
+ const logs = _chunkDHQEB6JRcjs.readProtocolLogs.call(void 0, receipt, context.protocolAddress);
129
+ const candidates = _chunkDHQEB6JRcjs.extractDeliveryCandidates.call(void 0, logs, context, receipt.block.number).filter(
126
130
  (candidate2) => candidate2.treeId === selected.treeId && candidate2.leafIndex === selected.leafIndex && candidate2.role === selected.role && candidate2.tokenAddress.toLowerCase() === context.tokenAddress.toLowerCase()
127
131
  );
128
132
  check(
@@ -180,9 +184,9 @@ function protocolConnection(protocol) {
180
184
 
181
185
  var _ethers = require('ethers');
182
186
  var sources = /* @__PURE__ */ new WeakMap();
183
- var Protocol = class _Protocol extends _protocol.Protocol {
187
+ var Protocol = class _Protocol extends _rpc.Protocol {
184
188
  static async fromRpc(rpc, provider, options = {}) {
185
- const verified = await _protocol.Protocol.fromRpc(rpc, provider, options);
189
+ const verified = await _rpc.Protocol.fromRpc(rpc, provider, options);
186
190
  const protocol = new _Protocol({ deployment: verified.deployment });
187
191
  if (rpc.getBroadcasters)
188
192
  sources.set(protocol, rpc);
@@ -194,9 +198,11 @@ var Protocol = class _Protocol extends _protocol.Protocol {
194
198
  );
195
199
  return protocol;
196
200
  }
197
- /** Returns enabled services that answer a token fee probe; final quotes are checked by prepared. */
201
+ /** Discover token support without disclosing a transaction or requesting a price. */
198
202
  async getBroadcasters(options) {
203
+ _optionalChain([options, 'access', _ => _.signal, 'optionalAccess', _2 => _2.throwIfAborted, 'call', _3 => _3()]);
199
204
  const token = _ethers.getAddress.call(void 0, options.tokenAddress);
205
+ if (BigInt(token) === 0n) throw Error("Invalid Broadcaster token address");
200
206
  if (!this.deployment.broadcasterRegistry)
201
207
  throw new Error("broadcaster registry is not configured");
202
208
  const rpc = sources.get(this);
@@ -206,9 +212,11 @@ var Protocol = class _Protocol extends _protocol.Protocol {
206
212
  let block;
207
213
  const seen = /* @__PURE__ */ new Set();
208
214
  do {
215
+ _optionalChain([options, 'access', _4 => _4.signal, 'optionalAccess', _5 => _5.throwIfAborted, 'call', _6 => _6()]);
209
216
  const page = await rpc.getBroadcasters({
210
217
  enabled: true,
211
218
  limit: 100,
219
+ ...options.signal ? { signal: options.signal } : {},
212
220
  ...after ? { after } : {},
213
221
  ...block ? { block } : {}
214
222
  });
@@ -217,14 +225,28 @@ var Protocol = class _Protocol extends _protocol.Protocol {
217
225
  page.broadcasters.map(async (entry) => {
218
226
  if (!entry.enabled) return void 0;
219
227
  try {
220
- const client = new (0, _chunkRHNIHI4Pcjs.BroadcasterClient)(entry);
221
- await client.fee(token);
228
+ const client = new (0, _chunk3KTQQZOWcjs.BroadcasterClient)({
229
+ endpoint: entry.endpoint,
230
+ quoteSigner: entry.quoteSigner,
231
+ feeRecipient: entry.feeRecipient
232
+ });
233
+ if (!await client.supportsToken(
234
+ token,
235
+ {
236
+ chainId: this.context.chainId,
237
+ protocol: this.context.protocolAddress
238
+ },
239
+ options
240
+ ))
241
+ return void 0;
222
242
  return client;
223
243
  } catch (e) {
244
+ _optionalChain([options, 'access', _7 => _7.signal, 'optionalAccess', _8 => _8.throwIfAborted, 'call', _9 => _9()]);
224
245
  return void 0;
225
246
  }
226
247
  })
227
248
  );
249
+ _optionalChain([options, 'access', _10 => _10.signal, 'optionalAccess', _11 => _11.throwIfAborted, 'call', _12 => _12()]);
228
250
  clients.push(
229
251
  ...compatible.filter((client) => client !== void 0)
230
252
  );
@@ -237,7 +259,7 @@ var Protocol = class _Protocol extends _protocol.Protocol {
237
259
  };
238
260
 
239
261
  // src/index.ts
240
- var _rpc = require('@invisi-labs/rpc');
262
+
241
263
 
242
264
  // src/protocol/BroadcasterRegistry.ts
243
265
  var _contracts = require('@invisi-labs/protocol/contracts');
@@ -310,7 +332,7 @@ var BroadcasterRegistry = class {
310
332
  /** Discover event operators, then read their latest entry; disabled services remain explicit. */
311
333
  async discover(options = {}) {
312
334
  const { provider, fromBlock, blockRange } = this.#options;
313
- _optionalChain([options, 'access', _ => _.signal, 'optionalAccess', _2 => _2.throwIfAborted, 'call', _3 => _3()]);
335
+ _optionalChain([options, 'access', _13 => _13.signal, 'optionalAccess', _14 => _14.throwIfAborted, 'call', _15 => _15()]);
314
336
  await this.validate();
315
337
  const toBlock = await _asyncNullishCoalesce(options.toBlock, async () => ( await provider.getBlockNumber()));
316
338
  if (!Number.isSafeInteger(toBlock) || toBlock < fromBlock) {
@@ -318,7 +340,7 @@ var BroadcasterRegistry = class {
318
340
  }
319
341
  const operators = /* @__PURE__ */ new Set();
320
342
  for (let start = fromBlock; start <= toBlock; ) {
321
- _optionalChain([options, 'access', _4 => _4.signal, 'optionalAccess', _5 => _5.throwIfAborted, 'call', _6 => _6()]);
343
+ _optionalChain([options, 'access', _16 => _16.signal, 'optionalAccess', _17 => _17.throwIfAborted, 'call', _18 => _18()]);
322
344
  const end = Math.min(start + blockRange - 1, toBlock);
323
345
  const logs = await provider.getLogs({
324
346
  address: this.address,
@@ -338,7 +360,7 @@ var BroadcasterRegistry = class {
338
360
  }
339
361
  const entries = [];
340
362
  for (const operator of operators) {
341
- _optionalChain([options, 'access', _7 => _7.signal, 'optionalAccess', _8 => _8.throwIfAborted, 'call', _9 => _9()]);
363
+ _optionalChain([options, 'access', _19 => _19.signal, 'optionalAccess', _20 => _20.throwIfAborted, 'call', _21 => _21()]);
342
364
  entries.push(await this.read(operator));
343
365
  }
344
366
  return entries;
@@ -349,10 +371,13 @@ var BroadcasterRegistry = class {
349
371
 
350
372
  var ProtocolRpcClient = class extends _rpc.ProtocolRpcClient {
351
373
  withProvider(provider) {
352
- return this.withReader(new (0, _chunk7F7ZZW3Lcjs.EthersChainReader)(provider));
374
+ return this.withReader(new (0, _chunkLOR6PYH5cjs.EthersChainReader)(provider));
353
375
  }
354
376
  };
355
377
 
378
+ // src/index.ts
379
+ var _protocol = require('@invisi-labs/protocol');
380
+
356
381
  // src/payment-note/PaymentNote.ts
357
382
 
358
383
 
@@ -391,17 +416,10 @@ async function verifyPaymentNote(data, protocol, options, wallet) {
391
416
  const confirmations = _nullishCoalesce(options.confirmations, () => ( 1));
392
417
  if (!Number.isSafeInteger(confirmations) || confirmations < 1)
393
418
  throw new RangeError("confirmations must be positive");
394
- const reader = _nullishCoalesce(options.chainReader, () => ( new (0, _chunk7F7ZZW3Lcjs.EthersChainReader)(options.provider)));
419
+ const reader = _nullishCoalesce(options.chainReader, () => ( new (0, _chunkLOR6PYH5cjs.EthersChainReader)(options.provider)));
395
420
  await protocol.validateDeployment(reader);
396
421
  if (wallet && _ethers.getAddress.call(void 0, wallet.ownerAddress) !== _ethers.getAddress.call(void 0, data.ownerAddress))
397
422
  throw new Error("Payment note owner mismatch");
398
- if (wallet) {
399
- if (typeof wallet.exportAuthorization !== "function")
400
- throw new Error("Wallet spending authorization capability required");
401
- const authorization = wallet.exportAuthorization();
402
- if (_ethers.getAddress.call(void 0, authorization.ownerAddress) !== _ethers.getAddress.call(void 0, data.ownerAddress))
403
- throw new Error("Wallet authorization owner mismatch");
404
- }
405
423
  const latest = await reader.getLatestBlockNumber();
406
424
  const number = latest - BigInt(confirmations - 1);
407
425
  if (number < protocol.deployment.protocol.fromBlock)
@@ -418,13 +436,13 @@ async function verifyPaymentNote(data, protocol, options, wallet) {
418
436
  const result = await rpc.getNote(protocol.context, data.commitment, checkedAt);
419
437
  if (!result) throw new Error("Payment note is not indexed at the requested confirmed block");
420
438
  const { output, membership } = result;
421
- if (output.commitment !== data.commitment || _ethers.getAddress.call(void 0, output.tokenAddress) !== _ethers.getAddress.call(void 0, data.tokenAddress) || membership.leaf !== data.commitment || membership.treeId !== output.treeId || membership.leafIndex !== output.leafIndex || membership.block.number > checkedAt.number || output.block.number > checkedAt.number || membership.path.length !== _core.TREE_DEPTH || !Number.isSafeInteger(output.leafIndex) || output.leafIndex < 0 || output.leafIndex >= 2 ** _core.TREE_DEPTH)
439
+ if (output.commitment !== data.commitment || _ethers.getAddress.call(void 0, output.tokenAddress) !== _ethers.getAddress.call(void 0, data.tokenAddress) || membership.leaf !== data.commitment || membership.treeId !== output.treeId || membership.leafIndex !== output.leafIndex || membership.block.number > checkedAt.number || output.block.number > checkedAt.number || membership.path.length !== _primitives.TREE_DEPTH || !Number.isSafeInteger(output.leafIndex) || output.leafIndex < 0 || output.leafIndex >= 2 ** _primitives.TREE_DEPTH)
422
440
  throw new Error("Payment note membership metadata mismatch");
423
441
  let root = BigInt(data.commitment);
424
442
  for (let level = 0; level < membership.path.length; level++) {
425
443
  const sibling = membership.path[level];
426
444
  root = BigInt(
427
- await _core.poseidonHash.call(void 0, output.leafIndex >> level & 1 ? [sibling, root] : [root, sibling])
445
+ await _primitives.poseidonHash.call(void 0, output.leafIndex >> level & 1 ? [sibling, root] : [root, sibling])
428
446
  );
429
447
  }
430
448
  if (root !== BigInt(membership.root) || !await reader.isKnownRoot(protocol.context, membership.treeId, membership.root, checkedAt))
@@ -434,7 +452,12 @@ async function verifyPaymentNote(data, protocol, options, wallet) {
434
452
  let spendabilityCheckedAt;
435
453
  if (wallet) {
436
454
  const current = await reader.getBlock(await reader.getLatestBlockNumber());
437
- const nullifier = await _core.computeNoteNullifier.call(void 0, data.chainId, data.nonce, data.commitment);
455
+ const nullifier = await _primitives.computeNoteNullifier.call(void 0,
456
+ data.chainId,
457
+ BigInt(data.protocolAddress),
458
+ data.nonce,
459
+ data.commitment
460
+ );
438
461
  const spent = await reader.isSpent(protocol.context, [nullifier], current);
439
462
  if (spent.length !== 1 || spent[0] !== false)
440
463
  throw new Error("Payment note is already spent");
@@ -518,16 +541,17 @@ var PaymentNote = class _PaymentNote {
518
541
  Object.freeze(this);
519
542
  }
520
543
  static async from(ipn) {
521
- const data = _chunkJ2JH6HIGcjs.decodePaymentNote.call(void 0, ipn);
522
- const identity = await _core.computeNoteIdentity.call(void 0, BigInt(data.ownerAddress), data.nonce);
523
- const commitment = await _core.computeNoteCommitment.call(void 0,
544
+ const data = _chunk4SDP53YQcjs.decodePaymentNote.call(void 0, ipn);
545
+ const identity = await _primitives.computeNoteIdentity.call(void 0, BigInt(data.ownerAddress), data.nonce);
546
+ const commitment = await _primitives.computeNoteCommitment.call(void 0,
524
547
  data.chainId,
548
+ BigInt(data.protocolAddress),
525
549
  identity,
526
550
  BigInt(data.tokenAddress),
527
551
  data.amount
528
552
  );
529
553
  if (commitment !== data.commitment) throw new Error("Payment note commitment mismatch");
530
- return new _PaymentNote(data, _chunkJ2JH6HIGcjs.encodePaymentNote.call(void 0, data));
554
+ return new _PaymentNote(data, _chunk4SDP53YQcjs.encodePaymentNote.call(void 0, data));
531
555
  }
532
556
  async verify(protocol, options = {}) {
533
557
  const result = await verifyPaymentNote(
@@ -540,8 +564,7 @@ var PaymentNote = class _PaymentNote {
540
564
  return verified;
541
565
  }
542
566
  async verifySpendable(protocol, wallet, options = {}) {
543
- if (!(wallet instanceof _core.Wallet))
544
- throw new Error("Wallet spending authorization capability required");
567
+ if (!(wallet instanceof _primitives.Wallet)) throw new Error("A public Wallet is required");
545
568
  const result = await verifyPaymentNote(
546
569
  this.data(),
547
570
  protocol,
@@ -562,6 +585,14 @@ var PaymentNote = class _PaymentNote {
562
585
  }
563
586
  };
564
587
 
588
+ // src/index.ts
589
+
590
+
591
+
592
+
593
+
594
+
595
+
565
596
 
566
597
 
567
598
 
@@ -609,5 +640,5 @@ var PaymentNote = class _PaymentNote {
609
640
 
610
641
 
611
642
 
612
- exports.AddressRegistry = _chunkRHNIHI4Pcjs.AddressRegistry; exports.BroadcasterClient = _chunkRHNIHI4Pcjs.BroadcasterClient; exports.BroadcasterRegistry = BroadcasterRegistry; exports.BroadcasterRpcError = _chunkRHNIHI4Pcjs.BroadcasterRpcError; exports.Detector = _core.Detector; exports.Disclosure = _core.Disclosure; exports.DisclosureVerifier = DisclosureVerifier; exports.Invisi = _chunkRHNIHI4Pcjs.Invisi; exports.InvisiError = _chunkJ2JH6HIGcjs.InvisiError; exports.MAX_MEMO_BYTES = _core.MAX_MEMO_BYTES; exports.MAX_UPDATE_BLOCKS = _rpc.MAX_UPDATE_BLOCKS; exports.MissingCapabilityError = _core.MissingCapabilityError; exports.NoteOutput = _chunkJ2JH6HIGcjs.NoteOutput; exports.NullifierCapability = _core.NullifierCapability; exports.PaymentNote = PaymentNote; exports.PreparedTransaction = _chunkRHNIHI4Pcjs.PreparedTransaction; exports.Protocol = Protocol; exports.ProtocolRpcClient = ProtocolRpcClient; exports.ProtocolRpcError = _rpc.ProtocolRpcError; exports.PublicWallet = _core.PublicWallet; exports.RegistrationOperation = _protocol.RegistrationOperation; exports.SpendablePaymentNote = SpendablePaymentNote; exports.TransactionOutput = _chunkRHNIHI4Pcjs.TransactionOutput; exports.VerifiedPaymentNote = VerifiedPaymentNote; exports.ViewingCapability = _core.ViewingCapability; exports.Wallet = _core.Wallet; exports.WalletAuthorization = _core.WalletAuthorization; exports.broadcasterQuoteDomain = _chunkRHNIHI4Pcjs.broadcasterQuoteDomain; exports.broadcasterQuoteTypes = _chunkRHNIHI4Pcjs.broadcasterQuoteTypes; exports.broadcasterRequestHash = _chunkRHNIHI4Pcjs.broadcasterRequestHash; exports.broadcasterTransactInterface = _chunkRHNIHI4Pcjs.broadcasterTransactInterface; exports.computeCreditNullifier = _core.computeCreditNullifier; exports.creditPeriods = _core.creditPeriods; exports.creditV1 = _core.creditV1; exports.decodeBroadcasterIntent = _chunkRHNIHI4Pcjs.decodeBroadcasterIntent; exports.decodeDeliveryHeader = _core.decodeDeliveryHeader; exports.decodeMemoText = _core.decodeMemoText; exports.decodePaymentNote = _chunkJ2JH6HIGcjs.decodePaymentNote; exports.decodePaymentRequest = _chunkJ2JH6HIGcjs.decodePaymentRequest; exports.decryptCandidates = _chunkRHNIHI4Pcjs.decryptCandidates; exports.defineGasBenchmarks = _chunkRHNIHI4Pcjs.defineGasBenchmarks; exports.encodeMemo = _core.encodeMemo; exports.encodePaymentNote = _chunkJ2JH6HIGcjs.encodePaymentNote; exports.encodePaymentRequest = _chunkJ2JH6HIGcjs.encodePaymentRequest; exports.fundsV1 = _core.fundsV1; exports.readProtocolLogs = _chunkRHNIHI4Pcjs.readProtocolLogs; exports.verifyBroadcasterQuote = _chunkRHNIHI4Pcjs.verifyBroadcasterQuote;
643
+ exports.AddressRegistry = _chunkDHQEB6JRcjs.AddressRegistry; exports.BroadcasterClient = _chunk3KTQQZOWcjs.BroadcasterClient; exports.BroadcasterRegistry = BroadcasterRegistry; exports.BroadcasterRpcError = _chunk3KTQQZOWcjs.BroadcasterRpcError; exports.DeliveryAuthenticationError = _primitives.DeliveryAuthenticationError; exports.DeliveryDecryptionError = _primitives.DeliveryDecryptionError; exports.Detector = _primitives.Detector; exports.Disclosure = _primitives.Disclosure; exports.DisclosureVerifier = DisclosureVerifier; exports.Invisi = _chunkDHQEB6JRcjs.Invisi; exports.InvisiError = _chunk4SDP53YQcjs.InvisiError; exports.MAX_MEMO_BYTES = _primitives.MAX_MEMO_BYTES; exports.MAX_UPDATE_BLOCKS = _rpc.MAX_UPDATE_BLOCKS; exports.MissingCapabilityError = _primitives.MissingCapabilityError; exports.NoteOutput = _chunk4SDP53YQcjs.NoteOutput; exports.NullifierCapability = _primitives.NullifierCapability; exports.PaymentNote = PaymentNote; exports.PreparedTransaction = _chunkDHQEB6JRcjs.PreparedTransaction; exports.Protocol = Protocol; exports.ProtocolRpcClient = ProtocolRpcClient; exports.ProtocolRpcError = _rpc.ProtocolRpcError; exports.RegistrationOperation = _rpc.RegistrationOperation; exports.SpendablePaymentNote = SpendablePaymentNote; exports.TransactionOutput = _chunkOCZLJKIAcjs.TransactionOutput; exports.VerifiedPaymentNote = VerifiedPaymentNote; exports.ViewingCapability = _primitives.ViewingCapability; exports.Wallet = _primitives.Wallet; exports.authenticatedDecryptor = _primitives.authenticatedDecryptor; exports.broadcasterQuoteDomain = _chunk3KTQQZOWcjs.broadcasterQuoteDomain; exports.broadcasterQuoteTypes = _chunk3KTQQZOWcjs.broadcasterQuoteTypes; exports.broadcasterRequestHash = _chunk3KTQQZOWcjs.broadcasterRequestHash; exports.broadcasterTransactInterface = _chunk3KTQQZOWcjs.broadcasterTransactInterface; exports.computeCreditNullifier = _primitives.computeCreditNullifier; exports.creditPeriods = _primitives.creditPeriods; exports.creditV1 = _primitives.creditV1; exports.decodeBroadcasterIntent = _chunk3KTQQZOWcjs.decodeBroadcasterIntent; exports.decodeDeliveryHeader = _primitives.decodeDeliveryHeader; exports.decodeMemoText = _primitives.decodeMemoText; exports.decodePaymentNote = _chunk4SDP53YQcjs.decodePaymentNote; exports.decodePaymentRequest = _chunk4SDP53YQcjs.decodePaymentRequest; exports.decryptCandidates = _chunkDHQEB6JRcjs.decryptCandidates; exports.encodeMemo = _primitives.encodeMemo; exports.encodePaymentNote = _chunk4SDP53YQcjs.encodePaymentNote; exports.encodePaymentRequest = _chunk4SDP53YQcjs.encodePaymentRequest; exports.fundsV1 = _primitives.fundsV1; exports.getDocumentedGasReference = _protocol.getDocumentedGasReference; exports.readProtocolLogs = _chunkDHQEB6JRcjs.readProtocolLogs; exports.verifyBroadcasterQuote = _chunk3KTQQZOWcjs.verifyBroadcasterQuote;
613
644
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/invisi-sdk-ts/invisi-sdk-ts/packages/sdk/dist/index.cjs","../src/index.ts","../src/disclosure/DisclosureVerifier.ts","../src/protocol/connections.ts","../src/protocol/Protocol.ts","../src/protocol/BroadcasterRegistry.ts","../src/protocol/ProtocolRpcClient.ts","../src/payment-note/PaymentNote.ts","../src/payment-note/verification.ts"],"names":["candidate","getAddress"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;AC9BA;AACI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,yCACG;AAkBP,iDAAsC;ADetC;AACA;AETA,SAAS,KAAA,CAAM,KAAA,EAAgB,OAAA,EAAgC;AAC3D,EAAA,GAAA,CAAI,CAAC,KAAA,EAAO,MAAM,IAAI,KAAA,CAAM,OAAO,CAAA;AACvC;AAEA,SAAS,SAAA,CAAU,KAAA,EAAiD;AAChE,EAAA,KAAA,CAAM,qBAAA,CAAsB,IAAA,CAAK,KAAA,CAAM,eAAe,CAAA,EAAG,qCAAqC,CAAA;AAC9F,EAAA,KAAA;AAAA,IACI,OAAO,KAAA,CAAM,OAAA,IAAW,SAAA,GAAY,KAAA,CAAM,OAAA,EAAS,GAAA,GAAM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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,0kFAAC","file":"/home/runner/work/invisi-sdk-ts/invisi-sdk-ts/packages/sdk/dist/index.cjs","sourcesContent":[null,"export {\n Detector,\n Disclosure,\n MAX_MEMO_BYTES,\n MissingCapabilityError,\n NullifierCapability,\n PublicWallet,\n ViewingCapability,\n Wallet,\n WalletAuthorization,\n computeCreditNullifier,\n creditPeriods,\n creditV1,\n decodeDeliveryHeader,\n decodeMemoText,\n encodeMemo,\n fundsV1,\n} from \"@invisi-labs/core\";\nexport type {\n Address,\n CreditDataV1,\n CreditDeliveryState,\n CreditNote,\n CreditOpening,\n CreditPolicy,\n DisclosureExport,\n DisclosureOutput,\n DisclosureResult,\n FundsDataV1,\n Hex,\n Memo,\n Note,\n ReceivingKeys,\n WalletAuthorizationProvider,\n} from \"@invisi-labs/core\";\nexport { RegistrationOperation } from \"@invisi-labs/protocol\";\nexport type {\n AddressRegistryOptions,\n CanonicalBlock,\n CanonicalReceipt,\n ChainReader,\n FactoryReader,\n Membership,\n ProtocolDataProvider,\n ProtocolDataStatus,\n ProtocolOptions,\n ProtocolUpdateRange,\n ProtocolUpdates,\n RegistryContext,\n RegistryReader,\n TokenProtocol,\n TokenProtocolOptions,\n TransactionCall,\n TransactionContext,\n} from \"@invisi-labs/protocol\";\nexport type {\n AggregateMember,\n AggregatorCapability,\n ProofBundle,\n ProofStatement,\n Prover,\n ProverOptions,\n} from \"@invisi-labs/prover\";\nexport { Invisi } from \"./client/Invisi\";\nexport type { InvisiOptions, RegistrationPreparationOptions } from \"./client/Invisi\";\nexport { DisclosureVerifier } from \"./disclosure/DisclosureVerifier\";\nexport type {\n DisclosureEvidence,\n DisclosureReader,\n DisclosureReference,\n DisclosureVerifierOptions,\n VerifiedDisclosure,\n} from \"./disclosure/DisclosureVerifier\";\nexport { InvisiError } from \"./errors\";\nexport type { InvisiErrorCode, InvisiErrorDetails } from \"./errors\";\nexport { NoteOutput } from \"./notes/NoteOutput\";\nexport type { NoteOutputContext, PaymentRequest, NoteOutputRecipient } from \"./notes/NoteOutput\";\nexport { Protocol } from \"./protocol/Protocol\";\nexport type {\n CancelCreditPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n FundingAuthorizationVerifier,\n FundingSigner,\n FundingSource,\n FundingTypedData,\n OperationAggregateMember,\n ShieldPreparation,\n TopUpCreditPreparation,\n TransactionExecution,\n TransactionProveOptions,\n TransferPreparation,\n} from \"./transactions/operation-types\";\n\nexport { MAX_UPDATE_BLOCKS, ProtocolRpcError } from \"@invisi-labs/rpc\";\nexport type {\n ProtocolDeployment,\n ProtocolRpcChain,\n ProtocolRpcClientOptions,\n ProtocolRpcConnectionOptions,\n ProtocolRpcReader,\n RegisteredReceivingAddress,\n} from \"@invisi-labs/rpc\";\nexport { AddressRegistry } from \"./protocol/AddressRegistry\";\nexport { BroadcasterRegistry } from \"./protocol/BroadcasterRegistry\";\nexport type {\n BroadcasterRegistration,\n BroadcasterRegistryOptions,\n RegisteredBroadcaster,\n} from \"./protocol/BroadcasterRegistry\";\nexport { ProtocolRpcClient } from \"./protocol/ProtocolRpcClient\";\n\nexport { PreparedTransaction } from \"./transactions/execution/PreparedTransaction\";\nexport type {\n CreditInput,\n ExplicitCancelCreditPreparation,\n ExplicitCreateCreditPreparation,\n ExplicitDrawCreditPreparation,\n ExplicitShieldPreparation,\n ExplicitTopUpCreditPreparation,\n ExplicitTransferPreparation,\n NoteInput,\n TransactionIdentity,\n} from \"./transactions/explicit-types\";\n\nexport type {\n GasBenchmarkCircuit,\n GasBenchmarkDeployment,\n GasBenchmarkProfile,\n GasBenchmarkSample,\n GasBenchmarkShape,\n GasReference,\n} from \"./gas/gas-estimation\";\n\nexport { defineGasBenchmarks } from \"./gas/gas-estimation\";\n\nexport type { SigningRequest } from \"@invisi-labs/core\";\n\n// Stateless recovery for applications that supply canonical receipts without a wallet store.\nexport { decryptCandidates } from \"./discovery/discovery\";\nexport type { DeliveryEventLog, DiscoveredCredit, DiscoveredNote } from \"./discovery/discovery\";\nexport { readProtocolLogs } from \"./discovery/receipt-logs\";\n\nexport type {\n ProtocolCreditTransition,\n ProtocolOutput,\n ProtocolTransactionUpdates,\n} from \"@invisi-labs/rpc\";\n\nexport * from \"./broadcaster/index\";\n\nexport type {\n BroadcasterFeeSource,\n WithBroadcasterOptions,\n} from \"./broadcaster/broadcaster-preparation\";\n\nexport { encodePaymentRequest, decodePaymentRequest } from \"./payment-request/codec\";\nexport type { NoteOutputExecutionOptions } from \"./payment-request/types\";\n\nexport { PaymentNote, VerifiedPaymentNote, SpendablePaymentNote } from \"./payment-note/PaymentNote\";\nexport { encodePaymentNote, decodePaymentNote } from \"./payment-note/codec\";\nexport type { PaymentNoteData } from \"./payment-note/types\";\nexport type {\n PaymentNoteVerificationOptions,\n PaymentNoteVerificationSettings,\n} from \"./payment-note/verification\";\nexport { TransactionOutput } from \"./notes/TransactionOutput\";\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport type { Provider } from \"ethers\";\nimport { readProtocolLogs } from \"../discovery/receipt-logs\";\nimport { EthersChainReader } from \"../integrations/ethers\";\n\nimport { Disclosure, type DisclosureOutput, type DisclosureResult } from \"@invisi-labs/core\";\nimport { TokenProtocol, type CanonicalBlock, type ChainReader } from \"@invisi-labs/protocol\";\nimport { extractDeliveryCandidates } from \"../discovery/discovery\";\n\nexport interface DisclosureReference {\n transactionHash: Hex;\n treeId: bigint;\n leafIndex: number;\n role: \"funds\" | \"owner\" | \"spender\";\n}\n\nexport type DisclosureReader = Pick<\n ChainReader,\n \"getChainId\" | \"getCode\" | \"getReceipt\" | \"getBlock\" | \"getLatestBlockNumber\"\n>;\n\nexport interface DisclosureVerifierOptions {\n protocol: TokenProtocol;\n reader: DisclosureReader;\n /** Minimum confirmations including the inclusion block; defaults to one. */\n confirmations?: number;\n}\n\nexport interface DisclosureEvidence {\n reference: Readonly<DisclosureReference>;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureOutput>;\n}\n\nexport interface VerifiedDisclosure {\n result: DisclosureResult;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureReference & { commitment: Hex }>;\n}\n\nfunction check(value: unknown, message: string): asserts value {\n if (!value) throw new Error(message);\n}\n\nfunction reference(value: DisclosureReference): DisclosureReference {\n check(/^0x[0-9a-fA-F]{64}$/.test(value.transactionHash), \"invalid disclosure transaction hash\");\n check(\n typeof value.treeId === \"bigint\" && value.treeId > 0n && value.treeId < 1n << 64n,\n \"invalid disclosure tree ID\"\n );\n check(\n Number.isSafeInteger(value.leafIndex) && value.leafIndex >= 0 && value.leafIndex < 65536,\n \"invalid disclosure leaf index\"\n );\n check([\"funds\", \"owner\", \"spender\"].includes(value.role), \"invalid disclosure reference role\");\n return {\n transactionHash: value.transactionHash.toLowerCase() as Hex,\n treeId: value.treeId,\n leafIndex: value.leafIndex,\n role: value.role,\n };\n}\n\n/** Read-only verification against a trusted RPC and authenticated protocol deployment.\n * Results establish output content/inclusion at a block, not payer identity, spent state or wallet completeness.\n */\nexport class DisclosureVerifier {\n readonly #protocol: TokenProtocol;\n readonly #reader: DisclosureReader;\n readonly #confirmations: bigint;\n\n constructor(\n options:\n | DisclosureVerifierOptions\n | (Omit<DisclosureVerifierOptions, \"reader\"> & { provider: Provider })\n ) {\n const confirmations = options.confirmations ?? 1;\n check(\n Number.isSafeInteger(confirmations) && confirmations >= 1,\n \"invalid disclosure confirmations\"\n );\n this.#protocol = options.protocol;\n this.#reader =\n \"provider\" in options ? new EthersChainReader(options.provider) : options.reader;\n this.#confirmations = BigInt(confirmations);\n Object.freeze(this);\n }\n\n private async barrier(block: Readonly<CanonicalBlock>): Promise<bigint> {\n await this.#protocol.validateDeployment(this.#reader);\n const canonical = await this.#reader.getBlock(block.number);\n check(\n canonical.number === block.number &&\n canonical.hash.toLowerCase() === block.hash.toLowerCase(),\n \"disclosure canonical block changed; reorg verification required\"\n );\n const head = await this.#reader.getLatestBlockNumber();\n check(\n head >= block.number && head - block.number + 1n >= this.#confirmations,\n \"insufficient disclosure confirmations\"\n );\n check(\n (await this.#reader.getChainId()) === this.#protocol.context.chainId,\n \"disclosure chain changed during verification\"\n );\n return head - block.number + 1n;\n }\n\n /** Resolve the exact inserted output and its delivery from a successful canonical receipt. */\n async readOutput(value: DisclosureReference): Promise<DisclosureEvidence> {\n const selected = reference(value);\n await this.#protocol.validateDeployment(this.#reader);\n const received = await this.#reader.getReceipt(selected.transactionHash);\n check(received, \"disclosure transaction receipt is unavailable\");\n const receipt = structuredClone(received);\n check(receipt.status === \"success\", \"disclosure requires a successful transaction receipt\");\n check(\n receipt.transactionHash.toLowerCase() === selected.transactionHash,\n \"disclosure receipt transaction mismatch\"\n );\n check(\n typeof receipt.block.number === \"bigint\" &&\n receipt.block.number >= 0n &&\n /^0x[0-9a-fA-F]{64}$/.test(receipt.block.hash),\n \"invalid disclosure receipt block\"\n );\n const { context } = this.#protocol;\n const logs = readProtocolLogs(receipt, context.protocolAddress);\n const candidates = extractDeliveryCandidates(logs, context, receipt.block.number).filter(\n (candidate) =>\n candidate.treeId === selected.treeId &&\n candidate.leafIndex === selected.leafIndex &&\n candidate.role === selected.role &&\n candidate.tokenAddress.toLowerCase() === context.tokenAddress.toLowerCase()\n );\n check(\n candidates.length === 1,\n \"disclosure output has no unique canonical insertion and delivery\"\n );\n const candidate = candidates[0]!;\n const confirmations = await this.barrier(receipt.block);\n return Object.freeze({\n reference: Object.freeze(selected),\n block: Object.freeze({ ...receipt.block }),\n confirmations,\n output: Object.freeze({\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n tokenAddress: BigInt(context.tokenAddress),\n outputCommitment: candidate.commitment,\n role: selected.role,\n ciphertext: candidate.delivery.ciphertext,\n }),\n });\n }\n\n async verify(disclosure: Disclosure, value: DisclosureReference): Promise<VerifiedDisclosure> {\n const evidence = await this.readOutput(value);\n const result = await disclosure.verify(evidence.output);\n const confirmations = await this.barrier(evidence.block);\n return Object.freeze({\n result: Object.freeze(result),\n block: evidence.block,\n confirmations,\n output: Object.freeze({\n ...evidence.reference,\n commitment: evidence.output.outputCommitment,\n }),\n });\n }\n\n toJSON() {\n return { disclosureVerifier: true, confirmations: this.#confirmations.toString() };\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import type { Protocol } from \"@invisi-labs/protocol\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\n\n/** Public network connections only; never holds wallet keys or a signer. */\nconst connections = new WeakMap<\n Protocol,\n { provider: Provider; protocolRpc: Pick<ProtocolRpcClient, \"withReader\"> }\n>();\nexport function rememberProtocolConnection(\n protocol: Protocol,\n provider: Provider,\n protocolRpc: Pick<ProtocolRpcClient, \"withReader\">\n): void {\n connections.set(protocol, { provider, protocolRpc });\n}\nexport function protocolConnection(protocol: Protocol) {\n return connections.get(protocol);\n}\n","import { rememberProtocolConnection } from \"./connections\";\nimport { Protocol as BaseProtocol } from \"@invisi-labs/protocol\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport { getAddress, type Provider } from \"ethers\";\nimport { BroadcasterClient } from \"../broadcaster/index\";\n\nconst sources = new WeakMap<Protocol, Pick<ProtocolRpcClient, \"getBroadcasters\">>();\n\n/** Deployment operations and token-compatible broadcaster discovery. */\nexport class Protocol extends BaseProtocol {\n static override async fromRpc(\n rpc: Pick<ProtocolRpcClient, \"getDeployment\"> &\n Partial<Pick<ProtocolRpcClient, \"getBroadcasters\" | \"withReader\">>,\n provider: Provider,\n options: { signal?: AbortSignal } = {}\n ): Promise<Protocol> {\n const verified = await BaseProtocol.fromRpc(rpc, provider, options);\n const protocol = new Protocol({ deployment: verified.deployment });\n if (rpc.getBroadcasters)\n sources.set(protocol, rpc as Pick<ProtocolRpcClient, \"getBroadcasters\">);\n if (rpc.withReader)\n rememberProtocolConnection(\n protocol,\n provider,\n rpc as Pick<ProtocolRpcClient, \"withReader\">\n );\n return protocol;\n }\n\n /** Returns enabled services that answer a token fee probe; final quotes are checked by prepared. */\n async getBroadcasters(options: { tokenAddress: string }): Promise<BroadcasterClient[]> {\n const token = getAddress(options.tokenAddress);\n if (!this.deployment.broadcasterRegistry)\n throw new Error(\"broadcaster registry is not configured\");\n const rpc = sources.get(this);\n if (!rpc) throw new Error(\"broadcaster discovery requires Protocol.fromRpc\");\n const clients: BroadcasterClient[] = [];\n let after: `0x${string}` | undefined;\n let block: Awaited<ReturnType<ProtocolRpcClient[\"getBroadcasters\"]>>[\"block\"] | undefined;\n const seen = new Set<string>();\n do {\n const page = await rpc.getBroadcasters({\n enabled: true,\n limit: 100,\n ...(after ? { after } : {}),\n ...(block ? { block } : {}),\n });\n block ??= page.block;\n const compatible = await Promise.all(\n page.broadcasters.map(async (entry) => {\n if (!entry.enabled) return undefined;\n try {\n const client = new BroadcasterClient(entry);\n await client.fee(token);\n return client;\n } catch {\n return undefined;\n }\n })\n );\n clients.push(\n ...compatible.filter((client): client is BroadcasterClient => client !== undefined)\n );\n after = page.next;\n if (after && seen.has(after)) throw new Error(\"repeated broadcaster pagination cursor\");\n if (after) seen.add(after);\n } while (after);\n return clients;\n }\n}\n","import type { TransactionCall } from \"@invisi-labs/protocol\";\nimport { broadcasterRegistryAbi, type Address, type Hex } from \"@invisi-labs/protocol/contracts\";\nimport { getAddress, Interface, keccak256, type Provider } from \"ethers\";\n\nexport interface BroadcasterRegistration {\n endpoint: string;\n metadataURI?: string;\n quoteSigner: Address;\n feeRecipient: Address;\n}\n\nexport interface RegisteredBroadcaster extends Required<BroadcasterRegistration> {\n operator: Address;\n enabled: boolean;\n}\n\nexport interface BroadcasterRegistryOptions {\n provider: Provider;\n address: Address;\n chainId: bigint;\n fromBlock: number;\n runtimeCodeHash: string;\n /** Maximum blocks per getLogs request. Defaults to 2,000. */\n blockRange?: number;\n}\n\nconst abi = new Interface(broadcasterRegistryAbi);\n\nfunction address(value: string): Address {\n const normalized = getAddress(value) as Address;\n if (BigInt(normalized) === 0n) throw new Error(\"zero broadcaster address\");\n return normalized;\n}\n\n/** Optional on-chain discovery. Registry entries do not authorize spending or endorse operators. */\nexport class BroadcasterRegistry {\n readonly address: Address;\n readonly #options: Readonly<BroadcasterRegistryOptions>;\n\n constructor(options: BroadcasterRegistryOptions) {\n this.address = address(options.address);\n const blockRange = options.blockRange ?? 2_000;\n if (\n options.chainId <= 0n ||\n !Number.isSafeInteger(options.fromBlock) ||\n options.fromBlock < 0 ||\n !Number.isSafeInteger(blockRange) ||\n blockRange < 1 ||\n blockRange > 100_000 ||\n !/^0x[0-9a-fA-F]{64}$/.test(options.runtimeCodeHash)\n )\n throw new Error(\"invalid broadcaster registry configuration\");\n this.#options = Object.freeze({ ...options, blockRange });\n }\n\n prepareRegistration(registration: BroadcasterRegistration): TransactionCall {\n const { endpoint, metadataURI = \"\" } = registration;\n if (\n !endpoint.startsWith(\"https://\") ||\n endpoint.length <= 8 ||\n endpoint.length > 2048 ||\n /[^\\x21-\\x7e]/.test(endpoint)\n )\n throw new Error(\"broadcaster endpoint must be a printable HTTPS URI\");\n // Parse locally for a useful error; the registry additionally enforces its byte limits.\n const url = new URL(endpoint);\n if (!url.hostname || url.username || url.password) {\n throw new Error(\"broadcaster HTTPS endpoint must not include credentials\");\n }\n if (metadataURI.length > 2048 || /[^\\x21-\\x7e]/.test(metadataURI)) {\n throw new Error(\"invalid broadcaster metadata URI\");\n }\n return this.call(\"setBroadcaster\", [\n endpoint,\n metadataURI,\n address(registration.quoteSigner),\n address(registration.feeRecipient),\n ]);\n }\n\n prepareAvailability(enabled: boolean): TransactionCall {\n return this.call(\"setEnabled\", [enabled]);\n }\n\n private call(name: string, args: readonly unknown[]): TransactionCall {\n return { to: this.address, data: abi.encodeFunctionData(name, args) as Hex, value: 0n };\n }\n\n private async validate(): Promise<void> {\n const { provider, chainId, runtimeCodeHash } = this.#options;\n if ((await provider.getNetwork()).chainId !== chainId) {\n throw new Error(\"broadcaster registry chain mismatch\");\n }\n if (\n keccak256(await provider.getCode(this.address)).toLowerCase() !==\n runtimeCodeHash.toLowerCase()\n ) {\n throw new Error(\"broadcaster registry runtime code mismatch\");\n }\n }\n\n async get(operator: Address): Promise<RegisteredBroadcaster> {\n await this.validate();\n return this.read(address(operator));\n }\n\n private async read(operator: Address): Promise<RegisteredBroadcaster> {\n const result = await this.#options.provider.call(this.call(\"broadcasterOf\", [operator]));\n const [entry] = abi.decodeFunctionResult(\"broadcasterOf\", result);\n return {\n operator,\n endpoint: entry.endpoint,\n metadataURI: entry.metadataURI,\n quoteSigner: address(entry.quoteSigner),\n feeRecipient: address(entry.feeRecipient),\n enabled: entry.enabled,\n };\n }\n\n /** Discover event operators, then read their latest entry; disabled services remain explicit. */\n async discover(\n options: { toBlock?: number; signal?: AbortSignal } = {}\n ): Promise<RegisteredBroadcaster[]> {\n const { provider, fromBlock, blockRange } = this.#options;\n options.signal?.throwIfAborted();\n await this.validate();\n const toBlock = options.toBlock ?? (await provider.getBlockNumber());\n if (!Number.isSafeInteger(toBlock) || toBlock < fromBlock) {\n throw new Error(\"invalid broadcaster discovery block range\");\n }\n const operators = new Set<Address>();\n for (let start = fromBlock; start <= toBlock;) {\n options.signal?.throwIfAborted();\n const end = Math.min(start + blockRange! - 1, toBlock);\n const logs = await provider.getLogs({\n address: this.address,\n topics: [abi.getEvent(\"BroadcasterSet\")!.topicHash],\n fromBlock: start,\n toBlock: end,\n });\n for (const log of logs) {\n if (getAddress(log.address) !== this.address)\n throw new Error(\"registry event address mismatch\");\n const event = abi.parseLog(log);\n if (!event || event.name !== \"BroadcasterSet\")\n throw new Error(\"invalid registry event\");\n operators.add(address(event.args.operator));\n }\n start = end + 1;\n }\n const entries: RegisteredBroadcaster[] = [];\n for (const operator of operators) {\n options.signal?.throwIfAborted();\n entries.push(await this.read(operator));\n }\n return entries;\n }\n}\n","import { ProtocolRpcClient as RpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\nimport { EthersChainReader } from \"../integrations/ethers\";\n\n/** Protocol RPC transport with ethers provider integration for independent chain checks. */\nexport class ProtocolRpcClient extends RpcClient {\n withProvider(provider: Provider): RpcClient {\n return this.withReader(new EthersChainReader(provider));\n }\n}\n","import { computeNoteIdentity, computeNoteCommitment, Wallet } from \"@invisi-labs/core\";\nimport type { Protocol, Membership, CanonicalBlock } from \"@invisi-labs/protocol\";\nimport type { NoteInput } from \"../transactions/explicit-types\";\nimport { decodePaymentNote, encodePaymentNote } from \"./codec\";\nimport type { PaymentNoteData } from \"./types\";\nimport {\n verifyPaymentNote,\n verificationOptions,\n type PaymentNoteVerificationSettings,\n type PaymentNoteVerificationOptions,\n} from \"./verification\";\n\nconst verification = Symbol(\"PaymentNote verification\");\nexport class VerifiedPaymentNote {\n readonly #membership: Membership;\n readonly #checkedAt: CanonicalBlock;\n constructor(token: symbol, membership: Membership, checkedAt: CanonicalBlock) {\n if (token !== verification) throw new Error(\"Payment note verification required\");\n this.#membership = structuredClone(membership);\n this.#checkedAt = structuredClone(checkedAt);\n }\n get membership(): Membership {\n return structuredClone(this.#membership);\n }\n get checkedAt(): CanonicalBlock {\n return structuredClone(this.#checkedAt);\n }\n}\nexport class SpendablePaymentNote extends VerifiedPaymentNote {\n readonly #input: NoteInput;\n readonly #spendabilityCheckedAt: CanonicalBlock;\n constructor(\n token: symbol,\n input: NoteInput,\n membership: Membership,\n checkedAt: CanonicalBlock,\n spendabilityCheckedAt: CanonicalBlock\n ) {\n super(token, membership, checkedAt);\n this.#input = structuredClone(input);\n this.#spendabilityCheckedAt = structuredClone(spendabilityCheckedAt);\n Object.freeze(this);\n }\n get spendabilityCheckedAt(): CanonicalBlock {\n return structuredClone(this.#spendabilityCheckedAt);\n }\n toInput(): NoteInput {\n return structuredClone(this.#input);\n }\n}\n/** A validated Note opening, independent of an indexed wallet store. */\nexport class PaymentNote implements PaymentNoteData {\n readonly chainId: bigint;\n readonly protocolAddress: PaymentNoteData[\"protocolAddress\"];\n readonly tokenAddress: PaymentNoteData[\"tokenAddress\"];\n readonly amount: bigint;\n readonly ownerAddress: PaymentNoteData[\"ownerAddress\"];\n readonly nonce: bigint;\n readonly commitment: PaymentNoteData[\"commitment\"];\n readonly ipn: string;\n private constructor(data: PaymentNoteData, ipn: string) {\n this.chainId = data.chainId;\n this.protocolAddress = data.protocolAddress;\n this.tokenAddress = data.tokenAddress;\n this.amount = data.amount;\n this.ownerAddress = data.ownerAddress;\n this.nonce = data.nonce;\n this.commitment = data.commitment;\n this.ipn = ipn;\n Object.freeze(this);\n }\n static async from(ipn: string): Promise<PaymentNote> {\n const data = decodePaymentNote(ipn);\n const identity = await computeNoteIdentity(BigInt(data.ownerAddress), data.nonce);\n const commitment = await computeNoteCommitment(\n data.chainId,\n identity,\n BigInt(data.tokenAddress),\n data.amount\n );\n if (commitment !== data.commitment) throw new Error(\"Payment note commitment mismatch\");\n return new PaymentNote(data, encodePaymentNote(data));\n }\n async verify(\n protocol: Protocol,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n ): Promise<VerifiedPaymentNote> {\n const result = await verifyPaymentNote(\n this.data(),\n protocol,\n verificationOptions(protocol, options)\n );\n const verified = new VerifiedPaymentNote(verification, result.membership, result.checkedAt);\n Object.freeze(verified);\n return verified;\n }\n async verifySpendable(\n protocol: Protocol,\n wallet: Wallet,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n ): Promise<SpendablePaymentNote> {\n if (!(wallet instanceof Wallet))\n throw new Error(\"Wallet spending authorization capability required\");\n const result = await verifyPaymentNote(\n this.data(),\n protocol,\n verificationOptions(protocol, options),\n wallet\n );\n return new SpendablePaymentNote(\n verification,\n result.input,\n result.membership,\n result.checkedAt,\n result.spendabilityCheckedAt!\n );\n }\n private data(): PaymentNoteData {\n const { chainId, protocolAddress, tokenAddress, amount, ownerAddress, nonce, commitment } =\n this;\n return { chainId, protocolAddress, tokenAddress, amount, ownerAddress, nonce, commitment };\n }\n}\n","import { protocolConnection } from \"../protocol/connections\";\nimport {\n poseidonHash,\n TREE_DEPTH,\n type Wallet,\n type Note,\n computeNoteNullifier,\n} from \"@invisi-labs/core\";\nimport type { CanonicalBlock, ChainReader, Membership, Protocol } from \"@invisi-labs/protocol\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport { getAddress, type Provider } from \"ethers\";\nimport { EthersChainReader } from \"../integrations/ethers\";\nimport type { NoteInput } from \"../transactions/explicit-types\";\nimport type { PaymentNoteData } from \"./types\";\n\n/** Supply connections for manually constructed Protocols; fromRpc connections are reused. */\nexport type PaymentNoteVerificationOptions = {\n protocolRpc: Pick<ProtocolRpcClient, \"withReader\">;\n confirmations?: number;\n} & ({ provider: Provider; chainReader?: never } | { chainReader: ChainReader; provider?: never });\n\nexport type PaymentNoteVerificationSettings = { confirmations?: number };\nexport function verificationOptions(\n protocol: Protocol,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n): PaymentNoteVerificationOptions {\n const connected = protocolConnection(protocol);\n const resolved = { ...connected, ...options };\n if (\n !(\"protocolRpc\" in resolved) ||\n !resolved.protocolRpc ||\n (!(\"chainReader\" in resolved) && !(\"provider\" in resolved))\n )\n throw new Error(\n \"Payment note verification requires Protocol.fromRpc or explicit chain and Protocol RPC connections\"\n );\n return resolved as PaymentNoteVerificationOptions;\n}\n\nfunction sameBlock(a: CanonicalBlock, b: CanonicalBlock): boolean {\n return (\n a.number === b.number &&\n a.hash === b.hash &&\n a.parentHash === b.parentHash &&\n a.timestamp === b.timestamp\n );\n}\nexport function asNote(data: PaymentNoteData): Note {\n return {\n chainId: data.chainId,\n protocolAddress: BigInt(data.protocolAddress),\n tokenAddress: BigInt(data.tokenAddress),\n amount: data.amount,\n ownerAddress: data.ownerAddress,\n nonce: data.nonce,\n };\n}\nexport async function verifyPaymentNote(\n data: PaymentNoteData,\n protocol: Protocol,\n options: PaymentNoteVerificationOptions,\n wallet?: Wallet\n): Promise<{\n input: NoteInput;\n membership: Membership;\n checkedAt: CanonicalBlock;\n spendabilityCheckedAt?: CanonicalBlock;\n}> {\n if (\n data.chainId !== protocol.context.chainId ||\n getAddress(data.protocolAddress) !== getAddress(protocol.context.protocolAddress)\n )\n throw new Error(\"Payment note protocol context mismatch\");\n const confirmations = options.confirmations ?? 1;\n if (!Number.isSafeInteger(confirmations) || confirmations < 1)\n throw new RangeError(\"confirmations must be positive\");\n const reader = options.chainReader ?? new EthersChainReader(options.provider!);\n await protocol.validateDeployment(reader);\n if (wallet && getAddress(wallet.ownerAddress) !== getAddress(data.ownerAddress))\n throw new Error(\"Payment note owner mismatch\");\n if (wallet) {\n if (typeof wallet.exportAuthorization !== \"function\")\n throw new Error(\"Wallet spending authorization capability required\");\n const authorization = wallet.exportAuthorization();\n if (getAddress(authorization.ownerAddress) !== getAddress(data.ownerAddress))\n throw new Error(\"Wallet authorization owner mismatch\");\n }\n const latest = await reader.getLatestBlockNumber();\n const number = latest - BigInt(confirmations - 1);\n if (number < protocol.deployment.protocol.fromBlock)\n throw new Error(\"Insufficient confirmed blocks\");\n const rpc = options.protocolRpc.withReader(reader);\n const status = await rpc.getStatus(protocol.context);\n if (!status.indexedHead) throw new Error(\"Protocol RPC has no indexed blocks\");\n const indexedNumber = status.indexedHead.number < number ? status.indexedHead.number : number;\n if (indexedNumber < protocol.deployment.protocol.fromBlock)\n throw new Error(\"Protocol RPC has not reached the deployment\");\n const checkedAt = await reader.getBlock(indexedNumber);\n if (checkedAt.number !== indexedNumber)\n throw new Error(\"Payment note confirmation block mismatch\");\n const result = await rpc.getNote(protocol.context, data.commitment, checkedAt);\n if (!result) throw new Error(\"Payment note is not indexed at the requested confirmed block\");\n const { output, membership } = result;\n if (\n output.commitment !== data.commitment ||\n getAddress(output.tokenAddress) !== getAddress(data.tokenAddress) ||\n membership.leaf !== data.commitment ||\n membership.treeId !== output.treeId ||\n membership.leafIndex !== output.leafIndex ||\n membership.block.number > checkedAt.number ||\n output.block.number > checkedAt.number ||\n membership.path.length !== TREE_DEPTH ||\n !Number.isSafeInteger(output.leafIndex) ||\n output.leafIndex < 0 ||\n output.leafIndex >= 2 ** TREE_DEPTH\n )\n throw new Error(\"Payment note membership metadata mismatch\");\n let root = BigInt(data.commitment);\n for (let level = 0; level < membership.path.length; level++) {\n const sibling = membership.path[level]!;\n root = BigInt(\n await poseidonHash((output.leafIndex >> level) & 1 ? [sibling, root] : [root, sibling])\n );\n }\n if (\n root !== BigInt(membership.root) ||\n !(await reader.isKnownRoot(protocol.context, membership.treeId, membership.root, checkedAt))\n )\n throw new Error(\"Payment note membership root is not accepted on chain\");\n if (\n !sameBlock(output.block, await reader.getBlock(output.block.number)) ||\n !sameBlock(membership.block, await reader.getBlock(membership.block.number))\n )\n throw new Error(\"Payment note block is no longer canonical\");\n let spendabilityCheckedAt: CanonicalBlock | undefined;\n if (wallet) {\n // Spendability concerns current state, not just the confirmed historical anchor.\n const current = await reader.getBlock(await reader.getLatestBlockNumber());\n const nullifier = await computeNoteNullifier(data.chainId, data.nonce, data.commitment);\n const spent = await reader.isSpent(protocol.context, [nullifier], current);\n if (spent.length !== 1 || spent[0] !== false)\n throw new Error(\"Payment note is already spent\");\n if (\n !(await reader.isKnownRoot(\n protocol.context,\n membership.treeId,\n membership.root,\n current\n ))\n )\n throw new Error(\"Payment note membership root is no longer spendable\");\n if (!sameBlock(current, await reader.getBlock(current.number)))\n throw new Error(\"Spendability block reorganized\");\n spendabilityCheckedAt = current;\n }\n if (!sameBlock(checkedAt, await reader.getBlock(checkedAt.number)))\n throw new Error(\"Payment note verification block reorganized\");\n return {\n input: {\n note: asNote(data),\n commitment: data.commitment,\n treeId: output.treeId,\n leafIndex: output.leafIndex,\n },\n membership,\n checkedAt,\n ...(spendabilityCheckedAt ? { spendabilityCheckedAt } : {}),\n };\n}\n"]}
1
+ {"version":3,"sources":["/Users/wx/Workspace/invisi-lab/invisi-sdk-ts/packages/sdk/dist/index.cjs","../src/index.ts","../src/disclosure/DisclosureVerifier.ts","../src/protocol/connections.ts","../src/protocol/Protocol.ts","../src/protocol/BroadcasterRegistry.ts","../src/protocol/ProtocolRpcClient.ts","../src/payment-note/PaymentNote.ts","../src/payment-note/verification.ts"],"names":["candidate","getAddress"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACpCA;AACI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,qDACG;AAiBP,uCAAsC;ADsBtC;AACA;AEZA,SAAS,KAAA,CAAM,KAAA,EAAgB,OAAA,EAAgC;AAC3D,EAAA,GAAA,CAAI,CAAC,KAAA,EAAO,MAAM,IAAI,KAAA,CAAM,OAAO,CAAA;AACvC;AAEA,SAAS,SAAA,CAAU,KAAA,EAAiD;AAChE,EAAA,KAAA,CAAM,qBAAA,CAAsB,IAAA,CAAK,KAAA,CAAM,eAAe,CAAA,EAAG,qCAAqC,CAAA;AAC9F,EAAA,KAAA;AAAA,IACI,OAAO,KAAA,CAAM,OAAA,IAAW,SAAA,GAAY,KAAA,CAAM,OAAA,EAAS,GAAA,GAAM,KAAA,CAAM,OAAA,EAAS,GAAA,GAAM,GAAA;AAAA,IAC9E;AAAA,EACJ,CAAA;AACA,EAAA,KAAA;AAAA,IACI,MAAA,CAAO,aAAA,CAAc,KAAA,CAAM,SAAS,EAAA,GAAK,KAAA,CAAM,UAAA,GAAa,EAAA,GAAK,KA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AAA;AAAA,MACP,MAAA,CAAO;AAAA,IACX,CAAA;AAAA,EACJ;AAAA,EACQ,IAAA,CAAA,EAAwB;AAC5B,IAAA,MAAM,EAAE,OAAA,EAAS,eAAA,EAAiB,YAAA,EAAc,MAAA,EAAQ,YAAA,EAAc,KAAA,EAAO,WAAW,EAAA,EACpF,IAAA;AACJ,IAAA,OAAO,EAAE,OAAA,EAAS,eAAA,EAAiB,YAAA,EAAc,MAAA,EAAQ,YAAA,EAAc,KAAA,EAAO,WAAW,CAAA;AAAA,EAC7F;AACJ,CAAA;AP+cA;AACA;ACzaA;AACI;AACA;AACA;AAAA;AD4aJ;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,oxFAAC","file":"/Users/wx/Workspace/invisi-lab/invisi-sdk-ts/packages/sdk/dist/index.cjs","sourcesContent":[null,"export {\n Detector,\n Disclosure,\n MAX_MEMO_BYTES,\n MissingCapabilityError,\n NullifierCapability,\n ViewingCapability,\n Wallet,\n computeCreditNullifier,\n creditPeriods,\n creditV1,\n decodeDeliveryHeader,\n decodeMemoText,\n encodeMemo,\n fundsV1,\n} from \"@invisi-labs/primitives\";\nexport type {\n Address,\n CreditDataV1,\n CreditDeliveryState,\n CreditState,\n CreditOpening,\n CreditPolicy,\n DisclosureExport,\n DisclosureOutput,\n DisclosureResult,\n FundsDataV1,\n Hex,\n Memo,\n Note,\n ReceivingKeys,\n} from \"@invisi-labs/primitives\";\nexport { RegistrationOperation } from \"@invisi-labs/rpc\";\nexport type {\n AddressRegistryOptions,\n ProtocolOptions,\n RegistryReader,\n TokenProtocol,\n TokenProtocolOptions,\n} from \"@invisi-labs/rpc\";\nexport type {\n CanonicalBlock,\n CanonicalReceipt,\n ChainReader,\n FactoryReader,\n Membership,\n ProtocolDataProvider,\n ProtocolDataStatus,\n ProtocolUpdateRange,\n RegistryContext,\n TransactionCall,\n TransactionContext,\n} from \"@invisi-labs/protocol\";\nexport type {\n AggregateMember,\n AggregatorCapability,\n ProofBundle,\n ProofStatement,\n Prover,\n ProverOptions,\n} from \"@invisi-labs/prover\";\nexport { Invisi } from \"./client/Invisi\";\nexport type { InvisiOptions, RegistrationPreparationOptions } from \"./client/Invisi\";\nexport { DisclosureVerifier } from \"./disclosure/DisclosureVerifier\";\nexport type {\n DisclosureEvidence,\n DisclosureReader,\n DisclosureReference,\n DisclosureVerifierOptions,\n VerifiedDisclosure,\n} from \"./disclosure/DisclosureVerifier\";\nexport { InvisiError } from \"./errors\";\nexport type { InvisiErrorCode, InvisiErrorDetails } from \"./errors\";\nexport { NoteOutput } from \"./notes/NoteOutput\";\nexport type { NoteOutputContext, PaymentRequest, NoteOutputRecipient } from \"./notes/NoteOutput\";\nexport { Protocol } from \"./protocol/Protocol\";\nexport type {\n RevokeCreditPreparation,\n CreateCreditPreparation,\n DrawCreditPreparation,\n FundingAuthorizationVerifier,\n FundingSigner,\n FundingSource,\n FundingTypedData,\n OperationAggregateMember,\n ShieldPreparation,\n UpdateCreditPreparation,\n TransactionExecution,\n TransactionProveOptions,\n TransferPreparation,\n} from \"./transactions/operation-types\";\n\nexport { MAX_UPDATE_BLOCKS, ProtocolRpcError } from \"@invisi-labs/rpc\";\nexport type {\n ProtocolDeployment,\n ProtocolRpcChain,\n ProtocolRpcClientOptions,\n ProtocolRpcConnectionOptions,\n ProtocolRpcReader,\n RegisteredReceivingAddress,\n} from \"@invisi-labs/rpc\";\nexport { AddressRegistry } from \"./protocol/AddressRegistry\";\nexport { BroadcasterRegistry } from \"./protocol/BroadcasterRegistry\";\nexport type {\n BroadcasterRegistration,\n BroadcasterRegistryOptions,\n RegisteredBroadcaster,\n} from \"./protocol/BroadcasterRegistry\";\nexport { ProtocolRpcClient } from \"./protocol/ProtocolRpcClient\";\n\nexport { PreparedTransaction } from \"./transactions/execution/PreparedTransaction\";\nexport type {\n CreditInput,\n ExplicitRevokeCreditPreparation,\n ExplicitCreateCreditPreparation,\n ExplicitDrawCreditPreparation,\n ExplicitShieldPreparation,\n ExplicitUpdateCreditPreparation,\n ExplicitTransferPreparation,\n NoteInput,\n TransactionIdentity,\n} from \"./transactions/explicit-types\";\n\nexport { getDocumentedGasReference } from \"@invisi-labs/protocol\";\nexport type { DocumentedGasReference, DocumentedGasShape } from \"@invisi-labs/protocol\";\n\nexport type { SigningRequest } from \"@invisi-labs/primitives\";\n\n// Stateless recovery for applications that supply canonical receipts without a wallet store.\nexport { decryptCandidates } from \"./discovery/discovery\";\nexport type { DeliveryEventLog, DiscoveredCredit, DiscoveredNote } from \"./discovery/discovery\";\nexport { readProtocolLogs } from \"./discovery/receipt-logs\";\n\nexport type {\n ProtocolCreditTransition,\n ProtocolNoteOutput,\n IndexedCreditState,\n ProtocolTransactionNoteUpdates,\n ProtocolTransactionCreditUpdates,\n} from \"@invisi-labs/rpc\";\n\nexport * from \"./broadcaster/index\";\n\nexport type {\n BroadcasterFeeSource,\n BroadcasterQuoteOptions,\n} from \"./broadcaster/broadcaster-preparation\";\n\nexport { encodePaymentRequest, decodePaymentRequest } from \"./payment-request/codec\";\nexport type { NoteOutputExecutionOptions } from \"./payment-request/types\";\n\nexport { PaymentNote, VerifiedPaymentNote, SpendablePaymentNote } from \"./payment-note/PaymentNote\";\nexport { encodePaymentNote, decodePaymentNote } from \"./payment-note/codec\";\nexport type { PaymentNoteData } from \"./payment-note/types\";\nexport type {\n PaymentNoteVerificationOptions,\n PaymentNoteVerificationSettings,\n} from \"./payment-note/verification\";\nexport { TransactionOutput } from \"./notes/TransactionOutput\";\n\nexport type { PreparedProvenanceCapability } from \"./broadcaster/provenance-preparation\";\n\nexport {\n authenticatedDecryptor,\n DeliveryDecryptionError,\n DeliveryAuthenticationError,\n} from \"@invisi-labs/primitives\";\nexport type {\n DeliveryDecryptor,\n DeliveryDecryptionResult,\n DeliveryDetectionCandidate,\n DeliveryDetectionBatch,\n} from \"@invisi-labs/primitives\";\n","import type { Hex } from \"@invisi-labs/protocol/contracts\";\nimport type { Provider } from \"ethers\";\nimport { readProtocolLogs } from \"../discovery/receipt-logs\";\nimport { EthersChainReader } from \"../integrations/ethers\";\n\nimport { Disclosure, type DisclosureOutput, type DisclosureResult } from \"@invisi-labs/primitives\";\nimport { TokenProtocol } from \"@invisi-labs/rpc\";\nimport { type CanonicalBlock, type ChainReader } from \"@invisi-labs/protocol\";\nimport { extractDeliveryCandidates } from \"../discovery/discovery\";\n\nexport interface DisclosureReference {\n transactionHash: Hex;\n treeId: bigint;\n leafIndex: number;\n role: \"funds\" | \"owner\" | \"spender\";\n}\n\nexport type DisclosureReader = Pick<\n ChainReader,\n \"getChainId\" | \"getCode\" | \"getReceipt\" | \"getBlock\" | \"getLatestBlockNumber\"\n>;\n\nexport interface DisclosureVerifierOptions {\n protocol: TokenProtocol;\n reader: DisclosureReader;\n /** Minimum confirmations including the inclusion block; defaults to one. */\n confirmations?: number;\n}\n\nexport interface DisclosureEvidence {\n reference: Readonly<DisclosureReference>;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureOutput>;\n}\n\nexport interface VerifiedDisclosure {\n result: DisclosureResult;\n block: Readonly<CanonicalBlock>;\n confirmations: bigint;\n output: Readonly<DisclosureReference & { commitment: Hex }>;\n}\n\nfunction check(value: unknown, message: string): asserts value {\n if (!value) throw new Error(message);\n}\n\nfunction reference(value: DisclosureReference): DisclosureReference {\n check(/^0x[0-9a-fA-F]{64}$/.test(value.transactionHash), \"invalid disclosure transaction hash\");\n check(\n typeof value.treeId === \"bigint\" && value.treeId > 0n && value.treeId < 1n << 64n,\n \"invalid disclosure tree ID\"\n );\n check(\n Number.isSafeInteger(value.leafIndex) && value.leafIndex >= 0 && value.leafIndex < 65536,\n \"invalid disclosure leaf index\"\n );\n check([\"funds\", \"owner\", \"spender\"].includes(value.role), \"invalid disclosure reference role\");\n return {\n transactionHash: value.transactionHash.toLowerCase() as Hex,\n treeId: value.treeId,\n leafIndex: value.leafIndex,\n role: value.role,\n };\n}\n\n/** Read-only verification against a trusted RPC and authenticated protocol deployment.\n * Results establish output content/inclusion at a block, not payer identity, spent state or wallet completeness.\n */\nexport class DisclosureVerifier {\n readonly #protocol: TokenProtocol;\n readonly #reader: DisclosureReader;\n readonly #confirmations: bigint;\n\n constructor(\n options:\n | DisclosureVerifierOptions\n | (Omit<DisclosureVerifierOptions, \"reader\"> & { provider: Provider })\n ) {\n const confirmations = options.confirmations ?? 1;\n check(\n Number.isSafeInteger(confirmations) && confirmations >= 1,\n \"invalid disclosure confirmations\"\n );\n this.#protocol = options.protocol;\n this.#reader =\n \"provider\" in options ? new EthersChainReader(options.provider) : options.reader;\n this.#confirmations = BigInt(confirmations);\n Object.freeze(this);\n }\n\n private async barrier(block: Readonly<CanonicalBlock>): Promise<bigint> {\n await this.#protocol.validateDeployment(this.#reader);\n const canonical = await this.#reader.getBlock(block.number);\n check(\n canonical.number === block.number &&\n canonical.hash.toLowerCase() === block.hash.toLowerCase(),\n \"disclosure canonical block changed; reorg verification required\"\n );\n const head = await this.#reader.getLatestBlockNumber();\n check(\n head >= block.number && head - block.number + 1n >= this.#confirmations,\n \"insufficient disclosure confirmations\"\n );\n check(\n (await this.#reader.getChainId()) === this.#protocol.context.chainId,\n \"disclosure chain changed during verification\"\n );\n return head - block.number + 1n;\n }\n\n /** Resolve the exact inserted output and its delivery from a successful canonical receipt. */\n async readOutput(value: DisclosureReference): Promise<DisclosureEvidence> {\n const selected = reference(value);\n await this.#protocol.validateDeployment(this.#reader);\n const received = await this.#reader.getReceipt(selected.transactionHash);\n check(received, \"disclosure transaction receipt is unavailable\");\n const receipt = structuredClone(received);\n check(receipt.status === \"success\", \"disclosure requires a successful transaction receipt\");\n check(\n receipt.transactionHash.toLowerCase() === selected.transactionHash,\n \"disclosure receipt transaction mismatch\"\n );\n check(\n typeof receipt.block.number === \"bigint\" &&\n receipt.block.number >= 0n &&\n /^0x[0-9a-fA-F]{64}$/.test(receipt.block.hash),\n \"invalid disclosure receipt block\"\n );\n const { context } = this.#protocol;\n const logs = readProtocolLogs(receipt, context.protocolAddress);\n const candidates = extractDeliveryCandidates(logs, context, receipt.block.number).filter(\n (candidate) =>\n candidate.treeId === selected.treeId &&\n candidate.leafIndex === selected.leafIndex &&\n candidate.role === selected.role &&\n candidate.tokenAddress.toLowerCase() === context.tokenAddress.toLowerCase()\n );\n check(\n candidates.length === 1,\n \"disclosure output has no unique canonical insertion and delivery\"\n );\n const candidate = candidates[0]!;\n const confirmations = await this.barrier(receipt.block);\n return Object.freeze({\n reference: Object.freeze(selected),\n block: Object.freeze({ ...receipt.block }),\n confirmations,\n output: Object.freeze({\n chainId: context.chainId,\n protocolAddress: BigInt(context.protocolAddress),\n tokenAddress: BigInt(context.tokenAddress),\n outputCommitment: candidate.commitment,\n role: selected.role,\n ciphertext: candidate.delivery.ciphertext,\n }),\n });\n }\n\n async verify(disclosure: Disclosure, value: DisclosureReference): Promise<VerifiedDisclosure> {\n const evidence = await this.readOutput(value);\n const result = await disclosure.verify(evidence.output);\n const confirmations = await this.barrier(evidence.block);\n return Object.freeze({\n result: Object.freeze(result),\n block: evidence.block,\n confirmations,\n output: Object.freeze({\n ...evidence.reference,\n commitment: evidence.output.outputCommitment,\n }),\n });\n }\n\n toJSON() {\n return { disclosureVerifier: true, confirmations: this.#confirmations.toString() };\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.toJSON();\n }\n}\n","import type { Protocol } from \"@invisi-labs/rpc\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\n\n/** Public network connections only; never holds wallet keys or a signer. */\nconst connections = new WeakMap<\n Protocol,\n { provider: Provider; protocolRpc: Pick<ProtocolRpcClient, \"withReader\"> }\n>();\nexport function rememberProtocolConnection(\n protocol: Protocol,\n provider: Provider,\n protocolRpc: Pick<ProtocolRpcClient, \"withReader\">\n): void {\n connections.set(protocol, { provider, protocolRpc });\n}\nexport function protocolConnection(protocol: Protocol) {\n return connections.get(protocol);\n}\n","import { rememberProtocolConnection } from \"./connections\";\nimport { Protocol as BaseProtocol } from \"@invisi-labs/rpc\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport { getAddress, type Provider } from \"ethers\";\nimport { BroadcasterClient } from \"../broadcaster/index\";\n\nconst sources = new WeakMap<Protocol, Pick<ProtocolRpcClient, \"getBroadcasters\">>();\n\n/** Deployment operations and transaction-compatible broadcaster discovery. */\nexport class Protocol extends BaseProtocol {\n static override async fromRpc(\n rpc: Pick<ProtocolRpcClient, \"getDeployment\"> &\n Partial<Pick<ProtocolRpcClient, \"getBroadcasters\" | \"withReader\">>,\n provider: Provider,\n options: { signal?: AbortSignal } = {}\n ): Promise<Protocol> {\n const verified = await BaseProtocol.fromRpc(rpc, provider, options);\n const protocol = new Protocol({ deployment: verified.deployment });\n if (rpc.getBroadcasters)\n sources.set(protocol, rpc as Pick<ProtocolRpcClient, \"getBroadcasters\">);\n if (rpc.withReader)\n rememberProtocolConnection(\n protocol,\n provider,\n rpc as Pick<ProtocolRpcClient, \"withReader\">\n );\n return protocol;\n }\n\n /** Discover token support without disclosing a transaction or requesting a price. */\n async getBroadcasters(options: {\n tokenAddress: string;\n signal?: AbortSignal;\n }): Promise<BroadcasterClient[]> {\n options.signal?.throwIfAborted();\n const token = getAddress(options.tokenAddress);\n if (BigInt(token) === 0n) throw Error(\"Invalid Broadcaster token address\");\n if (!this.deployment.broadcasterRegistry)\n throw new Error(\"broadcaster registry is not configured\");\n const rpc = sources.get(this);\n if (!rpc) throw new Error(\"broadcaster discovery requires Protocol.fromRpc\");\n const clients: BroadcasterClient[] = [];\n let after: `0x${string}` | undefined;\n let block: Awaited<ReturnType<ProtocolRpcClient[\"getBroadcasters\"]>>[\"block\"] | undefined;\n const seen = new Set<string>();\n do {\n options.signal?.throwIfAborted();\n const page = await rpc.getBroadcasters({\n enabled: true,\n limit: 100,\n ...(options.signal ? { signal: options.signal } : {}),\n ...(after ? { after } : {}),\n ...(block ? { block } : {}),\n });\n block ??= page.block;\n const compatible = await Promise.all(\n page.broadcasters.map(async (entry) => {\n if (!entry.enabled) return undefined;\n try {\n const client = new BroadcasterClient({\n endpoint: entry.endpoint,\n quoteSigner: entry.quoteSigner,\n feeRecipient: entry.feeRecipient,\n });\n if (\n !(await client.supportsToken(\n token,\n {\n chainId: this.context.chainId,\n protocol: this.context.protocolAddress,\n },\n options\n ))\n )\n return undefined;\n return client;\n } catch {\n options.signal?.throwIfAborted();\n return undefined;\n }\n })\n );\n options.signal?.throwIfAborted();\n clients.push(\n ...compatible.filter((client): client is BroadcasterClient => client !== undefined)\n );\n after = page.next;\n if (after && seen.has(after)) throw new Error(\"repeated broadcaster pagination cursor\");\n if (after) seen.add(after);\n } while (after);\n return clients;\n }\n}\n","import type { TransactionCall } from \"@invisi-labs/protocol\";\nimport { broadcasterRegistryAbi, type Address, type Hex } from \"@invisi-labs/protocol/contracts\";\nimport { getAddress, Interface, keccak256, type Provider } from \"ethers\";\n\nexport interface BroadcasterRegistration {\n endpoint: string;\n metadataURI?: string;\n quoteSigner: Address;\n feeRecipient: Address;\n}\n\nexport interface RegisteredBroadcaster extends Required<BroadcasterRegistration> {\n operator: Address;\n enabled: boolean;\n}\n\nexport interface BroadcasterRegistryOptions {\n provider: Provider;\n address: Address;\n chainId: bigint;\n fromBlock: number;\n runtimeCodeHash: string;\n /** Maximum blocks per getLogs request. Defaults to 2,000. */\n blockRange?: number;\n}\n\nconst abi = new Interface(broadcasterRegistryAbi);\n\nfunction address(value: string): Address {\n const normalized = getAddress(value) as Address;\n if (BigInt(normalized) === 0n) throw new Error(\"zero broadcaster address\");\n return normalized;\n}\n\n/** Optional on-chain discovery. Registry entries do not authorize spending or endorse operators. */\nexport class BroadcasterRegistry {\n readonly address: Address;\n readonly #options: Readonly<BroadcasterRegistryOptions>;\n\n constructor(options: BroadcasterRegistryOptions) {\n this.address = address(options.address);\n const blockRange = options.blockRange ?? 2_000;\n if (\n options.chainId <= 0n ||\n !Number.isSafeInteger(options.fromBlock) ||\n options.fromBlock < 0 ||\n !Number.isSafeInteger(blockRange) ||\n blockRange < 1 ||\n blockRange > 100_000 ||\n !/^0x[0-9a-fA-F]{64}$/.test(options.runtimeCodeHash)\n )\n throw new Error(\"invalid broadcaster registry configuration\");\n this.#options = Object.freeze({ ...options, blockRange });\n }\n\n prepareRegistration(registration: BroadcasterRegistration): TransactionCall {\n const { endpoint, metadataURI = \"\" } = registration;\n if (\n !endpoint.startsWith(\"https://\") ||\n endpoint.length <= 8 ||\n endpoint.length > 2048 ||\n /[^\\x21-\\x7e]/.test(endpoint)\n )\n throw new Error(\"broadcaster endpoint must be a printable HTTPS URI\");\n // Parse locally for a useful error; the registry additionally enforces its byte limits.\n const url = new URL(endpoint);\n if (!url.hostname || url.username || url.password) {\n throw new Error(\"broadcaster HTTPS endpoint must not include credentials\");\n }\n if (metadataURI.length > 2048 || /[^\\x21-\\x7e]/.test(metadataURI)) {\n throw new Error(\"invalid broadcaster metadata URI\");\n }\n return this.call(\"setBroadcaster\", [\n endpoint,\n metadataURI,\n address(registration.quoteSigner),\n address(registration.feeRecipient),\n ]);\n }\n\n prepareAvailability(enabled: boolean): TransactionCall {\n return this.call(\"setEnabled\", [enabled]);\n }\n\n private call(name: string, args: readonly unknown[]): TransactionCall {\n return { to: this.address, data: abi.encodeFunctionData(name, args) as Hex, value: 0n };\n }\n\n private async validate(): Promise<void> {\n const { provider, chainId, runtimeCodeHash } = this.#options;\n if ((await provider.getNetwork()).chainId !== chainId) {\n throw new Error(\"broadcaster registry chain mismatch\");\n }\n if (\n keccak256(await provider.getCode(this.address)).toLowerCase() !==\n runtimeCodeHash.toLowerCase()\n ) {\n throw new Error(\"broadcaster registry runtime code mismatch\");\n }\n }\n\n async get(operator: Address): Promise<RegisteredBroadcaster> {\n await this.validate();\n return this.read(address(operator));\n }\n\n private async read(operator: Address): Promise<RegisteredBroadcaster> {\n const result = await this.#options.provider.call(this.call(\"broadcasterOf\", [operator]));\n const [entry] = abi.decodeFunctionResult(\"broadcasterOf\", result);\n return {\n operator,\n endpoint: entry.endpoint,\n metadataURI: entry.metadataURI,\n quoteSigner: address(entry.quoteSigner),\n feeRecipient: address(entry.feeRecipient),\n enabled: entry.enabled,\n };\n }\n\n /** Discover event operators, then read their latest entry; disabled services remain explicit. */\n async discover(\n options: { toBlock?: number; signal?: AbortSignal } = {}\n ): Promise<RegisteredBroadcaster[]> {\n const { provider, fromBlock, blockRange } = this.#options;\n options.signal?.throwIfAborted();\n await this.validate();\n const toBlock = options.toBlock ?? (await provider.getBlockNumber());\n if (!Number.isSafeInteger(toBlock) || toBlock < fromBlock) {\n throw new Error(\"invalid broadcaster discovery block range\");\n }\n const operators = new Set<Address>();\n for (let start = fromBlock; start <= toBlock;) {\n options.signal?.throwIfAborted();\n const end = Math.min(start + blockRange! - 1, toBlock);\n const logs = await provider.getLogs({\n address: this.address,\n topics: [abi.getEvent(\"BroadcasterSet\")!.topicHash],\n fromBlock: start,\n toBlock: end,\n });\n for (const log of logs) {\n if (getAddress(log.address) !== this.address)\n throw new Error(\"registry event address mismatch\");\n const event = abi.parseLog(log);\n if (!event || event.name !== \"BroadcasterSet\")\n throw new Error(\"invalid registry event\");\n operators.add(address(event.args.operator));\n }\n start = end + 1;\n }\n const entries: RegisteredBroadcaster[] = [];\n for (const operator of operators) {\n options.signal?.throwIfAborted();\n entries.push(await this.read(operator));\n }\n return entries;\n }\n}\n","import { ProtocolRpcClient as RpcClient } from \"@invisi-labs/rpc\";\nimport type { Provider } from \"ethers\";\nimport { EthersChainReader } from \"../integrations/ethers\";\n\n/** Protocol RPC transport with ethers provider integration for independent chain checks. */\nexport class ProtocolRpcClient extends RpcClient {\n withProvider(provider: Provider): RpcClient {\n return this.withReader(new EthersChainReader(provider));\n }\n}\n","import { computeNoteIdentity, computeNoteCommitment, Wallet } from \"@invisi-labs/primitives\";\nimport type { Protocol } from \"@invisi-labs/rpc\";\nimport type { Membership, CanonicalBlock } from \"@invisi-labs/protocol\";\nimport type { NoteInput } from \"../transactions/explicit-types\";\nimport { decodePaymentNote, encodePaymentNote } from \"./codec\";\nimport type { PaymentNoteData } from \"./types\";\nimport {\n verifyPaymentNote,\n verificationOptions,\n type PaymentNoteVerificationSettings,\n type PaymentNoteVerificationOptions,\n} from \"./verification\";\n\nconst verification = Symbol(\"PaymentNote verification\");\nexport class VerifiedPaymentNote {\n readonly #membership: Membership;\n readonly #checkedAt: CanonicalBlock;\n constructor(token: symbol, membership: Membership, checkedAt: CanonicalBlock) {\n if (token !== verification) throw new Error(\"Payment note verification required\");\n this.#membership = structuredClone(membership);\n this.#checkedAt = structuredClone(checkedAt);\n }\n get membership(): Membership {\n return structuredClone(this.#membership);\n }\n get checkedAt(): CanonicalBlock {\n return structuredClone(this.#checkedAt);\n }\n}\nexport class SpendablePaymentNote extends VerifiedPaymentNote {\n readonly #input: NoteInput;\n readonly #spendabilityCheckedAt: CanonicalBlock;\n constructor(\n token: symbol,\n input: NoteInput,\n membership: Membership,\n checkedAt: CanonicalBlock,\n spendabilityCheckedAt: CanonicalBlock\n ) {\n super(token, membership, checkedAt);\n this.#input = structuredClone(input);\n this.#spendabilityCheckedAt = structuredClone(spendabilityCheckedAt);\n Object.freeze(this);\n }\n get spendabilityCheckedAt(): CanonicalBlock {\n return structuredClone(this.#spendabilityCheckedAt);\n }\n toInput(): NoteInput {\n return structuredClone(this.#input);\n }\n}\n/** A validated Note opening, independent of an indexed wallet store. */\nexport class PaymentNote implements PaymentNoteData {\n readonly chainId: bigint;\n readonly protocolAddress: PaymentNoteData[\"protocolAddress\"];\n readonly tokenAddress: PaymentNoteData[\"tokenAddress\"];\n readonly amount: bigint;\n readonly ownerAddress: PaymentNoteData[\"ownerAddress\"];\n readonly nonce: bigint;\n readonly commitment: PaymentNoteData[\"commitment\"];\n readonly ipn: string;\n private constructor(data: PaymentNoteData, ipn: string) {\n this.chainId = data.chainId;\n this.protocolAddress = data.protocolAddress;\n this.tokenAddress = data.tokenAddress;\n this.amount = data.amount;\n this.ownerAddress = data.ownerAddress;\n this.nonce = data.nonce;\n this.commitment = data.commitment;\n this.ipn = ipn;\n Object.freeze(this);\n }\n static async from(ipn: string): Promise<PaymentNote> {\n const data = decodePaymentNote(ipn);\n const identity = await computeNoteIdentity(BigInt(data.ownerAddress), data.nonce);\n const commitment = await computeNoteCommitment(\n data.chainId,\n BigInt(data.protocolAddress),\n identity,\n BigInt(data.tokenAddress),\n data.amount\n );\n if (commitment !== data.commitment) throw new Error(\"Payment note commitment mismatch\");\n return new PaymentNote(data, encodePaymentNote(data));\n }\n async verify(\n protocol: Protocol,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n ): Promise<VerifiedPaymentNote> {\n const result = await verifyPaymentNote(\n this.data(),\n protocol,\n verificationOptions(protocol, options)\n );\n const verified = new VerifiedPaymentNote(verification, result.membership, result.checkedAt);\n Object.freeze(verified);\n return verified;\n }\n async verifySpendable(\n protocol: Protocol,\n wallet: Wallet,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n ): Promise<SpendablePaymentNote> {\n if (!(wallet instanceof Wallet)) throw new Error(\"A public Wallet is required\");\n const result = await verifyPaymentNote(\n this.data(),\n protocol,\n verificationOptions(protocol, options),\n wallet\n );\n return new SpendablePaymentNote(\n verification,\n result.input,\n result.membership,\n result.checkedAt,\n result.spendabilityCheckedAt!\n );\n }\n private data(): PaymentNoteData {\n const { chainId, protocolAddress, tokenAddress, amount, ownerAddress, nonce, commitment } =\n this;\n return { chainId, protocolAddress, tokenAddress, amount, ownerAddress, nonce, commitment };\n }\n}\n","import { protocolConnection } from \"../protocol/connections\";\nimport {\n poseidonHash,\n TREE_DEPTH,\n type Wallet,\n type Note,\n computeNoteNullifier,\n} from \"@invisi-labs/primitives\";\nimport type { CanonicalBlock, ChainReader, Membership } from \"@invisi-labs/protocol\";\nimport type { Protocol } from \"@invisi-labs/rpc\";\nimport type { ProtocolRpcClient } from \"@invisi-labs/rpc\";\nimport { getAddress, type Provider } from \"ethers\";\nimport { EthersChainReader } from \"../integrations/ethers\";\nimport type { NoteInput } from \"../transactions/explicit-types\";\nimport type { PaymentNoteData } from \"./types\";\n\n/** Supply connections for manually constructed Protocols; fromRpc connections are reused. */\nexport type PaymentNoteVerificationOptions = {\n protocolRpc: Pick<ProtocolRpcClient, \"withReader\">;\n confirmations?: number;\n} & ({ provider: Provider; chainReader?: never } | { chainReader: ChainReader; provider?: never });\n\nexport type PaymentNoteVerificationSettings = { confirmations?: number };\nexport function verificationOptions(\n protocol: Protocol,\n options: PaymentNoteVerificationOptions | PaymentNoteVerificationSettings = {}\n): PaymentNoteVerificationOptions {\n const connected = protocolConnection(protocol);\n const resolved = { ...connected, ...options };\n if (\n !(\"protocolRpc\" in resolved) ||\n !resolved.protocolRpc ||\n (!(\"chainReader\" in resolved) && !(\"provider\" in resolved))\n )\n throw new Error(\n \"Payment note verification requires Protocol.fromRpc or explicit chain and Protocol RPC connections\"\n );\n return resolved as PaymentNoteVerificationOptions;\n}\n\nfunction sameBlock(a: CanonicalBlock, b: CanonicalBlock): boolean {\n return (\n a.number === b.number &&\n a.hash === b.hash &&\n a.parentHash === b.parentHash &&\n a.timestamp === b.timestamp\n );\n}\nexport function asNote(data: PaymentNoteData): Note {\n return {\n chainId: data.chainId,\n protocolAddress: BigInt(data.protocolAddress),\n tokenAddress: BigInt(data.tokenAddress),\n amount: data.amount,\n ownerAddress: data.ownerAddress,\n nonce: data.nonce,\n };\n}\nexport async function verifyPaymentNote(\n data: PaymentNoteData,\n protocol: Protocol,\n options: PaymentNoteVerificationOptions,\n wallet?: Wallet\n): Promise<{\n input: NoteInput;\n membership: Membership;\n checkedAt: CanonicalBlock;\n spendabilityCheckedAt?: CanonicalBlock;\n}> {\n if (\n data.chainId !== protocol.context.chainId ||\n getAddress(data.protocolAddress) !== getAddress(protocol.context.protocolAddress)\n )\n throw new Error(\"Payment note protocol context mismatch\");\n const confirmations = options.confirmations ?? 1;\n if (!Number.isSafeInteger(confirmations) || confirmations < 1)\n throw new RangeError(\"confirmations must be positive\");\n const reader = options.chainReader ?? new EthersChainReader(options.provider!);\n await protocol.validateDeployment(reader);\n if (wallet && getAddress(wallet.ownerAddress) !== getAddress(data.ownerAddress))\n throw new Error(\"Payment note owner mismatch\");\n const latest = await reader.getLatestBlockNumber();\n const number = latest - BigInt(confirmations - 1);\n if (number < protocol.deployment.protocol.fromBlock)\n throw new Error(\"Insufficient confirmed blocks\");\n const rpc = options.protocolRpc.withReader(reader);\n const status = await rpc.getStatus(protocol.context);\n if (!status.indexedHead) throw new Error(\"Protocol RPC has no indexed blocks\");\n const indexedNumber = status.indexedHead.number < number ? status.indexedHead.number : number;\n if (indexedNumber < protocol.deployment.protocol.fromBlock)\n throw new Error(\"Protocol RPC has not reached the deployment\");\n const checkedAt = await reader.getBlock(indexedNumber);\n if (checkedAt.number !== indexedNumber)\n throw new Error(\"Payment note confirmation block mismatch\");\n const result = await rpc.getNote(protocol.context, data.commitment, checkedAt);\n if (!result) throw new Error(\"Payment note is not indexed at the requested confirmed block\");\n const { output, membership } = result;\n if (\n output.commitment !== data.commitment ||\n getAddress(output.tokenAddress) !== getAddress(data.tokenAddress) ||\n membership.leaf !== data.commitment ||\n membership.treeId !== output.treeId ||\n membership.leafIndex !== output.leafIndex ||\n membership.block.number > checkedAt.number ||\n output.block.number > checkedAt.number ||\n membership.path.length !== TREE_DEPTH ||\n !Number.isSafeInteger(output.leafIndex) ||\n output.leafIndex < 0 ||\n output.leafIndex >= 2 ** TREE_DEPTH\n )\n throw new Error(\"Payment note membership metadata mismatch\");\n let root = BigInt(data.commitment);\n for (let level = 0; level < membership.path.length; level++) {\n const sibling = membership.path[level]!;\n root = BigInt(\n await poseidonHash((output.leafIndex >> level) & 1 ? [sibling, root] : [root, sibling])\n );\n }\n if (\n root !== BigInt(membership.root) ||\n !(await reader.isKnownRoot(protocol.context, membership.treeId, membership.root, checkedAt))\n )\n throw new Error(\"Payment note membership root is not accepted on chain\");\n if (\n !sameBlock(output.block, await reader.getBlock(output.block.number)) ||\n !sameBlock(membership.block, await reader.getBlock(membership.block.number))\n )\n throw new Error(\"Payment note block is no longer canonical\");\n let spendabilityCheckedAt: CanonicalBlock | undefined;\n if (wallet) {\n // Spendability concerns current state, not just the confirmed historical anchor.\n const current = await reader.getBlock(await reader.getLatestBlockNumber());\n const nullifier = await computeNoteNullifier(\n data.chainId,\n BigInt(data.protocolAddress),\n data.nonce,\n data.commitment\n );\n const spent = await reader.isSpent(protocol.context, [nullifier], current);\n if (spent.length !== 1 || spent[0] !== false)\n throw new Error(\"Payment note is already spent\");\n if (\n !(await reader.isKnownRoot(\n protocol.context,\n membership.treeId,\n membership.root,\n current\n ))\n )\n throw new Error(\"Payment note membership root is no longer spendable\");\n if (!sameBlock(current, await reader.getBlock(current.number)))\n throw new Error(\"Spendability block reorganized\");\n spendabilityCheckedAt = current;\n }\n if (!sameBlock(checkedAt, await reader.getBlock(checkedAt.number)))\n throw new Error(\"Payment note verification block reorganized\");\n return {\n input: {\n note: asNote(data),\n commitment: data.commitment,\n treeId: output.treeId,\n leafIndex: output.leafIndex,\n },\n membership,\n checkedAt,\n ...(spendabilityCheckedAt ? { spendabilityCheckedAt } : {}),\n };\n}\n"]}