@misofm/platform 0.0.0 → 0.18.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 (168) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +686 -3
  3. package/dist/auth.d.ts +73 -0
  4. package/dist/auth.d.ts.map +1 -0
  5. package/dist/auth.js +193 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/catalog.d.ts +48 -0
  8. package/dist/catalog.d.ts.map +1 -0
  9. package/dist/catalog.js +92 -0
  10. package/dist/catalog.js.map +1 -0
  11. package/dist/client.d.ts +462 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/client.js +788 -0
  14. package/dist/client.js.map +1 -0
  15. package/dist/contracts.d.ts +34 -0
  16. package/dist/contracts.d.ts.map +1 -0
  17. package/dist/contracts.js +49 -0
  18. package/dist/contracts.js.map +1 -0
  19. package/dist/cover.d.ts +69 -0
  20. package/dist/cover.d.ts.map +1 -0
  21. package/dist/cover.js +132 -0
  22. package/dist/cover.js.map +1 -0
  23. package/dist/credits.d.ts +200 -0
  24. package/dist/credits.d.ts.map +1 -0
  25. package/dist/credits.js +465 -0
  26. package/dist/credits.js.map +1 -0
  27. package/dist/deployments.d.ts +224 -0
  28. package/dist/deployments.d.ts.map +1 -0
  29. package/dist/deployments.js +177 -0
  30. package/dist/deployments.js.map +1 -0
  31. package/dist/execute.d.ts +30 -0
  32. package/dist/execute.d.ts.map +1 -0
  33. package/dist/execute.js +31 -0
  34. package/dist/execute.js.map +1 -0
  35. package/dist/index.d.ts +21 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +52 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/internal.d.ts +13 -0
  40. package/dist/internal.d.ts.map +1 -0
  41. package/dist/internal.js +41 -0
  42. package/dist/internal.js.map +1 -0
  43. package/dist/mix.d.ts +144 -0
  44. package/dist/mix.d.ts.map +1 -0
  45. package/dist/mix.js +656 -0
  46. package/dist/mix.js.map +1 -0
  47. package/dist/pressing.d.ts +137 -0
  48. package/dist/pressing.d.ts.map +1 -0
  49. package/dist/pressing.js +390 -0
  50. package/dist/pressing.js.map +1 -0
  51. package/dist/publication.d.ts +216 -0
  52. package/dist/publication.d.ts.map +1 -0
  53. package/dist/publication.js +872 -0
  54. package/dist/publication.js.map +1 -0
  55. package/dist/queries.d.ts +2 -0
  56. package/dist/queries.d.ts.map +1 -0
  57. package/dist/queries.js +8 -0
  58. package/dist/queries.js.map +1 -0
  59. package/dist/read/artist.d.ts +18 -0
  60. package/dist/read/artist.d.ts.map +1 -0
  61. package/dist/read/artist.js +86 -0
  62. package/dist/read/artist.js.map +1 -0
  63. package/dist/read/catalog.d.ts +93 -0
  64. package/dist/read/catalog.d.ts.map +1 -0
  65. package/dist/read/catalog.js +441 -0
  66. package/dist/read/catalog.js.map +1 -0
  67. package/dist/read/client.d.ts +37 -0
  68. package/dist/read/client.d.ts.map +1 -0
  69. package/dist/read/client.js +50 -0
  70. package/dist/read/client.js.map +1 -0
  71. package/dist/read/config.d.ts +68 -0
  72. package/dist/read/config.d.ts.map +1 -0
  73. package/dist/read/config.js +63 -0
  74. package/dist/read/config.js.map +1 -0
  75. package/dist/read/genres.d.ts +7 -0
  76. package/dist/read/genres.d.ts.map +1 -0
  77. package/dist/read/genres.js +38 -0
  78. package/dist/read/genres.js.map +1 -0
  79. package/dist/read/index.d.ts +14 -0
  80. package/dist/read/index.d.ts.map +1 -0
  81. package/dist/read/index.js +23 -0
  82. package/dist/read/index.js.map +1 -0
  83. package/dist/read/internal/scalars.d.ts +23 -0
  84. package/dist/read/internal/scalars.d.ts.map +1 -0
  85. package/dist/read/internal/scalars.js +57 -0
  86. package/dist/read/internal/scalars.js.map +1 -0
  87. package/dist/read/internal/walrus.d.ts +6 -0
  88. package/dist/read/internal/walrus.d.ts.map +1 -0
  89. package/dist/read/internal/walrus.js +29 -0
  90. package/dist/read/internal/walrus.js.map +1 -0
  91. package/dist/read/receipts.d.ts +41 -0
  92. package/dist/read/receipts.d.ts.map +1 -0
  93. package/dist/read/receipts.js +398 -0
  94. package/dist/read/receipts.js.map +1 -0
  95. package/dist/read/types.d.ts +328 -0
  96. package/dist/read/types.d.ts.map +1 -0
  97. package/dist/read/types.js +21 -0
  98. package/dist/read/types.js.map +1 -0
  99. package/dist/read/wallet.d.ts +74 -0
  100. package/dist/read/wallet.d.ts.map +1 -0
  101. package/dist/read/wallet.js +578 -0
  102. package/dist/read/wallet.js.map +1 -0
  103. package/dist/read/works.d.ts +29 -0
  104. package/dist/read/works.d.ts.map +1 -0
  105. package/dist/read/works.js +191 -0
  106. package/dist/read/works.js.map +1 -0
  107. package/dist/recording-extensions.d.ts +62 -0
  108. package/dist/recording-extensions.d.ts.map +1 -0
  109. package/dist/recording-extensions.js +159 -0
  110. package/dist/recording-extensions.js.map +1 -0
  111. package/dist/release-extensions.d.ts +93 -0
  112. package/dist/release-extensions.d.ts.map +1 -0
  113. package/dist/release-extensions.js +190 -0
  114. package/dist/release-extensions.js.map +1 -0
  115. package/dist/release-graph.d.ts +65 -0
  116. package/dist/release-graph.d.ts.map +1 -0
  117. package/dist/release-graph.js +136 -0
  118. package/dist/release-graph.js.map +1 -0
  119. package/dist/share-template.d.ts +3 -0
  120. package/dist/share-template.d.ts.map +1 -0
  121. package/dist/share-template.js +46 -0
  122. package/dist/share-template.js.map +1 -0
  123. package/dist/share.d.ts +67 -0
  124. package/dist/share.d.ts.map +1 -0
  125. package/dist/share.js +157 -0
  126. package/dist/share.js.map +1 -0
  127. package/dist/transactions.d.ts +216 -0
  128. package/dist/transactions.d.ts.map +1 -0
  129. package/dist/transactions.js +314 -0
  130. package/dist/transactions.js.map +1 -0
  131. package/dist/vault.d.ts +364 -0
  132. package/dist/vault.d.ts.map +1 -0
  133. package/dist/vault.js +507 -0
  134. package/dist/vault.js.map +1 -0
  135. package/package.json +145 -5
  136. package/src/auth.ts +275 -0
  137. package/src/catalog.ts +189 -0
  138. package/src/client.ts +1320 -0
  139. package/src/contracts.ts +54 -0
  140. package/src/cover.ts +240 -0
  141. package/src/credits.ts +906 -0
  142. package/src/deployments.ts +357 -0
  143. package/src/execute.ts +52 -0
  144. package/src/index.ts +69 -0
  145. package/src/internal.ts +46 -0
  146. package/src/mix.ts +910 -0
  147. package/src/pressing.ts +705 -0
  148. package/src/publication.ts +1214 -0
  149. package/src/queries.ts +9 -0
  150. package/src/read/artist.ts +118 -0
  151. package/src/read/catalog.ts +668 -0
  152. package/src/read/client.ts +87 -0
  153. package/src/read/config.ts +138 -0
  154. package/src/read/genres.ts +37 -0
  155. package/src/read/index.ts +85 -0
  156. package/src/read/internal/scalars.ts +59 -0
  157. package/src/read/internal/walrus.ts +42 -0
  158. package/src/read/receipts.ts +476 -0
  159. package/src/read/types.ts +415 -0
  160. package/src/read/wallet.ts +687 -0
  161. package/src/read/works.ts +297 -0
  162. package/src/recording-extensions.ts +256 -0
  163. package/src/release-extensions.ts +311 -0
  164. package/src/release-graph.ts +219 -0
  165. package/src/share-template.ts +55 -0
  166. package/src/share.ts +261 -0
  167. package/src/transactions.ts +542 -0
  168. package/src/vault.ts +1009 -0
