@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.
- package/LICENSE +201 -0
- package/README.md +248 -0
- package/dist/catalog.d.ts +31 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +45 -0
- package/dist/catalog.js.map +1 -0
- package/dist/client.d.ts +134 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +113 -0
- package/dist/client.js.map +1 -0
- package/dist/contracts/miso_pressing/certificate.d.ts +78 -0
- package/dist/contracts/miso_pressing/certificate.d.ts.map +1 -0
- package/dist/contracts/miso_pressing/certificate.js +91 -0
- package/dist/contracts/miso_pressing/certificate.js.map +1 -0
- package/dist/contracts/miso_pressing/deps/std/type_name.d.ts +18 -0
- package/dist/contracts/miso_pressing/deps/std/type_name.d.ts.map +1 -0
- package/dist/contracts/miso_pressing/deps/std/type_name.js +20 -0
- package/dist/contracts/miso_pressing/deps/std/type_name.js.map +1 -0
- package/dist/contracts/miso_pressing/listing.d.ts +449 -0
- package/dist/contracts/miso_pressing/listing.d.ts.map +1 -0
- package/dist/contracts/miso_pressing/listing.js +416 -0
- package/dist/contracts/miso_pressing/listing.js.map +1 -0
- package/dist/contracts/miso_pressing/pressing.d.ts +365 -0
- package/dist/contracts/miso_pressing/pressing.d.ts.map +1 -0
- package/dist/contracts/miso_pressing/pressing.js +335 -0
- package/dist/contracts/miso_pressing/pressing.js.map +1 -0
- package/dist/contracts/utils/index.d.ts +31 -0
- package/dist/contracts/utils/index.d.ts.map +1 -0
- package/dist/contracts/utils/index.js +162 -0
- package/dist/contracts/utils/index.js.map +1 -0
- package/dist/execute.d.ts +17 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +21 -0
- package/dist/execute.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/pressing.d.ts +223 -0
- package/dist/pressing.d.ts.map +1 -0
- package/dist/pressing.js +280 -0
- package/dist/pressing.js.map +1 -0
- package/dist/queries.d.ts +2 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +8 -0
- package/dist/queries.js.map +1 -0
- package/dist/release-graph.d.ts +93 -0
- package/dist/release-graph.d.ts.map +1 -0
- package/dist/release-graph.js +143 -0
- package/dist/release-graph.js.map +1 -0
- package/dist/share-template.d.ts +3 -0
- package/dist/share-template.d.ts.map +1 -0
- package/dist/share-template.js +46 -0
- package/dist/share-template.js.map +1 -0
- package/dist/share.d.ts +66 -0
- package/dist/share.d.ts.map +1 -0
- package/dist/share.js +156 -0
- package/dist/share.js.map +1 -0
- package/dist/transactions.d.ts +177 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/transactions.js +237 -0
- package/dist/transactions.js.map +1 -0
- package/package.json +99 -0
- package/src/catalog.ts +77 -0
- package/src/client.ts +249 -0
- package/src/contracts/miso_pressing/certificate.ts +129 -0
- package/src/contracts/miso_pressing/deps/std/type_name.ts +22 -0
- package/src/contracts/miso_pressing/listing.ts +621 -0
- package/src/contracts/miso_pressing/pressing.ts +454 -0
- package/src/contracts/utils/index.ts +229 -0
- package/src/execute.ts +34 -0
- package/src/index.ts +29 -0
- package/src/pressing.ts +497 -0
- package/src/queries.ts +9 -0
- package/src/release-graph.ts +279 -0
- package/src/share-template.ts +55 -0
- package/src/share.ts +258 -0
- package/src/transactions.ts +440 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Miso Labs, Inc. (build@miso.network)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# @misofm/sdk
|
|
2
|
+
|
|
3
|
+
Typed reads and transaction builders for the **Miso platform layer** on Sui: the
|
|
4
|
+
record production line and the sale of copies off it, plus the opinionated
|
|
5
|
+
publish flow (share economics, minato dispersal, whole-graph orchestration)
|
|
6
|
+
built on top of `@misonetwork/sdk`'s bare protocol primitives.
|
|
7
|
+
|
|
8
|
+
## The split
|
|
9
|
+
|
|
10
|
+
Miso ships two SDK families, and the npm scope tells you which promise you are
|
|
11
|
+
holding:
|
|
12
|
+
|
|
13
|
+
| Scope | Layer | Owns |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `@misonetwork/*` | **Protocol** | Composition, Recording, Release as bare primitives — mint a work, don't disperse/publish/transfer it. The permissionless layer anyone can build on |
|
|
16
|
+
| `@misofm/*` | **Platform** | Pressing, Listing, Record (how Miso sells copies of a release) — plus the opinionated finish for publishing works: disperse share supply via minato, publish (share), transfer the admin cap, provision share currencies, and orchestrate a whole release graph in one PTB |
|
|
17
|
+
|
|
18
|
+
A release is protocol. Pressing a record off that release and selling it is
|
|
19
|
+
platform. So is deciding *what to do* with a freshly-minted work's share
|
|
20
|
+
supply — the protocol only knows how to mint one. Keeping the boundary at the
|
|
21
|
+
package line is what stops the open protocol from quietly growing a
|
|
22
|
+
storefront (or an opinion about tokenomics).
|
|
23
|
+
|
|
24
|
+
This package depends on `@misonetwork/sdk` and imports its bare
|
|
25
|
+
`createComposition`/`createRecording` primitives, composing them with its own
|
|
26
|
+
minato-dispersal and share-currency logic in the same PTB — the
|
|
27
|
+
transaction-thunk composition pattern from the
|
|
28
|
+
[Sui SDK building guide](https://sdk.mystenlabs.com/sui/sdk-building), just
|
|
29
|
+
crossing a package boundary.
|
|
30
|
+
|
|
31
|
+
## The model
|
|
32
|
+
|
|
33
|
+
A release has exactly **one** `Pressing`: a single uncapped run whose counter numbers
|
|
34
|
+
every copy that release will ever sell. There are no editions, no supply caps, no
|
|
35
|
+
sold-out state, and no expiry — a run is `Scheduled → Active → Paused → Active` and
|
|
36
|
+
nothing else.
|
|
37
|
+
|
|
38
|
+
Selling in a currency is a `Listing<Currency>`, one per currency, permanent, edited in
|
|
39
|
+
place rather than replaced. A sale needs both switches open: the run active and that
|
|
40
|
+
currency's listing enabled.
|
|
41
|
+
|
|
42
|
+
**Everything is address math.** The pressing's UID derives off its release's, each
|
|
43
|
+
listing's off the pressing's. There is no registry and no pointer to follow, so
|
|
44
|
+
"where is it" is answered offline — which is why the builders take a RELEASE id and
|
|
45
|
+
compute the rest. A caller cannot pair a listing with the wrong pressing, because it
|
|
46
|
+
never picks one.
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
Register the extension on any client implementing Sui's Core API
|
|
51
|
+
([SDK building guidelines](https://sdk.mystenlabs.com/sui/sdk-building)):
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
55
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
56
|
+
import { misoPlatform } from "@misofm/sdk";
|
|
57
|
+
|
|
58
|
+
const client = new SuiGrpcClient({ network: "testnet", baseUrl }).$extend(
|
|
59
|
+
misoPlatform({ packageId: MISO_PRESSING_PACKAGE_ID, settingsId: MISO_RECORD_SETTINGS_ID }),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// Read: run + one currency's offer, one round trip, no registry lookup.
|
|
63
|
+
const { pressing, listing } = await client.misoPlatform.getSale({
|
|
64
|
+
releaseId,
|
|
65
|
+
currencyType: USD_COIN_TYPE,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Write: a thunk, so it composes with protocol calls in the same PTB.
|
|
69
|
+
const tx = new Transaction();
|
|
70
|
+
tx.add(
|
|
71
|
+
client.misoPlatform.tx.buyRecord({
|
|
72
|
+
releaseId,
|
|
73
|
+
currencyType: USD_COIN_TYPE,
|
|
74
|
+
amount: listing.price.amount,
|
|
75
|
+
recipient: buyer,
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Holding the ids yourself? Every builder and reader is exported bare, taking
|
|
81
|
+
`misoPressingPackageId` per call:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { buyRecord, getSale } from "@misofm/sdk/pressing";
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Payment
|
|
88
|
+
|
|
89
|
+
`listing::buy` takes a bare `Balance<Currency>`, and `buyRecord` sources it with
|
|
90
|
+
`tx.balance()` — which draws from the buyer's **address balance** first and falls back
|
|
91
|
+
to coin objects only if it must. When the address balance covers the price, that is a
|
|
92
|
+
single `balance::redeem_funds` and **no coin object is minted, touched, or destroyed**,
|
|
93
|
+
leaving the sale free of owned-object contention.
|
|
94
|
+
|
|
95
|
+
Never hand-pick coin objects for a payment. That road shows a buyer their $1,000 and
|
|
96
|
+
then refuses to spend a cent of it, because a coin listing cannot see money that lives
|
|
97
|
+
in the address balance.
|
|
98
|
+
|
|
99
|
+
Purchases through Miso are sponsored, so `useGasCoin` defaults to `false`: the gas coin
|
|
100
|
+
belongs to the sponsor, and drawing a SUI payment out of it would spend the wrong
|
|
101
|
+
wallet's money.
|
|
102
|
+
|
|
103
|
+
## Publishing (`transactions.ts`, `share.ts`, `release-graph.ts`)
|
|
104
|
+
|
|
105
|
+
`@misonetwork/sdk`'s `createComposition`/`createRecording` mint a work and hand
|
|
106
|
+
back its by-value parts (the object, its admin cap, its freshly-minted share
|
|
107
|
+
`Balance`) without dispersing, sharing, or transferring anything. This package
|
|
108
|
+
supplies the opinionated finish on top:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { misoPlatform } from "@misofm/sdk";
|
|
112
|
+
|
|
113
|
+
const client = new SuiGrpcClient({ network: "testnet", baseUrl }).$extend(
|
|
114
|
+
misoPlatform({
|
|
115
|
+
packageId: MISO_PRESSING_PACKAGE_ID,
|
|
116
|
+
misoPackageId: MISO_PROTOCOL_PACKAGE_ID, // required for publish builders
|
|
117
|
+
minatoPackageId: MINATO_PACKAGE_ID, // required — they disperse shares via minato
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Mints the composition's share supply, disperses it to shareRecipients via
|
|
122
|
+
// minato, publishes (shares) the composition, and transfers the
|
|
123
|
+
// CompositionAdminCap to adminAddress — createComposition → finalizeComposition
|
|
124
|
+
// in one PTB.
|
|
125
|
+
const thunk = client.misoPlatform.tx.publishComposition({
|
|
126
|
+
title: "Song Title",
|
|
127
|
+
royaltyRateBps: 1000,
|
|
128
|
+
shareType: "0x...::share::Share",
|
|
129
|
+
shareCurrencyId: "0x...",
|
|
130
|
+
shareTreasuryCapId: "0x...",
|
|
131
|
+
shareRecipients: [{ address: ownerAddress, value: 10_000_000_000_000 }],
|
|
132
|
+
adminAddress: ownerAddress,
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`client.misoPlatform.tx.publishRecording` and `publishCompositionAndRecording`
|
|
137
|
+
follow the same shape (the latter atomically, borrow-before-share, in one PTB —
|
|
138
|
+
see `@misonetwork/sdk`'s README for why the ordering is load-bearing).
|
|
139
|
+
`misoPackageId`/`minatoPackageId` are optional on the client — a sell-only
|
|
140
|
+
client (e.g. a storefront that never mints new works) can omit them; the
|
|
141
|
+
publish builders throw at call time, not at client construction, if they're
|
|
142
|
+
missing.
|
|
143
|
+
|
|
144
|
+
For custom PTBs, the bare primitives (`disperseShares`, `finalizeComposition`,
|
|
145
|
+
`finalizeRecording`) and the whole-graph orchestrator are exported standalone:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { publishReleaseGraph } from "@misofm/sdk";
|
|
149
|
+
|
|
150
|
+
// Every composition and recording, optional royalty pools, deals/tracks, and
|
|
151
|
+
// the release — with the release id derived ON-CHAIN — in one atomic PTB.
|
|
152
|
+
const thunk = publishReleaseGraph({
|
|
153
|
+
compositions: [{ shareType, shareCurrencyId, shareTreasuryCapId, title: "Song", royaltyRateBps: 1000, shareRecipients, adminAddress }],
|
|
154
|
+
recordings: [{ shareType, shareCurrencyId, shareTreasuryCapId, compositionShareType, parentCompositionIndex: 0, shareRecipients, adminAddress }],
|
|
155
|
+
release: {
|
|
156
|
+
title: "Album",
|
|
157
|
+
nonce: "42",
|
|
158
|
+
adminAddress,
|
|
159
|
+
releaseRegistryId: "0x...",
|
|
160
|
+
tracks: [{ recordingIndex: 0, splitBps: 10000 }],
|
|
161
|
+
},
|
|
162
|
+
misoPackageId: "0x...",
|
|
163
|
+
minatoPackageId: "0x...",
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Share Currency Provisioning (`share.ts`)
|
|
168
|
+
|
|
169
|
+
Every composition and recording is backed by its own fixed-supply share
|
|
170
|
+
currency: an independently published `share` package (bytecode template
|
|
171
|
+
embedded as `SHARE_TEMPLATE`, initializer patched via `patchInitializer`).
|
|
172
|
+
Publish and initialize are necessarily two transactions:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
// Sequential (one currency, two txs):
|
|
176
|
+
const currency = await client.misoPlatform.createShareCurrency(signer, {
|
|
177
|
+
name: "Song Shares",
|
|
178
|
+
description: "…",
|
|
179
|
+
});
|
|
180
|
+
// → { packageId, currencyId, shareType, treasuryCapId, gasUsed }
|
|
181
|
+
|
|
182
|
+
// Batched (many currencies, via a ParallelTransactionExecutor):
|
|
183
|
+
import { publishShareCurrencies, initializeShareCurrencies } from "@misofm/sdk";
|
|
184
|
+
const { packageIds } = await publishShareCurrencies(executor, initializerAddress, 10);
|
|
185
|
+
const { currencies } = await initializeShareCurrencies(executor, signerAddress, packageIds, (pkg) => ({
|
|
186
|
+
name: "…", description: "…",
|
|
187
|
+
}));
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`executeViaExecutor(executor, ...thunks)` (`execute.ts`) submits a
|
|
191
|
+
non-idempotent PTB through a `ParallelTransactionExecutor` exactly once (no
|
|
192
|
+
auto-retry) — it's what the batched provisioning above builds on, layered over
|
|
193
|
+
`@misonetwork/sdk`'s transport-agnostic `buildTx`/`toExecResult`.
|
|
194
|
+
|
|
195
|
+
## Layout
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
src/
|
|
199
|
+
client.ts the client extension — misoPlatform({ packageId, settingsId, misoPackageId?, minatoPackageId? })
|
|
200
|
+
pressing.ts facade: builders, readers, and the id derivations
|
|
201
|
+
queries.ts shared read plumbing (isNotFound)
|
|
202
|
+
transactions.ts the TxThunk contract + the opinionated publish flow (disperse/finalize/publish*)
|
|
203
|
+
release-graph.ts whole release graph in one PTB (publishReleaseGraph)
|
|
204
|
+
share.ts share-currency provisioning (createShareCurrency, batched variants)
|
|
205
|
+
share-template.ts embedded `share` package bytecode
|
|
206
|
+
execute.ts executeViaExecutor, layered on @misonetwork/sdk's buildTx/toExecResult
|
|
207
|
+
contracts/ GENERATED — do not edit by hand
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Codegen
|
|
211
|
+
|
|
212
|
+
Bindings are generated from the live Move source, so the typed layer cannot drift from
|
|
213
|
+
the on-chain ABI:
|
|
214
|
+
|
|
215
|
+
```sh
|
|
216
|
+
bun run codegen # reads sui-codegen.config.ts → src/contracts/
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
`sui-codegen.config.ts` lists **platform packages only** (currently just
|
|
220
|
+
`miso_pressing`). Protocol packages (`miso`/composition/recording/release and
|
|
221
|
+
its extensions) generate into `@misonetwork/sdk` instead, which this package
|
|
222
|
+
depends on for their typed bindings — adding a protocol package here to save
|
|
223
|
+
an import is how the split this package exists to enforce gets undone.
|
|
224
|
+
|
|
225
|
+
## Dependency on `@misonetwork/sdk`
|
|
226
|
+
|
|
227
|
+
`@misonetwork/sdk` is a `dependencies` entry (not a peer) — this package
|
|
228
|
+
imports its bare primitives and types directly, rather than registering it as
|
|
229
|
+
a second client extension via `$extend`, so it isn't the "avoid bundling two
|
|
230
|
+
copies of a Mysten package" situation the peer-dependency guidance targets.
|
|
231
|
+
`@mysten/sui` itself stays a peer dependency here, same as in
|
|
232
|
+
`@misonetwork/sdk`.
|
|
233
|
+
|
|
234
|
+
`@misonetwork/sdk` is installed from npm like any other dependency — no local
|
|
235
|
+
linking, no workspace, no build step on the consumer side. It ships compiled
|
|
236
|
+
output plus declarations, so this package resolves it the same way a third
|
|
237
|
+
party would.
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
bun install
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
If you are changing both packages at once, `bun link` still works for a local
|
|
244
|
+
loop — register the protocol SDK with `bun link` in its checkout, `bun link
|
|
245
|
+
@misonetwork/sdk` here, and remember to put the version range back before
|
|
246
|
+
committing. Note that `file:` does NOT work for this: Bun copies a `file:`
|
|
247
|
+
dependency while honouring `.gitignore`, and `@misonetwork/sdk` builds to a
|
|
248
|
+
gitignored `dist/`, so the copy arrives empty and nothing resolves.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ClientWithCoreApi } from "@mysten/sui/client";
|
|
2
|
+
import type { SuiGraphQLClient } from "@mysten/sui/graphql";
|
|
3
|
+
import { type Recording } from "@misonetwork/sdk";
|
|
4
|
+
export interface GetAdministeredRecordingsOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Maximum lookups in flight at once. The traversal is one lookup per admin
|
|
7
|
+
* cap, so an artist with a large catalog would otherwise open as many
|
|
8
|
+
* concurrent requests as they have recordings. Defaults to 10.
|
|
9
|
+
*/
|
|
10
|
+
concurrency?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Every `Recording` administered by `owner`.
|
|
14
|
+
*
|
|
15
|
+
* Two stages: list the owner's `RecordingAdminCap`s over the Core API, then
|
|
16
|
+
* resolve each cap's share type back to its recording.
|
|
17
|
+
*
|
|
18
|
+
* The second stage needs GraphQL and is inherently one lookup per cap, because
|
|
19
|
+
* `RecordingAdminCap` carries no back-pointer to its recording — unlike
|
|
20
|
+
* `ReleaseAdminCap`, which stores `release_id` and can therefore be resolved
|
|
21
|
+
* entirely over the Core API. The caps are derived objects (recording → cap via
|
|
22
|
+
* `deriveObjectID`), and that derivation cannot be inverted, so the share type
|
|
23
|
+
* is the only link back. Adding a `recording_id: ID` field to
|
|
24
|
+
* `RecordingAdminCap` on the protocol side would make this a pure Core-API
|
|
25
|
+
* batch read and remove both the GraphQL dependency and the fan-out.
|
|
26
|
+
*
|
|
27
|
+
* Until then the lookups run concurrently in bounded batches rather than
|
|
28
|
+
* serially.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAdministeredRecordings(client: ClientWithCoreApi, graphqlClient: SuiGraphQLClient, owner: string, misoPackageId: string, options?: GetAdministeredRecordingsOptions): Promise<Recording[]>;
|
|
31
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,gCAAgC;IAC/C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,gBAAgB,EAC/B,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,SAAS,EAAE,CAAC,CAsBtB"}
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { getOwnedRecordingAdminCaps, getRecordingByShareType, } from "@misonetwork/sdk";
|
|
4
|
+
/**
|
|
5
|
+
* Every `Recording` administered by `owner`.
|
|
6
|
+
*
|
|
7
|
+
* Two stages: list the owner's `RecordingAdminCap`s over the Core API, then
|
|
8
|
+
* resolve each cap's share type back to its recording.
|
|
9
|
+
*
|
|
10
|
+
* The second stage needs GraphQL and is inherently one lookup per cap, because
|
|
11
|
+
* `RecordingAdminCap` carries no back-pointer to its recording — unlike
|
|
12
|
+
* `ReleaseAdminCap`, which stores `release_id` and can therefore be resolved
|
|
13
|
+
* entirely over the Core API. The caps are derived objects (recording → cap via
|
|
14
|
+
* `deriveObjectID`), and that derivation cannot be inverted, so the share type
|
|
15
|
+
* is the only link back. Adding a `recording_id: ID` field to
|
|
16
|
+
* `RecordingAdminCap` on the protocol side would make this a pure Core-API
|
|
17
|
+
* batch read and remove both the GraphQL dependency and the fan-out.
|
|
18
|
+
*
|
|
19
|
+
* Until then the lookups run concurrently in bounded batches rather than
|
|
20
|
+
* serially.
|
|
21
|
+
*/
|
|
22
|
+
export async function getAdministeredRecordings(client, graphqlClient, owner, misoPackageId, options = {}) {
|
|
23
|
+
const concurrency = Math.max(1, options.concurrency ?? 10);
|
|
24
|
+
const caps = await getOwnedRecordingAdminCaps(client, owner, misoPackageId);
|
|
25
|
+
const recordings = [];
|
|
26
|
+
for (let i = 0; i < caps.length; i += concurrency) {
|
|
27
|
+
const batch = caps.slice(i, i + concurrency);
|
|
28
|
+
const settled = await Promise.all(batch.map(async (cap) => {
|
|
29
|
+
try {
|
|
30
|
+
return await getRecordingByShareType(client, graphqlClient, cap.shareType, misoPackageId);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// A cap whose recording cannot be resolved is skipped rather than
|
|
34
|
+
// failing the whole catalog — matching the previous behavior, where a
|
|
35
|
+
// missing address was silently passed over.
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
for (const rec of settled)
|
|
40
|
+
if (rec)
|
|
41
|
+
recordings.push(rec);
|
|
42
|
+
}
|
|
43
|
+
return recordings;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AActC,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,kBAAkB,CAAC;AAW1B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAyB,EACzB,aAA+B,EAC/B,KAAa,EACb,aAAqB,EACrB,UAA4C,EAAE;IAE9C,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,MAAM,0BAA0B,CAAC,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IAE5E,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACtB,IAAI,CAAC;gBACH,OAAO,MAAM,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YAC5F,CAAC;YAAC,MAAM,CAAC;gBACP,kEAAkE;gBAClE,sEAAsE;gBACtE,4CAA4C;gBAC5C,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CACH,CAAC;QACF,KAAK,MAAM,GAAG,IAAI,OAAO;YAAE,IAAI,GAAG;gBAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|