diff --git a/lib/forge-std b/lib/forge-std index 2b58ecb..36c303b 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 2b58ecbcf3dfde7a75959dc7b4eb3d0670278de6 +Subproject commit 36c303b7ffdd842d06b1ec2744c9b9b5fb3083f3 diff --git a/src/Patchwork721.sol b/src/Patchwork721.sol index d718e32..4423826 100644 --- a/src/Patchwork721.sol +++ b/src/Patchwork721.sol @@ -42,13 +42,15 @@ abstract contract Patchwork721 is ERC721, IPatchwork721, IERC4906, Ownable { @param name_ The ERC-721 name. @param symbol_ The ERC-721 symbol. @param manager_ The address that will be set as the manager (PatchworkProtocol). + @param owner_ The address that will be set as the owner */ constructor( string memory scopeName_, string memory name_, string memory symbol_, - address manager_ - ) ERC721(name_, symbol_) Ownable(msg.sender) { + address manager_, + address owner_ + ) ERC721(name_, symbol_) Ownable(owner_) { _scopeName = scopeName_; _manager = manager_; } diff --git a/src/PatchworkProtocol.sol b/src/PatchworkProtocol.sol index f0f8c03..d9eec53 100644 --- a/src/PatchworkProtocol.sol +++ b/src/PatchworkProtocol.sol @@ -76,13 +76,14 @@ contract PatchworkProtocol is IPatchworkProtocol, Ownable, ReentrancyGuard { uint256 public constant FEE_CHANGE_TIMELOCK = 1209600; /// The denominator for fee basis points - uint256 private constant FEE_BASIS_DENOM = 10000; + uint256 private constant _FEE_BASIS_DENOM = 10000; /// The maximum basis points patchwork can ever be configured to - uint256 private constant PROTOCOL_FEE_CEILING = 3000; + uint256 private constant _PROTOCOL_FEE_CEILING = 3000; /// Constructor - constructor() Ownable(msg.sender) ReentrancyGuard() {} + /// @param owner_ The address of the initial owner + constructor(address owner_) Ownable(owner_) ReentrancyGuard() {} /** @dev See {IPatchworkProtocol-claimScope} @@ -363,7 +364,7 @@ contract PatchworkProtocol is IPatchworkProtocol, Ownable, ReentrancyGuard { } else { mintBp = _protocolFeeConfig.mintBp; } - uint256 protocolFee = msg.value * mintBp / FEE_BASIS_DENOM; + uint256 protocolFee = msg.value * mintBp / _FEE_BASIS_DENOM; _protocolBalance += protocolFee; scope.balance += msg.value - protocolFee; } @@ -373,7 +374,7 @@ contract PatchworkProtocol is IPatchworkProtocol, Ownable, ReentrancyGuard { @dev See {IPatchworkProtocol-proposeProtocolFeeConfig} */ function proposeProtocolFeeConfig(FeeConfig memory config) public onlyProtoOwnerBanker { - if (config.assignBp > PROTOCOL_FEE_CEILING || config.mintBp > PROTOCOL_FEE_CEILING || config.patchBp > PROTOCOL_FEE_CEILING) { + if (config.assignBp > _PROTOCOL_FEE_CEILING || config.mintBp > _PROTOCOL_FEE_CEILING || config.patchBp > _PROTOCOL_FEE_CEILING) { revert InvalidFeeValue(); } _proposedFeeConfigs[""] = ProposedFeeConfig(config, block.timestamp, true); @@ -400,7 +401,7 @@ contract PatchworkProtocol is IPatchworkProtocol, Ownable, ReentrancyGuard { @dev See {IPatchworkProtocol-proposeScopeFeeOverride} */ function proposeScopeFeeOverride(string memory scopeName, FeeConfigOverride memory config) public onlyProtoOwnerBanker { - if (config.assignBp > PROTOCOL_FEE_CEILING || config.mintBp > PROTOCOL_FEE_CEILING || config.patchBp > PROTOCOL_FEE_CEILING) { + if (config.assignBp > _PROTOCOL_FEE_CEILING || config.mintBp > _PROTOCOL_FEE_CEILING || config.patchBp > _PROTOCOL_FEE_CEILING) { revert InvalidFeeValue(); } _proposedFeeConfigs[scopeName] = ProposedFeeConfig( @@ -631,7 +632,7 @@ contract PatchworkProtocol is IPatchworkProtocol, Ownable, ReentrancyGuard { } else { patchBp = _protocolFeeConfig.patchBp; } - uint256 protocolFee = msg.value * patchBp / FEE_BASIS_DENOM; + uint256 protocolFee = msg.value * patchBp / _FEE_BASIS_DENOM; _protocolBalance += protocolFee; scope.balance += msg.value - protocolFee; } @@ -651,7 +652,7 @@ contract PatchworkProtocol is IPatchworkProtocol, Ownable, ReentrancyGuard { } else { assignBp = _protocolFeeConfig.assignBp; } - uint256 protocolFee = msg.value * assignBp / FEE_BASIS_DENOM; + uint256 protocolFee = msg.value * assignBp / _FEE_BASIS_DENOM; _protocolBalance += protocolFee; scope.balance += msg.value - protocolFee; } diff --git a/test/Fees.t.sol b/test/Fees.t.sol index 6a3ac07..f892e16 100644 --- a/test/Fees.t.sol +++ b/test/Fees.t.sol @@ -33,7 +33,7 @@ contract FeesTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); vm.prank(_patchworkOwner); _prot.proposeProtocolFeeConfig(IPatchworkProtocol.FeeConfig(1000, 1000, 1000)); // 10%, 10%, 10% skip(20000000); diff --git a/test/Patchwork1155Patch.t.sol b/test/Patchwork1155Patch.t.sol index d84c278..dedce46 100644 --- a/test/Patchwork1155Patch.t.sol +++ b/test/Patchwork1155Patch.t.sol @@ -27,7 +27,7 @@ contract Patchwork1155PatchTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); vm.startPrank(_scopeOwner); _scopeName = "testscope"; diff --git a/test/PatchworkAccountPatch.t.sol b/test/PatchworkAccountPatch.t.sol index 0caad5d..e68dbed 100644 --- a/test/PatchworkAccountPatch.t.sol +++ b/test/PatchworkAccountPatch.t.sol @@ -26,7 +26,7 @@ contract PatchworkAccountPatchTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); vm.startPrank(_scopeOwner); _scopeName = "testscope"; diff --git a/test/PatchworkFragmentMulti.t.sol b/test/PatchworkFragmentMulti.t.sol index 761f51b..7b2d075 100644 --- a/test/PatchworkFragmentMulti.t.sol +++ b/test/PatchworkFragmentMulti.t.sol @@ -29,7 +29,7 @@ contract PatchworkFragmentMultiTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); _scopeName = "testscope"; vm.startPrank(_scopeOwner); _prot.claimScope(_scopeName); diff --git a/test/PatchworkFragmentSingle.t.sol b/test/PatchworkFragmentSingle.t.sol index 799d524..221e9b9 100644 --- a/test/PatchworkFragmentSingle.t.sol +++ b/test/PatchworkFragmentSingle.t.sol @@ -27,7 +27,7 @@ contract PatchworkFragmentSingleTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); _scopeName = "testscope"; vm.startPrank(_scopeOwner); _prot.claimScope(_scopeName); diff --git a/test/PatchworkNFT.t.sol b/test/PatchworkNFT.t.sol index fce9d28..dddd2bd 100644 --- a/test/PatchworkNFT.t.sol +++ b/test/PatchworkNFT.t.sol @@ -26,7 +26,7 @@ contract PatchworkNFTTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); _scopeName = "testscope"; vm.startPrank(_scopeOwner); _prot.claimScope(_scopeName); diff --git a/test/PatchworkNFTReferences.t.sol b/test/PatchworkNFTReferences.t.sol index 1d6b2c3..1dd103e 100644 --- a/test/PatchworkNFTReferences.t.sol +++ b/test/PatchworkNFTReferences.t.sol @@ -32,7 +32,7 @@ contract PatchworkNFTCombinedTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); _scopeName = "testscope"; vm.startPrank(_scopeOwner); _prot.claimScope(_scopeName); diff --git a/test/PatchworkPatch.t.sol b/test/PatchworkPatch.t.sol index 635f4dd..8f33735 100644 --- a/test/PatchworkPatch.t.sol +++ b/test/PatchworkPatch.t.sol @@ -29,7 +29,7 @@ contract PatchworkPatchTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); _scopeName = "testscope"; vm.startPrank(_scopeOwner); _prot.claimScope(_scopeName); diff --git a/test/PatchworkProtocol.t.sol b/test/PatchworkProtocol.t.sol index eba958e..c18f2d5 100644 --- a/test/PatchworkProtocol.t.sol +++ b/test/PatchworkProtocol.t.sol @@ -37,7 +37,7 @@ contract PatchworkProtocolTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); _scopeName = "testscope"; vm.prank(_userAddress); diff --git a/test/TestDynamicArrayLiteRefNFT.t.sol b/test/TestDynamicArrayLiteRefNFT.t.sol index 6a6ce22..a7a2db5 100644 --- a/test/TestDynamicArrayLiteRefNFT.t.sol +++ b/test/TestDynamicArrayLiteRefNFT.t.sol @@ -26,7 +26,7 @@ contract PatchworkAccountPatchTest is Test { _scopeOwner = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5; vm.prank(_patchworkOwner); - _prot = new PatchworkProtocol(); + _prot = new PatchworkProtocol(_patchworkOwner); vm.startPrank(_scopeOwner); _scopeName = "testscope"; diff --git a/test/nfts/Test1155PatchNFT.sol b/test/nfts/Test1155PatchNFT.sol index 228d10b..5350a70 100644 --- a/test/nfts/Test1155PatchNFT.sol +++ b/test/nfts/Test1155PatchNFT.sol @@ -11,7 +11,7 @@ contract Test1155PatchNFT is Patchwork1155Patch { uint256 thing; } - constructor(address manager_) Patchwork721("testscope", "Test1155PatchNFT", "TPLR", manager_) { + constructor(address manager_) Patchwork721("testscope", "Test1155PatchNFT", "TPLR", manager_, msg.sender) { } function schemaURI() pure external returns (string memory) { @@ -55,7 +55,7 @@ contract TestReversible1155PatchNFT is PatchworkReversible1155Patch { uint256 thing; } - constructor(address manager_) Patchwork721("testscope", "Test1155PatchNFT", "TPLR", manager_) { + constructor(address manager_) Patchwork721("testscope", "Test1155PatchNFT", "TPLR", manager_, msg.sender) { } function schemaURI() pure external returns (string memory) { diff --git a/test/nfts/TestAccountPatchNFT.sol b/test/nfts/TestAccountPatchNFT.sol index 6e8ffd1..6200bba 100644 --- a/test/nfts/TestAccountPatchNFT.sol +++ b/test/nfts/TestAccountPatchNFT.sol @@ -12,7 +12,7 @@ contract TestAccountPatchNFT is PatchworkReversibleAccountPatch { uint256 thing; } - constructor(address manager_, bool sameOwnerModel_) Patchwork721("testscope", "TestAccountPatchNFT", "TPLR", manager_) { + constructor(address manager_, bool sameOwnerModel_) Patchwork721("testscope", "TestAccountPatchNFT", "TPLR", manager_, msg.sender) { _sameOwnerModel = sameOwnerModel_; } @@ -68,7 +68,7 @@ contract TestAccountPatchNFT is PatchworkReversibleAccountPatch { super.safeTransferFrom(from, to, tokenId, data); } - function _checkTransfer(address from, address to, uint256 tokenId) internal { + function _checkTransfer(address from, address to, uint256 tokenId) internal view { if (_sameOwnerModel) { // allow burn only if (from == address(0)) { diff --git a/test/nfts/TestDynamicArrayLiteRefNFT.sol b/test/nfts/TestDynamicArrayLiteRefNFT.sol index 20d1612..4177c00 100644 --- a/test/nfts/TestDynamicArrayLiteRefNFT.sol +++ b/test/nfts/TestDynamicArrayLiteRefNFT.sol @@ -35,7 +35,7 @@ contract TestDynamicArrayLiteRefNFT is Patchwork721, PatchworkLiteRef, IPatchwor mapping(uint256 => DynamicLiteRefs) internal _dynamicLiterefStorage; // tokenId => indexed slots - constructor(address manager_) Patchwork721("testscope", "TestPatchLiteRef", "TPLR", manager_) PatchworkLiteRef() { + constructor(address manager_) Patchwork721("testscope", "TestPatchLiteRef", "TPLR", manager_, msg.sender) PatchworkLiteRef() { } // ERC-165 diff --git a/test/nfts/TestFragmentLiteRefNFT.sol b/test/nfts/TestFragmentLiteRefNFT.sol index 32a6056..877fe8c 100644 --- a/test/nfts/TestFragmentLiteRefNFT.sol +++ b/test/nfts/TestFragmentLiteRefNFT.sol @@ -36,7 +36,7 @@ contract TestFragmentLiteRefNFT is PatchworkFragmentSingle, PatchworkLiteRef, IP bool _getAssignedToOverrideSet; address _getAssignedToOverride; - constructor (address _manager) Patchwork721("testscope", "TestFragmentLiteRef", "TFLR", _manager) { + constructor (address _manager) Patchwork721("testscope", "TestFragmentLiteRef", "TFLR", _manager, msg.sender) { } // ERC-165 diff --git a/test/nfts/TestFragmentSingleNFT.sol b/test/nfts/TestFragmentSingleNFT.sol index 810e5f8..9c7440d 100644 --- a/test/nfts/TestFragmentSingleNFT.sol +++ b/test/nfts/TestFragmentSingleNFT.sol @@ -26,7 +26,7 @@ contract TestFragmentSingleNFT is PatchworkFragmentSingle { uint256 _nextTokenId; - constructor(address manager_) Patchwork721("testscope", "TestPatchFragment", "TPLR", manager_) PatchworkFragmentSingle() { + constructor(address manager_) Patchwork721("testscope", "TestPatchFragment", "TPLR", manager_, msg.sender) PatchworkFragmentSingle() { } function schemaURI() pure external override returns (string memory) { diff --git a/test/nfts/TestMultiFragmentNFT.sol b/test/nfts/TestMultiFragmentNFT.sol index 5c5e212..5c126eb 100644 --- a/test/nfts/TestMultiFragmentNFT.sol +++ b/test/nfts/TestMultiFragmentNFT.sol @@ -12,7 +12,7 @@ struct TestMultiFragmentNFTMetadata { contract TestMultiFragmentNFT is PatchworkFragmentMulti, IPatchworkMintable { uint256 _nextTokenId; - constructor (address _manager) Patchwork721("testscope", "TestMultiFragmentNFT", "TFLR", _manager) { + constructor (address _manager) Patchwork721("testscope", "TestMultiFragmentNFT", "TFLR", _manager, msg.sender) { } function supportsInterface(bytes4 interfaceID) public view virtual override returns (bool) { diff --git a/test/nfts/TestPatchFragmentNFT.sol b/test/nfts/TestPatchFragmentNFT.sol index 06d53f8..6bfa371 100644 --- a/test/nfts/TestPatchFragmentNFT.sol +++ b/test/nfts/TestPatchFragmentNFT.sol @@ -26,7 +26,7 @@ contract TestPatchFragmentNFT is PatchworkReversiblePatch, PatchworkFragmentSing uint256 _nextTokenId; - constructor(address manager_) Patchwork721("testscope", "TestPatchFragment", "TPLR", manager_) PatchworkFragmentSingle() { + constructor(address manager_) Patchwork721("testscope", "TestPatchFragment", "TPLR", manager_, msg.sender) PatchworkFragmentSingle() { } // ERC-165 diff --git a/test/nfts/TestPatchLiteRefNFT.sol b/test/nfts/TestPatchLiteRefNFT.sol index 50e2395..3fcb8b2 100644 --- a/test/nfts/TestPatchLiteRefNFT.sol +++ b/test/nfts/TestPatchLiteRefNFT.sol @@ -27,7 +27,7 @@ contract TestPatchLiteRefNFT is PatchworkPatch, PatchworkLiteRef { uint256 _nextTokenId; - constructor(address manager_) Patchwork721("testscope", "TestPatchLiteRef", "TPLR", manager_) PatchworkLiteRef() { + constructor(address manager_) Patchwork721("testscope", "TestPatchLiteRef", "TPLR", manager_, msg.sender) PatchworkLiteRef() { } // ERC-165 diff --git a/test/nfts/TestPatchNFT.sol b/test/nfts/TestPatchNFT.sol index 902120c..aa83085 100644 --- a/test/nfts/TestPatchNFT.sol +++ b/test/nfts/TestPatchNFT.sol @@ -25,7 +25,7 @@ contract TestPatchNFT is PatchworkPatch { uint256 _nextTokenId; - constructor(address manager_) Patchwork721("testscope", "TestPatchLiteRef", "TPLR", manager_) { + constructor(address manager_) Patchwork721("testscope", "TestPatchLiteRef", "TPLR", manager_, msg.sender) { } function schemaURI() pure external override returns (string memory) { diff --git a/test/nfts/TestPatchworkNFT.sol b/test/nfts/TestPatchworkNFT.sol index a426ff7..8584023 100644 --- a/test/nfts/TestPatchworkNFT.sol +++ b/test/nfts/TestPatchworkNFT.sol @@ -12,7 +12,7 @@ contract TestPatchworkNFT is Patchwork721, IPatchworkMintable { uint256 thing; } - constructor(address manager_) Patchwork721("testscope", "TestPatchworkNFT", "TPLR", manager_) { + constructor(address manager_) Patchwork721("testscope", "TestPatchworkNFT", "TPLR", manager_, msg.sender) { } function supportsInterface(bytes4 interfaceID) public view virtual override returns (bool) {