@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/indexeddb.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TransactionalWalletStore
3
- } from "./chunk-7TFLU2Z6.js";
3
+ } from "./chunk-Z6NDXVBL.js";
4
4
  import "./chunk-4HMM7ZKY.js";
5
5
 
6
6
  // src/integrations/indexeddb.ts
package/dist/memory.cjs CHANGED
@@ -516,25 +516,27 @@ function extractDeliveryCandidates(logs, context, confirmedThrough) {
516
516
  const tokens = array(a.tokens);
517
517
  const cs = array(a.commitments), tree = integer(a.treeId), start = index(a.startLeafIndex), packed = a.packedDeliveries;
518
518
  check2(
519
- typeof packed === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(packed) && packed.length === 2 + 452 * cs.length,
519
+ typeof packed === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(packed),
520
520
  "invalid packed deliveries"
521
521
  );
522
522
  check2(tokens.length === cs.length, "batch token count mismatch");
523
+ check2(start + cs.length <= 65536, "batch exceeds tree capacity");
524
+ let offset = 2;
523
525
  cs.forEach((c, i) => {
524
- const segment = packed.slice(2 + 452 * i, 2 + 452 * (i + 1));
525
- add(
526
- log,
527
- tree,
528
- start + i,
529
- c,
530
- "funds",
531
- {
532
- ciphertext: `0x${segment.slice(0, 316)}`,
533
- clue: `0x${segment.slice(316)}`
534
- },
535
- tokens[i]
526
+ check2(offset + 4 <= packed.length, "truncated delivery length prefix");
527
+ const length = Number.parseInt(packed.slice(offset, offset + 4), 16);
528
+ offset += 4;
529
+ check2(
530
+ length >= 160 && length <= 416 && offset + length * 2 + 136 <= packed.length,
531
+ "invalid packed delivery length"
536
532
  );
533
+ const ciphertext = `0x${packed.slice(offset, offset + length * 2)}`;
534
+ offset += length * 2;
535
+ const clue = `0x${packed.slice(offset, offset + 136)}`;
536
+ offset += 136;
537
+ add(log, tree, start + i, c, "funds", { ciphertext, clue }, tokens[i]);
537
538
  });
539
+ check2(offset === packed.length, "trailing packed delivery bytes");
538
540
  } else if (log.eventName === "CreditCreated") creation(log, a, a);
539
541
  else if (log.eventName === "CreditToppedUp")
540
542
  creation(log, a, object(object(a.params).creation));
@@ -3146,6 +3148,7 @@ var Preparation = class {
3146
3148
  const recipient = await import_core8.ReceivingAddress.parse(payment.to).resolve(
3147
3149
  this.runtime.options.addressResolver
3148
3150
  );
3151
+ const memo = (0, import_core8.encodeMemo)(payment.memo);
3149
3152
  const nonce = (0, import_core8.generateNonce)();
3150
3153
  const identity = await (0, import_core8.computeNoteIdentity)(BigInt(recipient.walletIdentity), nonce);
3151
3154
  const keys = recipient.getReceivingKeys();
@@ -3155,6 +3158,7 @@ var Preparation = class {
3155
3158
  tokenAddress: BigInt(context.tokenAddress),
3156
3159
  walletIdentity: recipient.walletIdentity,
3157
3160
  amount: payment.amount,
3161
+ ...memo.length === 0 ? {} : { memo },
3158
3162
  nonce
3159
3163
  };
3160
3164
  const commitment = await (0, import_core8.computeNoteCommitment)(
@@ -3390,6 +3394,7 @@ var CreditPreparation = class {
3390
3394
  ownerPayout: BigInt(ownerPayout),
3391
3395
  spenderPayout: BigInt(spenderPayout),
3392
3396
  amount: options.amount,
3397
+ ...options.memo === void 0 ? {} : { memo: options.memo },
3393
3398
  expiry,
3394
3399
  nonce: (0, import_core9.generateNonce)(),
3395
3400
  creditSharedKey: (0, import_core9.generateCreditSharedKey)()
@@ -3481,7 +3486,16 @@ var CreditPreparation = class {
3481
3486
  }
3482
3487
  const amount = positiveAmount(old.note.amount + options.additionalAmount, 126);
3483
3488
  const output = await this.seal(
3484
- { ...old, note: { ...old.note, amount, expiry, nonce: (0, import_core9.generateNonce)() } },
3489
+ {
3490
+ ...old,
3491
+ note: {
3492
+ ...old.note,
3493
+ amount,
3494
+ expiry,
3495
+ nonce: (0, import_core9.generateNonce)(),
3496
+ ...options.memo === void 0 ? {} : { memo: options.memo }
3497
+ }
3498
+ },
3485
3499
  frame
3486
3500
  );
3487
3501
  return this.creation(
@@ -3547,6 +3561,7 @@ var CreditPreparation = class {
3547
3561
  note: {
3548
3562
  ...n,
3549
3563
  amount: remaining,
3564
+ ...options.credits[i].memo === void 0 ? {} : { memo: options.credits[i].memo },
3550
3565
  nonce: await (0, import_core9.deriveRemainderNonce)(...args)
3551
3566
  }
3552
3567
  },
@@ -4016,6 +4031,10 @@ var InventoryProcessor = class {
4016
4031
  if (!remainder) {
4017
4032
  continue;
4018
4033
  }
4034
+ const child = foundByKey.get(
4035
+ params.remainderCommitments[index2] + ":" + previous.role
4036
+ );
4037
+ const memo = child?.state.note.memo;
4019
4038
  const record = {
4020
4039
  commitment: params.remainderCommitments[index2],
4021
4040
  treeId: BigInt(args.outputTreeId),
@@ -4024,7 +4043,13 @@ var InventoryProcessor = class {
4024
4043
  blockHash: event.blockHash,
4025
4044
  transactionHash: event.transactionHash,
4026
4045
  role: previous.role,
4027
- state: { ...clone(previous.state), note: remainder },
4046
+ state: {
4047
+ ...clone(previous.state),
4048
+ note: {
4049
+ ...remainder,
4050
+ ...memo === void 0 ? {} : { memo: (0, import_core10.encodeMemo)(memo) }
4051
+ }
4052
+ },
4028
4053
  receivingKeySource: { kind: "draw", commitment: previous.commitment },
4029
4054
  spent: "unknown"
4030
4055
  };