@invisi-labs/sdk 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/memory.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MemoryAtomicRecords,
3
3
  MemoryWalletStore
4
- } from "./chunk-7TFLU2Z6.js";
4
+ } from "./chunk-Z6NDXVBL.js";
5
5
  import "./chunk-4HMM7ZKY.js";
6
6
  export {
7
7
  MemoryAtomicRecords,
package/dist/sqlite.cjs CHANGED
@@ -466,25 +466,27 @@ function extractDeliveryCandidates(logs, context, confirmedThrough) {
466
466
  const tokens = array(a.tokens);
467
467
  const cs = array(a.commitments), tree = integer(a.treeId), start = index(a.startLeafIndex), packed = a.packedDeliveries;
468
468
  check2(
469
- typeof packed === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(packed) && packed.length === 2 + 452 * cs.length,
469
+ typeof packed === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(packed),
470
470
  "invalid packed deliveries"
471
471
  );
472
472
  check2(tokens.length === cs.length, "batch token count mismatch");
473
+ check2(start + cs.length <= 65536, "batch exceeds tree capacity");
474
+ let offset = 2;
473
475
  cs.forEach((c, i) => {
474
- const segment = packed.slice(2 + 452 * i, 2 + 452 * (i + 1));
475
- add(
476
- log,
477
- tree,
478
- start + i,
479
- c,
480
- "funds",
481
- {
482
- ciphertext: `0x${segment.slice(0, 316)}`,
483
- clue: `0x${segment.slice(316)}`
484
- },
485
- tokens[i]
476
+ check2(offset + 4 <= packed.length, "truncated delivery length prefix");
477
+ const length = Number.parseInt(packed.slice(offset, offset + 4), 16);
478
+ offset += 4;
479
+ check2(
480
+ length >= 160 && length <= 416 && offset + length * 2 + 136 <= packed.length,
481
+ "invalid packed delivery length"
486
482
  );
483
+ const ciphertext = `0x${packed.slice(offset, offset + length * 2)}`;
484
+ offset += length * 2;
485
+ const clue = `0x${packed.slice(offset, offset + 136)}`;
486
+ offset += 136;
487
+ add(log, tree, start + i, c, "funds", { ciphertext, clue }, tokens[i]);
487
488
  });
489
+ check2(offset === packed.length, "trailing packed delivery bytes");
488
490
  } else if (log.eventName === "CreditCreated") creation(log, a, a);
489
491
  else if (log.eventName === "CreditToppedUp")
490
492
  creation(log, a, object(object(a.params).creation));
@@ -3084,6 +3086,7 @@ var Preparation = class {
3084
3086
  const recipient = await import_core8.ReceivingAddress.parse(payment.to).resolve(
3085
3087
  this.runtime.options.addressResolver
3086
3088
  );
3089
+ const memo = (0, import_core8.encodeMemo)(payment.memo);
3087
3090
  const nonce = (0, import_core8.generateNonce)();
3088
3091
  const identity = await (0, import_core8.computeNoteIdentity)(BigInt(recipient.walletIdentity), nonce);
3089
3092
  const keys = recipient.getReceivingKeys();
@@ -3093,6 +3096,7 @@ var Preparation = class {
3093
3096
  tokenAddress: BigInt(context.tokenAddress),
3094
3097
  walletIdentity: recipient.walletIdentity,
3095
3098
  amount: payment.amount,
3099
+ ...memo.length === 0 ? {} : { memo },
3096
3100
  nonce
3097
3101
  };
3098
3102
  const commitment = await (0, import_core8.computeNoteCommitment)(
@@ -3328,6 +3332,7 @@ var CreditPreparation = class {
3328
3332
  ownerPayout: BigInt(ownerPayout),
3329
3333
  spenderPayout: BigInt(spenderPayout),
3330
3334
  amount: options.amount,
3335
+ ...options.memo === void 0 ? {} : { memo: options.memo },
3331
3336
  expiry,
3332
3337
  nonce: (0, import_core9.generateNonce)(),
3333
3338
  creditSharedKey: (0, import_core9.generateCreditSharedKey)()
@@ -3419,7 +3424,16 @@ var CreditPreparation = class {
3419
3424
  }
3420
3425
  const amount = positiveAmount(old.note.amount + options.additionalAmount, 126);
3421
3426
  const output = await this.seal(
3422
- { ...old, note: { ...old.note, amount, expiry, nonce: (0, import_core9.generateNonce)() } },
3427
+ {
3428
+ ...old,
3429
+ note: {
3430
+ ...old.note,
3431
+ amount,
3432
+ expiry,
3433
+ nonce: (0, import_core9.generateNonce)(),
3434
+ ...options.memo === void 0 ? {} : { memo: options.memo }
3435
+ }
3436
+ },
3423
3437
  frame
3424
3438
  );
3425
3439
  return this.creation(
@@ -3485,6 +3499,7 @@ var CreditPreparation = class {
3485
3499
  note: {
3486
3500
  ...n,
3487
3501
  amount: remaining,
3502
+ ...options.credits[i].memo === void 0 ? {} : { memo: options.credits[i].memo },
3488
3503
  nonce: await (0, import_core9.deriveRemainderNonce)(...args)
3489
3504
  }
3490
3505
  },
@@ -3954,6 +3969,10 @@ var InventoryProcessor = class {
3954
3969
  if (!remainder) {
3955
3970
  continue;
3956
3971
  }
3972
+ const child = foundByKey.get(
3973
+ params.remainderCommitments[index2] + ":" + previous.role
3974
+ );
3975
+ const memo = child?.state.note.memo;
3957
3976
  const record = {
3958
3977
  commitment: params.remainderCommitments[index2],
3959
3978
  treeId: BigInt(args.outputTreeId),
@@ -3962,7 +3981,13 @@ var InventoryProcessor = class {
3962
3981
  blockHash: event.blockHash,
3963
3982
  transactionHash: event.transactionHash,
3964
3983
  role: previous.role,
3965
- state: { ...clone(previous.state), note: remainder },
3984
+ state: {
3985
+ ...clone(previous.state),
3986
+ note: {
3987
+ ...remainder,
3988
+ ...memo === void 0 ? {} : { memo: (0, import_core10.encodeMemo)(memo) }
3989
+ }
3990
+ },
3966
3991
  receivingKeySource: { kind: "draw", commitment: previous.commitment },
3967
3992
  spent: "unknown"
3968
3993
  };