Skip to content

Commit

Permalink
updated contracts and scripts for new deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Oba-One committed Aug 28, 2024
1 parent c94c0c5 commit 7a2deb6
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 20 deletions.
21 changes: 14 additions & 7 deletions packages/contracts/script/DeployGardenToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,18 @@ contract DeployGardenToken is Script {
console.log("GardenToken deployed at:", token);

// Mint a garden for Rio Claro, São Paulo
address[] memory gardeners = new address[](1);
address[] memory gardenOperators = new address[](1);
address[] memory gardeners = new address[](4);
address[] memory gardenOperators = new address[](4);

gardeners[0] = 0x2aa64E6d80390F5C017F0313cB908051BE2FD35e; // afo-wefa.eth
gardeners[1] = 0xAcD59e854adf632d2322404198624F757C868C97; // groweco.eth
gardeners[2] = 0x29e6cbF2450F86006292D10A3cF791955600a457; // marcin
gardeners[3] = 0x2aa64E6d80390F5C017F0313cB908051BE2FD35e; // [email protected]
gardenOperators[0] = 0x2aa64E6d80390F5C017F0313cB908051BE2FD35e; // afo-wefa.eth
gardenOperators[1] = 0xAcD59e854adf632d2322404198624F757C868C97; // groweco.eth
gardenOperators[2] = 0x29e6cbF2450F86006292D10A3cF791955600a457; // marcin
gardenOperators[3] = 0x2aa64E6d80390F5C017F0313cB908051BE2FD35e; // [email protected]

gardenAccount = gardenToken.mintGarden(communityToken, "Root Planet", gardeners, gardenOperators);

vm.stopBroadcast();
Expand Down Expand Up @@ -124,11 +131,11 @@ contract DeployGardenToken is Script {
string.concat(
'src/GardenAccount.sol:GardenAccount --constructor-args $(cast abi-encode "constructor(address,address,address,address)" ',
Strings.toHexString(erc4337EntryPoint),
" ",
", ",
Strings.toHexString(multicallForwarder),
" ",
", ",
Strings.toHexString(TOKENBOUND_REGISTRY),
" ",
", ",
Strings.toHexString(guardian),
")\n"
)
Expand All @@ -140,7 +147,7 @@ contract DeployGardenToken is Script {
string.concat(
'src/AccountProxy.sol:AccountProxy --constructor-args $(cast abi-encode "constructor(address,address)" ',
Strings.toHexString(guardian),
" ",
", ",
Strings.toHexString(implementation),
")\n"
)
Expand All @@ -151,7 +158,7 @@ contract DeployGardenToken is Script {
string.concat(
'src/GardenToken.sol:GardenToken --constructor-args $(cast abi-encode "constructor(address)" ',
Strings.toHexString(implementation),
"",
", ",
Strings.toHexString(gardenAccount),
")\n"
)
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/script/DeployResolvers.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contract DeployResolvers is Script {
block.chainid,
predictedWorkResolverAddress,
string.concat(
'src/resolvers/Work.sol:WorkResolver --constructor-args $(cast abi-encode "constructor(address,address)" ',
'src/resolvers/Work.sol:WorkResolver --constructor-args $(cast abi-encode "constructor(address,address)", ',
Strings.toHexString(eas),
", ",
Strings.toHexString(ACTION_REGISTRY),
Expand Down
31 changes: 31 additions & 0 deletions packages/contracts/src/accounts/Garden.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ contract GardenAccount is AccountV3Upgradable, Initializable {
/// @param newName The new name of the garden.
event NameUpdated(address indexed updater, string newName);

/// @notice Emitted when the garden description is updated.
/// @param updater The address of the entity that updated the description.
/// @param newDescription The new description of the garden.
event DescriptionUpdated(address indexed updater, string newDescription);

/// @notice Emitted when a new gardener is added.
/// @param updater The address of the entity that added the gardener.
/// @param gardener The address of the added gardener.
Expand All @@ -41,6 +46,9 @@ contract GardenAccount is AccountV3Upgradable, Initializable {
/// @notice The name of the garden.
string public name;

/// @notice The description of the garden.
string public description;

/// @notice Mapping of gardener addresses to their status.
mapping(address gardener => bool isGardener) public gardeners;

Expand All @@ -64,16 +72,22 @@ contract GardenAccount is AccountV3Upgradable, Initializable {
/// @dev This function must be called after the contract is deployed.
/// @param _communityToken The address of the community token associated with the garden.
/// @param _name The name of the garden.
/// @param _description The description of the garden.
/// @param _gardeners An array of addresses representing the initial gardeners.
/// @param _gardenOperators An array of addresses representing the initial garden operators.
function initialize(
address _communityToken,
string calldata _name,
string calldata _description,
address[] calldata _gardeners,
address[] calldata _gardenOperators
) external initializer {
communityToken = _communityToken;
name = _name;
description = _description;

gardeners[_msgSender()] = true;
gardenOperators[_msgSender()] = true;

for (uint256 i = 0; i < _gardeners.length; i++) {
gardeners[_gardeners[i]] = true;
Expand All @@ -86,6 +100,10 @@ contract GardenAccount is AccountV3Upgradable, Initializable {
}

emit NameUpdated(_msgSender(), _name);
emit DescriptionUpdated(_msgSender(), _description);

emit GardenerAdded(_msgSender(), _msgSender());
emit GardenOperatorAdded(_msgSender(), _msgSender());
}

/// @notice Updates the name of the garden.
Expand All @@ -101,6 +119,19 @@ contract GardenAccount is AccountV3Upgradable, Initializable {
emit NameUpdated(_msgSender(), _name);
}

/// @notice Updates the description of the garden.
/// @dev Only callable by a valid signer of the contract.
/// @param _description The new description of the garden.
function updateDescription(string memory _description) external {
if (_isValidSigner(_msgSender(), "")) {
revert NotGardenOwner();
}

description = _description;

emit DescriptionUpdated(_msgSender(), _description);
}

/// @notice Adds a new gardener to the garden.
/// @dev Only callable by a valid signer of the contract.
/// @param gardener The address of the gardener to add.
Expand Down
45 changes: 35 additions & 10 deletions packages/contracts/src/registries/Action.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,39 @@ contract ActionRegistry is UUPSUpgradeable, OwnableUpgradeable {

/// @notice Emitted when a new action is registered.
/// @param owner The address of the action owner.
/// @param actionUID The unique identifier of the action.
/// @param action The details of the registered action.
event ActionRegistered(address indexed owner, uint256 actionUID, Action indexed action);
event ActionRegistered(address indexed owner, uint256 indexed actionUID, Action indexed action);

/// @notice Emitted when an action is updated.
/// @notice Emitted when an existing action is start time is updated.
/// @param owner The address of the action owner.
/// @param action The updated details of the action.
event ActionUpdated(address indexed owner, uint256 actionUID, Action indexed action);
/// @param actionUID The unique identifier of the action.
/// @param startTime The new start time of the action.
event ActionStartTimeUpdated(address indexed owner, uint256 indexed actionUID, uint256 indexed startTime);

/// @notice Emitted when an existing action is end time is updated.
/// @param owner The address of the action owner.
/// @param actionUID The unique identifier of the action.
/// @param endTime The new end time of the action.
event ActionEndTimeUpdated(address indexed owner, uint256 indexed actionUID, uint256 indexed endTime);

/// @notice Emitted when an existing action is title is updated.
/// @param owner The address of the action owner.
/// @param actionUID The unique identifier of the action.
/// @param title The new title of the action.
event ActionTitleUpdated(address indexed owner, uint256 indexed actionUID, string indexed title);

/// @notice Emitted when an existing action is instructions are updated.
/// @param owner The address of the action owner.
/// @param actionUID The unique identifier of the action.
/// @param instructions The new instructions of the action.
event ActionInstructionsUpdated(address indexed owner, uint256 indexed actionUID, string indexed instructions);

/// @notice Emitted when an existing action is media is updated.
/// @param owner The address of the action owner.
/// @param actionUID The unique identifier of the action.
/// @param media The new media URLs of the action.
event ActionMediaUpdated(address indexed owner, uint256 indexed actionUID, string[] indexed media);

uint256 private _nextActionUID;

Expand Down Expand Up @@ -88,7 +114,7 @@ contract ActionRegistry is UUPSUpgradeable, OwnableUpgradeable {
function updateActionStartTime(uint256 actionUID, uint256 _startTime) external onlyActionOwner(actionUID) {
idToAction[actionUID].startTime = _startTime;

emit ActionUpdated(actionToOwner[actionUID], actionUID, idToAction[actionUID]);
emit ActionStartTimeUpdated(actionToOwner[actionUID], actionUID, _startTime);
}

/// @notice Updates the end time of an existing action.
Expand All @@ -97,16 +123,15 @@ contract ActionRegistry is UUPSUpgradeable, OwnableUpgradeable {
function updateActionEndTime(uint256 actionUID, uint256 _endTime) external onlyActionOwner(actionUID) {
idToAction[actionUID].endTime = _endTime;

emit ActionUpdated(actionToOwner[actionUID], actionUID, idToAction[actionUID]);
}
emit ActionEndTimeUpdated(actionToOwner[actionUID], actionUID, _endTime);}

/// @notice Updates the title of an existing action.
/// @param actionUID The unique identifier of the action to update.
/// @param _title The new title for the action.
function updateActionTitle(uint256 actionUID, string calldata _title) external onlyActionOwner(actionUID) {
idToAction[actionUID].title = _title;

emit ActionUpdated(actionToOwner[actionUID], actionUID, idToAction[actionUID]);
emit ActionTitleUpdated(actionToOwner[actionUID], actionUID, _title);
}

/// @notice Updates the instructions for an existing action.
Expand All @@ -118,7 +143,7 @@ contract ActionRegistry is UUPSUpgradeable, OwnableUpgradeable {
) external onlyActionOwner(actionUID) {
idToAction[actionUID].instructions = _instructions;

emit ActionUpdated(actionToOwner[actionUID], actionUID, idToAction[actionUID]);
emit ActionInstructionsUpdated(actionToOwner[actionUID], actionUID, _instructions);
}

/// @notice Updates the media associated with an existing action.
Expand All @@ -127,7 +152,7 @@ contract ActionRegistry is UUPSUpgradeable, OwnableUpgradeable {
function updateActionMedia(uint256 actionUID, string[] memory _media) external onlyActionOwner(actionUID) {
idToAction[actionUID].media = _media;

emit ActionUpdated(actionToOwner[actionUID], actionUID, idToAction[actionUID]);
emit ActionMediaUpdated(actionToOwner[actionUID], actionUID, _media);
}

/// @dev Authorizes an upgrade to the contract's implementation.
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/src/tokens/Garden.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract GardenToken is ERC721Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
/// @param owner The owner of the minted Garden token.
/// @param tokenId The unique identifier of the minted Garden token.
/// @param name The name of the Garden associated with the minted token.
event GardenMinted(address indexed owner, uint256 indexed tokenId, address indexed account, string name);
event GardenMinted(address indexed owner, uint256 indexed tokenId, address indexed account);

/// @custom:oz-upgrades-unsafe-allow constructor
/// @param gardenAccountImplementation The address of the Garden account implementation.
Expand Down Expand Up @@ -56,7 +56,7 @@ contract GardenToken is ERC721Upgradeable, OwnableUpgradeable, UUPSUpgradeable {

GardenAccount(payable(gardenAccount)).initialize(communityToken, name, gardeners, gardenOperators);

emit GardenMinted(_msgSender(), tokenId, name);
emit GardenMinted(_msgSender(), tokenId, gardenAccount);

return gardenAccount;
}
Expand Down

0 comments on commit 7a2deb6

Please sign in to comment.