@esseyonsui/sui-sdk-v3 0.3.2 → 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 (134) 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/network.d.ts +2 -0
  14. package/dist/network.d.ts.map +1 -1
  15. package/dist/network.js +17 -3
  16. package/dist/v3/collateral/bodies.d.ts +23 -14
  17. package/dist/v3/collateral/bodies.d.ts.map +1 -1
  18. package/dist/v3/collateral/bodies.js +42 -35
  19. package/dist/v3/collateral/ext.d.ts +18 -13
  20. package/dist/v3/collateral/ext.d.ts.map +1 -1
  21. package/dist/v3/collateral/ext.js +5 -6
  22. package/dist/v3/collateral/health.d.ts +16 -10
  23. package/dist/v3/collateral/health.d.ts.map +1 -1
  24. package/dist/v3/collateral/health.js +55 -30
  25. package/dist/v3/collateral/math.d.ts +0 -2
  26. package/dist/v3/collateral/math.d.ts.map +1 -1
  27. package/dist/v3/collateral/math.js +0 -5
  28. package/dist/v3/collateral/openings.d.ts +5 -1
  29. package/dist/v3/collateral/openings.d.ts.map +1 -1
  30. package/dist/v3/collateral/openings.js +7 -12
  31. package/dist/v3/credential/membership.d.ts +16 -2
  32. package/dist/v3/credential/membership.d.ts.map +1 -1
  33. package/dist/v3/credential/membership.js +36 -3
  34. package/dist/v3/domains.d.ts +9 -0
  35. package/dist/v3/domains.d.ts.map +1 -1
  36. package/dist/v3/domains.js +5 -0
  37. package/dist/v3/fees.d.ts +13 -1
  38. package/dist/v3/fees.d.ts.map +1 -1
  39. package/dist/v3/fees.js +32 -2
  40. package/dist/v3/funds.d.ts +34 -0
  41. package/dist/v3/funds.d.ts.map +1 -0
  42. package/dist/v3/funds.js +60 -0
  43. package/dist/v3/keeper-payload.d.ts +29 -7
  44. package/dist/v3/keeper-payload.d.ts.map +1 -1
  45. package/dist/v3/keeper-payload.js +33 -22
  46. package/dist/v3/kinds.d.ts +6 -6
  47. package/dist/v3/kinds.d.ts.map +1 -1
  48. package/dist/v3/kinds.js +5 -13
  49. package/dist/v3/loans/bodies.d.ts +40 -68
  50. package/dist/v3/loans/bodies.d.ts.map +1 -1
  51. package/dist/v3/loans/bodies.js +50 -73
  52. package/dist/v3/loans/offer-payload.d.ts +109 -0
  53. package/dist/v3/loans/offer-payload.d.ts.map +1 -0
  54. package/dist/v3/loans/offer-payload.js +207 -0
  55. package/dist/v3/loans/offer-plan.d.ts +8 -60
  56. package/dist/v3/loans/offer-plan.d.ts.map +1 -1
  57. package/dist/v3/loans/offer-plan.js +19 -95
  58. package/dist/v3/loans/open-plan.d.ts +15 -5
  59. package/dist/v3/loans/open-plan.d.ts.map +1 -1
  60. package/dist/v3/loans/open-plan.js +18 -7
  61. package/dist/v3/loans/reclaim-plan.d.ts +31 -15
  62. package/dist/v3/loans/reclaim-plan.d.ts.map +1 -1
  63. package/dist/v3/loans/reclaim-plan.js +63 -32
  64. package/dist/v3/loans/refi-plan.d.ts +8 -34
  65. package/dist/v3/loans/refi-plan.d.ts.map +1 -1
  66. package/dist/v3/loans/refi-plan.js +30 -111
  67. package/dist/v3/loans/repay-plan.d.ts.map +1 -1
  68. package/dist/v3/loans/repay-plan.js +2 -2
  69. package/dist/v3/loans/settle-plan.d.ts +88 -53
  70. package/dist/v3/loans/settle-plan.d.ts.map +1 -1
  71. package/dist/v3/loans/settle-plan.js +141 -150
  72. package/dist/v3/locks.d.ts +21 -0
  73. package/dist/v3/locks.d.ts.map +1 -0
  74. package/dist/v3/locks.js +15 -0
  75. package/dist/v3/memo.d.ts +14 -4
  76. package/dist/v3/memo.d.ts.map +1 -1
  77. package/dist/v3/memo.js +14 -7
  78. package/dist/v3/notes/derive.d.ts +5 -0
  79. package/dist/v3/notes/derive.d.ts.map +1 -1
  80. package/dist/v3/notes/derive.js +5 -0
  81. package/dist/v3/pace.d.ts +0 -1
  82. package/dist/v3/pace.d.ts.map +1 -1
  83. package/dist/v3/pace.js +0 -1
  84. package/dist/v3/pads.d.ts +15 -0
  85. package/dist/v3/pads.d.ts.map +1 -0
  86. package/dist/v3/pads.js +25 -0
  87. package/dist/v3/prover.d.ts +1 -1
  88. package/dist/v3/prover.d.ts.map +1 -1
  89. package/dist/v3/prover.js +1 -0
  90. package/dist/v3/relay/client.d.ts.map +1 -1
  91. package/dist/v3/relay/client.js +2 -2
  92. package/dist/v3/sales/auctioneer.d.ts +32 -27
  93. package/dist/v3/sales/auctioneer.d.ts.map +1 -1
  94. package/dist/v3/sales/auctioneer.js +67 -108
  95. package/dist/v3/sales/bid.d.ts +20 -49
  96. package/dist/v3/sales/bid.d.ts.map +1 -1
  97. package/dist/v3/sales/bid.js +28 -83
  98. package/dist/v3/sales/bodies.d.ts +4 -54
  99. package/dist/v3/sales/bodies.d.ts.map +1 -1
  100. package/dist/v3/sales/bodies.js +10 -52
  101. package/dist/v3/sales/claim.d.ts +0 -2
  102. package/dist/v3/sales/claim.d.ts.map +1 -1
  103. package/dist/v3/sales/claim.js +6 -8
  104. package/dist/v3/sales/index.d.ts +0 -1
  105. package/dist/v3/sales/index.d.ts.map +1 -1
  106. package/dist/v3/sales/index.js +0 -1
  107. package/dist/v3/sales/listing.d.ts +8 -6
  108. package/dist/v3/sales/listing.d.ts.map +1 -1
  109. package/dist/v3/sales/listing.js +27 -9
  110. package/dist/v3/sales/open-kind.d.ts +1 -3
  111. package/dist/v3/sales/open-kind.d.ts.map +1 -1
  112. package/dist/v3/sales/open-kind.js +2 -3
  113. package/dist/v3/sales/outcome.d.ts +5 -8
  114. package/dist/v3/sales/outcome.d.ts.map +1 -1
  115. package/dist/v3/sales/outcome.js +5 -9
  116. package/dist/v3/sales/package-gate.d.ts +3 -4
  117. package/dist/v3/sales/package-gate.d.ts.map +1 -1
  118. package/dist/v3/sales/package-gate.js +9 -7
  119. package/dist/v3/sales/rows.d.ts +9 -49
  120. package/dist/v3/sales/rows.d.ts.map +1 -1
  121. package/dist/v3/sales/rows.js +17 -91
  122. package/dist/v3/sales/seller.d.ts +2 -6
  123. package/dist/v3/sales/seller.d.ts.map +1 -1
  124. package/dist/v3/sales/seller.js +4 -11
  125. package/dist/v3/stage1.d.ts +8 -21
  126. package/dist/v3/stage1.d.ts.map +1 -1
  127. package/dist/v3/stage1.js +8 -76
  128. package/package.json +1 -1
  129. package/dist/v3/loans/lock-round.d.ts +0 -22
  130. package/dist/v3/loans/lock-round.d.ts.map +0 -1
  131. package/dist/v3/loans/lock-round.js +0 -20
  132. package/dist/v3/sales/reclaim.d.ts +0 -46
  133. package/dist/v3/sales/reclaim.d.ts.map +0 -1
  134. package/dist/v3/sales/reclaim.js +0 -57
