@esseyonsui/sui-sdk-v3 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/config.d.ts +3 -0
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +1 -0
  4. package/dist/errors.d.ts +3 -1
  5. package/dist/errors.d.ts.map +1 -1
  6. package/dist/errors.js +5 -0
  7. package/dist/essey.d.ts +157 -131
  8. package/dist/essey.d.ts.map +1 -1
  9. package/dist/essey.js +641 -823
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/v3/collateral/bodies.d.ts +23 -14
  14. package/dist/v3/collateral/bodies.d.ts.map +1 -1
  15. package/dist/v3/collateral/bodies.js +42 -35
  16. package/dist/v3/collateral/ext.d.ts +18 -13
  17. package/dist/v3/collateral/ext.d.ts.map +1 -1
  18. package/dist/v3/collateral/ext.js +5 -6
  19. package/dist/v3/collateral/health.d.ts +16 -10
  20. package/dist/v3/collateral/health.d.ts.map +1 -1
  21. package/dist/v3/collateral/health.js +55 -30
  22. package/dist/v3/collateral/math.d.ts +0 -2
  23. package/dist/v3/collateral/math.d.ts.map +1 -1
  24. package/dist/v3/collateral/math.js +0 -5
  25. package/dist/v3/collateral/openings.d.ts +5 -1
  26. package/dist/v3/collateral/openings.d.ts.map +1 -1
  27. package/dist/v3/collateral/openings.js +7 -12
  28. package/dist/v3/credential/membership.d.ts +16 -2
  29. package/dist/v3/credential/membership.d.ts.map +1 -1
  30. package/dist/v3/credential/membership.js +36 -3
  31. package/dist/v3/domains.d.ts +9 -0
  32. package/dist/v3/domains.d.ts.map +1 -1
  33. package/dist/v3/domains.js +5 -0
  34. package/dist/v3/fees.d.ts +13 -1
  35. package/dist/v3/fees.d.ts.map +1 -1
  36. package/dist/v3/fees.js +32 -2
  37. package/dist/v3/funds.d.ts +34 -0
  38. package/dist/v3/funds.d.ts.map +1 -0
  39. package/dist/v3/funds.js +60 -0
  40. package/dist/v3/keeper-payload.d.ts +29 -7
  41. package/dist/v3/keeper-payload.d.ts.map +1 -1
  42. package/dist/v3/keeper-payload.js +33 -22
  43. package/dist/v3/kinds.d.ts +6 -6
  44. package/dist/v3/kinds.d.ts.map +1 -1
  45. package/dist/v3/kinds.js +5 -13
  46. package/dist/v3/loans/bodies.d.ts +40 -68
  47. package/dist/v3/loans/bodies.d.ts.map +1 -1
  48. package/dist/v3/loans/bodies.js +50 -73
  49. package/dist/v3/loans/offer-payload.d.ts +109 -0
  50. package/dist/v3/loans/offer-payload.d.ts.map +1 -0
  51. package/dist/v3/loans/offer-payload.js +207 -0
  52. package/dist/v3/loans/offer-plan.d.ts +8 -60
  53. package/dist/v3/loans/offer-plan.d.ts.map +1 -1
  54. package/dist/v3/loans/offer-plan.js +19 -95
  55. package/dist/v3/loans/open-plan.d.ts +15 -5
  56. package/dist/v3/loans/open-plan.d.ts.map +1 -1
  57. package/dist/v3/loans/open-plan.js +18 -7
  58. package/dist/v3/loans/reclaim-plan.d.ts +31 -15
  59. package/dist/v3/loans/reclaim-plan.d.ts.map +1 -1
  60. package/dist/v3/loans/reclaim-plan.js +63 -32
  61. package/dist/v3/loans/refi-plan.d.ts +8 -34
  62. package/dist/v3/loans/refi-plan.d.ts.map +1 -1
  63. package/dist/v3/loans/refi-plan.js +30 -111
  64. package/dist/v3/loans/repay-plan.d.ts.map +1 -1
  65. package/dist/v3/loans/repay-plan.js +2 -2
  66. package/dist/v3/loans/settle-plan.d.ts +88 -53
  67. package/dist/v3/loans/settle-plan.d.ts.map +1 -1
  68. package/dist/v3/loans/settle-plan.js +141 -150
  69. package/dist/v3/locks.d.ts +21 -0
  70. package/dist/v3/locks.d.ts.map +1 -0
  71. package/dist/v3/locks.js +15 -0
  72. package/dist/v3/memo.d.ts +14 -4
  73. package/dist/v3/memo.d.ts.map +1 -1
  74. package/dist/v3/memo.js +14 -7
  75. package/dist/v3/notes/derive.d.ts +5 -0
  76. package/dist/v3/notes/derive.d.ts.map +1 -1
  77. package/dist/v3/notes/derive.js +5 -0
  78. package/dist/v3/pace.d.ts +0 -1
  79. package/dist/v3/pace.d.ts.map +1 -1
  80. package/dist/v3/pace.js +0 -1
  81. package/dist/v3/pads.d.ts +15 -0
  82. package/dist/v3/pads.d.ts.map +1 -0
  83. package/dist/v3/pads.js +25 -0
  84. package/dist/v3/prover.d.ts +1 -1
  85. package/dist/v3/prover.d.ts.map +1 -1
  86. package/dist/v3/prover.js +1 -0
  87. package/dist/v3/sales/auctioneer.d.ts +32 -27
  88. package/dist/v3/sales/auctioneer.d.ts.map +1 -1
  89. package/dist/v3/sales/auctioneer.js +67 -108
  90. package/dist/v3/sales/bid.d.ts +20 -49
  91. package/dist/v3/sales/bid.d.ts.map +1 -1
  92. package/dist/v3/sales/bid.js +28 -83
  93. package/dist/v3/sales/bodies.d.ts +4 -54
  94. package/dist/v3/sales/bodies.d.ts.map +1 -1
  95. package/dist/v3/sales/bodies.js +10 -52
  96. package/dist/v3/sales/claim.d.ts +0 -2
  97. package/dist/v3/sales/claim.d.ts.map +1 -1
  98. package/dist/v3/sales/claim.js +6 -8
  99. package/dist/v3/sales/index.d.ts +0 -1
  100. package/dist/v3/sales/index.d.ts.map +1 -1
  101. package/dist/v3/sales/index.js +0 -1
  102. package/dist/v3/sales/listing.d.ts +8 -6
  103. package/dist/v3/sales/listing.d.ts.map +1 -1
  104. package/dist/v3/sales/listing.js +27 -9
  105. package/dist/v3/sales/open-kind.d.ts +1 -3
  106. package/dist/v3/sales/open-kind.d.ts.map +1 -1
  107. package/dist/v3/sales/open-kind.js +2 -3
  108. package/dist/v3/sales/outcome.d.ts +5 -8
  109. package/dist/v3/sales/outcome.d.ts.map +1 -1
  110. package/dist/v3/sales/outcome.js +5 -9
  111. package/dist/v3/sales/package-gate.d.ts +3 -4
  112. package/dist/v3/sales/package-gate.d.ts.map +1 -1
  113. package/dist/v3/sales/package-gate.js +9 -7
  114. package/dist/v3/sales/rows.d.ts +9 -49
  115. package/dist/v3/sales/rows.d.ts.map +1 -1
  116. package/dist/v3/sales/rows.js +17 -91
  117. package/dist/v3/sales/seller.d.ts +2 -6
  118. package/dist/v3/sales/seller.d.ts.map +1 -1
  119. package/dist/v3/sales/seller.js +4 -11
  120. package/dist/v3/stage1.d.ts +8 -21
  121. package/dist/v3/stage1.d.ts.map +1 -1
  122. package/dist/v3/stage1.js +8 -76
  123. package/package.json +1 -1
  124. package/dist/v3/loans/lock-round.d.ts +0 -22
  125. package/dist/v3/loans/lock-round.d.ts.map +0 -1
  126. package/dist/v3/loans/lock-round.js +0 -20
  127. package/dist/v3/sales/reclaim.d.ts +0 -46
  128. package/dist/v3/sales/reclaim.d.ts.map +0 -1
  129. package/dist/v3/sales/reclaim.js +0 -57
