Skip to content

Commit

Permalink
deployed to sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Apr 14, 2024
1 parent 17ddf2b commit cd5a14a
Show file tree
Hide file tree
Showing 25 changed files with 218 additions and 141 deletions.
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ snapshot :; forge snapshot

slither :; slither --config-file slither.config.json src/.

format :; forge fmt
format :; forge fmt src/**/*.sol && forge fmt scripts/**/*.sol && forge fmt test/**/*.sol

# solhint should be installed globally
lint :; solhint "src/**/*.sol"
Expand All @@ -44,15 +44,6 @@ deploy :;
verify :; ./scripts/verify.sh ${network} ${contract}

CONTRACTS = \
CharacterAccount \
CharacterSheetsImplementation \
ExperienceImplementation \
ItemsImplementation \
ItemsManagerImplementation \
ClassesImplementation \
MolochV2EligibilityAdaptor \
MolochV3EligibilityAdaptor \
ClassLevelAdaptor \
HatsAdaptor \
CharacterSheetsLevelEligibilityModule \
ERC6551HatsEligibilityModule \
Expand Down
66 changes: 21 additions & 45 deletions addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"HatsAdaptor": "",
"CharacterSheetsLevelEligibilityModule": "",
"AddressHatsEligibilityModule": "0x9AaF0df5657b634131784523F4F5e83459c61986",
"AllowListHatsEligibilityModule": "0xaC208e6668DE569C6ea1db76DeCea70430335Ed5",
"ERC721HatsEligibilityModule": "0xF37cf12fB4493D29270806e826fDDf50dd722bab",
"ERC6551HatsEligibilityModule": "0x36C55610d6043703bF7Ae29a8aa5768FC4772738",
"MultiERC6511HatsEligibilityModule": "",
Expand Down Expand Up @@ -66,6 +67,7 @@
"HatsAdaptor": "",
"CharacterSheetsLevelEligibilityModule": "",
"AddressHatsEligibilityModule": "0x9AaF0df5657b634131784523F4F5e83459c61986",
"AllowListHatsEligibilityModule": "0xaC208e6668DE569C6ea1db76DeCea70430335Ed5",
"ERC721HatsEligibilityModule": "0xF37cf12fB4493D29270806e826fDDf50dd722bab",
"ERC6551HatsEligibilityModule": "",
"MultiERC6511HatsEligibilityModule": "",
Expand Down Expand Up @@ -93,6 +95,7 @@
"HatsAdaptor": "",
"CharacterSheetsLevelEligibilityModule": "",
"AddressHatsEligibilityModule": "0x9AaF0df5657b634131784523F4F5e83459c61986",
"AllowListHatsEligibilityModule": "0xaC208e6668DE569C6ea1db76DeCea70430335Ed5",
"ERC721HatsEligibilityModule": "0xF37cf12fB4493D29270806e826fDDf50dd722bab",
"ERC6551HatsEligibilityModule": "",
"MultiERC6511HatsEligibilityModule": "",
Expand All @@ -107,57 +110,30 @@
"MolochV3EligibilityAdaptor": "",
"ClonesAddressStorageImplementation": ""
},
"goerli": {
"chainId": "5",
"network": "goerli",
"Erc6551Registry": "0x02101dfB77FDE026414827Fdc604ddAF224F0921",
"HatsContract": "0x3bc1A0Ad72417f2d411118085256fC53CBdDd137",
"HatsModuleFactory": "0xfE661c01891172046feE16D3a57c3Cf456729efA",
"CharacterAccount": "0x3cD942A7902b955E0a5222d80376B29062Ea9DaA",
"ClassesImplementation": "0x62b97b232Ed8b11409ff8a7648214010426355ed",
"CharacterSheetsFactory": "0x570F219D3FA620E7Fd48ff4787F2Da169Ed12244",
"ExperienceImplementation": "0x8065d9c66d41bF35473B71D17aCBD535dd2a3488",
"ItemsManagerImplementation": "0xEC48EB7BE3B867cB9Af481533008752d64514d84",
"CloneAddressStorage": "0xbc0A467b8100c87282988c6ff71d4227C822bF2e",
"ImplementationAddressStorage": "0x07ECa0752E074C981fB0a5eE16E7114d809ed3ff",
"ItemsImplementation": "0x8117C81B65dF2d899E413F65dd1230Ccd92Ea80a",
"CharacterSheetsImplementation": "0x5d429668Cc7FAE3657359548B413Ced02398F030",
"CharacterEligibilityAdaptorV2": "",
"CharacterEligibilityAdaptorV3": "0xC557D0a20e0BfC06adFA2eD0503523dF011E850B",
"ClassLevelAdaptor": "0x1F4Bf13C531f4875fb5d2859dCD88591b8d471f1",
"HatsAdaptor": "0x163920D269760feB9eD161601648832d963e4143",
"AddressHatsEligibilityModule": "0x9AaF0df5657b634131784523F4F5e83459c61986",
"CharacterSheetsLevelEligibilityModule": "0x6f52b30a4730C5Cb765E7c762249dc4Ae02fB8eD",
"ERC721HatsEligibilityModule": "0xF37cf12fB4493D29270806e826fDDf50dd722bab",
"ERC6551HatsEligibilityModule": "0xa25B005B82209B2D2dC6E86006ae75649b1dAb5b",
"MultiERC6511HatsEligibilityModule": "",
"ClonesAddressStorageImplementation": "0xfFE77f170cEFcC2248e6697c32ef665FcF685E14"
},
"sepolia": {
"chainId": "11155111",
"network": "sepolia",
"Erc6551Registry": "0x02101dfB77FDE026414827Fdc604ddAF224F0921",
"CharacterAccount": "0xb37557c4d1208A786fE0C28Dd865034c3e3d9038",
"ExperienceImplementation": "0xCA8d9B4c514B28a1aD5240F3071E3167E9074A53",
"CharacterSheetsImplementation": "0xF4A596FC9a70CDB508Ea21686ae20d42e6068423",
"ClassesImplementation": "0xA32b0d22cf72556D9caa1397E3c1096bFBb9CdCe",
"CharacterSheetsFactory": "0xc3158e0aB9aa1623022FeFdF4a3Ac022ff0dfcc1",
"ClassLevelAdaptor": "0x1d598591374D314AfFB2aed1370D8c81CbbA261F",
"HatsAdaptor": "0x1D5B39612a354C2Ff1f50cfd8D9FDEdB4d4F9e62",
"AddressHatsEligibilityModule": "0x9AaF0df5657b634131784523F4F5e83459c61986",
"AllowListHatsEligibilityModule": "0xaC208e6668DE569C6ea1db76DeCea70430335Ed5",
"ERC721HatsEligibilityModule": "0xF37cf12fB4493D29270806e826fDDf50dd722bab",
"ERC6551HatsEligibilityModule": "0x74e35a750DF66D3845a9359afb9EE0B4D7E41B99",
"MultiERC6511HatsEligibilityModule": "",
"CharacterSheetsLevelEligibilityModule": "0xb2Fe75E4FF7520A85938ff755BD6d2fCEFb9196E",
"ItemsManagerImplementation": "0x982EFC86035e838de7967De1b1A8f72097d84733",
"ClonesAddressStorage": "",
"ImplementationAddressStorage": "0x33018D9cCF2FE77130Cf22AA81CbA07E8B098dF3",
"ItemsImplementation": "0xE27109834a24838c2659b9a023803cb15e7633Ef",
"HatsContract": "0x3bc1A0Ad72417f2d411118085256fC53CBdDd137",
"HatsModuleFactory": "0xfE661c01891172046feE16D3a57c3Cf456729efA",
"MolochV2EligibilityAdaptor": "0x0E0514a13c905F4DEd5e46769aC5FD049fB8aC6F",
"MolochV3EligibilityAdaptor": "0xCb6787d033750D610107C96bcff4d925dde026b5",
"ClonesAddressStorageImplementation": "0xeCb73607DD8fD80F4E8f50b5B46A3286eA3e1854"
"CharacterAccount": "0x936aa7A9882725D6678751BCe43b834cFEB104d6",
"CharacterSheetsImplementation": "0xF925c147EB2d829693Dbd396ECFe0370627e7513",
"ExperienceImplementation": "0xd4d0f703a1B1205EC1a6C45499d2a8b7292B726c",
"ItemsImplementation": "0x6605D4F26e87b0bc034e5A059B448509bEd45577",
"ItemsManagerImplementation": "0x473017Ee3dF48C194f19688d39Cb9a83903A9CeF",
"ClassesImplementation": "0x6db7DF9a3bdF2c2dF76CA679f5954CCF88a34D94",
"MolochV2EligibilityAdaptor": "0x993c409E0f37238b97F45fe2D6223D8e3118d498",
"MolochV3EligibilityAdaptor": "0xFb38767DD77Ab247AA71F51774e0d9BdfC0238b3",
"ClassLevelAdaptor": "0x9888797415B7d5a976325972b3585bC1bbc390F3",
"HatsAdaptor": "0x966A24e86A6F4fe47C07A442bdA636Ae19cd9a50",
"CharacterSheetsLevelEligibilityModule": "0x6c904AF082FB429f5389278923EBA0Fe9dd59dc4",
"ERC6551HatsEligibilityModule": "0x2FB64E7cC67466f9dAA627c893D47AF3E42b06A9",
"MultiERC6551HatsEligibilityModule": "0x5a1551E7821eE6c56108761c301382B89f7bb08d",
"ClonesAddressStorageImplementation": "0x5768c8B53930C3971357c78EF91C1Edf33F4b1B3",
"ImplementationAddressStorage": "0xEd3551A9A4807134C568EFa7D2Db6f3C66558179",
"CharacterSheetsFactory": "0xC31cd47907ED2C2693182506Df6437d9151f37a6"
},
"anvil": {
"chainId": "31337",
Expand Down Expand Up @@ -186,4 +162,4 @@
"ERC6551HatsEligibilityModule": "",
"MultiERC6511HatsEligibilityModule": ""
}
}
}
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[profile.default]
solc_version = "0.8.24"
solc_version = "0.8.25"
evm_version = "cancun"
bytecode_hash = "none"
optimizer = true
Expand Down
26 changes: 24 additions & 2 deletions scripts/BaseDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
//solhint-disable

