@misofm/sdk 0.1.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 (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +248 -0
  3. package/dist/catalog.d.ts +31 -0
  4. package/dist/catalog.d.ts.map +1 -0
  5. package/dist/catalog.js +45 -0
  6. package/dist/catalog.js.map +1 -0
  7. package/dist/client.d.ts +134 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +113 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/contracts/miso_pressing/certificate.d.ts +78 -0
  12. package/dist/contracts/miso_pressing/certificate.d.ts.map +1 -0
  13. package/dist/contracts/miso_pressing/certificate.js +91 -0
  14. package/dist/contracts/miso_pressing/certificate.js.map +1 -0
  15. package/dist/contracts/miso_pressing/deps/std/type_name.d.ts +18 -0
  16. package/dist/contracts/miso_pressing/deps/std/type_name.d.ts.map +1 -0
  17. package/dist/contracts/miso_pressing/deps/std/type_name.js +20 -0
  18. package/dist/contracts/miso_pressing/deps/std/type_name.js.map +1 -0
  19. package/dist/contracts/miso_pressing/listing.d.ts +449 -0
  20. package/dist/contracts/miso_pressing/listing.d.ts.map +1 -0
  21. package/dist/contracts/miso_pressing/listing.js +416 -0
  22. package/dist/contracts/miso_pressing/listing.js.map +1 -0
  23. package/dist/contracts/miso_pressing/pressing.d.ts +365 -0
  24. package/dist/contracts/miso_pressing/pressing.d.ts.map +1 -0
  25. package/dist/contracts/miso_pressing/pressing.js +335 -0
  26. package/dist/contracts/miso_pressing/pressing.js.map +1 -0
  27. package/dist/contracts/utils/index.d.ts +31 -0
  28. package/dist/contracts/utils/index.d.ts.map +1 -0
  29. package/dist/contracts/utils/index.js +162 -0
  30. package/dist/contracts/utils/index.js.map +1 -0
  31. package/dist/execute.d.ts +17 -0
  32. package/dist/execute.d.ts.map +1 -0
  33. package/dist/execute.js +21 -0
  34. package/dist/execute.js.map +1 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +27 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/pressing.d.ts +223 -0
  40. package/dist/pressing.d.ts.map +1 -0
  41. package/dist/pressing.js +280 -0
  42. package/dist/pressing.js.map +1 -0
  43. package/dist/queries.d.ts +2 -0
  44. package/dist/queries.d.ts.map +1 -0
  45. package/dist/queries.js +8 -0
  46. package/dist/queries.js.map +1 -0
  47. package/dist/release-graph.d.ts +93 -0
  48. package/dist/release-graph.d.ts.map +1 -0
  49. package/dist/release-graph.js +143 -0
  50. package/dist/release-graph.js.map +1 -0
  51. package/dist/share-template.d.ts +3 -0
  52. package/dist/share-template.d.ts.map +1 -0
  53. package/dist/share-template.js +46 -0
  54. package/dist/share-template.js.map +1 -0
  55. package/dist/share.d.ts +66 -0
  56. package/dist/share.d.ts.map +1 -0
  57. package/dist/share.js +156 -0
  58. package/dist/share.js.map +1 -0
  59. package/dist/transactions.d.ts +177 -0
  60. package/dist/transactions.d.ts.map +1 -0
  61. package/dist/transactions.js +237 -0
  62. package/dist/transactions.js.map +1 -0
  63. package/package.json +99 -0
  64. package/src/catalog.ts +77 -0
  65. package/src/client.ts +249 -0
  66. package/src/contracts/miso_pressing/certificate.ts +129 -0
  67. package/src/contracts/miso_pressing/deps/std/type_name.ts +22 -0
  68. package/src/contracts/miso_pressing/listing.ts +621 -0
  69. package/src/contracts/miso_pressing/pressing.ts +454 -0
  70. package/src/contracts/utils/index.ts +229 -0
  71. package/src/execute.ts +34 -0
  72. package/src/index.ts +29 -0
  73. package/src/pressing.ts +497 -0
  74. package/src/queries.ts +9 -0
  75. package/src/release-graph.ts +279 -0
  76. package/src/share-template.ts +55 -0
  77. package/src/share.ts +258 -0
  78. package/src/transactions.ts +440 -0
@@ -0,0 +1,223 @@
1
+ import type { ClientWithCoreApi } from "@mysten/sui/client";
2
+ import type { TxThunk } from "./transactions.ts";
3
+ /** Pricing policy: pay exactly `amount` (fixed) or at least `amount` (floor). */
4
+ export type ListingPrice = {
5
+ kind: "fixed" | "floor";
6
+ amount: bigint | number | string;
7
+ };
8
+ /** Whether a currency's listing takes payment. Below the pressing's own run state. */
9
+ export type ListingSwitch = "enabled" | "disabled";
10
+ /**
11
+ * The run's state, across every currency at once.
12
+ *
13
+ * `scheduled` is transitional: the first sale past `startTimestampMs` rewrites it to
14
+ * `active` inside `mint_next`, and the start time leaves the object with it. "When was
15
+ * this run scheduled for" is an event-log question once a run has sold anything.
16
+ */
17
+ export type PressingRunState = {
18
+ kind: "scheduled";
19
+ startTimestampMs: bigint | number;
20
+ } | {
21
+ kind: "active";
22
+ } | {
23
+ kind: "paused";
24
+ };
25
+ /**
26
+ * Where `releaseId`'s pressing lives — computable before it has been opened, and
27
+ * stable forever after, because a release can only ever claim one.
28
+ *
29
+ * `misoPressingPackageId` must be the package's ORIGINAL (first-published) id, since
30
+ * that is the address a Move type tag canonicalises to. `miso_pressing` is published
31
+ * immutable, so its original and current ids are the same.
32
+ */
33
+ export declare function derivePressingId(releaseId: string, misoPressingPackageId: string): string;
34
+ /**
35
+ * Where `pressingId`'s admin cap was minted. The cap is transferable, so this is not
36
+ * where it lives — only where it came from.
37
+ */
38
+ export declare function derivePressingAdminCapId(pressingId: string, misoPressingPackageId: string): string;
39
+ /**
40
+ * Where `currencyType`'s listing on `pressingId` lives. The key is phantom-typed, so
41
+ * the currency rides in the key's TYPE — one listing per (pressing, currency), ever.
42
+ */
43
+ export declare function deriveListingId(pressingId: string, currencyType: string, misoPressingPackageId: string): string;
44
+ /** Both derived ids a sale needs, from the release id alone. */
45
+ export declare function deriveSaleIds(releaseId: string, currencyType: string, misoPressingPackageId: string): {
46
+ pressingId: string;
47
+ listingId: string;
48
+ };
49
+ /** One currency's offer, as `openPressing` takes it. */
50
+ export interface ListingTerms {
51
+ /** The `Currency` type argument, e.g. `0x2::sui::SUI`. */
52
+ currencyType: string;
53
+ price: ListingPrice;
54
+ /** Defaults to `"enabled"` — a listing opened disabled takes no payment yet. */
55
+ state?: ListingSwitch;
56
+ }
57
+ export interface OpenPressingParams {
58
+ /** The `Release` this run presses copies of — also the pressing's derivation parent. */
59
+ releaseId: string;
60
+ /** The release's `ReleaseAdminCap`. Needed ONLY to open the run; every later change
61
+ * authorizes against the `PressingAdminCap` this mints. */
62
+ releaseAdminCapId: string;
63
+ /** Currencies to open the run in. May be empty — listings can be added later with
64
+ * {@link openListing} — but a run with no listings sells nothing. */
65
+ listings: ListingTerms[];
66
+ /** Run state at open. Defaults to `active` (sell immediately); `scheduled` is the
67
+ * trustless drop moment, and needs no later transaction to open. */
68
+ state?: PressingRunState;
69
+ /** Where to send the minted `PressingAdminCap` (usually the artist or their vault). */
70
+ adminCapRecipient: string;
71
+ misoPressingPackageId: string;
72
+ }
73
+ /**
74
+ * Opens a release's pressing and lists it, in ONE transaction.
75
+ *
76
+ * `pressing::new` hands the `Pressing` back UNSHARED precisely so the listings can be
77
+ * claimed off it before `share` puts it on chain — that ordering is the whole reason
78
+ * this is a single builder and not three. A release can only ever open one pressing,
79
+ * so this call is once-per-release forever; changing price or currency afterwards is
80
+ * an edit ({@link setListingPrice}, {@link openListing}), never a re-open.
81
+ */
82
+ export declare function openPressing(p: OpenPressingParams): TxThunk;
83
+ export interface OpenListingParams {
84
+ /** The release whose pressing gains a currency. The pressing id derives from it. */
85
+ releaseId: string;
86
+ pressingAdminCapId: string;
87
+ terms: ListingTerms;
88
+ misoPressingPackageId: string;
89
+ }
90
+ /**
91
+ * Adds a currency to a live pressing. Once per currency, ever — the slot is a derived
92
+ * claim, so a second call for the same currency aborts. Everything after is an edit.
93
+ */
94
+ export declare function openListing(p: OpenListingParams): TxThunk;
95
+ export interface SetListingPriceParams {
96
+ releaseId: string;
97
+ currencyType: string;
98
+ pressingAdminCapId: string;
99
+ price: ListingPrice;
100
+ misoPressingPackageId: string;
101
+ }
102
+ /**
103
+ * Reprices one currency in place, keeping the listing's address and identity. Safe
104
+ * against in-flight buys by construction: a `fixed` buyer pays exactly, so a stale
105
+ * payment aborts against the new price, and a `floor` buyer never pays more than the
106
+ * balance they sent.
107
+ */
108
+ export declare function setListingPrice(p: SetListingPriceParams): TxThunk;
109
+ export interface SetListingStateParams {
110
+ releaseId: string;
111
+ currencyType: string;
112
+ pressingAdminCapId: string;
113
+ state: ListingSwitch;
114
+ misoPressingPackageId: string;
115
+ }
116
+ /** Stops or resumes ONE currency. The run's other currencies carry on. */
117
+ export declare function setListingState(p: SetListingStateParams): TxThunk;
118
+ export interface SetPressingStateParams {
119
+ releaseId: string;
120
+ pressingAdminCapId: string;
121
+ state: PressingRunState;
122
+ misoPressingPackageId: string;
123
+ }
124
+ /**
125
+ * Moves the whole run between its three modes, over every currency at once. There is
126
+ * no "end" — ending a campaign is `{ kind: "paused" }`.
127
+ */
128
+ export declare function setPressingState(p: SetPressingStateParams): TxThunk;
129
+ export interface BuyRecordParams {
130
+ /**
131
+ * The `Release` being bought a copy of. The pressing and this currency's listing
132
+ * BOTH derive from it (see {@link deriveSaleIds}), so there is nothing to look up
133
+ * and no way to pair a listing with the wrong pressing.
134
+ */
135
+ releaseId: string;
136
+ /** Amount to pay in the currency's smallest unit (exact for `fixed`, ≥ for `floor`). */
137
+ amount: bigint | number | string;
138
+ /** The listing's `Currency` type, e.g. `0x2::sui::SUI`. */
139
+ currencyType: string;
140
+ /** The `miso_record` `Settings` shared object — it must authorize `miso_pressing`'s
141
+ * `MintWitness`, or the mint aborts. */
142
+ settingsId: string;
143
+ /** Where to send the pressed `Record` (usually the buyer). */
144
+ recipient: string;
145
+ misoPressingPackageId: string;
146
+ /**
147
+ * Set only when the buyer pays their OWN gas. Miso sponsors every purchase — the gas
148
+ * coin is the sponsor's, so drawing a payment out of it would spend the wrong
149
+ * wallet's money. Defaults to sponsored; bites only on SUI-priced listings.
150
+ */
151
+ useGasCoin?: boolean;
152
+ }
153
+ /**
154
+ * Buys one record: sources the payment, calls `listing::buy`, and sends the pressed
155
+ * `Record` to `recipient`. `buy` RETURNS the record rather than transferring it, so
156
+ * the transfer here is not optional. The `Clock` is auto-supplied.
157
+ *
158
+ * ONE payment path, no coin picking. `tx.balance()` resolves the money at build time,
159
+ * preferring the buyer's ADDRESS BALANCE — where value is assumed to live — and falling
160
+ * back to coin objects inside the SDK if it must. Callers never enumerate coins: that
161
+ * road showed a buyer their $1000 and then refused to spend a cent of it, because the
162
+ * listing only saw `Coin<T>` objects and the money was in the address balance.
163
+ *
164
+ * `listing::buy` takes a bare `Balance<Currency>`, which is what makes that resolution
165
+ * cheap: when the address balance covers the price, `tx.balance()` emits a single
166
+ * `balance::redeem_funds` straight off the accumulator and no coin object is minted,
167
+ * touched, or destroyed — leaving the sale free of any owned-object contention. Only
168
+ * when it must fall back to coins does it merge, split, and `coin::into_balance`.
169
+ */
170
+ export declare function buyRecord(p: BuyRecordParams): TxThunk;
171
+ /** A parsed `Pressing` — the run itself. */
172
+ export interface PressingView {
173
+ id: string;
174
+ releaseId: string;
175
+ state: PressingRunState & {
176
+ startTimestampMs?: bigint;
177
+ };
178
+ /** Records pressed so far; also the most recent number. Not a cap — nothing counts
179
+ * against it, and there is no sold-out state to reach. */
180
+ supply: bigint;
181
+ }
182
+ /** A parsed `Listing<Currency>` — one currency's offer on the run. */
183
+ export interface ListingView {
184
+ id: string;
185
+ releaseId: string;
186
+ pressingId: string;
187
+ price: {
188
+ kind: "fixed" | "floor";
189
+ amount: bigint;
190
+ };
191
+ state: ListingSwitch;
192
+ /** The `Currency` type, parsed from the object's type tag (`null` if unavailable). */
193
+ currencyType: string | null;
194
+ }
195
+ /**
196
+ * Fetches and parses a `Pressing`, or `null` if the release has never opened one.
197
+ *
198
+ * NOTE: like the old drop reader, this deliberately deviates from the core-getter
199
+ * convention in `./queries.ts` (throw on missing object). A pressing's address is
200
+ * computable for ANY release, so probing one that was never opened is a normal state,
201
+ * not a broken reference — absence is `null` and only transport failures throw.
202
+ */
203
+ export declare function getPressing(client: ClientWithCoreApi, pressingId: string): Promise<PressingView | null>;
204
+ /** Fetches and parses a `Listing<Currency>`, or `null` if that currency is not listed. */
205
+ export declare function getListing(client: ClientWithCoreApi, listingId: string): Promise<ListingView | null>;
206
+ export interface GetSaleParams {
207
+ /** The release to resolve a sale for. */
208
+ releaseId: string;
209
+ /** The currency the buyer intends to pay in. */
210
+ currencyType: string;
211
+ misoPressingPackageId: string;
212
+ }
213
+ /**
214
+ * Resolves a release's run AND one currency's offer in a single round trip, by pure
215
+ * address math — no registry, no pointer, no event scan. `pressing: null` means the
216
+ * release has never opened one; `listing: null` means it does not sell in that
217
+ * currency (the other currencies, if any, are unaffected).
218
+ */
219
+ export declare function getSale(client: ClientWithCoreApi, p: GetSaleParams): Promise<{
220
+ pressing: PressingView | null;
221
+ listing: ListingView | null;
222
+ }>;
223
+ //# sourceMappingURL=pressing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pressing.d.ts","sourceRoot":"","sources":["../src/pressing.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAKjD,iFAAiF;AACjF,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEzF,sFAAsF;AACtF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AASvB;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,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CAOzE"}
@@ -0,0 +1,280 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { deriveObjectID, normalizeStructTag } from "@mysten/sui/utils";
4
+ import { isNotFound } from "./queries.js";
5
+ import * as listing from "./contracts/miso_pressing/listing.js";
6
+ import * as pressing from "./contracts/miso_pressing/pressing.js";
7
+ // ============================================================================
8
+ // Address math
9
+ // ============================================================================
10
+ /** Key bytes for Move unit structs (single `0x00` for `dummy_field: bool = false`). */
11
+ const UNIT_STRUCT_KEY_BYTES = new Uint8Array([0x00]);
12
+ /**
13
+ * Where `releaseId`'s pressing lives — computable before it has been opened, and
14
+ * stable forever after, because a release can only ever claim one.
15
+ *
16
+ * `misoPressingPackageId` must be the package's ORIGINAL (first-published) id, since
17
+ * that is the address a Move type tag canonicalises to. `miso_pressing` is published
18
+ * immutable, so its original and current ids are the same.
19
+ */
20
+ export function derivePressingId(releaseId, misoPressingPackageId) {
21
+ return deriveObjectID(releaseId, `${misoPressingPackageId}::pressing::PressingKey`, UNIT_STRUCT_KEY_BYTES);
22
+ }
23
+ /**
24
+ * Where `pressingId`'s admin cap was minted. The cap is transferable, so this is not
25
+ * where it lives — only where it came from.
26
+ */
27
+ export function derivePressingAdminCapId(pressingId, misoPressingPackageId) {
28
+ return deriveObjectID(pressingId, `${misoPressingPackageId}::pressing::PressingAdminCapKey`, UNIT_STRUCT_KEY_BYTES);
29
+ }
30
+ /**
31
+ * Where `currencyType`'s listing on `pressingId` lives. The key is phantom-typed, so
32
+ * the currency rides in the key's TYPE — one listing per (pressing, currency), ever.
33
+ */
34
+ export function deriveListingId(pressingId, currencyType, misoPressingPackageId) {
35
+ return deriveObjectID(pressingId, `${misoPressingPackageId}::listing::ListingKey<${normalizeStructTag(currencyType)}>`, UNIT_STRUCT_KEY_BYTES);
36
+ }
37
+ /** Both derived ids a sale needs, from the release id alone. */
38
+ export function deriveSaleIds(releaseId, currencyType, misoPressingPackageId) {
39
+ const pressingId = derivePressingId(releaseId, misoPressingPackageId);
40
+ return { pressingId, listingId: deriveListingId(pressingId, currencyType, misoPressingPackageId) };
41
+ }
42
+ function priceArg(tx, misoPressingPackageId, price) {
43
+ const make = price.kind === "fixed" ? listing.newFixedPrice : listing.newFloorPrice;
44
+ return tx.add(make({ package: misoPressingPackageId, arguments: [BigInt(price.amount)] }));
45
+ }
46
+ function switchArg(tx, misoPressingPackageId, state) {
47
+ const make = state === "enabled" ? listing.newEnabledState : listing.newDisabledState;
48
+ return tx.add(make({ package: misoPressingPackageId }));
49
+ }
50
+ function runStateArg(tx, misoPressingPackageId, state) {
51
+ const pkg = { package: misoPressingPackageId };
52
+ switch (state.kind) {
53
+ case "scheduled":
54
+ return tx.add(pressing.newScheduledState({ ...pkg, arguments: [BigInt(state.startTimestampMs)] }));
55
+ case "active":
56
+ return tx.add(pressing.newActiveState(pkg));
57
+ case "paused":
58
+ return tx.add(pressing.newPausedState(pkg));
59
+ }
60
+ }
61
+ /**
62
+ * Opens a release's pressing and lists it, in ONE transaction.
63
+ *
64
+ * `pressing::new` hands the `Pressing` back UNSHARED precisely so the listings can be
65
+ * claimed off it before `share` puts it on chain — that ordering is the whole reason
66
+ * this is a single builder and not three. A release can only ever open one pressing,
67
+ * so this call is once-per-release forever; changing price or currency afterwards is
68
+ * an edit ({@link setListingPrice}, {@link openListing}), never a re-open.
69
+ */
70
+ export function openPressing(p) {
71
+ return (tx) => {
72
+ const pkg = p.misoPressingPackageId;
73
+ const [run, adminCap] = tx.add(pressing._new({
74
+ package: pkg,
75
+ arguments: [p.releaseId, p.releaseAdminCapId, runStateArg(tx, pkg, p.state ?? { kind: "active" })],
76
+ }));
77
+ for (const terms of p.listings) {
78
+ tx.add(listing._new({
79
+ package: pkg,
80
+ arguments: [
81
+ run,
82
+ adminCap,
83
+ priceArg(tx, pkg, terms.price),
84
+ switchArg(tx, pkg, terms.state ?? "enabled"),
85
+ ],
86
+ typeArguments: [terms.currencyType],
87
+ }));
88
+ }
89
+ tx.add(pressing.share({ package: pkg, arguments: [run] }));
90
+ tx.transferObjects([adminCap], p.adminCapRecipient);
91
+ };
92
+ }
93
+ /**
94
+ * Adds a currency to a live pressing. Once per currency, ever — the slot is a derived
95
+ * claim, so a second call for the same currency aborts. Everything after is an edit.
96
+ */
97
+ export function openListing(p) {
98
+ return (tx) => {
99
+ const pkg = p.misoPressingPackageId;
100
+ tx.add(listing._new({
101
+ package: pkg,
102
+ arguments: [
103
+ derivePressingId(p.releaseId, pkg),
104
+ p.pressingAdminCapId,
105
+ priceArg(tx, pkg, p.terms.price),
106
+ switchArg(tx, pkg, p.terms.state ?? "enabled"),
107
+ ],
108
+ typeArguments: [p.terms.currencyType],
109
+ }));
110
+ };
111
+ }
112
+ /**
113
+ * Reprices one currency in place, keeping the listing's address and identity. Safe
114
+ * against in-flight buys by construction: a `fixed` buyer pays exactly, so a stale
115
+ * payment aborts against the new price, and a `floor` buyer never pays more than the
116
+ * balance they sent.
117
+ */
118
+ export function setListingPrice(p) {
119
+ return (tx) => {
120
+ const pkg = p.misoPressingPackageId;
121
+ const { listingId } = deriveSaleIds(p.releaseId, p.currencyType, pkg);
122
+ tx.add(listing.setPrice({
123
+ package: pkg,
124
+ arguments: [listingId, p.pressingAdminCapId, priceArg(tx, pkg, p.price)],
125
+ typeArguments: [p.currencyType],
126
+ }));
127
+ };
128
+ }
129
+ /** Stops or resumes ONE currency. The run's other currencies carry on. */
130
+ export function setListingState(p) {
131
+ return (tx) => {
132
+ const pkg = p.misoPressingPackageId;
133
+ const { listingId } = deriveSaleIds(p.releaseId, p.currencyType, pkg);
134
+ tx.add(listing.setState({
135
+ package: pkg,
136
+ arguments: [listingId, p.pressingAdminCapId, switchArg(tx, pkg, p.state)],
137
+ typeArguments: [p.currencyType],
138
+ }));
139
+ };
140
+ }
141
+ /**
142
+ * Moves the whole run between its three modes, over every currency at once. There is
143
+ * no "end" — ending a campaign is `{ kind: "paused" }`.
144
+ */
145
+ export function setPressingState(p) {
146
+ return (tx) => {
147
+ const pkg = p.misoPressingPackageId;
148
+ tx.add(pressing.setState({
149
+ package: pkg,
150
+ arguments: [
151
+ derivePressingId(p.releaseId, pkg),
152
+ p.pressingAdminCapId,
153
+ runStateArg(tx, pkg, p.state),
154
+ ],
155
+ }));
156
+ };
157
+ }
158
+ /**
159
+ * Buys one record: sources the payment, calls `listing::buy`, and sends the pressed
160
+ * `Record` to `recipient`. `buy` RETURNS the record rather than transferring it, so
161
+ * the transfer here is not optional. The `Clock` is auto-supplied.
162
+ *
163
+ * ONE payment path, no coin picking. `tx.balance()` resolves the money at build time,
164
+ * preferring the buyer's ADDRESS BALANCE — where value is assumed to live — and falling
165
+ * back to coin objects inside the SDK if it must. Callers never enumerate coins: that
166
+ * road showed a buyer their $1000 and then refused to spend a cent of it, because the
167
+ * listing only saw `Coin<T>` objects and the money was in the address balance.
168
+ *
169
+ * `listing::buy` takes a bare `Balance<Currency>`, which is what makes that resolution
170
+ * cheap: when the address balance covers the price, `tx.balance()` emits a single
171
+ * `balance::redeem_funds` straight off the accumulator and no coin object is minted,
172
+ * touched, or destroyed — leaving the sale free of any owned-object contention. Only
173
+ * when it must fall back to coins does it merge, split, and `coin::into_balance`.
174
+ */
175
+ export function buyRecord(p) {
176
+ return (tx) => {
177
+ const pkg = p.misoPressingPackageId;
178
+ const { pressingId, listingId } = deriveSaleIds(p.releaseId, p.currencyType, pkg);
179
+ const payment = tx.balance({
180
+ type: p.currencyType,
181
+ balance: BigInt(p.amount),
182
+ useGasCoin: p.useGasCoin ?? false,
183
+ });
184
+ const record = tx.add(listing.buy({
185
+ package: pkg,
186
+ arguments: [listingId, pressingId, payment, p.settingsId],
187
+ typeArguments: [p.currencyType],
188
+ }));
189
+ tx.transferObjects([record], p.recipient);
190
+ };
191
+ }
192
+ /** Extracts `CURRENCY` from a `…::listing::Listing<CURRENCY>` type tag. */
193
+ function currencyFromType(type) {
194
+ if (!type)
195
+ return null;
196
+ const lt = type.indexOf("<");
197
+ return lt >= 0 && type.endsWith(">") ? type.slice(lt + 1, -1) : null;
198
+ }
199
+ /** Reads one object's BCS content + type, or `null` when it does not exist. */
200
+ async function fetch(client, objectId) {
201
+ try {
202
+ const { object } = await client.core.getObject({ objectId, include: { content: true } });
203
+ return object?.content ? { content: object.content, type: object.type } : null;
204
+ }
205
+ catch (e) {
206
+ if (isNotFound(e))
207
+ return null;
208
+ throw e;
209
+ }
210
+ }
211
+ // The generated `MoveEnum` parsers emit `{ $kind, <Variant>: … }`; older ones omitted
212
+ // `$kind`. Both shapes are accepted so a codegen bump cannot silently mis-read a price.
213
+ function variant(v, ...names) {
214
+ for (const name of names)
215
+ if (v.$kind === name || v[name] != null)
216
+ return name;
217
+ return names[0];
218
+ }
219
+ /**
220
+ * Fetches and parses a `Pressing`, or `null` if the release has never opened one.
221
+ *
222
+ * NOTE: like the old drop reader, this deliberately deviates from the core-getter
223
+ * convention in `./queries.ts` (throw on missing object). A pressing's address is
224
+ * computable for ANY release, so probing one that was never opened is a normal state,
225
+ * not a broken reference — absence is `null` and only transport failures throw.
226
+ */
227
+ export async function getPressing(client, pressingId) {
228
+ const got = await fetch(client, pressingId);
229
+ if (!got)
230
+ return null;
231
+ const parsed = pressing.Pressing.parse(got.content);
232
+ const s = parsed.state;
233
+ const kind = variant(s, "Scheduled", "Active", "Paused");
234
+ return {
235
+ id: pressingId,
236
+ releaseId: parsed.release_id,
237
+ state: kind === "Scheduled"
238
+ ? { kind: "scheduled", startTimestampMs: BigInt(s.Scheduled?.start_timestamp_ms ?? "0") }
239
+ : kind === "Paused"
240
+ ? { kind: "paused" }
241
+ : { kind: "active" },
242
+ supply: BigInt(parsed.supply),
243
+ };
244
+ }
245
+ /** Fetches and parses a `Listing<Currency>`, or `null` if that currency is not listed. */
246
+ export async function getListing(client, listingId) {
247
+ const got = await fetch(client, listingId);
248
+ if (!got)
249
+ return null;
250
+ const parsed = listing.Listing.parse(got.content);
251
+ const p = parsed.price;
252
+ const priceKind = variant(p, "Fixed", "Floor");
253
+ const st = parsed.state;
254
+ return {
255
+ id: listingId,
256
+ releaseId: parsed.release_id,
257
+ pressingId: parsed.pressing_id,
258
+ price: {
259
+ kind: priceKind === "Fixed" ? "fixed" : "floor",
260
+ amount: BigInt((priceKind === "Fixed" ? p.Fixed?.amount : p.Floor?.amount) ?? "0"),
261
+ },
262
+ state: variant(st, "Enabled", "Disabled") === "Enabled" ? "enabled" : "disabled",
263
+ currencyType: currencyFromType(got.type),
264
+ };
265
+ }
266
+ /**
267
+ * Resolves a release's run AND one currency's offer in a single round trip, by pure
268
+ * address math — no registry, no pointer, no event scan. `pressing: null` means the
269
+ * release has never opened one; `listing: null` means it does not sell in that
270
+ * currency (the other currencies, if any, are unaffected).
271
+ */
272
+ export async function getSale(client, p) {
273
+ const { pressingId, listingId } = deriveSaleIds(p.releaseId, p.currencyType, p.misoPressingPackageId);
274
+ const [pressingView, listingView] = await Promise.all([
275
+ getPressing(client, pressingId),
276
+ getListing(client, listingId),
277
+ ]);
278
+ return { pressing: pressingView, listing: listingView };
279
+ }
280
+ //# sourceMappingURL=pressing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pressing.js","sourceRoot":"","sources":["../src/pressing.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAgBtC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,sCAAsC,CAAC;AAChE,OAAO,KAAK,QAAQ,MAAM,uCAAuC,CAAC;AAoBlE,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E,uFAAuF;AACvF,MAAM,qBAAqB,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,qBAA6B;IAC/E,OAAO,cAAc,CAAC,SAAS,EAAE,G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,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Shared read plumbing for the platform reads.
4
+ // `isNotFound` is the protocol SDK's — the not-found taxonomy is a property of
5
+ // the Sui transports, not of any one package's objects, so it is defined once in
6
+ // `@misonetwork/sdk` and re-exported here for the platform readers.
7
+ export { isNotFound } from "@misonetwork/sdk";
8
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAEtC,+CAA+C;AAE/C,+EAA+E;AAC/E,iFAAiF;AACjF,oEAAoE;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { Transaction } from "@mysten/sui/transactions";
2
+ import { type ShareRecipient } from "./transactions.ts";
3
+ /** A royalty pool to attach to a work, in the same PTB. */
4
+ export interface RoyaltyPoolNode {
5
+ currency: string;
6
+ /** `composition_royalty_pool` / `recording_royalty_pool` package id. */
7
+ extensionPackageId: string;
8
+ /** Base `royalty_pool` lib package id. */
9
+ royaltyPoolPackageId: string;
10
+ }
11
+ export interface CompositionNode {
12
+ shareType: string;
13
+ shareCurrencyId: string;
14
+ shareTreasuryCapId: string;
15
+ title: string;
16
+ royaltyRateBps: number;
17
+ shareRecipients: ShareRecipient[];
18
+ /** Recipient of the CompositionAdminCap (the owner). */
19
+ adminAddress: string;
20
+ royaltyPool?: RoyaltyPoolNode;
21
+ }
22
+ export interface RecordingNode {
23
+ shareType: string;
24
+ shareCurrencyId: string;
25
+ shareTreasuryCapId: string;
26
+ /** The parent composition's share type. */
27
+ compositionShareType: string;
28
+ /** Index into `compositions[]` if the parent is created in THIS PTB… */
29
+ parentCompositionIndex?: number;
30
+ /** …or the on-chain composition object id if the parent already exists. */
31
+ parentCompositionId?: string;
32
+ shareRecipients: ShareRecipient[];
33
+ adminAddress: string;
34
+ /**
35
+ * Slippage guard for `recording::new` against an EXISTING on-chain parent —
36
+ * pass the composition rate you observed (default: protocol max). Ignored for
37
+ * parents created in this PTB, whose exact known rate is pinned automatically.
38
+ */
39
+ maxRoyaltyRateBps?: number;
40
+ royaltyPool?: RoyaltyPoolNode;
41
+ }
42
+ /** A track whose recording is created in THIS PTB (its deal is created inline). */
43
+ export interface FreshTrackNode {
44
+ /** Index into `recordings[]`. */
45
+ recordingIndex: number;
46
+ splitBps: number;
47
+ }
48
+ /**
49
+ * A track over an EXISTING recording, authorized by its admin cap (held by the
50
+ * sender) — the deal is created inline against the on-chain-derived release id.
51
+ * This is the only way to mix existing recordings with ones created in this PTB.
52
+ */
53
+ export interface CapTrackNode {
54
+ recordingId: string;
55
+ recordingAdminCapId: string;
56
+ recordingShareType: string;
57
+ compositionShareType: string;
58
+ splitBps: number;
59
+ }
60
+ /**
61
+ * A track over an EXISTING recording, authorized by a pre-made `Deal` held by
62
+ * the sender. A deal pins the exact release id — a digest over ALL track
63
+ * recording ids — so deal-backed tracks cannot coexist with `FreshTrackNode`s
64
+ * (a fresh recording's id is unknowable when the deal was created).
65
+ * `splitBps` must be the value stored in the deal (read it from the object).
66
+ */
67
+ export interface DealTrackNode {
68
+ dealId: string;
69
+ recordingId: string;
70
+ recordingShareType: string;
71
+ compositionShareType: string;
72
+ splitBps: number;
73
+ }
74
+ export type TrackNode = FreshTrackNode | CapTrackNode | DealTrackNode;
75
+ export interface ReleaseNode {
76
+ title: string;
77
+ /** u256 nonce as a decimal string (deterministic release id). */
78
+ nonce: string;
79
+ adminAddress: string;
80
+ releaseRegistryId: string;
81
+ /** The ordered tracklist. Display grouping (discs/sides) is extension data. */
82
+ tracks: TrackNode[];
83
+ }
84
+ export interface PublishReleaseGraphParams {
85
+ compositions: CompositionNode[];
86
+ recordings: RecordingNode[];
87
+ release?: ReleaseNode;
88
+ misoPackageId: string;
89
+ minatoPackageId: string;
90
+ }
91
+ /** Builds the entire graph in a single transaction (see file header for ordering). */
92
+ export declare function publishReleaseGraph(params: PublishReleaseGraphParams): (tx: Transaction) => void;
93
+ //# sourceMappingURL=release-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-graph.d.ts","sourceRoot":"","sources":["../src/release-graph.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,WAAW,EAAkC,MAAM,0BAA0B,CAAC;AAQvF,OAAO,EAAmC,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIzF,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,cAAc,EAAE,CAAC;IACl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