Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions src/Patchwork721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
Expand Down
17 changes: 9 additions & 8 deletions src/PatchworkProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Fees.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/Patchwork1155Patch.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/PatchworkAccountPatch.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/PatchworkFragmentMulti.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/PatchworkFragmentSingle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/PatchworkNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/PatchworkNFTReferences.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/PatchworkPatch.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/PatchworkProtocol.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/TestDynamicArrayLiteRefNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions test/nfts/Test1155PatchNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/nfts/TestAccountPatchNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}

Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestDynamicArrayLiteRefNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestFragmentLiteRefNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestFragmentSingleNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestMultiFragmentNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestPatchFragmentNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestPatchLiteRefNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestPatchNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/nfts/TestPatchworkNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down