Expand All @@ -11,14 +11,36 @@ import {ForkManagement} from "./helpers/ForkManagement.sol";
abstract contract BaseDeployer is Script, ForkManagement {
using stdJson for string;

string public _version = "version 0.1";
string public _version = "0.0.1";
uint256 deployerPrivateKey;
address deployer;

bytes32 public SALT = bytes32(keccak256(abi.encode("CS")));
address public CREATE2_DEPLOYER = address(0x4e59b44847b379578588920cA78FbF26c0B4956C);

function loadBaseAddresses(string memory json, string memory targetEnv) internal virtual {
// empty
}

function getDeploymentAddress(bytes memory creationCode, bytes memory params) internal view returns (address) {
bytes32 newContract = keccak256(
abi.encodePacked(bytes1(0xff), CREATE2_DEPLOYER, SALT, keccak256(abi.encodePacked(creationCode, params)))
);
return address(uint160(uint256(newContract)));
}

function getDeploymentAddress(bytes memory creationCode) internal view returns (address) {
return getDeploymentAddress(creationCode, "");
}

function isContract(address a) public view returns (bool) {
uint32 size;
assembly {
size := extcodesize(a)
}
return (size > 0);
}

function loadPrivateKeys() internal {
string memory mnemonic = vm.envString("MNEMONIC");

Expand Down
9 changes: 7 additions & 2 deletions scripts/CharacterAccount.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ contract DeployCharacterAccount is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

characterAccount = new CharacterAccount();
address newContractAddress = getDeploymentAddress(type(CharacterAccount).creationCode);

if (!isContract(newContractAddress)) {
characterAccount = new CharacterAccount{salt: SALT}();
assert(address(characterAccount) == newContractAddress);
}

vm.stopBroadcast();

return address(characterAccount);
return newContractAddress;
}
}
22 changes: 14 additions & 8 deletions scripts/CharacterSheetsFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ contract DeployCharacterSheetsFactory is BaseDeployer {

vm.startBroadcast(deployerPrivateKey);

characterSheetsFactory = new CharacterSheetsFactory();
address newContractAddress = getDeploymentAddress(type(CharacterSheetsFactory).creationCode);

characterSheetsFactory.initialize(implementationAddressStorage);
if (!isContract(newContractAddress)) {
characterSheetsFactory = new CharacterSheetsFactory{salt: SALT}();

characterSheetsFactory.initialize(implementationAddressStorage);
assert(address(characterSheetsFactory) == newContractAddress);
}

vm.stopBroadcast();

return address(characterSheetsFactory);
return newContractAddress;
}
}

