diff --git a/script/Counter.s.sol b/script/Counter.s.sol deleted file mode 100644 index cdc1fe9..0000000 --- a/script/Counter.s.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Script, console} from "forge-std/Script.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterScript is Script { - Counter public counter; - - function setUp() public {} - - function run() public { - vm.startBroadcast(); - - counter = new Counter(); - - vm.stopBroadcast(); - } -} diff --git a/src/01-dont-init-def-val/IdRegDontInitDefVal.sol b/src/01-dont-init-def-val/IdRegDontInitDefVal.sol new file mode 100644 index 0000000..38024b4 --- /dev/null +++ b/src/01-dont-init-def-val/IdRegDontInitDefVal.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.28; + +import {IdRegUnop} from "../IdRegUnop.sol"; + +contract IdRegDontInitDefVal is IdRegUnop { + function generateIds(uint256 numIds, address[] memory owners) external override { + if(numIds != owners.length) + revert NumIdsOwnersLengthMismatch(numIds, owners.length); + + // @audit don't initialize loop variable to zero as solidity + // automatically initializes variable to their default value + // note: test shows no gas savings but does eliminate useless code + for(uint256 i; i address owner) public idToOwner; + + // creates `numIds` new valid ids in ascending + // order from previously created ids + // @audit external and public result in same gas cost, tested + // manually as this would break compilation with existing structure + function generateIds(uint256 numIds, address[] memory owners) external virtual { + if(numIds != owners.length) + revert NumIdsOwnersLengthMismatch(numIds, owners.length); + + for(uint256 i=0; i