@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.
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -0
- package/dist/essey.d.ts +157 -131
- package/dist/essey.d.ts.map +1 -1
- package/dist/essey.js +641 -823
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/network.d.ts +2 -0
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +17 -3
- package/dist/v3/collateral/bodies.d.ts +23 -14
- package/dist/v3/collateral/bodies.d.ts.map +1 -1
- package/dist/v3/collateral/bodies.js +42 -35
- package/dist/v3/collateral/ext.d.ts +18 -13
- package/dist/v3/collateral/ext.d.ts.map +1 -1
- package/dist/v3/collateral/ext.js +5 -6
- package/dist/v3/collateral/health.d.ts +16 -10
- package/dist/v3/collateral/health.d.ts.map +1 -1
- package/dist/v3/collateral/health.js +55 -30
- package/dist/v3/collateral/math.d.ts +0 -2
- package/dist/v3/collateral/math.d.ts.map +1 -1
- package/dist/v3/collateral/math.js +0 -5
- package/dist/v3/collateral/openings.d.ts +5 -1
- package/dist/v3/collateral/openings.d.ts.map +1 -1
- package/dist/v3/collateral/openings.js +7 -12
- package/dist/v3/credential/membership.d.ts +16 -2
- package/dist/v3/credential/membership.d.ts.map +1 -1
- package/dist/v3/credential/membership.js +36 -3
- package/dist/v3/domains.d.ts +9 -0
- package/dist/v3/domains.d.ts.map +1 -1
- package/dist/v3/domains.js +5 -0
- package/dist/v3/fees.d.ts +13 -1
- package/dist/v3/fees.d.ts.map +1 -1
- package/dist/v3/fees.js +32 -2
- package/dist/v3/funds.d.ts +34 -0
- package/dist/v3/funds.d.ts.map +1 -0
- package/dist/v3/funds.js +60 -0
- package/dist/v3/keeper-payload.d.ts +29 -7
- package/dist/v3/keeper-payload.d.ts.map +1 -1
- package/dist/v3/keeper-payload.js +33 -22
- package/dist/v3/kinds.d.ts +6 -6
- package/dist/v3/kinds.d.ts.map +1 -1
- package/dist/v3/kinds.js +5 -13
- package/dist/v3/loans/bodies.d.ts +40 -68
- package/dist/v3/loans/bodies.d.ts.map +1 -1
- package/dist/v3/loans/bodies.js +50 -73
- package/dist/v3/loans/offer-payload.d.ts +109 -0
- package/dist/v3/loans/offer-payload.d.ts.map +1 -0
- package/dist/v3/loans/offer-payload.js +207 -0
- package/dist/v3/loans/offer-plan.d.ts +8 -60
- package/dist/v3/loans/offer-plan.d.ts.map +1 -1
- package/dist/v3/loans/offer-plan.js +19 -95
- package/dist/v3/loans/open-plan.d.ts +15 -5
- package/dist/v3/loans/open-plan.d.ts.map +1 -1
- package/dist/v3/loans/open-plan.js +18 -7
- package/dist/v3/loans/reclaim-plan.d.ts +31 -15
- package/dist/v3/loans/reclaim-plan.d.ts.map +1 -1
- package/dist/v3/loans/reclaim-plan.js +63 -32
- package/dist/v3/loans/refi-plan.d.ts +8 -34
- package/dist/v3/loans/refi-plan.d.ts.map +1 -1
- package/dist/v3/loans/refi-plan.js +30 -111
- package/dist/v3/loans/repay-plan.d.ts.map +1 -1
- package/dist/v3/loans/repay-plan.js +2 -2
- package/dist/v3/loans/settle-plan.d.ts +88 -53
- package/dist/v3/loans/settle-plan.d.ts.map +1 -1
- package/dist/v3/loans/settle-plan.js +141 -150
- package/dist/v3/locks.d.ts +21 -0
- package/dist/v3/locks.d.ts.map +1 -0
- package/dist/v3/locks.js +15 -0
- package/dist/v3/memo.d.ts +14 -4
- package/dist/v3/memo.d.ts.map +1 -1
- package/dist/v3/memo.js +14 -7
- package/dist/v3/notes/derive.d.ts +5 -0
- package/dist/v3/notes/derive.d.ts.map +1 -1
- package/dist/v3/notes/derive.js +5 -0
- package/dist/v3/pace.d.ts +0 -1
- package/dist/v3/pace.d.ts.map +1 -1
- package/dist/v3/pace.js +0 -1
- package/dist/v3/pads.d.ts +15 -0
- package/dist/v3/pads.d.ts.map +1 -0
- package/dist/v3/pads.js +25 -0
- package/dist/v3/prover.d.ts +1 -1
- package/dist/v3/prover.d.ts.map +1 -1
- package/dist/v3/prover.js +1 -0
- package/dist/v3/relay/client.d.ts.map +1 -1
- package/dist/v3/relay/client.js +2 -2
- package/dist/v3/sales/auctioneer.d.ts +32 -27
- package/dist/v3/sales/auctioneer.d.ts.map +1 -1
- package/dist/v3/sales/auctioneer.js +67 -108
- package/dist/v3/sales/bid.d.ts +20 -49
- package/dist/v3/sales/bid.d.ts.map +1 -1
- package/dist/v3/sales/bid.js +28 -83
- package/dist/v3/sales/bodies.d.ts +4 -54
- package/dist/v3/sales/bodies.d.ts.map +1 -1
- package/dist/v3/sales/bodies.js +10 -52
- package/dist/v3/sales/claim.d.ts +0 -2
- package/dist/v3/sales/claim.d.ts.map +1 -1
- package/dist/v3/sales/claim.js +6 -8
- package/dist/v3/sales/index.d.ts +0 -1
- package/dist/v3/sales/index.d.ts.map +1 -1
- package/dist/v3/sales/index.js +0 -1
- package/dist/v3/sales/listing.d.ts +8 -6
- package/dist/v3/sales/listing.d.ts.map +1 -1
- package/dist/v3/sales/listing.js +27 -9
- package/dist/v3/sales/open-kind.d.ts +1 -3
- package/dist/v3/sales/open-kind.d.ts.map +1 -1
- package/dist/v3/sales/open-kind.js +2 -3
- package/dist/v3/sales/outcome.d.ts +5 -8
- package/dist/v3/sales/outcome.d.ts.map +1 -1
- package/dist/v3/sales/outcome.js +5 -9
- package/dist/v3/sales/package-gate.d.ts +3 -4
- package/dist/v3/sales/package-gate.d.ts.map +1 -1
- package/dist/v3/sales/package-gate.js +9 -7
- package/dist/v3/sales/rows.d.ts +9 -49
- package/dist/v3/sales/rows.d.ts.map +1 -1
- package/dist/v3/sales/rows.js +17 -91
- package/dist/v3/sales/seller.d.ts +2 -6
- package/dist/v3/sales/seller.d.ts.map +1 -1
- package/dist/v3/sales/seller.js +4 -11
- package/dist/v3/stage1.d.ts +8 -21
- package/dist/v3/stage1.d.ts.map +1 -1
- package/dist/v3/stage1.js +8 -76
- package/package.json +1 -1
- package/dist/v3/loans/lock-round.d.ts +0 -22
- package/dist/v3/loans/lock-round.d.ts.map +0 -1
- package/dist/v3/loans/lock-round.js +0 -20
- package/dist/v3/sales/reclaim.d.ts +0 -46
- package/dist/v3/sales/reclaim.d.ts.map +0 -1
- 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
|
|
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 `
|
|
30
|
-
encs: [
|
|
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
|
|
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,
|
|
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,EAAwD,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGlG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKvD,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,EAAE,eAAe,CAAC;IAC3B,qFAAqF;IACrF,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;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"}
|
package/dist/v3/sales/bodies.js
CHANGED
|
@@ -1,78 +1,36 @@
|
|
|
1
1
|
import { address } from "../../network.js";
|
|
2
|
-
import {
|
|
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
|
-
/** `
|
|
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
|
-
|
|
19
|
+
change: s.change,
|
|
32
20
|
itemClaim: s.item_claim,
|
|
33
|
-
|
|
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
|
-
|
|
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)], {
|
package/dist/v3/sales/claim.d.ts
CHANGED
|
@@ -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,
|
|
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,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,EAAE,eAAe,GAAG;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,kBAAkB,CAAC;CAC/B,CAsBA"}
|
package/dist/v3/sales/claim.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
15
|
-
|
|
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 =
|
|
25
|
-
if (
|
|
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);
|
package/dist/v3/sales/index.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/v3/sales/index.js
CHANGED
|
@@ -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
|
|
10
|
-
export declare function postedCommit(l: Listing): bigint;
|
|
11
|
-
export declare const LISTING_VERSION =
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/v3/sales/listing.js
CHANGED
|
@@ -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
|
|
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 =
|
|
18
|
-
|
|
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
|
|
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(
|
|
49
|
+
if (plain.subarray(END).some((b) => b !== 0))
|
|
36
50
|
return undefined;
|
|
37
|
-
const l = {
|
|
38
|
-
|
|
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:
|
|
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,
|
|
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,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:
|
|
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.
|
|
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 {
|
|
2
|
-
/** `sale_room.move` OPEN, SETTLED and EXPIRED. A CANCELLED room
|
|
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
|
|
11
|
-
*
|
|
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
|
-
|
|
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":"
|
|
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"}
|
package/dist/v3/sales/outcome.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { notePk } from "../notes/keys.js";
|
|
2
|
-
import {
|
|
3
|
-
/** `sale_room.move` OPEN, SETTLED and EXPIRED. A CANCELLED room
|
|
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
|
|
7
|
-
*
|
|
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
|
-
|
|
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" | "
|
|
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
|
|
6
|
-
*
|
|
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,
|
|
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
|
-
/**
|
|
3
|
-
|
|
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
|
|
13
|
-
*
|
|
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
|
-
|
|
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
|
}
|
package/dist/v3/sales/rows.d.ts
CHANGED
|
@@ -1,56 +1,16 @@
|
|
|
1
|
-
/**
|
|
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
|
-
|
|
8
|
-
s: bigint;
|
|
3
|
+
ownerSk: bigint;
|
|
9
4
|
ns: bigint;
|
|
10
|
-
amount: bigint;
|
|
11
5
|
b: bigint;
|
|
12
|
-
ownerSk: bigint;
|
|
13
6
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
/**
|
|
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":"
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/rows.ts"],"names":[],"mappings":"AASA,iHAAiH;AACjH,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE,sHAAsH;AACtH,wBAAgB,UAAU,CAAC,GAAG,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAG5E;AAQD,oGAAoG;AACpG,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAIlD;AAED,iEAAiE;AACjE,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAuC,CAAC"}
|