@@ -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,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;IACjB,+BAA+B;IAC/B,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,yHAAyH;AACzH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,CAmB7C;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,E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AC;CACf,CAAC;AAEF,0GAA0G;AAC1G,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,CA6BnD;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvF,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,CASnD;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,+GAA+G;AAC/G,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,SAAS,CAajD;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,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,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG,MAAM,MAAM,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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"}
@@ -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,q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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,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,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
  });
@@ -1,5 +1,5 @@
1
- import { type BidSecrets } from "./rows.ts";
2
- /** `sale_room.move` OPEN, SETTLED and EXPIRED. A CANCELLED room never held a bid. */
1
+ import type { BidSecrets } from "./rows.ts";
2
+ /** `sale_room.move` OPEN, SETTLED and EXPIRED. A CANCELLED room took no finish. */
3
3
  export declare const SALE_STATE: {
4
4
  readonly open: 0;
5
5
  readonly settled: 1;
@@ -7,14 +7,11 @@ export declare const SALE_STATE: {
7
7
  };
8
8
  export type Outcome = "won" | "lost" | "pending";
9
9
  /**
10
- * `won` iff settlement spent the bid's own lock nullifier N and stored the residual that the bid's `ns` and
11
- * owner key rebuild (C-SPEC §10.1). `spent` is the room's whole `spent` table, downloaded: asking a node
12
- * about one N would tell it which bid is the caller's, so N is only ever looked up in that set.
10
+ * `won` iff the room settled and its vault's claim is the one this bid's owner key and `ns` rebuild (freeze §3.5
11
+ * `itemClaimC`). Read from the room and vault alone; no node is asked about the bid's nullifier.
13
12
  */
14
13
  export declare function outcome(room: {
15
- saleKey: bigint;
16
14
  state: number;
17
- residual: bigint;
18
- spent: ReadonlySet<bigint>;
15
+ claim: bigint | null;
19
16
  }, bid: BidSecrets): Outcome;
20
17
  //# sourceMappingURL=outcome.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/outcome.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjE,qFAAqF;AACrF,eAAO,MAAM,UAAU;;;;CAA+C,CAAC;AAEvE,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,EACtF,GAAG,EAAE,UAAU,GACd,OAAO,CAQT"}
1
+ {"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/outcome.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,mFAAmF;AACnF,eAAO,MAAM,UAAU;;;;CAA+C,CAAC;AAEvE,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAK/F"}
@@ -1,11 +1,10 @@
1
1
  import { notePk } from "../notes/keys.js";
2
- import { lock4, residualLock } from "./rows.js";
3
- /** `sale_room.move` OPEN, SETTLED and EXPIRED. A CANCELLED room never held a bid. */
2
+ import { itemClaimCommit, winnerSalt } from "./claim.js";
3
+ /** `sale_room.move` OPEN, SETTLED and EXPIRED. A CANCELLED room took no finish. */
4
4
  export const SALE_STATE = { open: 0, settled: 1, expired: 2 };
5
5
  /**
6
- * `won` iff settlement spent the bid's own lock nullifier N and stored the residual that the bid's `ns` and
7
- * owner key rebuild (C-SPEC §10.1). `spent` is the room's whole `spent` table, downloaded: asking a node
8
- * about one N would tell it which bid is the caller's, so N is only ever looked up in that set.
6
+ * `won` iff the room settled and its vault's claim is the one this bid's owner key and `ns` rebuild (freeze §3.5
7
+ * `itemClaimC`). Read from the room and vault alone; no node is asked about the bid's nullifier.
9
8
  */
10
9
  export function outcome(room, bid) {
11
10
  if (room.state === SALE_STATE.open)
@@ -14,8 +13,5 @@ export function outcome(room, bid) {
14
13
  return "lost";
15
14
  if (room.state !== SALE_STATE.settled)
16
15
  throw new Error("no bid has an outcome in this room state");
17
- const ownerPk = notePk(bid.ownerSk);
18
- const own = lock4(room.saleKey, ownerPk, bid.ns, bid.amount, bid.b);
19
- const change = residualLock(room.saleKey, ownerPk, bid.ns, bid.amount - bid.v);
20
- return room.spent.has(own.nullifier) && change.lock === room.residual ? "won" : "lost";
16
+ return room.claim === itemClaimCommit(notePk(bid.ownerSk), winnerSalt(bid.ns)) ? "won" : "lost";
21
17
  }
@@ -1,14 +1,13 @@
1
- export type SaleKind = "open" | "bid" | "pick" | "finish" | "slash" | "expire" | "cancel" | "reclaim" | "claim";
1
+ export type SaleKind = "open" | "bid" | "finish" | "expire" | "cancel" | "claim";
2
2
  /** The package of a `SaleRoom` or `ItemVault` type tag, which names the package's original id. */
3
3
  export declare function salePackageOf(type: string): string;
4
4
  /**
5
- * `legacy` is true on a previous origin, whose `finish` still opens every active bid. A `drained` origin is R1 under
6
- * the Z1 record: ending kinds only, and its `finish` opens the pick. Every kind is refused on any other origin.
5
+ * `legacy` is true on a previous origin, whose Seal policy is its own package's. Every kind is refused on an origin
6
+ * that is neither the current one nor a previous one.
7
7
  */
8
8
  export declare function saleKindGate(kind: SaleKind, type: string, origins: {
9
9
  current: string;
10
10
  previous: readonly string[];
11
- drained?: readonly string[];
12
11
  }): {
13
12
  legacy: boolean;
14
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"package-gate.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/package-gate.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAClB,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAK3F,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACrF;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CASrB"}
1
+ {"version":3,"file":"package-gate.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/package-gate.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAQjF,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACxD;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAQrB"}
@@ -1,6 +1,9 @@
1
1
  import { normalizeSuiAddress } from "@mysten/sui/utils";
2
- /** DECISION-R1-MIGRATION option A: a previous sale package only ends what it already holds. */
3
- const ENDING = new Set(["finish", "slash", "expire", "cancel", "reclaim", "claim"]);
2
+ /**
3
+ * DECISION-R1-MIGRATION option A: a previous sale package only ends what it already holds. Its 16-slot finish, pick,
4
+ * slash and room reclaim are R1 paths Z1 deletes, so this SDK ends such a room by expire or cancel only.
5
+ */
6
+ const ENDING = new Set(["expire", "cancel", "claim"]);
4
7
  /** The package of a `SaleRoom` or `ItemVault` type tag, which names the package's original id. */
5
8
  export function salePackageOf(type) {
6
9
  const m = /^(0x[0-9a-fA-F]{1,64})::(sale_room::SaleRoom|vault::ItemVault)</.exec(type);
@@ -9,17 +12,16 @@ export function salePackageOf(type) {
9
12
  return normalizeSuiAddress(m[1]);
10
13
  }
11
14
  /**
12
- * `legacy` is true on a previous origin, whose `finish` still opens every active bid. A `drained` origin is R1 under
13
- * the Z1 record: ending kinds only, and its `finish` opens the pick. Every kind is refused on any other origin.
15
+ * `legacy` is true on a previous origin, whose Seal policy is its own package's. Every kind is refused on an origin
16
+ * that is neither the current one nor a previous one.
14
17
  */
15
18
  export function saleKindGate(kind, type, origins) {
16
19
  const pkg = salePackageOf(type);
17
20
  if (pkg === normalizeSuiAddress(origins.current))
18
21
  return { legacy: false };
19
- const legacy = origins.previous.some((p) => normalizeSuiAddress(p) === pkg);
20
- if (!legacy && !origins.drained?.some((p) => normalizeSuiAddress(p) === pkg))
22
+ if (!origins.previous.some((p) => normalizeSuiAddress(p) === pkg))
21
23
  throw new Error("refused: the object is not of this deployment's sale package");
22
24
  if (!ENDING.has(kind))
23
25
  throw new Error(`refused: a previous sale package takes no ${kind}; nothing was sent`);
24
- return { legacy };
26
+ return { legacy: true };
25
27
  }
@@ -1,56 +1,16 @@
1
- /** `sale_room.move` MAX_BIDS, the width of SaleSettle(16) and of Reclaim's lock rows. */
2
- export declare const SLOTS = 16;
3
- /** `sale_room.move` BID_BLOB_LEN. */
4
- export declare const BID_PLAIN_BYTES = 144;
5
- /** What a bidder keeps: it reopens the lock, the residual and the item claim. Never sent. */
1
+ /** What a bidder keeps: its lock's owner key, `ns` and blind, from the bid's reserved note key (freeze §6.4). */
6
2
  export type BidSecrets = {
7
- v: bigint;
8
- s: bigint;
3
+ ownerSk: bigint;
9
4
  ns: bigint;
10
- amount: bigint;
11
5
  b: bigint;
12
- ownerSk: bigint;
13
6
  };
14
- export type BidOpening = Omit<BidSecrets, "ownerSk"> & {
15
- ownerPk: bigint;
16
- };
17
- export declare function padSlots(xs: bigint[]): bigint[];
18
- /** `rows::enc_hash`, refusing a ciphertext that is not 128 bytes. */
7
+ /** The bid's keys from the note key at its reserved index: the offer `ns` (`offerKeys`) and a blind over it alone. */
8
+ export declare function bidSecrets(own: {
9
+ sk: bigint;
10
+ blinding: bigint;
11
+ }): BidSecrets;
12
+ /** `rows::enc_hash`: keccak256(bcs(encs)) read big-endian, mod R; every ciphertext is 128 bytes. */
19
13
  export declare function encHash(encs: Uint8Array[]): bigint;
20
- /** E-2, `lib/lock.circom` Lock4, with the lock's nullifier N. */
21
- export declare function lock4(field: bigint, ownerPk: bigint, ns: bigint, amount: bigint, b: bigint): {
22
- lock: bigint;
23
- nullifier: bigint;
24
- };
25
- /** C §4.4: the winner's change, a lock whose `ns` and blinding both derive from the bid's `ns`. */
26
- export declare function residualLock(field: bigint, ownerPk: bigint, ns: bigint, amount: bigint): {
27
- lock: bigint;
28
- nullifier: bigint;
29
- nsEff: bigint;
30
- b: bigint;
31
- };
14
+ /** PRV-24 A: `posted_commit = Poseidon3(DOM_BID, price, s*)`. */
32
15
  export declare const bidCommit: (v: bigint, s: bigint) => bigint;
33
- export type BidExt = {
34
- room: string;
35
- seq: number;
36
- relayer: string;
37
- relayerFee: bigint;
38
- commit: bigint;
39
- sealed: Uint8Array;
40
- memo: Uint8Array;
41
- /** `[enc_change, enc_fee]`, the order `room_lock_spend` takes them. */
42
- encs: Uint8Array[];
43
- };
44
- /** `sale_room::ext_hash`: keccak256(bcs(ExtLockBid)) mod R, the digest read big-endian. */
45
- export declare function bidExt(x: BidExt): bigint;
46
- /** `sale_room::bid_key_id`: blake2b256("ess3/bid" ‖ bcs(sale_key) ‖ bcs(seq)), the Seal id `pin_bid` requires. */
47
- export declare const bidKeyId: (saleKey: bigint, seq: bigint) => Uint8Array;
48
- /** `pin_bid`'s aad: bcs(n0), the note the bid spends. */
49
- export declare const bidAad: (n0: bigint) => Uint8Array;
50
- /** `membership::seal_bid(room, seq, viewer).bind`, the pass `seal_approve_bid` checks. */
51
- export declare const sealBidBind: (room: string, seq: bigint, viewer: string) => Uint8Array;
52
- /** C §7.1 plaintext, in the order `sale_room::opens` peels it: v ‖ s ‖ ns ‖ amount ‖ b ‖ ownerPk. */
53
- export declare function bidPlaintext(x: BidSecrets): Uint8Array;
54
- /** `sale_room::opens`: the opening when the plaintext gives both the commit and the lock. */
55
- export declare function openBid(plain: Uint8Array | undefined, field: bigint, commit: bigint, lock: bigint): BidOpening | undefined;
56
16
  //# sourceMappingURL=rows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/rows.ts"],"names":[],"mappings":"AAaA,yFAAyF;AACzF,eAAO,MAAM,KAAK,KAAK,CAAC;AACxB,qCAAqC;AACrC,eAAO,MAAM,eAAe,MAAM,CAAC;AAMnC,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAK3E,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GA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