@artblocks/contracts 1.5.0 → 1.7.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/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +61 -148
- package/artifacts/contracts/generator/GenArt721GeneratorV0.sol/GenArt721GeneratorV0.json +15 -2
- package/artifacts/contracts/generator/InPlaceDocument.sol/InPlaceDocument.json +10 -0
- package/artifacts/contracts/interfaces/v0.8.x/IAbxfsFileDataReader.sol/IAbxfsFileDataReader.json +109 -0
- package/artifacts/contracts/interfaces/v0.8.x/IAbxfsFileStore.sol/IAbxfsFileStore.json +86 -0
- package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +41 -27
- package/artifacts/contracts/interfaces/v0.8.x/IFormPaletteBindingHooks.sol/IFormPaletteBindingHooks.json +723 -0
- package/artifacts/contracts/interfaces/v0.8.x/IPMPProjectViewsV0.sol/IPMPProjectViewsV0.json +126 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterRequiredPMPV0.sol/ISharedMinterRequiredPMPV0.json +36 -0
- package/artifacts/contracts/libs/v0.8.x/AbxfsCanonical.sol/AbxfsCanonical.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol/DependencyRegistryStorageLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/RequiredPMPLib.sol/RequiredPMPLib.json +10 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePMPV0.sol/MinterSetPricePMPV0.json +613 -0
- package/artifacts/contracts/mock/CallProbeMock.sol/CallProbeMock.json +45 -0
- package/artifacts/contracts/mock/GasProbeMock.sol/GasProbeMock.json +45 -0
- package/artifacts/contracts/mock/GenArt721GeneratorV0ScriptyReferenceMock.sol/GenArt721GeneratorV0ScriptyReferenceMock.json +346 -0
- package/artifacts/contracts/mock/GenArt721GeneratorV0ScriptyReferenceMock.sol/ILegacyGenArt721CoreV2_PBAB_Flex.json +47 -0
- package/artifacts/contracts/mock/InPlaceDocumentHarnessMock.sol/InPlaceDocumentHarnessMock.json +161 -0
- package/artifacts/contracts/mock/MockAbxfsFileDataReader.sol/IMockFileStore.json +91 -0
- package/artifacts/contracts/mock/MockAbxfsFileDataReader.sol/MockAbxfsFileDataReader.json +183 -0
- package/artifacts/contracts/mock/MockAbxfsFileStore.sol/MockAbxfsFileStore.json +204 -0
- package/artifacts/contracts/mock/MockPMPMinterReentrantConfigureHook.sol/IMinterPMPPurchase.json +91 -0
- package/artifacts/contracts/mock/MockPMPMinterReentrantConfigureHook.sol/MockPMPMinterReentrantConfigureHook.json +180 -0
- package/artifacts/contracts/mock/MockPMPReentrantConfigureHook.sol/MockPMPReentrantConfigureHook.json +158 -0
- package/artifacts/contracts/mock/RawResponseMock.sol/RawResponseMock.json +61 -0
- package/artifacts/contracts/mock/ReentrancyPMPMockShared.sol/IMinterPurchaseWithPMPs.json +67 -0
- package/artifacts/contracts/mock/ReentrancyPMPMockShared.sol/ReentrancyPMPMockShared.json +154 -0
- package/artifacts/contracts/web3call/combined-hooks/FormPaletteBindingHooks.sol/FormPaletteBindingHooks.json +919 -0
- package/contracts/DependencyRegistryV0.sol +136 -226
- package/contracts/generator/GenArt721GeneratorV0.sol +541 -280
- package/contracts/generator/InPlaceDocument.sol +306 -0
- package/contracts/interfaces/v0.8.x/IAbxfsFileDataReader.sol +67 -0
- package/contracts/interfaces/v0.8.x/IAbxfsFileStore.sol +40 -0
- package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +33 -22
- package/contracts/interfaces/v0.8.x/IFormPaletteBindingHooks.sol +339 -0
- package/contracts/interfaces/v0.8.x/IPMPProjectViewsV0.sol +59 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterRequiredPMPV0.sol +27 -0
- package/contracts/libs/v0.8.x/AbxfsCanonical.sol +23 -0
- package/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol +10 -4
- package/contracts/libs/v0.8.x/minter-libs/RequiredPMPLib.sol +336 -0
- package/contracts/minter-suite/Minters/MinterSetPricePMPV0.sol +664 -0
- package/contracts/mock/CallProbeMock.sol +20 -0
- package/contracts/mock/GasProbeMock.sol +21 -0
- package/contracts/mock/GenArt721GeneratorV0ScriptyReferenceMock.sol +1316 -0
- package/contracts/mock/InPlaceDocumentHarnessMock.sol +189 -0
- package/contracts/mock/MockAbxfsFileDataReader.sol +134 -0
- package/contracts/mock/MockAbxfsFileStore.sol +125 -0
- package/contracts/mock/MockPMPMinterReentrantConfigureHook.sol +85 -0
- package/contracts/mock/MockPMPReentrantConfigureHook.sol +59 -0
- package/contracts/mock/RawResponseMock.sol +58 -0
- package/contracts/mock/ReentrancyPMPMockShared.sol +81 -0
- package/contracts/web3call/combined-hooks/FormPaletteBindingHooks.sol +1392 -0
- package/package.json +1 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Created By: Art Blocks Inc.
|
|
3
|
+
// `encodeBase64` is ported from ABX FS's FileDataReader `_encodeBase64`
|
|
4
|
+
// (https://github.com/ArtBlocks/abxfs, packages/contracts-companion/src/FileDataReader.sol, MIT),
|
|
5
|
+
// with one change, described at the function.
|
|
6
|
+
pragma solidity ^0.8.22;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title InPlaceDocument
|
|
10
|
+
* @author Art Blocks Inc.
|
|
11
|
+
* @notice Writes a document (a `bytes` value) in one buffer at the end of memory, then returns it
|
|
12
|
+
* from the current call where it is: as it is, or as a base64 data URI encoded in place.
|
|
13
|
+
* @dev A view that assembles a large document pays for the memory it touches, at a cost
|
|
14
|
+
* quadratic in the highest address touched. Assembled the usual way, the document is copied
|
|
15
|
+
* several times: into each intermediate value, into the ABI encoding of any external call that
|
|
16
|
+
* assembles it and out of that call's return data, and into the ABI encoding of the return
|
|
17
|
+
* value. Here each part is written once, at its place in the document, and the document is
|
|
18
|
+
* returned with no copy.
|
|
19
|
+
*
|
|
20
|
+
* Layout, from `doc`, the address of the document's length word:
|
|
21
|
+
*
|
|
22
|
+
* doc - 0x20 ABI head (0x20), written when the document is returned
|
|
23
|
+
* doc the document's length, written when it is returned
|
|
24
|
+
* doc + 0x20 the content, from `doc + 0x20` to `end`
|
|
25
|
+
*
|
|
26
|
+
* While a document is open, the free memory pointer is `end` rounded up to a whole word: the
|
|
27
|
+
* document is the last allocation, and grows in place. Nothing else may be allocated in memory
|
|
28
|
+
* until it is returned, since the next part is written where that allocation would be. Parts are
|
|
29
|
+
* written in whole words, so up to 31 bytes past `end` may hold junk; the next part writes over
|
|
30
|
+
* it, and the document's padding is zeroed when it is returned.
|
|
31
|
+
*/
|
|
32
|
+
library InPlaceDocument {
|
|
33
|
+
/**
|
|
34
|
+
* @notice Opens a document at the free memory pointer.
|
|
35
|
+
* @return doc The address of the document's length word.
|
|
36
|
+
* @return end The end of the (empty) content, where the first part goes.
|
|
37
|
+
*/
|
|
38
|
+
function open() internal pure returns (uint256 doc, uint256 end) {
|
|
39
|
+
assembly ("memory-safe") {
|
|
40
|
+
// one word for the ABI head, then the length word
|
|
41
|
+
doc := add(mload(0x40), 0x20)
|
|
42
|
+
end := add(doc, 0x20)
|
|
43
|
+
mstore(0x40, end)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @notice Appends `data` to the document ending at `end`.
|
|
49
|
+
* @return The document's new end.
|
|
50
|
+
*/
|
|
51
|
+
function appendBytes(
|
|
52
|
+
uint256 end,
|
|
53
|
+
bytes memory data
|
|
54
|
+
) internal pure returns (uint256) {
|
|
55
|
+
assembly ("memory-safe") {
|
|
56
|
+
let length := mload(data)
|
|
57
|
+
let src := add(data, 0x20)
|
|
58
|
+
for {
|
|
59
|
+
let i := 0
|
|
60
|
+
} lt(i, length) {
|
|
61
|
+
i := add(i, 0x20)
|
|
62
|
+
} {
|
|
63
|
+
mstore(add(end, i), mload(add(src, i)))
|
|
64
|
+
}
|
|
65
|
+
end := add(end, length)
|
|
66
|
+
mstore(0x40, and(add(end, 0x1f), not(0x1f)))
|
|
67
|
+
}
|
|
68
|
+
return end;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @notice Claims the memory up to `end`, after content was written there directly (e.g.
|
|
73
|
+
* copied from return data).
|
|
74
|
+
*/
|
|
75
|
+
function claim(uint256 end) internal pure {
|
|
76
|
+
assembly ("memory-safe") {
|
|
77
|
+
mstore(0x40, and(add(end, 0x1f), not(0x1f)))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @notice Returns from the current call with the document `doc` (content up to `end`) as the
|
|
83
|
+
* ABI-encoded `string`/`bytes` return value, in place: exactly `abi.encode(content)`, padding
|
|
84
|
+
* zeroed.
|
|
85
|
+
* @dev Never returns to its caller. The return type only lets a caller end with
|
|
86
|
+
* `return returnDocument(doc, end);`.
|
|
87
|
+
*/
|
|
88
|
+
function returnDocument(
|
|
89
|
+
uint256 doc,
|
|
90
|
+
uint256 end
|
|
91
|
+
) internal pure returns (string memory document) {
|
|
92
|
+
assembly ("memory-safe") {
|
|
93
|
+
document := doc
|
|
94
|
+
let length := sub(end, add(doc, 0x20))
|
|
95
|
+
mstore(doc, length)
|
|
96
|
+
// the padding to a whole word, which a part may have left junk in
|
|
97
|
+
mstore(end, 0)
|
|
98
|
+
mstore(sub(doc, 0x20), 0x20)
|
|
99
|
+
return(sub(doc, 0x20), add(0x40, and(add(length, 0x1f), not(0x1f))))
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @notice Returns from the current call with `prefix` followed by the base64 (RFC 4648,
|
|
105
|
+
* padded) of the document `doc` (content up to `end`), as the ABI-encoded `string` return
|
|
106
|
+
* value, in place: exactly `abi.encode(string.concat(prefix, Base64.encode(content)))`.
|
|
107
|
+
* @param prefix The prefix, left-aligned; bytes past `prefixLength` are ignored.
|
|
108
|
+
* @param prefixLength The prefix's length, at most 32.
|
|
109
|
+
* @dev Never returns to its caller (see `returnDocument`). The document becomes the encoding's
|
|
110
|
+
* input where `encodeBase64` reads in place: `groups + 64` bytes into the space the encoding
|
|
111
|
+
* fills, after the prefix, with the word after it zero. Moving it there is one copy through the
|
|
112
|
+
* identity precompile, which copies overlapping memory exactly (MCOPY needs Cancun; this
|
|
113
|
+
* library targets the repository's EVM version).
|
|
114
|
+
*/
|
|
115
|
+
function returnBase64DataUri(
|
|
116
|
+
uint256 doc,
|
|
117
|
+
uint256 end,
|
|
118
|
+
bytes32 prefix,
|
|
119
|
+
uint256 prefixLength
|
|
120
|
+
) internal view returns (string memory dataUri) {
|
|
121
|
+
uint256 size;
|
|
122
|
+
uint256 src;
|
|
123
|
+
uint256 dst;
|
|
124
|
+
assembly ("memory-safe") {
|
|
125
|
+
if gt(prefixLength, 0x20) {
|
|
126
|
+
revert(0, 0)
|
|
127
|
+
}
|
|
128
|
+
let content := add(doc, 0x20)
|
|
129
|
+
size := sub(end, content)
|
|
130
|
+
dst := add(content, prefixLength)
|
|
131
|
+
src := add(add(dst, div(add(size, 2), 3)), 0x40)
|
|
132
|
+
if iszero(staticcall(gas(), 0x04, content, size, src, size)) {
|
|
133
|
+
revert(0, 0)
|
|
134
|
+
}
|
|
135
|
+
mstore(add(src, size), 0)
|
|
136
|
+
// The prefix, then zeros to the end of its word. The encoding (if any) writes over
|
|
137
|
+
// the zeros; with no encoding they are the return value's padding.
|
|
138
|
+
mstore(content, and(prefix, not(shr(shl(3, prefixLength), not(0)))))
|
|
139
|
+
}
|
|
140
|
+
encodeBase64(src, size, dst);
|
|
141
|
+
assembly ("memory-safe") {
|
|
142
|
+
dataUri := doc
|
|
143
|
+
let length := add(prefixLength, shl(2, div(add(size, 2), 3)))
|
|
144
|
+
mstore(doc, length)
|
|
145
|
+
mstore(sub(doc, 0x20), 0x20)
|
|
146
|
+
return(sub(doc, 0x20), add(0x40, and(add(length, 0x1f), not(0x1f))))
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// @dev Base64-encodes (RFC 4648, padded) the `size` bytes at `src` to `dst`, front to back, and zeroes the word
|
|
151
|
+
/// after the encoding. Each step turns 24 bytes into 32 characters in one word, by arithmetic, with no table:
|
|
152
|
+
///
|
|
153
|
+
/// 1. Spread. The 24 bytes are 32 six-bit values `v`, the first in the high bits. Five steps move value `j` to
|
|
154
|
+
/// the low six bits of byte `j`: the high 16 values up 32 bits, then in each 128-bit lane the high 8 up 16,
|
|
155
|
+
/// then 4 up 8, 2 up 4 and 1 up 2. A step moves the bits under a mask `m` up `d` places by adding
|
|
156
|
+
/// `(x & m) * (2^d - 1)`, which is `x - (x & m) + ((x & m) << d)`; the bits it moves land on zeros and stay
|
|
157
|
+
/// below bit 256.
|
|
158
|
+
/// 2. Map. Byte `j` becomes `v + 65 + 6[v >= 26] - 75[v >= 52] - 15[v >= 62] + 3[v >= 63]`: `A`-`Z`, `a`-`z`,
|
|
159
|
+
/// `0`-`9`, `+`, `/`. `[v >= t]` is bit 7 of `v + 128 - t`, which is at most 165, so those additions carry
|
|
160
|
+
/// nothing between bytes; for `v >= 62`, `[v >= 63]` is bit 0 of `v`. The sum's bytes are each a character
|
|
161
|
+
/// (43 to 122), so the word holds exactly those bytes, whatever the order of its terms.
|
|
162
|
+
///
|
|
163
|
+
/// The one change from ABX FS: bit 7 of each byte of `v + 128 - t` is moved to bit 0 of that byte by masking
|
|
164
|
+
/// with `0x80...80`, then shifting right 7, for `[v >= 26]` only. For `[v >= 52]` it is shifting right 7, then
|
|
165
|
+
/// masking with `0x01...01`; for `[v >= 62]`, shifting right 6, masking with `0x02...02`, then shifting right
|
|
166
|
+
/// 1. Each picks the same bit, so the result is the same. With one 32-byte mask used three times per step,
|
|
167
|
+
/// solc at this repository's optimizer setting (runs: 10) loads it from code with CODECOPY at each use; with
|
|
168
|
+
/// three masks used once each, it pushes them. That makes the encoder about 16.5 gas per byte here rather
|
|
169
|
+
/// than 20.5.
|
|
170
|
+
///
|
|
171
|
+
/// In place: `src` lies `groups + 64` bytes past `dst`, where `groups = ceil(size / 3)`. Step `k` loads the
|
|
172
|
+
/// word at `src + 24k`, keeps its first 24 bytes, and writes the 32 bytes at `dst + 32k`. The writes before it
|
|
173
|
+
/// end at `dst + 32k`, which is at most `src + 24k` because `8k < size / 3 <= groups` for every step
|
|
174
|
+
/// `k < ceil(size / 24)`. So no write reaches a byte before it is read, and the word after the data is still
|
|
175
|
+
/// zero (the caller zeroes it) when the last step reads it as the bits past the data's end. The last step's
|
|
176
|
+
/// zeros encode as at most 31 characters past the encoding's end; the padding, then the zeroed word after the
|
|
177
|
+
/// encoding, overwrite them.
|
|
178
|
+
function encodeBase64(
|
|
179
|
+
uint256 src,
|
|
180
|
+
uint256 size,
|
|
181
|
+
uint256 dst
|
|
182
|
+
) internal pure {
|
|
183
|
+
assembly ("memory-safe") {
|
|
184
|
+
if size {
|
|
185
|
+
let end := add(dst, shl(2, div(add(size, 2), 3)))
|
|
186
|
+
let ptr := dst
|
|
187
|
+
let data := src
|
|
188
|
+
for {
|
|
189
|
+
|
|
190
|
+
} 1 {
|
|
191
|
+
|
|
192
|
+
} {
|
|
193
|
+
let x := shr(64, mload(data))
|
|
194
|
+
// Spread.
|
|
195
|
+
x := add(
|
|
196
|
+
x,
|
|
197
|
+
mul(
|
|
198
|
+
and(
|
|
199
|
+
x,
|
|
200
|
+
0x0000000000000000ffffffffffffffffffffffff000000000000000000000000
|
|
201
|
+
),
|
|
202
|
+
0xffffffff
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
x := add(
|
|
206
|
+
x,
|
|
207
|
+
mul(
|
|
208
|
+
and(
|
|
209
|
+
x,
|
|
210
|
+
0x00000000ffffffffffff00000000000000000000ffffffffffff000000000000
|
|
211
|
+
),
|
|
212
|
+
0xffff
|
|
213
|
+
)
|
|
214
|
+
)
|
|
215
|
+
x := add(
|
|
216
|
+
x,
|
|
217
|
+
mul(
|
|
218
|
+
and(
|
|
219
|
+
x,
|
|
220
|
+
0x0000ffffff0000000000ffffff0000000000ffffff0000000000ffffff000000
|
|
221
|
+
),
|
|
222
|
+
0xff
|
|
223
|
+
)
|
|
224
|
+
)
|
|
225
|
+
x := add(
|
|
226
|
+
x,
|
|
227
|
+
mul(
|
|
228
|
+
and(
|
|
229
|
+
x,
|
|
230
|
+
0x00fff00000fff00000fff00000fff00000fff00000fff00000fff00000fff000
|
|
231
|
+
),
|
|
232
|
+
0xf
|
|
233
|
+
)
|
|
234
|
+
)
|
|
235
|
+
x := add(
|
|
236
|
+
x,
|
|
237
|
+
mul(
|
|
238
|
+
and(
|
|
239
|
+
x,
|
|
240
|
+
0x0fc00fc00fc00fc00fc00fc00fc00fc00fc00fc00fc00fc00fc00fc00fc00fc0
|
|
241
|
+
),
|
|
242
|
+
0x3
|
|
243
|
+
)
|
|
244
|
+
)
|
|
245
|
+
// Map. `[v >= 26]`, `[v >= 52]` and `[v >= 62]` in bit 0 of each byte; `[v >= 63]` is `ge62 & v`.
|
|
246
|
+
let ge26 := shr(
|
|
247
|
+
7,
|
|
248
|
+
and(
|
|
249
|
+
add(
|
|
250
|
+
x,
|
|
251
|
+
0x6666666666666666666666666666666666666666666666666666666666666666
|
|
252
|
+
),
|
|
253
|
+
0x8080808080808080808080808080808080808080808080808080808080808080
|
|
254
|
+
)
|
|
255
|
+
)
|
|
256
|
+
let ge52 := and(
|
|
257
|
+
shr(
|
|
258
|
+
7,
|
|
259
|
+
add(
|
|
260
|
+
x,
|
|
261
|
+
0x4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c
|
|
262
|
+
)
|
|
263
|
+
),
|
|
264
|
+
0x0101010101010101010101010101010101010101010101010101010101010101
|
|
265
|
+
)
|
|
266
|
+
let ge62 := shr(
|
|
267
|
+
1,
|
|
268
|
+
and(
|
|
269
|
+
shr(
|
|
270
|
+
6,
|
|
271
|
+
add(
|
|
272
|
+
x,
|
|
273
|
+
0x4242424242424242424242424242424242424242424242424242424242424242
|
|
274
|
+
)
|
|
275
|
+
),
|
|
276
|
+
0x0202020202020202020202020202020202020202020202020202020202020202
|
|
277
|
+
)
|
|
278
|
+
)
|
|
279
|
+
mstore(
|
|
280
|
+
ptr,
|
|
281
|
+
sub(
|
|
282
|
+
add(
|
|
283
|
+
x,
|
|
284
|
+
add(
|
|
285
|
+
0x4141414141414141414141414141414141414141414141414141414141414141,
|
|
286
|
+
add(mul(ge26, 6), mul(and(ge62, x), 3))
|
|
287
|
+
)
|
|
288
|
+
),
|
|
289
|
+
add(mul(ge52, 75), mul(ge62, 15))
|
|
290
|
+
)
|
|
291
|
+
)
|
|
292
|
+
ptr := add(ptr, 0x20)
|
|
293
|
+
if iszero(lt(ptr, end)) {
|
|
294
|
+
break
|
|
295
|
+
}
|
|
296
|
+
data := add(data, 24)
|
|
297
|
+
}
|
|
298
|
+
// `o = [0, 2, 1][size % 3]` padding characters at the encoding's end; then the word after it is zeroed,
|
|
299
|
+
// which clears the last step's extra characters and pads the encoding to a whole word.
|
|
300
|
+
let o := div(2, mod(size, 3))
|
|
301
|
+
mstore(sub(end, o), shl(240, 0x3d3d))
|
|
302
|
+
mstore(end, 0)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
// Created By: Art Blocks Inc.
|
|
3
|
+
pragma solidity ^0.8.17;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @title IAbxfsFileDataReader
|
|
7
|
+
* @notice Read interface of the ABX FS FileDataReader, the companion contract that returns an ABX
|
|
8
|
+
* FS file's stored data (its chunks joined) for any file-level codec. FileDataReader is stateless,
|
|
9
|
+
* immutable and deployed by CREATE2 at the same address on every chain ABX FS supports.
|
|
10
|
+
* @dev Mirrors the subset of ABX FS `FileDataReader` read by the generator and the dependency
|
|
11
|
+
* registry. See
|
|
12
|
+
* https://github.com/ArtBlocks/abxfs (packages/contracts-companion/src/FileDataReader.sol).
|
|
13
|
+
* Every chunk returned is checked against the content hash ABX FS's ChunkStore recorded for it.
|
|
14
|
+
*/
|
|
15
|
+
interface IAbxfsFileDataReader {
|
|
16
|
+
/**
|
|
17
|
+
* @notice A whole file's data, base64-encoded (RFC 4648, padded).
|
|
18
|
+
* @param cid ABX FS file CID.
|
|
19
|
+
* @param maxBytes Refuse files whose data is larger than this many bytes.
|
|
20
|
+
* @param maxChunks Refuse files with more than this many chunks.
|
|
21
|
+
* @return mimeType The file's MIME type (of its content, not of the encoded data).
|
|
22
|
+
* @return codec The file-level codec token (e.g. "gzip"), zero for none; when set, the data
|
|
23
|
+
* is the encoded form.
|
|
24
|
+
* @return outputHash `keccak256(content)` for a file with a codec, zero otherwise.
|
|
25
|
+
* @return base64 The file's data, base64-encoded.
|
|
26
|
+
*/
|
|
27
|
+
function readFileDataBase64(
|
|
28
|
+
bytes32 cid,
|
|
29
|
+
uint256 maxBytes,
|
|
30
|
+
uint256 maxChunks
|
|
31
|
+
)
|
|
32
|
+
external
|
|
33
|
+
view
|
|
34
|
+
returns (
|
|
35
|
+
string memory mimeType,
|
|
36
|
+
bytes32 codec,
|
|
37
|
+
bytes32 outputHash,
|
|
38
|
+
string memory base64
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @notice Base64 (RFC 4648) of bytes `[start, start + length)` of a file's data: exactly the
|
|
43
|
+
* matching slice of `readFileDataBase64`'s result, so consecutive ranges concatenate to the
|
|
44
|
+
* whole file's base64. `start` must be a multiple of 3, and so must `length` unless the range
|
|
45
|
+
* ends at the end of the file; padding appears only there.
|
|
46
|
+
* @param cid ABX FS file CID.
|
|
47
|
+
* @param start First byte of the range.
|
|
48
|
+
* @param length Bytes in the range.
|
|
49
|
+
* @param maxBytes Refuse when the chunks the range touches hold more than this many bytes.
|
|
50
|
+
* @param maxChunks Refuse when the range touches more than this many chunks.
|
|
51
|
+
*/
|
|
52
|
+
function readFileDataRangeBase64(
|
|
53
|
+
bytes32 cid,
|
|
54
|
+
uint256 start,
|
|
55
|
+
uint256 length,
|
|
56
|
+
uint256 maxBytes,
|
|
57
|
+
uint256 maxChunks
|
|
58
|
+
)
|
|
59
|
+
external
|
|
60
|
+
view
|
|
61
|
+
returns (
|
|
62
|
+
string memory mimeType,
|
|
63
|
+
bytes32 codec,
|
|
64
|
+
bytes32 outputHash,
|
|
65
|
+
string memory base64
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
// Created By: Art Blocks Inc.
|
|
3
|
+
pragma solidity ^0.8.17;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @title IAbxfsFileStore
|
|
7
|
+
* @notice Minimal read interface of the ABX FS FileStore, the store-layer contract holding ABX FS
|
|
8
|
+
* files. FileStore is immutable and deployed by CREATE2 at the same address on every supported
|
|
9
|
+
* chain, and a file's CID is derived from its content, so a CID is valid on every chain the file
|
|
10
|
+
* has been uploaded to.
|
|
11
|
+
* @dev Mirrors the subset of ABX FS `IFileStore` read by the dependency registry. See
|
|
12
|
+
* https://github.com/ArtBlocks/abxfs (packages/contracts-core/src/interfaces/IFileStore.sol).
|
|
13
|
+
* A file's "data" is its stored bytes (chunks joined); when `codec` is non-zero (e.g. "gzip"),
|
|
14
|
+
* the file's content is `decode(codec, data)` and is decoded off chain.
|
|
15
|
+
*/
|
|
16
|
+
interface IAbxfsFileStore {
|
|
17
|
+
struct FileInfo {
|
|
18
|
+
bytes32 root;
|
|
19
|
+
uint8 rootLevel;
|
|
20
|
+
uint256 chunkCount;
|
|
21
|
+
// total bytes of the joined chunk data, before any file-level codec is decoded
|
|
22
|
+
uint256 size;
|
|
23
|
+
string mimeType;
|
|
24
|
+
bytes32 codec;
|
|
25
|
+
bytes32 outputHash;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @notice Returns whether `cid` is a file on this chain.
|
|
30
|
+
*/
|
|
31
|
+
function fileExists(bytes32 cid) external view returns (bool);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @notice Returns the metadata of file `cid`. Reverts for a CID that is not a file on this
|
|
35
|
+
* chain.
|
|
36
|
+
*/
|
|
37
|
+
function getFileInfo(
|
|
38
|
+
bytes32 cid
|
|
39
|
+
) external view returns (FileInfo memory info);
|
|
40
|
+
}
|
|
@@ -81,6 +81,7 @@ interface IDependencyRegistryV0 {
|
|
|
81
81
|
uint256 indexed additionalRepositoryIndex
|
|
82
82
|
);
|
|
83
83
|
|
|
84
|
+
/// @notice No longer emitted. Declared so indexers keep decoding the events already on chain.
|
|
84
85
|
event DependencyScriptUpdated(bytes32 indexed dependencyNameAndVersion);
|
|
85
86
|
|
|
86
87
|
event CoreRegistryAddressUpdated(address indexed coreRegistryAddress);
|
|
@@ -103,6 +104,11 @@ interface IDependencyRegistryV0 {
|
|
|
103
104
|
string projectScriptSpecialType
|
|
104
105
|
);
|
|
105
106
|
|
|
107
|
+
event DependencyAbxfsFileCidUpdated(
|
|
108
|
+
bytes32 indexed dependencyNameAndVersion,
|
|
109
|
+
bytes32 abxfsFileCid
|
|
110
|
+
);
|
|
111
|
+
|
|
106
112
|
/**
|
|
107
113
|
* @notice Enum representing the canvas tag requirements for a dependency.
|
|
108
114
|
* @dev Conveys whether generated HTML must include a canvas tag, and where.
|
|
@@ -155,10 +161,10 @@ interface IDependencyRegistryV0 {
|
|
|
155
161
|
uint24 additionalRepositoryCount;
|
|
156
162
|
// project website URL for dependency
|
|
157
163
|
string dependencyWebsite;
|
|
158
|
-
// whether the dependency is
|
|
164
|
+
// whether the dependency is on chain: true if and only if it has an ABX FS file
|
|
159
165
|
bool availableOnChain;
|
|
160
|
-
//
|
|
161
|
-
|
|
166
|
+
// CID of the gzip-codec ABX FS file holding the dependency's script, or zero if none
|
|
167
|
+
bytes32 abxfsFileCid;
|
|
162
168
|
// whether the dependency's own script is an ES module, and therefore must be exposed to
|
|
163
169
|
// project scripts via an import map rather than loaded with a plain `<script src>` tag
|
|
164
170
|
bool loadAsModule;
|
|
@@ -171,26 +177,30 @@ interface IDependencyRegistryV0 {
|
|
|
171
177
|
}
|
|
172
178
|
|
|
173
179
|
/**
|
|
174
|
-
* @notice Returns the
|
|
175
|
-
*
|
|
180
|
+
* @notice Returns the CID of the gzip-codec ABX FS file holding the script for dependency
|
|
181
|
+
* `dependencyNameAndVersion`, or zero if none is set. A dependency is on chain if and only
|
|
182
|
+
* if this is non-zero.
|
|
183
|
+
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
176
184
|
*/
|
|
177
|
-
function
|
|
185
|
+
function getDependencyAbxfsFileCid(
|
|
178
186
|
bytes32 dependencyNameAndVersion
|
|
179
|
-
) external view returns (
|
|
187
|
+
) external view returns (bytes32);
|
|
180
188
|
|
|
181
189
|
/**
|
|
182
|
-
* @notice Returns
|
|
183
|
-
*
|
|
190
|
+
* @notice Returns the number of slices `getDependencyScript` serves for dependency
|
|
191
|
+
* `dependencyNameAndVersion`'s ABX FS file, or zero if it has none.
|
|
192
|
+
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
184
193
|
*/
|
|
185
|
-
function
|
|
186
|
-
bytes32 dependencyNameAndVersion
|
|
187
|
-
|
|
188
|
-
) external view returns (address);
|
|
194
|
+
function getDependencyScriptCount(
|
|
195
|
+
bytes32 dependencyNameAndVersion
|
|
196
|
+
) external view returns (uint256);
|
|
189
197
|
|
|
190
198
|
/**
|
|
191
|
-
* @notice Returns
|
|
192
|
-
*
|
|
193
|
-
*
|
|
199
|
+
* @notice Returns slice `index` of dependency `dependencyNameAndVersion`'s ABX FS file:
|
|
200
|
+
* the base64 encoding of a fixed-size, three-byte-aligned range of its gzip bytes. The slices
|
|
201
|
+
* concatenated in order are the base64 encoding of the whole gzip file.
|
|
202
|
+
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
203
|
+
* @param index Index of the slice, less than `getDependencyScriptCount`.
|
|
194
204
|
*/
|
|
195
205
|
function getDependencyScript(
|
|
196
206
|
bytes32 dependencyNameAndVersion,
|
|
@@ -207,10 +217,11 @@ interface IDependencyRegistryV0 {
|
|
|
207
217
|
) external view returns (DependencyDetails memory dependencyDetails);
|
|
208
218
|
|
|
209
219
|
/**
|
|
210
|
-
* @notice Returns details for a given dependency type `dependencyNameAndVersion
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
220
|
+
* @notice Returns details for a given dependency type `dependencyNameAndVersion`, as a
|
|
221
|
+
* tuple.
|
|
222
|
+
* @dev `getDependencyDetailsV2` returns every field. This tuple form keeps its signature for
|
|
223
|
+
* deployed consumers that decode it; `availableOnChain` is whether the dependency has an ABX
|
|
224
|
+
* FS file, and `scriptCount` is `getDependencyScriptCount`.
|
|
214
225
|
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
215
226
|
* @return nameAndVersion String representation of `dependencyNameAndVersion`.
|
|
216
227
|
* (e.g. "p5js(atSymbol)1.0.0")
|
|
@@ -220,8 +231,8 @@ interface IDependencyRegistryV0 {
|
|
|
220
231
|
* @return preferredRepository Preferred repository URL for dependency
|
|
221
232
|
* @return additionalRepositoryCount Count of additional repository URLs for dependency
|
|
222
233
|
* @return dependencyWebsite Project website URL for dependency
|
|
223
|
-
* @return availableOnChain Whether dependency is
|
|
224
|
-
* @return scriptCount
|
|
234
|
+
* @return availableOnChain Whether dependency is on chain (has an ABX FS file)
|
|
235
|
+
* @return scriptCount Number of slices `getDependencyScript` serves for the ABX FS file
|
|
225
236
|
*/
|
|
226
237
|
function getDependencyDetails(
|
|
227
238
|
bytes32 dependencyNameAndVersion
|