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

Authorized deployer contract PRO-80 #39

Merged
merged 119 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
9cb56e6
forge update
duncancmt Oct 4, 2023
9fbfa52
Add first version of deployer contract
duncancmt Oct 4, 2023
b461cbd
Move deployer into its own directory
duncancmt Oct 4, 2023
f5c6f2c
Add function for setting fee collector
duncancmt Oct 4, 2023
445e9ce
Add function to mark deployments as buggy; add convenience function f…
duncancmt Oct 4, 2023
f438299
Small optimization since we know nonce zero is illegal
duncancmt Oct 4, 2023
1e266f2
Compilation error
duncancmt Oct 4, 2023
28d5b97
Add multicall
duncancmt Oct 4, 2023
f97b13a
Utility constants
duncancmt Oct 4, 2023
86f5cc6
Storage alignment
duncancmt Oct 4, 2023
829e895
Comment
duncancmt Oct 4, 2023
c71f02a
Error checking on deployment
duncancmt Oct 4, 2023
d625f79
Add WIP unit tests
duncancmt Oct 4, 2023
e5b5fc4
More test
duncancmt Oct 4, 2023
df62e61
Use new foundry tools in test
duncancmt Oct 4, 2023
192e151
More tests
duncancmt Oct 4, 2023
78b1e21
Golf
duncancmt Oct 4, 2023
3c6e9e3
Use setNonceUnsafe for better test coverage
duncancmt Oct 4, 2023
d7f6955
Golf
duncancmt Oct 5, 2023
744091a
Golf
duncancmt Oct 5, 2023
fc9428b
Un-golf (introduced a bug)
duncancmt Oct 5, 2023
cfd0bad
Golf
duncancmt Oct 5, 2023
bc81186
Use EXTCODEHASH instead of EXTCODESIZE
duncancmt Oct 5, 2023
c9842ab
Golf
duncancmt Oct 5, 2023
e8c8bcf
Clear dirty bits
duncancmt Oct 5, 2023
d77a3e7
Delete branch specifier from forge-std submodule
duncancmt Oct 5, 2023
3006a78
Fix CI issue by reinstalling forge-std
duncancmt Oct 5, 2023
aa6c4c6
forge install: forge-std
duncancmt Oct 5, 2023
a4648db
Remove forge-std from remappings
duncancmt Oct 5, 2023
501cf61
Revert "Remove forge-std from remappings"
duncancmt Oct 5, 2023
21764b7
Use submodules to manage dependencies, not `forge`
duncancmt Oct 5, 2023
67069d8
Golf
duncancmt Oct 7, 2023
f7c3592
Golf
duncancmt Oct 7, 2023
69d31e5
Use library for address computation
duncancmt Oct 9, 2023
09e8efd
Golf
duncancmt Oct 9, 2023
0d2e498
Configure fuzz runs correctly
duncancmt Oct 17, 2023
a43ae82
Golf
duncancmt Oct 17, 2023
fdbf29e
Comment
duncancmt Oct 17, 2023
af29105
Make Deployer keep a doubly-linked list of deployments so that we can…
duncancmt Oct 31, 2023
7ffb8ed
Never store to `_deploymentLists[address(0)]`
duncancmt Oct 31, 2023
b18119c
Make authorizations expire
duncancmt Oct 31, 2023
67b622e
Disallow `feature == 0`
duncancmt Oct 31, 2023
3dda906
Fix tests
duncancmt Oct 31, 2023
85219b6
Don't use `EXTCODEHASH` because it isn't supported across EVM flavors
duncancmt Nov 8, 2023
6030621
Golf
duncancmt Nov 8, 2023
3af968f
Set EVM version to Shanghai
duncancmt Nov 8, 2023
bbf1332
Golf
duncancmt Nov 8, 2023
4c70c1e
Reorder
duncancmt Nov 9, 2023
2f7e517
Merge branch 'master' into deployer
duncancmt Jan 8, 2024
c1052f7
WIP: make Deployer an ERC721 for increased inspectability
duncancmt Jan 8, 2024
28bae3f
Add check for bad curve points
duncancmt Jan 8, 2024
7ace79c
WIP: tokenURI in IPFS
duncancmt Jan 8, 2024
6c876d4
Create directory vendor/
duncancmt Jan 8, 2024
6c9beea
Move verifyIPFS.sol into vendor/
duncancmt Jan 8, 2024
b6a4b88
Finished: make Deployer an ERC721
duncancmt Jan 8, 2024
fa2c761
Resolve TODO; fix bug
duncancmt Jan 8, 2024
70e654d
Golf
duncancmt Jan 8, 2024
e4a01e8
Fix tests
duncancmt Jan 8, 2024
d4b5402
Reorganize for clarity
duncancmt Jan 8, 2024
9c84ac5
Bug! spurious Transfer events
duncancmt Jan 8, 2024
15b1ac8
Resolve TODO
duncancmt Jan 8, 2024
e528667
Golf
duncancmt Jan 8, 2024
c19cd2c
Golf
duncancmt Jan 8, 2024
c9c73ad
Golf
duncancmt Jan 8, 2024
879a407
Golf
duncancmt Jan 8, 2024
1fa5027
Add newline to end of description
duncancmt Jan 8, 2024
dd7f7c6
Golf
duncancmt Jan 8, 2024
9ae12a7
toBase58 => base58sha256multihash
duncancmt Jan 8, 2024
067dea6
Single-chunk IPFS files can't be that long
duncancmt Jan 8, 2024
34e0a13
Fix in CIDv0 hashing; protobuf uses 7-bit bytes for varints
duncancmt Jan 9, 2024
419f8e2
Bounds checking
duncancmt Jan 9, 2024
d2e0a4a
Add TODOs
duncancmt Jan 9, 2024
d350a65
Move IPFS out of vendor/
duncancmt Jan 9, 2024
7ae3e1d
unchecked
duncancmt Jan 9, 2024
77be36f
Golf
duncancmt Jan 9, 2024
f15eea0
DRY
duncancmt Jan 9, 2024
e2a0fe0
Avoid evaluating block.timestamp if authorization is unlimited
duncancmt Jan 9, 2024
6a3a958
Golf
duncancmt Jan 9, 2024
829a6ed
Add failing unit test for empty file IPFS
duncancmt Jan 9, 2024
86a983e
Correctly, but inelegantly, handle the empty file
duncancmt Jan 9, 2024
1e9caca
Golf
duncancmt Jan 9, 2024
c2295af
Rename library and functions
duncancmt Jan 9, 2024
5515391
natspec
duncancmt Jan 9, 2024
c12c59a
Cleanup
duncancmt Jan 9, 2024
78f6209
Make base58Sha256Multihash return string
duncancmt Jan 9, 2024
79d704d
natspec
duncancmt Jan 9, 2024
7cd8395
Resolve TODO
duncancmt Jan 9, 2024
5e8ca5c
More tests for IPFS
duncancmt Jan 9, 2024
f5426bb
Bug! ERC721.ownerOf is supposed to revert for tokens that do not exist
duncancmt Jan 9, 2024
2f354ec
Add comment about gas golfing after Pralectra
duncancmt Jan 9, 2024
070bab3
Bug! ERC721.balanceOf is supposed to revert for address(0)
duncancmt Jan 9, 2024
353d74b
Comment
duncancmt Jan 9, 2024
4524952
Put nonce *and* address in events
duncancmt Jan 10, 2024
ee5cc9e
Add ItoA
duncancmt Jan 10, 2024
99530b3
Move ItoA into utils/
duncancmt Jan 10, 2024
b35f5c9
Resolve TODO by putting feature number in the name of each token
duncancmt Jan 10, 2024
ea67148
Golf
duncancmt Jan 10, 2024
f17bad6
Add bounds checks to point coordinates in AddressDerivation.deriveEOA
duncancmt Jan 10, 2024
114e690
Golf
duncancmt Jan 10, 2024
458971e
Bug! put fee collector address as last constructor argument
duncancmt Jan 11, 2024
c4d3562
Add deploy-time check that newly-deployed instances have taken up the…
duncancmt Jan 11, 2024
5766f7e
Separate FeatureInitialized from FeatureNotInitialized
duncancmt Jan 11, 2024
80a271b
Return the content, not the URI from `setDescription`
duncancmt Jan 11, 2024
285eab4
Better test for correct `feeCollector()`
duncancmt Jan 11, 2024
8720315
Single authorized address per feature
duncancmt Jan 11, 2024
f4a244b
Comments
duncancmt Jan 11, 2024
9695016
Use library; less assembly
duncancmt Jan 11, 2024
116b3a1
Prohibit questionable authorized/expiry combinations
duncancmt Jan 12, 2024
7c30b42
Add two bare-minimum test cases
duncancmt Jan 12, 2024
2ac07cd
Rename functions
duncancmt Jan 15, 2024
44b7953
Add O(1) function to mark entire feature as unsafe
duncancmt Jan 15, 2024
6313d7e
Add test case
duncancmt Jan 15, 2024
2ea6410
Bug! Fix indexed event argument checking
duncancmt Jan 15, 2024
7a921e4
Add nonce to revert reason
duncancmt Jan 15, 2024
ee5356f
Slightly smarter sanity check in `authorize`
duncancmt Jan 15, 2024
52b25ad
Storage layout
duncancmt Jan 16, 2024
7a83596
Better revert reason
duncancmt Jan 18, 2024
1209be1
Make `expiry` => `deadline` work like it does in most other protocols
duncancmt Jan 19, 2024
f3f3967
Golf
duncancmt Jan 19, 2024
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
13 changes: 11 additions & 2 deletions src/deployer/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ contract Deployer is TwoStepOwnable, IERC721ViewMetadata {
if (descriptionHash[feature] != 0) {
revert FeatureInitialized(feature);
}
// TODO: put something better in the `"name"` field
string memory content = string(abi.encodePacked("{\"description\": \"", description, "\", \"name\": \"0xV5\"}"));
string memory ipfsURI = string(abi.encodePacked("ipfs://", verifyIPFS.generateHash(content)));
bytes32 contentHash = verifyIPFS.ipfsHash(content);
descriptionHash[feature] = contentHash;
string memory ipfsURI = string(abi.encodePacked("ipfs://", verifyIPFS.formatHash(contentHash)));
emit PermanentURI(ipfsURI, feature);
return ipfsURI;
}

