Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split BytecodeStorage into public/internal libraries #684

Merged
merged 25 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions contracts/DependencyRegistryV0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ contract DependencyRegistryV0 is
OwnableUpgradeable,
IDependencyRegistryV0
{
using BytecodeStorage for string;
using BytecodeStorage for address;
using BytecodeStorageWriterV1 for string;
using BytecodeStorageWriterV1 for address;
using Bytes32Strings for bytes32;
using Strings for uint256;
using EnumerableSet for EnumerableSet.Bytes32Set;
Expand Down Expand Up @@ -735,7 +735,7 @@ contract DependencyRegistryV0 is
return "";
}

return dependency.scriptBytecodeAddresses[_index].readFromBytecode();
return _readFromBytecode(dependency.scriptBytecodeAddresses[_index]);
}

/**
Expand Down Expand Up @@ -829,4 +829,14 @@ contract DependencyRegistryV0 is
OwnableUpgradeable._transferOwnership(newOwner);
adminACLContract = IAdminACLV0(newOwner);
}

/**
* Helper for calling `BytecodeStorageReaderV1` external library reader method,
* added for gas-optimization purposes.
*/
function _readFromBytecode(
address _address
) internal view returns (string memory) {
return BytecodeStorageReaderV1.readFromBytecode(_address);
}
}
16 changes: 13 additions & 3 deletions contracts/GenArt721CoreV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ contract GenArt721CoreV3 is
IGenArt721CoreContractV3,
IGenArt721CoreContractExposesHashSeed
{
using BytecodeStorage for string;
using BytecodeStorage for address;
using BytecodeStorageWriterV1 for string;
using BytecodeStorageWriterV1 for address;
using Bytes32Strings for bytes32;
using Strings for uint256;
uint256 constant ONE_HUNDRED = 100;
Expand Down Expand Up @@ -1493,7 +1493,7 @@ contract GenArt721CoreV3 is
if (_index >= project.scriptCount) {
return "";
}
return project.scriptBytecodeAddresses[_index].readFromBytecode();
return _readFromBytecode(project.scriptBytecodeAddresses[_index]);
}

/**
Expand Down Expand Up @@ -1945,4 +1945,14 @@ contract GenArt721CoreV3 is
(block.timestamp - projectCompletedTimestamp <
FOUR_WEEKS_IN_SECONDS);
}

/**
* Helper for calling `BytecodeStorageReaderV1` external library reader method,
* added for gas-optimization purposes.
*/
function _readFromBytecode(
address _address
) internal view returns (string memory) {
return BytecodeStorageReaderV1.readFromBytecode(_address);
}
}
16 changes: 13 additions & 3 deletions contracts/engine/V3/GenArt721CoreV3_Engine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ contract GenArt721CoreV3_Engine is
IGenArt721CoreContractV3_Engine,
IGenArt721CoreContractExposesHashSeed
{
using BytecodeStorage for string;
using BytecodeStorage for address;
using BytecodeStorageWriterV1 for string;
using BytecodeStorageWriterV1 for address;
using Bytes32Strings for bytes32;
using Strings for uint256;
using Strings for address;
Expand Down Expand Up @@ -1577,7 +1577,7 @@ contract GenArt721CoreV3_Engine is
if (_index >= project.scriptCount) {
return "";
}
return project.scriptBytecodeAddresses[_index].readFromBytecode();
return _readFromBytecode(project.scriptBytecodeAddresses[_index]);
}

/**
Expand Down Expand Up @@ -1996,4 +1996,14 @@ contract GenArt721CoreV3_Engine is
(block.timestamp - projectCompletedTimestamp <
FOUR_WEEKS_IN_SECONDS);
}

/**
* Helper for calling `BytecodeStorageReaderV1` external library reader method,
* added for gas-optimization purposes.
*/
function _readFromBytecode(
address _address
) internal view returns (string memory) {
return BytecodeStorageReaderV1.readFromBytecode(_address);
}
}
18 changes: 14 additions & 4 deletions contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ contract GenArt721CoreV3_Engine_Flex is
IGenArt721CoreContractV3_Engine_Flex,
IGenArt721CoreContractExposesHashSeed
{
using BytecodeStorage for string;
using BytecodeStorage for address;
using BytecodeStorageWriterV1 for string;
using BytecodeStorageWriterV1 for address;
using Bytes32Strings for bytes32;
uint256 constant ONE_HUNDRED = 100;
uint256 constant ONE_MILLION = 1_000_000;
Expand Down Expand Up @@ -1763,7 +1763,7 @@ contract GenArt721CoreV3_Engine_Flex is
if (_index >= project.scriptCount) {
return "";
}
return project.scriptBytecodeAddresses[_index].readFromBytecode();
return _readFromBytecode(project.scriptBytecodeAddresses[_index]);
}

/**
Expand Down Expand Up @@ -1994,7 +1994,7 @@ contract GenArt721CoreV3_Engine_Flex is
bytecodeAddress: _bytecodeAddress,
data: (_dependency.dependencyType ==
ExternalAssetDependencyType.ONCHAIN)
? _bytecodeAddress.readFromBytecode()
? _readFromBytecode(_bytecodeAddress)
: ""
});
}
Expand Down Expand Up @@ -2217,6 +2217,16 @@ contract GenArt721CoreV3_Engine_Flex is
FOUR_WEEKS_IN_SECONDS);
}

/**
* Helper for calling `BytecodeStorageReaderV1` external library reader method,
* added for gas-optimization purposes.
*/
function _readFromBytecode(
address _address
) internal view returns (string memory) {
return BytecodeStorageReaderV1.readFromBytecode(_address);
}

