@misofm/platform 0.0.0 → 0.19.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 +686 -3
- package/dist/auth.d.ts +73 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +193 -0
- package/dist/auth.js.map +1 -0
- package/dist/catalog.d.ts +48 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +92 -0
- package/dist/catalog.js.map +1 -0
- package/dist/client.d.ts +459 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +783 -0
- package/dist/client.js.map +1 -0
- package/dist/contracts.d.ts +33 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +48 -0
- package/dist/contracts.js.map +1 -0
- package/dist/cover.d.ts +69 -0
- package/dist/cover.d.ts.map +1 -0
- package/dist/cover.js +132 -0
- package/dist/cover.js.map +1 -0
- package/dist/credits.d.ts +200 -0
- package/dist/credits.d.ts.map +1 -0
- package/dist/credits.js +465 -0
- package/dist/credits.js.map +1 -0
- package/dist/deployments.d.ts +221 -0
- package/dist/deployments.d.ts.map +1 -0
- package/dist/deployments.js +176 -0
- package/dist/deployments.js.map +1 -0
- package/dist/execute.d.ts +30 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +31 -0
- package/dist/execute.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +13 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +41 -0
- package/dist/internal.js.map +1 -0
- package/dist/mix.d.ts +144 -0
- package/dist/mix.d.ts.map +1 -0
- package/dist/mix.js +656 -0
- package/dist/mix.js.map +1 -0
- package/dist/pressing.d.ts +137 -0
- package/dist/pressing.d.ts.map +1 -0
- package/dist/pressing.js +390 -0
- package/dist/pressing.js.map +1 -0
- package/dist/publication.d.ts +215 -0
- package/dist/publication.d.ts.map +1 -0
- package/dist/publication.js +864 -0
- package/dist/publication.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/read/artist.d.ts +18 -0
- package/dist/read/artist.d.ts.map +1 -0
- package/dist/read/artist.js +86 -0
- package/dist/read/artist.js.map +1 -0
- package/dist/read/catalog.d.ts +93 -0
- package/dist/read/catalog.d.ts.map +1 -0
- package/dist/read/catalog.js +441 -0
- package/dist/read/catalog.js.map +1 -0
- package/dist/read/client.d.ts +37 -0
- package/dist/read/client.d.ts.map +1 -0
- package/dist/read/client.js +50 -0
- package/dist/read/client.js.map +1 -0
- package/dist/read/config.d.ts +68 -0
- package/dist/read/config.d.ts.map +1 -0
- package/dist/read/config.js +63 -0
- package/dist/read/config.js.map +1 -0
- package/dist/read/genres.d.ts +7 -0
- package/dist/read/genres.d.ts.map +1 -0
- package/dist/read/genres.js +38 -0
- package/dist/read/genres.js.map +1 -0
- package/dist/read/index.d.ts +14 -0
- package/dist/read/index.d.ts.map +1 -0
- package/dist/read/index.js +23 -0
- package/dist/read/index.js.map +1 -0
- package/dist/read/internal/scalars.d.ts +23 -0
- package/dist/read/internal/scalars.d.ts.map +1 -0
- package/dist/read/internal/scalars.js +57 -0
- package/dist/read/internal/scalars.js.map +1 -0
- package/dist/read/internal/walrus.d.ts +6 -0
- package/dist/read/internal/walrus.d.ts.map +1 -0
- package/dist/read/internal/walrus.js +29 -0
- package/dist/read/internal/walrus.js.map +1 -0
- package/dist/read/receipts.d.ts +41 -0
- package/dist/read/receipts.d.ts.map +1 -0
- package/dist/read/receipts.js +398 -0
- package/dist/read/receipts.js.map +1 -0
- package/dist/read/types.d.ts +328 -0
- package/dist/read/types.d.ts.map +1 -0
- package/dist/read/types.js +21 -0
- package/dist/read/types.js.map +1 -0
- package/dist/read/wallet.d.ts +74 -0
- package/dist/read/wallet.d.ts.map +1 -0
- package/dist/read/wallet.js +578 -0
- package/dist/read/wallet.js.map +1 -0
- package/dist/read/works.d.ts +29 -0
- package/dist/read/works.d.ts.map +1 -0
- package/dist/read/works.js +191 -0
- package/dist/read/works.js.map +1 -0
- package/dist/recording-extensions.d.ts +58 -0
- package/dist/recording-extensions.d.ts.map +1 -0
- package/dist/recording-extensions.js +148 -0
- package/dist/recording-extensions.js.map +1 -0
- package/dist/release-extensions.d.ts +93 -0
- package/dist/release-extensions.d.ts.map +1 -0
- package/dist/release-extensions.js +190 -0
- package/dist/release-extensions.js.map +1 -0
- package/dist/release-graph.d.ts +65 -0
- package/dist/release-graph.d.ts.map +1 -0
- package/dist/release-graph.js +136 -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 +67 -0
- package/dist/share.d.ts.map +1 -0
- package/dist/share.js +157 -0
- package/dist/share.js.map +1 -0
- package/dist/transactions.d.ts +216 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/transactions.js +314 -0
- package/dist/transactions.js.map +1 -0
- package/dist/vault.d.ts +364 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +507 -0
- package/dist/vault.js.map +1 -0
- package/package.json +145 -5
- package/src/auth.ts +275 -0
- package/src/catalog.ts +189 -0
- package/src/client.ts +1310 -0
- package/src/contracts.ts +53 -0
- package/src/cover.ts +240 -0
- package/src/credits.ts +906 -0
- package/src/deployments.ts +354 -0
- package/src/execute.ts +52 -0
- package/src/index.ts +69 -0
- package/src/internal.ts +46 -0
- package/src/mix.ts +910 -0
- package/src/pressing.ts +705 -0
- package/src/publication.ts +1205 -0
- package/src/queries.ts +9 -0
- package/src/read/artist.ts +118 -0
- package/src/read/catalog.ts +668 -0
- package/src/read/client.ts +87 -0
- package/src/read/config.ts +138 -0
- package/src/read/genres.ts +37 -0
- package/src/read/index.ts +85 -0
- package/src/read/internal/scalars.ts +59 -0
- package/src/read/internal/walrus.ts +42 -0
- package/src/read/receipts.ts +476 -0
- package/src/read/types.ts +415 -0
- package/src/read/wallet.ts +687 -0
- package/src/read/works.ts +297 -0
- package/src/recording-extensions.ts +241 -0
- package/src/release-extensions.ts +311 -0
- package/src/release-graph.ts +219 -0
- package/src/share-template.ts +55 -0
- package/src/share.ts +261 -0
- package/src/transactions.ts +542 -0
- package/src/vault.ts +1009 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
// Copyright (c) Miso Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
//
|
|
4
|
+
// What one record sale actually was, read back from its transaction.
|
|
5
|
+
//
|
|
6
|
+
// The transaction digest plus Record ID is the receipt's identity: everything shown is
|
|
7
|
+
// re-derived from chain state, so a receipt link survives a refresh, a deep link,
|
|
8
|
+
// or a share to another device. `listing::purchase` emits `RecordSoldEvent` carrying
|
|
9
|
+
// the copy that was minted, its number in the run, and what the buyer paid.
|
|
10
|
+
//
|
|
11
|
+
// Two reads, in order, because a receipt is opened at two very different ages:
|
|
12
|
+
// fullnode the fresh path — usually the instant the transaction lands, possibly
|
|
13
|
+
// before this node has it, hence `waitForTransaction`.
|
|
14
|
+
// indexer the old path — GraphQL keeps transactions the fullnode has pruned.
|
|
15
|
+
// This is what makes a months-old receipt link still open.
|
|
16
|
+
//
|
|
17
|
+
// Where the money goes is PRESENTATIONAL, not a second on-chain fact: `purchase`
|
|
18
|
+
// forwards the whole payment to the release's funds accumulator (there is no
|
|
19
|
+
// platform fee), and the royalty layer splits it downstream by the same terms this
|
|
20
|
+
// read walks. We show the buyer that arithmetic, in the same truncating integer
|
|
21
|
+
// math the chain does.
|
|
22
|
+
import * as listingContract from "@misofm/protocol/contracts/miso_record_shop/listing";
|
|
23
|
+
import { extractTypeParams2, getCompositionsByIds, } from "@misofm/protocol";
|
|
24
|
+
import { normalizeStructTag, normalizeSuiAddress } from "@mysten/sui/utils";
|
|
25
|
+
import { getPressingDetail } from "./catalog.js";
|
|
26
|
+
import { int } from "./internal/scalars.js";
|
|
27
|
+
import { requireRecordSalesDeployment } from "../deployments.js";
|
|
28
|
+
import { getWorkAddressesByShareTypes } from "./works.js";
|
|
29
|
+
const BPS = 10000n;
|
|
30
|
+
const U64_MAX = (1n << 64n) - 1n;
|
|
31
|
+
/** `miso_record_shop::listing::RecordSoldEvent<Currency>`. */
|
|
32
|
+
const RECORD_SOLD_EVENT_NAME = "listing::RecordSoldEvent";
|
|
33
|
+
/**
|
|
34
|
+
* How long to wait for the fullnode to have the transaction before falling back
|
|
35
|
+
* to the indexer. Propagation is p95 ~330ms, so this only ever runs long for a
|
|
36
|
+
* digest the node genuinely doesn't have.
|
|
37
|
+
*/
|
|
38
|
+
const FULLNODE_WAIT_MS = 5_000;
|
|
39
|
+
export class MalformedRecordSoldEventError extends Error {
|
|
40
|
+
name = "MalformedRecordSoldEventError";
|
|
41
|
+
}
|
|
42
|
+
function coerceU64(v) {
|
|
43
|
+
const value = typeof v === "bigint"
|
|
44
|
+
? v
|
|
45
|
+
: typeof v === "number" && Number.isSafeInteger(v)
|
|
46
|
+
? BigInt(v)
|
|
47
|
+
: typeof v === "string" && /^\d+$/.test(v)
|
|
48
|
+
? BigInt(v)
|
|
49
|
+
: null;
|
|
50
|
+
return value !== null && value >= 0n && value <= U64_MAX ? value : null;
|
|
51
|
+
}
|
|
52
|
+
function priceFromUnknown(value) {
|
|
53
|
+
if (!value || typeof value !== "object")
|
|
54
|
+
return null;
|
|
55
|
+
const variants = value;
|
|
56
|
+
const fixed = variants.$kind === "Fixed" || Object.hasOwn(variants, "Fixed");
|
|
57
|
+
const floor = variants.$kind === "Floor" || Object.hasOwn(variants, "Floor");
|
|
58
|
+
if (fixed === floor)
|
|
59
|
+
return null;
|
|
60
|
+
const amount = coerceU64(fixed ? variants.Fixed : variants.Floor);
|
|
61
|
+
return amount == null || amount <= 0n
|
|
62
|
+
? null
|
|
63
|
+
: { kind: fixed ? "fixed" : "floor", amount: amount.toString() };
|
|
64
|
+
}
|
|
65
|
+
function typeName(value) {
|
|
66
|
+
const raw = typeof value === "string"
|
|
67
|
+
? value
|
|
68
|
+
: value && typeof value === "object"
|
|
69
|
+
? value.name
|
|
70
|
+
: null;
|
|
71
|
+
if (typeof raw !== "string" || !raw)
|
|
72
|
+
return null;
|
|
73
|
+
try {
|
|
74
|
+
return normalizeStructTag(raw);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function positiveU32(value) {
|
|
81
|
+
const bigint = coerceU64(value);
|
|
82
|
+
return bigint == null || bigint <= 0n || bigint > 0xffffffffn
|
|
83
|
+
? null
|
|
84
|
+
: Number(bigint);
|
|
85
|
+
}
|
|
86
|
+
function positiveU16(value) {
|
|
87
|
+
const number = positiveU32(value);
|
|
88
|
+
return number == null || number > 0xffff ? null : number;
|
|
89
|
+
}
|
|
90
|
+
function validPricingRelationship(purchasePrice, pricing) {
|
|
91
|
+
const configured = BigInt(pricing.amount);
|
|
92
|
+
return pricing.kind === "fixed"
|
|
93
|
+
? purchasePrice === configured
|
|
94
|
+
: purchasePrice >= configured;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The event's JSON projection — the fallback for transports that surface `json`
|
|
98
|
+
* but no BCS. Field names are the Move ones (snake_case).
|
|
99
|
+
*/
|
|
100
|
+
function saleFromJson(json, currencyType) {
|
|
101
|
+
const edition = positiveU16(json.edition);
|
|
102
|
+
const number = positiveU32(json.number);
|
|
103
|
+
const purchasePrice = coerceU64(json.purchase_price);
|
|
104
|
+
const purchasedTimestampMs = coerceU64(json.purchased_timestamp_ms);
|
|
105
|
+
const recordId = json.record_id;
|
|
106
|
+
const pricing = priceFromUnknown(json.pricing);
|
|
107
|
+
const embeddedCurrency = typeName(json.purchase_currency);
|
|
108
|
+
if (edition == null ||
|
|
109
|
+
number == null ||
|
|
110
|
+
purchasePrice == null || purchasePrice <= 0n ||
|
|
111
|
+
purchasedTimestampMs == null ||
|
|
112
|
+
!pricing || !validPricingRelationship(purchasePrice, pricing) ||
|
|
113
|
+
embeddedCurrency !== currencyType ||
|
|
114
|
+
typeof recordId !== "string" || !recordId ||
|
|
115
|
+
typeof json.listing_id !== "string" || !json.listing_id ||
|
|
116
|
+
typeof json.pressing_id !== "string" || !json.pressing_id ||
|
|
117
|
+
typeof json.release_id !== "string" || !json.release_id ||
|
|
118
|
+
typeof json.purchased_by !== "string" || !json.purchased_by)
|
|
119
|
+
return null;
|
|
120
|
+
return {
|
|
121
|
+
listingId: json.listing_id,
|
|
122
|
+
pressingId: json.pressing_id,
|
|
123
|
+
releaseId: json.release_id,
|
|
124
|
+
recordId,
|
|
125
|
+
edition,
|
|
126
|
+
number,
|
|
127
|
+
purchaseCurrency: embeddedCurrency,
|
|
128
|
+
purchasePrice: purchasePrice.toString(),
|
|
129
|
+
pricing,
|
|
130
|
+
currencyType,
|
|
131
|
+
purchasedBy: json.purchased_by,
|
|
132
|
+
purchasedTimestampMs: purchasedTimestampMs.toString(),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether `eventType` is this deployment's `listing::RecordSoldEvent<Currency>`.
|
|
137
|
+
*
|
|
138
|
+
* Event BCS is structural, so a same-shaped event from another package must never
|
|
139
|
+
* be decoded as a Miso sale. Normalize both package/type tags and require exactly
|
|
140
|
+
* one (possibly nested) currency type argument.
|
|
141
|
+
*/
|
|
142
|
+
export function recordSoldCurrencyType(eventType, recordShopPackageId) {
|
|
143
|
+
let tag;
|
|
144
|
+
try {
|
|
145
|
+
tag = normalizeStructTag(eventType);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const prefix = `${normalizeSuiAddress(recordShopPackageId)}::${RECORD_SOLD_EVENT_NAME}`;
|
|
151
|
+
if (!tag.startsWith(`${prefix}<`) || !tag.endsWith(">"))
|
|
152
|
+
return null;
|
|
153
|
+
const typeArgument = tag.slice(prefix.length + 1, -1);
|
|
154
|
+
if (!typeArgument)
|
|
155
|
+
return null;
|
|
156
|
+
let depth = 0;
|
|
157
|
+
for (const char of typeArgument) {
|
|
158
|
+
if (char === "<")
|
|
159
|
+
depth += 1;
|
|
160
|
+
else if (char === ">") {
|
|
161
|
+
depth -= 1;
|
|
162
|
+
if (depth < 0)
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
else if (char === "," && depth === 0) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return depth === 0 ? typeArgument : null;
|
|
170
|
+
}
|
|
171
|
+
export function isRecordSoldEventType(eventType, recordShopPackageId) {
|
|
172
|
+
return recordSoldCurrencyType(eventType, recordShopPackageId) !== null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The sale a transaction recorded, or null if it emitted none. BCS is the stable
|
|
176
|
+
* shape (a JSON projection's field names vary by transport), so it is tried first.
|
|
177
|
+
*/
|
|
178
|
+
export function findRecordSales(events, recordShopPackageId) {
|
|
179
|
+
const sales = [];
|
|
180
|
+
for (const e of events) {
|
|
181
|
+
const currencyType = recordSoldCurrencyType(e.eventType, recordShopPackageId);
|
|
182
|
+
if (!currencyType)
|
|
183
|
+
continue;
|
|
184
|
+
try {
|
|
185
|
+
// The generated struct decodes addresses to 0x-hex and u64s to decimal strings.
|
|
186
|
+
const s = listingContract.RecordSoldEvent.parse(e.bcs);
|
|
187
|
+
const pricing = priceFromUnknown(s.pricing);
|
|
188
|
+
const embeddedCurrency = typeName(s.purchase_currency);
|
|
189
|
+
const purchasePrice = BigInt(s.purchase_price);
|
|
190
|
+
if (!pricing || embeddedCurrency !== currencyType ||
|
|
191
|
+
!validPricingRelationship(purchasePrice, pricing) ||
|
|
192
|
+
s.edition <= 0 || s.number <= 0)
|
|
193
|
+
throw new MalformedRecordSoldEventError("malformed canonical RecordSoldEvent");
|
|
194
|
+
sales.push({
|
|
195
|
+
listingId: s.listing_id,
|
|
196
|
+
pressingId: s.pressing_id,
|
|
197
|
+
releaseId: s.release_id,
|
|
198
|
+
recordId: s.record_id,
|
|
199
|
+
edition: s.edition,
|
|
200
|
+
number: s.number,
|
|
201
|
+
purchaseCurrency: embeddedCurrency,
|
|
202
|
+
purchasePrice: s.purchase_price,
|
|
203
|
+
pricing,
|
|
204
|
+
currencyType,
|
|
205
|
+
purchasedBy: s.purchased_by,
|
|
206
|
+
purchasedTimestampMs: s.purchased_timestamp_ms,
|
|
207
|
+
});
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
// Never reinterpret malformed canonical BCS through a looser JSON view.
|
|
212
|
+
if (e.bcs.length > 0) {
|
|
213
|
+
if (error instanceof MalformedRecordSoldEventError)
|
|
214
|
+
throw error;
|
|
215
|
+
throw new MalformedRecordSoldEventError(`malformed canonical RecordSoldEvent BCS: ${error instanceof Error ? error.message : String(error)}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const fromJson = e.json && saleFromJson(e.json, currencyType);
|
|
219
|
+
if (!fromJson)
|
|
220
|
+
throw new MalformedRecordSoldEventError("malformed canonical RecordSoldEvent JSON");
|
|
221
|
+
sales.push(fromJson);
|
|
222
|
+
}
|
|
223
|
+
return sales;
|
|
224
|
+
}
|
|
225
|
+
/** Select one canonical sale by its Record ID. Selection is always explicit. */
|
|
226
|
+
export function findRecordSale(events, recordShopPackageId, recordId) {
|
|
227
|
+
const sales = findRecordSales(events, recordShopPackageId);
|
|
228
|
+
return sales.find((sale) => normalizeSuiAddress(sale.recordId) === normalizeSuiAddress(recordId)) ?? null;
|
|
229
|
+
}
|
|
230
|
+
/** Every canonical sale, read from the fullnode in event order. */
|
|
231
|
+
async function salesFromFullnode(client, txDigest) {
|
|
232
|
+
const result = await client.sui.waitForTransaction({
|
|
233
|
+
digest: txDigest,
|
|
234
|
+
include: { events: true },
|
|
235
|
+
timeout: FULLNODE_WAIT_MS,
|
|
236
|
+
});
|
|
237
|
+
if (result.$kind !== "Transaction" || !result.Transaction.status.success) {
|
|
238
|
+
throw new Error(`Transaction did not succeed: ${txDigest}`);
|
|
239
|
+
}
|
|
240
|
+
const sales = requireRecordSalesDeployment(client.config.recordSales);
|
|
241
|
+
const found = findRecordSales(result.Transaction.events, sales.recordShopPackageId);
|
|
242
|
+
if (found.length === 0)
|
|
243
|
+
throw new Error(`No record purchase in transaction ${txDigest}`);
|
|
244
|
+
return found;
|
|
245
|
+
}
|
|
246
|
+
const TX_EVENTS_QUERY = `query TransactionEvents($digest: String!) {
|
|
247
|
+
transaction(digest: $digest) {
|
|
248
|
+
effects {
|
|
249
|
+
status
|
|
250
|
+
events { nodes { contents { type { repr } json } } }
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}`;
|
|
254
|
+
/** Every canonical sale, read from the GraphQL indexer in event order. */
|
|
255
|
+
async function salesFromIndexer(client, txDigest) {
|
|
256
|
+
const { data, errors } = await client.graphqlRaw.query({
|
|
257
|
+
query: TX_EVENTS_QUERY,
|
|
258
|
+
variables: { digest: txDigest },
|
|
259
|
+
});
|
|
260
|
+
if (errors?.length)
|
|
261
|
+
throw new Error(errors[0].message);
|
|
262
|
+
const effects = data?.transaction?.effects;
|
|
263
|
+
if (!effects)
|
|
264
|
+
throw new Error(`Transaction not found: ${txDigest}`);
|
|
265
|
+
if (effects.status !== "SUCCESS")
|
|
266
|
+
throw new Error(`Transaction did not succeed: ${txDigest}`);
|
|
267
|
+
const salesDeployment = requireRecordSalesDeployment(client.config.recordSales);
|
|
268
|
+
const sales = [];
|
|
269
|
+
for (const node of effects.events?.nodes ?? []) {
|
|
270
|
+
const contents = node.contents;
|
|
271
|
+
if (!contents)
|
|
272
|
+
continue;
|
|
273
|
+
const currencyType = recordSoldCurrencyType(contents.type.repr, salesDeployment.recordShopPackageId);
|
|
274
|
+
if (!currencyType)
|
|
275
|
+
continue;
|
|
276
|
+
const sale = typeof contents.json === "object" && contents.json !== null
|
|
277
|
+
? saleFromJson(contents.json, currencyType)
|
|
278
|
+
: null;
|
|
279
|
+
if (!sale)
|
|
280
|
+
throw new MalformedRecordSoldEventError("malformed canonical RecordSoldEvent JSON");
|
|
281
|
+
sales.push(sale);
|
|
282
|
+
}
|
|
283
|
+
if (sales.length > 0)
|
|
284
|
+
return sales;
|
|
285
|
+
throw new Error(`No record purchase in transaction ${txDigest}`);
|
|
286
|
+
}
|
|
287
|
+
async function salesFromChain(client, txDigest) {
|
|
288
|
+
return salesFromFullnode(client, txDigest).catch((error) => {
|
|
289
|
+
if (error instanceof MalformedRecordSoldEventError)
|
|
290
|
+
throw error;
|
|
291
|
+
return salesFromIndexer(client, txDigest);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Each recording's parent composition royalty rate, in basis points, keyed by
|
|
296
|
+
* recording id.
|
|
297
|
+
*
|
|
298
|
+
* A `Recording<RecordingShare, CompositionShare>` names its parent by SHARE TYPE,
|
|
299
|
+
* not by id, so the hop is: recording type tag → composition share type →
|
|
300
|
+
* (GraphQL) composition id → (Core) the composition's `royaltyRate`.
|
|
301
|
+
*
|
|
302
|
+
* Best-effort by design: any failure returns the rates resolved so far, and the
|
|
303
|
+
* receipt drops to a track-level breakdown rather than failing the whole page.
|
|
304
|
+
*/
|
|
305
|
+
async function compositionRatesByRecording(client, recordingIds) {
|
|
306
|
+
if (recordingIds.length === 0)
|
|
307
|
+
return {};
|
|
308
|
+
const shareTypeByRecording = {};
|
|
309
|
+
const { objects } = await client.protocol.core.getObjects({ objectIds: [...new Set(recordingIds)] });
|
|
310
|
+
for (const obj of objects) {
|
|
311
|
+
if (obj instanceof Error || !obj.type)
|
|
312
|
+
continue;
|
|
313
|
+
try {
|
|
314
|
+
const [, compositionShareType] = extractTypeParams2(obj.type);
|
|
315
|
+
shareTypeByRecording[obj.objectId] = compositionShareType;
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
// A recording type we can't read the parent off — skip this track.
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const shareTypes = Object.values(shareTypeByRecording);
|
|
322
|
+
if (shareTypes.length === 0)
|
|
323
|
+
return {};
|
|
324
|
+
const addresses = await getWorkAddressesByShareTypes(client.graphql, { compositions: shareTypes, recordings: [] }, client.config.deployment.miso);
|
|
325
|
+
const compositionIds = Object.values(addresses.compositions).filter((id) => !!id);
|
|
326
|
+
const compositions = await getCompositionsByIds(client.protocol, compositionIds);
|
|
327
|
+
const rates = {};
|
|
328
|
+
for (const [recordingId, shareType] of Object.entries(shareTypeByRecording)) {
|
|
329
|
+
const compositionId = addresses.compositions[shareType];
|
|
330
|
+
const composition = compositionId ? compositions[compositionId] : undefined;
|
|
331
|
+
if (composition)
|
|
332
|
+
rates[recordingId] = int(composition.royaltyRate.value);
|
|
333
|
+
}
|
|
334
|
+
return rates;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Split `paid` across the release's tracks by their `splitBps`, then split each
|
|
338
|
+
* track's share between its composition and its recording. All BigInt — the same
|
|
339
|
+
* truncating integer math the on-chain royalty layer does, so the numbers shown
|
|
340
|
+
* are the numbers paid.
|
|
341
|
+
*/
|
|
342
|
+
export function breakdown(tracks, paid, compositionRates) {
|
|
343
|
+
const paidUnits = BigInt(paid);
|
|
344
|
+
return tracks.map((track) => {
|
|
345
|
+
const amount = (paidUnits * BigInt(track.splitBps)) / BPS;
|
|
346
|
+
const rate = compositionRates[track.recordingId];
|
|
347
|
+
const base = {
|
|
348
|
+
no: track.no,
|
|
349
|
+
title: track.title,
|
|
350
|
+
recordingId: track.recordingId,
|
|
351
|
+
splitBps: track.splitBps,
|
|
352
|
+
amount: amount.toString(),
|
|
353
|
+
};
|
|
354
|
+
if (rate == null)
|
|
355
|
+
return { ...base, composition: null, recording: null };
|
|
356
|
+
const composition = (amount * BigInt(rate)) / BPS;
|
|
357
|
+
return { ...base, composition: composition.toString(), recording: (amount - composition).toString() };
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* The receipt for `txDigest`. The event identifies the exact immutable Pressing
|
|
362
|
+
* and Listing; callers cannot accidentally reinterpret a Pressing id as an
|
|
363
|
+
* obsolete sale-object id.
|
|
364
|
+
*
|
|
365
|
+
* The sale identifies the Pressing before its detail is fetched. `null` only when
|
|
366
|
+
* that immutable Pressing cannot be read; it is never superseded or destroyed.
|
|
367
|
+
*/
|
|
368
|
+
async function hydratePurchaseReceipt(client, sale) {
|
|
369
|
+
const detail = await getPressingDetail(client, sale.pressingId);
|
|
370
|
+
if (!detail)
|
|
371
|
+
return null;
|
|
372
|
+
// Best-effort: a failed composition lookup costs the sub-rows, not the page.
|
|
373
|
+
const rates = await compositionRatesByRecording(client, detail.release.tracks.map((t) => t.recordingId)).catch(() => ({}));
|
|
374
|
+
return {
|
|
375
|
+
sale,
|
|
376
|
+
detail,
|
|
377
|
+
price: sale.pricing.amount,
|
|
378
|
+
tracks: breakdown(detail.release.tracks, sale.purchasePrice, rates),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
/** Read and hydrate every canonical Record sale in transaction event order. */
|
|
382
|
+
export async function getPurchaseReceipts(client, txDigest) {
|
|
383
|
+
const sales = await salesFromChain(client, txDigest);
|
|
384
|
+
const hydrated = await Promise.all(sales.map((sale) => hydratePurchaseReceipt(client, sale)));
|
|
385
|
+
if (hydrated.some((receipt) => receipt === null)) {
|
|
386
|
+
throw new Error(`A canonical Record sale in transaction ${txDigest} references an unreadable Pressing`);
|
|
387
|
+
}
|
|
388
|
+
return hydrated;
|
|
389
|
+
}
|
|
390
|
+
/** Read one canonical receipt selected by its Record ID. Selection is mandatory:
|
|
391
|
+
* one transaction may purchase multiple Records from the same Pressing. */
|
|
392
|
+
export async function getPurchaseReceipt(client, txDigest, recordId) {
|
|
393
|
+
const sales = await salesFromChain(client, txDigest);
|
|
394
|
+
const wanted = normalizeSuiAddress(recordId);
|
|
395
|
+
const sale = sales.find((candidate) => normalizeSuiAddress(candidate.recordId) === wanted);
|
|
396
|
+
return sale ? hydratePurchaseReceipt(client, sale) : null;
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=receipts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receipts.js","sourceRoot":"","sources":["../../src/read/receipts.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,sCAAsC;AACtC,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,uFAAuF;AACvF,kFAAkF;AAClF,qFAAqF;AACrF,4EAA4E;AAC5E,EAAE;AACF,+EAA+E;AAC/E,mFAAmF;AACnF,mEAAmE;AACnE,iFAAiF;AACjF,uEAAuE;AACvE,EAAE;AACF,iFAAiF;AACjF,6EAA6E;AAC7E,mFAAmF;AACnF,gFAAgF;AAChF,uBAAuB;AAEvB,OAAO,KAAK,eAAe,MAAM,qDAAqD,CAAC;AACvF,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,GAAG,GAAG,MAAO,CAAC;AACpB,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AAEjC,8DAA8D;AAC9D,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAE1D;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACpC,IAAI,GAAG,+BAA+B,CAAC;CAC1D;AAKD,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