From 072443ce82b35fe3abf2b268725e13fd29149bea Mon Sep 17 00:00:00 2001 From: Vectorized Date: Mon, 18 Mar 2024 21:43:46 +0000 Subject: [PATCH] Rename DN69 to DN420 --- .gas-snapshot | 254 +++++++++--------- src/{DN69.sol => DN420.sol} | 82 +++--- test/Bench.t.sol | 72 ++--- test/{DN69.t.sol => DN420.t.sol} | 70 ++--- ...69OnlyERC20.t.sol => DN420OnlyERC20.t.sol} | 24 +- .../mocks/{MockDN69.sol => MockDN420.sol} | 20 +- ...69OnlyERC20.sol => MockDN420OnlyERC20.sol} | 8 +- .../{MockDN69Slim.sol => MockDN420Slim.sol} | 8 +- 8 files changed, 269 insertions(+), 269 deletions(-) rename src/{DN69.sol => DN420.sol} (96%) rename test/{DN69.t.sol => DN420.t.sol} (94%) rename test/{DN69OnlyERC20.t.sol => DN420OnlyERC20.t.sol} (93%) rename test/utils/mocks/{MockDN69.sol => MockDN420.sol} (88%) rename test/utils/mocks/{MockDN69OnlyERC20.sol => MockDN420OnlyERC20.sol} (83%) rename test/utils/mocks/{MockDN69Slim.sol => MockDN420Slim.sol} (69%) diff --git a/.gas-snapshot b/.gas-snapshot index 28e754a..067d094 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -3,103 +3,103 @@ BaseInvariantTest:invariantMirror721BalanceSum() (runs: 30, calls: 450, reverts: BaseInvariantTest:invariantMirrorAndBaseRemainImmutable() (runs: 30, calls: 450, reverts: 0) BaseInvariantTest:invariantTotalReflectionIsValid() (runs: 30, calls: 450, reverts: 0) BaseInvariantTest:invariantUserReflectionIsValid() (runs: 30, calls: 450, reverts: 0) -BenchTest:testMintAndTransferDN404_01() (gas: 208979) -BenchTest:testMintAndTransferDN404_02() (gas: 215077) -BenchTest:testMintAndTransferDN404_03() (gas: 221269) -BenchTest:testMintAndTransferDN404_04() (gas: 227371) -BenchTest:testMintAndTransferDN404_05() (gas: 255483) -BenchTest:testMintAndTransferDN404_06() (gas: 261608) +BenchTest:testMintAndTransferDN404_01() (gas: 208935) +BenchTest:testMintAndTransferDN404_02() (gas: 215100) +BenchTest:testMintAndTransferDN404_03() (gas: 221224) +BenchTest:testMintAndTransferDN404_04() (gas: 227415) +BenchTest:testMintAndTransferDN404_05() (gas: 255440) +BenchTest:testMintAndTransferDN404_06() (gas: 261586) BenchTest:testMintAndTransferDN404_07() (gas: 267701) -BenchTest:testMintAndTransferDN404_08() (gas: 273856) +BenchTest:testMintAndTransferDN404_08() (gas: 273900) BenchTest:testMintAndTransferDN404_09() (gas: 345702) -BenchTest:testMintAndTransferDN404_10() (gas: 351850) -BenchTest:testMintAndTransferDN404_11() (gas: 358017) -BenchTest:testMintAndTransferDN404_12() (gas: 364140) -BenchTest:testMintAndTransferDN404_13() (gas: 392210) -BenchTest:testMintAndTransferDN404_14() (gas: 398357) -BenchTest:testMintAndTransferDN404_15() (gas: 404525) -BenchTest:testMintAndTransferDN404_16() (gas: 410649) -BenchTest:testMintAndTransferDN69_01() (gas: 135848) -BenchTest:testMintAndTransferDN69_02() (gas: 138889) -BenchTest:testMintAndTransferDN69_03() (gas: 141970) -BenchTest:testMintAndTransferDN69_04() (gas: 145072) -BenchTest:testMintAndTransferDN69_05() (gas: 148137) -BenchTest:testMintAndTransferDN69_06() (gas: 151260) -BenchTest:testMintAndTransferDN69_07() (gas: 154300) -BenchTest:testMintAndTransferDN69_08() (gas: 157405) -BenchTest:testMintAndTransferDN69_09() (gas: 160487) -BenchTest:testMintAndTransferDN69_10() (gas: 163571) -BenchTest:testMintAndTransferDN69_11() (gas: 166635) -BenchTest:testMintAndTransferDN69_12() (gas: 169738) -BenchTest:testMintAndTransferDN69_13() (gas: 172843) -BenchTest:testMintAndTransferDN69_14() (gas: 175929) -BenchTest:testMintAndTransferDN69_15() (gas: 179010) -BenchTest:testMintAndTransferDN69_16() (gas: 182094) -BenchTest:testMintAndTransferPandora_01() (gas: 190508) -BenchTest:testMintAndTransferPandora_02() (gas: 306390) -BenchTest:testMintAndTransferPandora_03() (gas: 422274) -BenchTest:testMintAndTransferPandora_04() (gas: 538174) -BenchTest:testMintAndTransferPandora_05() (gas: 654074) -BenchTest:testMintAndTransferPandora_06() (gas: 769991) -BenchTest:testMintAndTransferPandora_07() (gas: 885890) -BenchTest:testMintAndTransferPandora_08() (gas: 1001808) +BenchTest:testMintAndTransferDN404_10() (gas: 351894) +BenchTest:testMintAndTransferDN404_11() (gas: 358060) +BenchTest:testMintAndTransferDN404_12() (gas: 364163) +BenchTest:testMintAndTransferDN404_13() (gas: 392252) +BenchTest:testMintAndTransferDN404_14() (gas: 398358) +BenchTest:testMintAndTransferDN404_15() (gas: 404503) +BenchTest:testMintAndTransferDN404_16() (gas: 410626) +BenchTest:testMintAndTransferDN420_01() (gas: 135802) +BenchTest:testMintAndTransferDN420_02() (gas: 138913) +BenchTest:testMintAndTransferDN420_03() (gas: 141992) +BenchTest:testMintAndTransferDN420_04() (gas: 145095) +BenchTest:testMintAndTransferDN420_05() (gas: 148180) +BenchTest:testMintAndTransferDN420_06() (gas: 151239) +BenchTest:testMintAndTransferDN420_07() (gas: 154364) +BenchTest:testMintAndTransferDN420_08() (gas: 157384) +BenchTest:testMintAndTransferDN420_09() (gas: 160510) +BenchTest:testMintAndTransferDN420_10() (gas: 163550) +BenchTest:testMintAndTransferDN420_11() (gas: 166634) +BenchTest:testMintAndTransferDN420_12() (gas: 169760) +BenchTest:testMintAndTransferDN420_13() (gas: 172800) +BenchTest:testMintAndTransferDN420_14() (gas: 175904) +BenchTest:testMintAndTransferDN420_15() (gas: 179031) +BenchTest:testMintAndTransferDN420_16() (gas: 182050) +BenchTest:testMintAndTransferPandora_01() (gas: 190474) +BenchTest:testMintAndTransferPandora_02() (gas: 306408) +BenchTest:testMintAndTransferPandora_03() (gas: 422308) +BenchTest:testMintAndTransferPandora_04() (gas: 538173) +BenchTest:testMintAndTransferPandora_05() (gas: 654075) +BenchTest:testMintAndTransferPandora_06() (gas: 770009) +BenchTest:testMintAndTransferPandora_07() (gas: 885872) +BenchTest:testMintAndTransferPandora_08() (gas: 1001792) BenchTest:testMintAndTransferPandora_09() (gas: 1117673) -BenchTest:testMintAndTransferPandora_10() (gas: 1233574) -BenchTest:testMintAndTransferPandora_11() (gas: 1349508) -BenchTest:testMintAndTransferPandora_12() (gas: 1465425) -BenchTest:testMintAndTransferPandora_13() (gas: 1581310) -BenchTest:testMintAndTransferPandora_14() (gas: 1697190) -BenchTest:testMintAndTransferPandora_15() (gas: 1813108) -BenchTest:testMintAndTransferPandora_16() (gas: 1928992) -BenchTest:testMintDN404_01() (gas: 123563) -BenchTest:testMintDN404_02() (gas: 126674) -BenchTest:testMintDN404_03() (gas: 129765) -BenchTest:testMintDN404_04() (gas: 132816) -BenchTest:testMintDN404_05() (gas: 157785) -BenchTest:testMintDN404_06() (gas: 160899) -BenchTest:testMintDN404_07() (gas: 164015) -BenchTest:testMintDN404_08() (gas: 167061) -BenchTest:testMintDN404_09() (gas: 213998) -BenchTest:testMintDN404_10() (gas: 217070) -BenchTest:testMintDN404_11() (gas: 220160) -BenchTest:testMintDN404_12() (gas: 223275) -BenchTest:testMintDN404_13() (gas: 248245) -BenchTest:testMintDN404_14() (gas: 251338) -BenchTest:testMintDN404_15() (gas: 254426) -BenchTest:testMintDN404_16() (gas: 257520) -BenchTest:testMintDN69_01() (gas: 94562) -BenchTest:testMintDN69_02() (gas: 95931) -BenchTest:testMintDN69_03() (gas: 97377) -BenchTest:testMintDN69_04() (gas: 98807) -BenchTest:testMintDN69_05() (gas: 100236) -BenchTest:testMintDN69_06() (gas: 101683) -BenchTest:testMintDN69_07() (gas: 103092) -BenchTest:testMintDN69_08() (gas: 104496) -BenchTest:testMintDN69_09() (gas: 105925) -BenchTest:testMintDN69_10() (gas: 107401) -BenchTest:testMintDN69_11() (gas: 108783) -BenchTest:testMintDN69_12() (gas: 110209) -BenchTest:testMintDN69_13() (gas: 111664) -BenchTest:testMintDN69_14() (gas: 113114) -BenchTest:testMintDN69_15() (gas: 114520) -BenchTest:testMintDN69_16() (gas: 115970) -BenchTest:testMintPandora_01() (gas: 133934) -BenchTest:testMintPandora_02() (gas: 203438) -BenchTest:testMintPandora_03() (gas: 272942) +BenchTest:testMintAndTransferPandora_10() (gas: 1233575) +BenchTest:testMintAndTransferPandora_11() (gas: 1349489) +BenchTest:testMintAndTransferPandora_12() (gas: 1465390) +BenchTest:testMintAndTransferPandora_13() (gas: 1581309) +BenchTest:testMintAndTransferPandora_14() (gas: 1697172) +BenchTest:testMintAndTransferPandora_15() (gas: 1813072) +BenchTest:testMintAndTransferPandora_16() (gas: 1928974) +BenchTest:testMintDN404_01() (gas: 123564) +BenchTest:testMintDN404_02() (gas: 126608) +BenchTest:testMintDN404_03() (gas: 129721) +BenchTest:testMintDN404_04() (gas: 132839) +BenchTest:testMintDN404_05() (gas: 157828) +BenchTest:testMintDN404_06() (gas: 160878) +BenchTest:testMintDN404_07() (gas: 164034) +BenchTest:testMintDN404_08() (gas: 167062) +BenchTest:testMintDN404_09() (gas: 213997) +BenchTest:testMintDN404_10() (gas: 217092) +BenchTest:testMintDN404_11() (gas: 220159) +BenchTest:testMintDN404_12() (gas: 223231) +BenchTest:testMintDN404_13() (gas: 248268) +BenchTest:testMintDN404_14() (gas: 251336) +BenchTest:testMintDN404_15() (gas: 254448) +BenchTest:testMintDN404_16() (gas: 257542) +BenchTest:testMintDN420_01() (gas: 94520) +BenchTest:testMintDN420_02() (gas: 95953) +BenchTest:testMintDN420_03() (gas: 97377) +BenchTest:testMintDN420_04() (gas: 98827) +BenchTest:testMintDN420_05() (gas: 100237) +BenchTest:testMintDN420_06() (gas: 101686) +BenchTest:testMintDN420_07() (gas: 103112) +BenchTest:testMintDN420_08() (gas: 104521) +BenchTest:testMintDN420_09() (gas: 105971) +BenchTest:testMintDN420_10() (gas: 107377) +BenchTest:testMintDN420_11() (gas: 108826) +BenchTest:testMintDN420_12() (gas: 110255) +BenchTest:testMintDN420_13() (gas: 111640) +BenchTest:testMintDN420_14() (gas: 113114) +BenchTest:testMintDN420_15() (gas: 114497) +BenchTest:testMintDN420_16() (gas: 115948) +BenchTest:testMintPandora_01() (gas: 133912) +BenchTest:testMintPandora_02() (gas: 203394) +BenchTest:testMintPandora_03() (gas: 272897) BenchTest:testMintPandora_04() (gas: 342394) -BenchTest:testMintPandora_05() (gas: 411907) -BenchTest:testMintPandora_06() (gas: 481411) -BenchTest:testMintPandora_07() (gas: 550914) -BenchTest:testMintPandora_08() (gas: 620419) -BenchTest:testMintPandora_09() (gas: 689944) -BenchTest:testMintPandora_10() (gas: 759428) +BenchTest:testMintPandora_05() (gas: 411951) +BenchTest:testMintPandora_06() (gas: 481434) +BenchTest:testMintPandora_07() (gas: 550959) +BenchTest:testMintPandora_08() (gas: 620442) +BenchTest:testMintPandora_09() (gas: 689967) +BenchTest:testMintPandora_10() (gas: 759469) BenchTest:testMintPandora_11() (gas: 828952) -BenchTest:testMintPandora_12() (gas: 898479) -BenchTest:testMintPandora_13() (gas: 967960) -BenchTest:testMintPandora_14() (gas: 1037484) -BenchTest:testMintPandora_15() (gas: 1107011) -BenchTest:testMintPandora_16() (gas: 1176495) -BenchTest:test__codesize() (gas: 39142) +BenchTest:testMintPandora_12() (gas: 898457) +BenchTest:testMintPandora_13() (gas: 967961) +BenchTest:testMintPandora_14() (gas: 1037506) +BenchTest:testMintPandora_15() (gas: 1106967) +BenchTest:testMintPandora_16() (gas: 1176451) +BenchTest:test__codesize() (gas: 39186) DN404CustomUnitTest:testInitializeCorrectUnitSuccess() (gas: 129992) DN404CustomUnitTest:testInitializeWithUnitTooLargeReverts() (gas: 33824) DN404CustomUnitTest:testInitializeWithZeroUnitReverts() (gas: 13897) @@ -174,41 +174,41 @@ DN404Test:testTokenURI(string,uint256) (runs: 256, μ: 157949, ~: 135687) DN404Test:testTransfersAndBurns() (gas: 2924439) DN404Test:testWrapAround(uint32,uint256) (runs: 256, μ: 3662972, ~: 3425561) DN404Test:test__codesize() (gas: 57359) -DN69OnlyERC20Test:testApprove() (gas: 35770) -DN69OnlyERC20Test:testApprove(address,uint256) (runs: 256, μ: 30077, ~: 31321) -DN69OnlyERC20Test:testBurn() (gas: 50438) -DN69OnlyERC20Test:testBurn(address,uint256,uint256) (runs: 256, μ: 51557, ~: 51639) -DN69OnlyERC20Test:testBurnInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 44621, ~: 44709) -DN69OnlyERC20Test:testInfiniteApproveTransferFrom() (gas: 102630) -DN69OnlyERC20Test:testMaxSupplyTrick(uint256) (runs: 256, μ: 541, ~: 541) -DN69OnlyERC20Test:testMetadata() (gas: 10112) -DN69OnlyERC20Test:testMint() (gas: 45958) -DN69OnlyERC20Test:testMintOverMaxLimitReverts() (gas: 41962) -DN69OnlyERC20Test:testMintz(address,uint256) (runs: 256, μ: 46280, ~: 46380) -DN69OnlyERC20Test:testTransfer() (gas: 75434) -DN69OnlyERC20Test:testTransfer(address,uint256) (runs: 256, μ: 75788, ~: 75891) -DN69OnlyERC20Test:testTransferFrom() (gas: 85088) -DN69OnlyERC20Test:testTransferFrom(address,address,address,uint256,uint256) (runs: 256, μ: 105856, ~: 108058) -DN69OnlyERC20Test:testTransferFromInsufficientAllowanceReverts() (gas: 68658) -DN69OnlyERC20Test:testTransferFromInsufficientAllowanceReverts(address,uint256,uint256) (runs: 256, μ: 69177, ~: 69759) -DN69OnlyERC20Test:testTransferFromInsufficientBalanceReverts() (gas: 75577) -DN69OnlyERC20Test:testTransferFromInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 76706, ~: 76698) -DN69OnlyERC20Test:testTransferInsufficientBalanceReverts() (gas: 67140) -DN69OnlyERC20Test:testTransferInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 68178, ~: 68227) -DN69OnlyERC20Test:test__codesize() (gas: 27225) -DN69Test:testERC1155Methods(uint256) (runs: 256, μ: 4287998, ~: 4528649) -DN69Test:testERC1155MethodsSelfTransfers(uint256) (runs: 256, μ: 2326815, ~: 2038283) -DN69Test:testFindOwnedIds() (gas: 2609656) -DN69Test:testMintNext() (gas: 2096399) -DN69Test:testMintToNonERC155RecipientReverts(uint256) (runs: 256, μ: 933128, ~: 791303) -DN69Test:testMintToRevertingERC155RecipientReverts(uint256) (runs: 256, μ: 1480170, ~: 972226) -DN69Test:testMintToZeroReverts(uint256) (runs: 256, μ: 719207, ~: 654914) -DN69Test:testMixed(uint256) (runs: 256, μ: 10853923, ~: 6350437) -DN69Test:testSafeBatchTransferFromToERC1155Recipient(uint256) (runs: 256, μ: 2237953, ~: 2162770) -DN69Test:testSafeTransferFromToERC1155Recipient(uint256) (runs: 256, μ: 1738142, ~: 1465578) -DN69Test:testTransferFromToERC1155Recipient(uint256) (runs: 256, μ: 2861144, ~: 2847812) -DN69Test:testTransferMixedReverts(uint256) (runs: 256, μ: 4575504, ~: 3834197) -DN69Test:test__codesize() (gas: 65215) +DN420OnlyERC20Test:testApprove() (gas: 35770) +DN420OnlyERC20Test:testApprove(address,uint256) (runs: 256, μ: 30077, ~: 31321) +DN420OnlyERC20Test:testBurn() (gas: 50438) +DN420OnlyERC20Test:testBurn(address,uint256,uint256) (runs: 256, μ: 51561, ~: 51639) +DN420OnlyERC20Test:testBurnInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 44725, ~: 44704) +DN420OnlyERC20Test:testInfiniteApproveTransferFrom() (gas: 102630) +DN420OnlyERC20Test:testMaxSupplyTrick(uint256) (runs: 256, μ: 541, ~: 541) +DN420OnlyERC20Test:testMetadata() (gas: 10112) +DN420OnlyERC20Test:testMint() (gas: 45958) +DN420OnlyERC20Test:testMintOverMaxLimitReverts() (gas: 41962) +DN420OnlyERC20Test:testMintz(address,uint256) (runs: 256, μ: 46266, ~: 46380) +DN420OnlyERC20Test:testTransfer() (gas: 75434) +DN420OnlyERC20Test:testTransfer(address,uint256) (runs: 256, μ: 75776, ~: 75891) +DN420OnlyERC20Test:testTransferFrom() (gas: 85088) +DN420OnlyERC20Test:testTransferFrom(address,address,address,uint256,uint256) (runs: 256, μ: 105862, ~: 108058) +DN420OnlyERC20Test:testTransferFromInsufficientAllowanceReverts() (gas: 68658) +DN420OnlyERC20Test:testTransferFromInsufficientAllowanceReverts(address,uint256,uint256) (runs: 256, μ: 69183, ~: 69768) +DN420OnlyERC20Test:testTransferFromInsufficientBalanceReverts() (gas: 75577) +DN420OnlyERC20Test:testTransferFromInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 76638, ~: 76698) +DN420OnlyERC20Test:testTransferInsufficientBalanceReverts() (gas: 67140) +DN420OnlyERC20Test:testTransferInsufficientBalanceReverts(address,uint256,uint256) (runs: 256, μ: 68265, ~: 68227) +DN420OnlyERC20Test:test__codesize() (gas: 27225) +DN420Test:testERC1155Methods(uint256) (runs: 256, μ: 4272488, ~: 4513577) +DN420Test:testERC1155MethodsSelfTransfers(uint256) (runs: 256, μ: 2374763, ~: 2038371) +DN420Test:testFindOwnedIds() (gas: 2609788) +DN420Test:testMintNext() (gas: 2095753) +DN420Test:testMintToNonERC155RecipientReverts(uint256) (runs: 256, μ: 910536, ~: 790828) +DN420Test:testMintToRevertingERC155RecipientReverts(uint256) (runs: 256, μ: 1444697, ~: 972152) +DN420Test:testMintToZeroReverts(uint256) (runs: 256, μ: 759023, ~: 654981) +DN420Test:testMixed(uint256) (runs: 256, μ: 9743798, ~: 6289775) +DN420Test:testSafeBatchTransferFromToERC1155Recipient(uint256) (runs: 256, μ: 2208458, ~: 2162910) +DN420Test:testSafeTransferFromToERC1155Recipient(uint256) (runs: 256, μ: 1768999, ~: 1466043) +DN420Test:testTransferFromToERC1155Recipient(uint256) (runs: 256, μ: 2859178, ~: 2847717) +DN420Test:testTransferMixedReverts(uint256) (runs: 256, μ: 4066879, ~: 3255945) +DN420Test:test__codesize() (gas: 65215) MappingsTest:testAddressPairMapSetAndGet(address[2],address[2],uint256,uint256) (runs: 256, μ: 45753, ~: 47075) MappingsTest:testBitmapSetAndGet(uint256) (runs: 256, μ: 465457, ~: 442995) MappingsTest:testBitmapSetAndGet(uint256,uint256,bool,bool) (runs: 256, μ: 25658, ~: 26270) diff --git a/src/DN69.sol b/src/DN420.sol similarity index 96% rename from src/DN69.sol rename to src/DN420.sol index ff95055..9ef73ea 100644 --- a/src/DN69.sol +++ b/src/DN420.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; -/// @title DN69 -/// @notice DN69 is a fully standard compliant, single-contract, +/// @title DN420 +/// @notice DN420 is a fully standard compliant, single-contract, /// ERC20 and ERC1155 chimera implementation that mints /// and burns NFTs based on an account's ERC20 token balance. /// /// On-transfer token ID burning scheme: -/// - DN69: Largest token ID up to owned checkpoint (inclusive) first. +/// - DN420: Largest token ID up to owned checkpoint (inclusive) first. /// - DN404: Most recently acquired token ID first. /// /// This implementation uses bitmap scans to find ERC1155 token IDs @@ -24,7 +24,7 @@ pragma solidity ^0.8.4; /// @author cygaar (@0xCygaar) /// @author Thomas (@0xjustadev) /// @author Harrison (@PopPunkOnChain) -abstract contract DN69 { +abstract contract DN420 { /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/ /* EVENTS */ /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/ @@ -194,7 +194,7 @@ abstract contract DN69 { } /// @dev Struct containing the base token contract storage. - struct DN69Storage { + struct DN420Storage { // Next NFT ID to assign for a mint. uint32 nextTokenId; // The upper bound (inclusive) for token IDs minted thus far. @@ -213,11 +213,11 @@ abstract contract DN69 { mapping(address => AddressData) addressData; } - /// @dev Returns a storage pointer for DN69Storage. - function _getDN69Storage() internal pure virtual returns (DN69Storage storage $) { + /// @dev Returns a storage pointer for DN420Storage. + function _getDN420Storage() internal pure virtual returns (DN420Storage storage $) { /// @solidity memory-safe-assembly assembly { - // `uint72(bytes9(keccak256("DN69_STORAGE")))`. + // `uint72(bytes9(keccak256("DN420_STORAGE")))`. $.slot := 0xbf77275a289f9ab11f // Truncate to 9 bytes to reduce bytecode size. } } @@ -226,13 +226,13 @@ abstract contract DN69 { /* INITIALIZER */ /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/ - /// @dev Initializes the DN69 contract with an + /// @dev Initializes the DN420 contract with an /// `initialTokenSupply` and `initialTokenOwner`. - function _initializeDN69(uint256 initialTokenSupply, address initialSupplyOwner) + function _initializeDN420(uint256 initialTokenSupply, address initialSupplyOwner) internal virtual { - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); unchecked { if (_unit() - 1 >= 2 ** 96 - 1) revert InvalidUnit(); @@ -315,21 +315,21 @@ abstract contract DN69 { /// @dev Returns the amount of ERC20 tokens in existence. function totalSupply() public view virtual returns (uint256) { - return uint256(_getDN69Storage().totalSupply); + return uint256(_getDN420Storage().totalSupply); } /// @dev Returns the amount of ERC20 tokens owned by `owner`. function balanceOf(address owner) public view virtual returns (uint256) { - return _getDN69Storage().addressData[owner].balance; + return _getDN420Storage().addressData[owner].balance; } /// @dev Returns the amount of ERC20 tokens that `spender` can spend on behalf of `owner`. function allowance(address owner, address spender) public view returns (uint256) { if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) { - uint8 flags = _getDN69Storage().addressData[owner].flags; + uint8 flags = _getDN420Storage().addressData[owner].flags; if (_isZero(flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG)) return type(uint256).max; } - return _ref(_getDN69Storage().allowance, owner, spender).value; + return _ref(_getDN420Storage().allowance, owner, spender).value; } /// @dev Sets `amount` as the allowance of `spender` over the caller's ERC20 tokens. @@ -378,10 +378,10 @@ abstract contract DN69 { /// /// Emits a {Transfer} event. function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) { - Uint256Ref storage a = _ref(_getDN69Storage().allowance, from, msg.sender); + Uint256Ref storage a = _ref(_getDN420Storage().allowance, from, msg.sender); uint256 allowed = _givePermit2DefaultInfiniteAllowance() && msg.sender == _PERMIT2 - && _isZero(_getDN69Storage().addressData[from].flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG) + && _isZero(_getDN420Storage().addressData[from].flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG) ? type(uint256).max : a.value; @@ -421,7 +421,7 @@ abstract contract DN69 { if (to == address(0)) revert TransferToZeroAddress(); AddressData storage toAddressData = _addressData(to); - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); if (_isZero($.nextTokenId)) revert DNNotInitialized(); _DNMintTemps memory t; @@ -488,7 +488,7 @@ abstract contract DN69 { if (to == address(0)) revert TransferToZeroAddress(); AddressData storage toAddressData = _addressData(to); - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); if (_isZero($.nextTokenId)) revert DNNotInitialized(); uint256 id; @@ -556,7 +556,7 @@ abstract contract DN69 { /// Emits an ERC20 {Transfer} event. function _burn(address from, uint256 amount) internal virtual { AddressData storage fromAddressData = _addressData(from); - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); if (_isZero($.nextTokenId)) revert DNNotInitialized(); uint256 fromBalance = fromAddressData.balance; @@ -621,7 +621,7 @@ abstract contract DN69 { AddressData storage fromAddressData = _addressData(from); AddressData storage toAddressData = _addressData(to); - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); if (_isZero($.nextTokenId)) revert DNNotInitialized(); _DNTransferTemps memory t; @@ -754,7 +754,7 @@ abstract contract DN69 { { if (to == address(0)) revert TransferToZeroAddress(); - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); if (_isZero($.nextTokenId)) revert DNNotInitialized(); if (_toUint(by == address(0)) | _toUint(by == from) == 0) { @@ -820,7 +820,7 @@ abstract contract DN69 { ) internal virtual { if (to == address(0)) revert TransferToZeroAddress(); - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); if (_isZero($.nextTokenId)) revert DNNotInitialized(); if (_toUint(by == address(0)) | _toUint(by == from) == 0) { @@ -877,9 +877,9 @@ abstract contract DN69 { /// Emits a {Approval} event. function _approve(address owner, address spender, uint256 amount) internal virtual { if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) { - _getDN69Storage().addressData[owner].flags |= _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG; + _getDN420Storage().addressData[owner].flags |= _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG; } - _ref(_getDN69Storage().allowance, owner, spender).value = amount; + _ref(_getDN420Storage().allowance, owner, spender).value = amount; /// @solidity memory-safe-assembly assembly { // Emit the {Approval} event. @@ -897,14 +897,14 @@ abstract contract DN69 { /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data. /// Auxiliary data can be set for any address, even if it does not have any tokens. function _getAux(address owner) internal view virtual returns (uint88) { - return _getDN69Storage().addressData[owner].aux; + return _getDN420Storage().addressData[owner].aux; } /// @dev Set the auxiliary data for `owner` to `value`. /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data. /// Auxiliary data can be set for any address, even if it does not have any tokens. function _setAux(address owner, uint88 value) internal virtual { - _getDN69Storage().addressData[owner].aux = value; + _getDN420Storage().addressData[owner].aux = value; } /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/ @@ -914,7 +914,7 @@ abstract contract DN69 { /// @dev Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs. /// Returns false otherwise. function getSkipNFT(address owner) public view virtual returns (bool) { - AddressData storage d = _getDN69Storage().addressData[owner]; + AddressData storage d = _getDN420Storage().addressData[owner]; if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) return _hasCode(owner); return d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0; } @@ -948,7 +948,7 @@ abstract contract DN69 { /// /// Initializes account `owner` AddressData if it is not currently initialized. function _addressData(address owner) internal virtual returns (AddressData storage d) { - d = _getDN69Storage().addressData[owner]; + d = _getDN420Storage().addressData[owner]; unchecked { if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) { uint256 skipNFT = _toUint(_hasCode(owner)) * _ADDRESS_DATA_SKIP_NFT_FLAG; @@ -963,7 +963,7 @@ abstract contract DN69 { /// @dev Returns the owned checkpoint of `owner`. function getOwnedCheckpoint(address owner) public view virtual returns (uint256) { - return _getDN69Storage().addressData[owner].ownedCheckpoint; + return _getDN420Storage().addressData[owner].ownedCheckpoint; } /// @dev Just in case the collection gets too large and the caller needs @@ -976,7 +976,7 @@ abstract contract DN69 { /// @dev Sets the owned checkpoint of `owner` to `id`. /// `id` will be clamped to `[1..tokenIdUpTo]`. function _setOwnedCheckpoint(address owner, uint256 id) internal virtual { - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); id = _min(_max(1, id), $.tokenIdUpTo); $.addressData[owner].ownedCheckpoint = uint32(id); emit OwnedCheckpointSet(owner, id); @@ -988,7 +988,7 @@ abstract contract DN69 { /// @dev Returns if `owner` owns ERC1155 `id`. function owns(address owner, uint256 id) public view virtual returns (bool) { - return _owns(_getDN69Storage().owned[owner], id); + return _owns(_getDN420Storage().owned[owner], id); } /// @dev Returns if the ERC1155 `id` is set in `owned`. @@ -998,7 +998,7 @@ abstract contract DN69 { /// @dev Returns whether `operator` is approved to manage the ERC1155 tokens of `owner`. function isApprovedForAll(address owner, address operator) public view virtual returns (bool) { - return !_isZero(_ref(_getDN69Storage().operatorApprovals, owner, operator).value); + return !_isZero(_ref(_getDN420Storage().operatorApprovals, owner, operator).value); } /// @dev Sets whether `operator` is approved to manage the ERC1155 tokens of the caller. @@ -1015,7 +1015,7 @@ abstract contract DN69 { internal virtual { - _ref(_getDN69Storage().operatorApprovals, owner, operator).value = _toUint(isApproved); + _ref(_getDN420Storage().operatorApprovals, owner, operator).value = _toUint(isApproved); /// @solidity memory-safe-assembly assembly { // Emit the {ApprovalForAll} event. @@ -1058,12 +1058,12 @@ abstract contract DN69 { /// @dev Returns `owner`'s ERC1155 NFT balance. function _balanceOfNFT(address owner) internal view virtual returns (uint256) { - return _getDN69Storage().addressData[owner].ownedCount; + return _getDN420Storage().addressData[owner].ownedCount; } /// @dev Returns if the ERC1155 token `id` exists. function _exists(uint256 id) internal view virtual returns (bool) { - return _get(_getDN69Storage().exists, _restrictNFTId(id)); + return _get(_getDN420Storage().exists, _restrictNFTId(id)); } /// @dev Returns the ERC1155 NFT IDs of `owner` in range `[begin, end)`. @@ -1075,7 +1075,7 @@ abstract contract DN69 { returns (uint256[] memory ids) { unchecked { - DN69Storage storage $ = _getDN69Storage(); + DN420Storage storage $ = _getDN420Storage(); Bitmap storage owned = $.owned[owner]; end = _min(uint256($.tokenIdUpTo) + 1, end); /// @solidity memory-safe-assembly @@ -1096,7 +1096,7 @@ abstract contract DN69 { } /// @dev Fallback modifier for the regular ERC1155 functions and other functions. - modifier dn69Fallback() virtual { + modifier dn420Fallback() virtual { uint256 fnSelector = _calldataload(0x00) >> 224; // We hide the regular ERC1155 functions that has variable amounts @@ -1158,7 +1158,7 @@ abstract contract DN69 { ); _return(_toUint(result)); } - // `implementsDN69()`. + // `implementsDN420()`. if (fnSelector == 0x0e0b0984) { _return(1); } @@ -1168,8 +1168,8 @@ abstract contract DN69 { /// @dev Fallback function for regular ERC1155 functions and other functions. /// Override this if you need to implement your custom /// fallback with utilities like Solady's `LibZip.cdFallback()`. - /// And always remember to always wrap the fallback with `dn69Fallback`. - fallback() external payable virtual dn69Fallback { + /// And always remember to always wrap the fallback with `dn420Fallback`. + fallback() external payable virtual dn420Fallback { revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life. } diff --git a/test/Bench.t.sol b/test/Bench.t.sol index 0bf23c2..6603a66 100644 --- a/test/Bench.t.sol +++ b/test/Bench.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.4; import "./utils/SoladyTest.sol"; import {DN404, MockDN404Slim} from "./utils/mocks/MockDN404Slim.sol"; -import {DN69, MockDN69Slim} from "./utils/mocks/MockDN69Slim.sol"; +import {DN420, MockDN420Slim} from "./utils/mocks/MockDN420Slim.sol"; import {DN404Mirror} from "../src/DN404Mirror.sol"; abstract contract Ownable { @@ -372,18 +372,18 @@ interface IERC20 { contract BenchTest is SoladyTest { Pandora pandora; MockDN404Slim dn404; - MockDN69Slim dn69; + MockDN420Slim dn420; DN404Mirror mirror; function setUp() public { pandora = new Pandora(address(this)); - dn69 = new MockDN69Slim(); + dn420 = new MockDN420Slim(); dn404 = new MockDN404Slim(); mirror = new DN404Mirror(address(this)); pandora.setWhitelist(address(this), true); dn404.initializeDN404(10000 * 10 ** 18, address(this), address(mirror)); - dn69.initializeDN69(10000 * 10 ** 18, address(this)); + dn420.initializeDN420(10000 * 10 ** 18, address(this)); } modifier mint(address a, uint256 amount) { @@ -396,52 +396,52 @@ contract BenchTest is SoladyTest { function testMintPandora_01() public mint(address(pandora), 1) {} function testMintDN404_01() public mint(address(dn404), 1) {} - function testMintDN69_01() public mint(address(dn69), 1) {} + function testMintDN420_01() public mint(address(dn420), 1) {} function testMintPandora_02() public mint(address(pandora), 2) {} function testMintDN404_02() public mint(address(dn404), 2) {} - function testMintDN69_02() public mint(address(dn69), 2) {} + function testMintDN420_02() public mint(address(dn420), 2) {} function testMintPandora_03() public mint(address(pandora), 3) {} function testMintDN404_03() public mint(address(dn404), 3) {} - function testMintDN69_03() public mint(address(dn69), 3) {} + function testMintDN420_03() public mint(address(dn420), 3) {} function testMintPandora_04() public mint(address(pandora), 4) {} function testMintDN404_04() public mint(address(dn404), 4) {} - function testMintDN69_04() public mint(address(dn69), 4) {} + function testMintDN420_04() public mint(address(dn420), 4) {} function testMintPandora_05() public mint(address(pandora), 5) {} function testMintDN404_05() public mint(address(dn404), 5) {} - function testMintDN69_05() public mint(address(dn69), 5) {} + function testMintDN420_05() public mint(address(dn420), 5) {} function testMintPandora_06() public mint(address(pandora), 6) {} function testMintDN404_06() public mint(address(dn404), 6) {} - function testMintDN69_06() public mint(address(dn69), 6) {} + function testMintDN420_06() public mint(address(dn420), 6) {} function testMintPandora_07() public mint(address(pandora), 7) {} function testMintDN404_07() public mint(address(dn404), 7) {} - function testMintDN69_07() public mint(address(dn69), 7) {} + function testMintDN420_07() public mint(address(dn420), 7) {} function testMintPandora_08() public mint(address(pandora), 8) {} function testMintDN404_08() public mint(address(dn404), 8) {} - function testMintDN69_08() public mint(address(dn69), 8) {} + function testMintDN420_08() public mint(address(dn420), 8) {} function testMintPandora_09() public mint(address(pandora), 9) {} function testMintDN404_09() public mint(address(dn404), 9) {} - function testMintDN69_09() public mint(address(dn69), 9) {} + function testMintDN420_09() public mint(address(dn420), 9) {} function testMintPandora_10() public mint(address(pandora), 10) {} function testMintDN404_10() public mint(address(dn404), 10) {} - function testMintDN69_10() public mint(address(dn69), 10) {} + function testMintDN420_10() public mint(address(dn420), 10) {} function testMintPandora_11() public mint(address(pandora), 11) {} function testMintDN404_11() public mint(address(dn404), 11) {} - function testMintDN69_11() public mint(address(dn69), 11) {} + function testMintDN420_11() public mint(address(dn420), 11) {} function testMintPandora_12() public mint(address(pandora), 12) {} function testMintDN404_12() public mint(address(dn404), 12) {} - function testMintDN69_12() public mint(address(dn69), 12) {} + function testMintDN420_12() public mint(address(dn420), 12) {} function testMintPandora_13() public mint(address(pandora), 13) {} function testMintDN404_13() public mint(address(dn404), 13) {} - function testMintDN69_13() public mint(address(dn69), 13) {} + function testMintDN420_13() public mint(address(dn420), 13) {} function testMintPandora_14() public mint(address(pandora), 14) {} function testMintDN404_14() public mint(address(dn404), 14) {} - function testMintDN69_14() public mint(address(dn69), 14) {} + function testMintDN420_14() public mint(address(dn420), 14) {} function testMintPandora_15() public mint(address(pandora), 15) {} function testMintDN404_15() public mint(address(dn404), 15) {} - function testMintDN69_15() public mint(address(dn69), 15) {} + function testMintDN420_15() public mint(address(dn420), 15) {} function testMintPandora_16() public mint(address(pandora), 16) {} function testMintDN404_16() public mint(address(dn404), 16) {} - function testMintDN69_16() public mint(address(dn69), 16) {} + function testMintDN420_16() public mint(address(dn420), 16) {} modifier mintAndTransfer(address a, uint256 amount) { unchecked { @@ -456,50 +456,50 @@ contract BenchTest is SoladyTest { function testMintAndTransferPandora_01() public mintAndTransfer(address(pandora), 1) {} function testMintAndTransferDN404_01() public mintAndTransfer(address(dn404), 1) {} - function testMintAndTransferDN69_01() public mintAndTransfer(address(dn69), 1) {} + function testMintAndTransferDN420_01() public mintAndTransfer(address(dn420), 1) {} function testMintAndTransferPandora_02() public mintAndTransfer(address(pandora), 2) {} function testMintAndTransferDN404_02() public mintAndTransfer(address(dn404), 2) {} - function testMintAndTransferDN69_02() public mintAndTransfer(address(dn69), 2) {} + function testMintAndTransferDN420_02() public mintAndTransfer(address(dn420), 2) {} function testMintAndTransferPandora_03() public mintAndTransfer(address(pandora), 3) {} function testMintAndTransferDN404_03() public mintAndTransfer(address(dn404), 3) {} - function testMintAndTransferDN69_03() public mintAndTransfer(address(dn69), 3) {} + function testMintAndTransferDN420_03() public mintAndTransfer(address(dn420), 3) {} function testMintAndTransferPandora_04() public mintAndTransfer(address(pandora), 4) {} function testMintAndTransferDN404_04() public mintAndTransfer(address(dn404), 4) {} - function testMintAndTransferDN69_04() public mintAndTransfer(address(dn69), 4) {} + function testMintAndTransferDN420_04() public mintAndTransfer(address(dn420), 4) {} function testMintAndTransferPandora_05() public mintAndTransfer(address(pandora), 5) {} function testMintAndTransferDN404_05() public mintAndTransfer(address(dn404), 5) {} - function testMintAndTransferDN69_05() public mintAndTransfer(address(dn69), 5) {} + function testMintAndTransferDN420_05() public mintAndTransfer(address(dn420), 5) {} function testMintAndTransferPandora_06() public mintAndTransfer(address(pandora), 6) {} function testMintAndTransferDN404_06() public mintAndTransfer(address(dn404), 6) {} - function testMintAndTransferDN69_06() public mintAndTransfer(address(dn69), 6) {} + function testMintAndTransferDN420_06() public mintAndTransfer(address(dn420), 6) {} function testMintAndTransferPandora_07() public mintAndTransfer(address(pandora), 7) {} function testMintAndTransferDN404_07() public mintAndTransfer(address(dn404), 7) {} - function testMintAndTransferDN69_07() public mintAndTransfer(address(dn69), 7) {} + function testMintAndTransferDN420_07() public mintAndTransfer(address(dn420), 7) {} function testMintAndTransferPandora_08() public mintAndTransfer(address(pandora), 8) {} function testMintAndTransferDN404_08() public mintAndTransfer(address(dn404), 8) {} - function testMintAndTransferDN69_08() public mintAndTransfer(address(dn69), 8) {} + function testMintAndTransferDN420_08() public mintAndTransfer(address(dn420), 8) {} function testMintAndTransferPandora_09() public mintAndTransfer(address(pandora), 9) {} function testMintAndTransferDN404_09() public mintAndTransfer(address(dn404), 9) {} - function testMintAndTransferDN69_09() public mintAndTransfer(address(dn69), 9) {} + function testMintAndTransferDN420_09() public mintAndTransfer(address(dn420), 9) {} function testMintAndTransferPandora_10() public mintAndTransfer(address(pandora), 10) {} function testMintAndTransferDN404_10() public mintAndTransfer(address(dn404), 10) {} - function testMintAndTransferDN69_10() public mintAndTransfer(address(dn69), 10) {} + function testMintAndTransferDN420_10() public mintAndTransfer(address(dn420), 10) {} function testMintAndTransferPandora_11() public mintAndTransfer(address(pandora), 11) {} function testMintAndTransferDN404_11() public mintAndTransfer(address(dn404), 11) {} - function testMintAndTransferDN69_11() public mintAndTransfer(address(dn69), 11) {} + function testMintAndTransferDN420_11() public mintAndTransfer(address(dn420), 11) {} function testMintAndTransferPandora_12() public mintAndTransfer(address(pandora), 12) {} function testMintAndTransferDN404_12() public mintAndTransfer(address(dn404), 12) {} - function testMintAndTransferDN69_12() public mintAndTransfer(address(dn69), 12) {} + function testMintAndTransferDN420_12() public mintAndTransfer(address(dn420), 12) {} function testMintAndTransferPandora_13() public mintAndTransfer(address(pandora), 13) {} function testMintAndTransferDN404_13() public mintAndTransfer(address(dn404), 13) {} - function testMintAndTransferDN69_13() public mintAndTransfer(address(dn69), 13) {} + function testMintAndTransferDN420_13() public mintAndTransfer(address(dn420), 13) {} function testMintAndTransferPandora_14() public mintAndTransfer(address(pandora), 14) {} function testMintAndTransferDN404_14() public mintAndTransfer(address(dn404), 14) {} - function testMintAndTransferDN69_14() public mintAndTransfer(address(dn69), 14) {} + function testMintAndTransferDN420_14() public mintAndTransfer(address(dn420), 14) {} function testMintAndTransferPandora_15() public mintAndTransfer(address(pandora), 15) {} function testMintAndTransferDN404_15() public mintAndTransfer(address(dn404), 15) {} - function testMintAndTransferDN69_15() public mintAndTransfer(address(dn69), 15) {} + function testMintAndTransferDN420_15() public mintAndTransfer(address(dn420), 15) {} function testMintAndTransferPandora_16() public mintAndTransfer(address(pandora), 16) {} function testMintAndTransferDN404_16() public mintAndTransfer(address(dn404), 16) {} - function testMintAndTransferDN69_16() public mintAndTransfer(address(dn69), 16) {} + function testMintAndTransferDN420_16() public mintAndTransfer(address(dn420), 16) {} } diff --git a/test/DN69.t.sol b/test/DN420.t.sol similarity index 94% rename from test/DN69.t.sol rename to test/DN420.t.sol index b8699c3..8770a46 100644 --- a/test/DN69.t.sol +++ b/test/DN420.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.4; import "./utils/SoladyTest.sol"; -import {DN69, MockDN69} from "./utils/mocks/MockDN69.sol"; +import {DN420, MockDN420} from "./utils/mocks/MockDN420.sol"; import {LibSort} from "solady/utils/LibSort.sol"; import {LibPRNG} from "solady/utils/LibPRNG.sol"; @@ -150,7 +150,7 @@ contract WrongReturnDataERC1155Recipient is ERC1155TokenReceiver { contract NonERC1155Recipient {} -contract DN69Test is SoladyTest { +contract DN420Test is SoladyTest { using LibPRNG for *; event Transfer(address indexed from, address indexed to, uint256 amount); @@ -177,17 +177,17 @@ contract DN69Test is SoladyTest { uint256 internal constant _WAD = 10 ** 18; - MockDN69 dn; + MockDN420 dn; address internal constant _ALICE = address(111); address internal constant _BOB = address(222); function setUp() public { - dn = new MockDN69(); + dn = new MockDN420(); } function testFindOwnedIds() public { - dn.initializeDN69(0, address(this)); + dn.initializeDN420(0, address(this)); assertEq(dn.findOwnedIds(_ALICE, 0, 0), new uint256[](0)); assertEq(dn.findOwnedIds(_ALICE, 0, 1), new uint256[](0)); assertEq(dn.findOwnedIds(_ALICE, 0, 10), new uint256[](0)); @@ -228,7 +228,7 @@ contract DN69Test is SoladyTest { } function testERC1155Methods(uint256) public { - dn.initializeDN69(10 * _WAD, address(this)); + dn.initializeDN420(10 * _WAD, address(this)); unchecked { for (uint256 i; i < 3; ++i) { dn.transfer(_ALICE, 1 * _WAD); @@ -289,7 +289,7 @@ contract DN69Test is SoladyTest { assertEq(dn.balanceOf(_ALICE), t.aliceIds.length * _WAD); assertEq(dn.balanceOf(_BOB), t.bobIds.length * _WAD); if (_random() % 16 == 0) { - vm.expectRevert(DN69.InvalidNFTAmount.selector); + vm.expectRevert(DN420.InvalidNFTAmount.selector); IERC1155(address(dn)).safeTransferFrom(_ALICE, _BOB, t.id, _invalidAmount(), ""); } vm.expectEmit(true, true, true, true); @@ -330,11 +330,11 @@ contract DN69Test is SoladyTest { } } if (_random() % 16 == 0 && t.ids.length != 0) { - vm.expectRevert(DN69.InvalidNFTAmount.selector); + vm.expectRevert(DN420.InvalidNFTAmount.selector); IERC1155(address(dn)).safeBatchTransferFrom( _ALICE, _BOB, t.ids, _filled(t.ids.length, _invalidAmount()), "" ); - vm.expectRevert(DN69.ArrayLengthsMismatch.selector); + vm.expectRevert(DN420.ArrayLengthsMismatch.selector); IERC1155(address(dn)).safeBatchTransferFrom( _ALICE, _BOB, t.ids, _filled(_invalidLength(t.ids.length), 1), "" ); @@ -366,7 +366,7 @@ contract DN69Test is SoladyTest { _filled(t.ids.length, 1) ); if (_random() % 32 == 0) { - vm.expectRevert(DN69.ArrayLengthsMismatch.selector); + vm.expectRevert(DN420.ArrayLengthsMismatch.selector); IERC1155(address(dn)).balanceOfBatch( _filled(t.ids.length, _BOB), _filled(_invalidLength(t.ids.length), 0) ); @@ -375,7 +375,7 @@ contract DN69Test is SoladyTest { } function testERC1155MethodsSelfTransfers(uint256) public { - dn.initializeDN69(10 * _WAD, address(this)); + dn.initializeDN420(10 * _WAD, address(this)); for (uint256 i; i < 3; ++i) { dn.transfer(_ALICE, 1 * _WAD); } @@ -393,7 +393,7 @@ contract DN69Test is SoladyTest { if (_random() % 2 == 0) { t.id = t.aliceIds[_random() % t.aliceIds.length]; if (_random() % 16 == 0) { - vm.expectRevert(DN69.InvalidNFTAmount.selector); + vm.expectRevert(DN420.InvalidNFTAmount.selector); IERC1155(address(dn)).safeTransferFrom(_ALICE, _ALICE, t.id, _invalidAmount(), ""); } vm.expectEmit(true, true, true, true); @@ -418,7 +418,7 @@ contract DN69Test is SoladyTest { if (_random() % 2 == 0) { t.ids = _randomSampleWithoutReplacements(t.aliceIds); if (_random() % 16 == 0 && t.ids.length != 0) { - vm.expectRevert(DN69.InvalidNFTAmount.selector); + vm.expectRevert(DN420.InvalidNFTAmount.selector); IERC1155(address(dn)).safeBatchTransferFrom( _ALICE, _ALICE, t.ids, _filled(t.ids.length, _invalidAmount()), "" ); @@ -521,7 +521,7 @@ contract DN69Test is SoladyTest { function testMixed(uint256) public { uint256 n = _random() % 8 == 0 ? _bound(_random(), 0, 512) : _bound(_random(), 0, 16); - dn.initializeDN69(n * _WAD, address(1111)); + dn.initializeDN420(n * _WAD, address(1111)); address[] memory addresses = new address[](3); addresses[0] = address(111); @@ -619,7 +619,7 @@ contract DN69Test is SoladyTest { LibSort.uniquifySorted(t.idsCopy); if (t.idsCopy.length < t.ids.length) { vm.prank(t.from); - vm.expectRevert(DN69.TransferFromIncorrectOwner.selector); + vm.expectRevert(DN420.TransferFromIncorrectOwner.selector); dn.safeBatchTransferFromNFTs(t.from, t.to, t.ids); } else { vm.prank(t.from); @@ -700,13 +700,13 @@ contract DN69Test is SoladyTest { } function testMintToZeroReverts(uint256) public { - dn.initializeDN69(0, address(this)); - vm.expectRevert(DN69.TransferToZeroAddress.selector); + dn.initializeDN420(0, address(this)); + vm.expectRevert(DN420.TransferToZeroAddress.selector); dn.mint(address(0), _bound(_random(), _WAD, 10 * _WAD), _randomBytes()); } function testMintNext() public { - dn.initializeDN69(10 * _WAD, address(this)); + dn.initializeDN420(10 * _WAD, address(this)); dn.mintNext(_ALICE, 10 * _WAD); for (uint256 i = 11; i <= 20; ++i) { assertEq(dn.owns(_ALICE, i), true); @@ -722,7 +722,7 @@ contract DN69Test is SoladyTest { } function testMintToRevertingERC155RecipientReverts(uint256) public { - dn.initializeDN69(0, address(this)); + dn.initializeDN420(0, address(this)); address to = address(new RevertingERC1155Recipient()); vm.prank(to); dn.setSkipNFT(false); @@ -747,14 +747,14 @@ contract DN69Test is SoladyTest { } function testMintToNonERC155RecipientReverts(uint256) public { - dn.initializeDN69(0, address(this)); + dn.initializeDN420(0, address(this)); address to = address(new NonERC1155Recipient()); vm.prank(to); dn.setSkipNFT(false); if (_random() % 32 == 0) { dn.mint(to, _bound(_random(), 0, _WAD - 1), _randomBytes()); } else if (_random() % 2 == 0) { - vm.expectRevert(DN69.TransferToNonERC1155ReceiverImplementer.selector); + vm.expectRevert(DN420.TransferToNonERC1155ReceiverImplementer.selector); if (_random() % 2 == 0) { dn.mint(to, _bound(_random(), _WAD, 10 * _WAD), _randomBytes()); } else { @@ -765,14 +765,14 @@ contract DN69Test is SoladyTest { vm.prank(_ALICE); dn.setApprovalForAll(address(this), true); assertEq(dn.owns(_ALICE, 1), true); - vm.expectRevert(DN69.TransferToNonERC1155ReceiverImplementer.selector); + vm.expectRevert(DN420.TransferToNonERC1155ReceiverImplementer.selector); vm.prank(_ALICE); dn.safeTransferFromNFT(_ALICE, to, 1, _randomBytes()); } } function testSafeTransferFromToERC1155Recipient(uint256) public { - dn.initializeDN69(0, address(this)); + dn.initializeDN420(0, address(this)); ERC1155Recipient to = new ERC1155Recipient(); bytes memory transferData = _randomBytes(); @@ -805,7 +805,7 @@ contract DN69Test is SoladyTest { } function testSafeBatchTransferFromToERC1155Recipient(uint256) public { - dn.initializeDN69(0, address(this)); + dn.initializeDN420(0, address(this)); ERC1155Recipient to = new ERC1155Recipient(); bytes memory transferData = _randomBytes(); @@ -842,7 +842,7 @@ contract DN69Test is SoladyTest { } function testTransferFromToERC1155Recipient(uint256) public { - dn.initializeDN69(0, address(this)); + dn.initializeDN420(0, address(this)); ERC1155Recipient from = new ERC1155Recipient(); ERC1155Recipient to = new ERC1155Recipient(); @@ -890,22 +890,22 @@ contract DN69Test is SoladyTest { } function testTransferMixedReverts(uint256) public { - dn.initializeDN69(0, address(this)); + dn.initializeDN420(0, address(this)); address from = _randomNonZeroAddress(); uint256 amount = _bound(_random(), 1, 10) * _WAD; dn.mint(from, amount, ""); if (_random() % 4 == 0) { - vm.expectRevert(DN69.TransferToZeroAddress.selector); + vm.expectRevert(DN420.TransferToZeroAddress.selector); dn.mint(address(0), _random(), ""); - vm.expectRevert(DN69.TransferToZeroAddress.selector); + vm.expectRevert(DN420.TransferToZeroAddress.selector); dn.mintNext(address(0), _random(), ""); - vm.expectRevert(DN69.TransferToZeroAddress.selector); + vm.expectRevert(DN420.TransferToZeroAddress.selector); dn.transfer(address(0), amount); vm.prank(from); dn.approve(address(this), type(uint256).max); - vm.expectRevert(DN69.TransferToZeroAddress.selector); + vm.expectRevert(DN420.TransferToZeroAddress.selector); dn.transferFrom(from, address(0), amount); address to = _randomNonZeroAddress(); dn.transferFrom(from, to, amount); @@ -926,7 +926,7 @@ contract DN69Test is SoladyTest { vm.prank(from); dn.setApprovalForAll(by, false); } else { - vm.expectRevert(DN69.NotOwnerNorApproved.selector); + vm.expectRevert(DN420.NotOwnerNorApproved.selector); _safeTransferFromNFT(by, from, to, 1); } if (dn.owns(to, 1)) { @@ -938,7 +938,7 @@ contract DN69Test is SoladyTest { if (_random() % 4 == 0) { uint256 id = _bound(_random(), 0, 256); while (dn.owns(from, id)) id = _bound(_random(), 0, 256); - vm.expectRevert(DN69.TransferFromIncorrectOwner.selector); + vm.expectRevert(DN420.TransferFromIncorrectOwner.selector); _safeTransferFromNFT(from, from, _randomNonZeroAddress(), id); } @@ -948,7 +948,7 @@ contract DN69Test is SoladyTest { uint256[] memory ids = dn.findOwnedIds(from); if (ids.length < 2) break; ids[0] = ids[_bound(_random(), 1, ids.length - 1)]; - vm.expectRevert(DN69.TransferFromIncorrectOwner.selector); + vm.expectRevert(DN420.TransferFromIncorrectOwner.selector); dn.safeBatchTransferFromNFTs(from, from, to, ids); } @@ -957,7 +957,7 @@ contract DN69Test is SoladyTest { uint256[] memory ids = dn.findOwnedIds(from); ids[0] = _bound(_random(), 0, 256); while (dn.owns(from, ids[0])) ids[0] = _bound(_random(), 0, 256); - vm.expectRevert(DN69.TransferFromIncorrectOwner.selector); + vm.expectRevert(DN420.TransferFromIncorrectOwner.selector); dn.safeBatchTransferFromNFTs(from, from, to, ids); dn.safeBatchTransferFromNFTs(from, from, to, dn.findOwnedIds(from)); dn.safeBatchTransferFromNFTs(to, to, from, dn.findOwnedIds(to)); @@ -968,7 +968,7 @@ contract DN69Test is SoladyTest { uint256 oriLength = ids.length; ids = LibSort.union(ids, _randomSampleWithoutReplacements(ids)); if (ids.length > oriLength) { - vm.expectRevert(DN69.InsufficientBalance.selector); + vm.expectRevert(DN420.InsufficientBalance.selector); dn.safeBatchTransferFromNFTs(from, from, to, ids); } else { dn.safeBatchTransferFromNFTs(from, from, to, ids); diff --git a/test/DN69OnlyERC20.t.sol b/test/DN420OnlyERC20.t.sol similarity index 93% rename from test/DN69OnlyERC20.t.sol rename to test/DN420OnlyERC20.t.sol index 73d044f..a128677 100644 --- a/test/DN69OnlyERC20.t.sol +++ b/test/DN420OnlyERC20.t.sol @@ -4,10 +4,10 @@ pragma solidity ^0.8.4; import "./utils/SoladyTest.sol"; import "./utils/InvariantTest.sol"; -import {DN69, MockDN69OnlyERC20} from "./utils/mocks/MockDN69OnlyERC20.sol"; +import {DN420, MockDN420OnlyERC20} from "./utils/mocks/MockDN420OnlyERC20.sol"; -contract DN69OnlyERC20Test is SoladyTest { - MockDN69OnlyERC20 token; +contract DN420OnlyERC20Test is SoladyTest { + MockDN420OnlyERC20 token; uint256 private constant _WAD = 10 ** 18; @@ -20,7 +20,7 @@ contract DN69OnlyERC20Test is SoladyTest { event Approval(address indexed owner, address indexed spender, uint256 amount); function setUp() public { - token = new MockDN69OnlyERC20(); + token = new MockDN420OnlyERC20(); } function testMaxSupplyTrick(uint256 amount) public { @@ -113,13 +113,13 @@ contract DN69OnlyERC20Test is SoladyTest { function testMintOverMaxLimitReverts() public { token.mint(address(this), _MAX_SUPPLY); - vm.expectRevert(DN69.TotalSupplyOverflow.selector); + vm.expectRevert(DN420.TotalSupplyOverflow.selector); token.mint(address(this), 1); } function testTransferInsufficientBalanceReverts() public { token.mint(address(this), 0.9e18); - vm.expectRevert(DN69.InsufficientBalance.selector); + vm.expectRevert(DN420.InsufficientBalance.selector); token.transfer(address(0xBEEF), 1e18); } @@ -131,7 +131,7 @@ contract DN69OnlyERC20Test is SoladyTest { vm.prank(from); token.approve(address(this), 0.9e18); - vm.expectRevert(DN69.InsufficientAllowance.selector); + vm.expectRevert(DN420.InsufficientAllowance.selector); token.transferFrom(from, address(0xBEEF), 1e18); } @@ -143,7 +143,7 @@ contract DN69OnlyERC20Test is SoladyTest { vm.prank(from); token.approve(address(this), 1e18); - vm.expectRevert(DN69.InsufficientBalance.selector); + vm.expectRevert(DN420.InsufficientBalance.selector); token.transferFrom(from, address(0xBEEF), 1e18); } @@ -254,7 +254,7 @@ contract DN69OnlyERC20Test is SoladyTest { burnAmount = _bound(burnAmount, mintAmount + 1, _MAX_SUPPLY); token.mint(to, mintAmount); - vm.expectRevert(DN69.InsufficientBalance.selector); + vm.expectRevert(DN420.InsufficientBalance.selector); token.burn(to, burnAmount); } @@ -272,7 +272,7 @@ contract DN69OnlyERC20Test is SoladyTest { sendAmount = _bound(sendAmount, mintAmount + 1, _MAX_SUPPLY); token.mint(address(this), mintAmount); - vm.expectRevert(DN69.InsufficientBalance.selector); + vm.expectRevert(DN420.InsufficientBalance.selector); token.transfer(to, sendAmount); } @@ -296,7 +296,7 @@ contract DN69OnlyERC20Test is SoladyTest { vm.prank(from); token.approve(address(this), approval); - vm.expectRevert(DN69.InsufficientAllowance.selector); + vm.expectRevert(DN420.InsufficientAllowance.selector); token.transferFrom(from, to, amount); } @@ -319,7 +319,7 @@ contract DN69OnlyERC20Test is SoladyTest { vm.prank(from); token.approve(address(this), sendAmount); - vm.expectRevert(DN69.InsufficientBalance.selector); + vm.expectRevert(DN420.InsufficientBalance.selector); token.transferFrom(from, to, sendAmount); } } diff --git a/test/utils/mocks/MockDN69.sol b/test/utils/mocks/MockDN420.sol similarity index 88% rename from test/utils/mocks/MockDN69.sol rename to test/utils/mocks/MockDN420.sol index bc9b651..0234aaf 100644 --- a/test/utils/mocks/MockDN69.sol +++ b/test/utils/mocks/MockDN420.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; -import "../../../src/DN69.sol"; +import "../../../src/DN420.sol"; import "./MockBrutalizer.sol"; -contract MockDN69 is DN69, MockBrutalizer { +contract MockDN420 is DN420, MockBrutalizer { string private _name; string private _symbol; @@ -13,8 +13,8 @@ contract MockDN69 is DN69, MockBrutalizer { bool givePermit2DefaultInfiniteAllowance; - function initializeDN69(uint256 initialTokenSupply, address initialSupplyOwner) public { - _initializeDN69(initialTokenSupply, initialSupplyOwner); + function initializeDN420(uint256 initialTokenSupply, address initialSupplyOwner) public { + _initializeDN420(initialTokenSupply, initialSupplyOwner); } function setNameAndSymbol(string memory name_, string memory symbol_) public { @@ -60,7 +60,7 @@ contract MockDN69 is DN69, MockBrutalizer { } function getAddressDataInitialized(address target) public view returns (bool) { - return _getDN69Storage().addressData[target].flags & _ADDRESS_DATA_INITIALIZED_FLAG != 0; + return _getDN420Storage().addressData[target].flags & _ADDRESS_DATA_INITIALIZED_FLAG != 0; } function setAux(address target, uint88 value) public { @@ -72,7 +72,7 @@ contract MockDN69 is DN69, MockBrutalizer { } function getNextTokenId() public view returns (uint32) { - return _getDN69Storage().nextTokenId; + return _getDN420Storage().nextTokenId; } function findOwnedIds(address owner, uint256 begin, uint256 end) @@ -88,11 +88,11 @@ contract MockDN69 is DN69, MockBrutalizer { } function ownedCount(address owner) public view returns (uint256) { - return _getDN69Storage().addressData[owner].ownedCount; + return _getDN420Storage().addressData[owner].ownedCount; } function maxOwnedTokenId(address owner, uint256 upTo) public view returns (uint256 result) { - result = _findLastSet(_getDN69Storage().owned[owner], upTo); + result = _findLastSet(_getDN420Storage().owned[owner], upTo); } function exists(uint256 id) public view returns (bool) { @@ -158,7 +158,7 @@ contract MockDN69 is DN69, MockBrutalizer { override { _brutalizeMemory(); - DN69._transfer(_brutalized(from), _brutalized(to), amount, data); + DN420._transfer(_brutalized(from), _brutalized(to), amount, data); _checkMemory(data); } @@ -170,7 +170,7 @@ contract MockDN69 is DN69, MockBrutalizer { bytes memory data ) internal virtual override { _brutalizeMemory(); - DN69._safeBatchTransferNFTs(_brutalized(by), _brutalized(from), _brutalized(to), ids, data); + DN420._safeBatchTransferNFTs(_brutalized(by), _brutalized(from), _brutalized(to), ids, data); _checkMemory(data); } diff --git a/test/utils/mocks/MockDN69OnlyERC20.sol b/test/utils/mocks/MockDN420OnlyERC20.sol similarity index 83% rename from test/utils/mocks/MockDN69OnlyERC20.sol rename to test/utils/mocks/MockDN420OnlyERC20.sol index a327695..e919fb6 100644 --- a/test/utils/mocks/MockDN69OnlyERC20.sol +++ b/test/utils/mocks/MockDN420OnlyERC20.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; -import "../../../src/DN69.sol"; +import "../../../src/DN420.sol"; -contract MockDN69OnlyERC20 is DN69 { +contract MockDN420OnlyERC20 is DN420 { constructor() { - _initializeDN69(0, address(this)); + _initializeDN420(0, address(this)); } function name() public view virtual override returns (string memory) { @@ -21,7 +21,7 @@ contract MockDN69OnlyERC20 is DN69 { } function _addressData(address a) internal virtual override returns (AddressData storage d) { - d = DN69._addressData(a); + d = DN420._addressData(a); d.flags |= _ADDRESS_DATA_SKIP_NFT_FLAG; } diff --git a/test/utils/mocks/MockDN69Slim.sol b/test/utils/mocks/MockDN420Slim.sol similarity index 69% rename from test/utils/mocks/MockDN69Slim.sol rename to test/utils/mocks/MockDN420Slim.sol index 9d4a2ec..847ef46 100644 --- a/test/utils/mocks/MockDN69Slim.sol +++ b/test/utils/mocks/MockDN420Slim.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; -import "../../../src/DN69.sol"; +import "../../../src/DN420.sol"; -contract MockDN69Slim is DN69 { +contract MockDN420Slim is DN420 { function name() public view virtual override returns (string memory) { return "name"; } @@ -16,8 +16,8 @@ contract MockDN69Slim is DN69 { return ""; } - function initializeDN69(uint256 initialTokenSupply, address initialSupplyOwner) public { - _initializeDN69(initialTokenSupply, initialSupplyOwner); + function initializeDN420(uint256 initialTokenSupply, address initialSupplyOwner) public { + _initializeDN420(initialTokenSupply, initialSupplyOwner); } function _useDirectTransfersIfPossible() internal view virtual override returns (bool) {