event Deployed(uint128 indexed, address indexed);
Expand Down Expand Up @@ -256,10 +260,15 @@ contract Deployer is TwoStepOwnable, IERC721ViewMetadata {
return false;
}

error NoToken(uint256);

function tokenURI(uint256 tokenId) external view returns (string memory) {
if (tokenId > type(uint128).max) {
Panic.panic(Panic.ARITHMETIC_OVERFLOW);
}
// TODO:
if (_featureNonce[uint128(tokenId)] == 0) {
revert NoToken(tokenId);
}
return string(abi.encodePacked("ipfs://", verifyIPFS.formatHash(descriptionHash[uint128(tokenId)])));
}
}
16 changes: 8 additions & 8 deletions src/vendor/verifyIPFS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ library verifyIPFS {
bytes constant ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
duncancmt marked this conversation as resolved.
Show resolved Hide resolved

/// @dev generates the corresponding IPFS hash (in base 58) to the given string
/// @param contentString The content of the IPFS object
/// @param contentHash The hash of the content of the IPFS object
/// @return The IPFS hash in base 58
function generateHash(string memory contentString) internal pure returns (bytes memory) {
function formatHash(bytes32 contentHash) internal pure returns (bytes memory) {
return toBase58(concat(sha256MultiHash, toBytes(contentHash)));
}

function ipfsHash(string memory contentString) internal pure returns (bytes32) {
bytes memory content = bytes(contentString);
bytes memory len = lengthEncode(content.length);
bytes memory len2 = lengthEncode(content.length + 4 + 2 * len.length);
return toBase58(
concat(
sha256MultiHash, toBytes(sha256(abi.encodePacked(prefix1, len2, prefix2, len, content, postfix, len)))
)
);
return sha256(abi.encodePacked(prefix1, len2, prefix2, len, content, postfix, len));
}

/// @dev Compares an IPFS hash with content
function verifyHash(string memory contentString, string memory hash) internal pure returns (bool) {
return equal(generateHash(contentString), bytes(hash));
return equal(formatHash(ipfsHash(contentString)), bytes(hash));
}

/// @dev Converts hex string to base 58
Expand Down
Loading