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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "lib/properties"]
path = lib/properties
url = https://github.com/crytic/properties
[submodule "lib/safe-contracts"]
path = lib/safe-contracts
url = https://github.com/gnosis/safe-contracts
1 change: 1 addition & 0 deletions lib/safe-contracts
Submodule safe-contracts added at f3af2a
2 changes: 2 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
lib/ERC1155/=lib/hats-protocol/lib/ERC1155/
@hats-protocol/=lib/hats-protocol/src
hevm/=lib/properties/contracts/util/
@gnosis.pm/safe-contracts/=lib/safe-contracts/
@gnosis.pm/zodiac/=lib/zodiac/
146 changes: 11 additions & 135 deletions scripts/FullEscrowDeployment.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import {EscrowMulticall} from "../src/EscrowMulticall.sol";
// Roles
import { Roles } from "../src/Roles.sol";

import "./HatsDeployment.s.sol";

contract FullEscrowDeployment is Script {
address public adminAddress1 = 0x1310cEdD03Cc8F6aE50F2Fb93848070FACB042b8;
address public adminAddress2 = 0x1542612fee591eD35C05A3E980bAB325265c06a3; // The admin address
address public vaultAddress = address(0x11); // The vault that will receive fees
address public arbiterAddress = address(0x12); // The arbiter address
address public daoAddress = address(0x13); // The DAO address
address public adminAddress2 = 0x1542612fee591eD35C05A3E980bAB325265c06a3;
bool internal autoRelease = true; // Whether PaymentEscrow starts with autoRelease

Hats public hats;
Expand All @@ -45,131 +44,12 @@ contract FullEscrowDeployment is Script {


function run() external {
vm.startBroadcast(adminAddress1);
console.log("Starting FullEscrowDeployment");
// 1. Deploy the Hats base contract
hats = Hats(0x3bc1A0Ad72417f2d411118085256fC53CBdDd137);// this is the hats contract on all chains
//hats = new Hats("Hats Protocol v1", "ipfs://bafkreiflezpk3kjz6zsv23pbvowtatnd5hmqfkdro33x5mh2azlhne3ah4");
//use this just for amoy. the above address is on polygon and base

// 2. Deploy Eligibility & Toggle Modules
// pass admin address to each module’s constructor
eligibilityModule = new EligibilityModule(adminAddress1);
toggleModule = new ToggleModule(adminAddress1);

// 3. Mint the Top Hat to admin

// details in json format uploaded to IPFS
// {"type":"1.0","data":{"name":"sxxs","description":"xssxsxsx"}}
topHatId = hats.mintTopHat(
adminAddress1,
"ipfs://bafkreih3vqseitn7pijlkl2jcawbjrhae3dfb2pakqtgd4epvxxfulwoqq", //from ipfs/admin.json
""
);

// 4. Create child hats

adminHatId = hats.createHat(
topHatId,
"ipfs://bafkreih3vqseitn7pijlkl2jcawbjrhae3dfb2pakqtgd4epvxxfulwoqq", //from ipfs/admin.json
2, // maxSupply
address(eligibilityModule),
address(toggleModule),
true, // mutable
""// no image
);

arbiterHatId = hats.createHat(
adminHatId,
"ipfs://bafkreicbhbvddt2f475inukntzh6n72ehm4iyljstyyjsmizdsojmbdase", //from ipfs/arbiter.json
2, // maxSupply
address(eligibilityModule),
address(toggleModule),
true, // mutable
""// no image
);

daoHatId = hats.createHat(
adminHatId,
"ipfs://bafkreic2f5b6ykdvafs5nhkouruvlql73caou5etgdrx67yt6ofp6pwf24", //from ipfs/dao.json
2,
address(eligibilityModule),
address(toggleModule),
true,
""
);

uint256 systemHatId = hats.createHat(
adminHatId,
"ipfs://bafkreie2vxohaw7cneknlwv6hq7h4askkv6jfcadho6efz5bxfx66fqu3q", //from ipfs/system.json
2,
address(eligibilityModule),
address(toggleModule),
true,
""
);

uint256 pauserHatId = hats.createHat(
adminHatId,
"ipfs://bafkreiczfbtftesggzcfnumcy7rfru665a77uyznbabdk5b6ftfo2hvjw4", //from ipfs/pauser.json
2,
address(eligibilityModule),
address(toggleModule),
true,
""
);

console.log("Arbiter Hat ID:", arbiterHatId);
console.log("DAO Hat ID:", daoHatId);
console.log("System Hat ID:", systemHatId);
console.log("Pauser Hat ID:", pauserHatId);

// 5. Deploy HatsSecurityContext & set role hats
securityContext = new HatsSecurityContext(
address(hats),
adminHatId
);

// 6. Set the eligibility and toggle module
eligibilityModule.setHatRules(adminHatId, true, true);
eligibilityModule.setHatRules(arbiterHatId, true, true);
eligibilityModule.setHatRules(daoHatId, true, true);
eligibilityModule.setHatRules(systemHatId, true, true);
eligibilityModule.setHatRules(pauserHatId, true, true);

toggleModule.setHatStatus(adminHatId, true);
toggleModule.setHatStatus(arbiterHatId, true);
toggleModule.setHatStatus(daoHatId, true);
toggleModule.setHatStatus(systemHatId, true);
toggleModule.setHatStatus(pauserHatId, true);

// 7. Mint the hats to the respective addresses
// Mint the admin hat to the admin address
hats.mintHat(adminHatId, adminAddress1);
hats.mintHat(adminHatId, adminAddress2);
// Mint the arbiter hat to the arbiter address
hats.mintHat(arbiterHatId, adminAddress1);
hats.mintHat(arbiterHatId, adminAddress2);

// Mint the DAO hat to the DAO address
hats.mintHat(daoHatId, adminAddress1);
hats.mintHat(daoHatId, adminAddress2);

// Mint the system hat to the admin address
hats.mintHat(systemHatId, adminAddress1);
hats.mintHat(systemHatId, adminAddress2);


// Mint the pauser hat to the admin address
hats.mintHat(pauserHatId, adminAddress1);
hats.mintHat(pauserHatId, adminAddress2);

// Map each role to the correct hat
securityContext.setRoleHat(Roles.ARBITER_ROLE, arbiterHatId);
securityContext.setRoleHat(Roles.DAO_ROLE, daoHatId);
securityContext.setRoleHat(Roles.SYSTEM_ROLE, systemHatId);
securityContext.setRoleHat(Roles.PAUSER_ROLE, pauserHatId);

HatsDeployment hatsDeployment = new HatsDeployment();
(address safeAddr, address hatsSecurityContextAddr) = hatsDeployment.run();

vm.startBroadcast(adminAddress1);
//--------------------------------------//
// 8. Deploy SystemSettings //
//--------------------------------------//
Expand All @@ -178,8 +58,8 @@ contract FullEscrowDeployment is Script {
// vaultAddress
// initialFeeBps
systemSettings = new SystemSettings(
IHatsSecurityContext(address(securityContext)),
vaultAddress,
IHatsSecurityContext(hatsSecurityContextAddr),
safeAddr, //CHANGE FOR VAULT
0 // feeBps (0 for now)
);

Expand All @@ -191,7 +71,7 @@ contract FullEscrowDeployment is Script {
// ISystemSettings
// autoReleaseFlag
paymentEscrow = new PaymentEscrow(
IHatsSecurityContext(address(securityContext)),
IHatsSecurityContext(hatsSecurityContextAddr),
ISystemSettings(address(systemSettings)),
autoRelease
);
Expand All @@ -202,11 +82,7 @@ contract FullEscrowDeployment is Script {
escrowMulticall = new EscrowMulticall();

vm.stopBroadcast();

console.log("Hats deployed at: ", address(hats));
console.log("EligibilityModule deployed at:", address(eligibilityModule));
console.log("ToggleModule deployed at: ", address(toggleModule));
console.log("HatsSecurityContext deployed: ", address(securityContext));

console.log("SystemSettings deployed: ", address(systemSettings));
console.log("PaymentEscrow deployed: ", address(paymentEscrow));
console.log("EscrowMulticall deployed: ", address(escrowMulticall));
Expand Down
Loading
Loading