@6529-collections/stream-sdk 0.0.0-stage → 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/CHANGELOG.md +46 -0
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +413 -2
- package/dist/actions/accounts.d.ts +58 -0
- package/dist/actions/accounts.js +73 -0
- package/dist/actions/content.d.ts +22 -0
- package/dist/actions/content.js +45 -0
- package/dist/actions/curated.d.ts +177 -0
- package/dist/actions/curated.js +279 -0
- package/dist/actions/editions.d.ts +100 -0
- package/dist/actions/editions.js +161 -0
- package/dist/actions/independent.d.ts +149 -0
- package/dist/actions/independent.js +274 -0
- package/dist/actions/money.d.ts +117 -0
- package/dist/actions/money.js +148 -0
- package/dist/actions/record.d.ts +144 -0
- package/dist/actions/record.js +229 -0
- package/dist/actions/sale.d.ts +82 -0
- package/dist/actions/sale.js +113 -0
- package/dist/actions/shared.d.ts +40 -0
- package/dist/actions/shared.js +70 -0
- package/dist/actions/vault.d.ts +58 -0
- package/dist/actions/vault.js +94 -0
- package/dist/constants.d.ts +130 -0
- package/dist/constants.js +65 -0
- package/dist/display.d.ts +31 -0
- package/dist/display.js +28 -0
- package/dist/encoding.d.ts +110 -0
- package/dist/encoding.js +138 -0
- package/dist/errors.d.ts +76 -0
- package/dist/errors.js +66 -0
- package/dist/files/fetch.d.ts +85 -0
- package/dist/files/fetch.js +208 -0
- package/dist/files/verify.d.ts +36 -0
- package/dist/files/verify.js +125 -0
- package/dist/generated/abis/AccessManager.d.ts +1125 -0
- package/dist/generated/abis/AccessManager.js +1471 -0
- package/dist/generated/abis/Accounts.d.ts +1568 -0
- package/dist/generated/abis/Accounts.js +2049 -0
- package/dist/generated/abis/ClaimRouter.d.ts +343 -0
- package/dist/generated/abis/ClaimRouter.js +452 -0
- package/dist/generated/abis/ConsolidationAdapter.d.ts +97 -0
- package/dist/generated/abis/ConsolidationAdapter.js +133 -0
- package/dist/generated/abis/ContentStore.d.ts +812 -0
- package/dist/generated/abis/ContentStore.js +1073 -0
- package/dist/generated/abis/EconomicsResolver.d.ts +586 -0
- package/dist/generated/abis/EconomicsResolver.js +769 -0
- package/dist/generated/abis/Eip712CurationVerifier.d.ts +304 -0
- package/dist/generated/abis/Eip712CurationVerifier.js +406 -0
- package/dist/generated/abis/EnglishAuction.d.ts +1435 -0
- package/dist/generated/abis/EnglishAuction.js +1865 -0
- package/dist/generated/abis/GovernedVault.d.ts +468 -0
- package/dist/generated/abis/GovernedVault.js +617 -0
- package/dist/generated/abis/IndependentEditionAuction.d.ts +2373 -0
- package/dist/generated/abis/IndependentEditionAuction.js +3076 -0
- package/dist/generated/abis/IndependentStream6529.d.ts +1408 -0
- package/dist/generated/abis/IndependentStream6529.js +1834 -0
- package/dist/generated/abis/IndependentStreamDeployer.d.ts +141 -0
- package/dist/generated/abis/IndependentStreamDeployer.js +188 -0
- package/dist/generated/abis/IndependentStreamEditions6529.d.ts +963 -0
- package/dist/generated/abis/IndependentStreamEditions6529.js +1253 -0
- package/dist/generated/abis/IndependentStreamRegistry.d.ts +1351 -0
- package/dist/generated/abis/IndependentStreamRegistry.js +1755 -0
- package/dist/generated/abis/PackageRegistry.d.ts +1205 -0
- package/dist/generated/abis/PackageRegistry.js +1573 -0
- package/dist/generated/abis/RevenueEscrow.d.ts +626 -0
- package/dist/generated/abis/RevenueEscrow.js +820 -0
- package/dist/generated/abis/SaleStarter.d.ts +48 -0
- package/dist/generated/abis/SaleStarter.js +67 -0
- package/dist/generated/abis/SepoliaOpenGate.d.ts +317 -0
- package/dist/generated/abis/SepoliaOpenGate.js +419 -0
- package/dist/generated/abis/SplitLedger.d.ts +1097 -0
- package/dist/generated/abis/SplitLedger.js +1438 -0
- package/dist/generated/abis/StatementLog.d.ts +958 -0
- package/dist/generated/abis/StatementLog.js +1248 -0
- package/dist/generated/abis/Stream6529.d.ts +1490 -0
- package/dist/generated/abis/Stream6529.js +1941 -0
- package/dist/generated/abis/StreamDirectory6529.d.ts +355 -0
- package/dist/generated/abis/StreamDirectory6529.js +468 -0
- package/dist/generated/abis/StreamEditions6529.d.ts +1240 -0
- package/dist/generated/abis/StreamEditions6529.js +1614 -0
- package/dist/generated/abis/StreamTerms.d.ts +312 -0
- package/dist/generated/abis/StreamTerms.js +409 -0
- package/dist/generated/abis/StreamWorkFacts6529.d.ts +810 -0
- package/dist/generated/abis/StreamWorkFacts6529.js +1049 -0
- package/dist/generated/abis/UniformEditionAuction.d.ts +2372 -0
- package/dist/generated/abis/UniformEditionAuction.js +3074 -0
- package/dist/generated/abis/WorkDelivery.d.ts +605 -0
- package/dist/generated/abis/WorkDelivery.js +786 -0
- package/dist/generated/abis/WorkRules.d.ts +1154 -0
- package/dist/generated/abis/WorkRules.js +1501 -0
- package/dist/generated/abis/index.d.ts +28 -0
- package/dist/generated/abis/index.js +31 -0
- package/dist/generated/instances.d.ts +7 -0
- package/dist/generated/instances.js +9 -0
- package/dist/generated/sepoliaR10.d.ts +1391 -0
- package/dist/generated/sepoliaR10.js +1545 -0
- package/dist/hashing/content.d.ts +42 -0
- package/dist/hashing/content.js +54 -0
- package/dist/hashing/ids.d.ts +67 -0
- package/dist/hashing/ids.js +73 -0
- package/dist/hashing/items.d.ts +30 -0
- package/dist/hashing/items.js +44 -0
- package/dist/hashing/packages.d.ts +35 -0
- package/dist/hashing/packages.js +76 -0
- package/dist/hashing/vault.d.ts +17 -0
- package/dist/hashing/vault.js +37 -0
- package/dist/hashing/workState.d.ts +31 -0
- package/dist/hashing/workState.js +37 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +47 -0
- package/dist/instance.d.ts +236 -0
- package/dist/instance.js +99 -0
- package/dist/items.d.ts +85 -0
- package/dist/items.js +144 -0
- package/dist/reads/accounts.d.ts +86 -0
- package/dist/reads/accounts.js +121 -0
- package/dist/reads/chain.d.ts +54 -0
- package/dist/reads/chain.js +133 -0
- package/dist/reads/creation.d.ts +139 -0
- package/dist/reads/creation.js +256 -0
- package/dist/reads/editionSale.d.ts +120 -0
- package/dist/reads/editionSale.js +182 -0
- package/dist/reads/metadata.d.ts +195 -0
- package/dist/reads/metadata.js +191 -0
- package/dist/reads/money.d.ts +51 -0
- package/dist/reads/money.js +68 -0
- package/dist/reads/network.d.ts +137 -0
- package/dist/reads/network.js +157 -0
- package/dist/reads/sale.d.ts +94 -0
- package/dist/reads/sale.js +133 -0
- package/dist/reads/vault.d.ts +47 -0
- package/dist/reads/vault.js +75 -0
- package/dist/reads/work.d.ts +293 -0
- package/dist/reads/work.js +338 -0
- package/dist/reads/workPage.d.ts +197 -0
- package/dist/reads/workPage.js +169 -0
- package/dist/signing/messages.d.ts +679 -0
- package/dist/signing/messages.js +397 -0
- package/dist/testing.d.ts +17 -0
- package/dist/testing.js +18 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.js +14 -0
- package/docs/publishing.md +54 -0
- package/docs/reference.md +335 -0
- package/docs/using-from-a-site.md +175 -0
- package/package.json +93 -4
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { type Address, type Client } from "viem";
|
|
2
|
+
/** One deployment of the 6529 Stream contracts, as its deployment record states it. */
|
|
3
|
+
export interface StreamInstance {
|
|
4
|
+
/** The instance's name in the contracts repository, for example `sepolia-r10`. */
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
/** The first block of the deployment: scan events from here. */
|
|
8
|
+
readonly startBlock: bigint;
|
|
9
|
+
/** The commit of 6529-stream the instance was built from. The ABIs here are that commit's. */
|
|
10
|
+
readonly sourceCommit: string;
|
|
11
|
+
/** The deployment record in 6529-stream, and the commit it was read at. */
|
|
12
|
+
readonly record: string;
|
|
13
|
+
readonly recordCommit: string;
|
|
14
|
+
/** The 6529 delegation contract the accounts module reads consolidations from. */
|
|
15
|
+
readonly delegation: Address;
|
|
16
|
+
/**
|
|
17
|
+
* Every contract of the deployment by its name in the deployment record: its address, the
|
|
18
|
+
* Solidity contract it is an instance of, and the source file at `sourceCommit`. Use it to
|
|
19
|
+
* link a fact or an action to the code (`sourceUrl`), or an address to its name.
|
|
20
|
+
*/
|
|
21
|
+
readonly contracts: Readonly<Record<string, DeployedContract>>;
|
|
22
|
+
/** The account that governs the instance: on a test instance, a throwaway multisig. */
|
|
23
|
+
readonly network: Address;
|
|
24
|
+
readonly addresses: StreamAddresses;
|
|
25
|
+
/** The name each address has in the deployment record (`Stream6529`, `SplitFactory`, ...). */
|
|
26
|
+
readonly recordNames: Readonly<Record<keyof StreamAddresses, string>>;
|
|
27
|
+
/**
|
|
28
|
+
* The test-only open gate (`SepoliaOpenGate`), or null. With the gate open, nothing is
|
|
29
|
+
* curated: every package anyone submits is approved. It exists on test instances only.
|
|
30
|
+
*/
|
|
31
|
+
readonly openGate: Address | null;
|
|
32
|
+
/** The protocol's own strings as this instance's contracts were built with them. */
|
|
33
|
+
readonly protocol: StreamProtocol;
|
|
34
|
+
/** Who may call what, as the instance's genesis file sets it. Read the live state with `readNetwork`. */
|
|
35
|
+
readonly governance: StreamGovernance;
|
|
36
|
+
}
|
|
37
|
+
/** One deployed contract of an instance. */
|
|
38
|
+
export interface DeployedContract {
|
|
39
|
+
readonly address: Address;
|
|
40
|
+
/** The Solidity contract, for example `GovernedVault` for the record's `MuseumVault`. */
|
|
41
|
+
readonly contract: string;
|
|
42
|
+
/** The source file in the contracts repository, and its URL at the instance's `sourceCommit`. */
|
|
43
|
+
readonly source: string;
|
|
44
|
+
readonly sourceUrl: string;
|
|
45
|
+
readonly deployedInBlock: number;
|
|
46
|
+
readonly codeHash: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The deployed contract at `address`, with its record name, or null. For a page that shows an
|
|
50
|
+
* address and wants to say what it is and link its source.
|
|
51
|
+
*/
|
|
52
|
+
export declare function contractAt(instance: StreamInstance, address: Address): (DeployedContract & {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
}) | null;
|
|
55
|
+
/** The governance table of an instance at genesis: roles, holders, governed functions, settings. */
|
|
56
|
+
export interface StreamGovernance {
|
|
57
|
+
/** The roles of the access manager. `executionDelay` is the wait, in seconds, between scheduling and executing a call. */
|
|
58
|
+
readonly roles: readonly {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly executionDelay: number;
|
|
62
|
+
readonly grantDelay: number;
|
|
63
|
+
/** True for a role the network itself holds. */
|
|
64
|
+
readonly heldByNetwork: boolean;
|
|
65
|
+
}[];
|
|
66
|
+
/** The accounts granted each role at genesis, besides the network. Later grants are not listed here. */
|
|
67
|
+
readonly holdersAtGenesis: readonly {
|
|
68
|
+
readonly role: string;
|
|
69
|
+
readonly account: Address;
|
|
70
|
+
readonly label: string;
|
|
71
|
+
}[];
|
|
72
|
+
/** Every governed function: the contract, the function, and the role that may call it. */
|
|
73
|
+
readonly functions: readonly {
|
|
74
|
+
readonly contract: string;
|
|
75
|
+
readonly address: Address;
|
|
76
|
+
readonly signature: string;
|
|
77
|
+
readonly selector: string;
|
|
78
|
+
readonly role: string;
|
|
79
|
+
readonly delay: number;
|
|
80
|
+
readonly note?: string;
|
|
81
|
+
}[];
|
|
82
|
+
/** The network's settings and their values at genesis. */
|
|
83
|
+
readonly settings: readonly {
|
|
84
|
+
readonly contract: string;
|
|
85
|
+
readonly address: Address;
|
|
86
|
+
readonly getter: string;
|
|
87
|
+
readonly atGenesis: string;
|
|
88
|
+
}[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The strings a deployment's contracts were compiled with: the EIP-712 domain names and the
|
|
92
|
+
* labels that start each hash. They belong to an instance, not to the library: a later
|
|
93
|
+
* deployment may be built from source that spells them differently, and then every hash and
|
|
94
|
+
* every signature differs. They are generated from the Solidity source at the instance's
|
|
95
|
+
* `sourceCommit` and never typed here.
|
|
96
|
+
*/
|
|
97
|
+
export interface StreamProtocol {
|
|
98
|
+
/** The module slots: each one's name, the kind of contract that has it, and what it is for. */
|
|
99
|
+
readonly slots: readonly {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly on: "token" | "directory";
|
|
102
|
+
readonly what: string;
|
|
103
|
+
}[];
|
|
104
|
+
/**
|
|
105
|
+
* keccak256 of the init code every vault (split wallet) is created with: the ledger's
|
|
106
|
+
* `walletInitCodeHash`. With it a vault's address follows from its payee list alone.
|
|
107
|
+
*/
|
|
108
|
+
readonly vaultInitCodeHash: `0x${string}`;
|
|
109
|
+
/** The EIP-712 domain version of each signing contract, as each one passes it to its own domain. */
|
|
110
|
+
readonly domainVersions: {
|
|
111
|
+
readonly packageRegistry: string;
|
|
112
|
+
readonly curationVerifier: string;
|
|
113
|
+
readonly accounts: string;
|
|
114
|
+
readonly workRules: string;
|
|
115
|
+
readonly splitLedger: string;
|
|
116
|
+
readonly statementLog: string;
|
|
117
|
+
};
|
|
118
|
+
/** The EIP-712 domain name of each signing contract. */
|
|
119
|
+
readonly domainNames: {
|
|
120
|
+
readonly packageRegistry: string;
|
|
121
|
+
readonly curationVerifier: string;
|
|
122
|
+
readonly accounts: string;
|
|
123
|
+
readonly workRules: string;
|
|
124
|
+
readonly splitLedger: string;
|
|
125
|
+
readonly statementLog: string;
|
|
126
|
+
};
|
|
127
|
+
/** The labels hashed into each kind of hash, so one kind can never pass as another. */
|
|
128
|
+
readonly labels: {
|
|
129
|
+
/** Starts every item hash (keccak256 of it is `PACKAGE_ITEM_DOMAIN`). */
|
|
130
|
+
readonly packageItem: string;
|
|
131
|
+
/** Starts every media-list hash (`MEDIA_DOMAIN`). */
|
|
132
|
+
readonly media: string;
|
|
133
|
+
/** Starts every Independent Stream listing subject (`LISTING_DOMAIN`). */
|
|
134
|
+
readonly independentListing: string;
|
|
135
|
+
/** Starts every work state hash (`STATE_DOMAIN`). */
|
|
136
|
+
readonly workState: string;
|
|
137
|
+
/** Starts every Independent Stream collaborator consent; how it is encoded is `independentConsentTag`. */
|
|
138
|
+
readonly independentConsent: string;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* How the consent label enters the hash: `"string"`, the label itself as an ABI string (the
|
|
142
|
+
* r9 code), or `"bytes32"`, its keccak256 as one word like the other labels (later code:
|
|
143
|
+
* `INDEPENDENT_CONSENT_DOMAIN`).
|
|
144
|
+
*/
|
|
145
|
+
readonly independentConsentTag: "string" | "bytes32";
|
|
146
|
+
}
|
|
147
|
+
export interface StreamAddresses {
|
|
148
|
+
/** `ClaimRouter`: batch claims across vaults. */
|
|
149
|
+
readonly claimRouter: Address;
|
|
150
|
+
/** `ConsolidationAdapter`: answers whether a wallet is consolidated with a root. */
|
|
151
|
+
readonly consolidationAdapter: Address;
|
|
152
|
+
/** The network's fee vault (a `GovernedVault`, recorded as `FeeRecipientVault`). */
|
|
153
|
+
readonly feeVault: Address;
|
|
154
|
+
/** `RevenueEscrow`: holds a payment that could not be delivered, until someone flushes it. */
|
|
155
|
+
readonly revenueEscrow: Address;
|
|
156
|
+
/** The access manager (an OpenZeppelin `AccessManager`): who may call each governed function, and after what wait. */
|
|
157
|
+
readonly accessManager: Address;
|
|
158
|
+
readonly accounts: Address;
|
|
159
|
+
readonly contentStore: Address;
|
|
160
|
+
readonly curationVerifier: Address;
|
|
161
|
+
readonly economics: Address;
|
|
162
|
+
/** The English auction: the first sale of every 1/1. */
|
|
163
|
+
readonly englishAuction: Address;
|
|
164
|
+
/** The edition auction of 6529 Stream Editions. */
|
|
165
|
+
readonly editionAuction: Address;
|
|
166
|
+
/** The edition auction of Independent Stream editions. */
|
|
167
|
+
readonly independentEditionAuction: Address;
|
|
168
|
+
readonly independentRegistry: Address;
|
|
169
|
+
readonly independent721Deployer: Address;
|
|
170
|
+
readonly independentEditionsDeployer: Address;
|
|
171
|
+
readonly museumVault: Address;
|
|
172
|
+
readonly packageRegistry: Address;
|
|
173
|
+
readonly renderer: Address;
|
|
174
|
+
readonly saleStarter: Address;
|
|
175
|
+
/** `SplitLedger`, recorded as `SplitFactory` in the deployment record. */
|
|
176
|
+
readonly splitLedger: Address;
|
|
177
|
+
readonly statementLog: Address;
|
|
178
|
+
/** `Stream6529`: the curated 1/1 token. */
|
|
179
|
+
readonly stream: Address;
|
|
180
|
+
readonly streamDirectory: Address;
|
|
181
|
+
/** `StreamEditions6529`: the curated editions token. */
|
|
182
|
+
readonly streamEditions: Address;
|
|
183
|
+
readonly streamTerms: Address;
|
|
184
|
+
readonly workDelivery: Address;
|
|
185
|
+
/** `StreamWorkFacts6529`: the permanent record of every work. */
|
|
186
|
+
readonly workFacts: Address;
|
|
187
|
+
readonly workRules: Address;
|
|
188
|
+
}
|
|
189
|
+
/** What a deployment record of the contracts repository holds, as far as an instance needs it. */
|
|
190
|
+
export interface DeploymentRecord {
|
|
191
|
+
readonly chainId: number;
|
|
192
|
+
readonly startBlock: number;
|
|
193
|
+
readonly sourceCommit: string;
|
|
194
|
+
readonly confirmed: boolean;
|
|
195
|
+
readonly delegation: string;
|
|
196
|
+
readonly contracts: Readonly<Record<string, {
|
|
197
|
+
readonly address: string;
|
|
198
|
+
readonly block: number;
|
|
199
|
+
readonly codehash: string;
|
|
200
|
+
}>>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* An instance for another deployment of THE SAME CODE as `base`: a local development chain, or
|
|
204
|
+
* a fresh test deployment from the same commit. Addresses, blocks and code hashes come from
|
|
205
|
+
* the deployment record (the JSON the contracts repository writes under `deployments/`); the
|
|
206
|
+
* ABIs, the protocol's strings and the governance table are `base`'s, which is why the record
|
|
207
|
+
* must name the same source commit. The record does not hold the network account, a test
|
|
208
|
+
* gate or who held each role at launch (those are in the deployment's genesis file), so they
|
|
209
|
+
* are given; `holdersAtGenesis` is empty unless given.
|
|
210
|
+
*
|
|
211
|
+
* For a deployment of other code (a new release of the contracts), generate the instance
|
|
212
|
+
* instead: one entry in `scripts/instances.mjs`.
|
|
213
|
+
*
|
|
214
|
+
* @throws StreamSdkError `INVALID_INPUT` if the record is not confirmed, is built from another
|
|
215
|
+
* commit, or lacks a contract `base` has.
|
|
216
|
+
*/
|
|
217
|
+
export declare function instanceFromRecord(base: StreamInstance, record: DeploymentRecord, options: {
|
|
218
|
+
readonly name: string;
|
|
219
|
+
readonly network: Address;
|
|
220
|
+
readonly openGate?: Address | null;
|
|
221
|
+
readonly holdersAtGenesis?: StreamGovernance["holdersAtGenesis"];
|
|
222
|
+
readonly record?: string;
|
|
223
|
+
readonly recordCommit?: string;
|
|
224
|
+
}): StreamInstance;
|
|
225
|
+
/**
|
|
226
|
+
* Checks that `client` is connected to the chain `instance` lives on, and that the chain is a
|
|
227
|
+
* test network. Every read and action in this library calls it first, so a wallet that is on
|
|
228
|
+
* another network gets an error instead of a transaction to an address that means something
|
|
229
|
+
* else there. The answer is remembered only for a client without an account: such a client
|
|
230
|
+
* reads through a fixed RPC. A client with an account may be a browser wallet, which can
|
|
231
|
+
* switch network at any moment, so it is asked every time.
|
|
232
|
+
*
|
|
233
|
+
* @throws UnsupportedChainError when the instance is not on a test network.
|
|
234
|
+
* @throws WrongChainError when the client is on another chain.
|
|
235
|
+
*/
|
|
236
|
+
export declare function assertInstanceChain(client: Client, instance: StreamInstance): Promise<void>;
|
package/dist/instance.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { getAddress } from "viem";
|
|
3
|
+
import { getChainId } from "viem/actions";
|
|
4
|
+
import { StreamSdkError, UnsupportedChainError, WrongChainError } from "./errors.js";
|
|
5
|
+
/**
|
|
6
|
+
* The deployed contract at `address`, with its record name, or null. For a page that shows an
|
|
7
|
+
* address and wants to say what it is and link its source.
|
|
8
|
+
*/
|
|
9
|
+
export function contractAt(instance, address) {
|
|
10
|
+
const wanted = address.toLowerCase();
|
|
11
|
+
for (const [name, entry] of Object.entries(instance.contracts)) {
|
|
12
|
+
if (entry.address.toLowerCase() === wanted)
|
|
13
|
+
return { name, ...entry };
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An instance for another deployment of THE SAME CODE as `base`: a local development chain, or
|
|
19
|
+
* a fresh test deployment from the same commit. Addresses, blocks and code hashes come from
|
|
20
|
+
* the deployment record (the JSON the contracts repository writes under `deployments/`); the
|
|
21
|
+
* ABIs, the protocol's strings and the governance table are `base`'s, which is why the record
|
|
22
|
+
* must name the same source commit. The record does not hold the network account, a test
|
|
23
|
+
* gate or who held each role at launch (those are in the deployment's genesis file), so they
|
|
24
|
+
* are given; `holdersAtGenesis` is empty unless given.
|
|
25
|
+
*
|
|
26
|
+
* For a deployment of other code (a new release of the contracts), generate the instance
|
|
27
|
+
* instead: one entry in `scripts/instances.mjs`.
|
|
28
|
+
*
|
|
29
|
+
* @throws StreamSdkError `INVALID_INPUT` if the record is not confirmed, is built from another
|
|
30
|
+
* commit, or lacks a contract `base` has.
|
|
31
|
+
*/
|
|
32
|
+
export function instanceFromRecord(base, record, options) {
|
|
33
|
+
if (!record.confirmed)
|
|
34
|
+
throw new StreamSdkError("INVALID_INPUT", "The deployment record is not confirmed.");
|
|
35
|
+
if (record.sourceCommit !== base.sourceCommit) {
|
|
36
|
+
throw new StreamSdkError("INVALID_INPUT", `The record is built from ${record.sourceCommit}, not from ${base.sourceCommit}: generate an instance for it instead.`);
|
|
37
|
+
}
|
|
38
|
+
const addressOf = (recordName) => {
|
|
39
|
+
const entry = record.contracts[recordName];
|
|
40
|
+
if (!entry)
|
|
41
|
+
throw new StreamSdkError("INVALID_INPUT", `The record has no contract ${recordName}.`);
|
|
42
|
+
return getAddress(entry.address);
|
|
43
|
+
};
|
|
44
|
+
const addresses = Object.fromEntries(Object.entries(base.recordNames).map(([key, recordName]) => [key, addressOf(recordName)]));
|
|
45
|
+
const contracts = Object.fromEntries(Object.entries(base.contracts).map(([recordName, entry]) => {
|
|
46
|
+
const deployed = record.contracts[recordName];
|
|
47
|
+
if (!deployed)
|
|
48
|
+
throw new StreamSdkError("INVALID_INPUT", `The record has no contract ${recordName}.`);
|
|
49
|
+
return [recordName, { ...entry, address: getAddress(deployed.address), deployedInBlock: deployed.block, codeHash: deployed.codehash }];
|
|
50
|
+
}));
|
|
51
|
+
return {
|
|
52
|
+
...base,
|
|
53
|
+
name: options.name,
|
|
54
|
+
chainId: record.chainId,
|
|
55
|
+
startBlock: BigInt(record.startBlock),
|
|
56
|
+
record: options.record ?? "",
|
|
57
|
+
recordCommit: options.recordCommit ?? "",
|
|
58
|
+
delegation: getAddress(record.delegation),
|
|
59
|
+
network: options.network,
|
|
60
|
+
addresses,
|
|
61
|
+
openGate: options.openGate ?? null,
|
|
62
|
+
contracts,
|
|
63
|
+
governance: {
|
|
64
|
+
...base.governance,
|
|
65
|
+
holdersAtGenesis: options.holdersAtGenesis ?? [],
|
|
66
|
+
functions: base.governance.functions.map((entry) => ({ ...entry, address: addressOf(entry.contract) })),
|
|
67
|
+
settings: base.governance.settings.map((entry) => ({ ...entry, address: addressOf(entry.contract) })),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** The chains this release works on: Sepolia, and the local development chain. */
|
|
72
|
+
const TEST_CHAINS = new Set([11_155_111, 31_337]);
|
|
73
|
+
const checked = new WeakMap();
|
|
74
|
+
/**
|
|
75
|
+
* Checks that `client` is connected to the chain `instance` lives on, and that the chain is a
|
|
76
|
+
* test network. Every read and action in this library calls it first, so a wallet that is on
|
|
77
|
+
* another network gets an error instead of a transaction to an address that means something
|
|
78
|
+
* else there. The answer is remembered only for a client without an account: such a client
|
|
79
|
+
* reads through a fixed RPC. A client with an account may be a browser wallet, which can
|
|
80
|
+
* switch network at any moment, so it is asked every time.
|
|
81
|
+
*
|
|
82
|
+
* @throws UnsupportedChainError when the instance is not on a test network.
|
|
83
|
+
* @throws WrongChainError when the client is on another chain.
|
|
84
|
+
*/
|
|
85
|
+
export async function assertInstanceChain(client, instance) {
|
|
86
|
+
if (!TEST_CHAINS.has(instance.chainId))
|
|
87
|
+
throw new UnsupportedChainError(instance.chainId);
|
|
88
|
+
const fixed = client.account === undefined;
|
|
89
|
+
if (fixed && checked.get(client)?.has(instance.chainId))
|
|
90
|
+
return;
|
|
91
|
+
const actual = await getChainId(client);
|
|
92
|
+
if (actual !== instance.chainId)
|
|
93
|
+
throw new WrongChainError(instance.chainId, actual);
|
|
94
|
+
if (!fixed)
|
|
95
|
+
return;
|
|
96
|
+
const seen = checked.get(client) ?? new Set();
|
|
97
|
+
seen.add(instance.chainId);
|
|
98
|
+
checked.set(client, seen);
|
|
99
|
+
}
|
package/dist/items.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import type { StreamProtocol } from "./instance.js";
|
|
3
|
+
import type { License, MediaFile, PackageItem, Payee } from "./types.js";
|
|
4
|
+
/** What a work by one artist needs before it can be approved and minted. */
|
|
5
|
+
export interface WorkDraft {
|
|
6
|
+
/** The lead artist's wallet: the first party, who accepts the package and signs the move. */
|
|
7
|
+
readonly artist: Address;
|
|
8
|
+
/**
|
|
9
|
+
* The artist's ID from `readArtistId`. It is not always the wallet's own number, so it is
|
|
10
|
+
* asked for instead of derived.
|
|
11
|
+
*/
|
|
12
|
+
readonly artistId: bigint;
|
|
13
|
+
/** The collection of the token contract; an artist's own contract has exactly one, ID 1. */
|
|
14
|
+
readonly collectionId: bigint;
|
|
15
|
+
/** The primary media file: its content-store file ID and the SHA-256 of the decoded file. */
|
|
16
|
+
readonly primary: {
|
|
17
|
+
readonly fileId: Hex;
|
|
18
|
+
readonly sha256: Hex;
|
|
19
|
+
};
|
|
20
|
+
/** Further files the work loads, in order, each with its `FILE_ROLE` (1 preview, 2 auxiliary). */
|
|
21
|
+
readonly otherMedia?: readonly MediaFile[];
|
|
22
|
+
/** The file ID of the descriptive record (JSON). */
|
|
23
|
+
readonly recordFileId: Hex;
|
|
24
|
+
/** The license. For CC0 use `CC0-1.0` with `StreamWorkFacts6529.cc0TextFileId()`. */
|
|
25
|
+
readonly license: License;
|
|
26
|
+
/** Present for an edition master. `maxCount` 0 means no cap on the number of copies. */
|
|
27
|
+
readonly edition?: {
|
|
28
|
+
readonly maxCount: number;
|
|
29
|
+
};
|
|
30
|
+
/** Credited collaborators after the lead artist. Each must accept the package too. */
|
|
31
|
+
readonly collaborators?: readonly Address[];
|
|
32
|
+
/** The payees of the artist portion. Default: everything to the artist's account. */
|
|
33
|
+
readonly payees?: readonly Payee[];
|
|
34
|
+
}
|
|
35
|
+
/** An item and the media list its `mediaHash` commits to. */
|
|
36
|
+
export interface BuiltItem {
|
|
37
|
+
readonly item: PackageItem;
|
|
38
|
+
readonly media: readonly MediaFile[];
|
|
39
|
+
}
|
|
40
|
+
/** One rule an item breaks: a stable name, and a sentence for people. */
|
|
41
|
+
export interface ItemProblem {
|
|
42
|
+
readonly rule: "PARTIES" | "LEAD_ARTIST_ROLE" | "PARTY_ROLE" | "PARTY_TWICE" | "PAYEE_COUNT" | "PAYEE_NAMED_ONE_WAY" | "PAYEE_SHARE_ZERO" | "PAYEE_ORDER" | "PAYEE_IS_LEAD_ADDRESS" | "PAYEE_NOT_A_PARTY" | "SHARES_TOTAL" | "SALE_TERMS" | "SEED" | "LICENSE_ID";
|
|
43
|
+
readonly message: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The rules of an item that can be checked without the chain, each with its name: the ones
|
|
47
|
+
* the package registry enforces when a sale starts. An item that breaks one is approved and
|
|
48
|
+
* accepted all the same, and only refused (`InvalidItem`, with no reason) at the start, after
|
|
49
|
+
* every party has signed. Run this before anyone signs; `previewCuratedItem` also asks the
|
|
50
|
+
* registry.
|
|
51
|
+
*
|
|
52
|
+
* `independent: true` checks an item for an artist's own contract, where a payee named by
|
|
53
|
+
* address need not be a party.
|
|
54
|
+
*
|
|
55
|
+
* Contract: `_checkItem` of [`PackageRegistry`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/curation/PackageRegistry.sol)
|
|
56
|
+
* and the payee order of [`Splits`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/Splits.sol).
|
|
57
|
+
*/
|
|
58
|
+
export declare function itemProblems(item: PackageItem, options?: {
|
|
59
|
+
readonly independent?: boolean;
|
|
60
|
+
}): ItemProblem[];
|
|
61
|
+
/**
|
|
62
|
+
* Payees in the one order the contracts accept: strictly ascending by artist ID, then by
|
|
63
|
+
* address. The order carries no meaning, and the same payee twice is refused.
|
|
64
|
+
*
|
|
65
|
+
* Contract: [`Splits`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/Splits.sol)
|
|
66
|
+
* (`PayeesNotCanonical`), and `PackageRegistry`'s check of an item's payees.
|
|
67
|
+
*/
|
|
68
|
+
export declare function canonicalPayees(payees: readonly Payee[]): Payee[];
|
|
69
|
+
/**
|
|
70
|
+
* Builds the `PackageItem` of a work sold by English auction in ETH, unseeded, and the media
|
|
71
|
+
* list it commits to. The item is what gets hashed, approved, signed and minted: show its
|
|
72
|
+
* fields to the artist before any signature.
|
|
73
|
+
*
|
|
74
|
+
* Payees are put in the order the contracts accept, and the item is checked with
|
|
75
|
+
* `itemProblems`: the first broken rule is thrown as a `FlowError` whose message names it.
|
|
76
|
+
*
|
|
77
|
+
* Not checked here, because it needs the chain: that a payee named by artist ID is the account
|
|
78
|
+
* of one of the parties, and that the files are registered. The registry refuses the item at
|
|
79
|
+
* the start of the sale otherwise.
|
|
80
|
+
*
|
|
81
|
+
* Contract: the `PackageItem` struct of [`PackageTypes.sol`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/interfaces/types/PackageTypes.sol).
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildItem(protocol: StreamProtocol, draft: WorkDraft): BuiltItem;
|
|
84
|
+
/** A CC0 license for `buildItem`, given the file ID of the CC0 text the instance stores. */
|
|
85
|
+
export declare function cc0License(cc0TextFileId: Hex): License;
|
package/dist/items.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { isAddressEqual, zeroAddress } from "viem";
|
|
3
|
+
import { CC0_SPDX_ID, CURRENCY_DEFAULT, CURRENCY_ETH, DENOMINATOR, FILE_ROLE, ITEM_KIND, PARTY_ROLE, SALE_KIND, SEED_POLICY, ZERO_HASH } from "./constants.js";
|
|
4
|
+
import { FlowError } from "./errors.js";
|
|
5
|
+
import { mediaHash } from "./hashing/items.js";
|
|
6
|
+
/** The most parties one item names (`Limits.MAX_PARTIES`). */
|
|
7
|
+
const MAX_PARTIES = 16;
|
|
8
|
+
/** The longest SPDX identifier (`Limits.MAX_LICENSE_ID_BYTES`). */
|
|
9
|
+
const MAX_LICENSE_ID_BYTES = 64;
|
|
10
|
+
/**
|
|
11
|
+
* The rules of an item that can be checked without the chain, each with its name: the ones
|
|
12
|
+
* the package registry enforces when a sale starts. An item that breaks one is approved and
|
|
13
|
+
* accepted all the same, and only refused (`InvalidItem`, with no reason) at the start, after
|
|
14
|
+
* every party has signed. Run this before anyone signs; `previewCuratedItem` also asks the
|
|
15
|
+
* registry.
|
|
16
|
+
*
|
|
17
|
+
* `independent: true` checks an item for an artist's own contract, where a payee named by
|
|
18
|
+
* address need not be a party.
|
|
19
|
+
*
|
|
20
|
+
* Contract: `_checkItem` of [`PackageRegistry`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/curation/PackageRegistry.sol)
|
|
21
|
+
* and the payee order of [`Splits`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/Splits.sol).
|
|
22
|
+
*/
|
|
23
|
+
export function itemProblems(item, options = {}) {
|
|
24
|
+
const problems = [];
|
|
25
|
+
const add = (rule, message) => problems.push({ rule, message });
|
|
26
|
+
const { parties, payees } = item;
|
|
27
|
+
const lead = parties[0]?.account;
|
|
28
|
+
if (parties.length === 0 || parties.length > MAX_PARTIES)
|
|
29
|
+
add("PARTIES", `An item names 1 to ${MAX_PARTIES} parties.`);
|
|
30
|
+
if (parties[0] && parties[0].role !== PARTY_ROLE.ARTIST)
|
|
31
|
+
add("LEAD_ARTIST_ROLE", "The first party is the lead artist and has the artist role.");
|
|
32
|
+
if (parties.some((party) => party.role > PARTY_ROLE.COLLABORATOR))
|
|
33
|
+
add("PARTY_ROLE", "A party is an artist (0) or a collaborator (1).");
|
|
34
|
+
if (new Set(parties.map((party) => party.account.toLowerCase())).size !== parties.length)
|
|
35
|
+
add("PARTY_TWICE", "Each party is listed once.");
|
|
36
|
+
if (payees.length === 0 || (!options.independent && payees.length > parties.length)) {
|
|
37
|
+
add("PAYEE_COUNT", "An item has at least one payee and no more payees than parties.");
|
|
38
|
+
}
|
|
39
|
+
payees.forEach((payee, index) => {
|
|
40
|
+
const byAddress = payee.artistId === 0n;
|
|
41
|
+
if (byAddress === isAddressEqual(payee.account, zeroAddress)) {
|
|
42
|
+
add("PAYEE_NAMED_ONE_WAY", `Payee ${index} must be named by artist ID or by address, exactly one of the two.`);
|
|
43
|
+
}
|
|
44
|
+
if (payee.share <= 0)
|
|
45
|
+
add("PAYEE_SHARE_ZERO", `Payee ${index} has no share: every payee's share is above zero.`);
|
|
46
|
+
const previous = payees[index - 1];
|
|
47
|
+
if (previous) {
|
|
48
|
+
const ordered = payee.artistId > previous.artistId || (payee.artistId === previous.artistId && BigInt(payee.account) > BigInt(previous.account));
|
|
49
|
+
if (!ordered)
|
|
50
|
+
add("PAYEE_ORDER", `Payee ${index} is out of order: payees are listed by artist ID, then by address, each once (use canonicalPayees).`);
|
|
51
|
+
}
|
|
52
|
+
if (byAddress && lead && isAddressEqual(payee.account, lead)) {
|
|
53
|
+
add("PAYEE_IS_LEAD_ADDRESS", "The lead artist is paid through its account (by artist ID), not at its address.");
|
|
54
|
+
}
|
|
55
|
+
if (byAddress && !options.independent && !isAddressEqual(payee.account, zeroAddress) && !parties.some((party) => isAddressEqual(party.account, payee.account))) {
|
|
56
|
+
add("PAYEE_NOT_A_PARTY", `Payee ${payee.account} is not a party of the work: nobody is paid without accepting the package.`);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (payees.reduce((sum, payee) => sum + payee.share, 0) !== DENOMINATOR)
|
|
60
|
+
add("SHARES_TOTAL", "The payees' shares add up to 100,000.");
|
|
61
|
+
if (BigInt(item.sale.saleKind) === 0n || ![CURRENCY_ETH, CURRENCY_DEFAULT].some((currency) => isAddressEqual(currency, item.sale.currency))) {
|
|
62
|
+
add("SALE_TERMS", "The sale names a sale kind, and ETH (or the default currency, which is ETH).");
|
|
63
|
+
}
|
|
64
|
+
if (item.seedPolicy > SEED_POLICY.VRF || (item.seedPolicy === SEED_POLICY.ARTIST) !== (BigInt(item.seed) !== 0n)) {
|
|
65
|
+
add("SEED", "A seed is given exactly when the seed policy is the artist's own seed.");
|
|
66
|
+
}
|
|
67
|
+
if (!/^[A-Za-z0-9.+-]+$/.test(item.license.spdxId) || item.license.spdxId.length > MAX_LICENSE_ID_BYTES) {
|
|
68
|
+
add("LICENSE_ID", `A license ID is 1 to ${MAX_LICENSE_ID_BYTES} characters from A-Z, a-z, 0-9, ".", "+" and "-".`);
|
|
69
|
+
}
|
|
70
|
+
return problems;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Payees in the one order the contracts accept: strictly ascending by artist ID, then by
|
|
74
|
+
* address. The order carries no meaning, and the same payee twice is refused.
|
|
75
|
+
*
|
|
76
|
+
* Contract: [`Splits`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/Splits.sol)
|
|
77
|
+
* (`PayeesNotCanonical`), and `PackageRegistry`'s check of an item's payees.
|
|
78
|
+
*/
|
|
79
|
+
export function canonicalPayees(payees) {
|
|
80
|
+
const sorted = [...payees].sort((a, b) => {
|
|
81
|
+
if (a.artistId !== b.artistId)
|
|
82
|
+
return a.artistId < b.artistId ? -1 : 1;
|
|
83
|
+
const [aAccount, bAccount] = [BigInt(a.account), BigInt(b.account)];
|
|
84
|
+
return aAccount < bAccount ? -1 : aAccount > bAccount ? 1 : 0;
|
|
85
|
+
});
|
|
86
|
+
sorted.forEach((payee, index) => {
|
|
87
|
+
const previous = sorted[index - 1];
|
|
88
|
+
if (previous && previous.artistId === payee.artistId && BigInt(previous.account) === BigInt(payee.account)) {
|
|
89
|
+
throw new FlowError("INVALID_INPUT", "The same payee is listed twice.");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return sorted;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Builds the `PackageItem` of a work sold by English auction in ETH, unseeded, and the media
|
|
96
|
+
* list it commits to. The item is what gets hashed, approved, signed and minted: show its
|
|
97
|
+
* fields to the artist before any signature.
|
|
98
|
+
*
|
|
99
|
+
* Payees are put in the order the contracts accept, and the item is checked with
|
|
100
|
+
* `itemProblems`: the first broken rule is thrown as a `FlowError` whose message names it.
|
|
101
|
+
*
|
|
102
|
+
* Not checked here, because it needs the chain: that a payee named by artist ID is the account
|
|
103
|
+
* of one of the parties, and that the files are registered. The registry refuses the item at
|
|
104
|
+
* the start of the sale otherwise.
|
|
105
|
+
*
|
|
106
|
+
* Contract: the `PackageItem` struct of [`PackageTypes.sol`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/interfaces/types/PackageTypes.sol).
|
|
107
|
+
*/
|
|
108
|
+
export function buildItem(protocol, draft) {
|
|
109
|
+
const media = [
|
|
110
|
+
{ fileId: draft.primary.fileId, sha256Hash: draft.primary.sha256, role: FILE_ROLE.PRIMARY },
|
|
111
|
+
...(draft.otherMedia ?? []),
|
|
112
|
+
];
|
|
113
|
+
if (media.slice(1).some((file) => file.role === FILE_ROLE.PRIMARY)) {
|
|
114
|
+
throw new FlowError("INVALID_INPUT", "A work has exactly one primary file, and it comes first.");
|
|
115
|
+
}
|
|
116
|
+
const parties = [
|
|
117
|
+
{ account: draft.artist, role: PARTY_ROLE.ARTIST },
|
|
118
|
+
...(draft.collaborators ?? []).map((account) => ({ account, role: PARTY_ROLE.COLLABORATOR })),
|
|
119
|
+
];
|
|
120
|
+
const item = {
|
|
121
|
+
kind: draft.edition ? ITEM_KIND.EDITION_MASTER : ITEM_KIND.ORIGINAL,
|
|
122
|
+
collectionId: draft.collectionId,
|
|
123
|
+
contentHash: draft.primary.sha256,
|
|
124
|
+
mediaHash: mediaHash(protocol, media),
|
|
125
|
+
recordFileId: draft.recordFileId,
|
|
126
|
+
parties,
|
|
127
|
+
payees: canonicalPayees(draft.payees ?? [{ artistId: draft.artistId, account: zeroAddress, share: DENOMINATOR }]),
|
|
128
|
+
license: draft.license,
|
|
129
|
+
seedPolicy: SEED_POLICY.NONE,
|
|
130
|
+
seed: ZERO_HASH,
|
|
131
|
+
sale: { saleKind: SALE_KIND.ENGLISH_AUCTION, currency: CURRENCY_ETH, params: "0x" },
|
|
132
|
+
edition: draft.edition
|
|
133
|
+
? { maxCount: draft.edition.maxCount, currency: CURRENCY_ETH, saleKind: SALE_KIND.UNIFORM_AUCTION, params: "0x" }
|
|
134
|
+
: { maxCount: 0, currency: CURRENCY_ETH, saleKind: ZERO_HASH, params: "0x" },
|
|
135
|
+
};
|
|
136
|
+
const problem = itemProblems(item)[0];
|
|
137
|
+
if (problem)
|
|
138
|
+
throw new FlowError("INVALID_INPUT", `${problem.message} (${problem.rule})`);
|
|
139
|
+
return { item, media };
|
|
140
|
+
}
|
|
141
|
+
/** A CC0 license for `buildItem`, given the file ID of the CC0 text the instance stores. */
|
|
142
|
+
export function cc0License(cc0TextFileId) {
|
|
143
|
+
return { spdxId: CC0_SPDX_ID, textFileId: cc0TextFileId };
|
|
144
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Address, Client } from "viem";
|
|
2
|
+
import { type StreamInstance } from "../instance.js";
|
|
3
|
+
import type { ArtistIdentity } from "../types.js";
|
|
4
|
+
/** A wallet's artist ID, and whether an account exists for it yet. */
|
|
5
|
+
export interface ArtistIdRead {
|
|
6
|
+
/** The ID of the account this address is the root of, or the ID a new account for it gets. */
|
|
7
|
+
readonly artistId: bigint;
|
|
8
|
+
/** False when this address is not the root of any account. */
|
|
9
|
+
readonly exists: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The artist ID recorded for an address: the account it is (or was) the root of, or, with none,
|
|
13
|
+
* the ID a new account for it gets (the address as a number).
|
|
14
|
+
*
|
|
15
|
+
* This is a lookup by ROOT. A wallet that acts for an account only through consolidation is
|
|
16
|
+
* not a root: it reads as "no account" here, although the contracts accept its signatures for
|
|
17
|
+
* that account. There is no on-chain lookup from such a wallet to its account, so when a
|
|
18
|
+
* wallet may be consolidated, take the account's ID from where it is recorded (a work's
|
|
19
|
+
* `artistId`, `PackageRegistry.acceptedAs`, a token's `artistId()`) and check it with
|
|
20
|
+
* `readIsWallet`. An account whose root was replaced keeps its ID, so the old root still
|
|
21
|
+
* reads that ID here: `readIsWallet` says who acts for it now.
|
|
22
|
+
*
|
|
23
|
+
* Contract: [`Accounts.artistIdOf`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol).
|
|
24
|
+
*/
|
|
25
|
+
export declare function readArtistId(client: Client, instance: StreamInstance, wallet: Address): Promise<ArtistIdRead>;
|
|
26
|
+
/**
|
|
27
|
+
* The account a wallet acts for, or null. This is the one place the library answers "whose
|
|
28
|
+
* wallet is this", so that a change in the contracts is a change here only.
|
|
29
|
+
*
|
|
30
|
+
* Today the contracts can only say it for a root (`artistIdOf`). For a wallet that acts for an
|
|
31
|
+
* account through consolidation there is no lookup, so the caller names the accounts it could
|
|
32
|
+
* be (`candidates`: for example the artist of the work or contract in question) and each is
|
|
33
|
+
* checked with `isWallet`. Without a candidate that matches, the answer for such a wallet is
|
|
34
|
+
* null, which does not prove it acts for nobody.
|
|
35
|
+
*
|
|
36
|
+
* Contract: [`Accounts.artistIdOf`, `isWallet`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol).
|
|
37
|
+
*/
|
|
38
|
+
export declare function readAccountOf(client: Client, instance: StreamInstance, wallet: Address, options?: {
|
|
39
|
+
readonly candidates?: readonly bigint[];
|
|
40
|
+
}): Promise<{
|
|
41
|
+
artistId: bigint;
|
|
42
|
+
via: "root" | "consolidation";
|
|
43
|
+
} | null>;
|
|
44
|
+
/** An artist account as the chain records it. */
|
|
45
|
+
export interface Account {
|
|
46
|
+
readonly artistId: bigint;
|
|
47
|
+
/** The wallet the account's consolidation is read from, the payout address and the profile fields. */
|
|
48
|
+
readonly identity: ArtistIdentity;
|
|
49
|
+
/** The wallet that signs for the account now; zero while a recovery is pending. */
|
|
50
|
+
readonly activeAuthority: Address;
|
|
51
|
+
/** Unix seconds until which the account is frozen, or 0. */
|
|
52
|
+
readonly frozenUntil: number;
|
|
53
|
+
/** Where the account's artist-resolved payments go. */
|
|
54
|
+
readonly payoutAddress: Address;
|
|
55
|
+
/** The nonce the account's next own identity change signs. */
|
|
56
|
+
readonly changeNonce: bigint;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* An account's identity, authority and payout address, or null when no account has this ID.
|
|
60
|
+
*
|
|
61
|
+
* Contract: [`Accounts.artist`, `activeAuthorityOf`, `payoutAddress`, `changeNonce`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol).
|
|
62
|
+
*/
|
|
63
|
+
export declare function readAccount(client: Client, instance: StreamInstance, artistId: bigint): Promise<Account | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Whether `wallet` acts for the account `artistId` (its root, or a wallet consolidated with it).
|
|
66
|
+
*
|
|
67
|
+
* Contract: [`Accounts.isWallet`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/Accounts.sol).
|
|
68
|
+
*/
|
|
69
|
+
export declare function readIsWallet(client: Client, instance: StreamInstance, artistId: bigint, wallet: Address): Promise<boolean>;
|
|
70
|
+
/** ETH an account can withdraw now from each auction contract. */
|
|
71
|
+
export interface Claimable {
|
|
72
|
+
/** Outbid 1/1 bids: withdraw with `claimAuctionCredit`. */
|
|
73
|
+
readonly englishAuction: bigint;
|
|
74
|
+
/** Edition refunds credited on 6529 Stream Editions: withdraw with `claimEditionCredit`. */
|
|
75
|
+
readonly editionAuction: bigint;
|
|
76
|
+
/** Edition refunds credited on Independent Stream editions. */
|
|
77
|
+
readonly independentEditionAuction: bigint;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The ETH credited to `account` on the three auction contracts: outbid 1/1 bids and edition
|
|
81
|
+
* refunds are credited, never pushed, and wait to be withdrawn.
|
|
82
|
+
*
|
|
83
|
+
* Contract: [`EnglishAuction.claimable`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/sales/EnglishAuction.sol),
|
|
84
|
+
* [`UniformEditionAuction.claimable`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/sales/UniformEditionAuction.sol).
|
|
85
|
+
*/
|
|
86
|
+
export declare function readClaimable(client: Client, instance: StreamInstance, account: Address): Promise<Claimable>;
|