@esseyonsui/sui-sdk-v3 0.2.0 → 0.3.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/essey.d.ts +106 -21
- package/dist/essey.d.ts.map +1 -1
- package/dist/essey.js +456 -164
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/v3/collateral/bodies.d.ts +2 -1
- package/dist/v3/collateral/bodies.d.ts.map +1 -1
- package/dist/v3/collateral/bodies.js +5 -5
- package/dist/v3/collateral/local-health.d.ts +2 -2
- package/dist/v3/collateral/local-health.js +1 -1
- package/dist/v3/collateral/math.d.ts +8 -9
- package/dist/v3/collateral/math.d.ts.map +1 -1
- package/dist/v3/collateral/math.js +65 -13
- package/dist/v3/index.d.ts +1 -0
- package/dist/v3/index.d.ts.map +1 -1
- package/dist/v3/index.js +1 -0
- package/dist/v3/kinds.d.ts +5 -2
- package/dist/v3/kinds.d.ts.map +1 -1
- package/dist/v3/kinds.js +7 -1
- package/dist/v3/loans/bodies.d.ts +16 -0
- package/dist/v3/loans/bodies.d.ts.map +1 -1
- package/dist/v3/loans/bodies.js +13 -0
- package/dist/v3/loans/open-plan.d.ts +2 -0
- package/dist/v3/loans/open-plan.d.ts.map +1 -1
- package/dist/v3/loans/open-plan.js +1 -1
- package/dist/v3/loans/refi-plan.d.ts.map +1 -1
- package/dist/v3/loans/refi-plan.js +2 -4
- package/dist/v3/loans/settle-plan.d.ts +7 -2
- package/dist/v3/loans/settle-plan.d.ts.map +1 -1
- package/dist/v3/loans/settle-plan.js +15 -15
- package/dist/v3/memo.d.ts +68 -0
- package/dist/v3/memo.d.ts.map +1 -0
- package/dist/v3/memo.js +147 -0
- package/dist/v3/sales/auctioneer.d.ts +8 -3
- package/dist/v3/sales/auctioneer.d.ts.map +1 -1
- package/dist/v3/sales/auctioneer.js +22 -5
- package/dist/v3/sales/bid.d.ts +3 -0
- package/dist/v3/sales/bid.d.ts.map +1 -1
- package/dist/v3/sales/bid.js +3 -0
- package/dist/v3/sales/bodies.d.ts +14 -2
- package/dist/v3/sales/bodies.d.ts.map +1 -1
- package/dist/v3/sales/bodies.js +11 -2
- package/dist/v3/sales/index.d.ts +3 -0
- package/dist/v3/sales/index.d.ts.map +1 -1
- package/dist/v3/sales/index.js +3 -0
- package/dist/v3/sales/listing.d.ts +19 -0
- package/dist/v3/sales/listing.d.ts.map +1 -0
- package/dist/v3/sales/listing.js +41 -0
- package/dist/v3/sales/memo.d.ts +4 -0
- package/dist/v3/sales/memo.d.ts.map +1 -0
- package/dist/v3/sales/memo.js +6 -0
- package/dist/v3/sales/open-kind.d.ts +4 -1
- package/dist/v3/sales/open-kind.d.ts.map +1 -1
- package/dist/v3/sales/open-kind.js +4 -3
- package/dist/v3/sales/package-gate.d.ts +14 -0
- package/dist/v3/sales/package-gate.d.ts.map +1 -0
- package/dist/v3/sales/package-gate.js +24 -0
- package/dist/v3/sales/rows.d.ts +1 -0
- package/dist/v3/sales/rows.d.ts.map +1 -1
- package/dist/v3/sales/rows.js +3 -1
- package/dist/v3/sales/seller.d.ts +34 -10
- package/dist/v3/sales/seller.d.ts.map +1 -1
- package/dist/v3/sales/seller.js +43 -16
- package/dist/v3/stage1.d.ts +3 -3
- package/dist/v3/stage1.d.ts.map +1 -1
- package/dist/v3/stage1.js +3 -4
- package/dist/v3/time-grid.d.ts +12 -1
- package/dist/v3/time-grid.d.ts.map +1 -1
- package/dist/v3/time-grid.js +17 -2
- package/package.json +1 -1
|
@@ -22,6 +22,9 @@ export type SaleOpenKind = {
|
|
|
22
22
|
sellerCommit: bigint;
|
|
23
23
|
sellerItemFallback: bigint;
|
|
24
24
|
boundsCommit: bigint;
|
|
25
|
+
postedCommit: bigint;
|
|
26
|
+
listing: Uint8Array;
|
|
27
|
+
memo: Uint8Array;
|
|
25
28
|
closeMs: bigint;
|
|
26
29
|
finishByMs: bigint;
|
|
27
30
|
maxBids: number;
|
|
@@ -34,7 +37,7 @@ export type SaleOpenKind = {
|
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
/**
|
|
37
|
-
* `membership::from_proof` then `sale_room::open` (`move/v3/sale/sources/sale_room.move:
|
|
40
|
+
* `membership::from_proof` then `sale_room::open` (`move/v3/sale/sources/sale_room.move:167-184`), the pass as the
|
|
38
41
|
* open's third argument and the item an owned input of the sender: the one shape the relayer sponsors with a pass
|
|
39
42
|
* (`services/relayer-v3/src/sponsor.ts:33-80`).
|
|
40
43
|
*/
|
|
@@ -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,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,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C;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,CAqCnE"}
|
|
@@ -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:167-184`), 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,8 +31,9 @@ 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].map((v) => tx.pure.u256(v)),
|
|
35
|
-
tx.pure.option("vector<u8>",
|
|
34
|
+
...[p.saleKey, p.sellerCommit, p.sellerItemFallback, p.boundsCommit, p.postedCommit].map((v) => tx.pure.u256(v)),
|
|
35
|
+
tx.pure.option("vector<u8>", [...p.listing]),
|
|
36
|
+
tx.pure.vector("u8", p.memo),
|
|
36
37
|
tx.pure.u64(p.closeMs),
|
|
37
38
|
tx.pure.u64(p.finishByMs),
|
|
38
39
|
tx.pure.u64(p.maxBids),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type SaleKind = "open" | "bid" | "pick" | "finish" | "slash" | "expire" | "cancel" | "reclaim" | "claim";
|
|
2
|
+
/** The package of a `SaleRoom` or `ItemVault` type tag, which names the package's original id. */
|
|
3
|
+
export declare function salePackageOf(type: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* `legacy` is true on a previous origin, whose `finish` still opens every active bid. Every kind is refused on an
|
|
6
|
+
* origin that is neither the current one nor a previous one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function saleKindGate(kind: SaleKind, type: string, origins: {
|
|
9
|
+
current: string;
|
|
10
|
+
previous: readonly string[];
|
|
11
|
+
}): {
|
|
12
|
+
legacy: boolean;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=package-gate.d.ts.map
|
|
@@ -0,0 +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,CAAA;CAAE,GACxD;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAQrB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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"]);
|
|
4
|
+
/** The package of a `SaleRoom` or `ItemVault` type tag, which names the package's original id. */
|
|
5
|
+
export function salePackageOf(type) {
|
|
6
|
+
const m = /^(0x[0-9a-fA-F]{1,64})::(sale_room::SaleRoom|vault::ItemVault)</.exec(type);
|
|
7
|
+
if (!m)
|
|
8
|
+
throw new Error("not a SaleRoom or ItemVault type");
|
|
9
|
+
return normalizeSuiAddress(m[1]);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `legacy` is true on a previous origin, whose `finish` still opens every active bid. Every kind is refused on an
|
|
13
|
+
* origin that is neither the current one nor a previous one.
|
|
14
|
+
*/
|
|
15
|
+
export function saleKindGate(kind, type, origins) {
|
|
16
|
+
const pkg = salePackageOf(type);
|
|
17
|
+
if (pkg === normalizeSuiAddress(origins.current))
|
|
18
|
+
return { legacy: false };
|
|
19
|
+
if (!origins.previous.some((p) => normalizeSuiAddress(p) === pkg))
|
|
20
|
+
throw new Error("refused: the object is not of this deployment's sale package");
|
|
21
|
+
if (!ENDING.has(kind))
|
|
22
|
+
throw new Error(`refused: a previous sale package takes no ${kind}; nothing was sent`);
|
|
23
|
+
return { legacy: true };
|
|
24
|
+
}
|
package/dist/v3/sales/rows.d.ts
CHANGED
|
@@ -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":"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,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AAI,MAAM,KAAG,UAA+C,CAAC;AAEpF,0FAA0F;AAC1F,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,EAAE,QAAQ,MAAM,KAAG,UAMpE,CAAC;AAEL,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAStD;AAED,6FAA6F;AAC7F,wBAAgB,OAAO,CACrB,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAiBxB"}
|
package/dist/v3/sales/rows.js
CHANGED
|
@@ -7,6 +7,7 @@ import { lock4 as lockOf } from "../loans/offer-plan.js";
|
|
|
7
7
|
import { encHash as loanEncHash } from "../loans/reclaim-plan.js";
|
|
8
8
|
import { notePk } from "../notes/keys.js";
|
|
9
9
|
import { addressBytes, bcsBytes, le } from "./bcs.js";
|
|
10
|
+
import { assertMemo } from "./memo.js";
|
|
10
11
|
/** `sale_room.move` MAX_BIDS, the width of SaleSettle(16) and of Reclaim's lock rows. */
|
|
11
12
|
export const SLOTS = 16;
|
|
12
13
|
/** `sale_room.move` BID_BLOB_LEN. */
|
|
@@ -40,6 +41,7 @@ export function residualLock(field, ownerPk, ns, amount) {
|
|
|
40
41
|
export const bidCommit = (v, s) => poseidonHash([DOM_BID, v, s]);
|
|
41
42
|
/** `sale_room::ext_hash`: keccak256(bcs(ExtLockBid)) mod R, the digest read big-endian. */
|
|
42
43
|
export function bidExt(x) {
|
|
44
|
+
assertMemo(x.memo);
|
|
43
45
|
return keccakModR([
|
|
44
46
|
...bcsBytes(SBID_TAG),
|
|
45
47
|
...addressBytes(x.room, "room"),
|
|
@@ -48,7 +50,7 @@ export function bidExt(x) {
|
|
|
48
50
|
...le(x.relayerFee, 8, "relayerFee"),
|
|
49
51
|
x.seq === 0 ? FIRST_BID_PAIRS : 1,
|
|
50
52
|
...le(x.commit, 32, "commit"),
|
|
51
|
-
...bcsBytes(blake2b(x.sealed, { dkLen: 32 })),
|
|
53
|
+
...bcsBytes(blake2b(Uint8Array.from([...x.sealed, ...x.memo]), { dkLen: 32 })),
|
|
52
54
|
...le(encHash(x.encs), 32, "encHash"),
|
|
53
55
|
]);
|
|
54
56
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/** `sale_room.move` CLOSE_STEP_MS: Move's grid, whatever step the config gives loans. */
|
|
2
|
+
export declare const SALE_STEP_MS = 300000;
|
|
1
3
|
/**
|
|
2
4
|
* `std::type_name::with_original_ids<T>()` of a non-generic struct tag: 64 hex digits, no `0x`. The tag must name
|
|
3
5
|
* the package's original id, which `keys::allow_item` keys on too.
|
|
4
6
|
*/
|
|
5
7
|
export declare function typeNameOf(tag: string): string;
|
|
6
|
-
/** What `sale_room::open` stores and the item it takes.
|
|
8
|
+
/** What `sale_room::open` stores and the item it takes. `listing` is the sealed listing's bytes. */
|
|
7
9
|
export type OpenArgs = {
|
|
8
10
|
saleKey: bigint;
|
|
9
11
|
/** The `Pool<C>` object. */
|
|
@@ -15,25 +17,47 @@ export type OpenArgs = {
|
|
|
15
17
|
sellerCommit: bigint;
|
|
16
18
|
sellerItemFallback: bigint;
|
|
17
19
|
boundsCommit: bigint;
|
|
20
|
+
postedCommit: bigint;
|
|
21
|
+
listing: Uint8Array;
|
|
22
|
+
memo: Uint8Array;
|
|
18
23
|
closeMs: bigint;
|
|
19
24
|
finishByMs: bigint;
|
|
20
25
|
maxBids: number;
|
|
21
26
|
};
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* `sale_room::check_grid` (44_041) counts the bid window from `round_up(chain now)`, so the open must land after
|
|
29
|
+
* `landFromMs` and by `landByMs`, where that rounding is the one assumed here. `marginMs` is the time from `nowMs`
|
|
30
|
+
* to landing the caller expects: proving and the relay.
|
|
31
|
+
*/
|
|
32
|
+
export declare function saleTimes(p: {
|
|
33
|
+
nowMs: number;
|
|
34
|
+
bidWindowMs: number;
|
|
35
|
+
finishWindowMs: number;
|
|
36
|
+
marginMs: number;
|
|
37
|
+
}): {
|
|
38
|
+
closeMs: bigint;
|
|
39
|
+
finishByMs: bigint;
|
|
40
|
+
landFromMs: bigint;
|
|
41
|
+
landByMs: bigint;
|
|
42
|
+
};
|
|
43
|
+
/** `sale_room::open_args` (`sale_room.move:591-613`), the bytes the seller pass signs. */
|
|
25
44
|
export declare function openArgs(p: OpenArgs): Uint8Array;
|
|
26
|
-
|
|
27
|
-
export declare function openCommits(s: {
|
|
45
|
+
export type SaleSecrets = {
|
|
28
46
|
sellerSk: bigint;
|
|
29
47
|
sellerSecret: bigint;
|
|
30
48
|
boundsSalt: bigint;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
postedSalt: bigint;
|
|
50
|
+
};
|
|
51
|
+
/** The seller's room secrets from the note key it reserved, so the seed alone reopens them. */
|
|
52
|
+
export declare function saleSecrets(own: {
|
|
53
|
+
sk: bigint;
|
|
54
|
+
blinding: bigint;
|
|
55
|
+
}): SaleSecrets;
|
|
56
|
+
/** The four commits `sale_room::open` stores. PRV-24 A: bounds are [price, price]; every bid commits the price. */
|
|
57
|
+
export declare function openCommits(s: SaleSecrets, price: bigint): {
|
|
35
58
|
sellerCommit: bigint;
|
|
36
59
|
sellerItemFallback: bigint;
|
|
37
60
|
boundsCommit: bigint;
|
|
61
|
+
postedCommit: bigint;
|
|
38
62
|
};
|
|
39
63
|
//# sourceMappingURL=seller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seller.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/seller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"seller.d.ts","sourceRoot":"","sources":["../../../src/v3/sales/seller.ts"],"names":[],"mappings":"AAaA,yFAAyF;AACzF,eAAO,MAAM,YAAY,SAAU,CAAC;AAQpC;;;GA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"}
|
package/dist/v3/sales/seller.js
CHANGED
|
@@ -2,15 +2,18 @@ import { poseidonHash } from "@mysten/sui/zklogin";
|
|
|
2
2
|
import { blake2b } from "@noble/hashes/blake2.js";
|
|
3
3
|
import { DOM_BOUNDS, DOM_SELLER, R } from "../domains.js";
|
|
4
4
|
import { notePk } from "../notes/keys.js";
|
|
5
|
+
import { BID_WINDOW_STEPS, FINISH_WINDOW_STEPS } from "../time-grid.js";
|
|
5
6
|
import { addressBytes, bcsBytes, le } from "./bcs.js";
|
|
6
7
|
import { fallbackSalt, itemClaimCommit } from "./claim.js";
|
|
8
|
+
import { postedCommit } from "./listing.js";
|
|
9
|
+
import { assertMemo } from "./memo.js";
|
|
7
10
|
import { SLOTS } from "./rows.js";
|
|
8
|
-
/** `sale_room.move`
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
+
/** `sale_room.move` CLOSE_STEP_MS: Move's grid, whatever step the config gives loans. */
|
|
12
|
+
export const SALE_STEP_MS = 300_000;
|
|
13
|
+
/** `sale_room.move` MAX_LISTING_LEN. */
|
|
14
|
+
const MAX_LISTING_BYTES = 2048;
|
|
11
15
|
const STRUCT_TAG = /^0x([0-9a-fA-F]{1,64})(::[A-Za-z_][A-Za-z0-9_]*){2}$/;
|
|
12
16
|
const ascii = (text) => [...Buffer.from(text, "ascii")];
|
|
13
|
-
const EMPTY_BLAKE = blake2b(new Uint8Array(), { dkLen: 32 });
|
|
14
17
|
/**
|
|
15
18
|
* `std::type_name::with_original_ids<T>()` of a non-generic struct tag: 64 hex digits, no `0x`. The tag must name
|
|
16
19
|
* the package's original id, which `keys::allow_item` keys on too.
|
|
@@ -21,14 +24,27 @@ export function typeNameOf(tag) {
|
|
|
21
24
|
throw new Error("item type is not a non-generic struct tag");
|
|
22
25
|
return `${m[1].toLowerCase().padStart(64, "0")}${tag.slice(2 + m[1].length)}`;
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (finishByMs - closeMs > MAX_FINISH_WINDOW_MS)
|
|
29
|
-
throw new Error("finishByMs is more than 30 days after closeMs");
|
|
27
|
+
function steps(what, ms, set) {
|
|
28
|
+
if (!Number.isInteger(ms) || ms % SALE_STEP_MS !== 0 || !set.includes(ms / SALE_STEP_MS))
|
|
29
|
+
throw new Error(`${what} must be one of ${set.map((n) => n * SALE_STEP_MS).join(", ")} ms`);
|
|
30
|
+
return BigInt(ms / SALE_STEP_MS);
|
|
30
31
|
}
|
|
31
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* `sale_room::check_grid` (44_041) counts the bid window from `round_up(chain now)`, so the open must land after
|
|
34
|
+
* `landFromMs` and by `landByMs`, where that rounding is the one assumed here. `marginMs` is the time from `nowMs`
|
|
35
|
+
* to landing the caller expects: proving and the relay.
|
|
36
|
+
*/
|
|
37
|
+
export function saleTimes(p) {
|
|
38
|
+
const bid = steps("the bid window", p.bidWindowMs, BID_WINDOW_STEPS);
|
|
39
|
+
const finish = steps("the finish window", p.finishWindowMs, FINISH_WINDOW_STEPS);
|
|
40
|
+
if (!Number.isInteger(p.marginMs) || p.marginMs <= 0 || p.marginMs >= SALE_STEP_MS - 1)
|
|
41
|
+
throw new Error("marginMs must be above 0 and under one sale step");
|
|
42
|
+
const step = BigInt(SALE_STEP_MS);
|
|
43
|
+
const base = ((BigInt(p.nowMs + p.marginMs) + step - 1n) / step) * step;
|
|
44
|
+
const closeMs = base + bid * step;
|
|
45
|
+
return { closeMs, finishByMs: closeMs + finish * step, landFromMs: base - step + 1n, landByMs: base };
|
|
46
|
+
}
|
|
47
|
+
/** `sale_room::open_args` (`sale_room.move:591-613`), the bytes the seller pass signs. */
|
|
32
48
|
export function openArgs(p) {
|
|
33
49
|
if (p.saleKey <= 0n || p.saleKey >= R)
|
|
34
50
|
throw new Error("saleKey is not a sale key");
|
|
@@ -36,19 +52,24 @@ export function openArgs(p) {
|
|
|
36
52
|
sellerCommit: p.sellerCommit,
|
|
37
53
|
sellerItemFallback: p.sellerItemFallback,
|
|
38
54
|
boundsCommit: p.boundsCommit,
|
|
55
|
+
postedCommit: p.postedCommit,
|
|
39
56
|
}))
|
|
40
57
|
if (x < 0n || x >= R)
|
|
41
58
|
throw new Error(`${what} is not a field element`);
|
|
42
59
|
if (!Number.isInteger(p.maxBids) || p.maxBids < 1 || p.maxBids > SLOTS)
|
|
43
60
|
throw new Error("maxBids is not 1 to 16");
|
|
44
|
-
|
|
61
|
+
if (p.listing.length < 1 || p.listing.length > MAX_LISTING_BYTES)
|
|
62
|
+
throw new Error("the sealed listing is not 1 to 2048 bytes");
|
|
63
|
+
assertMemo(p.memo);
|
|
45
64
|
return Uint8Array.from([
|
|
46
65
|
...le(p.saleKey, 32, "saleKey"),
|
|
47
66
|
...addressBytes(p.pool, "pool"),
|
|
48
67
|
...le(p.sellerCommit, 32, "sellerCommit"),
|
|
49
68
|
...le(p.sellerItemFallback, 32, "sellerItemFallback"),
|
|
50
69
|
...le(p.boundsCommit, 32, "boundsCommit"),
|
|
51
|
-
...
|
|
70
|
+
...le(p.postedCommit, 32, "postedCommit"),
|
|
71
|
+
...blake2b(p.listing, { dkLen: 32 }),
|
|
72
|
+
...p.memo,
|
|
52
73
|
...le(p.closeMs, 8, "closeMs"),
|
|
53
74
|
...le(p.finishByMs, 8, "finishByMs"),
|
|
54
75
|
...le(BigInt(p.maxBids), 8, "maxBids"),
|
|
@@ -56,12 +77,18 @@ export function openArgs(p) {
|
|
|
56
77
|
...bcsBytes(Uint8Array.from(ascii(p.item.typeName))),
|
|
57
78
|
]);
|
|
58
79
|
}
|
|
59
|
-
/** The
|
|
60
|
-
export function
|
|
80
|
+
/** The seller's room secrets from the note key it reserved, so the seed alone reopens them. */
|
|
81
|
+
export function saleSecrets(own) {
|
|
82
|
+
const tagged = (t) => poseidonHash([own.sk, own.blinding, t]);
|
|
83
|
+
return { sellerSk: own.sk, sellerSecret: tagged(7n), boundsSalt: tagged(8n), postedSalt: tagged(9n) };
|
|
84
|
+
}
|
|
85
|
+
/** The four commits `sale_room::open` stores. PRV-24 A: bounds are [price, price]; every bid commits the price. */
|
|
86
|
+
export function openCommits(s, price) {
|
|
61
87
|
const sellerPk = notePk(s.sellerSk);
|
|
62
88
|
return {
|
|
63
89
|
sellerCommit: poseidonHash([DOM_SELLER, sellerPk, poseidonHash([s.sellerSecret])]),
|
|
64
90
|
sellerItemFallback: itemClaimCommit(sellerPk, fallbackSalt(s.sellerSecret)),
|
|
65
|
-
boundsCommit: poseidonHash([DOM_BOUNDS,
|
|
91
|
+
boundsCommit: poseidonHash([DOM_BOUNDS, price, price, s.boundsSalt]),
|
|
92
|
+
postedCommit: postedCommit({ price, salt: s.postedSalt }),
|
|
66
93
|
};
|
|
67
94
|
}
|
package/dist/v3/stage1.d.ts
CHANGED
|
@@ -106,9 +106,9 @@ export type SaleOpenParams = {
|
|
|
106
106
|
itemId: string;
|
|
107
107
|
itemType: string;
|
|
108
108
|
coin: CoinKey;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/** How long bids are taken, on the
|
|
109
|
+
/** PRV-24 A: the posted price every bid pays, sealed in the listing (`sales/listing.ts`). */
|
|
110
|
+
price: bigint;
|
|
111
|
+
/** How long bids are taken, on the bid-window set of `sales/seller.ts` saleTimes. */
|
|
112
112
|
bidWindowMs: number;
|
|
113
113
|
finishWindowMs: number;
|
|
114
114
|
maxBids: number;
|
package/dist/v3/stage1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage1.d.ts","sourceRoot":"","sources":["../../src/v3/stage1.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EAAE,SAAS,EAAW,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;AAErC,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,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AC,cAAc,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EACvF,GAAG,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACjC,IAAI,CAUN;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,gBAAgB,CA6BvE"}
|
package/dist/v3/stage1.js
CHANGED
|
@@ -519,8 +519,8 @@ export function assertSaleOpen(p) {
|
|
|
519
519
|
address(open.itemId, "itemId");
|
|
520
520
|
if (open.itemType.length < 1 || open.itemType.length > 200 || /\s/.test(open.itemType))
|
|
521
521
|
throw new EsseyError("INVALID_ARGUMENT", "itemType is not a Move type");
|
|
522
|
-
if (open.
|
|
523
|
-
throw new EsseyError("INVALID_ARGUMENT", "price
|
|
522
|
+
if (open.price <= 0n || open.price >= 1n << 64n)
|
|
523
|
+
throw new EsseyError("INVALID_ARGUMENT", "price must be above 0 and a u64");
|
|
524
524
|
if (!Number.isInteger(open.bidWindowMs) ||
|
|
525
525
|
open.bidWindowMs <= 0 ||
|
|
526
526
|
!Number.isInteger(open.finishWindowMs) ||
|
|
@@ -538,8 +538,7 @@ function snapshotSale(p) {
|
|
|
538
538
|
itemId: ownString(o, "itemId"),
|
|
539
539
|
itemType: ownString(o, "itemType"),
|
|
540
540
|
coin,
|
|
541
|
-
|
|
542
|
-
maxPrice: ownBigint(o, "maxPrice"),
|
|
541
|
+
price: ownBigint(o, "price"),
|
|
543
542
|
bidWindowMs: ownInt(o, "bidWindowMs"),
|
|
544
543
|
finishWindowMs: ownInt(o, "finishWindowMs"),
|
|
545
544
|
maxBids: ownInt(o, "maxBids"),
|
package/dist/v3/time-grid.d.ts
CHANGED
|
@@ -6,8 +6,19 @@ export declare const BID_WINDOW_STEPS: readonly [1, 6, 24, 72];
|
|
|
6
6
|
export declare const FINISH_WINDOW_STEPS: readonly [6, 24, 72];
|
|
7
7
|
/** `now_s` for a default claim: down to the settle step, inside `liquidation.move:400`'s 120 s window. */
|
|
8
8
|
export declare function defaultNowS(nowMs: number): bigint;
|
|
9
|
-
/** `now_s` for a settle:
|
|
9
|
+
/** `now_s` for a settle: on the step (42_047), never before the round's close (`move/v3/loan/sources/settle.move:135-143`). */
|
|
10
10
|
export declare function settleNowS(nowMs: number, closeMs: bigint): bigint;
|
|
11
|
+
/**
|
|
12
|
+
* PRV-27 (b), `loan::check_close` (`loan.move:317-323`): a close is `window` after the clock rounded up to the step,
|
|
13
|
+
* at the clock the open lands at.
|
|
14
|
+
*/
|
|
15
|
+
export declare const gridClose: (nowMs: number, windowMs: number, stepMs: number) => bigint;
|
|
16
|
+
/**
|
|
17
|
+
* How long to wait before choosing a close so the open lands in the same step as it was planned in: an open that
|
|
18
|
+
* lands past the next step boundary is one step late and aborts 42_046. 0 when the boundary is `marginMs` or more
|
|
19
|
+
* away, or when a step is shorter than the margin and no wait can help.
|
|
20
|
+
*/
|
|
21
|
+
export declare function closeWaitMs(nowMs: number, stepMs: number, marginMs: number): number;
|
|
11
22
|
/** Refuses a window or term off this deployment's public sets, so neither tells one member's loan from another. */
|
|
12
23
|
export declare function assertLoanGrid(p: {
|
|
13
24
|
termMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-grid.d.ts","sourceRoot":"","sources":["../../src/v3/time-grid.ts"],"names":[],"mappings":"AAKA,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,yBAA0B,CAAC;AAC1D,eAAO,MAAM,UAAU,kCAAmC,CAAC;AAE3D,6IAA6I;AAC7I,eAAO,MAAM,gBAAgB,yBAA0B,CAAC;AACxD,eAAO,MAAM,mBAAmB,sBAAuB,CAAC;AAExD,0GAA0G;AAC1G,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED
|
|
1
|
+
{"version":3,"file":"time-grid.d.ts","sourceRoot":"","sources":["../../src/v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s / 1000));
|
|
13
13
|
return s - (s % NOW_STEP_S);
|
|
14
14
|
}
|
|
15
|
-
/** `now_s` for a settle:
|
|
15
|
+
/** `now_s` for a settle: on the step (42_047), never before the round's close (`move/v3/loan/sources/settle.move:135-143`). */
|
|
16
16
|
export function settleNowS(nowMs, closeMs) {
|
|
17
17
|
const snapped = defaultNowS(nowMs);
|
|
18
|
-
const
|
|
18
|
+
const stepMs = NOW_STEP_S * 1000n;
|
|
19
|
+
const close = ((closeMs + stepMs - 1n) / stepMs) * NOW_STEP_S;
|
|
19
20
|
return snapped > close ? snapped : close;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* PRV-27 (b), `loan::check_close` (`loan.move:317-323`): a close is `window` after the clock rounded up to the step,
|
|
24
|
+
* at the clock the open lands at.
|
|
25
|
+
*/
|
|
26
|
+
export const gridClose = (nowMs, windowMs, stepMs) => BigInt(Math.ceil(nowMs / stepMs) * stepMs + windowMs);
|
|
27
|
+
/**
|
|
28
|
+
* How long to wait before choosing a close so the open lands in the same step as it was planned in: an open that
|
|
29
|
+
* lands past the next step boundary is one step late and aborts 42_046. 0 when the boundary is `marginMs` or more
|
|
30
|
+
* away, or when a step is shorter than the margin and no wait can help.
|
|
31
|
+
*/
|
|
32
|
+
export function closeWaitMs(nowMs, stepMs, marginMs) {
|
|
33
|
+
const left = Math.ceil(nowMs / stepMs) * stepMs - nowMs;
|
|
34
|
+
return left >= marginMs || stepMs <= marginMs ? 0 : left + 1;
|
|
35
|
+
}
|
|
21
36
|
const label = (ms) => ms % 86_400_000 === 0
|
|
22
37
|
? `${ms / 86_400_000} d`
|
|
23
38
|
: ms % 3_600_000 === 0
|