@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
|
@@ -9,6 +9,8 @@ import "./interfaces/v0.8.x/IDependencyRegistryV0.sol";
|
|
|
9
9
|
import "./interfaces/v0.8.x/ICoreRegistryV1.sol";
|
|
10
10
|
import "./interfaces/v0.8.x/IBytecodeStorageReaderV2.sol";
|
|
11
11
|
import "./interfaces/v0.8.x/IUniversalBytecodeStorageReader.sol";
|
|
12
|
+
import {IAbxfsFileStore} from "./interfaces/v0.8.x/IAbxfsFileStore.sol";
|
|
13
|
+
import {IAbxfsFileDataReader} from "./interfaces/v0.8.x/IAbxfsFileDataReader.sol";
|
|
12
14
|
|
|
13
15
|
import "@openzeppelin-4.7/contracts/utils/Strings.sol";
|
|
14
16
|
import "@openzeppelin-4.7/contracts/utils/structs/EnumerableSet.sol";
|
|
@@ -19,6 +21,7 @@ import "@openzeppelin-4.5/contracts/utils/math/SafeCast.sol";
|
|
|
19
21
|
import "./libs/v0.8.x/DependencyRegistryStorageLib.sol";
|
|
20
22
|
import "./libs/v0.8.x/BytecodeStorageV2.sol";
|
|
21
23
|
import "./libs/v0.8.x/Bytes32Strings.sol";
|
|
24
|
+
import {AbxfsCanonical} from "./libs/v0.8.x/AbxfsCanonical.sol";
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* @title Art Blocks Dependency Registry, V0.
|
|
@@ -31,6 +34,9 @@ import "./libs/v0.8.x/Bytes32Strings.sol";
|
|
|
31
34
|
* to our non-upgradeable and immutable ERC-721 conforming core contracts,
|
|
32
35
|
* and has been made upgradeable as we expect its required functionality in
|
|
33
36
|
* relation to the Art Blocks ecosystem to evolve over time.
|
|
37
|
+
* @notice On-chain scripts: a dependency is on chain if and only if it has an ABX FS file
|
|
38
|
+
* (`abxfsFileCid`), a gzip-codec file on ABX FS whose decoded content is the dependency's
|
|
39
|
+
* script. This registry stores no scripts; it records which ABX FS file holds each one.
|
|
34
40
|
*/
|
|
35
41
|
contract DependencyRegistryV0 is
|
|
36
42
|
Initializable,
|
|
@@ -47,6 +53,14 @@ contract DependencyRegistryV0 is
|
|
|
47
53
|
|
|
48
54
|
uint8 constant AT_CHARACTER_CODE = uint8(bytes1("@")); // 0x40
|
|
49
55
|
|
|
56
|
+
IAbxfsFileStore constant ABXFS_FILE_STORE =
|
|
57
|
+
IAbxfsFileStore(AbxfsCanonical.FILE_STORE);
|
|
58
|
+
IAbxfsFileDataReader constant ABXFS_FILE_DATA_READER =
|
|
59
|
+
IAbxfsFileDataReader(AbxfsCanonical.FILE_DATA_READER);
|
|
60
|
+
// @dev Size of the ABX FS file ranges `getDependencyScript` serves. A multiple of three, so
|
|
61
|
+
// the base64 encodings of consecutive slices concatenate into the encoding of the whole file.
|
|
62
|
+
uint256 constant ABXFS_SCRIPT_SLICE_BYTES = 24_576; // 3 * 8192
|
|
63
|
+
|
|
50
64
|
function _onlyNonZeroAddress(address address_) internal pure {
|
|
51
65
|
require(address_ != address(0), "Must input non-zero address");
|
|
52
66
|
}
|
|
@@ -222,154 +236,19 @@ contract DependencyRegistryV0 is
|
|
|
222
236
|
|
|
223
237
|
require(
|
|
224
238
|
dependency.additionalCDNCount == 0 &&
|
|
225
|
-
dependency.additionalRepositoryCount == 0
|
|
226
|
-
|
|
227
|
-
"Cannot remove dependency with additional CDNs, repositories, or scripts"
|
|
239
|
+
dependency.additionalRepositoryCount == 0,
|
|
240
|
+
"Cannot remove dependency with additional CDNs or repositories"
|
|
228
241
|
);
|
|
229
242
|
|
|
230
243
|
ds.dependencyNameVersionIds.remove(dependencyNameAndVersion);
|
|
231
244
|
// @dev all of the arrays in the dependency struct are required to be empty
|
|
232
|
-
// before this function can be called, so we don't need to delete them here
|
|
245
|
+
// before this function can be called, so we don't need to delete them here.
|
|
246
|
+
// Deleting the record also clears its ABX FS file.
|
|
233
247
|
delete ds.dependencyRecords[dependencyNameAndVersion];
|
|
234
248
|
|
|
235
249
|
emit DependencyRemoved(dependencyNameAndVersion);
|
|
236
250
|
}
|
|
237
251
|
|
|
238
|
-
/**
|
|
239
|
-
* @notice Adds a script to dependency `dependencyNameAndVersion`, by way of
|
|
240
|
-
* providing a string to write to bytecode storage.
|
|
241
|
-
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
242
|
-
* @param script Script to be added. Required to be a non-empty string,
|
|
243
|
-
* but no further validation is performed.
|
|
244
|
-
*/
|
|
245
|
-
function addDependencyScript(
|
|
246
|
-
bytes32 dependencyNameAndVersion,
|
|
247
|
-
string memory script
|
|
248
|
-
) external {
|
|
249
|
-
_onlyAdminACL(this.addDependencyScript.selector);
|
|
250
|
-
_onlyNonEmptyString(script);
|
|
251
|
-
_onlyExistingDependency(dependencyNameAndVersion);
|
|
252
|
-
|
|
253
|
-
DependencyRegistryStorageLib.Dependency
|
|
254
|
-
storage dependency = DependencyRegistryStorageLib
|
|
255
|
-
.s()
|
|
256
|
-
.dependencyRecords[dependencyNameAndVersion];
|
|
257
|
-
// store script in contract bytecode
|
|
258
|
-
dependency.scriptBytecodeAddresses[dependency.scriptCount] = script
|
|
259
|
-
.writeToBytecode();
|
|
260
|
-
dependency.scriptCount = dependency.scriptCount + 1;
|
|
261
|
-
|
|
262
|
-
emit DependencyScriptUpdated(dependencyNameAndVersion);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* @notice Updates script for dependencyType `dependencyNameAndVersion` at script `index`,
|
|
267
|
-
* by way of providing a string to write to bytecode storage.
|
|
268
|
-
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
269
|
-
* @param index The index of a given script, relative to the overall `scriptCount`.
|
|
270
|
-
* @param script The updated script value. Required to be a non-empty
|
|
271
|
-
* string, but no further validation is performed.
|
|
272
|
-
*/
|
|
273
|
-
function updateDependencyScript(
|
|
274
|
-
bytes32 dependencyNameAndVersion,
|
|
275
|
-
uint256 index,
|
|
276
|
-
string memory script
|
|
277
|
-
) external {
|
|
278
|
-
_onlyAdminACL(this.updateDependencyScript.selector);
|
|
279
|
-
_onlyNonEmptyString(script);
|
|
280
|
-
_onlyExistingDependency(dependencyNameAndVersion);
|
|
281
|
-
|
|
282
|
-
DependencyRegistryStorageLib.Dependency
|
|
283
|
-
storage dependency = DependencyRegistryStorageLib
|
|
284
|
-
.s()
|
|
285
|
-
.dependencyRecords[dependencyNameAndVersion];
|
|
286
|
-
_onlyInRangeIndex({index: index, length: dependency.scriptCount});
|
|
287
|
-
// store script in contract bytecode, replacing reference address from
|
|
288
|
-
// the contract that no longer exists with the newly created one
|
|
289
|
-
dependency.scriptBytecodeAddresses[index] = script.writeToBytecode();
|
|
290
|
-
|
|
291
|
-
emit DependencyScriptUpdated(dependencyNameAndVersion);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* @notice Adds a script to dependency `dependencyNameAndVersion`, by way of
|
|
296
|
-
* providing an already written chunk of bytecode storage.
|
|
297
|
-
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
298
|
-
* @param scriptPointer Address of script to be added. Required to be a non-zero address,
|
|
299
|
-
* but no further validation is performed.
|
|
300
|
-
*/
|
|
301
|
-
function addDependencyScriptPointer(
|
|
302
|
-
bytes32 dependencyNameAndVersion,
|
|
303
|
-
address scriptPointer
|
|
304
|
-
) external {
|
|
305
|
-
_onlyAdminACL(this.addDependencyScriptPointer.selector);
|
|
306
|
-
_onlyNonZeroAddress(scriptPointer);
|
|
307
|
-
_onlyExistingDependency(dependencyNameAndVersion);
|
|
308
|
-
|
|
309
|
-
DependencyRegistryStorageLib.Dependency
|
|
310
|
-
storage dependency = DependencyRegistryStorageLib
|
|
311
|
-
.s()
|
|
312
|
-
.dependencyRecords[dependencyNameAndVersion];
|
|
313
|
-
// store script in contract bytecode
|
|
314
|
-
dependency.scriptBytecodeAddresses[
|
|
315
|
-
dependency.scriptCount
|
|
316
|
-
] = scriptPointer;
|
|
317
|
-
dependency.scriptCount = dependency.scriptCount + 1;
|
|
318
|
-
|
|
319
|
-
emit DependencyScriptUpdated(dependencyNameAndVersion);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* @notice Updates script for dependency id `dependencyNameAndVersion` at script `index`,
|
|
324
|
-
* by way of providing an already written chunk of bytecode storage.
|
|
325
|
-
* @param dependencyNameAndVersion Name of dependency (i.e. "name@version") used to identify dependency.
|
|
326
|
-
* @param index The index of a given script, relative to the overall `scriptCount`.
|
|
327
|
-
* @param scriptPointer The updated script pointer (address of bytecode storage).
|
|
328
|
-
* Required to be a non-zero address, but no further validation is performed.
|
|
329
|
-
*/
|
|
330
|
-
function updateDependencyScriptPointer(
|
|
331
|
-
bytes32 dependencyNameAndVersion,
|
|
332
|
-
uint256 index,
|
|
333
|
-
address scriptPointer
|
|
334
|
-
) external {
|
|
335
|
-
_onlyAdminACL(this.updateDependencyScriptPointer.selector);
|
|
336
|
-
_onlyNonZeroAddress(scriptPointer);
|
|
337
|
-
_onlyExistingDependency(dependencyNameAndVersion);
|
|
338
|
-
|
|
339
|
-
DependencyRegistryStorageLib.Dependency
|
|
340
|
-
storage dependency = DependencyRegistryStorageLib
|
|
341
|
-
.s()
|
|
342
|
-
.dependencyRecords[dependencyNameAndVersion];
|
|
343
|
-
_onlyInRangeIndex({index: index, length: dependency.scriptCount});
|
|
344
|
-
dependency.scriptBytecodeAddresses[index] = scriptPointer;
|
|
345
|
-
|
|
346
|
-
emit DependencyScriptUpdated(dependencyNameAndVersion);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* @notice Removes last script from dependency `dependencyNameAndVersion`.
|
|
351
|
-
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
352
|
-
*/
|
|
353
|
-
function removeDependencyLastScript(
|
|
354
|
-
bytes32 dependencyNameAndVersion
|
|
355
|
-
) external {
|
|
356
|
-
_onlyAdminACL(this.removeDependencyLastScript.selector);
|
|
357
|
-
_onlyExistingDependency(dependencyNameAndVersion);
|
|
358
|
-
|
|
359
|
-
DependencyRegistryStorageLib.Dependency
|
|
360
|
-
storage dependency = DependencyRegistryStorageLib
|
|
361
|
-
.s()
|
|
362
|
-
.dependencyRecords[dependencyNameAndVersion];
|
|
363
|
-
require(dependency.scriptCount > 0, "there are no scripts to remove");
|
|
364
|
-
// delete reference to old storage contract address
|
|
365
|
-
delete dependency.scriptBytecodeAddresses[dependency.scriptCount - 1];
|
|
366
|
-
unchecked {
|
|
367
|
-
dependency.scriptCount = dependency.scriptCount - 1;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
emit DependencyScriptUpdated(dependencyNameAndVersion);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
252
|
/**
|
|
374
253
|
* @notice Updates preferred CDN for dependency `dependencyNameAndVersion`.
|
|
375
254
|
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
@@ -531,6 +410,47 @@ contract DependencyRegistryV0 is
|
|
|
531
410
|
);
|
|
532
411
|
}
|
|
533
412
|
|
|
413
|
+
/**
|
|
414
|
+
* @notice Updates the ABX FS file holding the script for dependency
|
|
415
|
+
* `dependencyNameAndVersion`, which puts the dependency on chain. Set to zero to take it off
|
|
416
|
+
* chain.
|
|
417
|
+
* @dev A non-zero CID must be a gzip-codec file on this chain's ABX FS, whose decoded
|
|
418
|
+
* content is the dependency's script. CIDs are content-derived, so one value is valid on
|
|
419
|
+
* every chain the file has been uploaded to; this check confirms it is on this one.
|
|
420
|
+
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
421
|
+
* @param abxfsFileCid ABX FS file CID, or zero to clear.
|
|
422
|
+
*/
|
|
423
|
+
function updateDependencyAbxfsFileCid(
|
|
424
|
+
bytes32 dependencyNameAndVersion,
|
|
425
|
+
bytes32 abxfsFileCid
|
|
426
|
+
) external {
|
|
427
|
+
_onlyAdminACL(this.updateDependencyAbxfsFileCid.selector);
|
|
428
|
+
_onlyExistingDependency(dependencyNameAndVersion);
|
|
429
|
+
if (abxfsFileCid != bytes32(0)) {
|
|
430
|
+
require(
|
|
431
|
+
ABXFS_FILE_STORE.fileExists(abxfsFileCid),
|
|
432
|
+
"ABX FS file not found"
|
|
433
|
+
);
|
|
434
|
+
IAbxfsFileStore.FileInfo memory info = ABXFS_FILE_STORE.getFileInfo(
|
|
435
|
+
abxfsFileCid
|
|
436
|
+
);
|
|
437
|
+
require(
|
|
438
|
+
info.codec == AbxfsCanonical.GZIP_CODEC && info.size != 0,
|
|
439
|
+
"ABX FS file must be gzip"
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
DependencyRegistryStorageLib
|
|
444
|
+
.s()
|
|
445
|
+
.dependencyRecords[dependencyNameAndVersion]
|
|
446
|
+
.abxfsFileCid = abxfsFileCid;
|
|
447
|
+
|
|
448
|
+
emit DependencyAbxfsFileCidUpdated(
|
|
449
|
+
dependencyNameAndVersion,
|
|
450
|
+
abxfsFileCid
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
|
|
534
454
|
/**
|
|
535
455
|
* @notice Adds a new CDN url to `dependencyNameAndVersion`.
|
|
536
456
|
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
@@ -1101,8 +1021,8 @@ contract DependencyRegistryV0 is
|
|
|
1101
1021
|
* @return preferredRepository Preferred repository URL for dependency
|
|
1102
1022
|
* @return additionalRepositoryCount Count of additional repository URLs for dependency
|
|
1103
1023
|
* @return dependencyWebsite Project website URL for dependency
|
|
1104
|
-
* @return availableOnChain Whether dependency is
|
|
1105
|
-
* @return scriptCount
|
|
1024
|
+
* @return availableOnChain Whether dependency is on chain (has an ABX FS file)
|
|
1025
|
+
* @return scriptCount Number of slices `getDependencyScript` serves for the ABX FS file
|
|
1106
1026
|
*/
|
|
1107
1027
|
function getDependencyDetailsFromString(
|
|
1108
1028
|
string memory dependencyNameAndVersion
|
|
@@ -1288,92 +1208,81 @@ contract DependencyRegistryV0 is
|
|
|
1288
1208
|
}
|
|
1289
1209
|
|
|
1290
1210
|
/**
|
|
1291
|
-
* @notice Returns the
|
|
1211
|
+
* @notice Returns the CID of the gzip-codec ABX FS file holding the script for dependency
|
|
1212
|
+
* `dependencyNameAndVersion`, or zero if none is set. A dependency is on chain if and only
|
|
1213
|
+
* if this is non-zero.
|
|
1292
1214
|
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
1293
1215
|
*/
|
|
1294
|
-
function
|
|
1216
|
+
function getDependencyAbxfsFileCid(
|
|
1295
1217
|
bytes32 dependencyNameAndVersion
|
|
1296
|
-
) external view returns (
|
|
1218
|
+
) external view returns (bytes32) {
|
|
1297
1219
|
return
|
|
1298
1220
|
DependencyRegistryStorageLib
|
|
1299
1221
|
.s()
|
|
1300
1222
|
.dependencyRecords[dependencyNameAndVersion]
|
|
1301
|
-
.
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
/**
|
|
1305
|
-
* @notice Returns address with bytecode containing script for
|
|
1306
|
-
* dependency `_dependencyTypes` at script index `index`.
|
|
1307
|
-
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
1308
|
-
* @param index The index of a given script, relative to the overall `scriptCount`.
|
|
1309
|
-
* @return The address of the bytecode storage for the script at the given index, if it can be determined.
|
|
1310
|
-
*/
|
|
1311
|
-
function getDependencyScriptBytecodeAddress(
|
|
1312
|
-
bytes32 dependencyNameAndVersion,
|
|
1313
|
-
uint256 index
|
|
1314
|
-
) external view returns (address) {
|
|
1315
|
-
DependencyRegistryStorageLib.Dependency
|
|
1316
|
-
storage dependency = DependencyRegistryStorageLib
|
|
1317
|
-
.s()
|
|
1318
|
-
.dependencyRecords[dependencyNameAndVersion];
|
|
1319
|
-
_onlyInRangeIndex({index: index, length: dependency.scriptCount});
|
|
1320
|
-
return dependency.scriptBytecodeAddresses[index];
|
|
1223
|
+
.abxfsFileCid;
|
|
1321
1224
|
}
|
|
1322
1225
|
|
|
1323
1226
|
/**
|
|
1324
|
-
* @notice Returns the
|
|
1325
|
-
*
|
|
1227
|
+
* @notice Returns the number of slices `getDependencyScript` serves for dependency
|
|
1228
|
+
* `dependencyNameAndVersion`'s ABX FS file, or zero if it has none.
|
|
1326
1229
|
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
1327
|
-
* @param index The index of a given script, relative to the overall `scriptCount`.
|
|
1328
|
-
* @return The storage library version for the script at the given index, if it can be determined.
|
|
1329
|
-
* @dev Note that we only expect this to be determinable if the script was written using a version
|
|
1330
|
-
* of the Art Blocks `BytecodeStorage` library, and in other cases the fallback will be the
|
|
1331
|
-
* unknown version string, as defined by the `BytecodeStorage` UNKNOWN_VERSION_STRING – this
|
|
1332
|
-
* is inclusive of the in the case of `SSTORE2` written data blobs, which are an unknown version
|
|
1333
|
-
* that can be fallback-read optimistically.
|
|
1334
1230
|
*/
|
|
1335
|
-
function
|
|
1336
|
-
bytes32 dependencyNameAndVersion
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
dependency.scriptBytecodeAddresses[index]
|
|
1348
|
-
);
|
|
1231
|
+
function getDependencyScriptCount(
|
|
1232
|
+
bytes32 dependencyNameAndVersion
|
|
1233
|
+
) public view returns (uint256) {
|
|
1234
|
+
bytes32 abxfsFileCid = DependencyRegistryStorageLib
|
|
1235
|
+
.s()
|
|
1236
|
+
.dependencyRecords[dependencyNameAndVersion]
|
|
1237
|
+
.abxfsFileCid;
|
|
1238
|
+
if (abxfsFileCid == bytes32(0)) {
|
|
1239
|
+
return 0;
|
|
1240
|
+
}
|
|
1241
|
+
uint256 size = ABXFS_FILE_STORE.getFileInfo(abxfsFileCid).size;
|
|
1242
|
+
return (size + ABXFS_SCRIPT_SLICE_BYTES - 1) / ABXFS_SCRIPT_SLICE_BYTES;
|
|
1349
1243
|
}
|
|
1350
1244
|
|
|
1351
1245
|
/**
|
|
1352
|
-
* @notice Returns
|
|
1246
|
+
* @notice Returns slice `index` of dependency `dependencyNameAndVersion`'s ABX FS file: the
|
|
1247
|
+
* base64 encoding of its gzip bytes `[index * 24576, min(size, (index + 1) * 24576))`.
|
|
1248
|
+
* The slices concatenated in order are the base64 encoding of the whole gzip file, the form
|
|
1249
|
+
* a `data:text/javascript;base64,` URI with a gzip script type expects.
|
|
1250
|
+
* @dev Serves consumers that read dependency scripts in indexed pieces. Contracts that want
|
|
1251
|
+
* the whole file in one call can read it from ABX FS by `getDependencyAbxfsFileCid`.
|
|
1353
1252
|
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
1354
|
-
* @param index
|
|
1355
|
-
* @return
|
|
1356
|
-
* @dev This method attempts to introspectively determine which library version of
|
|
1357
|
-
* `BytecodeStorage` was used to write the stored script string that is being
|
|
1358
|
-
* read back, in order to use the proper read approach. If the version is
|
|
1359
|
-
* non-determinate, a fall-back to reading using the assumption that the bytes
|
|
1360
|
-
* were written with `SSTORE2` is used.
|
|
1361
|
-
* Also note that in this `SSTORE2` fallback handling, the approach of casting bytes to string
|
|
1362
|
-
* can cause failure (e.g. unexpected continuation byte).
|
|
1253
|
+
* @param index Index of the slice, less than `getDependencyScriptCount`.
|
|
1254
|
+
* @return The base64-encoded slice.
|
|
1363
1255
|
*/
|
|
1364
1256
|
function getDependencyScript(
|
|
1365
1257
|
bytes32 dependencyNameAndVersion,
|
|
1366
1258
|
uint256 index
|
|
1367
1259
|
) external view returns (string memory) {
|
|
1368
|
-
DependencyRegistryStorageLib
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1260
|
+
bytes32 abxfsFileCid = DependencyRegistryStorageLib
|
|
1261
|
+
.s()
|
|
1262
|
+
.dependencyRecords[dependencyNameAndVersion]
|
|
1263
|
+
.abxfsFileCid;
|
|
1264
|
+
uint256 size = abxfsFileCid == bytes32(0)
|
|
1265
|
+
? 0
|
|
1266
|
+
: ABXFS_FILE_STORE.getFileInfo(abxfsFileCid).size;
|
|
1267
|
+
_onlyInRangeIndex({
|
|
1268
|
+
index: index,
|
|
1269
|
+
length: (size + ABXFS_SCRIPT_SLICE_BYTES - 1) /
|
|
1270
|
+
ABXFS_SCRIPT_SLICE_BYTES
|
|
1271
|
+
});
|
|
1272
|
+
uint256 start = index * ABXFS_SCRIPT_SLICE_BYTES;
|
|
1273
|
+
uint256 end = start + ABXFS_SCRIPT_SLICE_BYTES;
|
|
1274
|
+
if (end > size) {
|
|
1275
|
+
end = size;
|
|
1276
|
+
}
|
|
1277
|
+
(, , , string memory slice) = ABXFS_FILE_DATA_READER
|
|
1278
|
+
.readFileDataRangeBase64({
|
|
1279
|
+
cid: abxfsFileCid,
|
|
1280
|
+
start: start,
|
|
1281
|
+
length: end - start,
|
|
1282
|
+
maxBytes: type(uint256).max,
|
|
1283
|
+
maxChunks: type(uint256).max
|
|
1284
|
+
});
|
|
1285
|
+
return slice;
|
|
1377
1286
|
}
|
|
1378
1287
|
|
|
1379
1288
|
/**
|
|
@@ -1494,8 +1403,8 @@ contract DependencyRegistryV0 is
|
|
|
1494
1403
|
preferredRepository: dependency.preferredRepository,
|
|
1495
1404
|
additionalRepositoryCount: dependency.additionalRepositoryCount,
|
|
1496
1405
|
dependencyWebsite: dependency.website,
|
|
1497
|
-
availableOnChain: dependency.
|
|
1498
|
-
|
|
1406
|
+
availableOnChain: dependency.abxfsFileCid != bytes32(0),
|
|
1407
|
+
abxfsFileCid: dependency.abxfsFileCid,
|
|
1499
1408
|
loadAsModule: dependency.loadAsModule,
|
|
1500
1409
|
canvasTagType: dependency.canvasTagType,
|
|
1501
1410
|
projectScriptTagType: dependency.projectScriptTagType,
|
|
@@ -1504,10 +1413,11 @@ contract DependencyRegistryV0 is
|
|
|
1504
1413
|
}
|
|
1505
1414
|
|
|
1506
1415
|
/**
|
|
1507
|
-
* @notice Returns details for a given dependency type `dependencyNameAndVersion
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
1416
|
+
* @notice Returns details for a given dependency type `dependencyNameAndVersion`, as a
|
|
1417
|
+
* tuple.
|
|
1418
|
+
* @dev `getDependencyDetailsV2` returns every field. This tuple form keeps its signature for
|
|
1419
|
+
* deployed consumers that decode it; `availableOnChain` is whether the dependency has an ABX
|
|
1420
|
+
* FS file, and `scriptCount` is `getDependencyScriptCount`.
|
|
1511
1421
|
* @param dependencyNameAndVersion Name and version of dependency (i.e. "name@version") used to identify dependency.
|
|
1512
1422
|
* @return nameAndVersion String representation of `dependencyNameAndVersion`.
|
|
1513
1423
|
* (e.g. "p5js(atSymbol)1.0.0")
|
|
@@ -1517,8 +1427,8 @@ contract DependencyRegistryV0 is
|
|
|
1517
1427
|
* @return preferredRepository Preferred repository URL for dependency
|
|
1518
1428
|
* @return additionalRepositoryCount Count of additional repository URLs for dependency
|
|
1519
1429
|
* @return dependencyWebsite Project website URL for dependency
|
|
1520
|
-
* @return availableOnChain Whether dependency is
|
|
1521
|
-
* @return scriptCount
|
|
1430
|
+
* @return availableOnChain Whether dependency is on chain (has an ABX FS file)
|
|
1431
|
+
* @return scriptCount Number of slices `getDependencyScript` serves for the ABX FS file
|
|
1522
1432
|
*/
|
|
1523
1433
|
function getDependencyDetails(
|
|
1524
1434
|
bytes32 dependencyNameAndVersion
|
|
@@ -1537,20 +1447,20 @@ contract DependencyRegistryV0 is
|
|
|
1537
1447
|
uint24 scriptCount
|
|
1538
1448
|
)
|
|
1539
1449
|
{
|
|
1450
|
+
// @dev a uint24 slice count covers files up to ~412 GB, far beyond any ABX FS file
|
|
1451
|
+
scriptCount = uint24(
|
|
1452
|
+
getDependencyScriptCount(dependencyNameAndVersion)
|
|
1453
|
+
);
|
|
1540
1454
|
IDependencyRegistryV0.DependencyDetails
|
|
1541
1455
|
memory details = getDependencyDetailsV2(dependencyNameAndVersion);
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
details.dependencyWebsite,
|
|
1551
|
-
details.availableOnChain,
|
|
1552
|
-
details.scriptCount
|
|
1553
|
-
);
|
|
1456
|
+
nameAndVersion = details.nameAndVersion;
|
|
1457
|
+
licenseType = details.licenseType;
|
|
1458
|
+
preferredCDN = details.preferredCDN;
|
|
1459
|
+
additionalCDNCount = details.additionalCDNCount;
|
|
1460
|
+
preferredRepository = details.preferredRepository;
|
|
1461
|
+
additionalRepositoryCount = details.additionalRepositoryCount;
|
|
1462
|
+
dependencyWebsite = details.dependencyWebsite;
|
|
1463
|
+
availableOnChain = details.availableOnChain;
|
|
1554
1464
|
}
|
|
1555
1465
|
|
|
1556
1466
|
/**
|