// strings library from OpenZeppelin, modified for no constants

bytes16 private _HEX_SYMBOLS = "0123456789abcdef";
Expand Down
18 changes: 14 additions & 4 deletions contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ contract GenArt721CoreV3_Engine_Flex_PROOF is
IManifold,
IGenArt721CoreContractV3_Engine_Flex
{
using BytecodeStorage for string;
using BytecodeStorage for address;
using BytecodeStorageWriterV1 for string;
using BytecodeStorageWriterV1 for address;
using Bytes32Strings for bytes32;

uint256 constant ONE_HUNDRED = 100;
Expand Down Expand Up @@ -1773,7 +1773,7 @@ contract GenArt721CoreV3_Engine_Flex_PROOF is
if (_index >= project.scriptCount) {
return "";
}
return project.scriptBytecodeAddresses[_index].readFromBytecode();
return _readFromBytecode(project.scriptBytecodeAddresses[_index]);
}

/**
Expand Down Expand Up @@ -2004,7 +2004,7 @@ contract GenArt721CoreV3_Engine_Flex_PROOF is
bytecodeAddress: _bytecodeAddress,
data: (_dependency.dependencyType ==
ExternalAssetDependencyType.ONCHAIN)
? _bytecodeAddress.readFromBytecode()
? _readFromBytecode(_bytecodeAddress)
: ""
});
}
Expand Down Expand Up @@ -2227,6 +2227,16 @@ contract GenArt721CoreV3_Engine_Flex_PROOF is
FOUR_WEEKS_IN_SECONDS);
}

/**
* Helper for calling `BytecodeStorageReaderV1` external library reader method,
* added for gas-optimization purposes.
*/
function _readFromBytecode(
address _address
) internal view returns (string memory) {
return BytecodeStorageReaderV1.readFromBytecode(_address);
}

// strings library from OpenZeppelin, modified for no constants

bytes16 private _HEX_SYMBOLS = "0123456789abcdef";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ contract GenArt721CoreV3_Engine_Flex_PROHIBITION is
IManifold,
IGenArt721CoreContractV3_Engine_Flex_PROHIBITION
{
using BytecodeStorage for string;
using BytecodeStorage for address;
using BytecodeStorageWriterV1 for string;
using BytecodeStorageWriterV1 for address;
using Bytes32Strings for bytes32;
uint256 constant ONE_HUNDRED = 100;
uint256 constant ONE_MILLION = 1_000_000;
Expand Down Expand Up @@ -1781,7 +1781,7 @@ contract GenArt721CoreV3_Engine_Flex_PROHIBITION is
if (_index >= project.scriptCount) {
return "";
}
return project.scriptBytecodeAddresses[_index].readFromBytecode();
return _readFromBytecode(project.scriptBytecodeAddresses[_index]);
}

/**
Expand Down Expand Up @@ -2012,7 +2012,7 @@ contract GenArt721CoreV3_Engine_Flex_PROHIBITION is
bytecodeAddress: _bytecodeAddress,
data: (_dependency.dependencyType ==
ExternalAssetDependencyType.ONCHAIN)
? _bytecodeAddress.readFromBytecode()
? _readFromBytecode(_bytecodeAddress)
: ""
});
}
Expand Down Expand Up @@ -2276,6 +2276,16 @@ contract GenArt721CoreV3_Engine_Flex_PROHIBITION is
FOUR_WEEKS_IN_SECONDS);
}

/**
* Helper for calling `BytecodeStorageReaderV1` external library reader method,
* added for gas-optimization purposes.
*/
function _readFromBytecode(
address _address
) internal view returns (string memory) {
return BytecodeStorageReaderV1.readFromBytecode(_address);
}

// strings library from OpenZeppelin, modified for no constants

bytes16 private _HEX_SYMBOLS = "0123456789abcdef";
Expand Down
16 changes: 13 additions & 3 deletions contracts/explorations/GenArt721CoreV3_Explorations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ contract GenArt721CoreV3_Explorations is
IGenArt721CoreContractV3,
IGenArt721CoreContractExposesHashSeed
{
using BytecodeStorage for string;
using BytecodeStorage for address;
using BytecodeStorageWriterV1 for string;
using BytecodeStorageWriterV1 for address;
using Bytes32Strings for bytes32;
using Strings for uint256;
using Strings for address;
Expand Down Expand Up @@ -1499,7 +1499,7 @@ contract GenArt721CoreV3_Explorations is
if (_index >= project.scriptCount) {
return "";
}
return project.scriptBytecodeAddresses[_index].readFromBytecode();
return _readFromBytecode(project.scriptBytecodeAddresses[_index]);
}

/**
Expand Down Expand Up @@ -1951,4 +1951,14 @@ contract GenArt721CoreV3_Explorations is
(block.timestamp - projectCompletedTimestamp <
FOUR_WEEKS_IN_SECONDS);
}

/**
* Helper for calling `BytecodeStorageReaderV1` external library reader method,
* added for gas-optimization purposes.
*/
function _readFromBytecode(
address _address
) internal view returns (string memory) {
return BytecodeStorageReaderV1.readFromBytecode(_address);
}
}
Loading