@misonetwork/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 (238) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +644 -0
  3. package/dist/client.d.ts +197 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +218 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/contracts/composition_credits/composition_credits.d.ts +181 -0
  8. package/dist/contracts/composition_credits/composition_credits.d.ts.map +1 -0
  9. package/dist/contracts/composition_credits/composition_credits.js +109 -0
  10. package/dist/contracts/composition_credits/composition_credits.js.map +1 -0
  11. package/dist/contracts/composition_credits/composition_party_role.d.ts +119 -0
  12. package/dist/contracts/composition_credits/composition_party_role.d.ts.map +1 -0
  13. package/dist/contracts/composition_credits/composition_party_role.js +139 -0
  14. package/dist/contracts/composition_credits/composition_party_role.js.map +1 -0
  15. package/dist/contracts/composition_credits/deps/miso_credit/credit.d.ts +24 -0
  16. package/dist/contracts/composition_credits/deps/miso_credit/credit.d.ts.map +1 -0
  17. package/dist/contracts/composition_credits/deps/miso_credit/credit.js +23 -0
  18. package/dist/contracts/composition_credits/deps/miso_credit/credit.js.map +1 -0
  19. package/dist/contracts/composition_credits/deps/sui/vec_map.d.ts +37 -0
  20. package/dist/contracts/composition_credits/deps/sui/vec_map.d.ts.map +1 -0
  21. package/dist/contracts/composition_credits/deps/sui/vec_map.js +28 -0
  22. package/dist/contracts/composition_credits/deps/sui/vec_map.js.map +1 -0
  23. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.d.ts +87 -0
  24. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.d.ts.map +1 -0
  25. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.js +80 -0
  26. package/dist/contracts/composition_royalty_pool/composition_royalty_pool.js.map +1 -0
  27. package/dist/contracts/cover_art/cover_art.d.ts +85 -0
  28. package/dist/contracts/cover_art/cover_art.d.ts.map +1 -0
  29. package/dist/contracts/cover_art/cover_art.js +68 -0
  30. package/dist/contracts/cover_art/cover_art.js.map +1 -0
  31. package/dist/contracts/cover_art/deps/ori/walrus_data.d.ts +52 -0
  32. package/dist/contracts/cover_art/deps/ori/walrus_data.d.ts.map +1 -0
  33. package/dist/contracts/cover_art/deps/ori/walrus_data.js +37 -0
  34. package/dist/contracts/cover_art/deps/ori/walrus_data.js.map +1 -0
  35. package/dist/contracts/miso/composition.d.ts +231 -0
  36. package/dist/contracts/miso/composition.d.ts.map +1 -0
  37. package/dist/contracts/miso/composition.js +231 -0
  38. package/dist/contracts/miso/composition.js.map +1 -0
  39. package/dist/contracts/miso/deal.d.ts +184 -0
  40. package/dist/contracts/miso/deal.d.ts.map +1 -0
  41. package/dist/contracts/miso/deal.js +184 -0
  42. package/dist/contracts/miso/deal.js.map +1 -0
  43. package/dist/contracts/miso/deps/bps/bps.d.ts +19 -0
  44. package/dist/contracts/miso/deps/bps/bps.d.ts.map +1 -0
  45. package/dist/contracts/miso/deps/bps/bps.js +21 -0
  46. package/dist/contracts/miso/deps/bps/bps.js.map +1 -0
  47. package/dist/contracts/miso/recording.d.ts +228 -0
  48. package/dist/contracts/miso/recording.d.ts.map +1 -0
  49. package/dist/contracts/miso/recording.js +221 -0
  50. package/dist/contracts/miso/recording.js.map +1 -0
  51. package/dist/contracts/miso/release.d.ts +280 -0
  52. package/dist/contracts/miso/release.d.ts.map +1 -0
  53. package/dist/contracts/miso/release.js +282 -0
  54. package/dist/contracts/miso/release.js.map +1 -0
  55. package/dist/contracts/miso/track.d.ts +118 -0
  56. package/dist/contracts/miso/track.d.ts.map +1 -0
  57. package/dist/contracts/miso/track.js +118 -0
  58. package/dist/contracts/miso/track.js.map +1 -0
  59. package/dist/contracts/recording_credits/deps/miso_credit/credit.d.ts +24 -0
  60. package/dist/contracts/recording_credits/deps/miso_credit/credit.d.ts.map +1 -0
  61. package/dist/contracts/recording_credits/deps/miso_credit/credit.js +23 -0
  62. package/dist/contracts/recording_credits/deps/miso_credit/credit.js.map +1 -0
  63. package/dist/contracts/recording_credits/deps/sui/vec_map.d.ts +37 -0
  64. package/dist/contracts/recording_credits/deps/sui/vec_map.d.ts.map +1 -0
  65. package/dist/contracts/recording_credits/deps/sui/vec_map.js +28 -0
  66. package/dist/contracts/recording_credits/deps/sui/vec_map.js.map +1 -0
  67. package/dist/contracts/recording_credits/deps/sui/vec_set.d.ts +21 -0
  68. package/dist/contracts/recording_credits/deps/sui/vec_set.d.ts.map +1 -0
  69. package/dist/contracts/recording_credits/deps/sui/vec_set.js +20 -0
  70. package/dist/contracts/recording_credits/deps/sui/vec_set.js.map +1 -0
  71. package/dist/contracts/recording_credits/recording_credits.d.ts +2313 -0
  72. package/dist/contracts/recording_credits/recording_credits.d.ts.map +1 -0
  73. package/dist/contracts/recording_credits/recording_credits.js +270 -0
  74. package/dist/contracts/recording_credits/recording_credits.js.map +1 -0
  75. package/dist/contracts/recording_credits/recording_party_role.d.ts +1174 -0
  76. package/dist/contracts/recording_credits/recording_party_role.d.ts.map +1 -0
  77. package/dist/contracts/recording_credits/recording_party_role.js +692 -0
  78. package/dist/contracts/recording_credits/recording_party_role.js.map +1 -0
  79. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.d.ts +90 -0
  80. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.d.ts.map +1 -0
  81. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.js +80 -0
  82. package/dist/contracts/recording_royalty_pool/recording_royalty_pool.js.map +1 -0
  83. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.d.ts +52 -0
  84. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.d.ts.map +1 -0
  85. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.js +37 -0
  86. package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.js.map +1 -0
  87. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.d.ts +46 -0
  88. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.d.ts.map +1 -0
  89. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.js +21 -0
  90. package/dist/contracts/release_cover_art/deps/cover_art/cover_art.js.map +1 -0
  91. package/dist/contracts/release_cover_art/deps/per_track/per_track.d.ts +33 -0
  92. package/dist/contracts/release_cover_art/deps/per_track/per_track.d.ts.map +1 -0
  93. package/dist/contracts/release_cover_art/deps/per_track/per_track.js +32 -0
  94. package/dist/contracts/release_cover_art/deps/per_track/per_track.js.map +1 -0
  95. package/dist/contracts/release_cover_art/release_cover_art.d.ts +300 -0
  96. package/dist/contracts/release_cover_art/release_cover_art.d.ts.map +1 -0
  97. package/dist/contracts/release_cover_art/release_cover_art.js +168 -0
  98. package/dist/contracts/release_cover_art/release_cover_art.js.map +1 -0
  99. package/dist/contracts/release_credits/deps/miso_credit/credit.d.ts +24 -0
  100. package/dist/contracts/release_credits/deps/miso_credit/credit.d.ts.map +1 -0
  101. package/dist/contracts/release_credits/deps/miso_credit/credit.js +23 -0
  102. package/dist/contracts/release_credits/deps/miso_credit/credit.js.map +1 -0
  103. package/dist/contracts/release_credits/deps/sui/vec_map.d.ts +37 -0
  104. package/dist/contracts/release_credits/deps/sui/vec_map.d.ts.map +1 -0
  105. package/dist/contracts/release_credits/deps/sui/vec_map.js +28 -0
  106. package/dist/contracts/release_credits/deps/sui/vec_map.js.map +1 -0
  107. package/dist/contracts/release_credits/release_credits.d.ts +142 -0
  108. package/dist/contracts/release_credits/release_credits.d.ts.map +1 -0
  109. package/dist/contracts/release_credits/release_credits.js +108 -0
  110. package/dist/contracts/release_credits/release_credits.js.map +1 -0
  111. package/dist/contracts/release_credits/release_party_role.d.ts +58 -0
  112. package/dist/contracts/release_credits/release_party_role.d.ts.map +1 -0
  113. package/dist/contracts/release_credits/release_party_role.js +66 -0
  114. package/dist/contracts/release_credits/release_party_role.js.map +1 -0
  115. package/dist/contracts/royalty_pool/deps/std/type_name.d.ts +18 -0
  116. package/dist/contracts/royalty_pool/deps/std/type_name.d.ts.map +1 -0
  117. package/dist/contracts/royalty_pool/deps/std/type_name.js +20 -0
  118. package/dist/contracts/royalty_pool/deps/std/type_name.js.map +1 -0
  119. package/dist/contracts/royalty_pool/deps/sui/balance.d.ts +13 -0
  120. package/dist/contracts/royalty_pool/deps/sui/balance.d.ts.map +1 -0
  121. package/dist/contracts/royalty_pool/deps/sui/balance.js +15 -0
  122. package/dist/contracts/royalty_pool/deps/sui/balance.js.map +1 -0
  123. package/dist/contracts/royalty_pool/deps/sui/vec_map.d.ts +37 -0
  124. package/dist/contracts/royalty_pool/deps/sui/vec_map.d.ts.map +1 -0
  125. package/dist/contracts/royalty_pool/deps/sui/vec_map.js +28 -0
  126. package/dist/contracts/royalty_pool/deps/sui/vec_map.js.map +1 -0
  127. package/dist/contracts/royalty_pool/pool.d.ts +358 -0
  128. package/dist/contracts/royalty_pool/pool.d.ts.map +1 -0
  129. package/dist/contracts/royalty_pool/pool.js +352 -0
  130. package/dist/contracts/royalty_pool/pool.js.map +1 -0
  131. package/dist/contracts/royalty_pool/stake.d.ts +202 -0
  132. package/dist/contracts/royalty_pool/stake.d.ts.map +1 -0
  133. package/dist/contracts/royalty_pool/stake.js +197 -0
  134. package/dist/contracts/royalty_pool/stake.js.map +1 -0
  135. package/dist/contracts/utils/index.d.ts +31 -0
  136. package/dist/contracts/utils/index.d.ts.map +1 -0
  137. package/dist/contracts/utils/index.js +162 -0
  138. package/dist/contracts/utils/index.js.map +1 -0
  139. package/dist/contracts.d.ts +18 -0
  140. package/dist/contracts.d.ts.map +1 -0
  141. package/dist/contracts.js +26 -0
  142. package/dist/contracts.js.map +1 -0
  143. package/dist/cover.d.ts +48 -0
  144. package/dist/cover.d.ts.map +1 -0
  145. package/dist/cover.js +68 -0
  146. package/dist/cover.js.map +1 -0
  147. package/dist/credits.d.ts +171 -0
  148. package/dist/credits.d.ts.map +1 -0
  149. package/dist/credits.js +360 -0
  150. package/dist/credits.js.map +1 -0
  151. package/dist/execute.d.ts +49 -0
  152. package/dist/execute.d.ts.map +1 -0
  153. package/dist/execute.js +114 -0
  154. package/dist/execute.js.map +1 -0
  155. package/dist/extensions/royalty-pool.d.ts +32 -0
  156. package/dist/extensions/royalty-pool.d.ts.map +1 -0
  157. package/dist/extensions/royalty-pool.js +33 -0
  158. package/dist/extensions/royalty-pool.js.map +1 -0
  159. package/dist/index.d.ts +13 -0
  160. package/dist/index.d.ts.map +1 -0
  161. package/dist/index.js +16 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/internal.d.ts +20 -0
  164. package/dist/internal.d.ts.map +1 -0
  165. package/dist/internal.js +48 -0
  166. package/dist/internal.js.map +1 -0
  167. package/dist/parsers.d.ts +9 -0
  168. package/dist/parsers.d.ts.map +1 -0
  169. package/dist/parsers.js +52 -0
  170. package/dist/parsers.js.map +1 -0
  171. package/dist/queries.d.ts +105 -0
  172. package/dist/queries.d.ts.map +1 -0
  173. package/dist/queries.js +380 -0
  174. package/dist/queries.js.map +1 -0
  175. package/dist/schemas.d.ts +99 -0
  176. package/dist/schemas.d.ts.map +1 -0
  177. package/dist/schemas.js +76 -0
  178. package/dist/schemas.js.map +1 -0
  179. package/dist/transactions.d.ts +158 -0
  180. package/dist/transactions.d.ts.map +1 -0
  181. package/dist/transactions.js +154 -0
  182. package/dist/transactions.js.map +1 -0
  183. package/dist/types.d.ts +204 -0
  184. package/dist/types.d.ts.map +1 -0
  185. package/dist/types.js +4 -0
  186. package/dist/types.js.map +1 -0
  187. package/dist/view.d.ts +21 -0
  188. package/dist/view.d.ts.map +1 -0
  189. package/dist/view.js +36 -0
  190. package/dist/view.js.map +1 -0
  191. package/package.json +111 -0
  192. package/src/client.ts +278 -0
  193. package/src/contracts/composition_credits/composition_credits.ts +169 -0
  194. package/src/contracts/composition_credits/composition_party_role.ts +189 -0
  195. package/src/contracts/composition_credits/deps/miso_credit/credit.ts +27 -0
  196. package/src/contracts/composition_credits/deps/sui/vec_map.ts +33 -0
  197. package/src/contracts/composition_royalty_pool/composition_royalty_pool.ts +135 -0
  198. package/src/contracts/cover_art/cover_art.ts +99 -0
  199. package/src/contracts/cover_art/deps/ori/walrus_data.ts +36 -0
  200. package/src/contracts/miso/composition.ts +343 -0
  201. package/src/contracts/miso/deal.ts +257 -0
  202. package/src/contracts/miso/deps/bps/bps.ts +23 -0
  203. package/src/contracts/miso/recording.ts +298 -0
  204. package/src/contracts/miso/release.ts +392 -0
  205. package/src/contracts/miso/track.ts +153 -0
  206. package/src/contracts/recording_credits/deps/miso_credit/credit.ts +27 -0
  207. package/src/contracts/recording_credits/deps/sui/vec_map.ts +33 -0
  208. package/src/contracts/recording_credits/deps/sui/vec_set.ts +21 -0
  209. package/src/contracts/recording_credits/recording_credits.ts +458 -0
  210. package/src/contracts/recording_credits/recording_party_role.ts +1041 -0
  211. package/src/contracts/recording_royalty_pool/recording_royalty_pool.ts +138 -0
  212. package/src/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.ts +36 -0
  213. package/src/contracts/release_cover_art/deps/cover_art/cover_art.ts +23 -0
  214. package/src/contracts/release_cover_art/deps/per_track/per_track.ts +36 -0
  215. package/src/contracts/release_cover_art/release_cover_art.ts +251 -0
  216. package/src/contracts/release_credits/deps/miso_credit/credit.ts +27 -0
  217. package/src/contracts/release_credits/deps/sui/vec_map.ts +33 -0
  218. package/src/contracts/release_credits/release_credits.ts +156 -0
  219. package/src/contracts/release_credits/release_party_role.ts +87 -0
  220. package/src/contracts/royalty_pool/deps/std/type_name.ts +22 -0
  221. package/src/contracts/royalty_pool/deps/sui/balance.ts +17 -0
  222. package/src/contracts/royalty_pool/deps/sui/vec_map.ts +33 -0
  223. package/src/contracts/royalty_pool/pool.ts +577 -0
  224. package/src/contracts/royalty_pool/stake.ts +317 -0
  225. package/src/contracts/utils/index.ts +229 -0
  226. package/src/contracts.ts +30 -0
  227. package/src/cover.ts +136 -0
  228. package/src/credits.ts +645 -0
  229. package/src/execute.ts +141 -0
  230. package/src/extensions/royalty-pool.ts +85 -0
  231. package/src/index.ts +17 -0
  232. package/src/internal.ts +85 -0
  233. package/src/parsers.ts +80 -0
  234. package/src/queries.ts +478 -0
  235. package/src/schemas.ts +96 -0
  236. package/src/transactions.ts +290 -0
  237. package/src/types.ts +244 -0
  238. package/src/view.ts +59 -0
