@misofm/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +248 -0
  3. package/dist/catalog.d.ts +31 -0
  4. package/dist/catalog.d.ts.map +1 -0
  5. package/dist/catalog.js +45 -0
  6. package/dist/catalog.js.map +1 -0
  7. package/dist/client.d.ts +134 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +113 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/contracts/miso_pressing/certificate.d.ts +78 -0
  12. package/dist/contracts/miso_pressing/certificate.d.ts.map +1 -0
  13. package/dist/contracts/miso_pressing/certificate.js +91 -0
  14. package/dist/contracts/miso_pressing/certificate.js.map +1 -0
  15. package/dist/contracts/miso_pressing/deps/std/type_name.d.ts +18 -0
  16. package/dist/contracts/miso_pressing/deps/std/type_name.d.ts.map +1 -0
  17. package/dist/contracts/miso_pressing/deps/std/type_name.js +20 -0
  18. package/dist/contracts/miso_pressing/deps/std/type_name.js.map +1 -0
  19. package/dist/contracts/miso_pressing/listing.d.ts +449 -0
  20. package/dist/contracts/miso_pressing/listing.d.ts.map +1 -0
  21. package/dist/contracts/miso_pressing/listing.js +416 -0
  22. package/dist/contracts/miso_pressing/listing.js.map +1 -0
  23. package/dist/contracts/miso_pressing/pressing.d.ts +365 -0
  24. package/dist/contracts/miso_pressing/pressing.d.ts.map +1 -0
  25. package/dist/contracts/miso_pressing/pressing.js +335 -0
  26. package/dist/contracts/miso_pressing/pressing.js.map +1 -0
  27. package/dist/contracts/utils/index.d.ts +31 -0
  28. package/dist/contracts/utils/index.d.ts.map +1 -0
  29. package/dist/contracts/utils/index.js +162 -0
  30. package/dist/contracts/utils/index.js.map +1 -0
  31. package/dist/execute.d.ts +17 -0
  32. package/dist/execute.d.ts.map +1 -0
  33. package/dist/execute.js +21 -0
  34. package/dist/execute.js.map +1 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +27 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/pressing.d.ts +223 -0
  40. package/dist/pressing.d.ts.map +1 -0
  41. package/dist/pressing.js +280 -0
  42. package/dist/pressing.js.map +1 -0
  43. package/dist/queries.d.ts +2 -0
  44. package/dist/queries.d.ts.map +1 -0
  45. package/dist/queries.js +8 -0
  46. package/dist/queries.js.map +1 -0
  47. package/dist/release-graph.d.ts +93 -0
  48. package/dist/release-graph.d.ts.map +1 -0
  49. package/dist/release-graph.js +143 -0
  50. package/dist/release-graph.js.map +1 -0
  51. package/dist/share-template.d.ts +3 -0
  52. package/dist/share-template.d.ts.map +1 -0
  53. package/dist/share-template.js +46 -0
  54. package/dist/share-template.js.map +1 -0
  55. package/dist/share.d.ts +66 -0
  56. package/dist/share.d.ts.map +1 -0
  57. package/dist/share.js +156 -0
  58. package/dist/share.js.map +1 -0
  59. package/dist/transactions.d.ts +177 -0
  60. package/dist/transactions.d.ts.map +1 -0
  61. package/dist/transactions.js +237 -0
  62. package/dist/transactions.js.map +1 -0
  63. package/package.json +99 -0
  64. package/src/catalog.ts +77 -0
  65. package/src/client.ts +249 -0
  66. package/src/contracts/miso_pressing/certificate.ts +129 -0
  67. package/src/contracts/miso_pressing/deps/std/type_name.ts +22 -0
  68. package/src/contracts/miso_pressing/listing.ts +621 -0
  69. package/src/contracts/miso_pressing/pressing.ts +454 -0
  70. package/src/contracts/utils/index.ts +229 -0
  71. package/src/execute.ts +34 -0
  72. package/src/index.ts +29 -0
  73. package/src/pressing.ts +497 -0
  74. package/src/queries.ts +9 -0
  75. package/src/release-graph.ts +279 -0
  76. package/src/share-template.ts +55 -0
  77. package/src/share.ts +258 -0
  78. package/src/transactions.ts +440 -0
