Skip to content

Commit faafeb6

Browse files
authored
v2 (#47)
* Emit Register event (#23) * whitlisting enabled by default (#22) * Add schema update event (#24) * Added getters for registered fragment data (#27) * Fixed literef collisions in scope (#25) * Two step transfer (#26) * Two step transfer system * Added events * Patch an address (#28) * WIP * Refactor - split into own files * wip * wip * wip * wip, still need some custom errors and coverage * Most coverage in * Still needs custom errors * Custom errors * Rename param on storePatch * Refactor - Split all interfaces and base implementations (#30) * phase 1 - IPatchworkProtocol * Prot on interface entirely now, base contracts updated * More splitting refactorings * All base implementations split * Refactor - split tests (#31) * Fixing linter errors before splitting to save lots of time * Split off PatchworkNFT specific tests * Split tests * Moved interface tests to specific test contracts and expanded on ERC compliance * Unindexed scope name (#34) * Relation types (#32) * WIP renaming current fragment to single * Begin splitting single/multi assignable logic * Rename unassignNFT to unassignSingleNFT * Changing signatures to work WIP * more sigs * multi data structure starting * Multi WIP * First multi contract * basic multi working * recover gas on unassign * Made unique assignment checking global * Allow cross user assignments for multi * Multi assign and unassign permissions and test coverage * comments * Assignment count and paginated getter * Failing test for cross scope case - needs some additions to enable * Target scope multi permissions and cross scope support * Added by field so a multi assignable fragment can whitelist certain actors for specific actions * small linter fix * Assign permission principles * Refactoring to common logic for unassign * coverage * coverage * coverage * Coverage complete * Made scope change events use plain string instead of index (#33) (#35) * Allow patches to be fragments (#36) * Initial changes to support weak refs * Fragments can be patches now * Made scope change events use plain string instead of index (#33) (#38) * Moved test NFTs and fixed linter with proto test (#39) * Explicit patch ownership (#37) * Allow any ownership of a patch * Coverage * 1155 Patch (#40) * 1155 Patch WIP * rename to account * Finalizing a few 1155 things * coverage * Dynamic arrays (#41) * Changed metadata type for array length * WIP * Dynamic array basic operations in * More dynamic array work * Batch add reference implementation * mostly working * Oops, fixed copy paste * let's not bother with that right now * Multi ref pools (#42) * Basic refactoring and API changes done to enable multi ref pools * coverage * hotfix v1.1 * Reverse lookups (#43) * Implementation for all * test coverage * Renamed incorrectly named liteRefs (#44) * Payable mint support (#45) * Make unique patches global * first draft * converting test nfts to mintables * More mintable conversions * test mintables updated * Some progress * Lots of interface tweaks, mint/fee events * Refactored IPatchworkScoped interface * Non reentrancy * Coverage * proxyable mint functions * Mass renaming and standardizing (#46) * first big renaming * Renamings * More renaming * smaller renaming * More renaming * Added all slots metadata store/load to base 721 * More renaming * V2 test coverage (#48) * coverage * coverage * coverage * Protocol with full coverage again * coverage * Coverage * some ascii fun (#49) * natspec completion (#50) * Patchwork721 is ownable (#51) * small bugfix in test (#52) * small bugfix in test * Set foundry to use latest solc version * Protocol fee overrides (#53) * Patch burns (#54) * callbacks for burning patches * Patch burning working * Target scope unassign (#55) * Fixed out of bounds array access (#56) * Fixed out of bounds array access * keep the comment * ERC165 optimizations (#57) * ERC165 optimizations - tests not fixed yet * fixing... * fixed * spacing * all calls to getScopeName are memoized (#58) * Gas tests to prove/disprove some potential optimizations (#59) * Revert "ERC165 optimizations (#57)" (#60) This reverts commit c4880f6. * private modifiers (#61) * Fee change timelock (#62) * wip * events * Timelock working for protocol fees * May not claim empty scope * Timelock fee changes applied to fee overrides * update #1 * Feedback changes * Handle invalid fee configurations (#63) * Add assignment check to unassign (#64) * Added fee change events (#65) * Refactored into reversible account patch subclass (#66) * Validate redact/unredact (#68) * Bugfix in patch burn (#69) * Clean up getScopeName interface and test impls (#70) * use mustBeManager instead of adhoc (#71) * proto fee ceiling (#67) * Struct cleanup (#72) * Clean up assignment struct * Making structs more consistent in the patch implementations * More reversibles (#73) * Base patch reversible * Resolving all reversibles * added some indices to events (#74) * Some natspec improvements (#75) * Several improvement requests (#76) * Moved interfaces and hopefully fixed payable critical error * Refactoring patch targets and payables * Seeing if this helps Zeppelin Defender calm down * All patches payable so they can proxy from a public call * Standardizing patch targets across types * More standardizing * Patch field renaming * Make manager immutable * small fix (#79) * Open zeppelin 5 (#80) * OZ5 * forge install: openzeppelin-foundry-upgrades * forge install: openzeppelin-contracts-upgradeable v5.0.1 * Updates for OpenZeppelin 5 * small refactor * Create2 support (#81) * Update to latest forge-std * Moved implicit owner out to support create2 on PP and 721 * Event fees (#82) * Added mint fees to mint events * all fees in and doAssign restructuring' * Refactored doAssign for readability and object bytesize optimization (#83) * Fixed recursive burn bug (#85) * Assigner delegate contract (#86) * First stab at delegate contract * Clean up submodules * Update solidity spec to 0.8.23 * Refactor and natspec * Timelock delegate change code in * Delegate upgrade tests * small fixup * Deploy and Verify using create2 (#87) * deploy stub * deploy + verify * verify wip * enoceded constructor args * constructor args * manual verificatin steps * Small trial and error updates * Working completely with new delegate * removed file that shouldn't have been there * Fixed fee handling issue with batch assign (#89)
1 parent c56e802 commit faafeb6

File tree

68 files changed

+7663
-2423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+7663
-2423
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ out/
66
!/broadcast
77
/broadcast/*/31337/
88
/broadcast/**/dry-run/
9+
**/broadcast/**
10+
911

1012
# Docs
1113
docs/

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[submodule "lib/openzeppelin-contracts"]
2-
branch = v4.8.2
2+
branch = v5.0.1
33
path = lib/openzeppelin-contracts
44
url = https://github.com/openzeppelin/openzeppelin-contracts
55
[submodule "lib/forge-std"]
66
path = lib/forge-std
77
url = https://github.com/foundry-rs/forge-std
8-
branch = v1.5.2
8+
branch = v1.7.6

foundry.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ out = 'out'
55
test = 'test'
66
cache_path = 'cache'
77
script = 'script'
8+
solc_version = '0.8.23'
89

910
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

lib/openzeppelin-contracts

management/.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# .env file
2+
PRIVATE_KEY=your_private_key_here
3+
BASE_RPC_URL=your_base_network_rpc_url
4+
BASE_PATCHWORK_OWNER=base_patchwork_owner_address
5+
BASE_PATCHWORK_ADDRESS=base_patchwork_address
6+
BASE_CHAIN_ID=8453
7+
SEPOLIA_RPC_URL=your_sepolia_network_rpc_url
8+
SEPOLIA_PATCHWORK_OWNER=sepolia_patchwork_owner_address
9+
SEPOLIA_CHAIN_ID=11155111
10+
SEPOLIA_PATCHWORK_ADDRESS=0x635BDfB811Ef377a759231Ac3A2746814A93a7B8
11+

management/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Create a .env file in the format of .env.example
2+
3+
To deoploy on sepolia:
4+
./deploy.sh sepolia
5+
6+
To deploy on base:
7+
./deploy.sh base
8+
9+
Include --broadcast when you are ready to deploy
10+
11+
To verify on ether scan:
12+
13+
./verify.sh base
14+
15+
or
16+
17+
./verify.sh sepolia
18+
19+
manual verification:
20+
21+
forge verify-contract 0x635BDfB811Ef377a759231Ac3A2746814A93a7B8 src/PatchworkProtocol.sol:PatchworkProtocol --optimizer-runs 200 --constructor-args "0x0000000000000000000000007239aec2fa59303ba68bece386be2a9ddc72e63b" --show-standard-json-input > etherscan.json
22+
patch manually etherscan.json : "optimizer":{"enabled":true,"runs":100} -> "optimizer":{"enabled":true,"runs":100},"viaIR":true (or something of that sort)
23+
upload json to etherscan manually

management/constructor-args.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0x7239aEc2fA59303BA68BEcE386BE2A9dDC72e63B

management/deploy.s.sol

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.23;
3+
4+
import { Script } from "forge-std/Script.sol";
5+
import "forge-std/console.sol";
6+
import { PatchworkProtocol } from "../src/PatchworkProtocol.sol";
7+
import { PatchworkProtocolAssigner } from "../src/PatchworkProtocolAssigner.sol";
8+
9+
contract DeterministicPatchworkDeploy is Script {
10+
11+
address internal constant _DETERMINISTIC_CREATE2_FACTORY = 0x7A0D94F55792C434d74a40883C6ed8545E406D12;
12+
13+
function run() public {
14+
address patchworkOwner = vm.envAddress("PATCHWORK_OWNER");
15+
vm.startBroadcast();
16+
17+
bytes memory creationCode = type(PatchworkProtocolAssigner).creationCode;
18+
bytes memory creationBytecode = abi.encodePacked(creationCode, abi.encode(patchworkOwner));
19+
(bool success, bytes memory returnData) = _DETERMINISTIC_CREATE2_FACTORY.call(creationBytecode);
20+
require(success, "Failed to deploy Assigner Module");
21+
address assignerAddress = address(uint160(bytes20(returnData)));
22+
console.log("Deployed Assigner module contract at: ", assignerAddress);
23+
24+
creationCode = type(PatchworkProtocol).creationCode;
25+
creationBytecode = abi.encodePacked(creationCode, abi.encode(patchworkOwner), abi.encode(assignerAddress));
26+
(success, returnData) = _DETERMINISTIC_CREATE2_FACTORY.call(creationBytecode);
27+
require(success, "Failed to deploy Patchwork");
28+
address patchworkAddress = address(uint160(bytes20(returnData)));
29+
console.log("Deployed Patchwork contract at: ", patchworkAddress);
30+
31+
vm.stopBroadcast();
32+
}
33+
}

management/deploy.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# deploy.sh
4+
5+
# Usage instructions
6+
if [ $# -lt 1 ]; then
7+
echo "Usage: $0 <network> [--broadcast]"
8+
echo "Supported networks: base, sepolia"
9+
exit 1
10+
fi
11+
12+
# Load the .env file
13+
if [ -f .env ]; then
14+
export $(grep -v '^#' .env | xargs)
15+
else
16+
echo ".env file not found"
17+
exit 1
18+
fi
19+
20+
NETWORK=$1
21+
PATCHWORK_OWNER=""
22+
RPC_URL=""
23+
24+
case $NETWORK in
25+
"base")
26+
PATCHWORK_OWNER=$BASE_PATCHWORK_OWNER
27+
RPC_URL=$BASE_RPC_URL
28+
;;
29+
"sepolia")
30+
PATCHWORK_OWNER=$SEPOLIA_PATCHWORK_OWNER
31+
RPC_URL=$SEPOLIA_RPC_URL
32+
;;
33+
*)
34+
echo "Network not supported"
35+
exit 1
36+
;;
37+
esac
38+
39+
# Check for broadcast flag
40+
if [[ " $* " =~ " --broadcast " ]]; then
41+
echo "Broadcasting is enabled"
42+
forge_options="$forge_options --broadcast"
43+
fi
44+
45+
# Export the owner address as an environment variable
46+
export PATCHWORK_OWNER
47+
48+
# Execute the Solidity script with the environment variable
49+
forge script $forge_options --optimize --optimizer-runs 200 ./deploy.s.sol:DeterministicPatchworkDeploy \
50+
--rpc-url $RPC_URL \
51+
--private-key $PRIVATE_KEY

0 commit comments

Comments
 (0)