@misofm/sdk 0.9.0 → 0.11.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 +88 -56
- package/dist/client.d.ts +121 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +200 -44
- package/dist/client.js.map +1 -1
- package/dist/contracts/composition_routed_stake/composition_routed_stake.d.ts +205 -0
- package/dist/contracts/composition_routed_stake/composition_routed_stake.d.ts.map +1 -0
- package/dist/contracts/composition_routed_stake/composition_routed_stake.js +184 -0
- package/dist/contracts/composition_routed_stake/composition_routed_stake.js.map +1 -0
- package/dist/contracts/composition_routed_stake/witness.d.ts +7 -0
- package/dist/contracts/composition_routed_stake/witness.d.ts.map +1 -0
- package/dist/contracts/composition_routed_stake/witness.js +9 -0
- package/dist/contracts/composition_routed_stake/witness.js.map +1 -0
- package/dist/contracts/composition_royalty_pool/composition_royalty_pool.d.ts +89 -28
- package/dist/contracts/composition_royalty_pool/composition_royalty_pool.d.ts.map +1 -1
- package/dist/contracts/composition_royalty_pool/composition_royalty_pool.js +84 -23
- package/dist/contracts/composition_royalty_pool/composition_royalty_pool.js.map +1 -1
- package/dist/contracts/composition_royalty_pool/witness.d.ts +6 -0
- package/dist/contracts/composition_royalty_pool/witness.d.ts.map +1 -0
- package/dist/contracts/composition_royalty_pool/witness.js +8 -0
- package/dist/contracts/composition_royalty_pool/witness.js.map +1 -0
- package/dist/contracts/genre/genre.d.ts +96 -0
- package/dist/contracts/genre/genre.d.ts.map +1 -0
- package/dist/contracts/genre/genre.js +107 -0
- package/dist/contracts/genre/genre.js.map +1 -0
- 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_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/recording_royalty_pool/recording_royalty_pool.d.ts +90 -28
- package/dist/contracts/recording_royalty_pool/recording_royalty_pool.d.ts.map +1 -1
- package/dist/contracts/recording_royalty_pool/recording_royalty_pool.js +84 -23
- package/dist/contracts/recording_royalty_pool/recording_royalty_pool.js.map +1 -1
- package/dist/contracts/recording_royalty_pool/witness.d.ts +6 -0
- package/dist/contracts/recording_royalty_pool/witness.d.ts.map +1 -0
- package/dist/contracts/recording_royalty_pool/witness.js +8 -0
- package/dist/contracts/recording_royalty_pool/witness.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_revenue_distributor/release_revenue_distributor.d.ts +106 -0
- package/dist/contracts/release_revenue_distributor/release_revenue_distributor.d.ts.map +1 -0
- package/dist/contracts/release_revenue_distributor/release_revenue_distributor.js +113 -0
- package/dist/contracts/release_revenue_distributor/release_revenue_distributor.js.map +1 -0
- package/dist/contracts/release_revenue_distributor/witness.d.ts +7 -0
- package/dist/contracts/release_revenue_distributor/witness.d.ts.map +1 -0
- package/dist/contracts/release_revenue_distributor/witness.js +9 -0
- package/dist/contracts/release_revenue_distributor/witness.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/pool.d.ts +27 -17
- package/dist/contracts/royalty_pool/pool.d.ts.map +1 -1
- package/dist/contracts/royalty_pool/pool.js +26 -17
- package/dist/contracts/royalty_pool/pool.js.map +1 -1
- package/dist/contracts/vault/deps/sui/bag.d.ts +35 -0
- package/dist/contracts/vault/deps/sui/bag.d.ts.map +1 -0
- package/dist/contracts/vault/deps/sui/bag.js +37 -0
- package/dist/contracts/vault/deps/sui/bag.js.map +1 -0
- package/dist/contracts/vault/deps/sui/borrow.d.ts +20 -0
- package/dist/contracts/vault/deps/sui/borrow.d.ts.map +1 -0
- package/dist/contracts/vault/deps/sui/borrow.js +21 -0
- package/dist/contracts/vault/deps/sui/borrow.js.map +1 -0
- package/dist/contracts/vault/vault.d.ts +276 -0
- package/dist/contracts/vault/vault.d.ts.map +1 -0
- package/dist/contracts/vault/vault.js +274 -0
- package/dist/contracts/vault/vault.js.map +1 -0
- package/dist/contracts.d.ts +13 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +15 -7
- package/dist/contracts.js.map +1 -1
- package/dist/cover.d.ts +17 -3
- package/dist/cover.d.ts.map +1 -1
- package/dist/cover.js +43 -20
- package/dist/cover.js.map +1 -1
- package/dist/credits.d.ts +31 -12
- package/dist/credits.d.ts.map +1 -1
- package/dist/credits.js +41 -25
- package/dist/credits.js.map +1 -1
- package/dist/deployments.d.ts +30 -57
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +5 -53
- package/dist/deployments.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/pressing.d.ts +8 -7
- package/dist/pressing.d.ts.map +1 -1
- package/dist/pressing.js +91 -32
- package/dist/pressing.js.map +1 -1
- package/dist/read/artist.js +3 -3
- package/dist/read/artist.js.map +1 -1
- package/dist/read/catalog.d.ts +14 -9
- package/dist/read/catalog.d.ts.map +1 -1
- package/dist/read/catalog.js +71 -37
- package/dist/read/catalog.js.map +1 -1
- package/dist/read/client.d.ts +4 -2
- package/dist/read/client.d.ts.map +1 -1
- package/dist/read/client.js +15 -4
- package/dist/read/client.js.map +1 -1
- package/dist/read/config.d.ts +14 -11
- package/dist/read/config.d.ts.map +1 -1
- package/dist/read/config.js +10 -37
- package/dist/read/config.js.map +1 -1
- package/dist/read/index.d.ts +2 -2
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +1 -1
- package/dist/read/index.js.map +1 -1
- package/dist/read/receipts.d.ts +24 -7
- package/dist/read/receipts.d.ts.map +1 -1
- package/dist/read/receipts.js +78 -25
- package/dist/read/receipts.js.map +1 -1
- package/dist/read/types.d.ts +43 -25
- package/dist/read/types.d.ts.map +1 -1
- package/dist/read/types.js +2 -2
- package/dist/read/types.js.map +1 -1
- package/dist/recording-extensions.d.ts +37 -0
- package/dist/recording-extensions.d.ts.map +1 -0
- package/dist/recording-extensions.js +61 -0
- package/dist/recording-extensions.js.map +1 -0
- package/dist/release-extensions.d.ts +84 -0
- package/dist/release-extensions.d.ts.map +1 -0
- package/dist/release-extensions.js +160 -0
- package/dist/release-extensions.js.map +1 -0
- package/dist/release-graph.d.ts +17 -26
- package/dist/release-graph.d.ts.map +1 -1
- package/dist/release-graph.js +55 -49
- package/dist/release-graph.js.map +1 -1
- package/dist/transactions.d.ts +43 -24
- package/dist/transactions.d.ts.map +1 -1
- package/dist/transactions.js +48 -27
- package/dist/transactions.js.map +1 -1
- package/dist/vault.d.ts +268 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +389 -0
- package/dist/vault.js.map +1 -0
- package/package.json +17 -11
- package/src/client.ts +399 -61
- package/src/contracts/composition_routed_stake/composition_routed_stake.ts +346 -0
- package/src/contracts/composition_routed_stake/witness.ts +11 -0
- package/src/contracts/composition_royalty_pool/composition_royalty_pool.ts +151 -35
- package/src/contracts/composition_royalty_pool/witness.ts +7 -0
- package/src/contracts/genre/genre.ts +151 -0
- package/src/contracts/recording_advisory/recording_advisory.ts +315 -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/recording_royalty_pool/recording_royalty_pool.ts +152 -35
- package/src/contracts/recording_royalty_pool/witness.ts +7 -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_revenue_distributor/release_revenue_distributor.ts +178 -0
- package/src/contracts/release_revenue_distributor/witness.ts +11 -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/pool.ts +34 -24
- package/src/contracts/vault/deps/sui/bag.ts +39 -0
- package/src/contracts/vault/deps/sui/borrow.ts +25 -0
- package/src/contracts/vault/vault.ts +454 -0
- package/src/contracts.ts +16 -9
- package/src/cover.ts +62 -37
- package/src/credits.ts +64 -51
- package/src/deployments.ts +35 -97
- package/src/index.ts +11 -5
- package/src/pressing.ts +135 -39
- package/src/read/artist.ts +3 -3
- package/src/read/catalog.ts +99 -44
- package/src/read/client.ts +20 -4
- package/src/read/config.ts +23 -49
- package/src/read/index.ts +3 -1
- package/src/read/receipts.ts +103 -26
- package/src/read/types.ts +44 -27
- package/src/recording-extensions.ts +102 -0
- package/src/release-extensions.ts +261 -0
- package/src/release-graph.ts +68 -81
- package/src/transactions.ts +79 -53
- package/src/vault.ts +777 -0
- package/dist/contracts/miso_drop/drop.d.ts +0 -550
- package/dist/contracts/miso_drop/drop.d.ts.map +0 -1
- package/dist/contracts/miso_drop/drop.js +0 -523
- package/dist/contracts/miso_drop/drop.js.map +0 -1
- package/dist/contracts/release_registry/release_registry.d.ts +0 -114
- package/dist/contracts/release_registry/release_registry.d.ts.map +0 -1
- package/dist/contracts/release_registry/release_registry.js +0 -119
- package/dist/contracts/release_registry/release_registry.js.map +0 -1
- package/dist/drop.d.ts +0 -127
- package/dist/drop.d.ts.map +0 -1
- package/dist/drop.js +0 -202
- package/dist/drop.js.map +0 -1
- package/dist/extensions/royalty-pool.d.ts +0 -32
- package/dist/extensions/royalty-pool.d.ts.map +0 -1
- package/dist/extensions/royalty-pool.js +0 -33
- package/dist/extensions/royalty-pool.js.map +0 -1
- package/src/contracts/miso_drop/drop.ts +0 -798
- package/src/contracts/release_registry/release_registry.ts +0 -160
- package/src/drop.ts +0 -376
- package/src/extensions/royalty-pool.ts +0 -90
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The recommended canonical parent namespace for `miso::release::new`.
|
|
8
|
-
*
|
|
9
|
-
* `miso::release::new` takes `parent: &mut UID` and derives every release's id
|
|
10
|
-
* from `(parent, digest)`: core is deliberately parent-agnostic and implements no
|
|
11
|
-
* coordination policy of its own (see the "Consent scope" section of
|
|
12
|
-
* `miso::release`'s module doc). This package supplies the one recommended parent
|
|
13
|
-
* — a shared, permissionless, undeletable `UID` — and is deliberately the _only_
|
|
14
|
-
* policy it implements: it neither gates who may assemble a release through it nor
|
|
15
|
-
* interprets what a `Track` means.
|
|
16
|
-
*
|
|
17
|
-
* ### One instance, ever
|
|
18
|
-
*
|
|
19
|
-
* The module exposes no constructor: the only `ReleaseRegistry` that can ever
|
|
20
|
-
* exist is the canonical one created and shared by package initialization. "The
|
|
21
|
-
* registry" is therefore unambiguous on-chain — the type itself names the
|
|
22
|
-
* namespace, not a config convention. Every `new_release` takes `&mut` on that one
|
|
23
|
-
* shared object, so release creation through it serializes per checkpoint; the
|
|
24
|
-
* ceiling is accepted — releases are rare events. Alternative namespaces are still
|
|
25
|
-
* possible, but they live in other packages: core is parent-agnostic, and any
|
|
26
|
-
* object exposing a `&mut UID` (a release escrow, for instance) can parent its own
|
|
27
|
-
* releases; ids derived under different parents never collide, by construction of
|
|
28
|
-
* `derive_address`.
|
|
29
|
-
*
|
|
30
|
-
* ### Liveness
|
|
31
|
-
*
|
|
32
|
-
* The canonical instance is shared at publish, and this module exposes no delete
|
|
33
|
-
* function and no `uid_mut`: its only capability is being a derivation parent.
|
|
34
|
-
* That undeletability is a consent guarantee, not an accident — a `Track`'s
|
|
35
|
-
* `target_release_id` commits to this namespace's liveness (see `miso::release`'s
|
|
36
|
-
* module doc), and a deletable parent would strand every track and offer that ever
|
|
37
|
-
* targeted it. Keeping the surface to exactly one capability is what makes that
|
|
38
|
-
* guarantee durable: there is nothing else here to reason about.
|
|
39
|
-
*
|
|
40
|
-
* ### Permissionless
|
|
41
|
-
*
|
|
42
|
-
* No capability gates `new_release`: anyone holding a fully-formed `vector<Track>`
|
|
43
|
-
* may assemble and claim a release through this registry. That is not a gap —
|
|
44
|
-
* consent already lives in the `Track`s themselves, each one minted by its
|
|
45
|
-
* recording's admin via cap-gated `miso::track::new` against this exact digest.
|
|
46
|
-
* Assembly is bookkeeping over consent already given, not a second authorization
|
|
47
|
-
* step.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
51
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
52
|
-
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
53
|
-
const $moduleName = '@local-pkg/release_registry::release_registry';
|
|
54
|
-
export const ReleaseRegistry = new MoveStruct({ name: `${$moduleName}::ReleaseRegistry`, fields: {
|
|
55
|
-
id: bcs.Address
|
|
56
|
-
} });
|
|
57
|
-
export const ReleaseRegistryCreatedEvent = new MoveStruct({ name: `${$moduleName}::ReleaseRegistryCreatedEvent`, fields: {
|
|
58
|
-
registry_id: bcs.Address,
|
|
59
|
-
created_by: bcs.Address
|
|
60
|
-
} });
|
|
61
|
-
export interface NewReleaseArguments {
|
|
62
|
-
self: RawTransactionArgument<string>;
|
|
63
|
-
title: RawTransactionArgument<string>;
|
|
64
|
-
tracks: TransactionArgument;
|
|
65
|
-
nonce: RawTransactionArgument<number | bigint>;
|
|
66
|
-
}
|
|
67
|
-
export interface NewReleaseOptions {
|
|
68
|
-
package?: string;
|
|
69
|
-
arguments: NewReleaseArguments | [
|
|
70
|
-
self: RawTransactionArgument<string>,
|
|
71
|
-
title: RawTransactionArgument<string>,
|
|
72
|
-
tracks: TransactionArgument,
|
|
73
|
-
nonce: RawTransactionArgument<number | bigint>
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Assembles a release by delegating to `miso::release::new` with this registry as
|
|
78
|
-
* parent. Returns the `(Release, ReleaseAdminCap)` pair rather than transferring
|
|
79
|
-
* or sharing either: the release is not on-chain-final until `release::publish`
|
|
80
|
-
* consumes it by value — typically later in the same PTB — and where the cap ends
|
|
81
|
-
* up is the caller's decision, not this function's.
|
|
82
|
-
*/
|
|
83
|
-
export function newRelease(options: NewReleaseOptions) {
|
|
84
|
-
const packageAddress = options.package ?? '@local-pkg/release_registry';
|
|
85
|
-
const argumentsTypes = [
|
|
86
|
-
null,
|
|
87
|
-
'0x1::string::String',
|
|
88
|
-
'vector<null>',
|
|
89
|
-
'u256'
|
|
90
|
-
] satisfies (string | null)[];
|
|
91
|
-
const parameterNames = ["self", "title", "tracks", "nonce"];
|
|
92
|
-
return (tx: Transaction) => tx.moveCall({
|
|
93
|
-
package: packageAddress,
|
|
94
|
-
module: 'release_registry',
|
|
95
|
-
function: 'new_release',
|
|
96
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
export interface DeriveTargetReleaseIdArguments {
|
|
100
|
-
self: RawTransactionArgument<string>;
|
|
101
|
-
recordingIds: RawTransactionArgument<Array<string>>;
|
|
102
|
-
trackSplitValues: RawTransactionArgument<Array<number | bigint>>;
|
|
103
|
-
nonce: RawTransactionArgument<number | bigint>;
|
|
104
|
-
}
|
|
105
|
-
export interface DeriveTargetReleaseIdOptions {
|
|
106
|
-
package?: string;
|
|
107
|
-
arguments: DeriveTargetReleaseIdArguments | [
|
|
108
|
-
self: RawTransactionArgument<string>,
|
|
109
|
-
recordingIds: RawTransactionArgument<Array<string>>,
|
|
110
|
-
trackSplitValues: RawTransactionArgument<Array<number | bigint>>,
|
|
111
|
-
nonce: RawTransactionArgument<number | bigint>
|
|
112
|
-
];
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Derives the release id `new_release` would produce for the given inputs under
|
|
116
|
-
* this registry, without creating anything. Delegates to
|
|
117
|
-
* `miso::release::derive_target_release_id` with this registry's own id as parent.
|
|
118
|
-
*/
|
|
119
|
-
export function deriveTargetReleaseId(options: DeriveTargetReleaseIdOptions) {
|
|
120
|
-
const packageAddress = options.package ?? '@local-pkg/release_registry';
|
|
121
|
-
const argumentsTypes = [
|
|
122
|
-
null,
|
|
123
|
-
'vector<0x2::object::ID>',
|
|
124
|
-
'vector<u64>',
|
|
125
|
-
'u256'
|
|
126
|
-
] satisfies (string | null)[];
|
|
127
|
-
const parameterNames = ["self", "recordingIds", "trackSplitValues", "nonce"];
|
|
128
|
-
return (tx: Transaction) => tx.moveCall({
|
|
129
|
-
package: packageAddress,
|
|
130
|
-
module: 'release_registry',
|
|
131
|
-
function: 'derive_target_release_id',
|
|
132
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
export interface IdArguments {
|
|
136
|
-
self: RawTransactionArgument<string>;
|
|
137
|
-
}
|
|
138
|
-
export interface IdOptions {
|
|
139
|
-
package?: string;
|
|
140
|
-
arguments: IdArguments | [
|
|
141
|
-
self: RawTransactionArgument<string>
|
|
142
|
-
];
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Returns the registry's object id — the derivation parent that
|
|
146
|
-
* `derive_target_release_id` and `new_release` both commit to.
|
|
147
|
-
*/
|
|
148
|
-
export function id(options: IdOptions) {
|
|
149
|
-
const packageAddress = options.package ?? '@local-pkg/release_registry';
|
|
150
|
-
const argumentsTypes = [
|
|
151
|
-
null
|
|
152
|
-
] satisfies (string | null)[];
|
|
153
|
-
const parameterNames = ["self"];
|
|
154
|
-
return (tx: Transaction) => tx.moveCall({
|
|
155
|
-
package: packageAddress,
|
|
156
|
-
module: 'release_registry',
|
|
157
|
-
function: 'id',
|
|
158
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
159
|
-
});
|
|
160
|
-
}
|
package/src/drop.ts
DELETED
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Miso Labs, Inc.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
// Drop — the record sale. A `Drop<Currency>` is a shared, immutable object that sells
|
|
5
|
-
// copies of a Release's records at a fixed or floor price, optionally capped
|
|
6
|
-
// (`maxSupply`) and/or time-boxed. A release has at most ONE live drop: `createDrop`
|
|
7
|
-
// opens edition 0, and `newEdition` opens edition n+1 by consuming the predecessor —
|
|
8
|
-
// the one way to change price, currency, cap, or window. The registry tracks each
|
|
9
|
-
// release's live drop (`getCurrentDrop`).
|
|
10
|
-
|
|
11
|
-
import type { ClientWithCoreApi } from "@mysten/sui/client";
|
|
12
|
-
import { deriveDynamicFieldID } from "@mysten/sui/utils";
|
|
13
|
-
import { bcs } from "@mysten/sui/bcs";
|
|
14
|
-
import type { TxThunk } from "./transactions.ts";
|
|
15
|
-
import * as drop from "./contracts/miso_drop/drop.ts";
|
|
16
|
-
|
|
17
|
-
/** Pricing policy: pay exactly `amount` (fixed) or at least `amount` (floor). */
|
|
18
|
-
export type DropPrice = {
|
|
19
|
-
kind: "fixed" | "floor";
|
|
20
|
-
amount: bigint | number | string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export interface CreateDropParams {
|
|
24
|
-
/** The `Release` object the drop sells copies of — also the drop's derivation
|
|
25
|
-
* parent and the home of the live-drop pointer. */
|
|
26
|
-
releaseId: string;
|
|
27
|
-
/** The release's `ReleaseAdminCap` — authorizes the drop. */
|
|
28
|
-
releaseAdminCapId: string;
|
|
29
|
-
/** Fixed or floor price, in the currency's smallest unit. */
|
|
30
|
-
price: DropPrice;
|
|
31
|
-
/** The `Currency` type argument, e.g. `0x2::sui::SUI`. */
|
|
32
|
-
currencyType: string;
|
|
33
|
-
/** Copies this edition may ever sell; `null`/omitted = uncapped (an open edition). */
|
|
34
|
-
maxSupply?: bigint | number | null;
|
|
35
|
-
/** Unix ms the sale opens. Default 0 (open immediately). */
|
|
36
|
-
startTimestampMs?: bigint | number;
|
|
37
|
-
/** Unix ms the sale closes; `null`/omitted = evergreen. */
|
|
38
|
-
endTimestampMs?: bigint | number | null;
|
|
39
|
-
misoDropPackageId: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Creates and shares a release's FIRST drop — edition 0. A release's edition
|
|
44
|
-
* sequence can only ever start once; later terms changes go through `newEdition`.
|
|
45
|
-
* The `Clock` is auto-supplied by the generated binding.
|
|
46
|
-
*/
|
|
47
|
-
export function createDrop(p: CreateDropParams): TxThunk {
|
|
48
|
-
return (tx) => {
|
|
49
|
-
const terms = buildTerms(tx, p);
|
|
50
|
-
tx.add(
|
|
51
|
-
drop._new({
|
|
52
|
-
package: p.misoDropPackageId,
|
|
53
|
-
arguments: [
|
|
54
|
-
p.releaseId,
|
|
55
|
-
p.releaseAdminCapId,
|
|
56
|
-
terms.price,
|
|
57
|
-
terms.supply,
|
|
58
|
-
terms.window,
|
|
59
|
-
],
|
|
60
|
-
typeArguments: [p.currencyType],
|
|
61
|
-
}),
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface NewEditionParams {
|
|
67
|
-
/** The `Release` whose drop is being superseded. */
|
|
68
|
-
releaseId: string;
|
|
69
|
-
/** The release's CURRENT drop — consumed (destroyed) by this call. */
|
|
70
|
-
oldDropId: string;
|
|
71
|
-
/** The current drop's `Currency` type. */
|
|
72
|
-
oldCurrencyType: string;
|
|
73
|
-
/** The release's `ReleaseAdminCap`. */
|
|
74
|
-
releaseAdminCapId: string;
|
|
75
|
-
/** The successor's price. */
|
|
76
|
-
price: DropPrice;
|
|
77
|
-
/** The successor's `Currency` type (may differ from the old one). */
|
|
78
|
-
currencyType: string;
|
|
79
|
-
/** Successor's supply cap; `null`/omitted = uncapped. */
|
|
80
|
-
maxSupply?: bigint | number | null;
|
|
81
|
-
/** Unix ms the successor opens. Default 0 (open immediately). */
|
|
82
|
-
startTimestampMs?: bigint | number;
|
|
83
|
-
/** Unix ms the successor closes; `null`/omitted = evergreen. */
|
|
84
|
-
endTimestampMs?: bigint | number | null;
|
|
85
|
-
misoDropPackageId: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Opens edition n+1 of a release's drop, CONSUMING the current one — the one way to
|
|
90
|
-
* change price, currency, cap, or window (or start a fresh run after a sell-out).
|
|
91
|
-
* Serial numbers restart at 1 for the new edition. The `Clock` is auto-supplied.
|
|
92
|
-
*/
|
|
93
|
-
export function newEdition(p: NewEditionParams): TxThunk {
|
|
94
|
-
return (tx) => {
|
|
95
|
-
const terms = buildTerms(tx, p);
|
|
96
|
-
tx.add(
|
|
97
|
-
drop.newEdition({
|
|
98
|
-
package: p.misoDropPackageId,
|
|
99
|
-
arguments: [
|
|
100
|
-
p.releaseId,
|
|
101
|
-
p.oldDropId,
|
|
102
|
-
p.releaseAdminCapId,
|
|
103
|
-
terms.price,
|
|
104
|
-
terms.supply,
|
|
105
|
-
terms.window,
|
|
106
|
-
],
|
|
107
|
-
typeArguments: [p.oldCurrencyType, p.currencyType],
|
|
108
|
-
}),
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** Builds the three on-chain term values (`Price`, `Supply`, `Window`) from the flat
|
|
114
|
-
* facade params — the flat shape stays the public API; the enums are a wire detail. */
|
|
115
|
-
function buildTerms(
|
|
116
|
-
tx: Parameters<TxThunk>[0],
|
|
117
|
-
p: Pick<
|
|
118
|
-
CreateDropParams,
|
|
119
|
-
| "price"
|
|
120
|
-
| "maxSupply"
|
|
121
|
-
| "startTimestampMs"
|
|
122
|
-
| "endTimestampMs"
|
|
123
|
-
| "misoDropPackageId"
|
|
124
|
-
>,
|
|
125
|
-
) {
|
|
126
|
-
const pkg = { package: p.misoDropPackageId };
|
|
127
|
-
const makePrice =
|
|
128
|
-
p.price.kind === "fixed" ? drop.newFixedPrice : drop.newFloorPrice;
|
|
129
|
-
const price = tx.add(
|
|
130
|
-
makePrice({ ...pkg, arguments: [BigInt(p.price.amount)] }),
|
|
131
|
-
);
|
|
132
|
-
const supply =
|
|
133
|
-
p.maxSupply == null
|
|
134
|
-
? tx.add(drop.newUncappedSupply({ ...pkg, arguments: [] }))
|
|
135
|
-
: tx.add(
|
|
136
|
-
drop.newCappedSupply({ ...pkg, arguments: [BigInt(p.maxSupply)] }),
|
|
137
|
-
);
|
|
138
|
-
const start = BigInt(p.startTimestampMs ?? 0);
|
|
139
|
-
const window =
|
|
140
|
-
p.endTimestampMs == null
|
|
141
|
-
? tx.add(drop.newUnboundedWindow({ ...pkg, arguments: [start] }))
|
|
142
|
-
: tx.add(
|
|
143
|
-
drop.newBoundedWindow({
|
|
144
|
-
...pkg,
|
|
145
|
-
arguments: [start, BigInt(p.endTimestampMs)],
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
return { price, supply, window };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface BuyRecordParams {
|
|
152
|
-
/** The shared `Drop<Currency>` to buy from. */
|
|
153
|
-
dropId: string;
|
|
154
|
-
/** Buyer's `Coin<Currency>` object ids to pay from — merged, then split to `amount`. */
|
|
155
|
-
paymentCoinIds: string[];
|
|
156
|
-
/** Amount to pay in the currency's smallest unit (exact for `fixed`, ≥ for `floor`). */
|
|
157
|
-
amount: bigint | number | string;
|
|
158
|
-
/** The drop's `Currency` type, e.g. `0x2::sui::SUI`. */
|
|
159
|
-
currencyType: string;
|
|
160
|
-
/** The `miso_record` `Settings` shared object (authorizes the mint). */
|
|
161
|
-
settingsId: string;
|
|
162
|
-
/** Where to send the bought `Record` (usually the buyer). */
|
|
163
|
-
recipient: string;
|
|
164
|
-
misoDropPackageId: string;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Buys one record from a drop: merges the buyer's payment coins, splits the exact
|
|
169
|
-
* price, calls `buy`, and sends the minted `Record` to `recipient`. The buyer selects
|
|
170
|
-
* which of their coins to spend (see the app's coin selection); this builder only
|
|
171
|
-
* assembles the PTB. The `Clock` is auto-supplied.
|
|
172
|
-
*/
|
|
173
|
-
export function buyRecord(p: BuyRecordParams): TxThunk {
|
|
174
|
-
return (tx) => {
|
|
175
|
-
const [first, ...rest] = p.paymentCoinIds;
|
|
176
|
-
if (!first) throw new Error("buyRecord: no payment coins provided");
|
|
177
|
-
const primary = tx.object(first);
|
|
178
|
-
if (rest.length > 0)
|
|
179
|
-
tx.mergeCoins(
|
|
180
|
-
primary,
|
|
181
|
-
rest.map((id) => tx.object(id)),
|
|
182
|
-
);
|
|
183
|
-
const [payment] = tx.splitCoins(primary, [tx.pure.u64(BigInt(p.amount))]);
|
|
184
|
-
const record = tx.add(
|
|
185
|
-
drop.buy({
|
|
186
|
-
package: p.misoDropPackageId,
|
|
187
|
-
arguments: [p.dropId, payment, p.settingsId],
|
|
188
|
-
typeArguments: [p.currencyType],
|
|
189
|
-
}),
|
|
190
|
-
);
|
|
191
|
-
tx.transferObjects([record], p.recipient);
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/** A parsed drop, in the shape the featured-drop card renders. */
|
|
196
|
-
export interface DropView {
|
|
197
|
-
id: string;
|
|
198
|
-
releaseId: string;
|
|
199
|
-
edition: number;
|
|
200
|
-
price: { kind: "fixed" | "floor"; amount: bigint };
|
|
201
|
-
/** `null` = uncapped (an open edition). */
|
|
202
|
-
maxSupply: bigint | null;
|
|
203
|
-
quantitySold: bigint;
|
|
204
|
-
startTimestampMs: bigint;
|
|
205
|
-
/** `null` = evergreen. */
|
|
206
|
-
endTimestampMs: bigint | null;
|
|
207
|
-
/** The drop's `Currency` type, parsed from its object type tag (`null` if unavailable). */
|
|
208
|
-
currencyType: string | null;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** Extracts `CURRENCY` from a `…::drop::Drop<CURRENCY>` type tag. */
|
|
212
|
-
function currencyFromType(type: string | null | undefined): string | null {
|
|
213
|
-
if (!type) return null;
|
|
214
|
-
const lt = type.indexOf("<");
|
|
215
|
-
return lt >= 0 && type.endsWith(">") ? type.slice(lt + 1, -1) : null;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Fetches and parses a shared `Drop` object, or `null` if it doesn't exist.
|
|
220
|
-
*
|
|
221
|
-
* NOTE: this deliberately deviates from the core-getter convention in
|
|
222
|
-
* `./queries.ts` (throw on missing object). Consumers probe pasted or stored
|
|
223
|
-
* drop ids — a party's featured drop, a superseded edition — where "no such
|
|
224
|
-
* drop" is a normal state, so absence is `null` and only transport failures throw.
|
|
225
|
-
*/
|
|
226
|
-
export async function getDrop(
|
|
227
|
-
client: ClientWithCoreApi,
|
|
228
|
-
dropId: string,
|
|
229
|
-
): Promise<DropView | null> {
|
|
230
|
-
return (await getDropsByIds(client, [dropId]))[dropId] ?? null;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function parseDrop(
|
|
234
|
-
dropId: string,
|
|
235
|
-
content: Uint8Array,
|
|
236
|
-
type?: string,
|
|
237
|
-
): DropView {
|
|
238
|
-
const d = drop.Drop.parse(content);
|
|
239
|
-
const price = d.price as {
|
|
240
|
-
$kind?: string;
|
|
241
|
-
Fixed?: { amount: string };
|
|
242
|
-
Floor?: { amount: string };
|
|
243
|
-
};
|
|
244
|
-
const isFixed = price.$kind === "Fixed" || price.Fixed != null;
|
|
245
|
-
const amount = (isFixed ? price.Fixed?.amount : price.Floor?.amount) ?? "0";
|
|
246
|
-
const supply = d.supply as { $kind?: string; Capped?: { max: string } };
|
|
247
|
-
const capped = supply.$kind === "Capped" || supply.Capped != null;
|
|
248
|
-
const window = d.window as {
|
|
249
|
-
$kind?: string;
|
|
250
|
-
Unbounded?: { start_timestamp_ms: string };
|
|
251
|
-
Bounded?: { start_timestamp_ms: string; end_timestamp_ms: string };
|
|
252
|
-
};
|
|
253
|
-
const bounded = window.$kind === "Bounded" || window.Bounded != null;
|
|
254
|
-
|
|
255
|
-
return {
|
|
256
|
-
id: dropId,
|
|
257
|
-
releaseId: d.release_id,
|
|
258
|
-
edition: d.edition,
|
|
259
|
-
price: { kind: isFixed ? "fixed" : "floor", amount: BigInt(amount) },
|
|
260
|
-
maxSupply: capped ? BigInt(supply.Capped?.max ?? "0") : null,
|
|
261
|
-
quantitySold: BigInt(d.quantity_sold),
|
|
262
|
-
startTimestampMs: BigInt(
|
|
263
|
-
(bounded
|
|
264
|
-
? window.Bounded?.start_timestamp_ms
|
|
265
|
-
: window.Unbounded?.start_timestamp_ms) ?? "0",
|
|
266
|
-
),
|
|
267
|
-
endTimestampMs: bounded
|
|
268
|
-
? BigInt(window.Bounded?.end_timestamp_ms ?? "0")
|
|
269
|
-
: null,
|
|
270
|
-
currencyType: currencyFromType(type),
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/** Fetch and parse many Drop objects through one Core bulk request. */
|
|
275
|
-
export async function getDropsByIds(
|
|
276
|
-
client: ClientWithCoreApi,
|
|
277
|
-
dropIdsInput: readonly string[],
|
|
278
|
-
): Promise<Partial<Record<string, DropView>>> {
|
|
279
|
-
const dropIds = [...new Set(dropIdsInput)];
|
|
280
|
-
if (dropIds.length === 0) return {};
|
|
281
|
-
const { objects } = await client.core.getObjects({
|
|
282
|
-
objectIds: dropIds,
|
|
283
|
-
include: { content: true },
|
|
284
|
-
});
|
|
285
|
-
const out: Partial<Record<string, DropView>> = {};
|
|
286
|
-
objects.forEach((object, index) => {
|
|
287
|
-
const dropId = dropIds[index];
|
|
288
|
-
if (
|
|
289
|
-
!dropId ||
|
|
290
|
-
object instanceof Error ||
|
|
291
|
-
!object.content ||
|
|
292
|
-
!/::drop::Drop</.test(object.type ?? "")
|
|
293
|
-
) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
out[dropId] = parseDrop(dropId, object.content, object.type);
|
|
297
|
-
});
|
|
298
|
-
return out;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// The release's `CurrentDropKey` dynamic field holds a bare `ID`; the field object
|
|
302
|
-
// serializes as `Field { id, name: CurrentDropKey (unit), value: ID }`.
|
|
303
|
-
const CurrentDropField = bcs.struct("Field", {
|
|
304
|
-
id: bcs.Address,
|
|
305
|
-
name: bcs.bool(),
|
|
306
|
-
value: bcs.Address,
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
// Unit-struct key bytes (single `0x00` for the dummy bool field).
|
|
310
|
-
const CURRENT_DROP_KEY_BYTES = drop.CurrentDropKey.serialize([false]).toBytes();
|
|
311
|
-
|
|
312
|
-
export interface GetCurrentDropParams {
|
|
313
|
-
/** The release whose live drop to resolve. */
|
|
314
|
-
releaseId: string;
|
|
315
|
-
misoDropPackageId: string;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Resolves a release's LIVE drop through the `CurrentDropKey` pointer on the
|
|
320
|
-
* release's UID, or `null` if the release has never dropped. Superseded drops are
|
|
321
|
-
* destroyed, so this — not derived-address probing — is how the current edition is
|
|
322
|
-
* found.
|
|
323
|
-
*/
|
|
324
|
-
export async function getCurrentDrop(
|
|
325
|
-
client: ClientWithCoreApi,
|
|
326
|
-
p: GetCurrentDropParams,
|
|
327
|
-
): Promise<DropView | null> {
|
|
328
|
-
return (
|
|
329
|
-
(await getCurrentDrops(client, [p.releaseId], p.misoDropPackageId))[
|
|
330
|
-
p.releaseId
|
|
331
|
-
] ?? null
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Resolve the live drops for many releases in two Core bulk requests: all
|
|
337
|
-
* CurrentDrop pointer fields, then all pointed-to Drop objects.
|
|
338
|
-
*/
|
|
339
|
-
export async function getCurrentDrops(
|
|
340
|
-
client: ClientWithCoreApi,
|
|
341
|
-
releaseIdsInput: readonly string[],
|
|
342
|
-
misoDropPackageId: string,
|
|
343
|
-
): Promise<Partial<Record<string, DropView>>> {
|
|
344
|
-
const releaseIds = [...new Set(releaseIdsInput)];
|
|
345
|
-
if (releaseIds.length === 0) return {};
|
|
346
|
-
const fieldIds = releaseIds.map((releaseId) =>
|
|
347
|
-
deriveDynamicFieldID(
|
|
348
|
-
releaseId,
|
|
349
|
-
`${misoDropPackageId}::drop::CurrentDropKey`,
|
|
350
|
-
CURRENT_DROP_KEY_BYTES,
|
|
351
|
-
),
|
|
352
|
-
);
|
|
353
|
-
const { objects } = await client.core.getObjects({
|
|
354
|
-
objectIds: fieldIds,
|
|
355
|
-
include: { content: true },
|
|
356
|
-
});
|
|
357
|
-
const dropIdByRelease: Partial<Record<string, string>> = {};
|
|
358
|
-
objects.forEach((object, index) => {
|
|
359
|
-
const releaseId = releaseIds[index];
|
|
360
|
-
if (!releaseId || object instanceof Error || !object.content) return;
|
|
361
|
-
dropIdByRelease[releaseId] = CurrentDropField.parse(object.content).value;
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
const drops = await getDropsByIds(
|
|
365
|
-
client,
|
|
366
|
-
Object.values(dropIdByRelease).filter(
|
|
367
|
-
(id): id is string => id !== undefined,
|
|
368
|
-
),
|
|
369
|
-
);
|
|
370
|
-
const out: Partial<Record<string, DropView>> = {};
|
|
371
|
-
for (const [releaseId, dropId] of Object.entries(dropIdByRelease)) {
|
|
372
|
-
const dropView = dropId ? drops[dropId] : undefined;
|
|
373
|
-
if (dropView) out[releaseId] = dropView;
|
|
374
|
-
}
|
|
375
|
-
return out;
|
|
376
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Miso Labs, Inc.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
// First-party royalty-pool extension.
|
|
5
|
-
//
|
|
6
|
-
// A RoyaltyPool<Share, Currency> is an accumulator-based royalty-distribution pool
|
|
7
|
-
// bound to a composition or recording. It is created via the work's admin-gated
|
|
8
|
-
// `uid_mut(&AdminCap)` derived-object hook (`initialize_pool`), then shared
|
|
9
|
-
// (`pool::share`). Because `initialize_pool` borrows the work `&mut` (and the cap
|
|
10
|
-
// `&`) — not a shared on-chain input — it composes INSIDE the work's publish PTB:
|
|
11
|
-
// run it after `createComposition`/`createRecording` and before `finalize*` (which
|
|
12
|
-
// consumes the work into `share_object` and transfers the cap to the owner).
|
|
13
|
-
//
|
|
14
|
-
// Scope here is create + share only. Stake registration, funding (receive/redeem/
|
|
15
|
-
// deposit), and claiming are later owner/holder actions, not part of publishing.
|
|
16
|
-
//
|
|
17
|
-
// The work being extended (`composition`/`recording`) is a protocol object built
|
|
18
|
-
// by `@misonetwork/sdk`'s `createComposition`/`createRecording`; only the pool
|
|
19
|
-
// hung off it is ours. That is the whole reason this module lives on the platform
|
|
20
|
-
// side of the split — the protocol defines the `uid_mut` hook, not what to attach.
|
|
21
|
-
|
|
22
|
-
import type { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
23
|
-
import * as compositionRoyaltyPool from "../contracts/composition_royalty_pool/composition_royalty_pool.ts";
|
|
24
|
-
import * as recordingRoyaltyPool from "../contracts/recording_royalty_pool/recording_royalty_pool.ts";
|
|
25
|
-
import * as pool from "../contracts/royalty_pool/pool.ts";
|
|
26
|
-
|
|
27
|
-
export interface AttachCompositionRoyaltyPoolParams {
|
|
28
|
-
/** The Composition — an in-PTB `createComposition` result, borrowed `&mut`. */
|
|
29
|
-
composition: TransactionObjectArgument;
|
|
30
|
-
/** The CompositionAdminCap, borrowed `&`. */
|
|
31
|
-
adminCap: TransactionObjectArgument;
|
|
32
|
-
/** The composition's share type (the pool's `Share` phantom = CompositionShare). */
|
|
33
|
-
compositionShareType: string;
|
|
34
|
-
/** Fully-qualified coin type the pool accumulates (the `Currency` phantom). */
|
|
35
|
-
currency: string;
|
|
36
|
-
compositionRoyaltyPoolPackageId: string;
|
|
37
|
-
royaltyPoolPackageId: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Creates a royalty pool for a composition and shares it, appending to `tx`. */
|
|
41
|
-
export function attachCompositionRoyaltyPool(tx: Transaction, params: AttachCompositionRoyaltyPoolParams): void {
|
|
42
|
-
const created = tx.add(
|
|
43
|
-
compositionRoyaltyPool.initializePool({
|
|
44
|
-
package: params.compositionRoyaltyPoolPackageId,
|
|
45
|
-
typeArguments: [params.compositionShareType, params.currency],
|
|
46
|
-
arguments: [params.composition, params.adminCap],
|
|
47
|
-
}),
|
|
48
|
-
);
|
|
49
|
-
tx.add(
|
|
50
|
-
pool.share({
|
|
51
|
-
package: params.royaltyPoolPackageId,
|
|
52
|
-
typeArguments: [params.compositionShareType, params.currency],
|
|
53
|
-
arguments: [created],
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface AttachRecordingRoyaltyPoolParams {
|
|
59
|
-
/** The Recording — an in-PTB `createRecording` result, borrowed `&mut`. */
|
|
60
|
-
recording: TransactionObjectArgument;
|
|
61
|
-
/** The RecordingAdminCap, borrowed `&`. */
|
|
62
|
-
adminCap: TransactionObjectArgument;
|
|
63
|
-
/** The recording's own share type (the pool's `Share` phantom = RecordingShare). */
|
|
64
|
-
recordingShareType: string;
|
|
65
|
-
/** The parent composition's share type (the recording's `CompositionShare` phantom). */
|
|
66
|
-
compositionShareType: string;
|
|
67
|
-
/** Fully-qualified coin type the pool accumulates (the `Currency` phantom). */
|
|
68
|
-
currency: string;
|
|
69
|
-
recordingRoyaltyPoolPackageId: string;
|
|
70
|
-
royaltyPoolPackageId: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Creates a royalty pool for a recording and shares it, appending to `tx`. */
|
|
74
|
-
export function attachRecordingRoyaltyPool(tx: Transaction, params: AttachRecordingRoyaltyPoolParams): void {
|
|
75
|
-
const created = tx.add(
|
|
76
|
-
recordingRoyaltyPool.initializePool({
|
|
77
|
-
package: params.recordingRoyaltyPoolPackageId,
|
|
78
|
-
typeArguments: [params.recordingShareType, params.compositionShareType, params.currency],
|
|
79
|
-
arguments: [params.recording, params.adminCap],
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
82
|
-
// The pool is RoyaltyPool<RecordingShare, Currency> — Share is the recording's own share type.
|
|
83
|
-
tx.add(
|
|
84
|
-
pool.share({
|
|
85
|
-
package: params.royaltyPoolPackageId,
|
|
86
|
-
typeArguments: [params.recordingShareType, params.currency],
|
|
87
|
-
arguments: [created],
|
|
88
|
-
}),
|
|
89
|
-
);
|
|
90
|
-
}
|