@@ -0,0 +1,143 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Single-PTB publisher for a whole release graph: creates every composition and
4
+ // recording, optionally attaches royalty pools, derives the release id ON-CHAIN
5
+ // (so recordings need not be shared first), builds the deals/tracks/release,
6
+ // then shares everything and transfers the admin caps — all in ONE transaction.
7
+ //
8
+ // Share currencies must already be published + initialized (their Currency objects
9
+ // shared on-chain); their ids/types are passed in. Ordering is load-bearing:
10
+ // 1. composition::new → recording::new(&comp) (borrow-before-share) + pool attach
11
+ // 2. release::derive_release_id(<recording::id results>) → deal::new(cap, &rec,
12
+ // derivedId, split) → track::new → release::new
13
+ // 3. publish (share) comps + recs + release, disperse supply, transfer caps
14
+ // Steps 1–2 borrow the works; step 3 consumes them into share_object.
15
+ //
16
+ // Release tracks come in three shapes (see TrackNode): recordings created in
17
+ // THIS PTB, existing recordings authorized by their admin cap (deal created
18
+ // inline), and existing recordings authorized by a pre-made Deal in hand.
19
+ // Pre-made deals pin the release id, so they cannot coexist with fresh
20
+ // recordings — the builder rejects that mix up front.
21
+ //
22
+ // This is the whole-graph orchestration half of the opinionated publish flow —
23
+ // it composes `@misonetwork/sdk`'s bare `composition`/`recording`/`deal`/`track`/
24
+ // `release` call bindings, its `createRelease` primitive and
25
+ // `attachCompositionRoyaltyPool`/`attachRecordingRoyaltyPool`, plus this
26
+ // package's own `disperseShares`/`finalizeRelease`, into one PTB.
27
+ import { Transaction } from "@mysten/sui/transactions";
28
+ import { contracts, attachCompositionRoyaltyPool, attachRecordingRoyaltyPool, createRelease, PROTOCOL_MAX_ROYALTY_RATE_BPS, } from "@misonetwork/sdk";
29
+ import { disperseShares, finalizeRelease } from "./transactions.js";
30
+ const { composition, recording, deal, track, release } = contracts;
31
+ const isFresh = (t) => "recordingIndex" in t;
32
+ const isDealBacked = (t) => "dealId" in t;
33
+ /** Builds the entire graph in a single transaction (see file header for ordering). */
34
+ export function publishReleaseGraph(params) {
35
+ const { misoPackageId: pkg, minatoPackageId } = params;
36
+ return (tx) => {
37
+ // ── 1) Create every composition, then every recording (borrow-before-share) ──
38
+ const comps = params.compositions.map((c) => {
39
+ const r = tx.add(composition._new({
40
+ package: pkg,
41
+ typeArguments: [c.shareType],
42
+ arguments: [tx.pure.string(c.title), tx.pure.u16(c.royaltyRateBps), tx.object(c.shareCurrencyId), tx.object(c.shareTreasuryCapId)],
43
+ }));
44
+ const parts = { work: r[0], adminCap: r[1], balance: r[2] };
45
+ if (c.royaltyPool) {
46
+ attachCompositionRoyaltyPool(tx, {
47
+ composition: parts.work,
48
+ adminCap: parts.adminCap,
49
+ compositionShareType: c.shareType,
50
+ currency: c.royaltyPool.currency,
51
+ compositionRoyaltyPoolPackageId: c.royaltyPool.extensionPackageId,
52
+ royaltyPoolPackageId: c.royaltyPool.royaltyPoolPackageId,
53
+ });
54
+ }
55
+ return parts;
56
+ });
57
+ const recTypeArgs = (i) => {
58
+ const n = params.recordings[i];
59
+ return [n.shareType, n.compositionShareType];
60
+ };
61
+ const recs = params.recordings.map((rec, i) => {
62
+ const parent = rec.parentCompositionIndex !== undefined ? comps[rec.parentCompositionIndex].work : tx.object(rec.parentCompositionId);
63
+ // Slippage guard: a parent created in this PTB has a known rate — pin it
64
+ // exactly. An existing parent uses the caller's observed rate (or accepts
65
+ // up to the protocol max).
66
+ const maxRoyaltyRateBps = rec.parentCompositionIndex !== undefined
67
+ ? params.compositions[rec.parentCompositionIndex].royaltyRateBps
68
+ : (rec.maxRoyaltyRateBps ?? PROTOCOL_MAX_ROYALTY_RATE_BPS);
69
+ const typeArgs = recTypeArgs(i);
70
+ const r = tx.add(recording._new({ package: pkg, typeArguments: typeArgs, arguments: [parent, tx.object(rec.shareCurrencyId), tx.object(rec.shareTreasuryCapId), tx.pure.u16(maxRoyaltyRateBps)] }));
71
+ const parts = { work: r[0], adminCap: r[1], balance: r[2] };
72
+ if (rec.royaltyPool) {
73
+ attachRecordingRoyaltyPool(tx, {
74
+ recording: parts.work,
75
+ adminCap: parts.adminCap,
76
+ recordingShareType: rec.shareType,
77
+ compositionShareType: rec.compositionShareType,
78
+ currency: rec.royaltyPool.currency,
79
+ recordingRoyaltyPoolPackageId: rec.royaltyPool.extensionPackageId,
80
+ royaltyPoolPackageId: rec.royaltyPool.royaltyPoolPackageId,
81
+ });
82
+ }
83
+ return parts;
84
+ });
85
+ // ── 2) Release: derive the id on-chain, then deals → tracks → release ──
86
+ if (params.release) {
87
+ const rel = params.release;
88
+ const ordered = rel.tracks;
89
+ if (ordered.some(isDealBacked) && ordered.some(isFresh)) {
90
+ throw new Error("A release cannot mix pre-made deals with recordings created in this transaction: " +
91
+ "a deal pins the exact release id, whose digest includes every track's recording id, " +
92
+ "and a fresh recording's id is unknowable when the deal was created. " +
93
+ "Authorize the existing recordings with their admin caps instead.");
94
+ }
95
+ // The derived id feeds the deals created inline (fresh/cap-backed tracks).
96
+ // Pre-made deals already store it, so an all-deal release skips the derive.
97
+ let releaseId;
98
+ if (!ordered.every(isDealBacked)) {
99
+ const idVec = tx.makeMoveVec({
100
+ type: "0x2::object::ID",
101
+ elements: ordered.map((t) => isFresh(t)
102
+ ? tx.add(recording.id({ package: pkg, typeArguments: recTypeArgs(t.recordingIndex), arguments: [recs[t.recordingIndex].work] }))
103
+ : tx.pure.id(t.recordingId)),
104
+ });
105
+ const splitVec = tx.makeMoveVec({ type: "u64", elements: ordered.map((t) => tx.pure.u64(t.splitBps)) });
106
+ releaseId = tx.add(release.deriveReleaseId({ package: pkg, arguments: [idVec, splitVec, tx.pure.u256(BigInt(rel.nonce)), tx.object(rel.releaseRegistryId)] }));
107
+ }
108
+ const trackArgs = ordered.map((t) => {
109
+ if (isDealBacked(t)) {
110
+ const typeArgs = [t.recordingShareType, t.compositionShareType];
111
+ return tx.add(track._new({ package: pkg, typeArguments: typeArgs, arguments: [tx.object(t.dealId), tx.object(t.recordingId)] }));
112
+ }
113
+ if (isFresh(t)) {
114
+ const typeArgs = recTypeArgs(t.recordingIndex);
115
+ const parts = recs[t.recordingIndex];
116
+ const dealArg = tx.add(deal._new({ package: pkg, typeArguments: typeArgs, arguments: [parts.adminCap, parts.work, releaseId, tx.pure.u16(t.splitBps)] }));
117
+ return tx.add(track._new({ package: pkg, typeArguments: typeArgs, arguments: [dealArg, parts.work] }));
118
+ }
119
+ const typeArgs = [t.recordingShareType, t.compositionShareType];
120
+ const rec = tx.object(t.recordingId);
121
+ const dealArg = tx.add(deal._new({ package: pkg, typeArguments: typeArgs, arguments: [tx.object(t.recordingAdminCapId), rec, releaseId, tx.pure.u16(t.splitBps)] }));
122
+ return tx.add(track._new({ package: pkg, typeArguments: typeArgs, arguments: [dealArg, rec] }));
123
+ });
124
+ const trackVec = tx.makeMoveVec({ type: `${pkg}::track::Track`, elements: trackArgs });
125
+ const releaseParts = createRelease(tx, { title: rel.title, nonce: rel.nonce, releaseRegistryId: rel.releaseRegistryId, misoPackageId: pkg }, trackVec);
126
+ finalizeRelease(tx, { ...releaseParts, adminAddress: rel.adminAddress, misoPackageId: pkg });
127
+ }
128
+ // ── 3) Share every work, disperse its supply, transfer admin caps ──
129
+ params.compositions.forEach((c, i) => {
130
+ const parts = comps[i];
131
+ disperseShares(tx, minatoPackageId, c.shareType, parts.balance, c.shareRecipients);
132
+ tx.add(composition.publish({ package: pkg, typeArguments: [c.shareType], arguments: [parts.work, parts.adminCap] }));
133
+ tx.transferObjects([parts.adminCap], c.adminAddress);
134
+ });
135
+ params.recordings.forEach((rec, i) => {
136
+ const parts = recs[i];
137
+ tx.add(recording.publish({ package: pkg, typeArguments: recTypeArgs(i), arguments: [parts.work, parts.adminCap] }));
138
+ disperseShares(tx, minatoPackageId, rec.shareType, parts.balance, rec.shareRecipients);
139
+ tx.transferObjects([parts.adminCap], rec.adminAddress);
140
+ });
141
+ };
142
+ }
143
+ //# sourceMappingURL=release-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-graph.js","sourceRoot":"","sources":["../src/release-graph.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAEtC,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,EAAE;AACF,mFAAmF;AACnF,6E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AC,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YACpH,cAAc,CAAC,EAAE,EAAE,eAAe,EAAE,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;YACvF,EAAE,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { PackageBytecode } from "./transactions.ts";
2
+ export declare const SHARE_TEMPLATE: PackageBytecode;
3
+ //# sourceMappingURL=share-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-template.d.ts","sourceRoot":"","sources":["../src/share-template.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,eAAO,MAAM,cAAc,EAAE,eA0C5B,CAAC"}
@@ -0,0 +1,46 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export const SHARE_TEMPLATE = {
4
+ "modules": [
5
+ "oRzrCwYAAAAKAQAOAg4gAy4gBE4EBVJHB5kB1QEI7gJgBs4DNwqFBAYMiwQ4ABEBEgIHAggCCQIPAhMAAggAAQMHAAMEDAEAAQQACAAEAQABAAEFBgQABgUCAAANAAEAARQFBgACCwUEAAQKCgIBAAQOCAkBCAYQAwQABAcDBwUIAQgBCAEHCAMHCAYBCwIBCAAAAQYIBgEFAQoCAQgBAQgABwcIAwIIAQgBCAEIAQcIBgILBAEJAAsCAQkAAgsEAQkABwgGDENvaW5SZWdpc3RyeRNDdXJyZW5jeUluaXRpYWxpemVyBVNoYXJlBlN0cmluZwtUcmVhc3VyeUNhcAlUeENvbnRleHQDVUlEB2FkZHJlc3MEY29pbg1jb2luX3JlZ2lzdHJ5IGZpbmFsaXplX2FuZF9kZWxldGVfbWV0YWRhdGFfY2FwCmZyb21fYnl0ZXMCaWQKaW5pdGlhbGl6ZQxuZXdfY3VycmVuY3kGb2JqZWN0BnNlbmRlcgVzaGFyZQZzdHJpbmcKdHhfY29udGV4dAR1dGY4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCgIhIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwgAAAAAAAAAAAoCBgVTSEFSRQACAQwIBQABAAABHAoELhEFBwARAiEECAUOCwQBCwMBBwEnCwMxBgcCEQELAAsBCwIKBDgADAULBDgBCwUCAA=="
6
+ ],
7
+ "dependencies": [
8
+ "0x0000000000000000000000000000000000000000000000000000000000000001",
9
+ "0x0000000000000000000000000000000000000000000000000000000000000002"
10
+ ],
11
+ "digest": [
12
+ 191,
13
+ 44,
14
+ 36,
15
+ 112,
16
+ 72,
17
+ 10,
18
+ 163,
19
+ 173,
20
+ 88,
21
+ 79,
22
+ 123,
23
+ 99,
24
+ 33,
25
+ 92,
26
+ 255,
27
+ 215,
28
+ 122,
29
+ 199,
30
+ 22,
31
+ 101,
32
+ 247,
33
+ 141,
34
+ 222,
35
+ 237,
36
+ 187,
37
+ 42,
38
+ 28,
39
+ 13,
40
+ 201,
41
+ 193,
42
+ 173,
43
+ 204
44
+ ]
45
+ };
46
+ //# sourceMappingURL=share-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-template.js","sourceRoot":"","sources":["../src/share-template.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAWtC,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC7C,SAAS,EAAE;QACT,s0BAAs0B;KACv0B;IACD,cAAc,EAAE;QACd,oEAAoE;QACpE,oEAAoE;KACrE;IACD,QAAQ,EAAE;QACR,GAAG;QACH,EAAE;QACF,EAAE;QACF,GAAG;QACH,EAAE;QACF,EAAE;QACF,GAAG;QACH,GAAG;QACH,EAAE;QACF,EAAE;QACF,GAAG;QACH,EAAE;QACF,EAAE;QACF,EAAE;QACF,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,EAAE;QACF,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,EAAE;QACF,EAAE;QACF,EAAE;QACF,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;KACJ;CACF,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { ParallelTransactionExecutor } from "@mysten/sui/transactions";
2
+ import type { ClientWithCoreApi } from "@mysten/sui/client";
3
+ import type { Signer } from "@mysten/sui/cryptography";
4
+ import { type PackageBytecode } from "./transactions.ts";
5
+ export interface ShareCurrency {
6
+ /** The published share package id. */
7
+ packageId: string;
8
+ /** The `Currency<Share>` object id. */
9
+ currencyId: string;
10
+ /** The fully-qualified share type, `${packageId}::share::Share`. */
11
+ shareType: string;
12
+ /** The `TreasuryCap<Share>` object id (held by the treasury-cap recipient). */
13
+ treasuryCapId: string;
14
+ /** Net gas (MIST) attributed to this currency, if tracked per-item (else 0). */
15
+ gasUsed: number;
16
+ }
17
+ export interface ShareCurrencyMeta {
18
+ name: string;
19
+ description: string;
20
+ iconUrl?: string;
21
+ }
22
+ /**
23
+ * Patches the `INITIALIZER` constant in the share module bytecode, replacing the
24
+ * 32-byte zero-address placeholder with `initializerAddress`. The template is left
25
+ * untouched; a fresh patched copy is returned. `share::initialize` asserts the
26
+ * sender equals this address, so it must be the signer that will initialize.
27
+ */
28
+ export declare function patchInitializer(template: PackageBytecode, initializerAddress: string): PackageBytecode;
29
+ export interface CreateShareCurrencyParams {
30
+ /** The share bytecode template. Defaults to the embedded {@link SHARE_TEMPLATE}. */
31
+ template?: PackageBytecode;
32
+ name: string;
33
+ description: string;
34
+ iconUrl?: string;
35
+ /** Address baked in as INITIALIZER; must be the signer. Defaults to the signer. */
36
+ initializerAddress?: string;
37
+ /** Recipient of the minted `TreasuryCap`. Defaults to the signer. */
38
+ treasuryCapRecipient?: string;
39
+ }
40
+ /** Publishes + initializes a fresh share currency in two sequential txs. */
41
+ export declare function createShareCurrency(client: ClientWithCoreApi, signer: Signer, params: CreateShareCurrencyParams): Promise<ShareCurrency>;
42
+ /**
43
+ * Publishes `count` fresh share-currency packages, batched at ≤5 publishes per PTB
44
+ * and run concurrently through the executor. Returns the published package ids
45
+ * (fungible — order is not meaningful; the caller assigns them to work slots).
46
+ */
47
+ export declare function publishShareCurrencies(executor: ParallelTransactionExecutor, initializerAddress: string, count: number, template?: PackageBytecode): Promise<{
48
+ packageIds: string[];
49
+ gasUsed: number;
50
+ }>;
51
+ /**
52
+ * Initializes each published package into a `Currency<Share>` + `TreasuryCap`,
53
+ * batched and run concurrently. `metaOf` supplies each package's display metadata,
54
+ * so a currency destined for a specific work is named for it.
55
+ *
56
+ * `share::initialize` is NON-idempotent (`coin_registry` registers one `Currency`
57
+ * per type), so a batch must never be re-run. Batches run under `Promise.allSettled`
58
+ * and `onBatch` fires for each SUCCEEDED batch as it lands — letting the caller
59
+ * persist that batch immediately. If any batch fails, the succeeded ones are already
60
+ * reported and this throws, so a resume re-initializes only the still-missing packages.
61
+ */
62
+ export declare function initializeShareCurrencies(executor: ParallelTransactionExecutor, signerAddress: string, packageIds: string[], metaOf: (packageId: string) => ShareCurrencyMeta, onBatch?: (currencies: ShareCurrency[], gasUsed: number) => void | Promise<void>): Promise<{
63
+ currencies: ShareCurrency[];
64
+ gasUsed: number;
65
+ }>;
66
+ //# sourceMappingURL=share.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../src/share.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,O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,eAAgC,GACzC,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBpD;AAgBD;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,2BAA2B,EACrC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,iBAAiB,EAChD,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC/E,OAAO,CAAC;IAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAyC3D"}
package/dist/share.js ADDED
@@ -0,0 +1,156 @@
1
+ // Copyright (c) Miso Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { fromBase64, fromHex, toBase64 } from "@mysten/sui/utils";
4
+ import { update_constants } from "@mysten/move-bytecode-template";
5
+ import { execThunks, publishedPackageId, allPublishedPackageIds, createdByType, allCreatedByType, } from "@misonetwork/sdk";
6
+ import { publishShareCurrency, initializeShareCurrency } from "./transactions.js";
7
+ import { SHARE_TEMPLATE } from "./share-template.js";
8
+ import { executeViaExecutor } from "./execute.js";
9
+ /** The protocol cap on Publish/Upgrade commands per programmable transaction. */
10
+ const PUBLISHES_PER_PTB = 5;
11
+ /** Initializes batched per PTB (each is one moveCall + transfer; all share the 0xc registry). */
12
+ const INITS_PER_PTB = 10;
13
+ // Address-free type markers: gRPC object types carry fully-normalized addresses
14
+ // (e.g. 0x0000…0002::coin::TreasuryCap), so we match on module::type rather than a
15
+ // short "0x2" prefix that would never match.
16
+ const CURRENCY_TYPE = "::coin_registry::Currency<";
17
+ const TREASURY_CAP_TYPE = "::coin::TreasuryCap<";
18
+ // ── Bytecode patching ────────────────────────────────────────────────────────
19
+ /**
20
+ * Patches the `INITIALIZER` constant in the share module bytecode, replacing the
21
+ * 32-byte zero-address placeholder with `initializerAddress`. The template is left
22
+ * untouched; a fresh patched copy is returned. `share::initialize` asserts the
23
+ * sender equals this address, so it must be the signer that will initialize.
24
+ */
25
+ export function patchInitializer(template, initializerAddress) {
26
+ const moduleBytes = fromBase64(template.modules[0]);
27
+ // BCS-encoded vector<u8> of 32 zero bytes: [length=32, 0×32].
28
+ const oldValue = new Uint8Array(33);
29
+ oldValue[0] = 32;
30
+ // BCS-encoded vector<u8> of the initializer's 32 address bytes.
31
+ const newValue = new Uint8Array(33);
32
+ newValue[0] = 32;
33
+ newValue.set(fromHex(initializerAddress), 1);
34
+ const patched = update_constants(moduleBytes, newValue, oldValue, "Vector(U8)");
35
+ return { ...template, modules: [toBase64(patched)] };
36
+ }
37
+ /** Publishes + initializes a fresh share currency in two sequential txs. */
38
+ export async function createShareCurrency(client, signer, params) {
39
+ const signerAddress = signer.toSuiAddress();
40
+ const initializer = params.initializerAddress ?? signerAddress;
41
+ const recipient = params.treasuryCapRecipient ?? signerAddress;
42
+ // Tx 1: publish the share package with the initializer baked in.
43
+ const patched = patchInitializer(params.template ?? SHARE_TEMPLATE, initializer);
44
+ const publishRes = await execThunks(client, signer, publishShareCurrency(patched));
45
+ const packageId = publishedPackageId(publishRes);
46
+ // Tx 2: initialize → creates the Currency object + transfers the TreasuryCap.
47
+ const initRes = await execThunks(client, signer, initializeShareCurrency({
48
+ shareCurrencyPackageId: packageId,
49
+ name: params.name,
50
+ description: params.description,
51
+ iconUrl: params.iconUrl ?? "",
52
+ treasuryCapRecipient: recipient,
53
+ }));
54
+ return {
55
+ packageId,
56
+ currencyId: createdByType(initRes, CURRENCY_TYPE),
57
+ shareType: `${packageId}::share::Share`,
58
+ treasuryCapId: createdByType(initRes, TREASURY_CAP_TYPE),
59
+ gasUsed: publishRes.gasUsed + initRes.gasUsed,
60
+ };
61
+ }
62
+ // ── Batched (parallel) ─────────────────────────────────────────────────────
63
+ /** Splits an array into fixed-size chunks. */
64
+ function chunk(items, size) {
65
+ const out = [];
66
+ for (let i = 0; i < items.length; i += size)
67
+ out.push(items.slice(i, i + size));
68
+ return out;
69
+ }
70
+ /**
71
+ * Publishes `count` fresh share-currency packages, batched at ≤5 publishes per PTB
72
+ * and run concurrently through the executor. Returns the published package ids
73
+ * (fungible — order is not meaningful; the caller assigns them to work slots).
74
+ */
75
+ export async function publishShareCurrencies(executor, initializerAddress, count, template = SHARE_TEMPLATE) {
76
+ if (count <= 0)
77
+ return { packageIds: [], gasUsed: 0 };
78
+ // One patched template, reused for every publish (identical bytecode → distinct packages).
79
+ const patched = patchInitializer(template, initializerAddress);
80
+ const batchSizes = [];
81
+ for (let remaining = count; remaining > 0; remaining -= PUBLISHES_PER_PTB) {
82
+ batchSizes.push(Math.min(PUBLISHES_PER_PTB, remaining));
83
+ }
84
+ const results = await Promise.all(batchSizes.map((n) => executeViaExecutor(executor, ...Array.from({ length: n }, () => publishShareCurrency(patched)))));
85
+ const packageIds = results.flatMap(allPublishedPackageIds);
86
+ const gasUsed = results.reduce((sum, r) => sum + r.gasUsed, 0);
87
+ if (packageIds.length !== count) {
88
+ throw new Error(`Expected ${count} published share packages, got ${packageIds.length}.`);
89
+ }
90
+ return { packageIds, gasUsed };
91
+ }
92
+ /** Re-associates one init PTB's created objects back to their packages by share type. */
93
+ function currenciesFromResult(res, batchPkgs) {
94
+ const currencies = allCreatedByType(res, CURRENCY_TYPE);
95
+ const treasuries = allCreatedByType(res, TREASURY_CAP_TYPE);
96
+ return batchPkgs.map((pkg) => {
97
+ const shareType = `${pkg}::share::Share`;
98
+ const currency = currencies.find((o) => o.objectType.includes(shareType));
99
+ const treasury = treasuries.find((o) => o.objectType.includes(shareType));
100
+ if (!currency)
101
+ throw new Error(`No Currency<${shareType}> created during initialize.`);
102
+ if (!treasury)
103
+ throw new Error(`No TreasuryCap<${shareType}> created during initialize.`);
104
+ return { packageId: pkg, currencyId: currency.objectId, shareType, treasuryCapId: treasury.objectId, gasUsed: 0 };
105
+ });
106
+ }
107
+ /**
108
+ * Initializes each published package into a `Currency<Share>` + `TreasuryCap`,
109
+ * batched and run concurrently. `metaOf` supplies each package's display metadata,
110
+ * so a currency destined for a specific work is named for it.
111
+ *
112
+ * `share::initialize` is NON-idempotent (`coin_registry` registers one `Currency`
113
+ * per type), so a batch must never be re-run. Batches run under `Promise.allSettled`
114
+ * and `onBatch` fires for each SUCCEEDED batch as it lands — letting the caller
115
+ * persist that batch immediately. If any batch fails, the succeeded ones are already
116
+ * reported and this throws, so a resume re-initializes only the still-missing packages.
117
+ */
118
+ export async function initializeShareCurrencies(executor, signerAddress, packageIds, metaOf, onBatch) {
119
+ if (packageIds.length === 0)
120
+ return { currencies: [], gasUsed: 0 };
121
+ const batches = chunk(packageIds, INITS_PER_PTB);
122
+ const settled = await Promise.allSettled(batches.map(async (batchPkgs) => {
123
+ const res = await executeViaExecutor(executor, ...batchPkgs.map((pkg) => {
124
+ const meta = metaOf(pkg);
125
+ return initializeShareCurrency({
126
+ shareCurrencyPackageId: pkg,
127
+ name: meta.name,
128
+ description: meta.description,
129
+ iconUrl: meta.iconUrl ?? "",
130
+ treasuryCapRecipient: signerAddress,
131
+ });
132
+ }));
133
+ const batchCurrencies = currenciesFromResult(res, batchPkgs);
134
+ if (onBatch)
135
+ await onBatch(batchCurrencies, res.gasUsed);
136
+ return { batchCurrencies, gasUsed: res.gasUsed };
137
+ }));
138
+ const currencies = [];
139
+ const errors = [];
140
+ let gasUsed = 0;
141
+ for (const s of settled) {
142
+ if (s.status === "fulfilled") {
143
+ currencies.push(...s.value.batchCurrencies);
144
+ gasUsed += s.value.gasUsed;
145
+ }
146
+ else {
147
+ errors.push(s.reason);
148
+ }
149
+ }
150
+ if (errors.length > 0) {
151
+ const msg = errors.map((e) => (e instanceof Error ? e.message : String(e))).join("; ");
152
+ throw new Error(`${errors.length}/${batches.length} initialize batch(es) failed: ${msg}`);
153
+ }
154
+ return { currencies, gasUsed };
155
+ }
156
+ //# sourceMappingURL=share.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.js","sourceRoot":"","sources":["../src/share.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AAsBtC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,gBAAgB,GAEjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAwB,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,iGAAiG;AACjG,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,gFAAgF;AAChF,mFAAmF;AACnF,6CAA6C;AAC7C,MAAM,aAAa,GAAG,4BAA4B,CAAC;AACnD,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAqBjD,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,kBAA0B;IACpF,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC;IAErD,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACpC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IAEjB,gEAAgE;IAChE,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACpC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACjB,QAAQ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C;QACzD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IACnD,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,UAAU,GAAoB,EAAE,CAAC;IACvC,MAAM,MAAM,GAAc,EAAE,CAAC;IAC7B,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAC7B,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvF,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,177 @@
1
+ import { Transaction, type TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { type CompositionParts, type RecordingParts, type ReleaseParts, type ShareCurrencyBinding, type TxThunk } from "@misonetwork/sdk";
3
+ export type { TxThunk };
4
+ export interface ShareRecipient {
5
+ address: string;
6
+ value: number;
7
+ }
8
+ /**
9
+ * Splits a share `Balance` across `recipients` via `minato::disperse_balance`, then
10
+ * destroys the emptied balance. Exposed for consumers assembling custom share
11
+ * distributions in their own PTBs.
12
+ */
13
+ export declare function disperseShares(tx: Transaction, minatoPackageId: string, shareType: string, balance: TransactionObjectArgument, recipients: ShareRecipient[]): void;
14
+ export interface PackageBytecode {
15
+ modules: string[];
16
+ dependencies: string[];
17
+ digest: number[];
18
+ }
19
+ export declare function publishShareCurrency(bytecode: PackageBytecode): TxThunk;
20
+ export interface InitializeShareCurrencyParams {
21
+ shareCurrencyPackageId: string;
22
+ name: string;
23
+ description: string;
24
+ iconUrl: string;
25
+ treasuryCapRecipient: string;
26
+ }
27
+ export declare function initializeShareCurrency(params: InitializeShareCurrencyParams): TxThunk;
28
+ export interface FinalizeCompositionParams extends CompositionParts {
29
+ /** The composition's `share::Share` type. */
30
+ shareType: string;
31
+ shareRecipients: ShareRecipient[];
32
+ adminAddress: string;
33
+ misoPackageId: string;
34
+ minatoPackageId: string;
35
+ }
36
+ /**
37
+ * The opinionated finish for a composition: disperse its share supply to
38
+ * `shareRecipients`, publish (share) it, and transfer its admin cap to
39
+ * `adminAddress`. Consumers that want different economics skip this and act on
40
+ * the `CompositionParts` from `@misonetwork/sdk`'s `createComposition` directly.
41
+ */
42
+ export declare function finalizeComposition(tx: Transaction, params: FinalizeCompositionParams): void;
43
+ export interface PublishCompositionParams extends ShareCurrencyBinding {
44
+ title: string;
45
+ royaltyRateBps: number;
46
+ shareRecipients: ShareRecipient[];
47
+ /** Sole owner of the shares + CompositionAdminCap (the zkLogin address). */
48
+ adminAddress: string;
49
+ misoPackageId: string;
50
+ minatoPackageId: string;
51
+ }
52
+ /** Convenience: publish a composition end-to-end (createComposition → finalizeComposition). */
53
+ export declare function publishComposition(params: PublishCompositionParams): TxThunk;
54
+ export interface FinalizeRecordingParams extends RecordingParts {
55
+ /** The recording's own `share::Share` type. */
56
+ recordingShareType: string;
57
+ /** Share type of the parent composition. */
58
+ compositionShareType: string;
59
+ shareRecipients: ShareRecipient[];
60
+ adminAddress: string;
61
+ misoPackageId: string;
62
+ minatoPackageId: string;
63
+ }
64
+ /**
65
+ * The opinionated finish for a recording: publish (share) it, disperse its
66
+ * share supply, and transfer its admin cap to `adminAddress`. A recording has
67
+ * no embedded metadata to set — naming lives in the metadata extension.
68
+ */
69
+ export declare function finalizeRecording(tx: Transaction, params: FinalizeRecordingParams): void;
70
+ export interface PublishRecordingParams extends ShareCurrencyBinding {
71
+ /**
72
+ * Parent composition, referenced as an on-chain object. Read-only at
73
+ * `recording::new` (only its royalty rate and id are read).
74
+ */
75
+ compositionId: string;
76
+ /** Share type of the parent composition (the recording's `CompositionShare` phantom). */
77
+ compositionShareType: string;
78
+ shareRecipients: ShareRecipient[];
79
+ adminAddress: string;
80
+ /** Slippage guard for `recording::new` — pass the composition rate you observed (default: protocol max). */
81
+ maxRoyaltyRateBps?: number;
82
+ misoPackageId: string;
83
+ minatoPackageId: string;
84
+ }
85
+ /** Convenience: publish a recording against an already-on-chain composition. */
86
+ export declare function publishRecording(params: PublishRecordingParams): TxThunk;
87
+ export interface PublishCompositionAndRecordingParams {
88
+ title: string;
89
+ royaltyRateBps: number;
90
+ /** Share-currency binding for the composition. */
91
+ composition: ShareCurrencyBinding & {
92
+ shareRecipients: ShareRecipient[];
93
+ adminAddress: string;
94
+ };
95
+ /** Share-currency binding for the recording. */
96
+ recording: ShareCurrencyBinding & {
97
+ shareRecipients: ShareRecipient[];
98
+ adminAddress: string;
99
+ };
100
+ misoPackageId: string;
101
+ minatoPackageId: string;
102
+ }
103
+ /**
104
+ * Publishes a composition and its recording in a single atomic PTB.
105
+ *
106
+ * The ordering is load-bearing: `recording::new` borrows the composition by
107
+ * immutable reference, so it must run while the composition is still an unshared,
108
+ * transaction-local value — i.e. AFTER `composition::new` but BEFORE
109
+ * `composition::publish` (which moves the composition into `share_object`). Hence:
110
+ * `composition::new` → `recording::new(&comp)` → finalize composition (publish) →
111
+ * finalize recording (publish).
112
+ */
113
+ export declare function publishCompositionAndRecording(params: PublishCompositionAndRecordingParams): TxThunk;
114
+ export interface FinalizeReleaseParams extends ReleaseParts {
115
+ /** Recipient of the `ReleaseAdminCap`. */
116
+ adminAddress: string;
117
+ misoPackageId: string;
118
+ }
119
+ /**
120
+ * The opinionated finish for a release: publish (share) it and transfer its
121
+ * admin cap to `adminAddress`.
122
+ *
123
+ * MUST run in the same PTB as the `createRelease` that produced these parts —
124
+ * `Release` is `key`-only with no `drop`, so an unpublished release cannot
125
+ * outlive its transaction. Splitting create from finalize is what lets a caller
126
+ * do something else with the cap (route it to a vault, hand it to another
127
+ * package, keep it for later commands) instead of a plain address transfer.
128
+ */
129
+ export declare function finalizeRelease(tx: Transaction, params: FinalizeReleaseParams): void;
130
+ export interface TrackInput {
131
+ recordingId: string;
132
+ recordingAdminCapId: string;
133
+ /** Share type of the recording (the deal/track `RecordingShare` phantom). */
134
+ recordingShareType: string;
135
+ /** Share type of the parent composition (the deal/track `CompositionShare` phantom). */
136
+ compositionShareType: string;
137
+ splitBps: number;
138
+ }
139
+ export interface PublishReleaseParams {
140
+ title: string;
141
+ /** The ordered tracklist. Display grouping (discs/sides) is extension data. */
142
+ tracks: TrackInput[];
143
+ releaseRegistryId: string;
144
+ releaseId: string;
145
+ releaseNonce: string;
146
+ misoPackageId: string;
147
+ adminAddress: string;
148
+ }
149
+ /**
150
+ * Convenience: publish a release end-to-end, assembling its tracklist from
151
+ * recording admin caps held by the sender (a deal is created inline per track).
152
+ */
153
+ export declare function publishRelease(params: PublishReleaseParams): TxThunk;
154
+ export interface DealInput {
155
+ dealId: string;
156
+ /** The recording the deal is for — `track::new` takes `&Recording` alongside the deal. */
157
+ recordingId: string;
158
+ /** Share type of the recording (the deal/track `RecordingShare` phantom). */
159
+ recordingShareType: string;
160
+ /** Share type of the parent composition (the deal/track `CompositionShare` phantom). */
161
+ compositionShareType: string;
162
+ }
163
+ export interface PublishReleaseFromDealsParams {
164
+ title: string;
165
+ /** The ordered tracklist, one pre-made deal per track. */
166
+ deals: DealInput[];
167
+ releaseRegistryId: string;
168
+ releaseNonce: string;
169
+ misoPackageId: string;
170
+ adminAddress: string;
171
+ }
172
+ /**
173
+ * Convenience: publish a release end-to-end from pre-made `Deal`s held by the
174
+ * sender (each deal already pins this release's id).
175
+ */
176
+ export declare function publishReleaseFromDeals(params: PublishReleaseFromDealsParams): TxThunk;
177
+ //# sourceMappingURL=transactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,WAAW,EAAE,KAAK,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAKL,KAAK,gBAAgB,EAGrB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACb,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EAAE,OAAO,EAAE,CAAC;AAMxB,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,WAAW,EACf,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,yBAAyB,EAClC,UAAU,EAAE,cAAc,EAAE,QAY7B;AAMD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAKvE;AAID,MAAM,WAAW,6BAA6B;IAC5C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,o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