@6529-collections/stream-sdk 0.0.0-stage → 0.1.0-bootstrap.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 (148) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +4 -0
  4. package/README.md +413 -2
  5. package/dist/actions/accounts.d.ts +58 -0
  6. package/dist/actions/accounts.js +73 -0
  7. package/dist/actions/content.d.ts +22 -0
  8. package/dist/actions/content.js +45 -0
  9. package/dist/actions/curated.d.ts +177 -0
  10. package/dist/actions/curated.js +279 -0
  11. package/dist/actions/editions.d.ts +100 -0
  12. package/dist/actions/editions.js +161 -0
  13. package/dist/actions/independent.d.ts +149 -0
  14. package/dist/actions/independent.js +274 -0
  15. package/dist/actions/money.d.ts +117 -0
  16. package/dist/actions/money.js +148 -0
  17. package/dist/actions/record.d.ts +144 -0
  18. package/dist/actions/record.js +229 -0
  19. package/dist/actions/sale.d.ts +82 -0
  20. package/dist/actions/sale.js +113 -0
  21. package/dist/actions/shared.d.ts +40 -0
  22. package/dist/actions/shared.js +70 -0
  23. package/dist/actions/vault.d.ts +58 -0
  24. package/dist/actions/vault.js +94 -0
  25. package/dist/constants.d.ts +130 -0
  26. package/dist/constants.js +65 -0
  27. package/dist/display.d.ts +31 -0
  28. package/dist/display.js +28 -0
  29. package/dist/encoding.d.ts +110 -0
  30. package/dist/encoding.js +138 -0
  31. package/dist/errors.d.ts +76 -0
  32. package/dist/errors.js +66 -0
  33. package/dist/files/fetch.d.ts +85 -0
  34. package/dist/files/fetch.js +208 -0
  35. package/dist/files/verify.d.ts +36 -0
  36. package/dist/files/verify.js +125 -0
  37. package/dist/generated/abis/AccessManager.d.ts +1125 -0
  38. package/dist/generated/abis/AccessManager.js +1471 -0
  39. package/dist/generated/abis/Accounts.d.ts +1568 -0
  40. package/dist/generated/abis/Accounts.js +2049 -0
  41. package/dist/generated/abis/ClaimRouter.d.ts +343 -0
  42. package/dist/generated/abis/ClaimRouter.js +452 -0
  43. package/dist/generated/abis/ConsolidationAdapter.d.ts +97 -0
  44. package/dist/generated/abis/ConsolidationAdapter.js +133 -0
  45. package/dist/generated/abis/ContentStore.d.ts +812 -0
  46. package/dist/generated/abis/ContentStore.js +1073 -0
  47. package/dist/generated/abis/EconomicsResolver.d.ts +586 -0
  48. package/dist/generated/abis/EconomicsResolver.js +769 -0
  49. package/dist/generated/abis/Eip712CurationVerifier.d.ts +304 -0
  50. package/dist/generated/abis/Eip712CurationVerifier.js +406 -0
  51. package/dist/generated/abis/EnglishAuction.d.ts +1435 -0
  52. package/dist/generated/abis/EnglishAuction.js +1865 -0
  53. package/dist/generated/abis/GovernedVault.d.ts +468 -0
  54. package/dist/generated/abis/GovernedVault.js +617 -0
  55. package/dist/generated/abis/IndependentEditionAuction.d.ts +2373 -0
  56. package/dist/generated/abis/IndependentEditionAuction.js +3076 -0
  57. package/dist/generated/abis/IndependentStream6529.d.ts +1408 -0
  58. package/dist/generated/abis/IndependentStream6529.js +1834 -0
  59. package/dist/generated/abis/IndependentStreamDeployer.d.ts +141 -0
  60. package/dist/generated/abis/IndependentStreamDeployer.js +188 -0
  61. package/dist/generated/abis/IndependentStreamEditions6529.d.ts +963 -0
  62. package/dist/generated/abis/IndependentStreamEditions6529.js +1253 -0
  63. package/dist/generated/abis/IndependentStreamRegistry.d.ts +1351 -0
  64. package/dist/generated/abis/IndependentStreamRegistry.js +1755 -0
  65. package/dist/generated/abis/PackageRegistry.d.ts +1205 -0
  66. package/dist/generated/abis/PackageRegistry.js +1573 -0
  67. package/dist/generated/abis/RevenueEscrow.d.ts +626 -0
  68. package/dist/generated/abis/RevenueEscrow.js +820 -0
  69. package/dist/generated/abis/SaleStarter.d.ts +48 -0
  70. package/dist/generated/abis/SaleStarter.js +67 -0
  71. package/dist/generated/abis/SepoliaOpenGate.d.ts +317 -0
  72. package/dist/generated/abis/SepoliaOpenGate.js +419 -0
  73. package/dist/generated/abis/SplitLedger.d.ts +1097 -0
  74. package/dist/generated/abis/SplitLedger.js +1438 -0
  75. package/dist/generated/abis/StatementLog.d.ts +958 -0
  76. package/dist/generated/abis/StatementLog.js +1248 -0
  77. package/dist/generated/abis/Stream6529.d.ts +1490 -0
  78. package/dist/generated/abis/Stream6529.js +1941 -0
  79. package/dist/generated/abis/StreamDirectory6529.d.ts +355 -0
  80. package/dist/generated/abis/StreamDirectory6529.js +468 -0
  81. package/dist/generated/abis/StreamEditions6529.d.ts +1240 -0
  82. package/dist/generated/abis/StreamEditions6529.js +1614 -0
  83. package/dist/generated/abis/StreamTerms.d.ts +312 -0
  84. package/dist/generated/abis/StreamTerms.js +409 -0
  85. package/dist/generated/abis/StreamWorkFacts6529.d.ts +810 -0
  86. package/dist/generated/abis/StreamWorkFacts6529.js +1049 -0
  87. package/dist/generated/abis/UniformEditionAuction.d.ts +2372 -0
  88. package/dist/generated/abis/UniformEditionAuction.js +3074 -0
  89. package/dist/generated/abis/WorkDelivery.d.ts +605 -0
  90. package/dist/generated/abis/WorkDelivery.js +786 -0
  91. package/dist/generated/abis/WorkRules.d.ts +1154 -0
  92. package/dist/generated/abis/WorkRules.js +1501 -0
  93. package/dist/generated/abis/index.d.ts +28 -0
  94. package/dist/generated/abis/index.js +31 -0
  95. package/dist/generated/instances.d.ts +7 -0
  96. package/dist/generated/instances.js +9 -0
  97. package/dist/generated/sepoliaR10.d.ts +1391 -0
  98. package/dist/generated/sepoliaR10.js +1545 -0
  99. package/dist/hashing/content.d.ts +42 -0
  100. package/dist/hashing/content.js +54 -0
  101. package/dist/hashing/ids.d.ts +67 -0
  102. package/dist/hashing/ids.js +73 -0
  103. package/dist/hashing/items.d.ts +30 -0
  104. package/dist/hashing/items.js +44 -0
  105. package/dist/hashing/packages.d.ts +35 -0
  106. package/dist/hashing/packages.js +76 -0
  107. package/dist/hashing/vault.d.ts +17 -0
  108. package/dist/hashing/vault.js +37 -0
  109. package/dist/hashing/workState.d.ts +31 -0
  110. package/dist/hashing/workState.js +37 -0
  111. package/dist/index.d.ts +44 -0
  112. package/dist/index.js +47 -0
  113. package/dist/instance.d.ts +236 -0
  114. package/dist/instance.js +99 -0
  115. package/dist/items.d.ts +85 -0
  116. package/dist/items.js +144 -0
  117. package/dist/reads/accounts.d.ts +86 -0
  118. package/dist/reads/accounts.js +121 -0
  119. package/dist/reads/chain.d.ts +54 -0
  120. package/dist/reads/chain.js +133 -0
  121. package/dist/reads/creation.d.ts +139 -0
  122. package/dist/reads/creation.js +256 -0
  123. package/dist/reads/editionSale.d.ts +120 -0
  124. package/dist/reads/editionSale.js +182 -0
  125. package/dist/reads/metadata.d.ts +195 -0
  126. package/dist/reads/metadata.js +191 -0
  127. package/dist/reads/money.d.ts +51 -0
  128. package/dist/reads/money.js +68 -0
  129. package/dist/reads/network.d.ts +137 -0
  130. package/dist/reads/network.js +157 -0
  131. package/dist/reads/sale.d.ts +94 -0
  132. package/dist/reads/sale.js +133 -0
  133. package/dist/reads/vault.d.ts +47 -0
  134. package/dist/reads/vault.js +75 -0
  135. package/dist/reads/work.d.ts +293 -0
  136. package/dist/reads/work.js +338 -0
  137. package/dist/reads/workPage.d.ts +197 -0
  138. package/dist/reads/workPage.js +169 -0
  139. package/dist/signing/messages.d.ts +679 -0
  140. package/dist/signing/messages.js +397 -0
  141. package/dist/testing.d.ts +17 -0
  142. package/dist/testing.js +18 -0
  143. package/dist/types.d.ts +167 -0
  144. package/dist/types.js +14 -0
  145. package/docs/publishing.md +54 -0
  146. package/docs/reference.md +335 -0
  147. package/docs/using-from-a-site.md +175 -0
  148. package/package.json +93 -4