@@ -0,0 +1,357 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { MisoDeployment, MisoNetwork } from "@misofm/protocol/deployments";
5
+ import { MISO_DEPLOYMENTS } from "@misofm/protocol/deployments";
6
+ import { normalizeSuiObjectId } from "@mysten/sui/utils";
7
+ import { immutableSnapshot } from "./internal.ts";
8
+
9
+ /** Primary Record sales are unavailable on legacy deployments until both new
10
+ * immutable packages have been freshly published and verified. */
11
+ export type RecordSalesDeployment =
12
+ | {
13
+ readonly status: "unavailable";
14
+ readonly reason: string;
15
+ readonly legacy?: {
16
+ readonly recordPackageId: string;
17
+ readonly pressingPackageId: string;
18
+ };
19
+ }
20
+ | {
21
+ readonly status: "available";
22
+ readonly recordPackageId: string;
23
+ readonly recordShopPackageId: string;
24
+ };
25
+
26
+ export class RecordSalesUnavailableError extends Error {
27
+ override readonly name = "RecordSalesUnavailableError";
28
+ constructor(readonly reason: string) {
29
+ super(`@misofm/platform: Record sales are unavailable: ${reason}`);
30
+ }
31
+ }
32
+
33
+ export function requireRecordSalesDeployment(
34
+ deployment: RecordSalesDeployment | undefined,
35
+ ): Extract<RecordSalesDeployment, { status: "available" }> {
36
+ if (!deployment || deployment.status === "unavailable") {
37
+ throw new RecordSalesUnavailableError(
38
+ deployment?.reason ?? "no Record sales deployment was configured",
39
+ );
40
+ }
41
+ const canonicalPackageId = (value: string): boolean => {
42
+ if (!/^0x[0-9a-f]{64}$/.test(value)) return false;
43
+ try {
44
+ return normalizeSuiObjectId(value) === value;
45
+ } catch {
46
+ return false;
47
+ }
48
+ };
49
+ if (
50
+ !canonicalPackageId(deployment.recordPackageId) ||
51
+ !canonicalPackageId(deployment.recordShopPackageId)
52
+ ) {
53
+ throw new RecordSalesUnavailableError(
54
+ "Record and Record Shop package IDs must be canonical 32-byte Sui object IDs",
55
+ );
56
+ }
57
+ if (deployment.recordPackageId === deployment.recordShopPackageId) {
58
+ throw new RecordSalesUnavailableError(
59
+ "Record and Record Shop package IDs must be distinct",
60
+ );
61
+ }
62
+ return deployment;
63
+ }
64
+
65
+ /** Vault custody and the exact Action/plugin ABI deployed alongside it. */
66
+ export type OperationsDeployment =
67
+ | {
68
+ readonly status: "unavailable";
69
+ readonly reason: string;
70
+ /** Historical identities are metadata only and are never executable ABIs. */
71
+ readonly legacy?: {
72
+ readonly vaultPackageId?: string;
73
+ readonly vaultRegistryId?: string;
74
+ readonly packageIds?: Readonly<Record<string, string>>;
75
+ };
76
+ }
77
+ | {
78
+ readonly status: "available";
79
+ readonly vault: {
80
+ readonly packageId: string;
81
+ readonly registryId: string;
82
+ };
83
+ readonly actions: {
84
+ readonly compositionRoyaltyPool: string;
85
+ readonly recordingRoyaltyPool: string;
86
+ readonly partyWallet: string;
87
+ readonly compositionRoutedStake: string;
88
+ readonly releaseRevenueDistributor: string;
89
+ };
90
+ readonly plugins: {
91
+ readonly compositionRoyaltyPool: string;
92
+ readonly recordingRoyaltyPool: string;
93
+ readonly releaseRevenueDistributor: string;
94
+ };
95
+ };
96
+
97
+ export class OperationsUnavailableError extends Error {
98
+ override readonly name = "OperationsUnavailableError";
99
+ constructor(readonly reason: string) {
100
+ super(`@misofm/platform: Vault operations are unavailable: ${reason}`);
101
+ }
102
+ }
103
+
104
+ export type AvailableOperationsDeployment = Extract<
105
+ OperationsDeployment,
106
+ { status: "available" }
107
+ >;
108
+
109
+ function canonicalObjectId(value: unknown): value is string {
110
+ if (typeof value !== "string" || !/^0x[0-9a-f]{64}$/.test(value)) {
111
+ return false;
112
+ }
113
+ try {
114
+ return normalizeSuiObjectId(value) === value;
115
+ } catch {
116
+ return false;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Require one complete, non-aliased operations deployment.
122
+ *
123
+ * This validates only a complete canonical, pairwise-distinct structural set.
124
+ * It cannot establish provenance for arbitrary caller-supplied custom IDs; the
125
+ * caller owns that provenance. The bundled frozen map below is generated from
126
+ * one verified immutable admin export.
127
+ */
128
+ export function requireOperationsDeployment(
129
+ deployment: OperationsDeployment | undefined,
130
+ ): AvailableOperationsDeployment {
131
+ if (!deployment || deployment.status !== "available") {
132
+ throw new OperationsUnavailableError(
133
+ deployment?.reason ?? "no Vault operations deployment was configured",
134
+ );
135
+ }
136
+
137
+ const candidate = deployment as Partial<AvailableOperationsDeployment>;
138
+ const vault = candidate.vault as
139
+ | Partial<AvailableOperationsDeployment["vault"]>
140
+ | undefined;
141
+ const actions = candidate.actions as
142
+ | Partial<AvailableOperationsDeployment["actions"]>
143
+ | undefined;
144
+ const plugins = candidate.plugins as
145
+ | Partial<AvailableOperationsDeployment["plugins"]>
146
+ | undefined;
147
+ const packageEntries = [
148
+ ["vault.packageId", vault?.packageId],
149
+ ["actions.compositionRoyaltyPool", actions?.compositionRoyaltyPool],
150
+ ["actions.recordingRoyaltyPool", actions?.recordingRoyaltyPool],
151
+ ["actions.partyWallet", actions?.partyWallet],
152
+ ["actions.compositionRoutedStake", actions?.compositionRoutedStake],
153
+ ["actions.releaseRevenueDistributor", actions?.releaseRevenueDistributor],
154
+ ["plugins.compositionRoyaltyPool", plugins?.compositionRoyaltyPool],
155
+ ["plugins.recordingRoyaltyPool", plugins?.recordingRoyaltyPool],
156
+ ["plugins.releaseRevenueDistributor", plugins?.releaseRevenueDistributor],
157
+ ] as const;
158
+
159
+ for (const [field, id] of packageEntries) {
160
+ if (!canonicalObjectId(id)) {
161
+ throw new OperationsUnavailableError(
162
+ `${field} must be a canonical 32-byte Sui package ID`,
163
+ );
164
+ }
165
+ }
166
+ if (!canonicalObjectId(vault?.registryId)) {
167
+ throw new OperationsUnavailableError(
168
+ "vault.registryId must be a canonical 32-byte Sui object ID",
169
+ );
170
+ }
171
+
172
+ const identities = [
173
+ ...packageEntries.map(([, id]) => id as string),
174
+ vault.registryId,
175
+ ];
176
+ if (new Set(identities).size !== identities.length) {
177
+ throw new OperationsUnavailableError(
178
+ "the Vault registry object and all nine package IDs must be distinct",
179
+ );
180
+ }
181
+ return deployment;
182
+ }
183
+
184
+ /** Complete on-chain identity used by the Miso platform SDK on one network. */
185
+ export interface MisoPlatformDeployment {
186
+ /** Network name this immutable deployment set belongs to. */
187
+ readonly network: MisoNetwork;
188
+ /** Full ledger genesis digest used to reject a mislabeled RPC endpoint. */
189
+ readonly chainIdentifier: string;
190
+ /** The complete protocol and Party deployment this platform build targets. */
191
+ readonly protocol: MisoDeployment;
192
+ readonly recordSales: RecordSalesDeployment;
193
+ /** Fail-closed, structurally complete Vault/Action/plugin identity set. */
194
+ readonly operations: OperationsDeployment;
195
+ readonly packages: {
196
+ readonly minato: string;
197
+ readonly credit: string;
198
+ readonly compositionCredits: string;
199
+ readonly recordingCredits: string;
200
+ readonly releaseCredits: string;
201
+ /** Base royalty-pool value library. */
202
+ readonly royaltyPool: string;
203
+ /** Generic stake wrapper used by composition routed-stake operations. */
204
+ readonly routedStake: string;
205
+ /** Cover-art value type used by the release cover extension. */
206
+ readonly coverArt: string;
207
+ readonly releaseCoverArt: string;
208
+ /** Curated Genre vocabulary package used by release_genre. */
209
+ readonly genre: string;
210
+ readonly releaseDescription: string;
211
+ readonly releaseDspLink: string;
212
+ readonly releaseGenre: string;
213
+ readonly releaseKind: string;
214
+ readonly recordingAdvisory: string;
215
+ readonly recordingLanguage: string;
216
+ readonly recordingMasterReference: string;
217
+ /** Complete Walrus Quilt containing the Recording's streaming transcodes. */
218
+ readonly recordingStreamingTranscode?: string;
219
+ /** Canonical plaintext session pointer extension; absent before publication. */
220
+ readonly recordingEngineSession?: string;
221
+ /** Original immutable Record-gated Seal policy; absent before publication. */
222
+ readonly recordSealPolicy?: string;
223
+ readonly recordingPreview: string;
224
+ /** External `ori::walrus_data::WalrusData` dependency used by cover art. */
225
+ readonly ori: string;
226
+ };
227
+ readonly objects: {
228
+ readonly releaseRegistry: string;
229
+ /** Shared parent used to derive canonical Genre object ids. */
230
+ readonly genreRegistry: string;
231
+ /** Frozen namespace object embedded in Recording-session Seal identities. */
232
+ readonly recordGate?: string;
233
+ };
234
+ readonly legacy: {
235
+ readonly releaseCoverArtPackages: readonly string[];
236
+ };
237
+ }
238
+
239
+ /**
240
+ * Platform deployments bundled with this SDK release.
241
+ *
242
+ * IDs come only from verified immutable deployment output.
243
+ * Consumers may still pass an explicit complete deployment for custom networks.
244
+ */
245
+ export const MISO_PLATFORM_DEPLOYMENTS = immutableSnapshot({
246
+ testnet: {
247
+ network: "testnet",
248
+ chainIdentifier: "69WiPg3DAQiwdxfncX6wYQ2siKwAe6L9BZthQea3JNMD",
249
+ protocol: MISO_DEPLOYMENTS.testnet,
250
+ recordSales: {
251
+ status: "available",
252
+ recordPackageId:
253
+ "0x75e5fa520c39322e0526ff56a495f9a2a88d097e2df7902d94e58a9a12831e76",
254
+ recordShopPackageId:
255
+ "0x2b97df3773040bb2cffd8c329bfd57f05f1fd2defb6ab156050ba1ae540d5d2a",
256
+ },
257
+ operations: {
258
+ status: "available",
259
+ vault: {
260
+ packageId:
261
+ "0xaed1aa729452c77f4c62882b73317851d628c30af55355c81eb1c93d3d3276ac",
262
+ registryId:
263
+ "0x5de3c379a15e4609260a94ace3d186cc466366fc6aebafe5663c016057b6a2d6",
264
+ },
265
+ actions: {
266
+ compositionRoyaltyPool:
267
+ "0x46b9b193255f28ec5190e8cd37ae85397c9110266da73a4a7a94fcb6e990155b",
268
+ recordingRoyaltyPool:
269
+ "0x78964bdc2dd7fad943633542edf5a1c9be38b1d2d25de1cc6cca64757c7d037a",
270
+ partyWallet:
271
+ "0x934f15715f725e3eed2acaeda5c717b6641dce4bb88b7670db26249cb6646728",
272
+ compositionRoutedStake:
273
+ "0xb1539001eaf32350d7044acb03092dcbd5a366e708d959aece0cca683f7f57fc",
274
+ releaseRevenueDistributor:
275
+ "0xd19dde6c20fa41092c9645e8300284cf1a268ab5ed3b3c7a2a12593672203b45",
276
+ },
277
+ plugins: {
278
+ compositionRoyaltyPool:
279
+ "0xad3525b86fad3f2aaaa3fdf0430d690efba249e378b1b89ed8180ecbc5d89392",
280
+ recordingRoyaltyPool:
281
+ "0x2adfc809152c5c8cf07f0e466d881b62d48c7da3ae2e787c0471deb867a6a385",
282
+ releaseRevenueDistributor:
283
+ "0x4f1da8c04ec53749f6cf6e8d2d48701fd72654078240050e20e41dc774f93d46",
284
+ },
285
+ },
286
+ packages: {
287
+ minato:
288
+ "0xcdf58ed7e4580118a6a3f2a8077abffe633c551b2f19e95ce01685d42f90b8d9",
289
+ credit:
290
+ "0xc5a82310ce313af8f0ec18a4e564af11971b360db9e2ae686fef86fb2297a9a9",
291
+ compositionCredits:
292
+ "0xc58ac5d69740866f6514f68f2e9c86b1d069d819ad0bcf5384b6aaa66e0fbf53",
293
+ recordingCredits:
294
+ "0x7bafa653854f0820d911b8f6aa0aac3b131163c254b0021330881b77206d4d79",
295
+ releaseCredits:
296
+ "0x47ccd23c669b023b8678193e7748235916e16e737fdd8ba48b131ded29c76a00",
297
+ royaltyPool:
298
+ "0xecaa5a29cf8e110face3b80f0e4a5554e8c80edd8eda0983ed2f8015367eecca",
299
+ routedStake:
300
+ "0x30ed387d3fea69579ddb34d011fa6e1416580bfb3ee6587aabf103fb0d17bced",
301
+ coverArt:
302
+ "0x2b811f82d33cf6a9448adb11a598f6b04c14970cfc8e2982cde1d468e8e7d4a4",
303
+ releaseCoverArt:
304
+ "0x4f0a8736685f6b1ddbcd0bddcd7aae2d072aa3d4043efc0ad4042a7786068999",
305
+ genre:
306
+ "0x01e58dbc76c15c9ac137dabac1823ebd6ef81efd563c5121000bc11c51a47cc7",
307
+ releaseDescription:
308
+ "0x50f5acf7c0c05cdc7656072fd1bfc5ee76d02beabeae090103734b2d75118fa3",
309
+ releaseDspLink:
310
+ "0x9ca9ad8cab49c4897cd3cb89628b771ee4f10831ddc273036837751a5339d02a",
311
+ releaseGenre:
312
+ "0xfb73b04be2f72704ec5e6a1035bfab108e5ee2a72e72c0505f999291e23219bd",
313
+ releaseKind:
314
+ "0xfb2e5790f0577aca3ac8ddd672c4c58ef1e49ef1c3dfe14fb9676aaabf769169",
315
+ recordingAdvisory:
316
+ "0x23abf3f248466c08edc3349b202d6e809064c0e52098ff290cef1fdc51d5942e",
317
+ recordingLanguage:
318
+ "0xb3e1c578638a79acc7ab573c994206047ad8ef76893f9c5c987887c5b10a5c68",
319
+ recordingMasterReference:
320
+ "0x92a752854b80a6103721743125ee48223b577a023fe360e25d3aa695462a6d15",
321
+ recordingEngineSession:
322
+ "0xdd8f817a221e2acd5a4e6f34d0192d8e0dbddeb76c2dff2fdc82991cb4feb6c6",
323
+ recordSealPolicy:
324
+ "0xfa22d0678eaec39ad36b74c2c5439d574292e8fb19a9a15272733267499d5351",
325
+ recordingPreview:
326
+ "0x2be8405f6b77a30d6942cb240c0d804d608ef761395e6f861b71d9ae3c98f997",
327
+ ori: "0xf35cf353a62cef01084b51a9cf3da4c64c8724685ad1862f2f8284b71bd26c1a",
328
+ },
329
+ objects: {
330
+ releaseRegistry:
331
+ "0x452c9904677a1bbf92d4e07d86d2c3eb038c47595b0e17a23756f03887eb2a2a",
332
+ genreRegistry:
333
+ "0xda4cc070da1a71d43387973027a7230587a1b9c829d37c2af4a3adbc15fdb8a8",
334
+ recordGate:
335
+ "0x8fd51c8b31bb6012fb03d2be39ed7b9f0f581329b6b338c60c209110cc659f31",
336
+ },
337
+ legacy: {
338
+ releaseCoverArtPackages: [],
339
+ },
340
+ },
341
+ } as const) satisfies Partial<Record<MisoNetwork, MisoPlatformDeployment>>;
342
+
343
+ /** Resolve a bundled platform deployment, failing closed when it is unavailable. */
344
+ export function getMisoPlatformDeployment(
345
+ network: string,
346
+ ): MisoPlatformDeployment {
347
+ const deployment = (
348
+ MISO_PLATFORM_DEPLOYMENTS as Partial<Record<string, MisoPlatformDeployment>>
349
+ )[network];
350
+ if (!deployment) {
351
+ throw new Error(
352
+ `@misofm/platform: no bundled Miso platform deployment for network "${network}". ` +
353
+ "Pass an explicit deployment to miso() for custom networks.",
354
+ );
355
+ }
356
+ return deployment;
357
+ }
package/src/execute.ts ADDED
@@ -0,0 +1,52 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // `executeViaExecutor` — the one piece of transaction execution that's specific
5
+ // to this package's opinionated publish flows (batched, non-idempotent share-
6
+ // currency publishing in `share.ts`). Everything else — `buildTx`,
7
+ // `signAndExecute`, `toExecResult`, the object-change extractors — is generic
8
+ // PTB execution plumbing that stays in `@misofm/protocol`'s `execute.ts` and is
9
+ // re-exported from there; this module builds on top of it.
10
+
11
+ import type { ParallelTransactionExecutor } from "@mysten/sui/transactions";
12
+ import type { SuiClientTypes } from "@mysten/sui/client";
13
+ import { buildTx, toExecResult, FULL_INCLUDE, type ExecResult } from "@misofm/protocol";
14
+ import type { TxThunk } from "./transactions.ts";
15
+
16
+ // Consumers of the platform SDK should not need a second direct dependency on
17
+ // the protocol SDK just to execute a composed PTB. Keep the generic execution
18
+ // surface available through this platform-layer entry point as well.
19
+ export * from "@misofm/protocol/execute";
20
+
21
+ /** Publication execution also needs lifecycle events to associate same-typed
22
+ * objects (notably several new Parties and Vaults) with their manifest refs. */
23
+ export const PLATFORM_FULL_INCLUDE = { ...FULL_INCLUDE, events: true } as const;
24
+ type PlatformFullInclude = typeof PLATFORM_FULL_INCLUDE;
25
+
26
+ export interface PlatformExecResult extends ExecResult {
27
+ events: SuiClientTypes.Event[];
28
+ }
29
+
30
+ /**
31
+ * Builds a transaction from thunks and executes it through the parallel executor,
32
+ * exactly ONCE.
33
+ *
34
+ * These PTBs are typically non-idempotent (publish a package, initialize a
35
+ * currency, consume a TreasuryCap). A thrown transport error is ambiguous — the tx
36
+ * may already have committed — so blindly rebuilding and re-submitting would risk
37
+ * double-execution or a guaranteed abort against already-consumed inputs. We
38
+ * therefore do NOT auto-retry: any error propagates and recovery is the caller's
39
+ * job (e.g. a resumable checkpoint that reconciles against on-chain state). A Move
40
+ * abort RESOLVES as a `FailedTransaction`, so `toExecResult` surfaces it too.
41
+ */
42
+ export async function executeViaExecutor(
43
+ executor: ParallelTransactionExecutor,
44
+ ...thunks: TxThunk[]
45
+ ): Promise<PlatformExecResult> {
46
+ const tx = await buildTx(...thunks);
47
+ const res: SuiClientTypes.TransactionResult<PlatformFullInclude> =
48
+ await executor.executeTransaction(tx, PLATFORM_FULL_INCLUDE);
49
+ const base = toExecResult(res);
50
+ if (res.$kind !== "Transaction") throw new Error("unreachable: toExecResult accepted a failed transaction");
51
+ return { ...base, events: res.Transaction.events ?? [] };
52
+ }
package/src/index.ts ADDED
@@ -0,0 +1,69 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // `@misofm/platform` — the PLATFORM layer.
5
+ //
6
+ // Miso's own product sits on top of the permissionless protocol, and the two
7
+ // ship as separate packages because they have different promises:
8
+ //
9
+ // @misofm/protocol PROTOCOL — Composition, Recording, Release. The open layer
10
+ // anyone can build on, and nobody needs Miso's permission to use.
11
+ // @misofm/platform PLATFORM — Pressing, Listing, Record, and the first-party
12
+ // EXTENSIONS. How MISO sells copies of a release, and the
13
+ // opinions it attaches to a work along the way.
14
+ //
15
+ // A release is protocol. Pressing a record off it and selling that record is
16
+ // platform. Keeping the split at the package boundary is what stops the protocol
17
+ // from quietly growing a storefront. Core `release::new` uses its shared
18
+ // `ReleaseRegistry` as the PTB-callable derivation parent.
19
+ //
20
+ // Extensions live on this side of the line for the same reason. An extension is
21
+ // not part of what a Composition or Recording IS — it is a choice Miso makes
22
+ // about how to describe one (who gets credited and in what vocabulary, what the
23
+ // cover looks like, whether royalties accumulate in a pool). The protocol gives
24
+ // extensions a `&mut UID` hook and stops there; every opinion about what to hang
25
+ // off it is business logic, and business logic ships from the platform package.
26
+
27
+ // The recommended entry point is the client extension (see ./client.ts); the bare
28
+ // builders and readers stay exported for callers that hold ids themselves.
29
+ export {
30
+ miso,
31
+ misoPlatform,
32
+ MisoChainIdentifierMismatchError,
33
+ MisoClientNotReadyError,
34
+ MisoClient,
35
+ MisoNetworkMismatchError,
36
+ MisoPlatformClient,
37
+ } from "./client.ts";
38
+ export type {
39
+ ConfiguredReleaseGraphParams,
40
+ MisoOptions,
41
+ MisoPlatformConfig,
42
+ } from "./client.ts";
43
+ export * from "./deployments.ts";
44
+ export * from "./pressing.ts";
45
+ export * from "./transactions.ts";
46
+ export * from "./execute.ts";
47
+ export * from "./share.ts";
48
+ export * from "./share-template.ts";
49
+ export * from "./release-graph.ts";
50
+ export * from "./publication.ts";
51
+ export * from "./catalog.ts";
52
+ export * from "./mix.ts";
53
+
54
+ // High-level, JSON-safe platform projections used directly by clients and by
55
+ // the thin HTTP read service. Namespaced because these composed view types are
56
+ // intentionally distinct from the lower-level contract views above.
57
+ export * as read from "./read/index.ts";
58
+
59
+ // First-party extensions — attached to a protocol work via its cap-gated
60
+ // `uid_mut` hook.
61
+ export * from "./credits.ts";
62
+ export * from "./cover.ts";
63
+ export * from "./release-extensions.ts";
64
+ export * from "./recording-extensions.ts";
65
+ export * from "./mix.ts";
66
+ export * from "./vault.ts";
67
+
68
+ // Generated, ABI-bound bindings (BCS structs + type-safe Move calls).
69
+ export * as contracts from "./contracts.ts";
@@ -0,0 +1,46 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Internal shared helpers (deliberately NOT exported from the package root).
5
+ //
6
+ // PTB building blocks — the `0x1::option` move-call targets used when a generated
7
+ // call needs an `Option` argument built inline. Consumed by `./cover` and
8
+ // `./credits`.
9
+ //
10
+ // These came over from `@misonetwork/sdk`'s own private `internal.ts` when the
11
+ // extension surface moved here. They were NOT promoted to that package's public
12
+ // API to make them reachable: they are two literal Move function targets from the
13
+ // standard library, so re-deriving them costs nothing, whereas exporting them
14
+ // would widen the protocol SDK's public surface — and therefore its compatibility
15
+ // promise — for no benefit.
16
+
17
+ /** `0x1::option::none` / `0x1::option::some` moveCall targets. */
18
+ export const OPTION_NONE = "0x1::option::none";
19
+ export const OPTION_SOME = "0x1::option::some";
20
+
21
+ /**
22
+ * Clone arrays and plain records recursively, then freeze the clone.
23
+ *
24
+ * Registration inputs are data-only configuration records. Snapshotting them
25
+ * prevents later caller mutation without freezing or otherwise taking
26
+ * ownership of the caller's original objects. Non-plain objects are preserved
27
+ * by reference so this helper never attempts to clone SDK clients or signers.
28
+ */
29
+ export function immutableSnapshot<T>(value: T): T {
30
+ if (Array.isArray(value)) {
31
+ return Object.freeze(value.map((item) => immutableSnapshot(item))) as T;
32
+ }
33
+ if (value && typeof value === "object") {
34
+ const prototype = Object.getPrototypeOf(value);
35
+ if (prototype !== Object.prototype && prototype !== null) return value;
36
+ return Object.freeze(
37
+ Object.fromEntries(
38
+ Object.entries(value).map(([key, item]) => [
39
+ key,
40
+ immutableSnapshot(item),
41
+ ]),
42
+ ),
43
+ ) as T;
44
+ }
45
+ return value;
46
+ }