-
Notifications
You must be signed in to change notification settings - Fork 4
pull request with suggestions #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| +17 −15 | .gas-snapshot | |
| +1 −0 | foundry.toml | |
| +1 −1 | package.json | |
| +21 −2 | src/utils/Base64.sol | |
| +48 −18 | test/Base64.t.sol |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.13; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add this back |
||
| pragma solidity 0.8.13; | ||
|
|
||
| import "openzeppelin/token/ERC721/ERC721.sol"; | ||
| import "openzeppelin/access/Ownable.sol"; | ||
|
|
@@ -12,8 +12,8 @@ contract Conclusion is ERC721, Ownable { | |
| error MergeHasOccured(); | ||
|
|
||
| struct MintInfo { | ||
| uint128 blockNum; | ||
| uint128 blockdifficulty; | ||
| uint128 blockNumber; | ||
| uint128 blockDifficulty; | ||
| } | ||
|
|
||
| uint256 public lastWorkBlock; | ||
|
|
@@ -29,17 +29,17 @@ contract Conclusion is ERC721, Ownable { | |
| _; | ||
| } | ||
|
|
||
| constructor() ERC721("Conclusion", "CONCLUSION") {} | ||
| constructor() ERC721("The Last Work", "CONCLUSION") {} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets do 'sunset' and 'sunrise' for POS |
||
|
|
||
| function setRenderer(address renderer) external onlyOwner { | ||
| conclusionRenderer = renderer; | ||
| } | ||
|
|
||
| function mint() external onlyEOA { | ||
| if (mintedBlocks[tx.origin] > 0) revert AlreadyMinted(); | ||
| if (mergeHasOccured()) revert MergeHasOccured(); | ||
| _assetPoW(); | ||
|
|
||
| checkProofOfWorkValidAndUpdate(); | ||
| if (mintedBlocks[tx.origin] > 0) | ||
| revert AlreadyMinted(); | ||
|
|
||
| uint256 currSupply = totalSupply; | ||
|
|
||
|
|
@@ -56,13 +56,14 @@ contract Conclusion is ERC721, Ownable { | |
| totalSupply = currSupply; | ||
| } | ||
|
|
||
| function checkProofOfWorkValidAndUpdate() public { | ||
| if (!mergeHasOccured()) { | ||
| lastWorkBlock = block.number; | ||
| } | ||
| function _assetPoW() internal { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. asset or assess?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assert |
||
| if (isPoS()) | ||
| revert MergeHasOccured(); | ||
|
|
||
| lastWorkBlock = block.number; | ||
| } | ||
|
|
||
| function mergeHasOccured() public view returns (bool) { | ||
| function isPoS() public view returns (bool) { | ||
| return block.difficulty > 2**64 || block.difficulty == 0; | ||
| } | ||
|
|
||
|
|
@@ -73,11 +74,11 @@ contract Conclusion is ERC721, Ownable { | |
| override | ||
| returns (string memory) | ||
| { | ||
| if (!_exists(_tokenId)) revert TokenDoesNotExist(); | ||
| if (!_exists(_tokenId)) | ||
| revert TokenDoesNotExist(); | ||
|
|
||
| if (conclusionRenderer == address(0)) { | ||
| if (conclusionRenderer == address(0)) | ||
| return ""; | ||
| } | ||
|
|
||
| MintInfo memory info = tokenToBlockNum[_tokenId]; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,10 +10,13 @@ contract Genesis is ERC721, Ownable { | |
| error AlreadyMinted(); | ||
| error TokenDoesNotExist(); | ||
| error MergeHasNotOccured(); | ||
| error TooLate(); | ||
|
|
||
| uint256 immutable MAX_MINT_DISTANCE = 100; | ||
|
|
||
| struct MintInfo { | ||
| uint128 blockNum; | ||
| uint128 blockdifficulty; | ||
| uint128 blockNumber; | ||
| uint128 blockDifficulty; | ||
| } | ||
|
|
||
| uint256 public genesisMergeBlock; | ||
|
|
@@ -29,17 +32,20 @@ contract Genesis is ERC721, Ownable { | |
| _; | ||
| } | ||
|
|
||
| constructor() ERC721("Genesis", "GENESIS") {} | ||
| constructor() ERC721("New Genesis", "GENESIS") {} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sunrise |
||
|
|
||
| function setRenderer(address renderer) external onlyOwner { | ||
| genesisRenderer = renderer; | ||
| } | ||
|
|
||
| function mint() external onlyEOA { | ||
| if (mintedBlocks[tx.origin] > 0) revert AlreadyMinted(); | ||
| if (!mergeHasOccured()) revert MergeHasNotOccured(); | ||
| function mint() external onlyEOA { | ||
| assertPos(); | ||
|
|
||
| if (mintedBlocks[tx.origin] > 0) | ||
| revert AlreadyMinted(); | ||
|
|
||
| checkForMergeAndUpdate(); | ||
| if (block.number - genesisMergeBlock > MAX_MINT_DISTANCE) | ||
| revert TooLate(); | ||
|
|
||
| uint256 currSupply = totalSupply; | ||
|
|
||
|
|
@@ -56,13 +62,15 @@ contract Genesis is ERC721, Ownable { | |
| totalSupply = currSupply; | ||
| } | ||
|
|
||
| function checkForMergeAndUpdate() public { | ||
| if (genesisMergeBlock == 0 && mergeHasOccured()) { | ||
| function assertPoS() public { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i was thinking we could make this a function anyone could call just so we can keep updating the blocks (so we can guarantee not missing the POS block) |
||
| if (!isPoS()) | ||
| revert MergeHasNotOccured(); | ||
|
|
||
| if (genesisMergeBlock == 0) | ||
| genesisMergeBlock = block.number; | ||
| } | ||
| } | ||
|
|
||
| function mergeHasOccured() public view returns (bool) { | ||
| function isPoS() public view returns (bool) { | ||
| return block.difficulty > 2**64 || block.difficulty == 0; | ||
| } | ||
|
|
||
|
|
@@ -73,19 +81,19 @@ contract Genesis is ERC721, Ownable { | |
| override | ||
| returns (string memory) | ||
| { | ||
| if (!_exists(_tokenId)) revert TokenDoesNotExist(); | ||
| if (!_exists(_tokenId)) | ||
| revert TokenDoesNotExist(); | ||
|
|
||
| if (genesisRenderer == address(0)) { | ||
| if (genesisRenderer == address(0)) | ||
| return ""; | ||
| } | ||
|
|
||
| MintInfo memory info = tokenToBlockNum[_tokenId]; | ||
|
|
||
| return | ||
| IGenesisRenderer(genesisRenderer).tokenURI( | ||
| _tokenId, | ||
| info.blockNum, | ||
| info.blockdifficulty | ||
| info.blockNumber, | ||
| genesisMergeBlock | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is suppose to be the block difficulty the minter minted at - for metadata purposes
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PoS doesn't have block.difficulty (it's prevrandao then) so I re-purposed it to show when genesisMergeBlock (since it isn't known while PoW, so it's a nice compromise) |
||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,26 @@ | ||
| // // SPDX-License-Identifier: UNLICENSED | ||
| // pragma solidity ^0.8.13; | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity 0.8.13; | ||
|
|
||
| // import "forge-std/Test.sol"; | ||
| // import "../src/Conclusion.sol"; | ||
| import "forge-std/Test.sol"; | ||
| import "../src/Conclusion.sol"; | ||
|
|
||
| // contract ConclusionTest is Test { | ||
| // function setUp() public { | ||
| // } | ||
| contract ConclusionTest is Test { | ||
| Conclusion public c; | ||
| function setUp() public { | ||
| c = new Conclusion(); | ||
| vm.difficulty(2**25); | ||
| } | ||
|
|
||
| // } | ||
| function test_mintContract() public { | ||
| vm.expectRevert("only EOA"); | ||
| c.mint(); | ||
| } | ||
|
|
||
| // didnt have time to write tests T_T , but it was reviewed by some big brains. | ||
| function test_mint() public { | ||
| vm.prank(0x4C9ACeE7Ba4d5AFD8408D0c68591e2ABB01A3ec9, 0x4C9ACeE7Ba4d5AFD8408D0c68591e2ABB01A3ec9); | ||
| c.mint(); | ||
| } | ||
|
|
||
| function test_idk() public { | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity 0.8.13; | ||
|
|
||
| import "forge-std/Test.sol"; | ||
| import "../src/Genesis.sol"; | ||
|
|
||
| contract GenesisTest is Test { | ||
| Genesis public g; | ||
| function setUp() public { | ||
| g = new Genesis(); | ||
| vm.difficulty(2**255); | ||
| } | ||
|
|
||
| function mintContract() public { | ||
| vm.expectRevert("only EOA"); | ||
| g.mint(); | ||
| } | ||
|
|
||
| function test_mint() public { | ||
| vm.prank(0x4C9ACeE7Ba4d5AFD8408D0c68591e2ABB01A3ec9, 0x4C9ACeE7Ba4d5AFD8408D0c68591e2ABB01A3ec9); | ||
| g.mint(); | ||
| } | ||
|
|
||
| function test_idk() public { | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typically we want to keep lib so ppl can just run
forge installwhen playing with the repo