Expand All @@ -80,7 +85,8 @@ contract Create is BaseExecutor {
function loadBaseData(string memory json, string memory targetEnv) internal override {
// addresses
dao = json.readAddress(string(abi.encodePacked(".", targetEnv, ".Dao")));
address characterSheetsFactory = json.readAddress(string(abi.encodePacked(".", targetEnv, ".CharacterSheetsFactory")));
address characterSheetsFactory =
json.readAddress(string(abi.encodePacked(".", targetEnv, ".CharacterSheetsFactory")));
gameMasters = json.readAddressArray(string(abi.encodePacked(".", targetEnv, ".GameMasters")));
implementationStorageAddress =
json.readAddress(string(abi.encodePacked(".", targetEnv, ".ImplementationAddressStorage")));
Expand Down Expand Up @@ -110,12 +116,12 @@ contract Create is BaseExecutor {
// init and encode
factory = CharacterSheetsFactory(characterSheetsFactory);
encodedSheetsStrings = "";
// abi.encode(characterSheetsMetadataUri, characterSheetsBaseUri, itemsBaseUri, classesBaseUri);
encodedHatsAddresses = "";
// abi.encode(arg);
// abi.encode(characterSheetsMetadataUri, characterSheetsBaseUri, itemsBaseUri, classesBaseUri);
encodedHatsAddresses = "";
// abi.encode(arg);
}

function execute() internal override {
function execute() internal override {
vm.startBroadcast(deployerPrivateKey);
clonesAddressStorage = factory.create(dao);
vm.stopBroadcast();
Expand Down
9 changes: 7 additions & 2 deletions scripts/CharacterSheetsImplementation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ contract DeployCharacterSheetsImplementation is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

characterSheetsImplementation = new CharacterSheetsImplementation();
address newContractAddress = getDeploymentAddress(type(CharacterSheetsImplementation).creationCode);

if (!isContract(newContractAddress)) {
characterSheetsImplementation = new CharacterSheetsImplementation{salt: SALT}();
assert(address(characterSheetsImplementation) == newContractAddress);
}

vm.stopBroadcast();

return address(characterSheetsImplementation);
return newContractAddress;
}
}
9 changes: 7 additions & 2 deletions scripts/CharacterSheetsLevelEligibilityModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ contract DeployCharacterSheetsLevelEligibilityModule is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

characterSheetsLevelEligibilityModule = new CharacterSheetsLevelEligibilityModule(_version);
address newContractAddress = getDeploymentAddress(type(CharacterSheetsLevelEligibilityModule).creationCode, abi.encode(_version));

if (!isContract(newContractAddress)) {
characterSheetsLevelEligibilityModule = new CharacterSheetsLevelEligibilityModule{salt: SALT}(_version);
assert(address(characterSheetsLevelEligibilityModule) == newContractAddress);
}

vm.stopBroadcast();

return address(characterSheetsLevelEligibilityModule);
return newContractAddress;
}
}
9 changes: 7 additions & 2 deletions scripts/ClassLevelAdaptor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ contract DeployClassLevelAdaptor is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

