@misofm/sdk 0.9.0 → 0.10.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 +126 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +210 -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/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/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 +14 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +16 -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 +31 -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 +92 -0
- package/dist/release-extensions.d.ts.map +1 -0
- package/dist/release-extensions.js +175 -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 +428 -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/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/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 +17 -9
- package/src/cover.ts +62 -37
- package/src/credits.ts +64 -51
- package/src/deployments.ts +36 -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 +286 -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
package/dist/vault.d.ts
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability custody and vault-plugin transaction builders.
|
|
3
|
+
*
|
|
4
|
+
* A direct admin cap remains supported for existing works. New work should give
|
|
5
|
+
* the owner a `VaultAdminCap<AdminCap>` and keep the raw admin cap inside the
|
|
6
|
+
* shared Vault. Every authorized call borrows and returns the raw cap inside
|
|
7
|
+
* one helper; borrowed capabilities are never exposed to application code.
|
|
8
|
+
*/
|
|
9
|
+
import type { BcsType } from "@mysten/sui/bcs";
|
|
10
|
+
import type { ClientWithCoreApi } from "@mysten/sui/client";
|
|
11
|
+
import type { Transaction, TransactionArgument, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
12
|
+
/** A legacy work whose raw protocol admin cap is still address-owned. */
|
|
13
|
+
/** An object id resolved lazily when a transaction thunk is applied. */
|
|
14
|
+
export type ObjectInput = string | TransactionObjectArgument;
|
|
15
|
+
export interface DirectAdminCapAuthority {
|
|
16
|
+
readonly kind: "direct";
|
|
17
|
+
readonly adminCap: ObjectInput;
|
|
18
|
+
}
|
|
19
|
+
/** A work whose protocol admin cap is custodied by a shared Vault. */
|
|
20
|
+
export interface VaultAdminCapAuthority {
|
|
21
|
+
readonly kind: "vault";
|
|
22
|
+
readonly vault: ObjectInput;
|
|
23
|
+
readonly vaultAdminCap: ObjectInput;
|
|
24
|
+
/** Fully-qualified protocol cap type, e.g. `0x…::release::ReleaseAdminCap`. */
|
|
25
|
+
readonly capType: string;
|
|
26
|
+
readonly vaultPackageId: string;
|
|
27
|
+
}
|
|
28
|
+
/** Explicit compatibility boundary for protocol mutations. */
|
|
29
|
+
export type AdminCapAuthority = DirectAdminCapAuthority | VaultAdminCapAuthority;
|
|
30
|
+
export declare function directAdminCap(adminCap: ObjectInput): DirectAdminCapAuthority;
|
|
31
|
+
export declare function vaultAdminCap(authority: Omit<VaultAdminCapAuthority, "kind">): VaultAdminCapAuthority;
|
|
32
|
+
/**
|
|
33
|
+
* Lend an authority's raw protocol cap to `use` for the scope of this PTB.
|
|
34
|
+
*
|
|
35
|
+
* The vault branch deliberately encloses `use` between `borrow_as_admin` and
|
|
36
|
+
* `put_back`; callers cannot accidentally leave a non-drop `Borrow` receipt in
|
|
37
|
+
* the transaction. The direct branch preserves compatibility with pre-vault
|
|
38
|
+
* work without silently treating it as protected custody.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* A Move call whose argument list contains exactly one temporarily lent cap.
|
|
42
|
+
* No callback receives that cap, so it cannot escape past `put_back`.
|
|
43
|
+
*/
|
|
44
|
+
export interface AdminCapMoveCall {
|
|
45
|
+
readonly target: string;
|
|
46
|
+
readonly typeArguments?: string[];
|
|
47
|
+
readonly arguments: TransactionArgument[];
|
|
48
|
+
readonly adminCapIndex: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Invoke one cap-authorized Move call without exposing a borrowed cap to JS.
|
|
52
|
+
* The returned PTB result belongs to `call.target`, never to the Vault borrow.
|
|
53
|
+
*/
|
|
54
|
+
export declare function invokeWithAdminCap(tx: Transaction, authority: AdminCapAuthority, call: AdminCapMoveCall): TransactionObjectArgument;
|
|
55
|
+
export interface CustodyNewAdminCapParams {
|
|
56
|
+
/** The freshly-created raw protocol cap, consumed into the Vault. */
|
|
57
|
+
readonly adminCap: TransactionObjectArgument;
|
|
58
|
+
readonly capType: string;
|
|
59
|
+
readonly vaultPackageId: string;
|
|
60
|
+
/** Recipient of the only owner-held authority: VaultAdminCap. */
|
|
61
|
+
readonly owner: string | TransactionArgument;
|
|
62
|
+
/** Optional installation/configuration while the new Vault is still owned. */
|
|
63
|
+
readonly configure?: (vaultObject: TransactionArgument, vaultAdminCapObject: TransactionArgument) => void;
|
|
64
|
+
}
|
|
65
|
+
/** Where a newly-created raw protocol cap ends up after its work is published. */
|
|
66
|
+
export type AdminCapCustody = {
|
|
67
|
+
readonly kind: "direct";
|
|
68
|
+
readonly owner: string | TransactionArgument;
|
|
69
|
+
} | {
|
|
70
|
+
readonly kind: "vault";
|
|
71
|
+
readonly owner: string | TransactionArgument;
|
|
72
|
+
readonly capType: string;
|
|
73
|
+
readonly vaultPackageId: string;
|
|
74
|
+
readonly configure?: CustodyNewAdminCapParams["configure"];
|
|
75
|
+
};
|
|
76
|
+
/** Explicitly transfer a new cap or custody it before the PTB finishes. */
|
|
77
|
+
export declare function disposeNewAdminCap(tx: Transaction, adminCap: TransactionObjectArgument, custody: AdminCapCustody): void;
|
|
78
|
+
/** Destroy a vault only while deliberately disposing of its returned raw cap. */
|
|
79
|
+
export declare function destroyVault(tx: Transaction, params: {
|
|
80
|
+
readonly vault: ObjectInput;
|
|
81
|
+
readonly vaultAdminCap: ObjectInput;
|
|
82
|
+
readonly capType: string;
|
|
83
|
+
readonly vaultPackageId: string;
|
|
84
|
+
readonly disposition: AdminCapCustody;
|
|
85
|
+
}): void;
|
|
86
|
+
/**
|
|
87
|
+
* Custody a freshly-created raw admin cap, optionally install plugins, share the
|
|
88
|
+
* Vault, then transfer only the VaultAdminCap to its owner.
|
|
89
|
+
*/
|
|
90
|
+
export declare function custodyNewAdminCap(tx: Transaction, params: CustodyNewAdminCapParams): void;
|
|
91
|
+
export interface CompositionRoyaltyPoolPluginParams {
|
|
92
|
+
readonly vault: TransactionObjectArgument;
|
|
93
|
+
readonly vaultAdminCap: TransactionObjectArgument;
|
|
94
|
+
readonly compositionShareType: string;
|
|
95
|
+
readonly pluginPackageId: string;
|
|
96
|
+
}
|
|
97
|
+
/** Install the composition royalty-pool plugin; its witness stays internal. */
|
|
98
|
+
export declare function installCompositionRoyaltyPoolPlugin(tx: Transaction, params: CompositionRoyaltyPoolPluginParams): void;
|
|
99
|
+
export declare function uninstallCompositionRoyaltyPoolPlugin(tx: Transaction, params: CompositionRoyaltyPoolPluginParams): void;
|
|
100
|
+
export interface InitializeCompositionRoyaltyPoolParams extends CompositionRoyaltyPoolPluginParams {
|
|
101
|
+
readonly composition: TransactionObjectArgument;
|
|
102
|
+
readonly currencyType: string;
|
|
103
|
+
}
|
|
104
|
+
export declare function initializeCompositionRoyaltyPool(tx: Transaction, params: InitializeCompositionRoyaltyPoolParams): void;
|
|
105
|
+
export interface CompositionRoyaltyPoolCrankParams {
|
|
106
|
+
readonly vault: TransactionObjectArgument;
|
|
107
|
+
readonly composition: TransactionObjectArgument;
|
|
108
|
+
readonly pool: TransactionObjectArgument;
|
|
109
|
+
readonly compositionShareType: string;
|
|
110
|
+
readonly currencyType: string;
|
|
111
|
+
readonly pluginPackageId: string;
|
|
112
|
+
}
|
|
113
|
+
/** JSON-safe input for an on-chain u64. Numbers are rejected to prevent rounding. */
|
|
114
|
+
export type U64Input = bigint | string | number;
|
|
115
|
+
/** Validate an SDK scalar before serializing it as a Move u64. */
|
|
116
|
+
export declare function asU64(name: string, value: U64Input): bigint;
|
|
117
|
+
/** Permissionless crank: redeem address funds into the canonical pool. */
|
|
118
|
+
export declare function redeemCompositionRoyaltyPool(tx: Transaction, params: CompositionRoyaltyPoolCrankParams & {
|
|
119
|
+
readonly value: U64Input;
|
|
120
|
+
}): void;
|
|
121
|
+
/** Permissionless crank: receive selected Composition-owned coins into the pool. */
|
|
122
|
+
export declare function receiveCompositionRoyaltyPool(tx: Transaction, params: CompositionRoyaltyPoolCrankParams & {
|
|
123
|
+
readonly coins: readonly ReceivingObjectRef[];
|
|
124
|
+
}): void;
|
|
125
|
+
export interface RecordingRoyaltyPoolPluginParams {
|
|
126
|
+
readonly vault: TransactionObjectArgument;
|
|
127
|
+
readonly vaultAdminCap: TransactionObjectArgument;
|
|
128
|
+
readonly recordingShareType: string;
|
|
129
|
+
readonly compositionShareType: string;
|
|
130
|
+
readonly pluginPackageId: string;
|
|
131
|
+
}
|
|
132
|
+
export declare function installRecordingRoyaltyPoolPlugin(tx: Transaction, params: RecordingRoyaltyPoolPluginParams): void;
|
|
133
|
+
export declare function uninstallRecordingRoyaltyPoolPlugin(tx: Transaction, params: RecordingRoyaltyPoolPluginParams): void;
|
|
134
|
+
export interface InitializeRecordingRoyaltyPoolParams extends RecordingRoyaltyPoolPluginParams {
|
|
135
|
+
readonly recording: TransactionObjectArgument;
|
|
136
|
+
readonly currencyType: string;
|
|
137
|
+
}
|
|
138
|
+
export declare function initializeRecordingRoyaltyPool(tx: Transaction, params: InitializeRecordingRoyaltyPoolParams): void;
|
|
139
|
+
export interface RecordingRoyaltyPoolCrankParams {
|
|
140
|
+
readonly vault: TransactionObjectArgument;
|
|
141
|
+
readonly recording: TransactionObjectArgument;
|
|
142
|
+
readonly pool: TransactionObjectArgument;
|
|
143
|
+
readonly recordingShareType: string;
|
|
144
|
+
readonly compositionShareType: string;
|
|
145
|
+
readonly currencyType: string;
|
|
146
|
+
readonly pluginPackageId: string;
|
|
147
|
+
}
|
|
148
|
+
export declare function redeemRecordingRoyaltyPool(tx: Transaction, params: RecordingRoyaltyPoolCrankParams & {
|
|
149
|
+
readonly value: U64Input;
|
|
150
|
+
}): void;
|
|
151
|
+
/** Permissionless crank: receive selected Recording-owned coins into the pool. */
|
|
152
|
+
export declare function receiveRecordingRoyaltyPool(tx: Transaction, params: RecordingRoyaltyPoolCrankParams & {
|
|
153
|
+
readonly coins: readonly ReceivingObjectRef[];
|
|
154
|
+
}): void;
|
|
155
|
+
export interface ReleaseRevenueDistributorPluginParams {
|
|
156
|
+
readonly vault: TransactionObjectArgument;
|
|
157
|
+
readonly vaultAdminCap: TransactionObjectArgument;
|
|
158
|
+
readonly pluginPackageId: string;
|
|
159
|
+
}
|
|
160
|
+
export declare function installReleaseRevenueDistributorPlugin(tx: Transaction, params: ReleaseRevenueDistributorPluginParams): void;
|
|
161
|
+
export declare function uninstallReleaseRevenueDistributorPlugin(tx: Transaction, params: ReleaseRevenueDistributorPluginParams): void;
|
|
162
|
+
/** Permissionless crank: redeem release-held money and route it by track BPS. */
|
|
163
|
+
export declare function redeemAndDistributeReleaseRevenue(tx: Transaction, params: Omit<ReleaseRevenueDistributorPluginParams, "vaultAdminCap"> & {
|
|
164
|
+
readonly release: TransactionObjectArgument;
|
|
165
|
+
readonly currencyType: string;
|
|
166
|
+
readonly value: U64Input;
|
|
167
|
+
}): void;
|
|
168
|
+
/** Permissionless crank: receive release-owned coins and route them by track BPS. */
|
|
169
|
+
export declare function receiveAndDistributeReleaseRevenue(tx: Transaction, params: Omit<ReleaseRevenueDistributorPluginParams, "vaultAdminCap"> & {
|
|
170
|
+
readonly release: TransactionObjectArgument;
|
|
171
|
+
readonly currencyType: string;
|
|
172
|
+
readonly coins: readonly ReceivingObjectRef[];
|
|
173
|
+
}): void;
|
|
174
|
+
export interface CompositionRoutedStakePluginParams {
|
|
175
|
+
readonly vault: TransactionObjectArgument;
|
|
176
|
+
readonly vaultAdminCap: TransactionObjectArgument;
|
|
177
|
+
readonly compositionShareType: string;
|
|
178
|
+
readonly pluginPackageId: string;
|
|
179
|
+
}
|
|
180
|
+
export declare function installCompositionRoutedStakePlugin(tx: Transaction, params: CompositionRoutedStakePluginParams): void;
|
|
181
|
+
export declare function uninstallCompositionRoutedStakePlugin(tx: Transaction, params: CompositionRoutedStakePluginParams): void;
|
|
182
|
+
export interface CreateCompositionRoutedStakeParams extends CompositionRoutedStakePluginParams {
|
|
183
|
+
readonly recording: TransactionObjectArgument;
|
|
184
|
+
readonly composition: TransactionObjectArgument;
|
|
185
|
+
readonly recordingShareType: string;
|
|
186
|
+
readonly value: U64Input;
|
|
187
|
+
}
|
|
188
|
+
export declare function createCompositionRoutedStake(tx: Transaction, params: CreateCompositionRoutedStakeParams): void;
|
|
189
|
+
export interface ManageCompositionRoutedStakeParams extends CompositionRoutedStakePluginParams {
|
|
190
|
+
readonly composition: TransactionObjectArgument;
|
|
191
|
+
readonly recording: TransactionObjectArgument;
|
|
192
|
+
readonly routedStake: TransactionObjectArgument;
|
|
193
|
+
readonly royaltyPool: TransactionObjectArgument;
|
|
194
|
+
readonly recordingShareType: string;
|
|
195
|
+
readonly currencyType: string;
|
|
196
|
+
}
|
|
197
|
+
/** Register the routed stake with the matching Recording royalty pool. */
|
|
198
|
+
export declare function registerCompositionRoutedStake(tx: Transaction, params: ManageCompositionRoutedStakeParams): void;
|
|
199
|
+
/** Unregister a routed stake after pending rewards have been swept. */
|
|
200
|
+
export declare function unregisterCompositionRoutedStake(tx: Transaction, params: Omit<ManageCompositionRoutedStakeParams, "recording">): void;
|
|
201
|
+
/** Return routed principal to the Composition address, never to the caller. */
|
|
202
|
+
export declare function unstakeCompositionRoutedStake(tx: Transaction, params: Omit<ManageCompositionRoutedStakeParams, "recording" | "royaltyPool" | "currencyType">): void;
|
|
203
|
+
/** Refill an empty routed stake from Recording shares held by the Composition. */
|
|
204
|
+
export declare function restakeCompositionRoutedStake(tx: Transaction, params: Omit<ManageCompositionRoutedStakeParams, "recording" | "royaltyPool" | "currencyType"> & {
|
|
205
|
+
readonly value: U64Input;
|
|
206
|
+
}): void;
|
|
207
|
+
/** Permissionlessly sweep a routed stake's accrued rewards into its parent pool. */
|
|
208
|
+
export declare function sweepRoutedStake(tx: Transaction, params: {
|
|
209
|
+
readonly routedStake: ObjectInput;
|
|
210
|
+
/** The pool where the wrapped stake accrues rewards. */
|
|
211
|
+
readonly stakePool: ObjectInput;
|
|
212
|
+
readonly parentId: string;
|
|
213
|
+
readonly royaltyPool: ObjectInput;
|
|
214
|
+
readonly routedStakePackageId: string;
|
|
215
|
+
readonly stakeShareType: string;
|
|
216
|
+
readonly poolShareType: string;
|
|
217
|
+
readonly currencyType: string;
|
|
218
|
+
}): void;
|
|
219
|
+
/** Parse a VaultAdminCap whose phantom capability does not affect BCS layout. */
|
|
220
|
+
export declare function parseVaultAdminCap(content: Uint8Array): {
|
|
221
|
+
id: string;
|
|
222
|
+
vault_id: string;
|
|
223
|
+
};
|
|
224
|
+
/** Parse lifecycle events whose phantom type parameters do not affect BCS. */
|
|
225
|
+
export declare function parseVaultCreatedEvent(content: Uint8Array): {
|
|
226
|
+
vault_id: string;
|
|
227
|
+
vault_admin_cap_id: string;
|
|
228
|
+
wrapped_cap_id: string;
|
|
229
|
+
authorized_plugins_id: string;
|
|
230
|
+
};
|
|
231
|
+
/** Parse the release-distribution summary event into JSON-safe quantities. */
|
|
232
|
+
export declare function parseReleaseRevenueDistributedEvent(content: Uint8Array): {
|
|
233
|
+
releaseId: string;
|
|
234
|
+
totalInput: string;
|
|
235
|
+
totalDistributed: string;
|
|
236
|
+
remainder: string;
|
|
237
|
+
};
|
|
238
|
+
/** Parse one per-track routing event, retaining its u64 values as strings. */
|
|
239
|
+
export declare function parseReleaseTrackRevenueDistributedEvent(content: Uint8Array): {
|
|
240
|
+
releaseId: string;
|
|
241
|
+
trackIndex: string;
|
|
242
|
+
recordingId: string;
|
|
243
|
+
amount: string;
|
|
244
|
+
};
|
|
245
|
+
/** Read and BCS-parse an owner-held VaultAdminCap. */
|
|
246
|
+
export declare function getVaultAdminCap(client: ClientWithCoreApi, vaultAdminCapId: string, expected: {
|
|
247
|
+
readonly vaultPackageId: string;
|
|
248
|
+
readonly capType: string;
|
|
249
|
+
}): Promise<{
|
|
250
|
+
id: string;
|
|
251
|
+
vault_id: string;
|
|
252
|
+
} | null>;
|
|
253
|
+
/**
|
|
254
|
+
* Build a `vector<Receiving<Coin<Currency>>>` for receive-and-* plugin calls.
|
|
255
|
+
* The caller supplies only object ids; recipient/ownership checks still happen
|
|
256
|
+
* on chain when `hikida::receive_balance` opens each receiving object.
|
|
257
|
+
*/
|
|
258
|
+
export interface ReceivingObjectRef {
|
|
259
|
+
readonly objectId: string;
|
|
260
|
+
readonly version: string | number;
|
|
261
|
+
readonly digest: string;
|
|
262
|
+
}
|
|
263
|
+
/** Resolve owned coins to the exact references required by a Receiving input. */
|
|
264
|
+
export declare function resolveReceivingCoins(client: ClientWithCoreApi, coinIds: readonly string[]): Promise<ReceivingObjectRef[]>;
|
|
265
|
+
export declare function receivingCoins(tx: Transaction, currencyType: string, coins: readonly ReceivingObjectRef[]): TransactionArgument;
|
|
266
|
+
/** Type-only helper for consumers that supply a generated admin-cap BCS type. */
|
|
267
|
+
export type VaultCapBcs<Cap extends BcsType<unknown>> = Cap;
|
|
268
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AASlC,yEAAyE;AACzE,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,yBAAyB,CAAC;AAM7D,MAAM,WAAW,uBAAuB;IACt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C,cAAc,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE;;;UAgBxE;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,iFAAiF;AACjF,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAQ/B;AAED,wBAAgB,cAAc,CAC5B,EAAE,EAAE,WAAW,EACf,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,SAAS,kBAAkB,EAAE,GACnC,mBAAmB,CAKrB;AAED,iFAAiF;AACjF,MAAM,MAAM,WAAW,CAAC,GAAG,SAAS,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC"}
|
package/dist/vault.js
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
4
|
+
import * as vault from "./contracts/vault/vault.js";
|
|
5
|
+
import * as compositionRoyaltyPool from "./contracts/composition_royalty_pool/composition_royalty_pool.js";
|
|
6
|
+
import * as recordingRoyaltyPool from "./contracts/recording_royalty_pool/recording_royalty_pool.js";
|
|
7
|
+
import * as compositionRoutedStake from "./contracts/composition_routed_stake/composition_routed_stake.js";
|
|
8
|
+
import * as releaseRevenueDistributor from "./contracts/release_revenue_distributor/release_revenue_distributor.js";
|
|
9
|
+
import * as routedStake from "./contracts/routed_stake/routed_stake.js";
|
|
10
|
+
function object(tx, value) {
|
|
11
|
+
return typeof value === "string" ? tx.object(value) : value;
|
|
12
|
+
}
|
|
13
|
+
export function directAdminCap(adminCap) {
|
|
14
|
+
return { kind: "direct", adminCap };
|
|
15
|
+
}
|
|
16
|
+
function requiredVaultResult(result, index, command) {
|
|
17
|
+
const value = result[index];
|
|
18
|
+
if (value === undefined)
|
|
19
|
+
throw new Error(`${command} did not return result ${index}`);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
export function vaultAdminCap(authority) {
|
|
23
|
+
return { kind: "vault", ...authority };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Invoke one cap-authorized Move call without exposing a borrowed cap to JS.
|
|
27
|
+
* The returned PTB result belongs to `call.target`, never to the Vault borrow.
|
|
28
|
+
*/
|
|
29
|
+
export function invokeWithAdminCap(tx, authority, call) {
|
|
30
|
+
if (call.adminCapIndex < 0 || call.adminCapIndex > call.arguments.length) {
|
|
31
|
+
throw new Error("admin cap argument index is out of range");
|
|
32
|
+
}
|
|
33
|
+
const invoke = (adminCap) => tx.moveCall({
|
|
34
|
+
target: call.target,
|
|
35
|
+
typeArguments: call.typeArguments,
|
|
36
|
+
arguments: [
|
|
37
|
+
...call.arguments.slice(0, call.adminCapIndex),
|
|
38
|
+
adminCap,
|
|
39
|
+
...call.arguments.slice(call.adminCapIndex),
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
if (authority.kind === "direct")
|
|
43
|
+
return invoke(object(tx, authority.adminCap));
|
|
44
|
+
const borrowed = tx.add(vault.borrowAsAdmin({
|
|
45
|
+
package: authority.vaultPackageId,
|
|
46
|
+
typeArguments: [authority.capType],
|
|
47
|
+
arguments: [object(tx, authority.vault), object(tx, authority.vaultAdminCap)],
|
|
48
|
+
}));
|
|
49
|
+
const adminCap = borrowed[0];
|
|
50
|
+
const receipt = borrowed[1];
|
|
51
|
+
if (adminCap === undefined || receipt === undefined) {
|
|
52
|
+
throw new Error("vault::borrow_as_admin returned an incomplete result");
|
|
53
|
+
}
|
|
54
|
+
const result = invoke(adminCap);
|
|
55
|
+
tx.add(vault.putBack({
|
|
56
|
+
package: authority.vaultPackageId,
|
|
57
|
+
typeArguments: [authority.capType],
|
|
58
|
+
arguments: [authority.vault, adminCap, receipt],
|
|
59
|
+
}));
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
/** Explicitly transfer a new cap or custody it before the PTB finishes. */
|
|
63
|
+
export function disposeNewAdminCap(tx, adminCap, custody) {
|
|
64
|
+
if (custody.kind === "direct") {
|
|
65
|
+
tx.transferObjects([adminCap], custody.owner);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
custodyNewAdminCap(tx, {
|
|
69
|
+
adminCap,
|
|
70
|
+
capType: custody.capType,
|
|
71
|
+
vaultPackageId: custody.vaultPackageId,
|
|
72
|
+
owner: custody.owner,
|
|
73
|
+
configure: custody.configure,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Destroy a vault only while deliberately disposing of its returned raw cap. */
|
|
77
|
+
export function destroyVault(tx, params) {
|
|
78
|
+
const cap = tx.add(vault.destroy({
|
|
79
|
+
package: params.vaultPackageId,
|
|
80
|
+
typeArguments: [params.capType],
|
|
81
|
+
arguments: [object(tx, params.vault), object(tx, params.vaultAdminCap)],
|
|
82
|
+
}));
|
|
83
|
+
disposeNewAdminCap(tx, cap, params.disposition);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Custody a freshly-created raw admin cap, optionally install plugins, share the
|
|
87
|
+
* Vault, then transfer only the VaultAdminCap to its owner.
|
|
88
|
+
*/
|
|
89
|
+
export function custodyNewAdminCap(tx, params) {
|
|
90
|
+
const created = tx.add(vault._new({
|
|
91
|
+
package: params.vaultPackageId,
|
|
92
|
+
typeArguments: [params.capType],
|
|
93
|
+
arguments: [params.adminCap],
|
|
94
|
+
}));
|
|
95
|
+
const vaultObject = requiredVaultResult(created, 0, "vault::_new");
|
|
96
|
+
const vaultAdminCap = requiredVaultResult(created, 1, "vault::_new");
|
|
97
|
+
params.configure?.(vaultObject, vaultAdminCap);
|
|
98
|
+
tx.add(vault.share({
|
|
99
|
+
package: params.vaultPackageId,
|
|
100
|
+
typeArguments: [params.capType],
|
|
101
|
+
arguments: [vaultObject],
|
|
102
|
+
}));
|
|
103
|
+
tx.transferObjects([vaultAdminCap], params.owner);
|
|
104
|
+
}
|
|
105
|
+
/** Install the composition royalty-pool plugin; its witness stays internal. */
|
|
106
|
+
export function installCompositionRoyaltyPoolPlugin(tx, params) {
|
|
107
|
+
tx.add(compositionRoyaltyPool.install({
|
|
108
|
+
package: params.pluginPackageId,
|
|
109
|
+
typeArguments: [params.compositionShareType],
|
|
110
|
+
arguments: [params.vault, params.vaultAdminCap],
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
export function uninstallCompositionRoyaltyPoolPlugin(tx, params) {
|
|
114
|
+
tx.add(compositionRoyaltyPool.uninstall({ package: params.pluginPackageId, typeArguments: [params.compositionShareType], arguments: [params.vault, params.vaultAdminCap] }));
|
|
115
|
+
}
|
|
116
|
+
export function initializeCompositionRoyaltyPool(tx, params) {
|
|
117
|
+
tx.add(compositionRoyaltyPool.initializePool({
|
|
118
|
+
package: params.pluginPackageId,
|
|
119
|
+
typeArguments: [params.compositionShareType, params.currencyType],
|
|
120
|
+
arguments: [params.vault, params.composition, params.vaultAdminCap],
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
/** Validate an SDK scalar before serializing it as a Move u64. */
|
|
124
|
+
export function asU64(name, value) {
|
|
125
|
+
if (typeof value === "number" && (!Number.isSafeInteger(value) || value < 0)) {
|
|
126
|
+
throw new Error(`${name}: number must be a non-negative safe integer; use bigint or decimal string`);
|
|
127
|
+
}
|
|
128
|
+
if (typeof value === "string" && !/^(0|[1-9][0-9]*)$/.test(value)) {
|
|
129
|
+
throw new Error(`${name}: expected an unsigned decimal u64`);
|
|
130
|
+
}
|
|
131
|
+
const parsed = typeof value === "bigint" ? value : BigInt(value);
|
|
132
|
+
if (parsed < 0n || parsed > 18446744073709551615n) {
|
|
133
|
+
throw new Error(`${name}: value is outside u64`);
|
|
134
|
+
}
|
|
135
|
+
return parsed;
|
|
136
|
+
}
|
|
137
|
+
/** Permissionless crank: redeem address funds into the canonical pool. */
|
|
138
|
+
export function redeemCompositionRoyaltyPool(tx, params) {
|
|
139
|
+
tx.add(compositionRoyaltyPool.redeemAndDeposit({
|
|
140
|
+
package: params.pluginPackageId,
|
|
141
|
+
typeArguments: [params.compositionShareType, params.currencyType],
|
|
142
|
+
arguments: [params.vault, params.composition, params.pool, asU64("value", params.value)],
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
/** Permissionless crank: receive selected Composition-owned coins into the pool. */
|
|
146
|
+
export function receiveCompositionRoyaltyPool(tx, params) {
|
|
147
|
+
tx.add(compositionRoyaltyPool.receiveAndDeposit({
|
|
148
|
+
package: params.pluginPackageId,
|
|
149
|
+
typeArguments: [params.compositionShareType, params.currencyType],
|
|
150
|
+
arguments: [
|
|
151
|
+
params.vault,
|
|
152
|
+
params.composition,
|
|
153
|
+
params.pool,
|
|
154
|
+
receivingCoins(tx, params.currencyType, params.coins),
|
|
155
|
+
],
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
export function installRecordingRoyaltyPoolPlugin(tx, params) {
|
|
159
|
+
tx.add(recordingRoyaltyPool.install({
|
|
160
|
+
package: params.pluginPackageId,
|
|
161
|
+
typeArguments: [params.recordingShareType],
|
|
162
|
+
arguments: [params.vault, params.vaultAdminCap],
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
export function uninstallRecordingRoyaltyPoolPlugin(tx, params) {
|
|
166
|
+
tx.add(recordingRoyaltyPool.uninstall({ package: params.pluginPackageId, typeArguments: [params.recordingShareType], arguments: [params.vault, params.vaultAdminCap] }));
|
|
167
|
+
}
|
|
168
|
+
export function initializeRecordingRoyaltyPool(tx, params) {
|
|
169
|
+
tx.add(recordingRoyaltyPool.initializePool({
|
|
170
|
+
package: params.pluginPackageId,
|
|
171
|
+
typeArguments: [
|
|
172
|
+
params.recordingShareType,
|
|
173
|
+
params.compositionShareType,
|
|
174
|
+
params.currencyType,
|
|
175
|
+
],
|
|
176
|
+
arguments: [params.vault, params.recording, params.vaultAdminCap],
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
export function redeemRecordingRoyaltyPool(tx, params) {
|
|
180
|
+
tx.add(recordingRoyaltyPool.redeemAndDeposit({
|
|
181
|
+
package: params.pluginPackageId,
|
|
182
|
+
typeArguments: [
|
|
183
|
+
params.recordingShareType,
|
|
184
|
+
params.compositionShareType,
|
|
185
|
+
params.currencyType,
|
|
186
|
+
],
|
|
187
|
+
arguments: [params.vault, params.recording, params.pool, asU64("value", params.value)],
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
/** Permissionless crank: receive selected Recording-owned coins into the pool. */
|
|
191
|
+
export function receiveRecordingRoyaltyPool(tx, params) {
|
|
192
|
+
tx.add(recordingRoyaltyPool.receiveAndDeposit({
|
|
193
|
+
package: params.pluginPackageId,
|
|
194
|
+
typeArguments: [
|
|
195
|
+
params.recordingShareType,
|
|
196
|
+
params.compositionShareType,
|
|
197
|
+
params.currencyType,
|
|
198
|
+
],
|
|
199
|
+
arguments: [
|
|
200
|
+
params.vault,
|
|
201
|
+
params.recording,
|
|
202
|
+
params.pool,
|
|
203
|
+
receivingCoins(tx, params.currencyType, params.coins),
|
|
204
|
+
],
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
export function installReleaseRevenueDistributorPlugin(tx, params) {
|
|
208
|
+
tx.add(releaseRevenueDistributor.install({
|
|
209
|
+
package: params.pluginPackageId,
|
|
210
|
+
arguments: [params.vault, params.vaultAdminCap],
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
export function uninstallReleaseRevenueDistributorPlugin(tx, params) {
|
|
214
|
+
tx.add(releaseRevenueDistributor.uninstall({ package: params.pluginPackageId, arguments: [params.vault, params.vaultAdminCap] }));
|
|
215
|
+
}
|
|
216
|
+
/** Permissionless crank: redeem release-held money and route it by track BPS. */
|
|
217
|
+
export function redeemAndDistributeReleaseRevenue(tx, params) {
|
|
218
|
+
tx.add(releaseRevenueDistributor.redeemAndDistribute({
|
|
219
|
+
package: params.pluginPackageId,
|
|
220
|
+
typeArguments: [params.currencyType],
|
|
221
|
+
arguments: [params.vault, params.release, asU64("value", params.value)],
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
/** Permissionless crank: receive release-owned coins and route them by track BPS. */
|
|
225
|
+
export function receiveAndDistributeReleaseRevenue(tx, params) {
|
|
226
|
+
tx.add(releaseRevenueDistributor.receiveAndDistribute({
|
|
227
|
+
package: params.pluginPackageId,
|
|
228
|
+
typeArguments: [params.currencyType],
|
|
229
|
+
arguments: [
|
|
230
|
+
params.vault,
|
|
231
|
+
params.release,
|
|
232
|
+
receivingCoins(tx, params.currencyType, params.coins),
|
|
233
|
+
],
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
export function installCompositionRoutedStakePlugin(tx, params) {
|
|
237
|
+
tx.add(compositionRoutedStake.install({
|
|
238
|
+
package: params.pluginPackageId,
|
|
239
|
+
typeArguments: [params.compositionShareType],
|
|
240
|
+
arguments: [params.vault, params.vaultAdminCap],
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
export function uninstallCompositionRoutedStakePlugin(tx, params) {
|
|
244
|
+
tx.add(compositionRoutedStake.uninstall({ package: params.pluginPackageId, typeArguments: [params.compositionShareType], arguments: [params.vault, params.vaultAdminCap] }));
|
|
245
|
+
}
|
|
246
|
+
export function createCompositionRoutedStake(tx, params) {
|
|
247
|
+
tx.add(compositionRoutedStake.createStake({
|
|
248
|
+
package: params.pluginPackageId,
|
|
249
|
+
typeArguments: [params.recordingShareType, params.compositionShareType],
|
|
250
|
+
arguments: [
|
|
251
|
+
params.vault,
|
|
252
|
+
params.composition,
|
|
253
|
+
params.recording,
|
|
254
|
+
params.vaultAdminCap,
|
|
255
|
+
asU64("value", params.value),
|
|
256
|
+
],
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
/** Register the routed stake with the matching Recording royalty pool. */
|
|
260
|
+
export function registerCompositionRoutedStake(tx, params) {
|
|
261
|
+
tx.add(compositionRoutedStake.register({
|
|
262
|
+
package: params.pluginPackageId,
|
|
263
|
+
typeArguments: [
|
|
264
|
+
params.recordingShareType,
|
|
265
|
+
params.compositionShareType,
|
|
266
|
+
params.currencyType,
|
|
267
|
+
],
|
|
268
|
+
arguments: [
|
|
269
|
+
params.vault,
|
|
270
|
+
params.composition,
|
|
271
|
+
params.recording,
|
|
272
|
+
params.routedStake,
|
|
273
|
+
params.royaltyPool,
|
|
274
|
+
params.vaultAdminCap,
|
|
275
|
+
],
|
|
276
|
+
}));
|
|
277
|
+
}
|
|
278
|
+
/** Unregister a routed stake after pending rewards have been swept. */
|
|
279
|
+
export function unregisterCompositionRoutedStake(tx, params) {
|
|
280
|
+
tx.add(compositionRoutedStake.unregister({
|
|
281
|
+
package: params.pluginPackageId,
|
|
282
|
+
typeArguments: [
|
|
283
|
+
params.recordingShareType,
|
|
284
|
+
params.compositionShareType,
|
|
285
|
+
params.currencyType,
|
|
286
|
+
],
|
|
287
|
+
arguments: [
|
|
288
|
+
params.vault,
|
|
289
|
+
params.composition,
|
|
290
|
+
params.routedStake,
|
|
291
|
+
params.royaltyPool,
|
|
292
|
+
params.vaultAdminCap,
|
|
293
|
+
],
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
/** Return routed principal to the Composition address, never to the caller. */
|
|
297
|
+
export function unstakeCompositionRoutedStake(tx, params) {
|
|
298
|
+
tx.add(compositionRoutedStake.unstake({
|
|
299
|
+
package: params.pluginPackageId,
|
|
300
|
+
typeArguments: [params.recordingShareType, params.compositionShareType],
|
|
301
|
+
arguments: [
|
|
302
|
+
params.vault,
|
|
303
|
+
params.composition,
|
|
304
|
+
params.routedStake,
|
|
305
|
+
params.vaultAdminCap,
|
|
306
|
+
],
|
|
307
|
+
}));
|
|
308
|
+
}
|
|
309
|
+
/** Refill an empty routed stake from Recording shares held by the Composition. */
|
|
310
|
+
export function restakeCompositionRoutedStake(tx, params) {
|
|
311
|
+
tx.add(compositionRoutedStake.restake({
|
|
312
|
+
package: params.pluginPackageId,
|
|
313
|
+
typeArguments: [params.recordingShareType, params.compositionShareType],
|
|
314
|
+
arguments: [
|
|
315
|
+
params.vault,
|
|
316
|
+
params.composition,
|
|
317
|
+
params.routedStake,
|
|
318
|
+
params.vaultAdminCap,
|
|
319
|
+
asU64("value", params.value),
|
|
320
|
+
],
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
/** Permissionlessly sweep a routed stake's accrued rewards into its parent pool. */
|
|
324
|
+
export function sweepRoutedStake(tx, params) {
|
|
325
|
+
tx.add(routedStake.sweep({
|
|
326
|
+
package: params.routedStakePackageId,
|
|
327
|
+
typeArguments: [params.stakeShareType, params.poolShareType, params.currencyType],
|
|
328
|
+
arguments: [object(tx, params.routedStake), object(tx, params.stakePool), object(tx, params.royaltyPool), params.parentId],
|
|
329
|
+
}));
|
|
330
|
+
}
|
|
331
|
+
/** Parse a VaultAdminCap whose phantom capability does not affect BCS layout. */
|
|
332
|
+
export function parseVaultAdminCap(content) {
|
|
333
|
+
return vault.VaultAdminCap.parse(content);
|
|
334
|
+
}
|
|
335
|
+
/** Parse lifecycle events whose phantom type parameters do not affect BCS. */
|
|
336
|
+
export function parseVaultCreatedEvent(content) {
|
|
337
|
+
return vault.VaultCreatedEvent.parse(content);
|
|
338
|
+
}
|
|
339
|
+
/** Parse the release-distribution summary event into JSON-safe quantities. */
|
|
340
|
+
export function parseReleaseRevenueDistributedEvent(content) {
|
|
341
|
+
const event = releaseRevenueDistributor.ReleaseRevenueDistributedEvent.parse(content);
|
|
342
|
+
return {
|
|
343
|
+
releaseId: event.release_id,
|
|
344
|
+
totalInput: event.total_input.toString(),
|
|
345
|
+
totalDistributed: event.total_distributed.toString(),
|
|
346
|
+
remainder: event.remainder.toString(),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/** Parse one per-track routing event, retaining its u64 values as strings. */
|
|
350
|
+
export function parseReleaseTrackRevenueDistributedEvent(content) {
|
|
351
|
+
const event = releaseRevenueDistributor.ReleaseTrackRevenueDistributedEvent.parse(content);
|
|
352
|
+
return {
|
|
353
|
+
releaseId: event.release_id,
|
|
354
|
+
trackIndex: event.track_index.toString(),
|
|
355
|
+
recordingId: event.recording_id,
|
|
356
|
+
amount: event.amount.toString(),
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/** Read and BCS-parse an owner-held VaultAdminCap. */
|
|
360
|
+
export async function getVaultAdminCap(client, vaultAdminCapId, expected) {
|
|
361
|
+
const { object } = await client.core.getObject({
|
|
362
|
+
objectId: vaultAdminCapId,
|
|
363
|
+
include: { content: true },
|
|
364
|
+
});
|
|
365
|
+
if (!object || object instanceof Error || !object.content)
|
|
366
|
+
return null;
|
|
367
|
+
const expectedType = normalizeStructTag(`${expected.vaultPackageId}::vault::VaultAdminCap<${expected.capType}>`);
|
|
368
|
+
if (!object.type || normalizeStructTag(object.type) !== expectedType) {
|
|
369
|
+
throw new Error(`getVaultAdminCap: expected ${expectedType}, received ${object.type ?? "unknown"}`);
|
|
370
|
+
}
|
|
371
|
+
return parseVaultAdminCap(object.content);
|
|
372
|
+
}
|
|
373
|
+
/** Resolve owned coins to the exact references required by a Receiving input. */
|
|
374
|
+
export async function resolveReceivingCoins(client, coinIds) {
|
|
375
|
+
const { objects } = await client.core.getObjects({ objectIds: [...coinIds] });
|
|
376
|
+
return objects.map((coin, index) => {
|
|
377
|
+
if (coin instanceof Error || !coin) {
|
|
378
|
+
throw new Error(`resolveReceivingCoins: could not resolve ${coinIds[index]}`);
|
|
379
|
+
}
|
|
380
|
+
return { objectId: coin.objectId, version: coin.version, digest: coin.digest };
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
export function receivingCoins(tx, currencyType, coins) {
|
|
384
|
+
return tx.makeMoveVec({
|
|
385
|
+
type: `0x2::transfer::Receiving<0x2::coin::Coin<${currencyType}>>`,
|
|
386
|
+
elements: coins.map((coin) => tx.receivingRef(coin)),
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=vault.js.map
|