@misofm/musicos 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +75 -0
  3. package/dist/client.d.ts +309 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +216 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/contracts/musicos/composition.d.ts +195 -0
  8. package/dist/contracts/musicos/composition.d.ts.map +1 -0
  9. package/dist/contracts/musicos/composition.js +195 -0
  10. package/dist/contracts/musicos/composition.js.map +1 -0
  11. package/dist/contracts/musicos/deps/bps/bps.d.ts +17 -0
  12. package/dist/contracts/musicos/deps/bps/bps.d.ts.map +1 -0
  13. package/dist/contracts/musicos/deps/bps/bps.js +19 -0
  14. package/dist/contracts/musicos/deps/bps/bps.js.map +1 -0
  15. package/dist/contracts/musicos/recording.d.ts +238 -0
  16. package/dist/contracts/musicos/recording.d.ts.map +1 -0
  17. package/dist/contracts/musicos/recording.js +232 -0
  18. package/dist/contracts/musicos/recording.js.map +1 -0
  19. package/dist/contracts/musicos/release.d.ts +298 -0
  20. package/dist/contracts/musicos/release.d.ts.map +1 -0
  21. package/dist/contracts/musicos/release.js +298 -0
  22. package/dist/contracts/musicos/release.js.map +1 -0
  23. package/dist/contracts/musicos/track.d.ts +193 -0
  24. package/dist/contracts/musicos/track.d.ts.map +1 -0
  25. package/dist/contracts/musicos/track.js +197 -0
  26. package/dist/contracts/musicos/track.js.map +1 -0
  27. package/dist/contracts/utils/index.d.ts +104 -0
  28. package/dist/contracts/utils/index.d.ts.map +1 -0
  29. package/dist/contracts/utils/index.js +272 -0
  30. package/dist/contracts/utils/index.js.map +1 -0
  31. package/dist/contracts.d.ts +9 -0
  32. package/dist/contracts.d.ts.map +1 -0
  33. package/dist/contracts.js +14 -0
  34. package/dist/contracts.js.map +1 -0
  35. package/dist/deployments.d.ts +60 -0
  36. package/dist/deployments.d.ts.map +1 -0
  37. package/dist/deployments.js +109 -0
  38. package/dist/deployments.js.map +1 -0
  39. package/dist/events.d.ts +16 -0
  40. package/dist/events.d.ts.map +1 -0
  41. package/dist/events.js +25 -0
  42. package/dist/events.js.map +1 -0
  43. package/dist/execute.d.ts +49 -0
  44. package/dist/execute.d.ts.map +1 -0
  45. package/dist/execute.js +110 -0
  46. package/dist/execute.js.map +1 -0
  47. package/dist/index.d.ts +13 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +20 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/internal.d.ts +17 -0
  52. package/dist/internal.d.ts.map +1 -0
  53. package/dist/internal.js +46 -0
  54. package/dist/internal.js.map +1 -0
  55. package/dist/numeric.d.ts +5 -0
  56. package/dist/numeric.d.ts.map +1 -0
  57. package/dist/numeric.js +21 -0
  58. package/dist/numeric.js.map +1 -0
  59. package/dist/packages.d.ts +67 -0
  60. package/dist/packages.d.ts.map +1 -0
  61. package/dist/packages.js +85 -0
  62. package/dist/packages.js.map +1 -0
  63. package/dist/parsers.d.ts +9 -0
  64. package/dist/parsers.d.ts.map +1 -0
  65. package/dist/parsers.js +40 -0
  66. package/dist/parsers.js.map +1 -0
  67. package/dist/queries.d.ts +178 -0
  68. package/dist/queries.d.ts.map +1 -0
  69. package/dist/queries.js +611 -0
  70. package/dist/queries.js.map +1 -0
  71. package/dist/transactions.d.ts +136 -0
  72. package/dist/transactions.d.ts.map +1 -0
  73. package/dist/transactions.js +145 -0
  74. package/dist/transactions.js.map +1 -0
  75. package/dist/types.d.ts +194 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/dist/types.js +4 -0
  78. package/dist/types.js.map +1 -0
  79. package/dist/view.d.ts +22 -0
  80. package/dist/view.d.ts.map +1 -0
  81. package/dist/view.js +42 -0
  82. package/dist/view.js.map +1 -0
  83. package/package.json +119 -0
  84. package/src/client.ts +341 -0
  85. package/src/contracts/musicos/composition.ts +280 -0
  86. package/src/contracts/musicos/deps/bps/bps.ts +22 -0
  87. package/src/contracts/musicos/recording.ts +308 -0
  88. package/src/contracts/musicos/release.ts +409 -0
  89. package/src/contracts/musicos/track.ts +255 -0
  90. package/src/contracts/utils/index.ts +428 -0
  91. package/src/contracts.ts +29 -0
  92. package/src/deployments.ts +166 -0
  93. package/src/events.ts +30 -0
  94. package/src/execute.ts +137 -0
  95. package/src/index.ts +21 -0
  96. package/src/internal.ts +78 -0
  97. package/src/numeric.ts +25 -0
  98. package/src/packages.ts +117 -0
  99. package/src/parsers.ts +66 -0
  100. package/src/queries.ts +928 -0
  101. package/src/transactions.ts +305 -0
  102. package/src/types.ts +222 -0
  103. package/src/view.ts +65 -0