classLevelAdaptor = new ClassLevelAdaptor();
address newContractAddress = getDeploymentAddress(type(ClassLevelAdaptor).creationCode);

if (!isContract(newContractAddress)) {
classLevelAdaptor = new ClassLevelAdaptor{salt: SALT}();
assert(address(classLevelAdaptor) == newContractAddress);
}

vm.stopBroadcast();

return address(classLevelAdaptor);
return newContractAddress;
}
}
9 changes: 7 additions & 2 deletions scripts/ClassesImplementation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ contract DeployClassesImplementation is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

classesImplementation = new ClassesImplementation();
address newContractAddress = getDeploymentAddress(type(ClassesImplementation).creationCode);

if (!isContract(newContractAddress)) {
classesImplementation = new ClassesImplementation{salt: SALT}();
assert(address(classesImplementation) == newContractAddress);
}

vm.stopBroadcast();

return address(classesImplementation);
return newContractAddress;
}
}

Expand Down
9 changes: 7 additions & 2 deletions scripts/ClonesAddressStorageImplementation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ contract DeployClonesAddressStorageImplementation is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

clonesAddressStorage = new ClonesAddressStorageImplementation();
address newContractAddress = getDeploymentAddress(type(ClonesAddressStorageImplementation).creationCode);

if (!isContract(newContractAddress)) {
clonesAddressStorage = new ClonesAddressStorageImplementation{salt: SALT}();
assert(address(clonesAddressStorage) == newContractAddress);
}

