@misonetwork/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -139
- package/dist/client.d.ts +1225 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +43 -19
- package/dist/client.js.map +1 -1
- package/dist/contracts/composition_credits/composition_credits.d.ts +181 -0
- package/dist/contracts/composition_credits/composition_credits.d.ts.map +1 -0
- package/dist/contracts/composition_credits/composition_credits.js +109 -0
- package/dist/contracts/composition_credits/composition_credits.js.map +1 -0
- package/dist/contracts/composition_credits/composition_party_role.d.ts +119 -0
- package/dist/contracts/composition_credits/composition_party_role.d.ts.map +1 -0
- package/dist/contracts/composition_credits/composition_party_role.js +139 -0
- package/dist/contracts/composition_credits/composition_party_role.js.map +1 -0
- package/dist/contracts/composition_credits/deps/miso_credit/credit.d.ts +24 -0
- package/dist/contracts/composition_credits/deps/miso_credit/credit.d.ts.map +1 -0
- package/dist/contracts/composition_credits/deps/miso_credit/credit.js +23 -0
- package/dist/contracts/composition_credits/deps/miso_credit/credit.js.map +1 -0
- package/dist/contracts/composition_credits/deps/sui/vec_map.d.ts +37 -0
- package/dist/contracts/composition_credits/deps/sui/vec_map.d.ts.map +1 -0
- package/dist/contracts/composition_credits/deps/sui/vec_map.js +28 -0
- package/dist/contracts/composition_credits/deps/sui/vec_map.js.map +1 -0
- package/dist/contracts/miso/composition.d.ts +1 -1
- package/dist/contracts/miso/composition.js +2 -2
- package/dist/contracts/miso/deps/bps/bps.d.ts +1 -1
- package/dist/contracts/miso/deps/bps/bps.js +1 -1
- package/dist/contracts/miso/recording.d.ts +1 -1
- package/dist/contracts/miso/recording.js +1 -1
- package/dist/contracts/miso/release.d.ts +61 -37
- package/dist/contracts/miso/release.d.ts.map +1 -1
- package/dist/contracts/miso/release.js +65 -38
- package/dist/contracts/miso/release.js.map +1 -1
- package/dist/contracts/miso/track.d.ts +2 -2
- package/dist/contracts/miso/track.js +2 -2
- package/dist/contracts/recording_advisory/recording_advisory.d.ts +194 -0
- package/dist/contracts/recording_advisory/recording_advisory.d.ts.map +1 -0
- package/dist/contracts/recording_advisory/recording_advisory.js +204 -0
- package/dist/contracts/recording_advisory/recording_advisory.js.map +1 -0
- package/dist/contracts/recording_credits/deps/miso_credit/credit.d.ts +24 -0
- package/dist/contracts/recording_credits/deps/miso_credit/credit.d.ts.map +1 -0
- package/dist/contracts/recording_credits/deps/miso_credit/credit.js +23 -0
- package/dist/contracts/recording_credits/deps/miso_credit/credit.js.map +1 -0
- package/dist/contracts/recording_credits/deps/sui/vec_map.d.ts +37 -0
- package/dist/contracts/recording_credits/deps/sui/vec_map.d.ts.map +1 -0
- package/dist/contracts/recording_credits/deps/sui/vec_map.js +28 -0
- package/dist/contracts/recording_credits/deps/sui/vec_map.js.map +1 -0
- package/dist/contracts/recording_credits/deps/sui/vec_set.d.ts +21 -0
- package/dist/contracts/recording_credits/deps/sui/vec_set.d.ts.map +1 -0
- package/dist/contracts/recording_credits/deps/sui/vec_set.js +20 -0
- package/dist/contracts/recording_credits/deps/sui/vec_set.js.map +1 -0
- package/dist/contracts/recording_credits/recording_credits.d.ts +2313 -0
- package/dist/contracts/recording_credits/recording_credits.d.ts.map +1 -0
- package/dist/contracts/recording_credits/recording_credits.js +270 -0
- package/dist/contracts/recording_credits/recording_credits.js.map +1 -0
- package/dist/contracts/recording_credits/recording_party_role.d.ts +1174 -0
- package/dist/contracts/recording_credits/recording_party_role.d.ts.map +1 -0
- package/dist/contracts/recording_credits/recording_party_role.js +692 -0
- package/dist/contracts/recording_credits/recording_party_role.js.map +1 -0
- package/dist/contracts/recording_language/deps/language_code/language_code.d.ts +6 -0
- package/dist/contracts/recording_language/deps/language_code/language_code.d.ts.map +1 -0
- package/dist/contracts/recording_language/deps/language_code/language_code.js +8 -0
- package/dist/contracts/recording_language/deps/language_code/language_code.js.map +1 -0
- package/dist/contracts/recording_language/recording_language.d.ts +152 -0
- package/dist/contracts/recording_language/recording_language.d.ts.map +1 -0
- package/dist/contracts/recording_language/recording_language.js +149 -0
- package/dist/contracts/recording_language/recording_language.js.map +1 -0
- package/dist/contracts/recording_master_reference/deps/ori/walrus_data.d.ts +52 -0
- package/dist/contracts/recording_master_reference/deps/ori/walrus_data.d.ts.map +1 -0
- package/dist/contracts/recording_master_reference/deps/ori/walrus_data.js +37 -0
- package/dist/contracts/recording_master_reference/deps/ori/walrus_data.js.map +1 -0
- package/dist/contracts/recording_master_reference/recording_master_reference.d.ts +131 -0
- package/dist/contracts/recording_master_reference/recording_master_reference.d.ts.map +1 -0
- package/dist/contracts/recording_master_reference/recording_master_reference.js +121 -0
- package/dist/contracts/recording_master_reference/recording_master_reference.js.map +1 -0
- package/dist/contracts/recording_preview/deps/ori/walrus_data.d.ts +52 -0
- package/dist/contracts/recording_preview/deps/ori/walrus_data.d.ts.map +1 -0
- package/dist/contracts/recording_preview/deps/ori/walrus_data.js +37 -0
- package/dist/contracts/recording_preview/deps/ori/walrus_data.js.map +1 -0
- package/dist/contracts/recording_preview/recording_preview.d.ts +104 -0
- package/dist/contracts/recording_preview/recording_preview.d.ts.map +1 -0
- package/dist/contracts/recording_preview/recording_preview.js +94 -0
- package/dist/contracts/recording_preview/recording_preview.js.map +1 -0
- package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.d.ts +52 -0
- package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.d.ts.map +1 -0
- package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.js +37 -0
- package/dist/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.js.map +1 -0
- package/dist/contracts/release_cover_art/deps/cover_art/cover_art.d.ts +46 -0
- package/dist/contracts/release_cover_art/deps/cover_art/cover_art.d.ts.map +1 -0
- package/dist/contracts/release_cover_art/deps/cover_art/cover_art.js +21 -0
- package/dist/contracts/release_cover_art/deps/cover_art/cover_art.js.map +1 -0
- package/dist/contracts/release_cover_art/deps/per_track/per_track.d.ts +33 -0
- package/dist/contracts/release_cover_art/deps/per_track/per_track.d.ts.map +1 -0
- package/dist/contracts/release_cover_art/deps/per_track/per_track.js +32 -0
- package/dist/contracts/release_cover_art/deps/per_track/per_track.js.map +1 -0
- package/dist/contracts/release_cover_art/release_cover_art.d.ts +300 -0
- package/dist/contracts/release_cover_art/release_cover_art.d.ts.map +1 -0
- package/dist/contracts/release_cover_art/release_cover_art.js +168 -0
- package/dist/contracts/release_cover_art/release_cover_art.js.map +1 -0
- package/dist/contracts/release_credits/deps/miso_credit/credit.d.ts +24 -0
- package/dist/contracts/release_credits/deps/miso_credit/credit.d.ts.map +1 -0
- package/dist/contracts/release_credits/deps/miso_credit/credit.js +23 -0
- package/dist/contracts/release_credits/deps/miso_credit/credit.js.map +1 -0
- package/dist/contracts/release_credits/deps/sui/vec_map.d.ts +37 -0
- package/dist/contracts/release_credits/deps/sui/vec_map.d.ts.map +1 -0
- package/dist/contracts/release_credits/deps/sui/vec_map.js +28 -0
- package/dist/contracts/release_credits/deps/sui/vec_map.js.map +1 -0
- package/dist/contracts/release_credits/release_credits.d.ts +142 -0
- package/dist/contracts/release_credits/release_credits.d.ts.map +1 -0
- package/dist/contracts/release_credits/release_credits.js +108 -0
- package/dist/contracts/release_credits/release_credits.js.map +1 -0
- package/dist/contracts/release_credits/release_party_role.d.ts +58 -0
- package/dist/contracts/release_credits/release_party_role.d.ts.map +1 -0
- package/dist/contracts/release_credits/release_party_role.js +66 -0
- package/dist/contracts/release_credits/release_party_role.js.map +1 -0
- package/dist/contracts/release_description/release_description.d.ts +112 -0
- package/dist/contracts/release_description/release_description.d.ts.map +1 -0
- package/dist/contracts/release_description/release_description.js +123 -0
- package/dist/contracts/release_description/release_description.js.map +1 -0
- package/dist/contracts/release_dsp_link/release_dsp_link.d.ts +644 -0
- package/dist/contracts/release_dsp_link/release_dsp_link.d.ts.map +1 -0
- package/dist/contracts/release_dsp_link/release_dsp_link.js +556 -0
- package/dist/contracts/release_dsp_link/release_dsp_link.js.map +1 -0
- package/dist/contracts/release_genre/deps/per_track/per_track.d.ts +33 -0
- package/dist/contracts/release_genre/deps/per_track/per_track.d.ts.map +1 -0
- package/dist/contracts/release_genre/deps/per_track/per_track.js +32 -0
- package/dist/contracts/release_genre/deps/per_track/per_track.js.map +1 -0
- package/dist/contracts/release_genre/release_genre.d.ts +193 -0
- package/dist/contracts/release_genre/release_genre.d.ts.map +1 -0
- package/dist/contracts/release_genre/release_genre.js +207 -0
- package/dist/contracts/release_genre/release_genre.js.map +1 -0
- package/dist/contracts/release_kind/release_kind.d.ts +98 -0
- package/dist/contracts/release_kind/release_kind.d.ts.map +1 -0
- package/dist/contracts/release_kind/release_kind.js +109 -0
- package/dist/contracts/release_kind/release_kind.js.map +1 -0
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.d.ts +52 -0
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.d.ts.map +1 -0
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.js +37 -0
- package/dist/contracts/release_snapshot_bundle/deps/ori/walrus_data.js.map +1 -0
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.d.ts +91 -0
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.d.ts.map +1 -0
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.js +91 -0
- package/dist/contracts/release_snapshot_bundle/release_snapshot_bundle.js.map +1 -0
- package/dist/contracts/routed_stake/deps/royalty_pool/stake.d.ts +54 -0
- package/dist/contracts/routed_stake/deps/royalty_pool/stake.d.ts.map +1 -0
- package/dist/contracts/routed_stake/deps/royalty_pool/stake.js +37 -0
- package/dist/contracts/routed_stake/deps/royalty_pool/stake.js.map +1 -0
- package/dist/contracts/routed_stake/deps/std/type_name.d.ts +18 -0
- package/dist/contracts/routed_stake/deps/std/type_name.d.ts.map +1 -0
- package/dist/contracts/routed_stake/deps/std/type_name.js +20 -0
- package/dist/contracts/routed_stake/deps/std/type_name.js.map +1 -0
- package/dist/contracts/routed_stake/deps/sui/balance.d.ts +13 -0
- package/dist/contracts/routed_stake/deps/sui/balance.d.ts.map +1 -0
- package/dist/contracts/routed_stake/deps/sui/balance.js +15 -0
- package/dist/contracts/routed_stake/deps/sui/balance.js.map +1 -0
- package/dist/contracts/routed_stake/deps/sui/vec_map.d.ts +37 -0
- package/dist/contracts/routed_stake/deps/sui/vec_map.d.ts.map +1 -0
- package/dist/contracts/routed_stake/deps/sui/vec_map.js +28 -0
- package/dist/contracts/routed_stake/deps/sui/vec_map.js.map +1 -0
- package/dist/contracts/routed_stake/routed_stake.d.ts +356 -0
- package/dist/contracts/routed_stake/routed_stake.d.ts.map +1 -0
- package/dist/contracts/routed_stake/routed_stake.js +311 -0
- package/dist/contracts/routed_stake/routed_stake.js.map +1 -0
- package/dist/contracts/royalty_pool/deps/std/type_name.d.ts +18 -0
- package/dist/contracts/royalty_pool/deps/std/type_name.d.ts.map +1 -0
- package/dist/contracts/royalty_pool/deps/std/type_name.js +20 -0
- package/dist/contracts/royalty_pool/deps/std/type_name.js.map +1 -0
- package/dist/contracts/royalty_pool/deps/sui/balance.d.ts +13 -0
- package/dist/contracts/royalty_pool/deps/sui/balance.d.ts.map +1 -0
- package/dist/contracts/royalty_pool/deps/sui/balance.js +15 -0
- package/dist/contracts/royalty_pool/deps/sui/balance.js.map +1 -0
- package/dist/contracts/royalty_pool/deps/sui/vec_map.d.ts +37 -0
- package/dist/contracts/royalty_pool/deps/sui/vec_map.d.ts.map +1 -0
- package/dist/contracts/royalty_pool/deps/sui/vec_map.js +28 -0
- package/dist/contracts/royalty_pool/deps/sui/vec_map.js.map +1 -0
- package/dist/contracts/royalty_pool/pool.d.ts +394 -0
- package/dist/contracts/royalty_pool/pool.d.ts.map +1 -0
- package/dist/contracts/royalty_pool/pool.js +387 -0
- package/dist/contracts/royalty_pool/pool.js.map +1 -0
- package/dist/contracts/royalty_pool/stake.d.ts +202 -0
- package/dist/contracts/royalty_pool/stake.d.ts.map +1 -0
- package/dist/contracts/royalty_pool/stake.js +197 -0
- package/dist/contracts/royalty_pool/stake.js.map +1 -0
- package/dist/contracts.d.ts +37 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +42 -8
- package/dist/contracts.js.map +1 -1
- package/dist/deployments.d.ts +46 -12
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +119 -11
- package/dist/deployments.js.map +1 -1
- package/dist/events.d.ts +1081 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +124 -0
- package/dist/events.js.map +1 -0
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +0 -4
- package/dist/execute.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/numeric.d.ts +5 -0
- package/dist/numeric.d.ts.map +1 -0
- package/dist/numeric.js +21 -0
- package/dist/numeric.js.map +1 -0
- package/dist/packages.d.ts +159 -0
- package/dist/packages.d.ts.map +1 -0
- package/dist/packages.js +179 -0
- package/dist/packages.js.map +1 -0
- package/dist/parsers.d.ts +5 -1
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +18 -2
- package/dist/parsers.js.map +1 -1
- package/dist/queries.d.ts +92 -0
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +132 -23
- package/dist/queries.js.map +1 -1
- package/dist/transactions.d.ts +96 -3
- package/dist/transactions.d.ts.map +1 -1
- package/dist/transactions.js +123 -11
- package/dist/transactions.js.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/view.d.ts +6 -5
- package/dist/view.d.ts.map +1 -1
- package/dist/view.js +8 -2
- package/dist/view.js.map +1 -1
- package/package.json +14 -4
- package/src/client.ts +57 -23
- package/src/contracts/composition_credits/composition_credits.ts +169 -0
- package/src/contracts/composition_credits/composition_party_role.ts +189 -0
- package/src/contracts/composition_credits/deps/miso_credit/credit.ts +27 -0
- package/src/contracts/composition_credits/deps/sui/vec_map.ts +33 -0
- package/src/contracts/miso/composition.ts +8 -8
- package/src/contracts/miso/deps/bps/bps.ts +3 -3
- package/src/contracts/miso/recording.ts +10 -10
- package/src/contracts/miso/release.ts +103 -67
- package/src/contracts/miso/track.ts +5 -5
- package/src/contracts/recording_advisory/recording_advisory.ts +315 -0
- package/src/contracts/recording_credits/deps/miso_credit/credit.ts +27 -0
- package/src/contracts/recording_credits/deps/sui/vec_map.ts +33 -0
- package/src/contracts/recording_credits/deps/sui/vec_set.ts +21 -0
- package/src/contracts/recording_credits/recording_credits.ts +458 -0
- package/src/contracts/recording_credits/recording_party_role.ts +1041 -0
- package/src/contracts/recording_language/deps/language_code/language_code.ts +7 -0
- package/src/contracts/recording_language/recording_language.ts +237 -0
- package/src/contracts/recording_master_reference/deps/ori/walrus_data.ts +36 -0
- package/src/contracts/recording_master_reference/recording_master_reference.ts +181 -0
- package/src/contracts/recording_preview/deps/ori/walrus_data.ts +36 -0
- package/src/contracts/recording_preview/recording_preview.ts +154 -0
- package/src/contracts/release_cover_art/deps/0x340057f2174fb59e4626742dd2b46c662237837b6187450cb59e4976ce7eac78/walrus_data.ts +36 -0
- package/src/contracts/release_cover_art/deps/cover_art/cover_art.ts +23 -0
- package/src/contracts/release_cover_art/deps/per_track/per_track.ts +36 -0
- package/src/contracts/release_cover_art/release_cover_art.ts +251 -0
- package/src/contracts/release_credits/deps/miso_credit/credit.ts +27 -0
- package/src/contracts/release_credits/deps/sui/vec_map.ts +33 -0
- package/src/contracts/release_credits/release_credits.ts +156 -0
- package/src/contracts/release_credits/release_party_role.ts +87 -0
- package/src/contracts/release_description/release_description.ts +167 -0
- package/src/contracts/release_dsp_link/release_dsp_link.ts +813 -0
- package/src/contracts/release_genre/deps/per_track/per_track.ts +36 -0
- package/src/contracts/release_genre/release_genre.ts +314 -0
- package/src/contracts/release_kind/release_kind.ts +153 -0
- package/src/contracts/release_snapshot_bundle/deps/ori/walrus_data.ts +36 -0
- package/src/contracts/release_snapshot_bundle/release_snapshot_bundle.ts +124 -0
- package/src/contracts/routed_stake/deps/royalty_pool/stake.ts +39 -0
- package/src/contracts/routed_stake/deps/std/type_name.ts +22 -0
- package/src/contracts/routed_stake/deps/sui/balance.ts +17 -0
- package/src/contracts/routed_stake/deps/sui/vec_map.ts +33 -0
- package/src/contracts/routed_stake/routed_stake.ts +508 -0
- package/src/contracts/royalty_pool/deps/std/type_name.ts +22 -0
- package/src/contracts/royalty_pool/deps/sui/balance.ts +17 -0
- package/src/contracts/royalty_pool/deps/sui/vec_map.ts +33 -0
- package/src/contracts/royalty_pool/pool.ts +613 -0
- package/src/contracts/royalty_pool/stake.ts +317 -0
- package/src/contracts.ts +59 -6
- package/src/deployments.ts +160 -22
- package/src/events.ts +129 -0
- package/src/execute.ts +0 -4
- package/src/index.ts +6 -3
- package/src/internal.ts +0 -4
- package/src/numeric.ts +25 -0
- package/src/packages.ts +251 -0
- package/src/parsers.ts +32 -2
- package/src/queries.ts +227 -25
- package/src/transactions.ts +254 -12
- package/src/types.ts +20 -0
- package/src/view.ts +12 -6
package/src/queries.ts
CHANGED
|
@@ -12,10 +12,8 @@
|
|
|
12
12
|
// they obtained from the chain, so a miss means a broken reference — an
|
|
13
13
|
// exceptional state, not a normal one.
|
|
14
14
|
// - Extension dynamic-field readers return `null` — extension data is optional
|
|
15
|
-
// by design, and "not attached" is a normal, expected state.
|
|
16
|
-
//
|
|
17
|
-
// `getReleaseCredits`, `getReleaseCover`) and re-import {@link isNotFound}
|
|
18
|
-
// from here to keep one not-found taxonomy across both packages.
|
|
15
|
+
// by design, and "not attached" is a normal, expected state. Use
|
|
16
|
+
// `getExtensionField` with the generated BCS codec for the extension.
|
|
19
17
|
// All null-returning readers use {@link isNotFound} to distinguish a missing
|
|
20
18
|
// object from a transport failure (which still throws).
|
|
21
19
|
|
|
@@ -26,7 +24,13 @@ import { deriveObjectID, normalizeSuiAddress } from "@mysten/sui/utils";
|
|
|
26
24
|
|
|
27
25
|
import { Composition as CompositionBcs } from "./contracts/miso/composition.ts";
|
|
28
26
|
import { Recording as RecordingBcs } from "./contracts/miso/recording.ts";
|
|
29
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
Release as ReleaseBcs,
|
|
29
|
+
ReleaseRegistry as ReleaseRegistryBcs,
|
|
30
|
+
} from "./contracts/miso/release.ts";
|
|
31
|
+
import { RoyaltyPool as RoyaltyPoolBcs } from "./contracts/royalty_pool/pool.ts";
|
|
32
|
+
import { Stake as RoyaltyStakeBcs } from "./contracts/royalty_pool/stake.ts";
|
|
33
|
+
import { RoutedStake as RoutedStakeBcs } from "./contracts/routed_stake/routed_stake.ts";
|
|
30
34
|
import {
|
|
31
35
|
mapBps,
|
|
32
36
|
mapComposition,
|
|
@@ -117,6 +121,35 @@ export function isNotFound(e: unknown): boolean {
|
|
|
117
121
|
/** Key bytes for Move unit structs (single `0x00` for `dummy_field: bool = false`). */
|
|
118
122
|
const UNIT_STRUCT_KEY_BYTES = new Uint8Array([0x00]);
|
|
119
123
|
|
|
124
|
+
/** Any generated BCS codec with a `parse` method. */
|
|
125
|
+
export interface BcsParser<T> {
|
|
126
|
+
parse(bytes: Uint8Array): T;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Exhaust every Core owned-object page; cap discovery must not truncate. */
|
|
130
|
+
async function listAllOwnedObjects(
|
|
131
|
+
client: ClientWithCoreApi,
|
|
132
|
+
input: Record<string, unknown>,
|
|
133
|
+
): Promise<Array<{ objectId: string; type?: string; json?: unknown }>> {
|
|
134
|
+
const objects: Array<{ objectId: string; type?: string; json?: unknown }> = [];
|
|
135
|
+
let cursor: string | null | undefined;
|
|
136
|
+
do {
|
|
137
|
+
const page = await (client.core.listOwnedObjects as (args: unknown) => Promise<{
|
|
138
|
+
objects: Array<{ objectId: string; type?: string; json?: unknown }>;
|
|
139
|
+
pageInfo?: { hasNextPage?: boolean; endCursor?: string | null };
|
|
140
|
+
hasNextPage?: boolean;
|
|
141
|
+
cursor?: string | null;
|
|
142
|
+
}>)(cursor ? { ...input, cursor } : input);
|
|
143
|
+
objects.push(...page.objects);
|
|
144
|
+
cursor = page.pageInfo?.hasNextPage
|
|
145
|
+
? page.pageInfo.endCursor
|
|
146
|
+
: page.hasNextPage
|
|
147
|
+
? page.cursor
|
|
148
|
+
: null;
|
|
149
|
+
} while (cursor);
|
|
150
|
+
return objects;
|
|
151
|
+
}
|
|
152
|
+
|
|
120
153
|
/** Fetches one object's BCS content bytes (or null if absent). */
|
|
121
154
|
async function getContent(
|
|
122
155
|
client: ClientWithCoreApi,
|
|
@@ -129,6 +162,168 @@ async function getContent(
|
|
|
129
162
|
return object.content ?? null;
|
|
130
163
|
}
|
|
131
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Fetch and parse an object through the transport-neutral Core API. Object
|
|
167
|
+
* content is BCS; never pass the full `objectBcs` envelope to a Move codec.
|
|
168
|
+
*/
|
|
169
|
+
export async function getObjectByBcs<T>(
|
|
170
|
+
client: ClientWithCoreApi,
|
|
171
|
+
objectId: string,
|
|
172
|
+
codec: BcsParser<T>,
|
|
173
|
+
): Promise<T> {
|
|
174
|
+
const content = await getContent(client, objectId);
|
|
175
|
+
if (!content) throw new Error(`Object not found: ${objectId}`);
|
|
176
|
+
return codec.parse(content);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface ExtensionFieldParams<T> {
|
|
180
|
+
/** Freshly published package address for the extension. */
|
|
181
|
+
packageId: string;
|
|
182
|
+
/** Move module declaring the fieldless `ExtensionKey`. */
|
|
183
|
+
module: string;
|
|
184
|
+
/** Generated codec for the dynamic-field value. */
|
|
185
|
+
codec: BcsParser<T>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Read an optional first-party extension field from a core object's UID. Every
|
|
190
|
+
* current extension uses a fieldless `ExtensionKey`, whose BCS is one false
|
|
191
|
+
* boolean byte. Absence returns `null`; transport errors still propagate.
|
|
192
|
+
*/
|
|
193
|
+
export async function getExtensionField<T>(
|
|
194
|
+
client: ClientWithCoreApi,
|
|
195
|
+
parentId: string,
|
|
196
|
+
params: ExtensionFieldParams<T>,
|
|
197
|
+
): Promise<T | null> {
|
|
198
|
+
try {
|
|
199
|
+
const { dynamicField } = await client.core.getDynamicField({
|
|
200
|
+
parentId,
|
|
201
|
+
name: {
|
|
202
|
+
type: `${params.packageId}::${params.module}::ExtensionKey`,
|
|
203
|
+
bcs: UNIT_STRUCT_KEY_BYTES,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
return params.codec.parse(dynamicField.value.bcs);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
if (isNotFound(error)) return null;
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface ReleaseDspFieldParams<T> {
|
|
214
|
+
/** Freshly published `release_dsp_link` package address. */
|
|
215
|
+
packageId: string;
|
|
216
|
+
/** Numeric DSP discriminator (`DspLinkData::platform()`). */
|
|
217
|
+
platform: number;
|
|
218
|
+
/** Generated codec for `DspLinkData` or `PerTrack<Option<DspLinkData>>`. */
|
|
219
|
+
codec: BcsParser<T>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function getReleaseDspField<T>(
|
|
223
|
+
client: ClientWithCoreApi,
|
|
224
|
+
releaseId: string,
|
|
225
|
+
key: "ReleaseLinkKey" | "TrackLinksKey",
|
|
226
|
+
params: ReleaseDspFieldParams<T>,
|
|
227
|
+
): Promise<T | null> {
|
|
228
|
+
if (!Number.isInteger(params.platform) || params.platform < 0 || params.platform > 255) {
|
|
229
|
+
throw new Error("DSP platform must be a u8 discriminator");
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
const { dynamicField } = await client.core.getDynamicField({
|
|
233
|
+
parentId: releaseId,
|
|
234
|
+
name: {
|
|
235
|
+
type: `${params.packageId}::release_dsp_link::${key}`,
|
|
236
|
+
bcs: Uint8Array.of(params.platform),
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
return params.codec.parse(dynamicField.value.bcs);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if (isNotFound(error)) return null;
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Read a release-level DSP link stored under `ReleaseLinkKey(platform)`. */
|
|
247
|
+
export function getReleaseDspLink<T>(
|
|
248
|
+
client: ClientWithCoreApi,
|
|
249
|
+
releaseId: string,
|
|
250
|
+
params: ReleaseDspFieldParams<T>,
|
|
251
|
+
): Promise<T | null> {
|
|
252
|
+
return getReleaseDspField(client, releaseId, "ReleaseLinkKey", params);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Read the per-track DSP-link array stored under `TrackLinksKey(platform)`. */
|
|
256
|
+
export function getTrackDspLinks<T>(
|
|
257
|
+
client: ClientWithCoreApi,
|
|
258
|
+
releaseId: string,
|
|
259
|
+
params: ReleaseDspFieldParams<T>,
|
|
260
|
+
): Promise<T | null> {
|
|
261
|
+
return getReleaseDspField(client, releaseId, "TrackLinksKey", params);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ============================================================================
|
|
265
|
+
// Core registry and generic primitive reads
|
|
266
|
+
// ============================================================================
|
|
267
|
+
|
|
268
|
+
/** Parse the shared canonical core `miso::release::ReleaseRegistry` by ID. */
|
|
269
|
+
export async function getReleaseRegistryById(
|
|
270
|
+
client: ClientWithCoreApi,
|
|
271
|
+
registryId: string,
|
|
272
|
+
) {
|
|
273
|
+
return getObjectByBcs(client, registryId, ReleaseRegistryBcs);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Parse a royalty pool by object ID. Phantom type arguments do not affect BCS. */
|
|
277
|
+
export async function getRoyaltyPoolById(
|
|
278
|
+
client: ClientWithCoreApi,
|
|
279
|
+
poolId: string,
|
|
280
|
+
) {
|
|
281
|
+
return getObjectByBcs(client, poolId, RoyaltyPoolBcs);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Parse an owned `Stake<Share>` by object ID. */
|
|
285
|
+
export async function getRoyaltyStakeById(
|
|
286
|
+
client: ClientWithCoreApi,
|
|
287
|
+
stakeId: string,
|
|
288
|
+
) {
|
|
289
|
+
return getObjectByBcs(client, stakeId, RoyaltyStakeBcs);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Parse a shared routed stake by object ID. */
|
|
293
|
+
export async function getRoutedStakeById(
|
|
294
|
+
client: ClientWithCoreApi,
|
|
295
|
+
routedStakeId: string,
|
|
296
|
+
) {
|
|
297
|
+
return getObjectByBcs(client, routedStakeId, RoutedStakeBcs);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Deterministically derive the royalty-pool ID for a parent and type pair. */
|
|
301
|
+
export function deriveRoyaltyPoolId(
|
|
302
|
+
parentId: string,
|
|
303
|
+
shareType: string,
|
|
304
|
+
currencyType: string,
|
|
305
|
+
royaltyPoolPackageId: string,
|
|
306
|
+
): string {
|
|
307
|
+
return deriveObjectID(
|
|
308
|
+
parentId,
|
|
309
|
+
`${royaltyPoolPackageId}::pool::RoyaltyPoolKey<${shareType}, ${currencyType}>`,
|
|
310
|
+
UNIT_STRUCT_KEY_BYTES,
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Deterministically derive the routed-stake ID for a parent and stake share. */
|
|
315
|
+
export function deriveRoutedStakeId(
|
|
316
|
+
parentId: string,
|
|
317
|
+
stakeShareType: string,
|
|
318
|
+
routedStakePackageId: string,
|
|
319
|
+
): string {
|
|
320
|
+
return deriveObjectID(
|
|
321
|
+
parentId,
|
|
322
|
+
`${routedStakePackageId}::routed_stake::RoutedStakeKey<${stakeShareType}>`,
|
|
323
|
+
UNIT_STRUCT_KEY_BYTES,
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
132
327
|
// ============================================================================
|
|
133
328
|
// GraphQL discovery queries
|
|
134
329
|
// ============================================================================
|
|
@@ -465,10 +660,7 @@ export async function getOwnedCompositionAdminCaps(
|
|
|
465
660
|
misoPackageId: string,
|
|
466
661
|
): Promise<CompositionAdminCap[]> {
|
|
467
662
|
const capType = `${misoPackageId}::composition::CompositionAdminCap`;
|
|
468
|
-
const
|
|
469
|
-
owner,
|
|
470
|
-
type: capType,
|
|
471
|
-
});
|
|
663
|
+
const objects = await listAllOwnedObjects(client, { owner, type: capType });
|
|
472
664
|
const caps: CompositionAdminCap[] = [];
|
|
473
665
|
for (const obj of objects) {
|
|
474
666
|
const match = obj.type?.match(/<(.+)>$/);
|
|
@@ -590,10 +782,7 @@ export async function getOwnedRecordingAdminCaps(
|
|
|
590
782
|
misoPackageId: string,
|
|
591
783
|
): Promise<RecordingAdminCap[]> {
|
|
592
784
|
const capType = `${misoPackageId}::recording::RecordingAdminCap`;
|
|
593
|
-
const
|
|
594
|
-
owner,
|
|
595
|
-
type: capType,
|
|
596
|
-
});
|
|
785
|
+
const objects = await listAllOwnedObjects(client, { owner, type: capType });
|
|
597
786
|
const caps: RecordingAdminCap[] = [];
|
|
598
787
|
for (const obj of objects) {
|
|
599
788
|
const match = obj.type?.match(/<(.+)>$/);
|
|
@@ -666,7 +855,7 @@ export async function getOwnedReleaseAdminCaps(
|
|
|
666
855
|
misoPackageId: string,
|
|
667
856
|
): Promise<ReleaseAdminCap[]> {
|
|
668
857
|
const capType = `${misoPackageId}::release::ReleaseAdminCap`;
|
|
669
|
-
const
|
|
858
|
+
const objects = await listAllOwnedObjects(client, {
|
|
670
859
|
owner,
|
|
671
860
|
type: capType,
|
|
672
861
|
include: { json: true },
|
|
@@ -724,7 +913,7 @@ export async function getShareCurrencyTreasuryCap(
|
|
|
724
913
|
shareType: string,
|
|
725
914
|
owner: string,
|
|
726
915
|
): Promise<string> {
|
|
727
|
-
const
|
|
916
|
+
const objects = await listAllOwnedObjects(client, {
|
|
728
917
|
owner,
|
|
729
918
|
type: `0x2::coin::TreasuryCap<${shareType}>`,
|
|
730
919
|
});
|
|
@@ -766,15 +955,28 @@ async function addressOfRecordingWithShareType(
|
|
|
766
955
|
misoPackageId: string,
|
|
767
956
|
shareType: string,
|
|
768
957
|
): Promise<string | null> {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
958
|
+
let cursor: string | null | undefined;
|
|
959
|
+
do {
|
|
960
|
+
const result = await client.query<
|
|
961
|
+
{ objects?: WorkAddressConnection | null },
|
|
962
|
+
{ type: string; cursor?: string | null }
|
|
963
|
+
>({
|
|
964
|
+
query: `query RecordingAddress($type: String!, $cursor: String) {
|
|
965
|
+
objects(first: 50, after: $cursor, filter: { type: $type }) {
|
|
966
|
+
pageInfo { hasNextPage endCursor }
|
|
967
|
+
nodes { address asMoveObject { contents { type { repr } } } }
|
|
968
|
+
}
|
|
969
|
+
}`,
|
|
970
|
+
variables: { type: `${misoPackageId}::recording::Recording`, cursor },
|
|
971
|
+
});
|
|
972
|
+
const page = result.data?.objects;
|
|
973
|
+
for (const node of page?.nodes ?? []) {
|
|
974
|
+
const repr = node?.asMoveObject?.contents?.type?.repr;
|
|
975
|
+
if (!repr || !node.address) continue;
|
|
976
|
+
const [recordingShareType] = extractTypeParams2(repr);
|
|
977
|
+
if (recordingShareType === shareType) return node.address;
|
|
978
|
+
}
|
|
979
|
+
cursor = page?.pageInfo?.hasNextPage ? page.pageInfo.endCursor : null;
|
|
980
|
+
} while (cursor);
|
|
779
981
|
return null;
|
|
780
982
|
}
|
package/src/transactions.ts
CHANGED
|
@@ -25,20 +25,24 @@
|
|
|
25
25
|
// sending an admin cap somewhere other than a plain address (every admin cap is
|
|
26
26
|
// `key, store`, so it is freely routable).
|
|
27
27
|
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// `finalizeComposition`/`finalizeRecording`/`finalizeRelease`,
|
|
32
|
-
// `publishComposition`/`publishRecording`/`publishCompositionAndRecording`,
|
|
33
|
-
// `share.ts`) as free functions taking `misoPackageId` explicitly. Those import
|
|
34
|
-
// the primitives from here and build on top, same PTB composition pattern, just
|
|
35
|
-
// crossing a package boundary.
|
|
28
|
+
// This package exposes the complete low-level current ABI. The platform SDK
|
|
29
|
+
// should own product-specific orchestration (cap disposition, currency
|
|
30
|
+
// lifecycle, authority-package workflows) on top of these composable calls.
|
|
36
31
|
|
|
37
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
Transaction,
|
|
34
|
+
type TransactionArgument,
|
|
35
|
+
type TransactionObjectArgument,
|
|
36
|
+
} from "@mysten/sui/transactions";
|
|
38
37
|
|
|
39
38
|
import * as composition from "./contracts/miso/composition.ts";
|
|
40
39
|
import * as recording from "./contracts/miso/recording.ts";
|
|
40
|
+
import * as release from "./contracts/miso/release.ts";
|
|
41
|
+
import { asU256, type UnsignedInput } from "./numeric.ts";
|
|
41
42
|
import * as track from "./contracts/miso/track.ts";
|
|
43
|
+
import * as royaltyPool from "./contracts/royalty_pool/pool.ts";
|
|
44
|
+
import * as royaltyStake from "./contracts/royalty_pool/stake.ts";
|
|
45
|
+
import * as routedStake from "./contracts/routed_stake/routed_stake.ts";
|
|
42
46
|
|
|
43
47
|
/** A thunk that adds commands to a transaction. May be async (resolves at build time). */
|
|
44
48
|
export type TxThunk = (tx: Transaction) => void | Promise<void>;
|
|
@@ -145,7 +149,10 @@ export function createRecording(tx: Transaction, params: CreateRecordingParams):
|
|
|
145
149
|
// ============================================================================
|
|
146
150
|
|
|
147
151
|
export interface CreateTrackParams {
|
|
148
|
-
|
|
152
|
+
/** Shared recording object ID, unless `recording` is PTB-local. */
|
|
153
|
+
recordingId?: string;
|
|
154
|
+
/** A recording returned by `createRecording` earlier in this same PTB. */
|
|
155
|
+
recording?: TransactionObjectArgument;
|
|
149
156
|
recordingAdminCapId?: string;
|
|
150
157
|
recordingAdminCap?: TransactionObjectArgument;
|
|
151
158
|
/** Share type of the recording (the track's `RecordingShare` phantom). */
|
|
@@ -161,7 +168,8 @@ export interface CreateTrackParams {
|
|
|
161
168
|
* PRIMITIVE. Appends `track::new` and returns its by-value `Track`. A track has
|
|
162
169
|
* `drop, store`, so callers may leave it unused; to assemble a release, pass
|
|
163
170
|
* returned tracks to `tx.makeMoveVec({ type: `${misoPackageId}::track::Track`,
|
|
164
|
-
* elements })` and then
|
|
171
|
+
* elements })` and then pass that vector to `createRelease` with its shared
|
|
172
|
+
* `ReleaseRegistry` object.
|
|
165
173
|
*
|
|
166
174
|
* The `recordingAdminCap` may be passed as an on-chain object id
|
|
167
175
|
* (`recordingAdminCapId`) or as a PTB-local argument (`recordingAdminCap`) —
|
|
@@ -172,17 +180,251 @@ export function createTrack(tx: Transaction, params: CreateTrackParams): Transac
|
|
|
172
180
|
if (!params.recordingAdminCap && !params.recordingAdminCapId) {
|
|
173
181
|
throw new Error("createTrack: recordingAdminCapId or recordingAdminCap required");
|
|
174
182
|
}
|
|
183
|
+
if (!params.recording && !params.recordingId) {
|
|
184
|
+
throw new Error("createTrack: recordingId or recording required");
|
|
185
|
+
}
|
|
175
186
|
const adminCapArg = params.recordingAdminCap ?? tx.object(params.recordingAdminCapId!);
|
|
187
|
+
const recordingArg = params.recording ?? tx.object(params.recordingId!);
|
|
176
188
|
return tx.add(
|
|
177
189
|
track._new({
|
|
178
190
|
package: params.misoPackageId,
|
|
179
191
|
typeArguments: [params.recordingShareType, params.compositionShareType],
|
|
180
192
|
arguments: [
|
|
181
193
|
adminCapArg,
|
|
182
|
-
|
|
194
|
+
recordingArg,
|
|
183
195
|
tx.pure.id(params.targetReleaseId),
|
|
184
196
|
tx.pure.u16(params.trackSplitBps),
|
|
185
197
|
],
|
|
186
198
|
}),
|
|
187
199
|
);
|
|
188
200
|
}
|
|
201
|
+
|
|
202
|
+
// ============================================================================
|
|
203
|
+
// Publish finalizers
|
|
204
|
+
// ============================================================================
|
|
205
|
+
|
|
206
|
+
/** Consume and share an initialized composition. The generated call supplies Clock. */
|
|
207
|
+
export function publishComposition(
|
|
208
|
+
tx: Transaction,
|
|
209
|
+
params: {
|
|
210
|
+
composition: TransactionObjectArgument;
|
|
211
|
+
adminCap: TransactionObjectArgument;
|
|
212
|
+
shareType: string;
|
|
213
|
+
misoPackageId: string;
|
|
214
|
+
},
|
|
215
|
+
): void {
|
|
216
|
+
tx.add(
|
|
217
|
+
composition.publish({
|
|
218
|
+
package: params.misoPackageId,
|
|
219
|
+
typeArguments: [params.shareType],
|
|
220
|
+
arguments: [params.composition, params.adminCap],
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Consume and share an initialized recording. The generated call supplies Clock. */
|
|
226
|
+
export function publishRecording(
|
|
227
|
+
tx: Transaction,
|
|
228
|
+
params: {
|
|
229
|
+
recording: TransactionObjectArgument;
|
|
230
|
+
adminCap: TransactionObjectArgument;
|
|
231
|
+
recordingShareType: string;
|
|
232
|
+
compositionShareType: string;
|
|
233
|
+
misoPackageId: string;
|
|
234
|
+
},
|
|
235
|
+
): void {
|
|
236
|
+
tx.add(
|
|
237
|
+
recording.publish({
|
|
238
|
+
package: params.misoPackageId,
|
|
239
|
+
typeArguments: [params.recordingShareType, params.compositionShareType],
|
|
240
|
+
arguments: [params.recording, params.adminCap],
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Consume and share an initialized release. The generated call supplies Clock. */
|
|
246
|
+
export function publishRelease(
|
|
247
|
+
tx: Transaction,
|
|
248
|
+
params: {
|
|
249
|
+
release: TransactionObjectArgument;
|
|
250
|
+
adminCap: TransactionObjectArgument;
|
|
251
|
+
misoPackageId: string;
|
|
252
|
+
},
|
|
253
|
+
): void {
|
|
254
|
+
tx.add(
|
|
255
|
+
release.publish({
|
|
256
|
+
package: params.misoPackageId,
|
|
257
|
+
arguments: [params.release, params.adminCap],
|
|
258
|
+
}),
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ============================================================================
|
|
263
|
+
// Core release registry
|
|
264
|
+
// ============================================================================
|
|
265
|
+
|
|
266
|
+
/** The by-value result of core `release::new`. Publish it in this PTB. */
|
|
267
|
+
export interface ReleaseParts {
|
|
268
|
+
release: TransactionObjectArgument;
|
|
269
|
+
adminCap: TransactionObjectArgument;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface CreateReleaseParams {
|
|
273
|
+
/** Shared, canonical `miso::release::ReleaseRegistry` object ID. */
|
|
274
|
+
releaseRegistryId: string;
|
|
275
|
+
title: string;
|
|
276
|
+
/** `Track` values returned by {@link createTrack}; all are consumed. */
|
|
277
|
+
tracks: readonly TransactionObjectArgument[];
|
|
278
|
+
nonce: UnsignedInput;
|
|
279
|
+
/** Freshly published core `miso` package ID. */
|
|
280
|
+
misoPackageId: string;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Assemble a release through core `miso::release::new`. The registry is the
|
|
285
|
+
* first object argument; there is no arbitrary-parent or utility-package path.
|
|
286
|
+
* Both returned values are non-drop and must be published or otherwise consumed
|
|
287
|
+
* in this PTB.
|
|
288
|
+
*/
|
|
289
|
+
export function createRelease(
|
|
290
|
+
tx: Transaction,
|
|
291
|
+
params: CreateReleaseParams,
|
|
292
|
+
): ReleaseParts {
|
|
293
|
+
const tracks = tx.makeMoveVec({
|
|
294
|
+
type: `${params.misoPackageId}::track::Track`,
|
|
295
|
+
elements: [...params.tracks],
|
|
296
|
+
});
|
|
297
|
+
const result = tx.add(
|
|
298
|
+
release._new({
|
|
299
|
+
package: params.misoPackageId,
|
|
300
|
+
arguments: [
|
|
301
|
+
tx.object(params.releaseRegistryId),
|
|
302
|
+
tx.pure.string(params.title),
|
|
303
|
+
tracks,
|
|
304
|
+
tx.pure.u256(asU256("release nonce", params.nonce)),
|
|
305
|
+
],
|
|
306
|
+
}),
|
|
307
|
+
);
|
|
308
|
+
return { release: result[0]!, adminCap: result[1]! };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// ============================================================================
|
|
312
|
+
// Generic royalty primitives
|
|
313
|
+
// ============================================================================
|
|
314
|
+
|
|
315
|
+
/** Create an owned `Stake<Share>` from a by-value `Balance<Share>`. */
|
|
316
|
+
export function createRoyaltyStake(
|
|
317
|
+
tx: Transaction,
|
|
318
|
+
params: {
|
|
319
|
+
balance: TransactionArgument;
|
|
320
|
+
shareType: string;
|
|
321
|
+
royaltyPoolPackageId: string;
|
|
322
|
+
},
|
|
323
|
+
): TransactionObjectArgument {
|
|
324
|
+
return tx.add(
|
|
325
|
+
royaltyStake._new({
|
|
326
|
+
package: params.royaltyPoolPackageId,
|
|
327
|
+
typeArguments: [params.shareType],
|
|
328
|
+
arguments: [params.balance],
|
|
329
|
+
}),
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Destroy an unregistered stake and return its principal `Balance<Share>`. */
|
|
334
|
+
export function destroyRoyaltyStake(
|
|
335
|
+
tx: Transaction,
|
|
336
|
+
params: {
|
|
337
|
+
stake: TransactionObjectArgument;
|
|
338
|
+
shareType: string;
|
|
339
|
+
royaltyPoolPackageId: string;
|
|
340
|
+
},
|
|
341
|
+
): TransactionObjectArgument {
|
|
342
|
+
return tx.add(
|
|
343
|
+
royaltyStake.destroy({
|
|
344
|
+
package: params.royaltyPoolPackageId,
|
|
345
|
+
typeArguments: [params.shareType],
|
|
346
|
+
arguments: [params.stake],
|
|
347
|
+
}),
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Register an owned stake against a shared royalty pool. */
|
|
352
|
+
export function registerRoyaltyStake(
|
|
353
|
+
tx: Transaction,
|
|
354
|
+
params: {
|
|
355
|
+
poolId: string;
|
|
356
|
+
stakeId?: string;
|
|
357
|
+
/** A `Stake` created earlier in this same PTB. */
|
|
358
|
+
stake?: TransactionObjectArgument;
|
|
359
|
+
shareType: string;
|
|
360
|
+
currencyType: string;
|
|
361
|
+
royaltyPoolPackageId: string;
|
|
362
|
+
},
|
|
363
|
+
): void {
|
|
364
|
+
if (!params.stake && !params.stakeId) {
|
|
365
|
+
throw new Error("registerRoyaltyStake: stakeId or stake required");
|
|
366
|
+
}
|
|
367
|
+
tx.add(
|
|
368
|
+
royaltyPool.registerStake({
|
|
369
|
+
package: params.royaltyPoolPackageId,
|
|
370
|
+
typeArguments: [params.shareType, params.currencyType],
|
|
371
|
+
arguments: [tx.object(params.poolId), params.stake ?? tx.object(params.stakeId!)],
|
|
372
|
+
}),
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Claim rewards. The returned `Balance<Currency>` must be consumed in this PTB. */
|
|
377
|
+
export function claimRoyaltyRewards(
|
|
378
|
+
tx: Transaction,
|
|
379
|
+
params: {
|
|
380
|
+
poolId: string;
|
|
381
|
+
stakeId: string;
|
|
382
|
+
shareType: string;
|
|
383
|
+
currencyType: string;
|
|
384
|
+
royaltyPoolPackageId: string;
|
|
385
|
+
},
|
|
386
|
+
): TransactionObjectArgument {
|
|
387
|
+
return tx.add(
|
|
388
|
+
royaltyPool.claimRewards({
|
|
389
|
+
package: params.royaltyPoolPackageId,
|
|
390
|
+
typeArguments: [params.shareType, params.currencyType],
|
|
391
|
+
arguments: [tx.object(params.poolId), tx.object(params.stakeId)],
|
|
392
|
+
}),
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Permissionlessly route rewards from a shared routed stake into its parent
|
|
398
|
+
* pool. Pool/routed-stake creation and lifecycle operations take `&mut UID` and
|
|
399
|
+
* belong in the parent authority module, not in a client-side PTB helper.
|
|
400
|
+
*/
|
|
401
|
+
export function sweepRoutedStake(
|
|
402
|
+
tx: Transaction,
|
|
403
|
+
params: {
|
|
404
|
+
routedStakeId: string;
|
|
405
|
+
stakePoolId: string;
|
|
406
|
+
routedPoolId: string;
|
|
407
|
+
parentId: string;
|
|
408
|
+
stakeShareType: string;
|
|
409
|
+
poolShareType: string;
|
|
410
|
+
currencyType: string;
|
|
411
|
+
routedStakePackageId: string;
|
|
412
|
+
},
|
|
413
|
+
): void {
|
|
414
|
+
tx.add(
|
|
415
|
+
routedStake.sweep({
|
|
416
|
+
package: params.routedStakePackageId,
|
|
417
|
+
typeArguments: [
|
|
418
|
+
params.stakeShareType,
|
|
419
|
+
params.poolShareType,
|
|
420
|
+
params.currencyType,
|
|
421
|
+
],
|
|
422
|
+
arguments: [
|
|
423
|
+
tx.object(params.routedStakeId),
|
|
424
|
+
tx.object(params.stakePoolId),
|
|
425
|
+
tx.object(params.routedPoolId),
|
|
426
|
+
tx.pure.id(params.parentId),
|
|
427
|
+
],
|
|
428
|
+
}),
|
|
429
|
+
);
|
|
430
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -108,6 +108,20 @@ export interface RecordingPublishedEvent {
|
|
|
108
108
|
recordingId: string;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Emitted when recording creation grants the composition its immutable royalty
|
|
113
|
+
* rate's share of the new recording currency.
|
|
114
|
+
*/
|
|
115
|
+
export interface CompositionSharesGrantedEvent {
|
|
116
|
+
recordingId: string;
|
|
117
|
+
compositionId: string;
|
|
118
|
+
/** Recording-share base units sent to the composition address. */
|
|
119
|
+
value: string;
|
|
120
|
+
/** The immutable composition royalty rate applied at recording creation. */
|
|
121
|
+
rateBps: number;
|
|
122
|
+
grantedBy: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
111
125
|
/**
|
|
112
126
|
* Admin cap for a Recording, derived deterministically from the Recording object ID.
|
|
113
127
|
*
|
|
@@ -188,6 +202,12 @@ export interface ReleasePublishedEvent {
|
|
|
188
202
|
releaseId: string;
|
|
189
203
|
}
|
|
190
204
|
|
|
205
|
+
/** Emitted when package initialization shares the canonical release registry. */
|
|
206
|
+
export interface ReleaseRegistryCreatedEvent {
|
|
207
|
+
registryId: string;
|
|
208
|
+
createdBy: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
191
211
|
/**
|
|
192
212
|
* Admin cap for a Release, derived deterministically from the Release object ID.
|
|
193
213
|
*
|
package/src/view.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Transaction } from "@mysten/sui/transactions";
|
|
|
10
10
|
import { bcs } from "@mysten/sui/bcs";
|
|
11
11
|
import type { ClientWithCoreApi } from "@mysten/sui/client";
|
|
12
12
|
import * as release from "./contracts/miso/release.ts";
|
|
13
|
+
import { asU256, asU64, type UnsignedInput } from "./numeric.ts";
|
|
13
14
|
|
|
14
15
|
export interface DeriveTargetReleaseIdParams {
|
|
15
16
|
/** Sender for the simulation (any address; not charged). */
|
|
@@ -17,18 +18,18 @@ export interface DeriveTargetReleaseIdParams {
|
|
|
17
18
|
/** Recording object ids, in track order. */
|
|
18
19
|
recordingIds: string[];
|
|
19
20
|
/** Per-track split basis points, aligned to `recordingIds`. */
|
|
20
|
-
splitBps:
|
|
21
|
+
splitBps: UnsignedInput[];
|
|
21
22
|
/** The release nonce (u256 as a decimal string). */
|
|
22
|
-
nonce:
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
nonce: UnsignedInput;
|
|
24
|
+
/** Shared canonical core `miso::release::ReleaseRegistry` object ID. */
|
|
25
|
+
releaseRegistryId: string;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Derives the release id the on-chain `release::new` will produce for these
|
|
29
30
|
* inputs, via a `simulateTransaction` call to `release::derive_target_release_id`.
|
|
30
31
|
* Tracks embedded in a release must reference this exact ID, so it is computed
|
|
31
|
-
* up front and threaded into the
|
|
32
|
+
* up front and threaded into the core release builder.
|
|
32
33
|
*/
|
|
33
34
|
export async function deriveTargetReleaseId(
|
|
34
35
|
client: ClientWithCoreApi,
|
|
@@ -44,7 +45,12 @@ export async function deriveTargetReleaseId(
|
|
|
44
45
|
tx.add(
|
|
45
46
|
release.deriveTargetReleaseId({
|
|
46
47
|
package: misoPackageId,
|
|
47
|
-
arguments: [
|
|
48
|
+
arguments: [
|
|
49
|
+
params.releaseRegistryId,
|
|
50
|
+
params.recordingIds,
|
|
51
|
+
params.splitBps.map((v) => asU64("track split bps", v)),
|
|
52
|
+
asU256("release nonce", params.nonce),
|
|
53
|
+
],
|
|
48
54
|
}),
|
|
49
55
|
);
|
|
50
56
|
|