@@ -0,0 +1,290 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Transaction builders. Every builder adds commands to a caller-owned
5
+ // `Transaction`, so flows compose in a single PTB, but they come in two shapes.
6
+ // The `create*` primitives take the `Transaction` as their FIRST argument and
7
+ // return their by-value results, so those results can be threaded into later
8
+ // commands. `rejectDeal` has nothing to hand back, so it keeps the Sui SDK
9
+ // thunk shape: `(params) => (tx: Transaction) => …`. Miso calls go through the
10
+ // codegen-generated, type-safe call functions.
11
+ //
12
+ // This module keeps the bare protocol PRIMITIVES only. The rule is: do the
13
+ // minimum the Move semantics FORCE, and return anything the caller could
14
+ // legitimately route elsewhere.
15
+ //
16
+ // `createComposition`, `createRecording`, and `createRelease` each append a
17
+ // single `::new` and hand back its by-value results — never dispersing a share
18
+ // supply, publishing (sharing) the object, or routing an admin cap.
19
+ //
20
+ // Each created object MUST still be consumed by its `publish` in the same PTB
21
+ // (`Composition`, `Recording`, and `Release` are all `key`-only with no `drop`),
22
+ // but that is a same-TRANSACTION requirement, not a same-FUNCTION one: a later
23
+ // `finalize*` command on the same `tx` satisfies it. Keeping them apart is what
24
+ // lets the intermediate value be used at all — borrowing a still-unshared
25
+ // composition into `recording::new`, attaching a royalty pool via `uid_mut`, or
26
+ // sending an admin cap somewhere other than a plain address (every admin cap is
27
+ // `key, store`, so it is freely routable).
28
+ //
29
+ // The opinionated layers — track assembly, cap disposition, minato dispersal,
30
+ // the share-currency lifecycle — live in `@misofm/sdk`
31
+ // (`publishRelease`/`publishReleaseFromDeals`/`publishReleaseGraph`,
32
+ // `finalizeComposition`/`finalizeRecording`/`finalizeRelease`,
33
+ // `publishComposition`/`publishRecording`/`publishCompositionAndRecording`,
34
+ // `share.ts`) as free functions taking `misoPackageId` explicitly. Those import
35
+ // the primitives from here and build on top, same PTB composition pattern, just
36
+ // crossing a package boundary.
37
+
38
+ import { Transaction, type TransactionObjectArgument } from "@mysten/sui/transactions";
39
+
40
+ import * as composition from "./contracts/miso/composition.ts";
41
+ import * as recording from "./contracts/miso/recording.ts";
42
+ import * as deal from "./contracts/miso/deal.ts";
43
+ import * as release from "./contracts/miso/release.ts";
44
+
45
+ /** A thunk that adds commands to a transaction. May be async (resolves at build time). */
46
+ export type TxThunk = (tx: Transaction) => void | Promise<void>;
47
+
48
+ // ============================================================================
49
+ // Shared inputs
50
+ // ============================================================================
51
+
52
+ /**
53
+ * Share-currency binding for a work: the fully-qualified `share::Share` type, the
54
+ * `Currency<Share>` object, and the `TreasuryCap<Share>`. All three are known once
55
+ * the currency has been published + initialized, so builders take them explicitly
56
+ * rather than reading them from chain — keeping the thunks synchronous and
57
+ * composable (no RPC inside the transaction build).
58
+ */
59
+ export interface ShareCurrencyBinding {
60
+ /** The `${packageId}::share::Share` type. */
61
+ shareType: string;
62
+ /** The `Currency<Share>` object id. */
63
+ shareCurrencyId: string;
64
+ /** The `TreasuryCap<Share>` object id (held by the caller, consumed by `new`). */
65
+ shareTreasuryCapId: string;
66
+ }
67
+
68
+ // ============================================================================
69
+ // Composition
70
+ // ============================================================================
71
+
72
+ /** The three by-value results of `composition::new`, for threading onward in a PTB. */
73
+ export interface CompositionParts {
74
+ composition: TransactionObjectArgument;
75
+ adminCap: TransactionObjectArgument;
76
+ /** The creator's freshly-minted share supply (a `Balance<Share>`). */
77
+ balance: TransactionObjectArgument;
78
+ }
79
+
80
+ export interface CreateCompositionParams extends ShareCurrencyBinding {
81
+ title: string;
82
+ royaltyRateBps: number;
83
+ misoPackageId: string;
84
+ }
85
+
86
+ /**
87
+ * PRIMITIVE. Appends `composition::new` and returns its by-value results without
88
+ * dispersing, sharing, or transferring anything — the caller decides what happens
89
+ * next (share it, keep it unshared to bundle with a recording, attach a dynamic
90
+ * field via `uid_mut`, …). Composes with anything in the same PTB.
91
+ */
92
+ export function createComposition(tx: Transaction, params: CreateCompositionParams): CompositionParts {
93
+ const result = tx.add(
94
+ composition._new({
95
+ package: params.misoPackageId,
96
+ typeArguments: [params.shareType],
97
+ arguments: [tx.pure.string(params.title), tx.pure.u16(params.royaltyRateBps), tx.object(params.shareCurrencyId), tx.object(params.shareTreasuryCapId)],
98
+ }),
99
+ );
100
+ return { composition: result[0]!, adminCap: result[1]!, balance: result[2]! };
101
+ }
102
+
103
+ // ============================================================================
104
+ // Recording
105
+ // ============================================================================
106
+
107
+ /** The three by-value results of `recording::new`, for threading onward in a PTB. */
108
+ export interface RecordingParts {
109
+ recording: TransactionObjectArgument;
110
+ adminCap: TransactionObjectArgument;
111
+ /** The creator's remaining share supply after the composition's cut is split off. */
112
+ balance: TransactionObjectArgument;
113
+ }
114
+
115
+ /** The protocol's maximum composition royalty rate (`MAX_ROYALTY_RATE_BPS`). */
116
+ export const PROTOCOL_MAX_ROYALTY_RATE_BPS = 2000;
117
+
118
+ export interface CreateRecordingParams extends ShareCurrencyBinding {
119
+ /** Share type of the parent composition (the recording's `CompositionShare` phantom). */
120
+ compositionShareType: string;
121
+ /**
122
+ * Parent `Composition`, passed by immutable reference (`recording::new` reads only
123
+ * its id + royalty rate). May be an on-chain object (`tx.object(id)`) or a still-
124
+ * unshared, transaction-local `createComposition(...).composition` result.
125
+ */
126
+ composition: TransactionObjectArgument;
127
+ /**
128
+ * Slippage guard: the maximum composition royalty rate (bps) the recorder will
129
+ * grant — `recording::new` aborts if the composition's live rate exceeds it.
130
+ * Pass the rate you observed. Defaults to the protocol maximum (2000), which
131
+ * accepts any legal rate.
132
+ */
133
+ maxRoyaltyRateBps?: number;
134
+ misoPackageId: string;
135
+ }
136
+
137
+ /**
138
+ * PRIMITIVE. Appends `recording::new` and returns its by-value results without
139
+ * publishing/dispersing/transferring. Because it borrows the composition by
140
+ * reference, it can run against a composition that is still an unshared PTB-local
141
+ * value — the borrow-before-share pattern that lets a composition + recording share
142
+ * one PTB.
143
+ */
144
+ export function createRecording(tx: Transaction, params: CreateRecordingParams): RecordingParts {
145
+ const result = tx.add(
146
+ recording._new({
147
+ package: params.misoPackageId,
148
+ typeArguments: [params.shareType, params.compositionShareType],
149
+ arguments: [params.composition, tx.object(params.shareCurrencyId), tx.object(params.shareTreasuryCapId), tx.pure.u16(params.maxRoyaltyRateBps ?? PROTOCOL_MAX_ROYALTY_RATE_BPS)],
150
+ }),
151
+ );
152
+ return { recording: result[0]!, adminCap: result[1]!, balance: result[2]! };
153
+ }
154
+
155
+ // ============================================================================
156
+ // Deal
157
+ // ============================================================================
158
+
159
+ export interface CreateDealParams {
160
+ recordingId: string;
161
+ recordingAdminCapId?: string;
162
+ recordingAdminCap?: TransactionObjectArgument;
163
+ /** Share type of the recording (the deal's `RecordingShare` phantom). */
164
+ recordingShareType: string;
165
+ /** Share type of the parent composition (the deal's `CompositionShare` phantom). */
166
+ compositionShareType: string;
167
+ releaseId: string;
168
+ trackSplitBps: number;
169
+ misoPackageId: string;
170
+ }
171
+
172
+ /**
173
+ * PRIMITIVE. Appends `deal::new` and returns the `Deal` by value without routing
174
+ * it anywhere — the caller decides what happens next.
175
+ *
176
+ * LIFECYCLE NOTE — the returned `Deal` MUST be consumed in this same
177
+ * transaction. It is `key, store` with no `drop`, so it cannot be discarded, but
178
+ * it CAN go to either of two places, which is exactly why this does not choose:
179
+ *
180
+ * 1. `tx.transferObjects([deal], recipient)` — send it to whoever is
181
+ * assembling the release, for them to redeem later. This is the
182
+ * cross-party flow: a recording owner signs a deal for someone else's
183
+ * release.
184
+ * 2. straight into `track::new(deal, &recording)` in this same PTB — the
185
+ * same-party flow, where the deal is a transient authorization rather than
186
+ * something anyone holds. `@misofm/sdk`'s `publishReleaseGraph` does this.
187
+ *
188
+ * Both are legitimate, and picking one for the caller would make the other
189
+ * awkward, so the disposition stays with the caller. `@misofm/sdk` layers the
190
+ * opinionated flows on top.
191
+ *
192
+ * The `recordingAdminCap` may be passed as an on-chain object id
193
+ * (`recordingAdminCapId`) or as a PTB-local argument (`recordingAdminCap`) —
194
+ * the latter lets a deal be signed against a recording created earlier in the
195
+ * same transaction, before its cap has been transferred anywhere.
196
+ */
197
+ export function createDeal(tx: Transaction, params: CreateDealParams): TransactionObjectArgument {
198
+ if (!params.recordingAdminCap && !params.recordingAdminCapId) {
199
+ throw new Error("createDeal: recordingAdminCapId or recordingAdminCap required");
200
+ }
201
+ const adminCapArg = params.recordingAdminCap ?? tx.object(params.recordingAdminCapId!);
202
+ return tx.add(
203
+ deal._new({
204
+ package: params.misoPackageId,
205
+ typeArguments: [params.recordingShareType, params.compositionShareType],
206
+ arguments: [
207
+ adminCapArg,
208
+ tx.object(params.recordingId),
209
+ tx.pure.id(params.releaseId),
210
+ tx.pure.u16(params.trackSplitBps),
211
+ ],
212
+ }),
213
+ );
214
+ }
215
+
216
+ export interface RejectDealParams {
217
+ dealId: string;
218
+ /** Share type of the recording (the deal's `RecordingShare` phantom). */
219
+ recordingShareType: string;
220
+ /** Share type of the parent composition (the deal's `CompositionShare` phantom). */
221
+ compositionShareType: string;
222
+ misoPackageId: string;
223
+ }
224
+
225
+ /** Rejects (destroys) a deal without including it in a release. Emits `DealRejectedEvent`. */
226
+ export function rejectDeal(params: RejectDealParams): TxThunk {
227
+ return (tx) => {
228
+ tx.add(deal.reject({
229
+ package: params.misoPackageId,
230
+ typeArguments: [params.recordingShareType, params.compositionShareType],
231
+ arguments: [tx.object(params.dealId)],
232
+ }));
233
+ };
234
+ }
235
+
236
+ // ============================================================================
237
+ // Release
238
+ // ============================================================================
239
+
240
+ /** The two by-value results of `release::new`, for threading onward in a PTB. */
241
+ export interface ReleaseParts {
242
+ release: TransactionObjectArgument;
243
+ adminCap: TransactionObjectArgument;
244
+ }
245
+
246
+ export interface CreateReleaseParams {
247
+ title: string;
248
+ /** u256 nonce as a decimal string (deterministic release id). */
249
+ nonce: string;
250
+ releaseRegistryId: string;
251
+ misoPackageId: string;
252
+ }
253
+
254
+ /**
255
+ * PRIMITIVE. Appends `release::new` over a caller-built `vector<Track>` and
256
+ * returns its by-value results without publishing (sharing) the release or
257
+ * routing the admin cap — the caller decides what happens next. Mirrors
258
+ * {@link createComposition}/{@link createRecording}.
259
+ *
260
+ * `trackVec` is supplied by the caller because track assembly is the part that
261
+ * genuinely varies between release flows: from recording admin caps, from
262
+ * pre-made deals, or from a mix of fresh and existing recordings (see
263
+ * `@misofm/sdk`'s `publishRelease`/`publishReleaseFromDeals`/
264
+ * `publishReleaseGraph`).
265
+ *
266
+ * LIFECYCLE NOTE — the returned `Release` MUST be consumed by
267
+ * `release::publish` in this same transaction. `Release` is `key`-only with no
268
+ * `drop`, and `publish` is its only by-value consumer, so an `Initialized`
269
+ * release cannot be transferred, wrapped, shared, or discarded, and cannot
270
+ * outlive its creating transaction; the protocol deliberately provides no keep
271
+ * function. That is a same-PTB requirement, NOT a same-function one — pairing
272
+ * this with a later `finalizeRelease` command in the same `tx` satisfies it.
273
+ * (`Composition` and `Recording` carry the identical requirement, which is why
274
+ * all three primitives have the same shape.) The admin cap has no such
275
+ * constraint: `ReleaseAdminCap` is `key, store` and `publish` only borrows it,
276
+ * so it is an ordinary transferable value the caller routes as it sees fit.
277
+ */
278
+ export function createRelease(
279
+ tx: Transaction,
280
+ params: CreateReleaseParams,
281
+ trackVec: TransactionObjectArgument,
282
+ ): ReleaseParts {
283
+ const result = tx.add(
284
+ release._new({
285
+ package: params.misoPackageId,
286
+ arguments: [tx.pure.string(params.title), trackVec, tx.pure.u256(BigInt(params.nonce)), tx.object(params.releaseRegistryId)],
287
+ }),
288
+ );
289
+ return { release: result[0]!, adminCap: result[1]! };
290
+ }
package/src/types.ts ADDED
@@ -0,0 +1,244 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // ============================================================================
5
+ // Common
6
+ // ============================================================================
7
+
8
+ /** Basis points value (0-10000, where 10000 = 100%). */
9
+ export interface BPS {
10
+ value: number;
11
+ }
12
+
13
+ // ============================================================================
14
+ // Composition
15
+ // ============================================================================
16
+
17
+ /** Lifecycle state of a composition. */
18
+ export type CompositionState =
19
+ | { type: "Initialized" }
20
+ | { type: "Published"; timestampMs: number };
21
+
22
+ /**
23
+ * A musical composition representing the underlying written work.
24
+ *
25
+ * Compositions are the written musical works (songs, instrumentals) that
26
+ * recordings are based on. Each composition has its own share token for
27
+ * ownership distribution.
28
+ *
29
+ * State machine: Initialized -> Published (immutable after publish)
30
+ */
31
+ export interface Composition {
32
+ /** Unique identifier for this composition. */
33
+ id: string;
34
+ /** Current lifecycle state. */
35
+ state: CompositionState;
36
+ /** Primary title of the composition. */
37
+ title: string;
38
+ /** Royalty rate this composition earns from each recording's revenue (basis points, 0-2000). */
39
+ royaltyRate: BPS;
40
+ }
41
+
42
+ /**
43
+ * Emitted once when a composition is published. A pure pointer carrying only the
44
+ * composition's identity — an indexer fetches the full immutable object by
45
+ * `compositionId`.
46
+ */
47
+ export interface CompositionPublishedEvent {
48
+ compositionId: string;
49
+ }
50
+
51
+ /**
52
+ * Emitted when a composition's royalty rate is set or changed. The composition
53
+ * is identified by the event's `CompositionShare` phantom type, not a field.
54
+ */
55
+ export interface CompositionRoyaltySetEvent {
56
+ royaltyRateBps: number;
57
+ }
58
+
59
+ /**
60
+ * Admin cap for a Composition, derived deterministically from the Composition object ID.
61
+ *
62
+ * The share type parameter T is extracted from the on-chain type
63
+ * `CompositionAdminCap<T>` where T is the composition's share token type.
64
+ */
65
+ export interface CompositionAdminCap {
66
+ /** The object ID of the admin cap. */
67
+ id: string;
68
+ /** The share type parameter T from CompositionAdminCap<T>. */
69
+ shareType: string;
70
+ }
71
+
72
+ // ============================================================================
73
+ // Recording
74
+ // ============================================================================
75
+
76
+ /** Lifecycle state of a recording. */
77
+ export type RecordingState =
78
+ | { type: "Initialized" }
79
+ | { type: "Published"; timestampMs: number };
80
+
81
+ /**
82
+ * An audio recording of a composition.
83
+ *
84
+ * Recordings are the audio performances that are distributed and played.
85
+ * Each recording has its own share token for ownership distribution.
86
+ *
87
+ * A recording carries no name of its own: its display title is its
88
+ * composition's title, resolved through the recording's `CompositionShare`
89
+ * type parameter. Richer naming ("(Live)", localized titles) lives in the
90
+ * metadata extension.
91
+ *
92
+ * State machine: Initialized -> Published (immutable after publish)
93
+ */
94
+ export interface Recording {
95
+ /** Unique identifier for this recording. */
96
+ id: string;
97
+ /** Current lifecycle state. */
98
+ state: RecordingState;
99
+ }
100
+
101
+ /**
102
+ * Emitted once when a recording is published. A pure pointer carrying only the
103
+ * recording's identity — an indexer fetches the full immutable object by
104
+ * `recordingId`.
105
+ */
106
+ export interface RecordingPublishedEvent {
107
+ recordingId: string;
108
+ }
109
+
110
+ /**
111
+ * Admin cap for a Recording, derived deterministically from the Recording object ID.
112
+ *
113
+ * The share type parameter T is extracted from the on-chain type
114
+ * `RecordingAdminCap<T>` where T is the recording's share token type.
115
+ */
116
+ export interface RecordingAdminCap {
117
+ /** The object ID of the admin cap. */
118
+ id: string;
119
+ /** The share type parameter T from RecordingAdminCap<T>. */
120
+ shareType: string;
121
+ }
122
+
123
+ // ============================================================================
124
+ // Deal
125
+ // ============================================================================
126
+
127
+ /**
128
+ * A deal authorizing a recording's inclusion in a specific release. Created by
129
+ * the recording's admin, held (transferably) by whoever assembles the release,
130
+ * and consumed by `track::new`. The recording/composition identities ride on
131
+ * the object's type parameters; the recording's object id is NOT stored.
132
+ */
133
+ export interface Deal {
134
+ /** The object ID of the deal. */
135
+ id: string;
136
+ /** The exact release id this deal authorizes (a digest of the full tracklist + nonce). */
137
+ releaseId: string;
138
+ /** The agreed track split for this recording within the release. */
139
+ trackSplitBps: BPS;
140
+ /** The recording's share type (first type parameter of `Deal<R, C>`). */
141
+ recordingShareType: string;
142
+ /** The parent composition's share type (second type parameter of `Deal<R, C>`). */
143
+ compositionShareType: string;
144
+ }
145
+
146
+ // ============================================================================
147
+ // Track
148
+ // ============================================================================
149
+
150
+ /** Lifecycle state of a track on a release. */
151
+ export type TrackState = "Unassigned" | "Assigned";
152
+
153
+ /**
154
+ * A track on a release, linking a recording to its position in the tracklist.
155
+ * The recording is the handle through which all other metadata (share types,
156
+ * composition lineage, and — via the composition — the display title) is
157
+ * reached.
158
+ */
159
+ export interface Track {
160
+ /** Current state of the track (Unassigned until the release claims it, then Assigned). */
161
+ state: TrackState;
162
+ /** ID of the recording on this track. */
163
+ recordingId: string;
164
+ /** Revenue split for this track within the release (in basis points). */
165
+ splitBps: BPS;
166
+ }
167
+
168
+ // ============================================================================
169
+ // Release
170
+ // ============================================================================
171
+
172
+ /** Lifecycle state of a release. */
173
+ export type ReleaseState =
174
+ | { type: "Initialized" }
175
+ | { type: "Published"; timestampMs: number };
176
+
177
+ /**
178
+ * A music release (album, EP, or single).
179
+ *
180
+ * A release is a flat, ordered tracklist with per-track revenue distribution
181
+ * configuration. Display grouping (discs, vinyl sides), cover art, and edition
182
+ * naming live in extensions — the stored tracklist has the same shape as the
183
+ * digest pre-image every deal consented to.
184
+ *
185
+ * State machine: Initialized -> Published (immutable after publish)
186
+ */
187
+ export interface Release {
188
+ /** Unique identifier for this release. */
189
+ id: string;
190
+ /** Current lifecycle state. */
191
+ state: ReleaseState;
192
+ /** Title of the release. */
193
+ title: string;
194
+ /** The ordered tracklist. */
195
+ tracks: Track[];
196
+ }
197
+
198
+ /**
199
+ * Emitted once when a release is published. A pure pointer carrying only the
200
+ * release's identity — an indexer fetches the full immutable object (discs,
201
+ * tracks) by `releaseId`.
202
+ */
203
+ export interface ReleasePublishedEvent {
204
+ releaseId: string;
205
+ }
206
+
207
+ /**
208
+ * Admin cap for a Release, derived deterministically from the Release object ID.
209
+ *
210
+ * Unlike Composition and Recording admin caps, ReleaseAdminCap is not generic
211
+ * (Release has no share type parameter) and stores a reference to its Release.
212
+ */
213
+ export interface ReleaseAdminCap {
214
+ /** The object ID of the admin cap. */
215
+ id: string;
216
+ /** The object ID of the Release this cap administers. */
217
+ releaseId: string;
218
+ }
219
+
220
+ // ============================================================================
221
+ // Deal Events
222
+ // ============================================================================
223
+
224
+ export interface DealCreatedEvent {
225
+ dealId: string;
226
+ releaseId: string;
227
+ trackSplitBps: BPS;
228
+ }
229
+
230
+ /**
231
+ * Emitted when a deal is accepted: consumed by `track::new` into a track for
232
+ * its target release. Treat as provisional until the release publishes (in the
233
+ * honest path both land in the same transaction).
234
+ */
235
+ export interface DealAcceptedEvent {
236
+ dealId: string;
237
+ releaseId: string;
238
+ }
239
+
240
+ /** Emitted when a deal is rejected: destroyed without inclusion in a release. Terminal. */
241
+ export interface DealRejectedEvent {
242
+ dealId: string;
243
+ releaseId: string;
244
+ }
package/src/view.ts ADDED
@@ -0,0 +1,59 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Simulate-based reads (the `view` surface). These build a transaction and run it
5
+ // through the Core `simulateTransaction` API to read a computed value without
6
+ // changing state — used where the value is a pure function of inputs the chain
7
+ // derives (e.g. the deterministic release id).
8
+
9
+ import { Transaction } from "@mysten/sui/transactions";
10
+ import { bcs } from "@mysten/sui/bcs";
11
+ import type { ClientWithCoreApi } from "@mysten/sui/client";
12
+ import * as release from "./contracts/miso/release.ts";
13
+
14
+ export interface DeriveReleaseIdParams {
15
+ /** Sender for the simulation (any address; not charged). */
16
+ sender: string;
17
+ /** Recording object ids, in track order. */
18
+ recordingIds: string[];
19
+ /** Per-track split basis points, aligned to `recordingIds`. */
20
+ splitBps: number[];
21
+ /** The release nonce (u256 as a decimal string). */
22
+ nonce: string;
23
+ /** The shared ReleaseRegistry object id. */
24
+ releaseRegistryId: string;
25
+ }
26
+
27
+ /**
28
+ * Derives the release id the on-chain `release::new` will produce for these
29
+ * inputs, via a `simulateTransaction` call to `release::derive_release_id`. The
30
+ * deals embedded in a release must reference this exact id, so it is computed up
31
+ * front and threaded into the release publish builder.
32
+ */
33
+ export async function deriveReleaseId(
34
+ client: ClientWithCoreApi,
35
+ misoPackageId: string,
36
+ params: DeriveReleaseIdParams,
37
+ ): Promise<string> {
38
+ if (params.recordingIds.length !== params.splitBps.length) {
39
+ throw new Error(`deriveReleaseId: recordingIds (${params.recordingIds.length}) and splitBps (${params.splitBps.length}) length mismatch.`);
40
+ }
41
+
42
+ const tx = new Transaction();
43
+ tx.setSender(params.sender);
44
+ tx.add(
45
+ release.deriveReleaseId({
46
+ package: misoPackageId,
47
+ arguments: [params.recordingIds, params.splitBps.map((v) => BigInt(v)), BigInt(params.nonce), params.releaseRegistryId],
48
+ }),
49
+ );
50
+
51
+ // gRPC/Core equivalent of devInspect: simulate with per-command return values.
52
+ const res = await client.core.simulateTransaction({ transaction: tx, include: { commandResults: true } });
53
+ if (res.$kind !== "Transaction") {
54
+ throw new Error(`derive_release_id simulation failed: ${JSON.stringify(res.FailedTransaction.status)}`);
55
+ }
56
+ const returned = res.commandResults?.[0]?.returnValues?.[0]?.bcs;
57
+ if (!returned) throw new Error("derive_release_id returned no value.");
58
+ return bcs.Address.parse(returned);
59
+ }