vm.stopBroadcast();

return address(clonesAddressStorage);
return newContractAddress;
}
}
9 changes: 7 additions & 2 deletions scripts/ERC6551HatsEligibilityModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ contract DeployERC6551HatsEligibilityModule is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

erc6551HatsEligibilityModule = new ERC6551HatsEligibilityModule(_version);
address newContractAddress = getDeploymentAddress(type(ERC6551HatsEligibilityModule).creationCode, abi.encode(_version));

if (!isContract(newContractAddress)) {
erc6551HatsEligibilityModule = new ERC6551HatsEligibilityModule{salt: SALT}(_version);
assert(address(erc6551HatsEligibilityModule) == newContractAddress);
}

vm.stopBroadcast();

return address(erc6551HatsEligibilityModule);
return newContractAddress;
}
}
9 changes: 7 additions & 2 deletions scripts/ExperienceImplementation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ contract DeployExperienceImplementation is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

experienceImplementation = new ExperienceImplementation();
address newContractAddress = getDeploymentAddress(type(ExperienceImplementation).creationCode);

if (!isContract(newContractAddress)) {
experienceImplementation = new ExperienceImplementation{salt: SALT}();
assert(address(experienceImplementation) == newContractAddress);
}

vm.stopBroadcast();

return address(experienceImplementation);
return newContractAddress;
}
}

Expand Down
9 changes: 7 additions & 2 deletions scripts/HatsAdaptor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ contract DeployHatsAdaptor is BaseDeployer {
function deploy() internal override returns (address) {
vm.startBroadcast(deployerPrivateKey);

hatsAdaptor = new HatsAdaptor();
address newContractAddress = getDeploymentAddress(type(HatsAdaptor).creationCode);

if (!isContract(newContractAddress)) {
hatsAdaptor = new HatsAdaptor{salt: SALT}();
assert(address(hatsAdaptor) == newContractAddress);
}

vm.stopBroadcast();

return address(hatsAdaptor);
return newContractAddress;
}
}
Loading

0 comments on commit cd5a14a

Please sign in to comment.