@@ -0,0 +1,110 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Transaction execution + effect extraction (the Signer-parameter pattern).
4
+ //
5
+ // Builders elsewhere only *append* to a caller-owned Transaction; this module is
6
+ // where a transaction is actually submitted. `signAndExecute` submits over the
7
+ // unified Core API, unwraps the `{ $kind: "Transaction", Transaction }` envelope,
8
+ // waits for finality, and returns changed objects, the objectId→type map, balance
9
+ // changes, and net gas for downstream extraction. Everything here is
10
+ // transport-agnostic — it takes any `ClientWithCoreApi`, so gRPC / JSON-RPC /
11
+ // GraphQL clients all work.
12
+ //
13
+ import { Transaction } from "@mysten/sui/transactions";
14
+ /** The effect fields every submit path requests, so extraction is uniform. */
15
+ export const FULL_INCLUDE = { effects: true, objectTypes: true, balanceChanges: true };
16
+ /** Builds a fresh Transaction from one or more thunks (awaiting async ones). */
17
+ export async function buildTx(...thunks) {
18
+ const tx = new Transaction();
19
+ for (const thunk of thunks)
20
+ await thunk(tx);
21
+ return tx;
22
+ }
23
+ /** Normalizes the `{ $kind }` transaction-result envelope into an {@link ExecResult}. */
24
+ export function toExecResult(res) {
25
+ if (res.$kind !== "Transaction") {
26
+ const failed = res.FailedTransaction;
27
+ const status = failed.effects?.status;
28
+ const err = status && !status.success ? JSON.stringify(status.error) : "unknown error";
29
+ throw new Error(`Transaction failed: ${err} (digest ${failed.digest})`);
30
+ }
31
+ const t = res.Transaction;
32
+ const effects = t.effects;
33
+ if (!effects.status.success) {
34
+ throw new Error(`Transaction reverted: ${JSON.stringify(effects.status.error)} (digest ${t.digest})`);
35
+ }
36
+ return {
37
+ digest: t.digest,
38
+ changedObjects: effects.changedObjects,
39
+ objectTypes: t.objectTypes ?? {},
40
+ balanceChanges: t.balanceChanges ?? [],
41
+ gasUsed: netGas(effects.gasUsed),
42
+ };
43
+ }
44
+ /** Signs, executes, and waits for a transaction; returns changes, types, gas. */
45
+ export async function signAndExecute(client, signer, tx) {
46
+ const res = await client.core.signAndExecuteTransaction({ transaction: tx, signer, include: FULL_INCLUDE });
47
+ const result = toExecResult(res);
48
+ await client.core.waitForTransaction({ digest: result.digest });
49
+ return result;
50
+ }
51
+ /** Convenience: build from thunks, then sign+execute in one call. */
52
+ export async function execThunks(client, signer, ...thunks) {
53
+ return signAndExecute(client, signer, await buildTx(...thunks));
54
+ }
55
+ // ── Object-change extractors ────────────────────────────────────────────────
56
+ /** The package id from the (single) newly-published package. */
57
+ export function publishedPackageId(r) {
58
+ const pkg = r.changedObjects.find((c) => c.idOperation === "Created" && c.outputState === "PackageWrite");
59
+ if (!pkg)
60
+ throw new Error("No published package found in object changes.");
61
+ return pkg.objectId;
62
+ }
63
+ /** All package ids newly published by the transaction (up to 5 per PTB). */
64
+ export function allPublishedPackageIds(r) {
65
+ return r.changedObjects
66
+ .filter((c) => c.idOperation === "Created" && c.outputState === "PackageWrite")
67
+ .map((c) => c.objectId);
68
+ }
69
+ /** The first newly-created object whose type contains `substr`. */
70
+ export function createdByType(r, substr) {
71
+ const id = maybeCreatedByType(r, substr);
72
+ if (!id)
73
+ throw new Error(`No created object with type containing "${substr}" found in object changes.`);
74
+ return id;
75
+ }
76
+ /** Like {@link createdByType} but returns undefined instead of throwing. */
77
+ export function maybeCreatedByType(r, substr) {
78
+ for (const c of r.changedObjects) {
79
+ if (c.idOperation === "Created" && (r.objectTypes[c.objectId] ?? "").includes(substr))
80
+ return c.objectId;
81
+ }
82
+ return undefined;
83
+ }
84
+ /** The first newly-created object whose type is EXACTLY `type` (for non-generic types). */
85
+ export function createdByExactType(r, type) {
86
+ for (const c of r.changedObjects) {
87
+ if (c.idOperation === "Created" && r.objectTypes[c.objectId] === type)
88
+ return c.objectId;
89
+ }
90
+ throw new Error(`No created object of exact type "${type}" found in object changes.`);
91
+ }
92
+ /** All newly-created objects whose type contains `substr`. */
93
+ export function allCreatedByType(r, substr) {
94
+ const out = [];
95
+ for (const c of r.changedObjects) {
96
+ const type = r.objectTypes[c.objectId] ?? "";
97
+ if (c.idOperation === "Created" && type.includes(substr))
98
+ out.push({ objectId: c.objectId, objectType: type });
99
+ }
100
+ return out;
101
+ }
102
+ /** The signed balance delta for `address` in `coinType`, or "0" if absent. */
103
+ export function balanceDelta(r, address, coinType) {
104
+ const change = r.balanceChanges.find((b) => b.address === address && b.coinType === coinType);
105
+ return change?.amount ?? "0";
106
+ }
107
+ function netGas(gasUsed) {
108
+ return Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate);
109
+ }
110
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAEtC,4EAA4E;AAC5E,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,kFAAkF;AAClF,kFAAkF;AAClF,qEAAqE;AACrE,8EAA8E;AAC9E,4BAA4B;AAC5B,EAAE;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAKvD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAW,CAAC;AAehG,gFAAgF;AAChF,MAAM,CAAC,KAAK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,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC7C,IAAI,CAAC,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,CAAa,EAAE,OAAe,EAAE,QAAgB;IAC3E,MAAM,MAAM,GAAG,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAC9F,OAAO,MAAM,EAAE,MAAM,IAAI,GAAG,CAAC;AAC/B,CAAC;AAED,SAAS,MAAM,CAAC,OAAsC;IACpD,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACvG,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from "./types.ts";
2
+ export * from "./transactions.ts";
3
+ export * from "./execute.ts";
4
+ export * from "./numeric.ts";
5
+ export * from "./queries.ts";
6
+ export * from "./parsers.ts";
7
+ export * from "./events.ts";
8
+ export * from "./view.ts";
9
+ export * from "./client.ts";
10
+ export * from "./deployments.ts";
11
+ export * from "./packages.ts";
12
+ export * as contracts from "./contracts.ts";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAG9B,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // ABI-bound object-model bindings ONLY: Composition, Recording, Release, and
4
+ // Track (the `musicos` Move package). `@misofm/musicos` is the object model;
5
+ // everything Miso offers on top of it — extensions, Party, royalty
6
+ // primitives, and product-specific workflows — lives in `@misofm/platform`.
7
+ export * from "./types.js";
8
+ export * from "./transactions.js";
9
+ export * from "./execute.js";
10
+ export * from "./numeric.js";
11
+ export * from "./queries.js";
12
+ export * from "./parsers.js";
13
+ export * from "./events.js";
14
+ export * from "./view.js";
15
+ export * from "./client.js";
16
+ export * from "./deployments.js";
17
+ export * from "./packages.js";
18
+ // Generated, ABI-bound bindings (BCS structs + type-safe Move calls).
19
+ export * as contracts from "./contracts.js";
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAEtC,6EAA6E;AAC7E,6EAA6E;AAC7E,mEAAmE;AACnE,4EAA4E;AAC5E,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAE9B,sEAAsE;AACtE,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { BPS, Composition, Recording, Release as ReleaseType, Track } from "./types.ts";
2
+ type Parsed = any;
3
+ /** `BPS` is a Move tuple struct `(u16)`, parsed as `[number]`. */
4
+ export declare function mapBps(d: Parsed): BPS;
5
+ /** Lifecycle state enum (`Initialized | Published(u64)`). */
6
+ export declare function mapState(d: Parsed): {
7
+ type: "Initialized";
8
+ } | {
9
+ type: "Published";
10
+ timestampMs: number;
11
+ };
12
+ export declare function mapComposition(id: string, d: Parsed): Composition;
13
+ export declare function mapRecording(id: string, d: Parsed): Recording;
14
+ export declare function mapTrack(d: Parsed): Track;
15
+ export declare function mapRelease(id: string, d: Parsed): ReleaseType;
16
+ export {};
17
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,GAAG,EACH,WAAW,EACX,SAAS,EACT,OAAO,IAAI,WAAW,EACtB,KAAK,EAEN,MAAM,YAAY,CAAC;AAKpB,KAAK,MAAM,GAAG,GAAG,CAAC;AAIlB,kEAAkE;AAClE,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAErC;AAED,6DAA6D;AAC7D,wBAAgB,QAAQ,CACtB,CAAC,EAAE,MAAM,GACR;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAGtE;AAID,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAOjE;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAM7D;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAOzC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAO7D"}
@@ -0,0 +1,46 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // === Primitives ===
4
+ /** `BPS` is a Move tuple struct `(u16)`, parsed as `[number]`. */
5
+ export function mapBps(d) {
6
+ return { value: Number(Array.isArray(d) ? d[0] : d) };
7
+ }
8
+ /** Lifecycle state enum (`Initialized | Published(u64)`). */
9
+ export function mapState(d) {
10
+ if (d?.$kind === "Published")
11
+ return { type: "Published", timestampMs: Number(d.Published) };
12
+ return { type: "Initialized" };
13
+ }
14
+ // === Objects ===
15
+ export function mapComposition(id, d) {
16
+ return {
17
+ id,
18
+ state: mapState(d.state),
19
+ title: d.title,
20
+ royaltyRate: mapBps(d.royalty_rate),
21
+ };
22
+ }
23
+ export function mapRecording(id, d) {
24
+ return {
25
+ id,
26
+ state: mapState(d.state),
27
+ compositionId: d.composition_id,
28
+ };
29
+ }
30
+ export function mapTrack(d) {
31
+ return {
32
+ state: (d.state?.$kind ?? "Unassigned"),
33
+ compositionId: d.composition_id,
34
+ recordingId: d.recording_id,
35
+ splitBps: mapBps(d.split_bps),
36
+ };
37
+ }
38
+ export function mapRelease(id, d) {
39
+ return {
40
+ id,
41
+ state: mapState(d.state),
42
+ title: d.title,
43
+ tracks: (d.tracks ?? []).map(mapTrack),
44
+ };
45
+ }
46
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AA0BtC,qBAAqB;AAErB,kEAAkE;AAClE,MAAM,UAAU,MAAM,CAAC,CAAS;IAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OA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,CAAC,KAAK;QACd,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;KACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** JSON-safe input for an unsigned Move integer. Decimal strings preserve exactness. */
2
+ export type UnsignedInput = bigint | number | string;
3
+ export declare function asU64(name: string, value: UnsignedInput): bigint;
4
+ export declare function asU256(name: string, value: UnsignedInput): bigint;
5
+ //# sourceMappingURL=numeric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric.d.ts","sourceRoot":"","sources":["../src/numeric.ts"],"names":[],"mappings":"AAGA,wFAAwF;AACxF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAcrD,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAEhE;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAEjE"}
@@ -0,0 +1,21 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ function unsigned(name, value, maximum) {
4
+ if (typeof value === "number" && (!Number.isSafeInteger(value) || value < 0)) {
5
+ throw new Error(`${name}: number must be a non-negative safe integer; use bigint or decimal string`);
6
+ }
7
+ if (typeof value === "string" && !/^(0|[1-9][0-9]*)$/.test(value)) {
8
+ throw new Error(`${name}: expected an unsigned decimal integer`);
9
+ }
10
+ const parsed = typeof value === "bigint" ? value : BigInt(value);
11
+ if (parsed < 0n || parsed > maximum)
12
+ throw new Error(`${name}: value is outside its Move integer range`);
13
+ return parsed;
14
+ }
15
+ export function asU64(name, value) {
16
+ return unsigned(name, value, 18446744073709551615n);
17
+ }
18
+ export function asU256(name, value) {
19
+ return unsigned(name, value, (1n << 256n) - 1n);
20
+ }
21
+ //# sourceMappingURL=numeric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric.js","sourceRoot":"","sources":["../src/numeric.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAKtC,SAAS,QAAQ,CAAC,IAAY,EAAE,KAAoB,EAAE,OAAe;IACnE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,4EAA4E,CAAC,CAAC;IACvG,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,wCAAwC,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjE,IAAI,MAAM,GAAG,EAAE,IAAI,MAAM,GAAG,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,2CAA2C,CAAC,CAAC;IACzG,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,IAAY,EAAE,KAAoB;IACtD,OAAO,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,qBAA2B,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,KAAoB;IACvD,OAAO,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Package-bound generated APIs.
3
+ *
4
+ * `@mysten/codegen` intentionally emits `@local-pkg/*` source labels. This
5
+ * adapter replaces those labels with the exact addresses from a complete Miso
6
+ * deployment manifest, so applications never have to hand-write a Move target.
7
+ */
8
+ import { type MisoDeployment } from "./deployments.ts";
9
+ import * as composition from "./contracts/musicos/composition.ts";
10
+ import * as recording from "./contracts/musicos/recording.ts";
11
+ import * as release from "./contracts/musicos/release.ts";
12
+ import * as track from "./contracts/musicos/track.ts";
13
+ type BoundMoveFunction<F> = F extends (options: infer Options) => infer Result ? Options extends {
14
+ package?: unknown;
15
+ } ? (options: Omit<Options, "package">) => Result : F : F;
16
+ type BoundModule<M extends object, Removed extends PropertyKey> = {
17
+ [Key in Exclude<keyof M, Removed>]: BoundMoveFunction<M[Key]>;
18
+ };
19
+ /** Generated modules mix BCS constants with transaction-builder functions. */
20
+ type CodecModule<M extends object> = {
21
+ [Key in keyof M as M[Key] extends (...args: never[]) => unknown ? never : Key]: M[Key];
22
+ };
23
+ /** Defaults a generated module's optional `package` field to `packageId`. */
24
+ export declare function bindModulePackage<M extends object, K extends readonly (keyof M)[] = readonly []>(mod: M, packageId: string, unavailable?: K): BoundModule<M, K[number]>;
25
+ /**
26
+ * Public Move functions that return references. A PTB can borrow internally,
27
+ * but a Move-call command result cannot carry a reference to a later command.
28
+ * Keep them out of `call`; use object/dynamic-field BCS queries instead.
29
+ */
30
+ export declare const REF_RETURNING_CALLS: {
31
+ readonly composition: readonly ["title", "uid", "uidMut"];
32
+ readonly recording: readonly ["uid", "uidMut"];
33
+ readonly release: readonly ["title", "tracks", "uid", "uidMut"];
34
+ };
35
+ /**
36
+ * All generated functions and BCS codecs bound to one full, verified deployment.
37
+ *
38
+ * The `call` namespaces construct only caller-owned PTB commands. They neither
39
+ * set gas nor sign/execute. Query dynamic fields directly rather than using a
40
+ * Move function whose return type is a reference: PTB command outputs cannot
41
+ * carry references.
42
+ */
43
+ export declare class MisoPackageBindings {
44
+ readonly deployment: MisoDeployment;
45
+ constructor(deployment: MisoDeployment);
46
+ get call(): {
47
+ core: {
48
+ composition: BoundModule<typeof composition, "title" | "uid" | "uidMut">;
49
+ recording: BoundModule<typeof recording, "uid" | "uidMut">;
50
+ release: BoundModule<typeof release, "title" | "tracks" | "uid" | "uidMut">;
51
+ track: BoundModule<typeof track, never>;
52
+ };
53
+ };
54
+ /** Generated BCS codecs, grouped with the same ownership boundary as `call`. */
55
+ get bcs(): {
56
+ core: {
57
+ composition: CodecModule<typeof composition>;
58
+ recording: CodecModule<typeof recording>;
59
+ release: CodecModule<typeof release>;
60
+ track: CodecModule<typeof track>;
61
+ };
62
+ };
63
+ }
64
+ /** Construct complete package bindings from an explicit verified manifest. */
65
+ export declare function misoPackages(deployment: MisoDeployment): MisoPackageBindings;
66
+ export {};
67
+ //# sourceMappingURL=packages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packages.d.ts","sourceRoot":"","sources":["../src/packages.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,WAAW,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,OAAO,MAAM,gCAAgC,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC;AAEtD,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,OAAO,KAAK,MAAM,MAAM,GAC1E,OAAO,SAAS;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GACnC,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,MAAM,GAC7C,CAAC,GACH,CAAC,CAAC;AACN,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,SAAS,WAAW,IAAI;KAC/D,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CA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+ *
6
+ * `@mysten/codegen` intentionally emits `@local-pkg/*` source labels. This
7
+ * adapter replaces those labels with the exact addresses from a complete Miso
8
+ * deployment manifest, so applications never have to hand-write a Move target.
9
+ */
10
+ import { normalizeMisoDeployment } from "./deployments.js";
11
+ import * as composition from "./contracts/musicos/composition.js";
12
+ import * as recording from "./contracts/musicos/recording.js";
13
+ import * as release from "./contracts/musicos/release.js";
14
+ import * as track from "./contracts/musicos/track.js";
15
+ /** BCS-only projection: never leak Move-call builders into the `bcs` namespace. */
16
+ function codecsOnly(mod) {
17
+ return Object.fromEntries(Object.entries(mod).filter(([, value]) => typeof value !== "function"));
18
+ }
19
+ /** Defaults a generated module's optional `package` field to `packageId`. */
20
+ export function bindModulePackage(mod, packageId, unavailable = []) {
21
+ const bound = {};
22
+ for (const [key, value] of Object.entries(mod)) {
23
+ if (unavailable.includes(key))
24
+ continue;
25
+ bound[key] =
26
+ typeof value === "function"
27
+ ? (options) => value({
28
+ ...options,
29
+ package: packageId,
30
+ })
31
+ : value;
32
+ }
33
+ return bound;
34
+ }
35
+ /**
36
+ * Public Move functions that return references. A PTB can borrow internally,
37
+ * but a Move-call command result cannot carry a reference to a later command.
38
+ * Keep them out of `call`; use object/dynamic-field BCS queries instead.
39
+ */
40
+ export const REF_RETURNING_CALLS = {
41
+ composition: ["title", "uid", "uidMut"],
42
+ recording: ["uid", "uidMut"],
43
+ release: ["title", "tracks", "uid", "uidMut"],
44
+ };
45
+ /**
46
+ * All generated functions and BCS codecs bound to one full, verified deployment.
47
+ *
48
+ * The `call` namespaces construct only caller-owned PTB commands. They neither
49
+ * set gas nor sign/execute. Query dynamic fields directly rather than using a
50
+ * Move function whose return type is a reference: PTB command outputs cannot
51
+ * carry references.
52
+ */
53
+ export class MisoPackageBindings {
54
+ deployment;
55
+ constructor(deployment) {
56
+ this.deployment = normalizeMisoDeployment(deployment);
57
+ }
58
+ get call() {
59
+ const d = this.deployment;
60
+ return {
61
+ core: {
62
+ composition: bindModulePackage(composition, d.musicos, REF_RETURNING_CALLS.composition),
63
+ recording: bindModulePackage(recording, d.musicos, REF_RETURNING_CALLS.recording),
64
+ release: bindModulePackage(release, d.musicos, REF_RETURNING_CALLS.release),
65
+ track: bindModulePackage(track, d.musicos),
66
+ },
67
+ };
68
+ }
69
+ /** Generated BCS codecs, grouped with the same ownership boundary as `call`. */
70
+ get bcs() {
71
+ return {
72
+ core: {
73
+ composition: codecsOnly(composition),
74
+ recording: codecsOnly(recording),
75
+ release: codecsOnly(release),
76
+ track: codecsOnly(track),
77
+ },
78
+ };
79
+ }
80
+ }
81
+ /** Construct complete package bindings from an explicit verified manifest. */
82
+ export function misoPackages(deployment) {
83
+ return new MisoPackageBindings(deployment);
84
+ }
85
+ //# sourceMappingURL=packages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packages.js","sourceRoot":"","sources":["../src/packages.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAEtC;;;;;;GAMG;AAEH,OAAO,EAAE,uBAAuB,EAAuB,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,WAAW,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,OAAO,MAAM,gCAAgC,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC;AAetD,mFAAmF;AACnF,SAAS,UAAU,CAAmB,GAAM;IAC1C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CACrD,CAAC;AACtB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAI/B,GAAM,EACN,SAAiB,EACjB,WAAW,GAAM,EAAkB;IAEnC,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC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AK,EAAE,CAAC,CAAC,OAAO,CAAC;aAC3C;SACF,CAAC;IACJ,CAAC;IAED,gFAAgF;IAChF,IAAI,GAAG;QACL,OAAO;YACL,IAAI,EAAE;gBACJ,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC;gBACpC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC;gBAChC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;gBAC5B,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;aACzB;SACF,CAAC;IACJ,CAAC;CACF;AAED,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,UAA0B;IACrD,OAAO,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { CompositionPublishedEvent, CompositionSharesGrantedEvent, RecordingPublishedEvent, ReleaseRegistryCreatedEvent, ReleasePublishedEvent } from "./types.ts";
2
+ export declare function parseCompositionPublishedEvent(bytes: Uint8Array): CompositionPublishedEvent;
3
+ export declare function parseRecordingPublishedEvent(bytes: Uint8Array): RecordingPublishedEvent;
4
+ /** Decode the royalty-rate share grant emitted during `recording::new`. */
5
+ export declare function parseCompositionSharesGrantedEvent(bytes: Uint8Array): CompositionSharesGrantedEvent;
6
+ export declare function parseReleasePublishedEvent(bytes: Uint8Array): ReleasePublishedEvent;
7
+ /** Decode the singleton core release-registry creation event. */
8
+ export declare function parseReleaseRegistryCreatedEvent(bytes: Uint8Array): ReleaseRegistryCreatedEvent;
9
+ //# sourceMappingURL=parsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC7B,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAIpB,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,UAAU,GAAG,yBAAyB,CAG3F;AAID,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,UAAU,GAAG,uBAAuB,CAGvF;AAED,2EAA2E;AAC3E,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,UAAU,GAChB,6BAA6B,CAS/B;AAID,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,qBAAqB,CAGnF;AAED,iEAAiE;AACjE,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,UAAU,GAChB,2BAA2B,CAG7B"}
@@ -0,0 +1,40 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Event parsers. The BCS layouts come from the codegen-generated structs (so
4
+ // they track the on-chain ABI automatically); these functions parse raw event
5
+ // bytes and map them to the public camelCase event types.
6
+ import { CompositionPublishedEvent as CompositionPublishedEventBcs } from "./contracts/musicos/composition.js";
7
+ import { CompositionSharesGrantedEvent as CompositionSharesGrantedEventBcs, RecordingPublishedEvent as RecordingPublishedEventBcs, } from "./contracts/musicos/recording.js";
8
+ import { ReleasePublishedEvent as ReleasePublishedEventBcs, ReleaseRegistryCreatedEvent as ReleaseRegistryCreatedEventBcs, } from "./contracts/musicos/release.js";
9
+ // === Composition ===
10
+ export function parseCompositionPublishedEvent(bytes) {
11
+ const e = CompositionPublishedEventBcs.parse(bytes);
12
+ return { compositionId: e.composition_id };
13
+ }
14
+ // === Recording ===
15
+ export function parseRecordingPublishedEvent(bytes) {
16
+ const e = RecordingPublishedEventBcs.parse(bytes);
17
+ return { recordingId: e.recording_id };
18
+ }
19
+ /** Decode the royalty-rate share grant emitted during `recording::new`. */
20
+ export function parseCompositionSharesGrantedEvent(bytes) {
21
+ const e = CompositionSharesGrantedEventBcs.parse(bytes);
22
+ return {
23
+ recordingId: e.recording_id,
24
+ compositionId: e.composition_id,
25
+ value: e.value,
26
+ rateBps: e.rate_bps,
27
+ grantedBy: e.granted_by,
28
+ };
29
+ }
30
+ // === Release ===
31
+ export function parseReleasePublishedEvent(bytes) {
32
+ const e = ReleasePublishedEventBcs.parse(bytes);
33
+ return { releaseId: e.release_id };
34
+ }
35
+ /** Decode the singleton core release-registry creation event. */
36
+ export function parseReleaseRegistryCreatedEvent(bytes) {
37
+ const e = ReleaseRegistryCreatedEventBcs.parse(bytes);
38
+ return { registryId: e.registry_id, createdBy: e.created_by };
39
+ }
40
+ //# sourceMappingURL=parsers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsers.js","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAEtC,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,EAAE,yBAAyB,IAAI,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAC/G,OAAO,EACL,6BAA6B,IAAI,gCAAgC,EACjE,uBAAuB,IAAI,0BAA0B,GACtD,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,qBAAqB,IAAI,wBAAwB,EACjD,2BAA2B,IAAI,8BAA8B,GAC9D,MAAM,gCAAgC,CAAC;AASxC,sBAAsB;AAEtB,MAAM,UAAU,8BAA8B,CAAC,KAAiB;IAC9D,MAAM,CAAC,GAAG,4BAA4B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC;AAC7C,CAAC;AAED,oBAAoB;AAEpB,MAAM,UAAU,4BAA4B,CAAC,KAAiB;IAC5D,MAAM,CAAC,GAAG,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClD,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC;AACzC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,kCAAkC,CAChD,KAAiB;IAEjB,MAAM,CAAC,GAAG,gCAAgC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACxD,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,YAAY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