@@ -1,54 +1,25 @@
1
- import { type FeeCommitInput } from "../fees.ts";
2
- import { type CircuitInput, type SpendNote } from "../inputs.ts";
1
+ import { type Payload, type Recovery } from "../loans/offer-payload.ts";
3
2
  import { type BidSecrets } from "./rows.ts";
4
- export type LockBidParams = {
5
- root: bigint;
6
- ins: [SpendNote, SpendNote];
7
- /** `id` is the SaleRoom object, `saleKey` its `sale_key`, `seq` the number of bids it already holds. */
8
- room: {
9
- id: string;
10
- saleKey: bigint;
11
- seq: number;
12
- postedCommit: bigint;
13
- };
14
- bid: BidSecrets;
15
- /** The amount of the change note is what conserves value; it is computed, never passed. */
16
- change: {
17
- pk: bigint;
18
- blinding: bigint;
19
- };
20
- relayer: string;
21
- relayerFee: bigint;
22
- /** The Seal object `sale_room::bid` pins. The proof binds its blake2b256. */
23
- sealed: Uint8Array;
24
- /** The proof binds it with `sealed` (`sale_room::ext_hash`). */
25
- memo: Uint8Array;
26
- /** `[enc_change, enc_fee]`. */
27
- encs: [Uint8Array, Uint8Array];
28
- fee: FeeCommitInput;
29
- eph: bigint;
30
- };
31
- /** Everything `sale_room::bid` takes besides the pass, the proof, `sealed`, the relayer and the ciphertexts. */
32
- export type LockBidStatement = {
33
- root: bigint;
34
- n0: bigint;
35
- n1: bigint;
36
- lock: bigint;
37
- change: bigint;
38
- feeNote: bigint;
39
- commit: bigint;
40
- ephX: bigint;
41
- ephY: bigint;
42
- feeCt: bigint;
43
- feeCommit: bigint;
3
+ export type BidLock = {
4
+ pk: bigint;
5
+ blinding: bigint;
6
+ payload: Payload;
7
+ recovery: Recovery;
8
+ secrets: BidSecrets;
44
9
  };
45
10
  /**
46
- * Witness for `circuits/v3/lock_bid/lock_bid.circom`.
47
- * Public signals, in order: hOuts, hCtx, root, publicAmount, extHash, n0, n1.
11
+ * PRV-28 B+C: a bid is a plain transfer into a Lock5 leaf under the room's `sale_key`, with keys from the reserved
12
+ * note index (Erik's condition 2). aux carries `amount_w`; `unlock_s` is the first grid second after `finish_by_ms`,
13
+ * so an on-time reclaim cannot race a finish (condition 4).
48
14
  */
49
- export declare function lockBid(p: LockBidParams): Promise<{
50
- input: CircuitInput;
51
- publics: bigint[];
52
- statement: LockBidStatement;
53
- }>;
15
+ export declare function bidLock(p: {
16
+ saleKey: bigint;
17
+ own: {
18
+ sk: bigint;
19
+ blinding: bigint;
20
+ };
21
+ noteIndex: number;
22
+ amount: bigint;
23
+ finishByMs: bigint;
24
+ }): BidLock;
54
25
  //# sourceMappingURL=bid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bid.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/bid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC5B,wGAAwG;IACxG,IA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AO,EAA2B,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAIjG,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAqBV"}
@@ -1,88 +1,33 @@
1
- import { poseidonHash } from "@mysten/sui/zklogin";
2
- import { R } from "../domains.js";
3
- import { feeWitness } from "../fee-witness.js";
4
- import { assertU64, feeLane } from "../fees.js";
5
- import { JS4_LEVELS } from "../inputs.js";
6
- import { noteCommitment, noteNullifier, notePk } from "../notes/keys.js";
7
- import { SLOTS, bidCommit, bidExt, lock4 } from "./rows.js";
1
+ import { assertU64 } from "../fees.js";
2
+ import { packAmount, unlockAfter } from "../loans/offer-payload.js";
3
+ import { lock5 } from "../locks.js";
4
+ import { notePk } from "../notes/keys.js";
5
+ import { bidSecrets } from "./rows.js";
8
6
  /**
9
- * Witness for `circuits/v3/lock_bid/lock_bid.circom`.
10
- * Public signals, in order: hOuts, hCtx, root, publicAmount, extHash, n0, n1.
7
+ * PRV-28 B+C: a bid is a plain transfer into a Lock5 leaf under the room's `sale_key`, with keys from the reserved
8
+ * note index (Erik's condition 2). aux carries `amount_w`; `unlock_s` is the first grid second after `finish_by_ms`,
9
+ * so an on-time reclaim cannot race a finish (condition 4).
11
10
  */
12
- export async function lockBid(p) {
13
- const { bid, room } = p;
14
- if (!Number.isInteger(room.seq) || room.seq < 0 || room.seq >= SLOTS)
15
- throw new Error("seq is not a bid slot");
16
- if (p.relayerFee > 0n && BigInt(p.relayer) === 0n)
17
- throw new Error("a relayer fee needs a relayer");
18
- assertU64("v", bid.v);
19
- assertU64("amount", bid.amount);
20
- if (bid.v > bid.amount)
21
- throw new Error("the deposit does not cover the bid");
22
- for (const note of p.ins)
23
- if (note.pathElements.length !== JS4_LEVELS)
24
- throw new Error("a spend needs 20 path elements");
25
- // Fee base 0 (E-21): the lane's fee is 0, so the balance line carries none.
26
- const lane = await feeLane({ ...p.fee, base: 0n, eph: p.eph });
27
- const chg = p.ins[0].amount + p.ins[1].amount - p.relayerFee - bid.amount;
28
- if (chg < 0n)
29
- throw new Error("inputs do not cover the deposit");
30
- const commitments = p.ins.map((n) => noteCommitment(n.amount, notePk(n.sk), n.blinding));
31
- const [n0, n1] = p.ins.map((n, i) => noteNullifier(commitments[i], n.sk, n.pathIndex));
32
- const ownerPk = notePk(bid.ownerSk);
33
- const commit = bidCommit(bid.v, bid.s);
34
- if (commit !== room.postedCommit)
35
- throw new Error("the bid is not the room's posted price (bid aborts 44_035)");
36
- const ext = bidExt({
37
- room: room.id,
38
- seq: room.seq,
39
- relayer: p.relayer,
40
- relayerFee: p.relayerFee,
41
- commit,
42
- sealed: p.sealed,
43
- memo: p.memo,
44
- encs: p.encs,
11
+ export function bidLock(p) {
12
+ assertU64("amount", p.amount);
13
+ if (p.amount === 0n)
14
+ throw new Error("the bid amount must be above 0");
15
+ const secrets = bidSecrets(p.own);
16
+ const ownerPk = notePk(secrets.ownerSk);
17
+ const unlockS = unlockAfter(p.finishByMs);
18
+ const { lockPk } = lock5({
19
+ field: p.saleKey,
20
+ ownerPk,
21
+ ns: secrets.ns,
22
+ amount: p.amount,
23
+ b: secrets.b,
24
+ unlockS,
45
25
  });
46
- const statement = {
47
- root: p.root,
48
- n0,
49
- n1,
50
- lock: lock4(room.saleKey, ownerPk, bid.ns, bid.amount, bid.b).lock,
51
- change: noteCommitment(chg, p.change.pk, p.change.blinding),
52
- feeNote: lane.fee_note,
53
- commit,
54
- ephX: lane.ephX,
55
- ephY: lane.ephY,
56
- feeCt: lane.fee_ct,
57
- feeCommit: lane.fee_commit,
26
+ return {
27
+ pk: lockPk,
28
+ blinding: secrets.b,
29
+ payload: { ownerPk, ns: secrets.ns, aux: packAmount(p.amount), unlockS },
30
+ recovery: { amount: p.amount, field: p.saleKey, unlockS, index: BigInt(p.noteIndex) },
31
+ secrets,
58
32
  };
59
- const s = statement;
60
- const hOuts = poseidonHash([s.lock, s.change, s.feeNote, commit, s.ephX, s.ephY, s.feeCt]);
61
- const hCtx = poseidonHash([room.saleKey, lane.fee_commit, p.relayerFee]);
62
- const publicAmount = p.relayerFee === 0n ? 0n : R - p.relayerFee;
63
- const input = {
64
- root: p.root.toString(),
65
- publicAmount: publicAmount.toString(),
66
- extHash: ext.toString(),
67
- n0: n0.toString(),
68
- n1: n1.toString(),
69
- inAmount: p.ins.map((n) => n.amount.toString()),
70
- inPrivateKey: p.ins.map((n) => n.sk.toString()),
71
- inBlinding: p.ins.map((n) => n.blinding.toString()),
72
- inPathIndices: p.ins.map((n) => n.pathIndex.toString()),
73
- inPathElements: p.ins.map((n) => n.pathElements.map(String)),
74
- amount: bid.amount.toString(),
75
- ownerPk: ownerPk.toString(),
76
- ns: bid.ns.toString(),
77
- b: bid.b.toString(),
78
- roomField: room.saleKey.toString(),
79
- v: bid.v.toString(),
80
- s: bid.s.toString(),
81
- chg: chg.toString(),
82
- pkC: p.change.pk.toString(),
83
- bC: p.change.blinding.toString(),
84
- relayer_fee: p.relayerFee.toString(),
85
- ...feeWitness(p.fee, 0n, p.eph, lane),
86
- };
87
- return { input, publics: [hOuts, hCtx, p.root, publicAmount, ext, n0, n1], statement };
88
33
  }
@@ -1,57 +1,19 @@
1
1
  import type { CoinKey } from "../../config.ts";
2
2
  import type { Proved, RelayBody } from "../bodies.ts";
3
- import { type DerivedKeys, type Pass } from "../body-args.ts";
3
+ import { type Pass } from "../body-args.ts";
4
4
  import type { SettleStatement } from "./auctioneer.ts";
5
- import type { LockBidStatement } from "./bid.ts";
6
- import type { ReclaimStatement } from "./reclaim.ts";
7
- export type BidBody = {
8
- pool: CoinKey;
9
- room: string;
10
- /** The bidder's spend pass over this room, bound to `statement.n0`. */
11
- pass: Omit<Pass, "n0">;
12
- proved: Proved;
13
- statement: LockBidStatement;
14
- sealed: Uint8Array;
15
- memo: Uint8Array;
16
- /** `[enc_change, enc_fee]`. */
17
- encs: [Uint8Array, Uint8Array];
18
- relayerFee: bigint;
19
- wait: boolean;
20
- };
21
- /** `sale_bid` (kinds/sale.ts): the pass proof, then the LockBid proof; pays the pool constant (`sale_room.move:317`). */
22
- export declare function bidBody(p: BidBody): RelayBody;
23
5
  export type FinishBody = {
24
6
  pool: CoinKey;
25
7
  room: string;
26
8
  vault: string;
27
9
  proved: Proved;
28
10
  statement: SettleStatement;
29
- /** `[seller note, fee note]`, the order `finish` hands `room_insert`. */
30
- encs: [Uint8Array, Uint8Array];
11
+ /** `[seller note, fee note, change, pad]`, the order `finish` hands `room_apply`. */
12
+ encs: Uint8Array[];
31
13
  wait: boolean;
32
14
  };
33
- /** `sale_finish` pays no relayer: SaleSettle binds relayer `@0x0` and fee 0 (`rows.move:13-16`). */
15
+ /** `sale_finish` pays no relayer: SaleSettle binds relayer `@0x0` and fee 0 (`rows::fold_settle_ctx`). */
34
16
  export declare function finishBody(p: FinishBody): RelayBody;
35
- export type PickBody = {
36
- pool: CoinKey;
37
- room: string;
38
- wait: boolean;
39
- };
40
- /**
41
- * `sale_pick`: `sale_room::pick` takes `Random` (0x8), so it must be the last call of its PTB and is relayed alone.
42
- * No proof, no pass, no fee: anyone may draw once bidding has closed.
43
- */
44
- export declare function pickBody(p: PickBody): RelayBody;
45
- /** `seq` must be the room's pick (44_039); a slash clears it, so `pick` draws again. */
46
- export type SlashBody = {
47
- pool: CoinKey;
48
- room: string;
49
- seq: bigint;
50
- keys: DerivedKeys;
51
- wait: boolean;
52
- };
53
- /** `sale_slash` takes no proof and pays no relayer: the derived keys of bid `seq` are the authorization. */
54
- export declare function slashBody(p: SlashBody): RelayBody;
55
17
  export type ExpireBody = {
56
18
  pool: CoinKey;
57
19
  room: string;
@@ -60,18 +22,6 @@ export type ExpireBody = {
60
22
  };
61
23
  /** `sale_expire`: permissionless once the finish window passed. */
62
24
  export declare function expireBody(p: ExpireBody): RelayBody;
63
- export type ReclaimBody = {
64
- pool: CoinKey;
65
- room: string;
66
- proved: Proved;
67
- statement: ReclaimStatement;
68
- /** `[out note, fee note]`. */
69
- encs: [Uint8Array, Uint8Array];
70
- relayerFee: bigint;
71
- wait: boolean;
72
- };
73
- /** `sale_reclaim` pays the pool constant (`sale_room.move:522`); the statement's relayer is the envelope's signer. */
74
- export declare function reclaimBody(p: ReclaimBody): RelayBody;
75
25
  export type ClaimBody = {
76
26
  pool: CoinKey;
77
27
  vault: string;
@@ -1 +1 @@
1
- {"version":3,"file":"bodies.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/bodies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,IAAI,EACV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQrD,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,I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AAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,qCAAqC;AACrC,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,CASnD"}
@@ -1,78 +1,36 @@
1
1
  import { address } from "../../network.js";
2
- import { bytesOf, encOf, envelope, fieldOf, keyArgs, passArgs, proofOf, u64Of, } from "../body-args.js";
2
+ import { encOf, envelope, fieldOf, invalid, passArgs, proofOf } from "../body-args.js";
3
3
  import { VK } from "../kinds.js";
4
- import { MEMO_LEN } from "./memo.js";
5
- /** `services/relayer-v3/src/field.ts` SEALED_REQ_MAX. */
6
- const SEALED_MAX = 1024;
7
4
  const fields = (rows) => Object.fromEntries(Object.entries(rows).map(([k, v]) => [k, fieldOf(v, k)]));
8
- /** `sale_bid` (kinds/sale.ts): the pass proof, then the LockBid proof; pays the pool constant (`sale_room.move:317`). */
9
- export function bidBody(p) {
10
- const { tag, expiryMs } = passArgs({ ...p.pass, n0: p.statement.n0 });
11
- return envelope("sale_bid", p.pool, [proofOf(VK.membership, p.pass.proved), proofOf(VK.lockBid, p.proved)], {
12
- room: address(p.room, "room"),
13
- tag,
14
- expiryMs,
15
- ...fields(p.statement),
16
- sealed: bytesOf(p.sealed, "sealed", 1, SEALED_MAX),
17
- memo: bytesOf(p.memo, "memo", MEMO_LEN, MEMO_LEN),
18
- encChange: encOf(p.encs[0], "encChange"),
19
- encFee: encOf(p.encs[1], "encFee"),
20
- }, p.relayerFee, p.wait);
21
- }
22
- /** `sale_finish` pays no relayer: SaleSettle binds relayer `@0x0` and fee 0 (`rows.move:13-16`). */
5
+ /** `sale_finish` pays no relayer: SaleSettle binds relayer `@0x0` and fee 0 (`rows::fold_settle_ctx`). */
23
6
  export function finishBody(p) {
24
7
  const s = p.statement;
8
+ if (p.encs?.length !== 4)
9
+ invalid("finish carries 4 encs in leaf order");
25
10
  return envelope("sale_finish", p.pool, [proofOf(VK.saleSettle, p.proved)], {
26
11
  room: address(p.room, "room"),
27
12
  vault: address(p.vault, "vault"),
28
13
  ...fields({
14
+ root: s.root,
15
+ nLock: s.n_lock,
16
+ nDummy: s.n_dummy,
29
17
  sellerOut: s.seller_out,
30
18
  feeOut: s.fee_out,
31
- residual: s.residual,
19
+ change: s.change,
32
20
  itemClaim: s.item_claim,
33
- winNull: s.win_null,
21
+ pad: s.pad,
34
22
  ephX: s.eph_x,
35
23
  ephY: s.eph_y,
36
24
  feeCt: s.fee_ct,
37
25
  feeCommit: s.fee_commit,
38
26
  }),
39
- encSeller: encOf(p.encs[0], "encSeller"),
40
- encFee: encOf(p.encs[1], "encFee"),
27
+ ...Object.fromEntries(p.encs.map((e, i) => [`enc${i}`, encOf(e, `enc${i}`)])),
41
28
  }, 0n, p.wait);
42
29
  }
43
- /**
44
- * `sale_pick`: `sale_room::pick` takes `Random` (0x8), so it must be the last call of its PTB and is relayed alone.
45
- * No proof, no pass, no fee: anyone may draw once bidding has closed.
46
- */
47
- export function pickBody(p) {
48
- return envelope("sale_pick", p.pool, [], { room: address(p.room, "room") }, 0n, p.wait);
49
- }
50
- /** `sale_slash` takes no proof and pays no relayer: the derived keys of bid `seq` are the authorization. */
51
- export function slashBody(p) {
52
- return envelope("sale_slash", p.pool, [], { room: address(p.room, "room"), seq: u64Of(p.seq, "seq"), ...keyArgs(p.keys) }, 0n, p.wait);
53
- }
54
30
  /** `sale_expire`: permissionless once the finish window passed. */
55
31
  export function expireBody(p) {
56
32
  return envelope("sale_expire", p.pool, [], { room: address(p.room, "room"), vault: address(p.vault, "vault") }, 0n, p.wait);
57
33
  }
58
- /** `sale_reclaim` pays the pool constant (`sale_room.move:522`); the statement's relayer is the envelope's signer. */
59
- export function reclaimBody(p) {
60
- const s = p.statement;
61
- return envelope("sale_reclaim", p.pool, [proofOf(VK.reclaim, p.proved)], {
62
- room: address(p.room, "room"),
63
- ...fields({
64
- nullifier: s.nullifier,
65
- outNote: s.out_note,
66
- feeCommit: s.fee_commit,
67
- ephX: s.eph_x,
68
- ephY: s.eph_y,
69
- feeCt: s.fee_ct,
70
- feeNote: s.fee_note,
71
- }),
72
- encOut: encOf(p.encs[0], "encOut"),
73
- encFee: encOf(p.encs[1], "encFee"),
74
- }, p.relayerFee, p.wait);
75
- }
76
34
  /** `sale_claim_item` pays no relayer. `nullifier` is the proof's second public signal (`vault.move:48-62`). */
77
35
  export function claimBody(p) {
78
36
  return envelope("sale_claim_item", p.pool, [proofOf(VK.itemClaim, p.proved)], {
@@ -1,8 +1,6 @@
1
1
  import type { CircuitInput } from "../inputs.ts";
2
2
  export declare const itemClaimCommit: (pk: bigint, salt: bigint) => bigint;
3
3
  export declare const winnerSalt: (ns: bigint) => bigint;
4
- /** C §4.6: the seller's claim after a settlement with no winner. */
5
- export declare const noWinnerSalt: (sellerSecret: bigint, roomField: bigint) => bigint;
6
4
  /** C §4.5: the salt of `seller_item_fallback`, the claim `expire` and `cancel` set. */
7
5
  export declare const fallbackSalt: (sellerSecret: bigint) => bigint;
8
6
  export type ClaimHolder = {
@@ -1 +1 @@
1
- {"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/claim.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,EAAE,MAAM,MAAM,KAAG,MAA4C,CAAC;AAExG,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,KAAG,MAAuC,CAAC;AAEhF,oEAAoE;AACpE,eAAO,MAAM,YAAY,GAAI,cAAc,MAAM,EAAE,WAAW,MAAM,KAAG,MACnB,CAAC;AAErD,uFAAuF;AACvF,eAAO,MAAM,YAAY,GAAI,cAAc,MAAM,KAAG,MAAiD,CAAC;AAEtG,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAA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AAM,eAAe,GAAG;IAC5B,wEAAwE;IACxE,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qGAAqG;AACrG,MAAM,MAAM,kBAAkB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAQ3F;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,eAAe,GAAG;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,kBAAkB,CAAC;CAC/B,CAsBA"}
@@ -5,15 +5,13 @@ import { DOM_INULL, DOM_ISALT, DOM_ITEM } from "../domains.js";
5
5
  import { notePk } from "../notes/keys.js";
6
6
  export const itemClaimCommit = (pk, salt) => poseidonHash([DOM_ITEM, pk, salt]);
7
7
  export const winnerSalt = (ns) => poseidonHash([DOM_ISALT, ns]);
8
- /** C §4.6: the seller's claim after a settlement with no winner. */
9
- export const noWinnerSalt = (sellerSecret, roomField) => poseidonHash([DOM_ISALT, sellerSecret, roomField]);
10
8
  /** C §4.5: the salt of `seller_item_fallback`, the claim `expire` and `cancel` set. */
11
9
  export const fallbackSalt = (sellerSecret) => poseidonHash([DOM_ISALT, sellerSecret]);
12
- function claimKeys(holder, roomField) {
10
+ /** Z1 (ruling Q4): a finish always has a winner, so the seller only ever holds the fallback claim. */
11
+ function claimKey(holder) {
13
12
  if ("ns" in holder)
14
- return [{ claimSk: holder.ownerSk, claimSalt: winnerSalt(holder.ns) }];
15
- const salts = [noWinnerSalt(holder.sellerSecret, roomField), fallbackSalt(holder.sellerSecret)];
16
- return salts.map((claimSalt) => ({ claimSk: holder.sellerSk, claimSalt }));
13
+ return { claimSk: holder.ownerSk, claimSalt: winnerSalt(holder.ns) };
14
+ return { claimSk: holder.sellerSk, claimSalt: fallbackSalt(holder.sellerSecret) };
17
15
  }
18
16
  /**
19
17
  * Witness for `circuits/v3/item_claim/item_claim.circom`. Public signals, in order: itemClaimC, Ni, hCtx.
@@ -21,8 +19,8 @@ function claimKeys(holder, roomField) {
21
19
  */
22
20
  export function itemClaim(p) {
23
21
  const { roomField, claim } = p.vault;
24
- const key = claimKeys(p.holder, roomField).find((k) => itemClaimCommit(notePk(k.claimSk), k.claimSalt) === claim);
25
- if (!key)
22
+ const key = claimKey(p.holder);
23
+ if (itemClaimCommit(notePk(key.claimSk), key.claimSalt) !== claim)
26
24
  throw new Error("these keys do not open the vault's claim");
27
25
  const recipientField = addrField(p.recipient);
28
26
  const relayerField = addrField(p.relayer);
@@ -7,7 +7,6 @@ export * from "./memo.ts";
7
7
  export * from "./open-kind.ts";
8
8
  export * from "./outcome.ts";
9
9
  export * from "./package-gate.ts";
10
- export * from "./reclaim.ts";
11
10
  export * from "./rows.ts";
12
11
  export * from "./seller.ts";
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -7,6 +7,5 @@ export * from "./memo.js";
7
7
  export * from "./open-kind.js";
8
8
  export * from "./outcome.js";
9
9
  export * from "./package-gate.js";
10
- export * from "./reclaim.js";
11
10
  export * from "./rows.js";
12
11
  export * from "./seller.js";
@@ -1,19 +1,21 @@
1
1
  /** `sale_room.move` LISTING_BLOB_LEN: every listing pads to it, so its length says nothing. */
2
2
  export declare const LISTING_PLAIN_BYTES = 1024;
3
+ /** `bidEncPub` is the key bids are sealed to (Z1 freeze §6.3), from the seller record's note index. */
3
4
  export type Listing = {
4
5
  price: bigint;
5
6
  salt: bigint;
7
+ bidEncPub: Uint8Array;
6
8
  };
7
9
  /** `sale_room::listing_key_id`: blake2b256("list3" ‖ bcs(sale_key)). */
8
10
  export declare const listingKeyId: (saleKey: bigint) => Uint8Array;
9
- /** PRV-24 A: the commit every bid of the room carries. */
10
- export declare function postedCommit(l: Listing): bigint;
11
- export declare const LISTING_VERSION = 1;
12
- /** `version` u8 ‖ `price` u64 ‖ `s*` u256, little-endian, then zeros to 1024 bytes. */
11
+ /** PRV-24 A: the commit SaleSettle charges. */
12
+ export declare function postedCommit(l: Pick<Listing, "price" | "salt">): bigint;
13
+ export declare const LISTING_VERSION = 2;
14
+ /** `version` u8 ‖ `price` u64 ‖ `s*` u256, little-endian, ‖ `bidEncPub` (33), then zeros to 1024 bytes. */
13
15
  export declare function listingPlaintext(l: Listing): Uint8Array;
14
16
  /**
15
- * The listing only if it is exactly what `listingPlaintext` writes and it opens the room's `posted_commit`. A
16
- * listing of another layout version throws rather than reading as malformed.
17
+ * The listing only if it is exactly what `listingPlaintext` writes, carries a valid bid key and opens the room's
18
+ * `posted_commit`. A listing of another layout version throws rather than reading as malformed.
17
19
  */
18
20
  export declare function readListing(plain: Uint8Array | undefined, posted: bigint): Listing | undefined;
19
21
  //# sourceMappingURL=listing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/listing.ts"],"names":[],"mappings":"AAOA,+FAA+F;AAC/F,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,MAAM,MAAM,OAAO,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,wEAAwE;AACxE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,UAC6D,CAAC;AAE7G,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAI/C;AAED,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,UAAU,CAKvD;AAID;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAQ9F"}
1
+ {"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/listing.ts"],"names":[],"mappings":"AAQA,+FAA+F;AAC/F,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,uGAAuG;AACvG,MAAM,MAAM,OAAO,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,CAAC;AAE7E,wEAAwE;AACxE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,UAC6D,CAAC;AAE7G,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,GAAG,MAAM,CAIvE;AAED,eAAO,MAAM,eAAe,IAAI,CAAC;AAajC,2GAA2G;AAC3G,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,UAAU,CAOvD;AAID;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAY9F"}
@@ -1,3 +1,4 @@
1
+ import { secp256k1 } from "@noble/curves/secp256k1.js";
1
2
  import { blake2b } from "@noble/hashes/blake2.js";
2
3
  import { R } from "../domains.js";
3
4
  import { le } from "./bcs.js";
@@ -6,7 +7,7 @@ import { bidCommit } from "./rows.js";
6
7
  export const LISTING_PLAIN_BYTES = 1024;
7
8
  /** `sale_room::listing_key_id`: blake2b256("list3" ‖ bcs(sale_key)). */
8
9
  export const listingKeyId = (saleKey) => blake2b(Uint8Array.from([...Buffer.from("list3", "ascii"), ...le(saleKey, 32, "saleKey")]), { dkLen: 32 });
9
- /** PRV-24 A: the commit every bid of the room carries. */
10
+ /** PRV-24 A: the commit SaleSettle charges. */
10
11
  export function postedCommit(l) {
11
12
  if (l.price <= 0n)
12
13
  throw new Error("the price must be above 0");
@@ -14,28 +15,45 @@ export function postedCommit(l) {
14
15
  throw new Error("the salt is not a field element");
15
16
  return bidCommit(l.price, l.salt);
16
17
  }
17
- export const LISTING_VERSION = 1;
18
- /** `version` u8 ‖ `price` u64 ‖ `s*` u256, little-endian, then zeros to 1024 bytes. */
18
+ export const LISTING_VERSION = 2;
19
+ const KEY_AT = 41;
20
+ const END = KEY_AT + 33;
21
+ function isPoint(pub) {
22
+ try {
23
+ secp256k1.Point.fromBytes(pub);
24
+ return true;
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ }
30
+ /** `version` u8 ‖ `price` u64 ‖ `s*` u256, little-endian, ‖ `bidEncPub` (33), then zeros to 1024 bytes. */
19
31
  export function listingPlaintext(l) {
20
32
  postedCommit(l);
33
+ if (l.bidEncPub.length !== 33 || !isPoint(l.bidEncPub))
34
+ throw new Error("the bid key is not a compressed point");
21
35
  const out = new Uint8Array(LISTING_PLAIN_BYTES);
22
- out.set([LISTING_VERSION, ...le(l.price, 8, "price"), ...le(l.salt, 32, "salt")]);
36
+ out.set([LISTING_VERSION, ...le(l.price, 8, "price"), ...le(l.salt, 32, "salt"), ...l.bidEncPub]);
23
37
  return out;
24
38
  }
25
39
  const readLe = (bytes) => BigInt(`0x${Buffer.from(bytes).reverse().toString("hex")}`);
26
40
  /**
27
- * The listing only if it is exactly what `listingPlaintext` writes and it opens the room's `posted_commit`. A
28
- * listing of another layout version throws rather than reading as malformed.
41
+ * The listing only if it is exactly what `listingPlaintext` writes, carries a valid bid key and opens the room's
42
+ * `posted_commit`. A listing of another layout version throws rather than reading as malformed.
29
43
  */
30
44
  export function readListing(plain, posted) {
31
45
  if (plain?.length !== LISTING_PLAIN_BYTES)
32
46
  return undefined;
33
47
  if (plain[0] !== LISTING_VERSION)
34
48
  throw new Error(`refused: this listing uses layout version ${plain[0]}, which this SDK does not read`);
35
- if (plain.subarray(41).some((b) => b !== 0))
49
+ if (plain.subarray(END).some((b) => b !== 0))
36
50
  return undefined;
37
- const l = { price: readLe(plain.subarray(1, 9)), salt: readLe(plain.subarray(9, 41)) };
38
- if (l.price === 0n || l.salt >= R)
51
+ const l = {
52
+ price: readLe(plain.subarray(1, 9)),
53
+ salt: readLe(plain.subarray(9, KEY_AT)),
54
+ bidEncPub: plain.slice(KEY_AT, END),
55
+ };
56
+ if (l.price === 0n || l.salt >= R || !isPoint(l.bidEncPub))
39
57
  return undefined;
40
58
  return bidCommit(l.price, l.salt) === posted ? l : undefined;
41
59
  }
@@ -21,13 +21,11 @@ export type SaleOpenKind = {
21
21
  saleKey: bigint;
22
22
  sellerCommit: bigint;
23
23
  sellerItemFallback: bigint;
24
- boundsCommit: bigint;
25
24
  postedCommit: bigint;
26
25
  listing: Uint8Array;
27
26
  memo: Uint8Array;
28
27
  closeMs: bigint;
29
28
  finishByMs: bigint;
30
- maxBids: number;
31
29
  pass: {
32
30
  tag: bigint;
33
31
  expiryMs: bigint;
@@ -37,7 +35,7 @@ export type SaleOpenKind = {
37
35
  };
38
36
  };
39
37
  /**
40
- * `membership::from_proof` then `sale_room::open` (`move/v3/sale/sources/sale_room.move:167-184`), the pass as the
38
+ * `membership::from_proof` then `sale_room::open` (`move/v3/sale/sources/sale_room.move:98-113`), the pass as the
41
39
  * open's third argument and the item an owned input of the sender: the one shape the relayer sponsors with a pass
42
40
  * (`services/relayer-v3/src/sponsor.ts:33-80`).
43
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"open-kind.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/open-kind.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,OAAO,EAAE;QAAE,OAAO,EAAE,SAAS,CAAC;QAAC,WAAW,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,UAAU,CAA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,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACtF,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAkCnE"}
@@ -2,7 +2,7 @@ import { Transaction } from "@mysten/sui/transactions";
2
2
  import { normalizeSuiAddress, toBase64 } from "@mysten/sui/utils";
3
3
  import { DOMAIN_SPEND } from "../credential/membership.js";
4
4
  /**
5
- * `membership::from_proof` then `sale_room::open` (`move/v3/sale/sources/sale_room.move:167-184`), the pass as the
5
+ * `membership::from_proof` then `sale_room::open` (`move/v3/sale/sources/sale_room.move:98-113`), the pass as the
6
6
  * open's third argument and the item an owned input of the sender: the one shape the relayer sponsors with a pass
7
7
  * (`services/relayer-v3/src/sponsor.ts:33-80`).
8
8
  */
@@ -31,12 +31,11 @@ export async function saleOpenKind(p) {
31
31
  shared(p.objects.pool, true),
32
32
  pass,
33
33
  tx.objectRef(p.item),
34
- ...[p.saleKey, p.sellerCommit, p.sellerItemFallback, p.boundsCommit, p.postedCommit].map((v) => tx.pure.u256(v)),
34
+ ...[p.saleKey, p.sellerCommit, p.sellerItemFallback, p.postedCommit].map((v) => tx.pure.u256(v)),
35
35
  tx.pure.option("vector<u8>", [...p.listing]),
36
36
  tx.pure.vector("u8", p.memo),
37
37
  tx.pure.u64(p.closeMs),
38
38
  tx.pure.u64(p.finishByMs),
39
- tx.pure.u64(p.maxBids),
40
39
  tx.object.clock(),
41
40
  ],
42
41
  });