@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.
- 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,195 @@
|
|
|
1
|
+
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
+
import { type StreamInstance } from "../instance.js";
|
|
3
|
+
import { type LogScanOptions } from "./chain.js";
|
|
4
|
+
import type { WorkRef } from "./work.js";
|
|
5
|
+
/** A descriptive record, as far as its keys are the ones the renderer reads. */
|
|
6
|
+
export interface WorkRecord {
|
|
7
|
+
readonly name: string | null;
|
|
8
|
+
readonly description: string | null;
|
|
9
|
+
readonly artists: readonly string[];
|
|
10
|
+
readonly year: number | null;
|
|
11
|
+
readonly medium: string | null;
|
|
12
|
+
readonly dimensions: string | null;
|
|
13
|
+
readonly attributes: readonly {
|
|
14
|
+
readonly trait_type: string;
|
|
15
|
+
readonly value: string | number;
|
|
16
|
+
readonly display_type?: string;
|
|
17
|
+
readonly max_value?: number;
|
|
18
|
+
}[];
|
|
19
|
+
readonly dependencies: readonly unknown[];
|
|
20
|
+
/** Every other key of the record, untouched. */
|
|
21
|
+
readonly other: Readonly<Record<string, unknown>>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads the known keys out of a record's JSON (as `fetchRecord` returns it): name,
|
|
25
|
+
* description, artists, year, medium, dimensions, attributes, dependencies. A key that is
|
|
26
|
+
* missing or of another type comes back null or empty; nothing throws. Every string is the
|
|
27
|
+
* artist's own text: escape it for display.
|
|
28
|
+
*
|
|
29
|
+
* Contract: the keys [`Renderer`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/content/Renderer.sol)
|
|
30
|
+
* reads from a record for `tokenURI`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseRecord(json: unknown): WorkRecord;
|
|
33
|
+
/** The metadata a token contract serves to marketplaces and wallets. */
|
|
34
|
+
export interface TokenMetadata {
|
|
35
|
+
/** The URI exactly as the contract answers it. */
|
|
36
|
+
readonly uri: string;
|
|
37
|
+
/** The JSON inside a `data:application/json` URI, parsed; null for any other URI or bad JSON. */
|
|
38
|
+
readonly json: Readonly<Record<string, unknown>> | null;
|
|
39
|
+
/**
|
|
40
|
+
* Set when the renderer could not use the work's record: `not_open`, `incomplete` or
|
|
41
|
+
* `invalid`. The name and description are then placeholders.
|
|
42
|
+
*/
|
|
43
|
+
readonly recordStatus: string | null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The metadata of a work as marketplaces and wallets see it: `tokenURI(tokenId)`, with its
|
|
47
|
+
* JSON parsed when it is a `data:` URI. Use it to compare what a page shows with what a
|
|
48
|
+
* marketplace will show. It is the renderer's output: an `image` or `animation_url` inside it
|
|
49
|
+
* can point anywhere, so treat it as untrusted and prefer `fetchWorkFile` for the art itself.
|
|
50
|
+
* Returns null when the token does not exist or its renderer does not answer.
|
|
51
|
+
*
|
|
52
|
+
* Contract: [`Stream6529.tokenURI`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamBase.sol),
|
|
53
|
+
* answered by [`Renderer.tokenURI`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/content/Renderer.sol).
|
|
54
|
+
*/
|
|
55
|
+
export declare function readTokenMetadata(client: Client, instance: StreamInstance, ref: WorkRef): Promise<TokenMetadata | null>;
|
|
56
|
+
/**
|
|
57
|
+
* A token contract's own metadata (`contractURI`, ERC-7572), parsed like `readTokenMetadata`.
|
|
58
|
+
* Works for the 1/1 contracts and the editions contracts.
|
|
59
|
+
*
|
|
60
|
+
* Contract: [`Stream6529.contractURI`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamBase.sol).
|
|
61
|
+
*/
|
|
62
|
+
export declare function readContractMetadata(client: Client, instance: StreamInstance, token?: Address): Promise<TokenMetadata | null>;
|
|
63
|
+
/** An edition: the copies of one master work. */
|
|
64
|
+
export interface Edition {
|
|
65
|
+
/** The editions contract and the edition's ID, which is its master's token ID. */
|
|
66
|
+
readonly editions: Address;
|
|
67
|
+
readonly editionId: bigint;
|
|
68
|
+
/** False until a sale created the edition. */
|
|
69
|
+
readonly exists: boolean;
|
|
70
|
+
/** The sale contract that may mint it. */
|
|
71
|
+
readonly minter: Address;
|
|
72
|
+
/**
|
|
73
|
+
* What the contract stores as `maxSupply`, which means two things. Before the edition is
|
|
74
|
+
* sealed: the creator's cap, 0 for none. Once sealed: the final MAXIMUM, where 0 means no
|
|
75
|
+
* copy can exist. It is a ceiling, not a count: sealing accepts any value from the copies
|
|
76
|
+
* minted up to the cap, and the sale contract can still mint up to it. For display use the
|
|
77
|
+
* three separate numbers `minted`, `sealedMaximum` and `cap`.
|
|
78
|
+
*/
|
|
79
|
+
readonly maxSupply: number;
|
|
80
|
+
/**
|
|
81
|
+
* The final maximum number of copies, once the edition is sealed; null while it is not. No
|
|
82
|
+
* more than this many copies can ever exist. It is NOT the number minted (`minted`), which
|
|
83
|
+
* can be lower and can still rise to it.
|
|
84
|
+
*/
|
|
85
|
+
readonly sealedMaximum: number | null;
|
|
86
|
+
/**
|
|
87
|
+
* The creator's original cap on copies, from the event that created the edition; 0 for no
|
|
88
|
+
* cap, null if the event was not found in the range scanned.
|
|
89
|
+
*/
|
|
90
|
+
readonly cap: number | null;
|
|
91
|
+
/** Copies minted so far. */
|
|
92
|
+
readonly minted: number;
|
|
93
|
+
/**
|
|
94
|
+
* True once the maximum is final (`sealedMaximum`) and can never rise. More copies can
|
|
95
|
+
* still be minted while `minted` is below it.
|
|
96
|
+
*/
|
|
97
|
+
readonly supplySealed: boolean;
|
|
98
|
+
readonly royaltyReceiver: Address;
|
|
99
|
+
/** Out of 100,000. */
|
|
100
|
+
readonly royaltyRate: number;
|
|
101
|
+
/** The edition's metadata URI, or null. */
|
|
102
|
+
readonly uri: string | null;
|
|
103
|
+
/** Copies `holder` owns, when a holder was given. */
|
|
104
|
+
readonly balance: bigint | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The edition of a master work on an editions contract: how many copies exist, whether more
|
|
108
|
+
* can be minted, its royalty, its metadata URI, and a holder's balance. `editions` is the
|
|
109
|
+
* ERC-1155 contract (`readEditionVenue(...).editions`; default: the instance's curated one).
|
|
110
|
+
*
|
|
111
|
+
* Contract: the `EditionCreated` event and [`StreamEditions6529.editionOf`, `uri`, `balanceOf`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamEditions6529.sol).
|
|
112
|
+
*/
|
|
113
|
+
export declare function readEdition(client: Client, instance: StreamInstance, args: {
|
|
114
|
+
readonly editions?: Address;
|
|
115
|
+
readonly editionId: bigint;
|
|
116
|
+
readonly holder?: Address;
|
|
117
|
+
}, options?: LogScanOptions): Promise<Edition>;
|
|
118
|
+
/** One work in a listing. */
|
|
119
|
+
export interface WorkListing {
|
|
120
|
+
readonly token: Address;
|
|
121
|
+
readonly tokenId: bigint;
|
|
122
|
+
readonly collectionId: bigint;
|
|
123
|
+
readonly artistId: bigint;
|
|
124
|
+
/** The work's number within its collection, from 1. */
|
|
125
|
+
readonly serial: number;
|
|
126
|
+
readonly itemHash: Hex;
|
|
127
|
+
readonly contentHash: Hex;
|
|
128
|
+
/** `ITEM_KIND`: 0 an original, 1 an edition master. */
|
|
129
|
+
readonly kind: number;
|
|
130
|
+
/** The sale contract that minted it, and the block and transaction of the mint. */
|
|
131
|
+
readonly minter: Address;
|
|
132
|
+
readonly blockNumber: bigint;
|
|
133
|
+
readonly transactionHash: Hex;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The works of a token contract, oldest first, optionally only one collection's or one
|
|
137
|
+
* artist's. Read from the contract's `WorkMinted` events, so it includes works that were
|
|
138
|
+
* burned since; `readWork` tells what each is now. For a testnet's volumes a scan is enough;
|
|
139
|
+
* a site with many works wants an indexer.
|
|
140
|
+
*
|
|
141
|
+
* Contract: the `WorkMinted` event of [`Stream6529`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamBase.sol)
|
|
142
|
+
* (indexed by token, collection and artist).
|
|
143
|
+
*/
|
|
144
|
+
export declare function readWorks(client: Client, instance: StreamInstance, filter?: {
|
|
145
|
+
readonly token?: Address;
|
|
146
|
+
readonly collectionId?: bigint;
|
|
147
|
+
readonly artistId?: bigint;
|
|
148
|
+
}, options?: LogScanOptions): Promise<WorkListing[]>;
|
|
149
|
+
/** One entry of a subject's statement chain. */
|
|
150
|
+
export interface StatementEntry {
|
|
151
|
+
/** Its position in the subject's chain, from 0. */
|
|
152
|
+
readonly index: number;
|
|
153
|
+
readonly entryHash: Hex;
|
|
154
|
+
/** `STATEMENT_ROLE`: who spoke (artist, owner, curator, platform). */
|
|
155
|
+
readonly role: number;
|
|
156
|
+
readonly signer: Address;
|
|
157
|
+
readonly kind: Hex;
|
|
158
|
+
readonly schema: Hex;
|
|
159
|
+
/** The hash of the statement's document and how it was computed (1 keccak256, 2 SHA-256, 3 BLAKE3). */
|
|
160
|
+
readonly content: {
|
|
161
|
+
readonly algorithm: number;
|
|
162
|
+
readonly digest: Hex;
|
|
163
|
+
};
|
|
164
|
+
/** Where the document is, as its author wrote it: untrusted text. */
|
|
165
|
+
readonly uri: string;
|
|
166
|
+
readonly fileId: Hex;
|
|
167
|
+
readonly supersedes: Hex;
|
|
168
|
+
/** Unix seconds. */
|
|
169
|
+
readonly recordedAt: number;
|
|
170
|
+
readonly transactionHash: Hex;
|
|
171
|
+
}
|
|
172
|
+
/** The statements made about a token or a package. */
|
|
173
|
+
export interface Statements {
|
|
174
|
+
/** How many entries the log holds for the subject, and the head of its hash chain. */
|
|
175
|
+
readonly count: number;
|
|
176
|
+
readonly head: Hex;
|
|
177
|
+
/** The entries found, oldest first. */
|
|
178
|
+
readonly entries: readonly StatementEntry[];
|
|
179
|
+
/** True when every entry the log counts was found and the newest one's head is the log's. */
|
|
180
|
+
readonly complete: boolean;
|
|
181
|
+
/** The entry hash of the latest dispute outcome about the subject, or null. */
|
|
182
|
+
readonly latestDisputeOutcome: Hex | null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The statements the log holds about a subject: a token (`token`, `id`), or, with the zero
|
|
186
|
+
* address as token, a package (`id` is the package root as a number). Statements are
|
|
187
|
+
* append-only attributions: who said what about a work, with a hash of the document.
|
|
188
|
+
*
|
|
189
|
+
* Contract: [`StatementLog.chainOf`, `latestDisputeOutcome`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/records/StatementLog.sol)
|
|
190
|
+
* and its `StatementAppended` event.
|
|
191
|
+
*/
|
|
192
|
+
export declare function readStatements(client: Client, instance: StreamInstance, subject: {
|
|
193
|
+
readonly token: Address;
|
|
194
|
+
readonly id: bigint;
|
|
195
|
+
}, options?: LogScanOptions): Promise<Statements>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { getAbiItem, isAddressEqual } from "viem";
|
|
3
|
+
import { readContract } from "viem/actions";
|
|
4
|
+
import { stream6529Abi } from "../generated/abis/Stream6529.js";
|
|
5
|
+
import { statementLogAbi } from "../generated/abis/StatementLog.js";
|
|
6
|
+
import { streamEditions6529Abi } from "../generated/abis/StreamEditions6529.js";
|
|
7
|
+
import { statementSubjectKey } from "../hashing/ids.js";
|
|
8
|
+
import { assertInstanceChain } from "../instance.js";
|
|
9
|
+
import { orOnRevert, scanEvents } from "./chain.js";
|
|
10
|
+
/**
|
|
11
|
+
* Reads the known keys out of a record's JSON (as `fetchRecord` returns it): name,
|
|
12
|
+
* description, artists, year, medium, dimensions, attributes, dependencies. A key that is
|
|
13
|
+
* missing or of another type comes back null or empty; nothing throws. Every string is the
|
|
14
|
+
* artist's own text: escape it for display.
|
|
15
|
+
*
|
|
16
|
+
* Contract: the keys [`Renderer`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/content/Renderer.sol)
|
|
17
|
+
* reads from a record for `tokenURI`.
|
|
18
|
+
*/
|
|
19
|
+
export function parseRecord(json) {
|
|
20
|
+
const source = json !== null && typeof json === "object" && !Array.isArray(json) ? json : {};
|
|
21
|
+
const text = (key) => (typeof source[key] === "string" ? source[key] : null);
|
|
22
|
+
const known = new Set(["name", "description", "artists", "year", "medium", "dimensions", "attributes", "dependencies"]);
|
|
23
|
+
const attributes = Array.isArray(source["attributes"]) ? source["attributes"] : [];
|
|
24
|
+
return {
|
|
25
|
+
name: text("name"),
|
|
26
|
+
description: text("description"),
|
|
27
|
+
artists: Array.isArray(source["artists"]) ? source["artists"].filter((entry) => typeof entry === "string") : [],
|
|
28
|
+
year: typeof source["year"] === "number" && Number.isInteger(source["year"]) ? source["year"] : null,
|
|
29
|
+
medium: text("medium"),
|
|
30
|
+
dimensions: text("dimensions"),
|
|
31
|
+
attributes: attributes.filter((entry) => entry !== null &&
|
|
32
|
+
typeof entry === "object" &&
|
|
33
|
+
typeof entry.trait_type === "string" &&
|
|
34
|
+
["string", "number"].includes(typeof entry.value)),
|
|
35
|
+
dependencies: Array.isArray(source["dependencies"]) ? source["dependencies"] : [],
|
|
36
|
+
other: Object.fromEntries(Object.entries(source).filter(([key]) => !known.has(key))),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function parseDataUri(uri) {
|
|
40
|
+
const match = /^data:application\/json(;charset=[^;,]+)?(;utf8|;base64)?,/i.exec(uri);
|
|
41
|
+
if (!match)
|
|
42
|
+
return null;
|
|
43
|
+
const body = uri.slice(match[0].length);
|
|
44
|
+
try {
|
|
45
|
+
// The renderer percent-escapes only `%` and `#`, the two bytes a non-base64 data URI cannot carry.
|
|
46
|
+
const text = match[2]?.toLowerCase() === ";base64" ? new TextDecoder().decode(Uint8Array.from(atob(body), (c) => c.charCodeAt(0))) : body.replace(/%2[35]/g, (escaped) => (escaped === "%23" ? "#" : "%"));
|
|
47
|
+
const parsed = JSON.parse(text);
|
|
48
|
+
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The metadata of a work as marketplaces and wallets see it: `tokenURI(tokenId)`, with its
|
|
56
|
+
* JSON parsed when it is a `data:` URI. Use it to compare what a page shows with what a
|
|
57
|
+
* marketplace will show. It is the renderer's output: an `image` or `animation_url` inside it
|
|
58
|
+
* can point anywhere, so treat it as untrusted and prefer `fetchWorkFile` for the art itself.
|
|
59
|
+
* Returns null when the token does not exist or its renderer does not answer.
|
|
60
|
+
*
|
|
61
|
+
* Contract: [`Stream6529.tokenURI`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamBase.sol),
|
|
62
|
+
* answered by [`Renderer.tokenURI`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/content/Renderer.sol).
|
|
63
|
+
*/
|
|
64
|
+
export async function readTokenMetadata(client, instance, ref) {
|
|
65
|
+
await assertInstanceChain(client, instance);
|
|
66
|
+
const uri = await orOnRevert(readContract(client, { address: ref.token ?? instance.addresses.stream, abi: stream6529Abi, functionName: "tokenURI", args: [ref.tokenId] }), null);
|
|
67
|
+
if (uri === null)
|
|
68
|
+
return null;
|
|
69
|
+
const json = parseDataUri(uri);
|
|
70
|
+
return { uri, json, recordStatus: typeof json?.["record_status"] === "string" ? json["record_status"] : null };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A token contract's own metadata (`contractURI`, ERC-7572), parsed like `readTokenMetadata`.
|
|
74
|
+
* Works for the 1/1 contracts and the editions contracts.
|
|
75
|
+
*
|
|
76
|
+
* Contract: [`Stream6529.contractURI`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamBase.sol).
|
|
77
|
+
*/
|
|
78
|
+
export async function readContractMetadata(client, instance, token) {
|
|
79
|
+
await assertInstanceChain(client, instance);
|
|
80
|
+
const uri = await orOnRevert(readContract(client, { address: token ?? instance.addresses.stream, abi: stream6529Abi, functionName: "contractURI" }), null);
|
|
81
|
+
if (uri === null)
|
|
82
|
+
return null;
|
|
83
|
+
return { uri, json: parseDataUri(uri), recordStatus: null };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The edition of a master work on an editions contract: how many copies exist, whether more
|
|
87
|
+
* can be minted, its royalty, its metadata URI, and a holder's balance. `editions` is the
|
|
88
|
+
* ERC-1155 contract (`readEditionVenue(...).editions`; default: the instance's curated one).
|
|
89
|
+
*
|
|
90
|
+
* Contract: the `EditionCreated` event and [`StreamEditions6529.editionOf`, `uri`, `balanceOf`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamEditions6529.sol).
|
|
91
|
+
*/
|
|
92
|
+
export async function readEdition(client, instance, args, options = {}) {
|
|
93
|
+
await assertInstanceChain(client, instance);
|
|
94
|
+
const on = { address: args.editions ?? instance.addresses.streamEditions, abi: streamEditions6529Abi };
|
|
95
|
+
const [edition, created, uri, balance] = await Promise.all([
|
|
96
|
+
readContract(client, { ...on, functionName: "editionOf", args: [args.editionId] }),
|
|
97
|
+
scanEvents(client, instance, { address: on.address, event: EDITION_CREATED, args: { editionId: args.editionId } }, options),
|
|
98
|
+
orOnRevert(readContract(client, { ...on, functionName: "uri", args: [args.editionId] }), null),
|
|
99
|
+
args.holder ? readContract(client, { ...on, functionName: "balanceOf", args: [args.holder, args.editionId] }) : null,
|
|
100
|
+
]);
|
|
101
|
+
return {
|
|
102
|
+
editions: on.address,
|
|
103
|
+
editionId: args.editionId,
|
|
104
|
+
exists: BigInt(edition.minter) !== 0n,
|
|
105
|
+
minter: edition.minter,
|
|
106
|
+
maxSupply: edition.maxSupply,
|
|
107
|
+
sealedMaximum: edition.supplySealed ? edition.maxSupply : null,
|
|
108
|
+
cap: created[0] ? created[0].args.maxSupply : null,
|
|
109
|
+
minted: edition.minted,
|
|
110
|
+
supplySealed: edition.supplySealed,
|
|
111
|
+
royaltyReceiver: edition.royaltyReceiver,
|
|
112
|
+
royaltyRate: edition.royaltyRate,
|
|
113
|
+
uri,
|
|
114
|
+
balance,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const WORK_MINTED = /*#__PURE__*/ getAbiItem({ abi: stream6529Abi, name: "WorkMinted" });
|
|
118
|
+
const EDITION_CREATED = /*#__PURE__*/ getAbiItem({ abi: streamEditions6529Abi, name: "EditionCreated" });
|
|
119
|
+
/**
|
|
120
|
+
* The works of a token contract, oldest first, optionally only one collection's or one
|
|
121
|
+
* artist's. Read from the contract's `WorkMinted` events, so it includes works that were
|
|
122
|
+
* burned since; `readWork` tells what each is now. For a testnet's volumes a scan is enough;
|
|
123
|
+
* a site with many works wants an indexer.
|
|
124
|
+
*
|
|
125
|
+
* Contract: the `WorkMinted` event of [`Stream6529`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamBase.sol)
|
|
126
|
+
* (indexed by token, collection and artist).
|
|
127
|
+
*/
|
|
128
|
+
export async function readWorks(client, instance, filter = {}, options = {}) {
|
|
129
|
+
await assertInstanceChain(client, instance);
|
|
130
|
+
const token = filter.token ?? instance.addresses.stream;
|
|
131
|
+
const args = {
|
|
132
|
+
...(filter.collectionId === undefined ? {} : { collectionId: filter.collectionId }),
|
|
133
|
+
...(filter.artistId === undefined ? {} : { artistId: filter.artistId }),
|
|
134
|
+
};
|
|
135
|
+
const logs = await scanEvents(client, instance, { address: token, event: WORK_MINTED, args }, options);
|
|
136
|
+
return logs.map((log) => ({
|
|
137
|
+
token,
|
|
138
|
+
tokenId: log.args.tokenId,
|
|
139
|
+
collectionId: log.args.collectionId,
|
|
140
|
+
artistId: log.args.artistId,
|
|
141
|
+
serial: log.args.serial,
|
|
142
|
+
itemHash: log.args.facts.itemHash,
|
|
143
|
+
contentHash: log.args.facts.contentHash,
|
|
144
|
+
kind: log.args.facts.kind,
|
|
145
|
+
minter: log.args.minter,
|
|
146
|
+
blockNumber: log.blockNumber,
|
|
147
|
+
transactionHash: log.transactionHash,
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
const STATEMENT_APPENDED = /*#__PURE__*/ getAbiItem({ abi: statementLogAbi, name: "StatementAppended" });
|
|
151
|
+
/**
|
|
152
|
+
* The statements the log holds about a subject: a token (`token`, `id`), or, with the zero
|
|
153
|
+
* address as token, a package (`id` is the package root as a number). Statements are
|
|
154
|
+
* append-only attributions: who said what about a work, with a hash of the document.
|
|
155
|
+
*
|
|
156
|
+
* Contract: [`StatementLog.chainOf`, `latestDisputeOutcome`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/records/StatementLog.sol)
|
|
157
|
+
* and its `StatementAppended` event.
|
|
158
|
+
*/
|
|
159
|
+
export async function readStatements(client, instance, subject, options = {}) {
|
|
160
|
+
await assertInstanceChain(client, instance);
|
|
161
|
+
const log = { address: instance.addresses.statementLog, abi: statementLogAbi };
|
|
162
|
+
const [[count, head], outcome, appended] = await Promise.all([
|
|
163
|
+
readContract(client, { ...log, functionName: "chainOf", args: [subject.token, subject.id] }),
|
|
164
|
+
orOnRevert(readContract(client, { ...log, functionName: "latestDisputeOutcome", args: [subject.token, subject.id] }), null),
|
|
165
|
+
scanEvents(client, instance, { address: log.address, event: STATEMENT_APPENDED, args: { subjectKey: statementSubjectKey(subject.token, subject.id) } }, options),
|
|
166
|
+
]);
|
|
167
|
+
const entries = appended
|
|
168
|
+
.filter((entry) => isAddressEqual(entry.args.statement.token, subject.token) && entry.args.statement.id === subject.id)
|
|
169
|
+
.map((entry) => ({
|
|
170
|
+
index: Number(entry.args.index),
|
|
171
|
+
entryHash: entry.args.entryHash,
|
|
172
|
+
role: entry.args.role,
|
|
173
|
+
signer: entry.args.signer,
|
|
174
|
+
kind: entry.args.statement.kind,
|
|
175
|
+
schema: entry.args.statement.schema,
|
|
176
|
+
content: entry.args.statement.content,
|
|
177
|
+
uri: entry.args.statement.uri,
|
|
178
|
+
fileId: entry.args.statement.fileId,
|
|
179
|
+
supersedes: entry.args.statement.supersedes,
|
|
180
|
+
recordedAt: Number(entry.args.recordedAt),
|
|
181
|
+
transactionHash: entry.transactionHash,
|
|
182
|
+
}));
|
|
183
|
+
const newest = appended.at(-1);
|
|
184
|
+
return {
|
|
185
|
+
count: Number(count),
|
|
186
|
+
head,
|
|
187
|
+
entries,
|
|
188
|
+
complete: entries.length === Number(count) && (newest === undefined || newest.args.head === head),
|
|
189
|
+
latestDisputeOutcome: outcome && BigInt(outcome) !== 0n ? outcome : null,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Address, type Client } from "viem";
|
|
2
|
+
import { type StreamInstance } from "../instance.js";
|
|
3
|
+
/** What the escrow holds for one account in one asset. */
|
|
4
|
+
export interface EscrowCredit {
|
|
5
|
+
readonly wallet: Address;
|
|
6
|
+
readonly asset: Address;
|
|
7
|
+
/** Everything owed: anyone can pay it out to the wallet with `flushEscrow`. */
|
|
8
|
+
readonly owed: bigint;
|
|
9
|
+
/** The part that has waited the unclaimed period and can be moved to the network now (`expireEscrow`). */
|
|
10
|
+
readonly expirableNow: bigint;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What the revenue escrow holds for an account. A payment that could not be delivered (a
|
|
14
|
+
* wallet that refused ETH, a token that blocks an address) is credited here instead, so the
|
|
15
|
+
* sale still settles; the credit waits for anyone to flush it to the wallet it was made for.
|
|
16
|
+
* A credit nobody flushes for the unclaimed period (180 days at launch) can be moved to the
|
|
17
|
+
* network.
|
|
18
|
+
*
|
|
19
|
+
* Contract: [`RevenueEscrow.owed`, `expirableAt`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/RevenueEscrow.sol).
|
|
20
|
+
*/
|
|
21
|
+
export declare function readEscrow(client: Client, instance: StreamInstance, wallet: Address, asset?: Address): Promise<EscrowCredit>;
|
|
22
|
+
/** One of the network's two vaults. */
|
|
23
|
+
export interface NetworkVault {
|
|
24
|
+
/** `"fee"`: the network's share of sales and royalties. `"museum"`: unsold curated works. */
|
|
25
|
+
readonly vault: "fee" | "museum";
|
|
26
|
+
readonly address: Address;
|
|
27
|
+
/** Where the vault forwards what it holds: the network's own setting. */
|
|
28
|
+
readonly destination: Address;
|
|
29
|
+
/** ETH the vault holds now, which anyone can forward to the destination. */
|
|
30
|
+
readonly balance: bigint;
|
|
31
|
+
/** ETH the escrow holds for the vault. */
|
|
32
|
+
readonly escrowed: bigint;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The network's fee vault and museum vault: where each forwards to, and the ETH each holds.
|
|
36
|
+
* Neither vault can send anywhere but its destination; anyone may trigger the forward
|
|
37
|
+
* (`forwardVault`).
|
|
38
|
+
*
|
|
39
|
+
* Contract: [`GovernedVault.destination`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/GovernedVault.sol),
|
|
40
|
+
* and `RevenueEscrow.owed`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readNetworkVaults(client: Client, instance: StreamInstance): Promise<NetworkVault[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Whether `wallet` is consolidated with `root` in the 6529 delegation contract (use case 999,
|
|
45
|
+
* all collections, registered in both directions and not expired). A consolidated wallet acts
|
|
46
|
+
* for the root's account with the same rights. Consolidations are made in the delegation
|
|
47
|
+
* contract itself (`instance.delegation`), not in these contracts.
|
|
48
|
+
*
|
|
49
|
+
* Contract: [`ConsolidationAdapter.isConsolidated`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/ConsolidationAdapter.sol).
|
|
50
|
+
*/
|
|
51
|
+
export declare function readIsConsolidated(client: Client, instance: StreamInstance, root: Address, wallet: Address): Promise<boolean>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import {} from "viem";
|
|
3
|
+
import { getBalance, readContract } from "viem/actions";
|
|
4
|
+
import { CURRENCY_ETH } from "../constants.js";
|
|
5
|
+
import { consolidationAdapterAbi } from "../generated/abis/ConsolidationAdapter.js";
|
|
6
|
+
import { governedVaultAbi } from "../generated/abis/GovernedVault.js";
|
|
7
|
+
import { revenueEscrowAbi } from "../generated/abis/RevenueEscrow.js";
|
|
8
|
+
import { assertInstanceChain } from "../instance.js";
|
|
9
|
+
import { chainTime } from "./chain.js";
|
|
10
|
+
/**
|
|
11
|
+
* What the revenue escrow holds for an account. A payment that could not be delivered (a
|
|
12
|
+
* wallet that refused ETH, a token that blocks an address) is credited here instead, so the
|
|
13
|
+
* sale still settles; the credit waits for anyone to flush it to the wallet it was made for.
|
|
14
|
+
* A credit nobody flushes for the unclaimed period (180 days at launch) can be moved to the
|
|
15
|
+
* network.
|
|
16
|
+
*
|
|
17
|
+
* Contract: [`RevenueEscrow.owed`, `expirableAt`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/RevenueEscrow.sol).
|
|
18
|
+
*/
|
|
19
|
+
export async function readEscrow(client, instance, wallet, asset = CURRENCY_ETH) {
|
|
20
|
+
await assertInstanceChain(client, instance);
|
|
21
|
+
const escrow = { address: instance.addresses.revenueEscrow, abi: revenueEscrowAbi };
|
|
22
|
+
const now = await chainTime(client);
|
|
23
|
+
const [owed, expirableNow] = await Promise.all([
|
|
24
|
+
readContract(client, { ...escrow, functionName: "owed", args: [wallet, asset] }),
|
|
25
|
+
readContract(client, { ...escrow, functionName: "expirableAt", args: [wallet, asset, now] }),
|
|
26
|
+
]);
|
|
27
|
+
return { wallet, asset, owed, expirableNow };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The network's fee vault and museum vault: where each forwards to, and the ETH each holds.
|
|
31
|
+
* Neither vault can send anywhere but its destination; anyone may trigger the forward
|
|
32
|
+
* (`forwardVault`).
|
|
33
|
+
*
|
|
34
|
+
* Contract: [`GovernedVault.destination`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/GovernedVault.sol),
|
|
35
|
+
* and `RevenueEscrow.owed`.
|
|
36
|
+
*/
|
|
37
|
+
export async function readNetworkVaults(client, instance) {
|
|
38
|
+
await assertInstanceChain(client, instance);
|
|
39
|
+
const vaults = [
|
|
40
|
+
{ vault: "fee", address: instance.addresses.feeVault },
|
|
41
|
+
{ vault: "museum", address: instance.addresses.museumVault },
|
|
42
|
+
];
|
|
43
|
+
return Promise.all(vaults.map(async ({ vault, address }) => {
|
|
44
|
+
const [destination, balance, escrowed] = await Promise.all([
|
|
45
|
+
readContract(client, { address, abi: governedVaultAbi, functionName: "destination" }),
|
|
46
|
+
getBalance(client, { address }),
|
|
47
|
+
readContract(client, { address: instance.addresses.revenueEscrow, abi: revenueEscrowAbi, functionName: "owed", args: [address, CURRENCY_ETH] }),
|
|
48
|
+
]);
|
|
49
|
+
return { vault, address, destination, balance, escrowed };
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether `wallet` is consolidated with `root` in the 6529 delegation contract (use case 999,
|
|
54
|
+
* all collections, registered in both directions and not expired). A consolidated wallet acts
|
|
55
|
+
* for the root's account with the same rights. Consolidations are made in the delegation
|
|
56
|
+
* contract itself (`instance.delegation`), not in these contracts.
|
|
57
|
+
*
|
|
58
|
+
* Contract: [`ConsolidationAdapter.isConsolidated`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/identity/ConsolidationAdapter.sol).
|
|
59
|
+
*/
|
|
60
|
+
export async function readIsConsolidated(client, instance, root, wallet) {
|
|
61
|
+
await assertInstanceChain(client, instance);
|
|
62
|
+
return readContract(client, {
|
|
63
|
+
address: instance.addresses.consolidationAdapter,
|
|
64
|
+
abi: consolidationAdapterAbi,
|
|
65
|
+
functionName: "isConsolidated",
|
|
66
|
+
args: [root, wallet],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
+
import { type StreamInstance } from "../instance.js";
|
|
3
|
+
import { type LogScanOptions } from "./chain.js";
|
|
4
|
+
/** One module slot of one contract: what is installed, and what is waiting to replace it. */
|
|
5
|
+
export interface ModuleSlot {
|
|
6
|
+
/** The contract that has the slot, and its address. */
|
|
7
|
+
readonly on: "Stream6529" | "StreamEditions6529" | "StreamDirectory6529";
|
|
8
|
+
readonly address: Address;
|
|
9
|
+
/** The slot's name, for example `RENDERER`, and what it is for. */
|
|
10
|
+
readonly slot: string;
|
|
11
|
+
readonly what: string;
|
|
12
|
+
/** The module in force, or null for an empty slot. */
|
|
13
|
+
readonly module: Address | null;
|
|
14
|
+
/** A proposed replacement and the Unix time from which it can take effect, or null. */
|
|
15
|
+
readonly pending: {
|
|
16
|
+
readonly module: Address;
|
|
17
|
+
readonly readyAt: number;
|
|
18
|
+
} | null;
|
|
19
|
+
}
|
|
20
|
+
/** A role of the access manager and who holds it. */
|
|
21
|
+
export interface RoleState {
|
|
22
|
+
readonly id: bigint;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** Seconds between scheduling and executing a call with this role, as set at genesis. */
|
|
25
|
+
readonly executionDelay: number;
|
|
26
|
+
/** The accounts checked, with whether each holds the role now and its own wait, in seconds. */
|
|
27
|
+
readonly holders: readonly {
|
|
28
|
+
readonly account: Address;
|
|
29
|
+
readonly label: string;
|
|
30
|
+
readonly isMember: boolean;
|
|
31
|
+
readonly executionDelay: number;
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
34
|
+
/** A governed function and the role that may call it now. */
|
|
35
|
+
export interface GovernedFunction {
|
|
36
|
+
readonly contract: string;
|
|
37
|
+
readonly address: Address;
|
|
38
|
+
readonly signature: string;
|
|
39
|
+
/** The role at genesis, and the role's wait in seconds. */
|
|
40
|
+
readonly role: string;
|
|
41
|
+
readonly delay: number;
|
|
42
|
+
/** The role ID the access manager answers now. */
|
|
43
|
+
readonly roleIdNow: bigint;
|
|
44
|
+
/** False when the role now is not the one set at genesis. */
|
|
45
|
+
readonly unchanged: boolean;
|
|
46
|
+
readonly note: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** A setting of the network: its value now and at genesis. */
|
|
49
|
+
export interface NetworkSetting {
|
|
50
|
+
readonly contract: string;
|
|
51
|
+
readonly address: Address;
|
|
52
|
+
readonly getter: string;
|
|
53
|
+
readonly now: bigint | null;
|
|
54
|
+
readonly atGenesis: bigint;
|
|
55
|
+
readonly changed: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** A call scheduled in the access manager that has not run yet. */
|
|
58
|
+
export interface ScheduledCall {
|
|
59
|
+
readonly operationId: Hex;
|
|
60
|
+
readonly caller: Address;
|
|
61
|
+
readonly target: Address;
|
|
62
|
+
/** The contract and function, when the target and selector are in the governance table. */
|
|
63
|
+
readonly what: string | null;
|
|
64
|
+
readonly data: Hex;
|
|
65
|
+
/** Unix seconds from which it can be executed. */
|
|
66
|
+
readonly executableAt: number;
|
|
67
|
+
/** True when it can be executed now. */
|
|
68
|
+
readonly ready: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** The state of an instance's governance, read from the chain. */
|
|
71
|
+
export interface NetworkState {
|
|
72
|
+
/** The account that governs, as the access manager answers, and a proposed successor if any. */
|
|
73
|
+
readonly network: Address;
|
|
74
|
+
readonly pendingNetwork: Address | null;
|
|
75
|
+
/** True when the network on chain is the one the instance's genesis file names. */
|
|
76
|
+
readonly networkUnchanged: boolean;
|
|
77
|
+
readonly accessManager: Address;
|
|
78
|
+
/** Every module slot of the token contracts and the directory. */
|
|
79
|
+
readonly modules: readonly ModuleSlot[];
|
|
80
|
+
/** How long a proposed module waits on each contract, in seconds. */
|
|
81
|
+
readonly moduleDelays: readonly {
|
|
82
|
+
readonly on: ModuleSlot["on"];
|
|
83
|
+
readonly seconds: number;
|
|
84
|
+
}[];
|
|
85
|
+
readonly roles: readonly RoleState[];
|
|
86
|
+
readonly functions: readonly GovernedFunction[];
|
|
87
|
+
readonly settings: readonly NetworkSetting[];
|
|
88
|
+
/** Calls scheduled in the access manager that are still waiting or ready. */
|
|
89
|
+
readonly scheduled: readonly ScheduledCall[];
|
|
90
|
+
/** Whether new sales are paused on each auction (bids, settling and claims always work). */
|
|
91
|
+
readonly paused: {
|
|
92
|
+
readonly englishAuction: boolean;
|
|
93
|
+
readonly editionAuction: boolean;
|
|
94
|
+
readonly independentEditionAuction: boolean;
|
|
95
|
+
};
|
|
96
|
+
/** Whether each auction may mint on its token contract now. */
|
|
97
|
+
readonly minters: {
|
|
98
|
+
readonly englishAuctionOnStream: boolean;
|
|
99
|
+
readonly editionAuctionOnEditions: boolean;
|
|
100
|
+
};
|
|
101
|
+
/** The network's share and the royalty rate for new works of each product, out of 100,000. */
|
|
102
|
+
readonly economics: readonly {
|
|
103
|
+
readonly product: "stream" | "editions" | "independent";
|
|
104
|
+
readonly feeRecipient: Address;
|
|
105
|
+
readonly feeShare: number;
|
|
106
|
+
readonly royaltyRate: number;
|
|
107
|
+
}[];
|
|
108
|
+
/** Where unsold curated works go. */
|
|
109
|
+
readonly museum: Address;
|
|
110
|
+
/** The chain's time when this was read, in Unix seconds. */
|
|
111
|
+
readonly readAt: bigint;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A read-only view of how an instance is governed right now: the network account, the modules
|
|
115
|
+
* in force and any waiting to replace them, each role and who holds it, the role each governed
|
|
116
|
+
* function needs, the settings, and the calls scheduled in the access manager with the time
|
|
117
|
+
* each can run.
|
|
118
|
+
*
|
|
119
|
+
* The roles, functions and settings to look at come from the instance's genesis table
|
|
120
|
+
* (`instance.governance`); each is then read from the chain, and a value that differs from
|
|
121
|
+
* genesis is flagged (`unchanged: false`, `changed: true`). Role holders checked are the
|
|
122
|
+
* network, the genesis holders, the open gate if there is one, and any `extraAccounts`: the
|
|
123
|
+
* access manager cannot list a role's members, so an account granted a role later is found
|
|
124
|
+
* only if it is named.
|
|
125
|
+
*
|
|
126
|
+
* Contract: [`AccessManager`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/manager/AccessManager.sol)
|
|
127
|
+
* `hasRole`, `getTargetFunctionRole`, `getSchedule`, event `OperationScheduled`;
|
|
128
|
+
* [`StreamDirectory6529`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/core/StreamDirectory6529.sol)
|
|
129
|
+
* and the token contracts' `moduleOf`, `pendingModule`, `moduleDelay`;
|
|
130
|
+
* [`EconomicsResolver.economics`, `museum`](https://github.com/6529-Collections/6529-stream/blob/c6d4965861907841519cf3878c9db7052424a9a0/src/economics/EconomicsResolver.sol).
|
|
131
|
+
*/
|
|
132
|
+
export declare function readNetwork(client: Client, instance: StreamInstance, options?: LogScanOptions & {
|
|
133
|
+
readonly extraAccounts?: readonly {
|
|
134
|
+
readonly account: Address;
|
|
135
|
+
readonly label: string;
|
|
136
|
+
}[];
|
|
137
|
+
}): Promise<NetworkState>;
|