Skip to content

Commit

Permalink
Contracts/attestations (#76)
Browse files Browse the repository at this point in the history
* removed garden contracts

* added action registry

* Started to modify contracts for work attestations
Added deploy script for Action Registry

* added eas schema deployer

* added schemas file with attestations needed for MVP.

* Action registry completed with comments and optimizations

* cleared constant not yet set with 0x0 address or bytes
added common error messages
added enum for capitals

* created schemas struct for resolver to reference attestation onAttest

* renamed deploy attestations to resolvers

* updated resolvers adding needed imports

* removed garden from name so attestations can scale past garden work

* created lib for returing community token address

* added constatnts for community token and garden

* address lint warning with more declartive mapping names

* added conditionals for enabling attestations be approved

* prettified solidity code

* added back tab width 4 and added solhint ignore

* fixed eas import mappings

* added requires for resolvers
made garden mapping public for resolvers to access
changed calldata for media update to memory to avoid compiler errpr
created get action view function

* reverted tab width to 2 for non solidity files

* updated deploy scripts

* added new constants such as safe and token

* updated msg.sender to _msgSender()

* added lib to get eas address

* made token upgradeable

* added overrides just for sol files

* created delpoy script action registry, garden token and resolvers

* added test for garden token/acount and resolvers

* updated mapping using tokenbound forge-std and ds-test

* polished libs with documentation and optimizations

* polished contracts adding comments for clear documentation

* created mock eas for testing

* updated lock

* added prod env var to set ethers deployment chain

* added resolver as option for schema deployment

* polished test and commented out test not ready

* removed disabling initalizers

* added Schema registry addresses
moved salt and factory to constants file

* added emot for garden name

* polished deploy scripts

* added title to action
created modifier for not action owner

* updated sepolia rpc to proper one

* fixed solhint config issue

* updated commands for deploying splitting into different scripts

* updated name for etherscan api key

* updated tokenbounsd constants and interface

* disabled transfer ownership causing issues

* modify intializer test now that owner stays same
removed prank multisig with owner now address(this)
  • Loading branch information
Oba-One authored Aug 20, 2024
1 parent d579329 commit 920af17
Show file tree
Hide file tree
Showing 40 changed files with 2,389 additions and 312 deletions.
15 changes: 14 additions & 1 deletion packages/contracts/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
{
"plugins": ["prettier-plugin-solidity"],
"bracketSpacing": true,
"printWidth": 120,
"proseWrap": "always",
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
"useTabs": false,
"overrides": [
{
"files": "*.sol",
"options": {
"parser": "solidity-parse",
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false
}
}
]
}
2 changes: 1 addition & 1 deletion packages/contracts/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"named-parameters-mapping": "warn",
"no-console": "off",
"not-rely-on-time": "off",
"one-contract-per-file": true,
"one-contract-per-file": "error",
"avoid-low-level-calls": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "off",
Expand Down
6 changes: 6 additions & 0 deletions packages/contracts/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# directories
broadcast
cache
coverage
node_modules
out
4 changes: 2 additions & 2 deletions packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test = 'test'
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 2
tab_width = 4
wrap_comments = true

extra_output_files = [
Expand All @@ -43,7 +43,7 @@ fs_permissions = [{ access = "read", path = "./"}]
eth_rpc_url = "http://localhost:8545"

[profile.sepolia]
eth_rpc_url = "https://arb-mainnet.g.alchemy.com/v2/i2qnBKk5GQ8pVGPLA-G3D9il5o0ULQO3"
eth_rpc_url = "https://eth-sepolia.g.alchemy.com/v2/i2qnBKk5GQ8pVGPLA-G3D9il5o0ULQO3"

[profile.arbitrum]
eth_rpc_url = "https://arb-mainnet.g.alchemy.com/v2/i2qnBKk5GQ8pVGPLA-G3D9il5o0ULQO3"
Expand Down
11 changes: 6 additions & 5 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "contracts",
"version": "0.0.8",
"private": true,
"description": "Contracts for Protocol",
"descripticon": "Contracts for Protocol",
"scripts": {
"account": "node script/ListAccount.js",
"chain": "anvil --config-out localhost.json",
Expand All @@ -13,9 +13,11 @@
"lint": "pnpm run prettier && pnpm run solhint",
"anvil": "source .env && anvil --fork-url $ANVIL_FORK_URL --chain-id $ANVIL_CHAIN_ID",
"build": "forge build",
"test": "pnpm run build && forge test -f https://sepolia-rollup.arbitrum.io/rpc --gas-report",
"deploy:arbitrum": "source .env && FOUNDRY_PROFILE=arbitrum forge script script/Arbitrum.s.sol:ArbitrumScript --private-key $FORGE_PRIVATE_KEY --etherscan-api-key $ETHERSCAN_API_KEY --broadcast",
"deploy:arbitrum-sepolia": "source .env && FOUNDRY_PROFILE=arbitrum-sepolia forge script script/ArbitrumSepolia.s.sol:ArbitrumScript --private-key $FORGE_PRIVATE_KEY --etherscan-api-key $ETHERSCAN_API_KEY --broadcast"
"test": "pnpm run build && forge test -f https://eth-sepolia.g.alchemy.com/v2/i2qnBKk5GQ8pVGPLA-G3D9il5o0ULQO3 --gas-report",
"deploy:counter": "source .env && forge script script/Counter.s.sol:CounterScript --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY_ETHERSCAN",
"deploy:action": "source .env && forge script script/DeployActionRegistry.s.sol:DeployActionRegistry --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY_ETHERSCAN",
"deploy:garden": "source .env && forge script script/DeployGardenToken.s.sol:DeployGardenToken --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY_ETHERSCAN",
"deploy:resolvers": "source .env && forge script script/DeployResolvers.s.sol:DeployResolvers --private-key $PRIVATE_KEY --etherscan-api-key $API_KEY_ETHERSCAN"
},
"dependencies": {
"@ethereum-attestation-service/eas-contracts": "1.7.1",
Expand All @@ -29,7 +31,6 @@
"toml": "~3.0.0",
"solidity-coverage": "^0.8.12",
"solhint": "^5.0.3",
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.4.0"
}
Expand Down
10 changes: 5 additions & 5 deletions packages/contracts/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ds-test=./node_modules/ds-test/src/
forge-std=./node_modules/forge-std/src/
@openzeppelin/contracts=lib/tokenbound/lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts-upgradeable=./node_modules/@openzeppelin/contracts-upgradeable/
@eas=./node_modules/@ethereum-attestation-service/eas-contracts/contracts/
@tokenbound=./lib/tokenbound/src/
erc6551/=lib/tokenbound/lib/erc6551/src/
forge-std=./lib/tokenbound/lib/forge-std/src/
ds-test=./lib/tokenbound/lib/forge-std/lib/ds-test/src/
@eas=./node_modules/@ethereum-attestation-service/eas-contracts/contracts/
@openzeppelin/contracts=lib/tokenbound/lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts-upgradeable=./node_modules/@openzeppelin/contracts-upgradeable/
2 changes: 1 addition & 1 deletion packages/contracts/script/Counter.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.25;

import "forge-std/Script.sol";
import { Script } from "forge-std/Script.sol";

contract CounterScript is Script {
function setUp() public {}
Expand Down
65 changes: 65 additions & 0 deletions packages/contracts/script/DeployActionRegistry.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.25;

import { Script, console } from "forge-std/Script.sol";
import { Create2 } from "@openzeppelin/contracts/utils/Create2.sol";
import { FACTORY, SALT } from "../src/Constants.sol";
import { ActionRegistry, Capital } from "../src/registries/Action.sol";

/// @title DeployActionRegistry
/// @notice Script for deploying the ActionRegistry contract using CREATE2.
contract DeployActionRegistry is Script {
function run() public {
// Calculate the CREATE2 address for the ActionRegistry
address predictedRegistryAddress = Create2.computeAddress(
SALT,
keccak256(abi.encodePacked(type(ActionRegistry).creationCode, "")),
FACTORY
);

// Check if the contract is already deployed
if (predictedRegistryAddress.code.length == 0) {
vm.startBroadcast();
ActionRegistry newRegistry = new ActionRegistry{ salt: SALT }();

Capital[] memory capitals = new Capital[](1);
capitals[0] = Capital.LIVING;

string[] memory media = new string[](2);
media[0] = "QmWYQY9vnb9ot7u49UMeH41DdjZghrgr2YoaYaNwYSpeAn";
media[1] = "QmS9K5EdyakRPW7gV86xivaUNx1AuhPUzUSRD53WnjL4Uz";

newRegistry.initialize(address(this));
newRegistry.registerAction(
block.timestamp,
block.timestamp + 30 days,
"Test Action 1",
"QmTmbcRyKtkMpMFWsm6D8YpgwMUuds3jE4sJdjqhqFGvWe",
capitals,
media
);
newRegistry.registerAction(
block.timestamp,
block.timestamp + 30 days,
"Test Action 2",
"QmTmbcRyKtkMpMFWsm6D8YpgwMUuds3jE4sJdjqhqFGvWe",
capitals,
media
);

vm.stopBroadcast();

console.log("ActionRegistry deployed at:", predictedRegistryAddress);
} else {
console.log("ActionRegistry already exists at:", predictedRegistryAddress);
}

// Print out verification commands
console.log("\nVerification Commands:\n");
console.log(
"ActionRegistry: forge verify-contract --num-of-optimizations 200 --chain-id",
block.chainid,
predictedRegistryAddress
);
}
}
130 changes: 0 additions & 130 deletions packages/contracts/script/DeployGardenAccount.s.sol

This file was deleted.

Loading

0 comments on commit 920af17

Please sign in to comment.