@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,237 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Transaction builders follow the Sui SDK thunk pattern: a builder returns a
4
+ // `(tx: Transaction) => …` thunk that adds commands to a caller-owned
5
+ // `Transaction`, so a platform call composes with protocol calls and anything
6
+ // else in the same PTB.
7
+ //
8
+ // This module holds the OPINIONATED publish flows. `@misonetwork/sdk` does the
9
+ // minimum the Move semantics FORCE and returns anything a caller could
10
+ // legitimately route elsewhere; deciding where those values GO is the
11
+ // platform-layer call that lives here:
12
+ //
13
+ // - minting a work's share supply is a protocol primitive
14
+ // (`createComposition`/`createRecording`) — dispersing it to recipients via
15
+ // minato, publishing (sharing) the work, and transferring its admin cap is
16
+ // an opinion about economics;
17
+ // - minting a release is likewise a primitive (`createRelease`) — choosing a
18
+ // track-assembly strategy, publishing (sharing) it, and picking a recipient
19
+ // for its `ReleaseAdminCap` is the opinion, so `finalizeRelease` /
20
+ // `publishRelease` / `publishReleaseFromDeals` live here.
21
+ //
22
+ // Every `finalize*` here MUST run in the same PTB as the `create*` that produced
23
+ // its parts — `Composition`, `Recording`, and `Release` are all `key`-only with
24
+ // no `drop`, so none can outlive its creating transaction. That is a same-PTB
25
+ // constraint, not a same-function one, which is exactly what makes this split
26
+ // possible.
27
+ //
28
+ // Composes with `@misonetwork/sdk`'s calls in the same PTB (the
29
+ // transaction-thunk composition pattern, just crossing a package boundary now).
30
+ import { Transaction } from "@mysten/sui/transactions";
31
+ import { contracts, createComposition, createRecording, createRelease, } from "@misonetwork/sdk";
32
+ const { deal, track, release } = contracts;
33
+ /**
34
+ * Splits a share `Balance` across `recipients` via `minato::disperse_balance`, then
35
+ * destroys the emptied balance. Exposed for consumers assembling custom share
36
+ * distributions in their own PTBs.
37
+ */
38
+ export function disperseShares(tx, minatoPackageId, shareType, balance, recipients) {
39
+ tx.moveCall({
40
+ target: `${minatoPackageId}::minato::disperse_balance`,
41
+ typeArguments: [shareType],
42
+ arguments: [
43
+ balance,
44
+ tx.makeMoveVec({ type: "u64", elements: recipients.map((r) => tx.pure.u64(r.value)) }),
45
+ tx.makeMoveVec({ type: "address", elements: recipients.map((r) => tx.pure.address(r.address)) }),
46
+ ],
47
+ });
48
+ tx.moveCall({ target: "0x2::balance::destroy_zero", typeArguments: [shareType], arguments: [balance] });
49
+ }
50
+ export function publishShareCurrency(bytecode) {
51
+ return (tx) => {
52
+ const upgradeCap = tx.publish(bytecode);
53
+ tx.moveCall({ target: "0x2::package::make_immutable", arguments: [upgradeCap] });
54
+ };
55
+ }
56
+ const SUI_COIN_REGISTRY_ID = "0xc";
57
+ export function initializeShareCurrency(params) {
58
+ const { shareCurrencyPackageId, name, description, iconUrl, treasuryCapRecipient } = params;
59
+ return (tx) => {
60
+ const treasuryCap = tx.moveCall({
61
+ target: `${shareCurrencyPackageId}::share::initialize`,
62
+ arguments: [tx.pure.string(name), tx.pure.string(description), tx.pure.string(iconUrl), tx.object(SUI_COIN_REGISTRY_ID)],
63
+ });
64
+ tx.transferObjects([treasuryCap], treasuryCapRecipient);
65
+ };
66
+ }
67
+ /**
68
+ * The opinionated finish for a composition: disperse its share supply to
69
+ * `shareRecipients`, publish (share) it, and transfer its admin cap to
70
+ * `adminAddress`. Consumers that want different economics skip this and act on
71
+ * the `CompositionParts` from `@misonetwork/sdk`'s `createComposition` directly.
72
+ */
73
+ export function finalizeComposition(tx, params) {
74
+ disperseShares(tx, params.minatoPackageId, params.shareType, params.balance, params.shareRecipients);
75
+ tx.add(contracts.composition.publish({ package: params.misoPackageId, typeArguments: [params.shareType], arguments: [params.composition, params.adminCap] }));
76
+ tx.transferObjects([params.adminCap], params.adminAddress);
77
+ }
78
+ /** Convenience: publish a composition end-to-end (createComposition → finalizeComposition). */
79
+ export function publishComposition(params) {
80
+ return (tx) => {
81
+ const parts = createComposition(tx, {
82
+ shareType: params.shareType,
83
+ shareCurrencyId: params.shareCurrencyId,
84
+ shareTreasuryCapId: params.shareTreasuryCapId,
85
+ title: params.title,
86
+ royaltyRateBps: params.royaltyRateBps,
87
+ misoPackageId: params.misoPackageId,
88
+ });
89
+ finalizeComposition(tx, {
90
+ ...parts,
91
+ shareType: params.shareType,
92
+ shareRecipients: params.shareRecipients,
93
+ adminAddress: params.adminAddress,
94
+ misoPackageId: params.misoPackageId,
95
+ minatoPackageId: params.minatoPackageId,
96
+ });
97
+ };
98
+ }
99
+ /**
100
+ * The opinionated finish for a recording: publish (share) it, disperse its
101
+ * share supply, and transfer its admin cap to `adminAddress`. A recording has
102
+ * no embedded metadata to set — naming lives in the metadata extension.
103
+ */
104
+ export function finalizeRecording(tx, params) {
105
+ const typeArguments = [params.recordingShareType, params.compositionShareType];
106
+ tx.add(contracts.recording.publish({ package: params.misoPackageId, typeArguments, arguments: [params.recording, params.adminCap] }));
107
+ disperseShares(tx, params.minatoPackageId, params.recordingShareType, params.balance, params.shareRecipients);
108
+ tx.transferObjects([params.adminCap], params.adminAddress);
109
+ }
110
+ /** Convenience: publish a recording against an already-on-chain composition. */
111
+ export function publishRecording(params) {
112
+ return (tx) => {
113
+ const parts = createRecording(tx, {
114
+ shareType: params.shareType,
115
+ shareCurrencyId: params.shareCurrencyId,
116
+ shareTreasuryCapId: params.shareTreasuryCapId,
117
+ compositionShareType: params.compositionShareType,
118
+ composition: tx.object(params.compositionId),
119
+ maxRoyaltyRateBps: params.maxRoyaltyRateBps,
120
+ misoPackageId: params.misoPackageId,
121
+ });
122
+ finalizeRecording(tx, {
123
+ ...parts,
124
+ recordingShareType: params.shareType,
125
+ compositionShareType: params.compositionShareType,
126
+ shareRecipients: params.shareRecipients,
127
+ adminAddress: params.adminAddress,
128
+ misoPackageId: params.misoPackageId,
129
+ minatoPackageId: params.minatoPackageId,
130
+ });
131
+ };
132
+ }
133
+ /**
134
+ * Publishes a composition and its recording in a single atomic PTB.
135
+ *
136
+ * The ordering is load-bearing: `recording::new` borrows the composition by
137
+ * immutable reference, so it must run while the composition is still an unshared,
138
+ * transaction-local value — i.e. AFTER `composition::new` but BEFORE
139
+ * `composition::publish` (which moves the composition into `share_object`). Hence:
140
+ * `composition::new` → `recording::new(&comp)` → finalize composition (publish) →
141
+ * finalize recording (publish).
142
+ */
143
+ export function publishCompositionAndRecording(params) {
144
+ return (tx) => {
145
+ const comp = createComposition(tx, {
146
+ shareType: params.composition.shareType,
147
+ shareCurrencyId: params.composition.shareCurrencyId,
148
+ shareTreasuryCapId: params.composition.shareTreasuryCapId,
149
+ title: params.title,
150
+ royaltyRateBps: params.royaltyRateBps,
151
+ misoPackageId: params.misoPackageId,
152
+ });
153
+ // Borrow the still-unshared composition into recording::new before publishing it.
154
+ // The composition is created in this PTB with a known rate, so the slippage
155
+ // guard pins that exact value — front-running is structurally impossible here.
156
+ const rec = createRecording(tx, {
157
+ shareType: params.recording.shareType,
158
+ shareCurrencyId: params.recording.shareCurrencyId,
159
+ shareTreasuryCapId: params.recording.shareTreasuryCapId,
160
+ compositionShareType: params.composition.shareType,
161
+ composition: comp.composition,
162
+ maxRoyaltyRateBps: params.royaltyRateBps,
163
+ misoPackageId: params.misoPackageId,
164
+ });
165
+ finalizeComposition(tx, {
166
+ ...comp,
167
+ shareType: params.composition.shareType,
168
+ shareRecipients: params.composition.shareRecipients,
169
+ adminAddress: params.composition.adminAddress,
170
+ misoPackageId: params.misoPackageId,
171
+ minatoPackageId: params.minatoPackageId,
172
+ });
173
+ finalizeRecording(tx, {
174
+ ...rec,
175
+ recordingShareType: params.recording.shareType,
176
+ compositionShareType: params.composition.shareType,
177
+ shareRecipients: params.recording.shareRecipients,
178
+ adminAddress: params.recording.adminAddress,
179
+ misoPackageId: params.misoPackageId,
180
+ minatoPackageId: params.minatoPackageId,
181
+ });
182
+ };
183
+ }
184
+ /**
185
+ * The opinionated finish for a release: publish (share) it and transfer its
186
+ * admin cap to `adminAddress`.
187
+ *
188
+ * MUST run in the same PTB as the `createRelease` that produced these parts —
189
+ * `Release` is `key`-only with no `drop`, so an unpublished release cannot
190
+ * outlive its transaction. Splitting create from finalize is what lets a caller
191
+ * do something else with the cap (route it to a vault, hand it to another
192
+ * package, keep it for later commands) instead of a plain address transfer.
193
+ */
194
+ export function finalizeRelease(tx, params) {
195
+ tx.add(release.publish({ package: params.misoPackageId, arguments: [params.release, params.adminCap] }));
196
+ tx.transferObjects([params.adminCap], tx.pure.address(params.adminAddress));
197
+ }
198
+ function buildTrackVec(tx, misoPackageId, trackArgs) {
199
+ return tx.makeMoveVec({ type: `${misoPackageId}::track::Track`, elements: trackArgs });
200
+ }
201
+ /**
202
+ * Convenience: publish a release end-to-end, assembling its tracklist from
203
+ * recording admin caps held by the sender (a deal is created inline per track).
204
+ */
205
+ export function publishRelease(params) {
206
+ return (tx) => {
207
+ const { misoPackageId } = params;
208
+ const trackArgs = params.tracks.map((t) => {
209
+ const typeArguments = [t.recordingShareType, t.compositionShareType];
210
+ const dealArg = tx.add(deal._new({
211
+ package: misoPackageId,
212
+ typeArguments,
213
+ arguments: [tx.object(t.recordingAdminCapId), tx.object(t.recordingId), tx.pure.id(params.releaseId), tx.pure.u16(t.splitBps)],
214
+ }));
215
+ return tx.add(track._new({ package: misoPackageId, typeArguments, arguments: [dealArg, tx.object(t.recordingId)] }));
216
+ });
217
+ const parts = createRelease(tx, { title: params.title, nonce: params.releaseNonce, releaseRegistryId: params.releaseRegistryId, misoPackageId }, buildTrackVec(tx, misoPackageId, trackArgs));
218
+ finalizeRelease(tx, { ...parts, adminAddress: params.adminAddress, misoPackageId });
219
+ };
220
+ }
221
+ /**
222
+ * Convenience: publish a release end-to-end from pre-made `Deal`s held by the
223
+ * sender (each deal already pins this release's id).
224
+ */
225
+ export function publishReleaseFromDeals(params) {
226
+ return (tx) => {
227
+ const { misoPackageId } = params;
228
+ const trackArgs = params.deals.map((dl) => tx.add(track._new({
229
+ package: misoPackageId,
230
+ typeArguments: [dl.recordingShareType, dl.compositionShareType],
231
+ arguments: [tx.object(dl.dealId), tx.object(dl.recordingId)],
232
+ })));
233
+ const parts = createRelease(tx, { title: params.title, nonce: params.releaseNonce, releaseRegistryId: params.releaseRegistryId, misoPackageId }, buildTrackVec(tx, misoPackageId, trackArgs));
234
+ finalizeRelease(tx, { ...parts, adminAddress: params.adminAddress, misoPackageId });
235
+ };
236
+ }
237
+ //# sourceMappingURL=transactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.js","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAEtC,6EAA6E;AAC7E,sEAAsE;AACtE,8EAA8E;AAC9E,wBAAwB;AACxB,EAAE;AACF,+EAA+E;AAC/E,uEAAuE;AACvE,sEAAsE;AACtE,uCAAuC;AACvC,EAAE;AACF,4DAA4D;AAC5D,gFAAgF;AAChF,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAC/E,gFAAgF;AAChF,uEAAuE;AACvE,8DAA8D;AAC9D,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,8EAA8E;AAC9E,8EAA8E;AAC9E,YAAY;AACZ,EAAE;AACF,gEAAgE;AAChE,gFAAgF;AAEhF,OAAO,EAAE,WAAW,EAAkC,MAAM,0BAA0B,CAAC;AACvF,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,GAQd,MAAM,kBAAkB,CAAC;AAE1B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;AAe3C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,EAAe,EACf,eAAuB,EACvB,SAAiB,EACjB,OAAkC,EAClC,UAA4B;IAE5B,EAAE,CAAC,QAAQ,CAAC;QACV,MAAM,EAAE,GAAG,eAAe,4BAA4B;QACtD,aAAa,EAAE,CAAC,SAAS,CAAC;QAC1B,SAAS,EAAE;YACT,OAAO;YACP,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACtF,EAAE,CAAC,WAAW,CAAC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AuB,CAAC,MAAqC;IAC3E,OAAO,CAAC,EAAE,EAAE,EAAE;QACZ,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;QACjC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACxC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAChB,OAAO,EAAE,aAAa;YACtB,aAAa,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC;YAC/D,SAAS,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;SAC7D,CAAC,CAAC,CACJ,CAAC;QACF,MAAM,KAAK,GAAG,aAAa,CACzB,EAAE,EACF,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAAE,aAAa,EAAE,EAC/G,aAAa,CAAC,EAAE,EAAE,aAAa,EAAE,SAAS,CAAC,CAC5C,CAAC;QACF,eAAe,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@misofm/sdk",
3
+ "version": "0.1.0",
4
+ "description": "Typed query helpers and transaction builders for the Miso platform layer on Sui \u2014 pressings, listings, records, and opinionated work publishing.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/misofm/sdk.git"
9
+ },
10
+ "homepage": "https://github.com/misofm/sdk#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/misofm/sdk/issues"
13
+ },
14
+ "keywords": [
15
+ "sui",
16
+ "move",
17
+ "miso",
18
+ "music",
19
+ "blockchain",
20
+ "sdk",
21
+ "pressing"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "type": "module",
29
+ "sideEffects": false,
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./client": {
36
+ "types": "./dist/client.d.ts",
37
+ "default": "./dist/client.js"
38
+ },
39
+ "./pressing": {
40
+ "types": "./dist/pressing.d.ts",
41
+ "default": "./dist/pressing.js"
42
+ },
43
+ "./transactions": {
44
+ "types": "./dist/transactions.d.ts",
45
+ "default": "./dist/transactions.js"
46
+ },
47
+ "./execute": {
48
+ "types": "./dist/execute.d.ts",
49
+ "default": "./dist/execute.js"
50
+ },
51
+ "./share": {
52
+ "types": "./dist/share.d.ts",
53
+ "default": "./dist/share.js"
54
+ },
55
+ "./share-template": {
56
+ "types": "./dist/share-template.d.ts",
57
+ "default": "./dist/share-template.js"
58
+ },
59
+ "./release-graph": {
60
+ "types": "./dist/release-graph.d.ts",
61
+ "default": "./dist/release-graph.js"
62
+ },
63
+ "./catalog": {
64
+ "types": "./dist/catalog.d.ts",
65
+ "default": "./dist/catalog.js"
66
+ },
67
+ "./package.json": "./package.json"
68
+ },
69
+ "files": [
70
+ "dist",
71
+ "src",
72
+ "README.md",
73
+ "LICENSE",
74
+ "package.json"
75
+ ],
76
+ "scripts": {
77
+ "codegen": "sui-codegen generate",
78
+ "typecheck": "tsc --noEmit",
79
+ "test": "bun test",
80
+ "build": "tsc -p tsconfig.build.json",
81
+ "prepack": "tsc -p tsconfig.build.json",
82
+ "prepare": "tsc -p tsconfig.build.json"
83
+ },
84
+ "devDependencies": {
85
+ "@mysten/codegen": "^0.11.14",
86
+ "@mysten/move-bytecode-template": "^0.4.0",
87
+ "@mysten/sui": "^2.24.0",
88
+ "@types/bun": "^1.3.14"
89
+ },
90
+ "peerDependencies": {
91
+ "@mysten/move-bytecode-template": "^0.4.0",
92
+ "@mysten/sui": "^2.4.0",
93
+ "typescript": "^5"
94
+ },
95
+ "dependencies": {
96
+ "@misonetwork/sdk": "^0.2.2"
97
+ },
98
+ "main": "./dist/index.js"
99
+ }
package/src/catalog.ts ADDED
@@ -0,0 +1,77 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Composed catalog reads.
5
+ //
6
+ // `@misonetwork/sdk` exposes one-question reads: fetch an object by id, list the
7
+ // caps an address owns, resolve a share type to its work. Stitching several of
8
+ // those together to answer a PRODUCT question — "show me everything this artist
9
+ // administers" — is orchestration, and it lives here for the same reason the
10
+ // opinionated publish flows do: it picks a traversal strategy, decides how much
11
+ // to fetch, and chooses a concurrency/rate-limit tradeoff. Those are platform
12
+ // calls, not protocol facts.
13
+
14
+ import type { ClientWithCoreApi } from "@mysten/sui/client";
15
+ import type { SuiGraphQLClient } from "@mysten/sui/graphql";
16
+ import {
17
+ getOwnedRecordingAdminCaps,
18
+ getRecordingByShareType,
19
+ type Recording,
20
+ } from "@misonetwork/sdk";
21
+
22
+ export interface GetAdministeredRecordingsOptions {
23
+ /**
24
+ * Maximum lookups in flight at once. The traversal is one lookup per admin
25
+ * cap, so an artist with a large catalog would otherwise open as many
26
+ * concurrent requests as they have recordings. Defaults to 10.
27
+ */
28
+ concurrency?: number;
29
+ }
30
+
31
+ /**
32
+ * Every `Recording` administered by `owner`.
33
+ *
34
+ * Two stages: list the owner's `RecordingAdminCap`s over the Core API, then
35
+ * resolve each cap's share type back to its recording.
36
+ *
37
+ * The second stage needs GraphQL and is inherently one lookup per cap, because
38
+ * `RecordingAdminCap` carries no back-pointer to its recording — unlike
39
+ * `ReleaseAdminCap`, which stores `release_id` and can therefore be resolved
40
+ * entirely over the Core API. The caps are derived objects (recording → cap via
41
+ * `deriveObjectID`), and that derivation cannot be inverted, so the share type
42
+ * is the only link back. Adding a `recording_id: ID` field to
43
+ * `RecordingAdminCap` on the protocol side would make this a pure Core-API
44
+ * batch read and remove both the GraphQL dependency and the fan-out.
45
+ *
46
+ * Until then the lookups run concurrently in bounded batches rather than
47
+ * serially.
48
+ */
49
+ export async function getAdministeredRecordings(
50
+ client: ClientWithCoreApi,
51
+ graphqlClient: SuiGraphQLClient,
52
+ owner: string,
53
+ misoPackageId: string,
54
+ options: GetAdministeredRecordingsOptions = {},
55
+ ): Promise<Recording[]> {
56
+ const concurrency = Math.max(1, options.concurrency ?? 10);
57
+ const caps = await getOwnedRecordingAdminCaps(client, owner, misoPackageId);
58
+
59
+ const recordings: Recording[] = [];
60
+ for (let i = 0; i < caps.length; i += concurrency) {
61
+ const batch = caps.slice(i, i + concurrency);
62
+ const settled = await Promise.all(
63
+ batch.map(async (cap) => {
64
+ try {
65
+ return await getRecordingByShareType(client, graphqlClient, cap.shareType, misoPackageId);
66
+ } catch {
67
+ // A cap whose recording cannot be resolved is skipped rather than
68
+ // failing the whole catalog — matching the previous behavior, where a
69
+ // missing address was silently passed over.
70
+ return null;
71
+ }
72
+ }),
73
+ );
74
+ for (const rec of settled) if (rec) recordings.push(rec);
75
+ }
76
+ return recordings;
77
+ }
package/src/client.ts ADDED
@@ -0,0 +1,249 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // The client extension — Sui's recommended shape for an SDK
5
+ // (https://sdk.mystenlabs.com/sui/sdk-building). Register it once and the
6
+ // platform layer hangs off whatever client you already have:
7
+ //
8
+ // const client = new SuiGrpcClient({ network, baseUrl })
9
+ // .$extend(misoPlatform({ packageId, settingsId }));
10
+ //
11
+ // await client.misoPlatform.getSale({ releaseId, currencyType });
12
+ // tx.add(client.misoPlatform.tx.buyRecord({ releaseId, currencyType, amount, recipient }));
13
+ //
14
+ // Two things this buys over calling the bare functions:
15
+ //
16
+ // IDS ARE CONFIGURED ONCE. Every builder and reader below needs the pressing
17
+ // package id, and half of them need the record `Settings` too. Threading those
18
+ // through 20 call sites is how an app ends up publishing against one package and
19
+ // reading against another.
20
+ //
21
+ // IT COMPOSES. `register` takes the transport-agnostic `ClientWithCoreApi`, never
22
+ // a concrete client, so this works on gRPC, GraphQL, or JSON-RPC — and the
23
+ // builders stay thunks, so a platform call and a protocol call go in the same PTB.
24
+ //
25
+ // Namespaces follow the guide's convention: top-level methods read and parse,
26
+ // `tx` builds transactions without executing, `bcs` exposes the generated struct
27
+ // definitions, `ids` is the address math that replaces a registry.
28
+
29
+ import type { ClientWithCoreApi } from "@mysten/sui/client";
30
+ import type { Signer } from "@mysten/sui/cryptography";
31
+
32
+ import * as listingContract from "./contracts/miso_pressing/listing.ts";
33
+ import * as pressingContract from "./contracts/miso_pressing/pressing.ts";
34
+ import {
35
+ buyRecord,
36
+ deriveListingId,
37
+ derivePressingAdminCapId,
38
+ derivePressingId,
39
+ deriveSaleIds,
40
+ getListing,
41
+ getPressing,
42
+ getSale,
43
+ openListing,
44
+ openPressing,
45
+ setListingPrice,
46
+ setListingState,
47
+ setPressingState,
48
+ } from "./pressing.ts";
49
+ import type {
50
+ BuyRecordParams,
51
+ GetSaleParams,
52
+ ListingView,
53
+ OpenListingParams,
54
+ OpenPressingParams,
55
+ PressingView,
56
+ SetListingPriceParams,
57
+ SetListingStateParams,
58
+ SetPressingStateParams,
59
+ } from "./pressing.ts";
60
+ import {
61
+ publishShareCurrency,
62
+ initializeShareCurrency,
63
+ publishComposition,
64
+ publishRecording,
65
+ publishCompositionAndRecording,
66
+ } from "./transactions.ts";
67
+ import type {
68
+ TxThunk,
69
+ PublishCompositionParams,
70
+ PublishRecordingParams,
71
+ PublishCompositionAndRecordingParams,
72
+ } from "./transactions.ts";
73
+ import * as share from "./share.ts";
74
+
75
+ export interface MisoPlatformConfig {
76
+ /** The published `miso_pressing` package. */
77
+ packageId: string;
78
+ /**
79
+ * The `miso_record` shared `Settings` that authorizes `miso_pressing`'s
80
+ * `MintWitness`. Required to buy; optional if this client only ever reads.
81
+ */
82
+ settingsId?: string;
83
+ /**
84
+ * The `@misonetwork/sdk` protocol package (miso core). Required for the
85
+ * publish builders (`publishComposition`, `publishRecording`,
86
+ * `publishCompositionAndRecording`) — optional if this client only ever
87
+ * sells pressed records.
88
+ */
89
+ misoPackageId?: string;
90
+ /**
91
+ * The minato share-disperse package. Bound into the publish builders so
92
+ * callers don't repeat it; required alongside `misoPackageId` for the same
93
+ * builders (they disperse shares via minato).
94
+ */
95
+ minatoPackageId?: string;
96
+ }
97
+
98
+ /** Params with the ids this client already knows dropped from the call site. */
99
+ type Configured<T> = Omit<T, "misoPressingPackageId" | "settingsId">;
100
+
101
+ /** Publish-builder params with the protocol/minato ids this client already knows dropped. */
102
+ type ConfiguredPublish<T> = Omit<T, "misoPackageId" | "minatoPackageId">;
103
+
104
+ export class MisoPlatformClient {
105
+ readonly #client: ClientWithCoreApi;
106
+ readonly #config: MisoPlatformConfig;
107
+
108
+ constructor(client: ClientWithCoreApi, config: MisoPlatformConfig) {
109
+ this.#client = client;
110
+ this.#config = config;
111
+ }
112
+
113
+ get packageId(): string {
114
+ return this.#config.packageId;
115
+ }
116
+
117
+ #settings(): string {
118
+ const { settingsId } = this.#config;
119
+ if (!settingsId) {
120
+ throw new Error(
121
+ "misoPlatform: `settingsId` is required to build a purchase — pass it to misoPlatform({ settingsId }).",
122
+ );
123
+ }
124
+ return settingsId;
125
+ }
126
+
127
+ #misoPackageId(): string {
128
+ const { misoPackageId } = this.#config;
129
+ if (!misoPackageId) {
130
+ throw new Error(
131
+ "misoPlatform: `misoPackageId` is required for the publish builders " +
132
+ "(publishComposition, publishRecording, publishCompositionAndRecording) — pass it to misoPlatform({ misoPackageId }).",
133
+ );
134
+ }
135
+ return misoPackageId;
136
+ }
137
+
138
+ #minatoPackageId(): string {
139
+ const { minatoPackageId } = this.#config;
140
+ if (!minatoPackageId) {
141
+ throw new Error(
142
+ "misoPlatform: `minatoPackageId` is required for the publish builders that disperse shares " +
143
+ "(publishComposition, publishRecording, publishCompositionAndRecording) — pass it to misoPlatform({ minatoPackageId }).",
144
+ );
145
+ }
146
+ return minatoPackageId;
147
+ }
148
+
149
+ // ── Reads ─────────────────────────────────────────────────────────────────
150
+
151
+ /** The run itself, or `null` if this release has never opened one. */
152
+ getPressing(pressingId: string): Promise<PressingView | null> {
153
+ return getPressing(this.#client, pressingId);
154
+ }
155
+
156
+ /** One currency's offer, or `null` if the run does not sell in it. */
157
+ getListing(listingId: string): Promise<ListingView | null> {
158
+ return getListing(this.#client, listingId);
159
+ }
160
+
161
+ /** Run + one currency's offer in a single round trip, by address math. */
162
+ getSale(p: Configured<GetSaleParams>): Promise<{
163
+ pressing: PressingView | null;
164
+ listing: ListingView | null;
165
+ }> {
166
+ return getSale(this.#client, { ...p, misoPressingPackageId: this.packageId });
167
+ }
168
+
169
+ // ── Address math ──────────────────────────────────────────────────────────
170
+
171
+ readonly ids = {
172
+ pressing: (releaseId: string) => derivePressingId(releaseId, this.packageId),
173
+ pressingAdminCap: (pressingId: string) =>
174
+ derivePressingAdminCapId(pressingId, this.packageId),
175
+ listing: (pressingId: string, currencyType: string) =>
176
+ deriveListingId(pressingId, currencyType, this.packageId),
177
+ sale: (releaseId: string, currencyType: string) =>
178
+ deriveSaleIds(releaseId, currencyType, this.packageId),
179
+ };
180
+
181
+ // ── Transaction builders ──────────────────────────────────────────────────
182
+
183
+ readonly tx = {
184
+ buyRecord: (p: Configured<BuyRecordParams>): TxThunk =>
185
+ buyRecord({
186
+ ...p,
187
+ settingsId: this.#settings(),
188
+ misoPressingPackageId: this.packageId,
189
+ }),
190
+ openPressing: (p: Configured<OpenPressingParams>): TxThunk =>
191
+ openPressing({ ...p, misoPressingPackageId: this.packageId }),
192
+ openListing: (p: Configured<OpenListingParams>): TxThunk =>
193
+ openListing({ ...p, misoPressingPackageId: this.packageId }),
194
+ setListingPrice: (p: Configured<SetListingPriceParams>): TxThunk =>
195
+ setListingPrice({ ...p, misoPressingPackageId: this.packageId }),
196
+ setListingState: (p: Configured<SetListingStateParams>): TxThunk =>
197
+ setListingState({ ...p, misoPressingPackageId: this.packageId }),
198
+ setPressingState: (p: Configured<SetPressingStateParams>): TxThunk =>
199
+ setPressingState({ ...p, misoPressingPackageId: this.packageId }),
200
+
201
+ // Publishing (protocol works + minato share economics) — package-id-free
202
+ // builders pass through unchanged; the rest bind this client's
203
+ // `misoPackageId`/`minatoPackageId`, throwing at call time if either is
204
+ // missing (kept optional on the client so a sell-only client, e.g. a
205
+ // storefront that never mints new works, doesn't need to carry them).
206
+ publishShareCurrency,
207
+ initializeShareCurrency,
208
+ publishComposition: (p: ConfiguredPublish<PublishCompositionParams>): TxThunk =>
209
+ publishComposition({ ...p, misoPackageId: this.#misoPackageId(), minatoPackageId: this.#minatoPackageId() }),
210
+ publishRecording: (p: ConfiguredPublish<PublishRecordingParams>): TxThunk =>
211
+ publishRecording({ ...p, misoPackageId: this.#misoPackageId(), minatoPackageId: this.#minatoPackageId() }),
212
+ publishCompositionAndRecording: (p: ConfiguredPublish<PublishCompositionAndRecordingParams>): TxThunk =>
213
+ publishCompositionAndRecording({ ...p, misoPackageId: this.#misoPackageId(), minatoPackageId: this.#minatoPackageId() }),
214
+ };
215
+
216
+ // ── Share currency provisioning (executes; Signer pattern) ─────────────────
217
+
218
+ /** Publishes + initializes a fresh share currency (two txs). */
219
+ async createShareCurrency(signer: Signer, params: share.CreateShareCurrencyParams): Promise<share.ShareCurrency> {
220
+ return share.createShareCurrency(this.#client, signer, params);
221
+ }
222
+
223
+ // ── Generated layer ───────────────────────────────────────────────────────
224
+
225
+ /** Generated Move-call bindings, for commands this facade doesn't wrap. */
226
+ readonly call = { listing: listingContract, pressing: pressingContract };
227
+
228
+ /** Generated BCS definitions, for parsing objects or events yourself. */
229
+ readonly bcs = {
230
+ Pressing: pressingContract.Pressing,
231
+ PressingAdminCap: pressingContract.PressingAdminCap,
232
+ Listing: listingContract.Listing,
233
+ Price: listingContract.Price,
234
+ };
235
+ }
236
+
237
+ /**
238
+ * Registers the platform layer on a Sui client. Pass the result to `$extend`.
239
+ *
240
+ * `settingsId` is optional so a read-only client (an indexer, a catalog page) can
241
+ * skip it; asking to build a purchase without it throws rather than sending a
242
+ * transaction against the wrong `Settings`.
243
+ */
244
+ export function misoPlatform(config: MisoPlatformConfig) {
245
+ return {
246
+ name: "misoPlatform" as const,
247
+ register: (client: ClientWithCoreApi) => new MisoPlatformClient(client, config),
248
+ };
249
+ }