@@ -0,0 +1,397 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { concat } from "viem";
3
+ function domainOf(where) {
4
+ return { name: where.name, version: where.version, chainId: where.chainId, verifyingContract: where.verifyingContract };
5
+ }
6
+ /** The signing domain of each contract of an instance. */
7
+ export function signingDomains(instance) {
8
+ const at = (contract, verifyingContract) => ({
9
+ name: instance.protocol.domainNames[contract],
10
+ version: instance.protocol.domainVersions[contract],
11
+ chainId: instance.chainId,
12
+ verifyingContract,
13
+ });
14
+ return {
15
+ packageRegistry: at("packageRegistry", instance.addresses.packageRegistry),
16
+ curationVerifier: at("curationVerifier", instance.addresses.curationVerifier),
17
+ accounts: at("accounts", instance.addresses.accounts),
18
+ workRules: at("workRules", instance.addresses.workRules),
19
+ splitLedger: at("splitLedger", instance.addresses.splitLedger),
20
+ statementLog: at("statementLog", instance.addresses.statementLog),
21
+ };
22
+ }
23
+ /**
24
+ * The proof form the contracts read a wallet's signature in: the wallet's 20 bytes followed
25
+ * by its signature (`abi.encodePacked(wallet, signature)`).
26
+ *
27
+ * Contract: [`Accounts.requireSigned`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol).
28
+ */
29
+ export function walletProof(wallet, signature) {
30
+ return concat([wallet, signature]).toLowerCase();
31
+ }
32
+ // ----------------------------------------------------------------------- package registry
33
+ /**
34
+ * A party accepts a package root. The first acceptance of a wallet creates its account with
35
+ * these profile fields; every later one must repeat the stored fields.
36
+ *
37
+ * Type: `PackageAcceptance(bytes32 packageRoot,address account,bytes32 profileId,bytes32 profileDocHash,uint64 deadline)`
38
+ *
39
+ * Contract: checked by [`PackageRegistry.acceptPackage`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/curation/PackageRegistry.sol);
40
+ * the digest is `PackageRegistry.acceptanceDigest`.
41
+ */
42
+ export function packageAcceptanceTypedData(packageRegistry, packageRoot, acceptance) {
43
+ return {
44
+ domain: domainOf(packageRegistry),
45
+ types: {
46
+ PackageAcceptance: [
47
+ { name: "packageRoot", type: "bytes32" },
48
+ { name: "account", type: "address" },
49
+ { name: "profileId", type: "bytes32" },
50
+ { name: "profileDocHash", type: "bytes32" },
51
+ { name: "deadline", type: "uint64" },
52
+ ],
53
+ },
54
+ primaryType: "PackageAcceptance",
55
+ message: {
56
+ packageRoot,
57
+ account: acceptance.account,
58
+ profileId: acceptance.profileId,
59
+ profileDocHash: acceptance.profileDocHash,
60
+ deadline: acceptance.deadline,
61
+ },
62
+ };
63
+ }
64
+ /**
65
+ * The lead artist moves an approved item to Stream: the signature that lets anyone start the
66
+ * work's sale, once.
67
+ *
68
+ * Type: `MoveToStream(bytes32 packageRoot,bytes32 itemHash,uint256 nonce,uint64 deadline)`
69
+ *
70
+ * Contract: checked by [`PackageRegistry.authorize`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/curation/PackageRegistry.sol)
71
+ * when a sale starts; the digest is `PackageRegistry.moveDigest`.
72
+ */
73
+ export function moveToStreamTypedData(packageRegistry, move) {
74
+ return {
75
+ domain: domainOf(packageRegistry),
76
+ types: {
77
+ MoveToStream: [
78
+ { name: "packageRoot", type: "bytes32" },
79
+ { name: "itemHash", type: "bytes32" },
80
+ { name: "nonce", type: "uint256" },
81
+ { name: "deadline", type: "uint64" },
82
+ ],
83
+ },
84
+ primaryType: "MoveToStream",
85
+ message: { packageRoot: move.packageRoot, itemHash: move.itemHash, nonce: move.nonce, deadline: move.deadline },
86
+ };
87
+ }
88
+ /**
89
+ * A curation signer approves a package root. Only an account holding the curation signer role
90
+ * can make a signature the registry accepts.
91
+ *
92
+ * Type: `PackageApproval(bytes32 packageRoot,bytes32 evidenceHash,uint256 signerEpoch)`
93
+ *
94
+ * Contract: checked by [`Eip712CurationVerifier`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/curation/Eip712CurationVerifier.sol)
95
+ * for `PackageRegistry.registerPackage`; the digest is `approvalDigest`. The attestation the
96
+ * registry takes is `abi.encode(signer, signature)`.
97
+ */
98
+ export function packageApprovalTypedData(curationVerifier, approval) {
99
+ return {
100
+ domain: domainOf(curationVerifier),
101
+ types: {
102
+ PackageApproval: [
103
+ { name: "packageRoot", type: "bytes32" },
104
+ { name: "evidenceHash", type: "bytes32" },
105
+ { name: "signerEpoch", type: "uint256" },
106
+ ],
107
+ },
108
+ primaryType: "PackageApproval",
109
+ message: { packageRoot: approval.packageRoot, evidenceHash: approval.evidenceHash, signerEpoch: approval.signerEpoch },
110
+ };
111
+ }
112
+ // ----------------------------------------------------------------------- accounts
113
+ /**
114
+ * A wallet agrees to the account the Independent Stream module creates for it when it lists
115
+ * its first contract.
116
+ *
117
+ * Type: `ArtistRegistration(address account,bytes32 profileId,bytes32 profileDocHash,uint64 deadline)`
118
+ *
119
+ * Contract: checked by [`Accounts.registerIndependent`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol),
120
+ * called from `IndependentStreamRegistry.register`; the digest is `Accounts.registrationDigest`.
121
+ */
122
+ export function artistRegistrationTypedData(accounts, registration) {
123
+ return {
124
+ domain: domainOf(accounts),
125
+ types: {
126
+ ArtistRegistration: [
127
+ { name: "account", type: "address" },
128
+ { name: "profileId", type: "bytes32" },
129
+ { name: "profileDocHash", type: "bytes32" },
130
+ { name: "deadline", type: "uint64" },
131
+ ],
132
+ },
133
+ primaryType: "ArtistRegistration",
134
+ message: {
135
+ account: registration.account,
136
+ profileId: registration.profileId,
137
+ profileDocHash: registration.profileDocHash,
138
+ deadline: registration.deadline,
139
+ },
140
+ };
141
+ }
142
+ /**
143
+ * An account consents to `what`, for the contract `subject` only. There is no deadline and no
144
+ * nonce in the message: where one is needed it is inside `what` (see `listingSubject`).
145
+ *
146
+ * `what` is a hash: build it with `listingSubject` or `independentConsent` from values the
147
+ * signer can see, never from a value an RPC answered.
148
+ *
149
+ * Type: `Consent(address subject,bytes32 what)`
150
+ *
151
+ * Contract: checked by [`Accounts.requireConsent`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol),
152
+ * where `subject` is the calling contract; the digest is `Accounts.consentDigest`.
153
+ */
154
+ export function consentTypedData(accounts, consent) {
155
+ return {
156
+ domain: domainOf(accounts),
157
+ types: {
158
+ Consent: [
159
+ { name: "subject", type: "address" },
160
+ { name: "what", type: "bytes32" },
161
+ ],
162
+ },
163
+ primaryType: "Consent",
164
+ message: { subject: consent.subject, what: consent.what },
165
+ };
166
+ }
167
+ /**
168
+ * An account's own identity change, signed by any wallet of the account.
169
+ *
170
+ * Type: `IdentityChange(uint256 artistId,address root,address payout,bytes32 profileId,bytes32 profileDocHash,uint256 nonce,uint64 deadline)`
171
+ *
172
+ * Contract: checked by [`Accounts`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol)
173
+ * when the change is staged; the digest is `Accounts.changeDigest`. `nonce` is
174
+ * `Accounts.changeNonce(artistId)`.
175
+ */
176
+ export function identityChangeTypedData(accounts, change) {
177
+ return {
178
+ domain: domainOf(accounts),
179
+ types: {
180
+ IdentityChange: [
181
+ { name: "artistId", type: "uint256" },
182
+ { name: "root", type: "address" },
183
+ { name: "payout", type: "address" },
184
+ { name: "profileId", type: "bytes32" },
185
+ { name: "profileDocHash", type: "bytes32" },
186
+ { name: "nonce", type: "uint256" },
187
+ { name: "deadline", type: "uint64" },
188
+ ],
189
+ },
190
+ primaryType: "IdentityChange",
191
+ message: {
192
+ artistId: change.artistId,
193
+ root: change.next.root,
194
+ payout: change.next.payout,
195
+ profileId: change.next.profileId,
196
+ profileDocHash: change.next.profileDocHash,
197
+ nonce: change.nonce,
198
+ deadline: change.deadline,
199
+ },
200
+ };
201
+ }
202
+ /**
203
+ * The new root accepts a replacement of an account's root by the network.
204
+ *
205
+ * Type: `ReplacementAcceptance(uint256 artistId,address root,address payout,bytes32 profileId,bytes32 profileDocHash,bytes32 evidenceHash,uint64 deadline)`
206
+ *
207
+ * Contract: checked by [`Accounts`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol);
208
+ * the digest is `Accounts.replacementDigest`.
209
+ */
210
+ export function replacementAcceptanceTypedData(accounts, replacement) {
211
+ return {
212
+ domain: domainOf(accounts),
213
+ types: {
214
+ ReplacementAcceptance: [
215
+ { name: "artistId", type: "uint256" },
216
+ { name: "root", type: "address" },
217
+ { name: "payout", type: "address" },
218
+ { name: "profileId", type: "bytes32" },
219
+ { name: "profileDocHash", type: "bytes32" },
220
+ { name: "evidenceHash", type: "bytes32" },
221
+ { name: "deadline", type: "uint64" },
222
+ ],
223
+ },
224
+ primaryType: "ReplacementAcceptance",
225
+ message: {
226
+ artistId: replacement.artistId,
227
+ root: replacement.next.root,
228
+ payout: replacement.next.payout,
229
+ profileId: replacement.next.profileId,
230
+ profileDocHash: replacement.next.profileDocHash,
231
+ evidenceHash: replacement.evidenceHash,
232
+ deadline: replacement.deadline,
233
+ },
234
+ };
235
+ }
236
+ /**
237
+ * Every party agrees to relicense a work. `licenseKey` is `licenseKey(spdxId)` of the new
238
+ * license and `textFileId` the file ID of its text.
239
+ *
240
+ * Type: `Relicense(address token,uint256 tokenId,bytes32 licenseKey,bytes32 textFileId,bytes32 stateHash,uint64 deadline)`
241
+ *
242
+ * Contract: checked by [`WorkRules.relicense`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/records/WorkRules.sol),
243
+ * one signature per party, and the network makes the call.
244
+ */
245
+ export function relicenseTypedData(workRules, change) {
246
+ return {
247
+ domain: domainOf(workRules),
248
+ types: {
249
+ Relicense: [
250
+ { name: "token", type: "address" },
251
+ { name: "tokenId", type: "uint256" },
252
+ { name: "licenseKey", type: "bytes32" },
253
+ { name: "textFileId", type: "bytes32" },
254
+ { name: "stateHash", type: "bytes32" },
255
+ { name: "deadline", type: "uint64" },
256
+ ],
257
+ },
258
+ primaryType: "Relicense",
259
+ message: {
260
+ token: change.token,
261
+ tokenId: change.tokenId,
262
+ licenseKey: change.licenseKey,
263
+ textFileId: change.textFileId,
264
+ stateHash: change.stateHash,
265
+ deadline: change.deadline,
266
+ },
267
+ };
268
+ }
269
+ /**
270
+ * Every party agrees to change a work's royalty rate (`rate` out of 100,000).
271
+ *
272
+ * Type: `RoyaltyRateChange(address token,uint256 tokenId,uint24 rate,bytes32 stateHash,uint64 deadline)`
273
+ *
274
+ * Contract: checked by [`WorkRules.setRoyaltyRate`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/records/WorkRules.sol),
275
+ * one signature per party, and the network makes the call.
276
+ */
277
+ export function royaltyRateChangeTypedData(workRules, change) {
278
+ return {
279
+ domain: domainOf(workRules),
280
+ types: {
281
+ RoyaltyRateChange: [
282
+ { name: "token", type: "address" },
283
+ { name: "tokenId", type: "uint256" },
284
+ { name: "rate", type: "uint24" },
285
+ { name: "stateHash", type: "bytes32" },
286
+ { name: "deadline", type: "uint64" },
287
+ ],
288
+ },
289
+ primaryType: "RoyaltyRateChange",
290
+ message: { token: change.token, tokenId: change.tokenId, rate: change.rate, stateHash: change.stateHash, deadline: change.deadline },
291
+ };
292
+ }
293
+ /**
294
+ * The lead artist gives up powers over a work for good. `powers` is a mask of `WORK_POWERS`.
295
+ *
296
+ * Type: `RenouncePowers(address token,uint256 tokenId,uint16 powers,bytes32 stateHash,uint64 deadline)`
297
+ *
298
+ * Contract: checked by [`WorkRules.renounce`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/records/WorkRules.sol).
299
+ */
300
+ export function renouncePowersTypedData(workRules, change) {
301
+ return {
302
+ domain: domainOf(workRules),
303
+ types: {
304
+ RenouncePowers: [
305
+ { name: "token", type: "address" },
306
+ { name: "tokenId", type: "uint256" },
307
+ { name: "powers", type: "uint16" },
308
+ { name: "stateHash", type: "bytes32" },
309
+ { name: "deadline", type: "uint64" },
310
+ ],
311
+ },
312
+ primaryType: "RenouncePowers",
313
+ message: { token: change.token, tokenId: change.tokenId, powers: change.powers, stateHash: change.stateHash, deadline: change.deadline },
314
+ };
315
+ }
316
+ /**
317
+ * A payee authorizes a release of its share to a recipient, relayed by anyone.
318
+ *
319
+ * Type: `ReleaseAuthorization(address wallet,address asset,uint256 payee,address account,address recipient,uint256 amount,uint256 nonce,uint256 deadline)`
320
+ *
321
+ * Contract: checked by [`SplitLedger.releaseWithAuthorization`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/SplitLedger.sol);
322
+ * the digest is `SplitLedger.releaseDigest`.
323
+ */
324
+ export function releaseAuthorizationTypedData(splitLedger, authorization) {
325
+ return {
326
+ domain: domainOf(splitLedger),
327
+ types: {
328
+ ReleaseAuthorization: [
329
+ { name: "wallet", type: "address" },
330
+ { name: "asset", type: "address" },
331
+ { name: "payee", type: "uint256" },
332
+ { name: "account", type: "address" },
333
+ { name: "recipient", type: "address" },
334
+ { name: "amount", type: "uint256" },
335
+ { name: "nonce", type: "uint256" },
336
+ { name: "deadline", type: "uint256" },
337
+ ],
338
+ },
339
+ primaryType: "ReleaseAuthorization",
340
+ message: {
341
+ wallet: authorization.wallet,
342
+ asset: authorization.asset,
343
+ payee: authorization.payee,
344
+ account: authorization.account,
345
+ recipient: authorization.recipient,
346
+ amount: authorization.amount,
347
+ nonce: authorization.nonce,
348
+ deadline: authorization.deadline,
349
+ },
350
+ };
351
+ }
352
+ /**
353
+ * A signer authorizes one statement in a role, relayed by anyone.
354
+ *
355
+ * Type: `Authorization(uint8 role,address signer,uint256 nonce,uint64 deadline,Statement statement)`
356
+ * with `Statement(address token,uint256 id,bytes32 kind,bytes32 schema,HashRef content,string uri,bytes32 fileId,bytes32 supersedes)`
357
+ * and `HashRef(uint16 algorithm,bytes32 digest)`.
358
+ *
359
+ * Contract: checked by [`StatementLog.appendSigned`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/records/StatementLog.sol);
360
+ * the digest is `StatementLog.authorizationDigest`.
361
+ */
362
+ export function statementAuthorizationTypedData(statementLog, authorization) {
363
+ return {
364
+ domain: domainOf(statementLog),
365
+ types: {
366
+ Authorization: [
367
+ { name: "role", type: "uint8" },
368
+ { name: "signer", type: "address" },
369
+ { name: "nonce", type: "uint256" },
370
+ { name: "deadline", type: "uint64" },
371
+ { name: "statement", type: "Statement" },
372
+ ],
373
+ Statement: [
374
+ { name: "token", type: "address" },
375
+ { name: "id", type: "uint256" },
376
+ { name: "kind", type: "bytes32" },
377
+ { name: "schema", type: "bytes32" },
378
+ { name: "content", type: "HashRef" },
379
+ { name: "uri", type: "string" },
380
+ { name: "fileId", type: "bytes32" },
381
+ { name: "supersedes", type: "bytes32" },
382
+ ],
383
+ HashRef: [
384
+ { name: "algorithm", type: "uint16" },
385
+ { name: "digest", type: "bytes32" },
386
+ ],
387
+ },
388
+ primaryType: "Authorization",
389
+ message: {
390
+ role: authorization.role,
391
+ signer: authorization.signer,
392
+ nonce: authorization.nonce,
393
+ deadline: authorization.deadline,
394
+ statement: authorization.statement,
395
+ },
396
+ };
397
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Helpers for tests and test instances only. They are kept out of the main entry so that
3
+ * nothing here ends up in a real flow by accident.
4
+ */
5
+ import { type Address, type Hex } from "viem";
6
+ export { send, sign, accountOf, assertReady } from "./actions/shared.js";
7
+ export { allowClockDifferenceForTests } from "./reads/chain.js";
8
+ /**
9
+ * Placeholder profile fields for a test account: the values the contracts repository's test
10
+ * flows use. FOR TEST INSTANCES ONLY. A real account's `profileId` is its 6529 profile ID and
11
+ * `profileDocHash` the hash of its profile document, and the first acceptance or listing
12
+ * stores them for good.
13
+ */
14
+ export declare function testProfile(account: Address): {
15
+ profileId: Hex;
16
+ profileDocHash: Hex;
17
+ };
@@ -0,0 +1,18 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Helpers for tests and test instances only. They are kept out of the main entry so that
4
+ * nothing here ends up in a real flow by accident.
5
+ */
6
+ import { encodeAbiParameters, keccak256 } from "viem";
7
+ export { send, sign, accountOf, assertReady } from "./actions/shared.js";
8
+ export { allowClockDifferenceForTests } from "./reads/chain.js";
9
+ /**
10
+ * Placeholder profile fields for a test account: the values the contracts repository's test
11
+ * flows use. FOR TEST INSTANCES ONLY. A real account's `profileId` is its 6529 profile ID and
12
+ * `profileDocHash` the hash of its profile document, and the first acceptance or listing
13
+ * stores them for good.
14
+ */
15
+ export function testProfile(account) {
16
+ const hash = (label) => keccak256(encodeAbiParameters([{ type: "string" }, { type: "address" }], [label, account]));
17
+ return { profileId: hash("6529 profile"), profileDocHash: hash("6529 profile document") };
18
+ }
@@ -0,0 +1,167 @@
1
+ import type { AbiParameterToPrimitiveType, Address, Hex } from "viem";
2
+ /**
3
+ * The ABI shape of `PackageItem` and of `MediaFile[]`, taken from the generated ABI of
4
+ * `StreamWorkFacts6529.open(token, tokenId, item, media)`, so the encodings in this library
5
+ * cannot drift from the contracts.
6
+ */
7
+ export declare const PACKAGE_ITEM_ABI: {
8
+ readonly components: readonly [{
9
+ readonly internalType: "uint8";
10
+ readonly name: "kind";
11
+ readonly type: "uint8";
12
+ }, {
13
+ readonly internalType: "uint256";
14
+ readonly name: "collectionId";
15
+ readonly type: "uint256";
16
+ }, {
17
+ readonly internalType: "bytes32";
18
+ readonly name: "contentHash";
19
+ readonly type: "bytes32";
20
+ }, {
21
+ readonly internalType: "bytes32";
22
+ readonly name: "mediaHash";
23
+ readonly type: "bytes32";
24
+ }, {
25
+ readonly internalType: "bytes32";
26
+ readonly name: "recordFileId";
27
+ readonly type: "bytes32";
28
+ }, {
29
+ readonly components: readonly [{
30
+ readonly internalType: "address";
31
+ readonly name: "account";
32
+ readonly type: "address";
33
+ }, {
34
+ readonly internalType: "uint8";
35
+ readonly name: "role";
36
+ readonly type: "uint8";
37
+ }];
38
+ readonly internalType: "struct Party[]";
39
+ readonly name: "parties";
40
+ readonly type: "tuple[]";
41
+ }, {
42
+ readonly components: readonly [{
43
+ readonly internalType: "uint256";
44
+ readonly name: "artistId";
45
+ readonly type: "uint256";
46
+ }, {
47
+ readonly internalType: "address";
48
+ readonly name: "account";
49
+ readonly type: "address";
50
+ }, {
51
+ readonly internalType: "uint32";
52
+ readonly name: "share";
53
+ readonly type: "uint32";
54
+ }];
55
+ readonly internalType: "struct ISplitWallet.Payee[]";
56
+ readonly name: "payees";
57
+ readonly type: "tuple[]";
58
+ }, {
59
+ readonly components: readonly [{
60
+ readonly internalType: "string";
61
+ readonly name: "spdxId";
62
+ readonly type: "string";
63
+ }, {
64
+ readonly internalType: "bytes32";
65
+ readonly name: "textFileId";
66
+ readonly type: "bytes32";
67
+ }];
68
+ readonly internalType: "struct License";
69
+ readonly name: "license";
70
+ readonly type: "tuple";
71
+ }, {
72
+ readonly internalType: "uint8";
73
+ readonly name: "seedPolicy";
74
+ readonly type: "uint8";
75
+ }, {
76
+ readonly internalType: "bytes32";
77
+ readonly name: "seed";
78
+ readonly type: "bytes32";
79
+ }, {
80
+ readonly components: readonly [{
81
+ readonly internalType: "bytes32";
82
+ readonly name: "saleKind";
83
+ readonly type: "bytes32";
84
+ }, {
85
+ readonly internalType: "address";
86
+ readonly name: "currency";
87
+ readonly type: "address";
88
+ }, {
89
+ readonly internalType: "bytes";
90
+ readonly name: "params";
91
+ readonly type: "bytes";
92
+ }];
93
+ readonly internalType: "struct SaleTerms";
94
+ readonly name: "sale";
95
+ readonly type: "tuple";
96
+ }, {
97
+ readonly components: readonly [{
98
+ readonly internalType: "uint32";
99
+ readonly name: "maxCount";
100
+ readonly type: "uint32";
101
+ }, {
102
+ readonly internalType: "address";
103
+ readonly name: "currency";
104
+ readonly type: "address";
105
+ }, {
106
+ readonly internalType: "bytes32";
107
+ readonly name: "saleKind";
108
+ readonly type: "bytes32";
109
+ }, {
110
+ readonly internalType: "bytes";
111
+ readonly name: "params";
112
+ readonly type: "bytes";
113
+ }];
114
+ readonly internalType: "struct EditionTerms";
115
+ readonly name: "edition";
116
+ readonly type: "tuple";
117
+ }];
118
+ readonly internalType: "struct PackageItem";
119
+ readonly name: "item";
120
+ readonly type: "tuple";
121
+ };
122
+ export declare const MEDIA_FILES_ABI: {
123
+ readonly components: readonly [{
124
+ readonly internalType: "bytes32";
125
+ readonly name: "fileId";
126
+ readonly type: "bytes32";
127
+ }, {
128
+ readonly internalType: "bytes32";
129
+ readonly name: "sha256Hash";
130
+ readonly type: "bytes32";
131
+ }, {
132
+ readonly internalType: "uint8";
133
+ readonly name: "role";
134
+ readonly type: "uint8";
135
+ }];
136
+ readonly internalType: "struct MediaFile[]";
137
+ readonly name: "media";
138
+ readonly type: "tuple[]";
139
+ };
140
+ /**
141
+ * One item of an approved package: everything that is approved and that every party signs.
142
+ * Source: [`PackageTypes.sol`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/interfaces/types/PackageTypes.sol).
143
+ */
144
+ export type PackageItem = AbiParameterToPrimitiveType<typeof PACKAGE_ITEM_ABI>;
145
+ /** One media file of a work: its content-store file ID, the SHA-256 of the decoded file, its role. */
146
+ export type MediaFile = AbiParameterToPrimitiveType<typeof MEDIA_FILES_ABI>[number];
147
+ /** A party of an item: an account and its role. */
148
+ export type Party = PackageItem["parties"][number];
149
+ /** A payee of an item's artist portion: by artist ID (account zero) or by fixed address (artist ID zero). */
150
+ export type Payee = PackageItem["payees"][number];
151
+ /** A license: an SPDX identifier and the file ID of its full text. */
152
+ export type License = PackageItem["license"];
153
+ /** A party's acceptance of a package root (`PartyAcceptance`). */
154
+ export interface PartyAcceptance {
155
+ readonly account: Address;
156
+ readonly profileId: Hex;
157
+ readonly profileDocHash: Hex;
158
+ /** Unix seconds, on the chain's clock. */
159
+ readonly deadline: bigint;
160
+ }
161
+ /** An artist account's recorded fields (`ArtistIdentity`). */
162
+ export interface ArtistIdentity {
163
+ readonly root: Address;
164
+ readonly payout: Address;
165
+ readonly profileId: Hex;
166
+ readonly profileDocHash: Hex;
167
+ }
package/dist/types.js ADDED
@@ -0,0 +1,14 @@
1
+ import { streamWorkFacts6529Abi } from "./generated/abis/StreamWorkFacts6529.js";
2
+ function openInputs() {
3
+ const open = streamWorkFacts6529Abi.find((entry) => entry.type === "function" && entry.name === "open");
4
+ if (!open)
5
+ throw new Error("StreamWorkFacts6529 ABI has no open function");
6
+ return open.inputs;
7
+ }
8
+ /**
9
+ * The ABI shape of `PackageItem` and of `MediaFile[]`, taken from the generated ABI of
10
+ * `StreamWorkFacts6529.open(token, tokenId, item, media)`, so the encodings in this library
11
+ * cannot drift from the contracts.
12
+ */
13
+ export const PACKAGE_ITEM_ABI = openInputs()[2];
14
+ export const MEDIA_FILES_ABI = openInputs()[3];
@@ -0,0 +1,54 @@
1
+ # Publishing to npm
2
+
3
+ For the maintainers. The library is built to be published as `@6529-collections/stream-sdk`.
4
+ Publishing is a decision for the package's owner; nothing publishes by itself, and the
5
+ package stays pre-audit and for test networks only whatever its version.
6
+
7
+ ## What gets published
8
+
9
+ `npm pack` is the package: the built `dist/` (JavaScript and type declarations, ES modules),
10
+ `README.md`, `LICENSE`, `NOTICE`, `CHANGELOG.md` and `docs/`. No source, tests, scripts or
11
+ source maps. A consumer runs no install script. CI packs the library on every pull request,
12
+ installs the tarball in an empty project with scripts off, imports it with Node and
13
+ type-checks it under the `NodeNext` and `Bundler` module resolutions
14
+ ([`scripts/pack-test.sh`](../scripts/pack-test.sh)).
15
+
16
+ `npm run build && npm run size` prints the size of the package and what a page pulls in for
17
+ typical imports. Each contract's ABI is its own module and the package is marked free of
18
+ side effects, so a bundler keeps only the ABIs of the functions a page uses.
19
+
20
+ ## One-time set-up, by the owner of the npm scope
21
+
22
+ The workflow holds no npm token. It uses npm's trusted publishing:
23
+
24
+ 1. On npmjs.com, in the `@6529-collections` organisation, create the package. A first
25
+ version must exist before a trusted publisher can be added to it, so publish a bootstrap
26
+ prerelease once by hand, as the organisation did for its other packages. From a clean
27
+ checkout of `main`: `npm ci`, `npm run build`,
28
+ `npm version 0.1.0-bootstrap.0 --no-git-tag-version`, then
29
+ `npm publish --access public --tag bootstrap`. Do not commit the version change. The
30
+ real `0.1.0` is then published by the workflow, with a provenance statement.
31
+ 2. In the package's settings, add a trusted publisher: GitHub Actions, organisation
32
+ `6529-Collections`, repository `6529-stream-sdk`, workflow file `publish.yml`,
33
+ environment `npm-publish`.
34
+ 3. Optionally require two-factor authentication and disallow tokens for the package.
35
+
36
+ Until step 2 is done, the workflow's last step fails and nothing is published.
37
+
38
+ ## Each release
39
+
40
+ 1. In a pull request: raise `version` in `package.json` (and `package-lock.json`, with
41
+ `npm version <new> --no-git-tag-version`), and date the entry in `CHANGELOG.md`.
42
+ 2. After it is merged, on GitHub: Actions, "Publish to npm", Run workflow, on `main`, and type
43
+ the version. The workflow refuses any other branch, a version that does not match
44
+ `package.json`, and a version that is already on npm. It runs the checks, builds, tests
45
+ the tarball and publishes with a provenance statement.
46
+
47
+ ## A new instance
48
+
49
+ A new deployment of the contracts (r11, say) is one entry in
50
+ [`scripts/instances.mjs`](../scripts/instances.mjs) and one run of it; the entry's constant
51
+ (`sepoliaR10`), the list `instances` and `latestInstance` are generated. Then a new version
52
+ is published as above. An older instance stays in the list only while every function the
53
+ library calls kept its shape, because the library carries one set of ABIs, those of its
54
+ newest instance.