Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:greenpill-dev-guild/green-goods
Browse files Browse the repository at this point in the history
  • Loading branch information
Oba-One committed Jan 6, 2025
2 parents 38410ea + 7bfcb57 commit 39b2473
Show file tree
Hide file tree
Showing 21 changed files with 592 additions and 391 deletions.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@0no-co/graphqlsp": "^1.12.12",
"daisyui": "4.12.10",
"@eslint/js": "^9.9.0",
"@tanstack/eslint-plugin-query": "5.52.0",
"@tailwindcss/forms": "^0.5.7",
Expand All @@ -45,6 +43,7 @@
"@vercel/node": "3.2.10",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"daisyui": "4.12.10",
"dotenv-expand": "11.0.6",
"eslint": "^9.9.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
Expand Down
13 changes: 1 addition & 12 deletions packages/client/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,7 @@
"noFallthroughCasesInSwitch": true,

/* Plugins */
"plugins": [
{
"name": "@0no-co/graphqlsp",
"schema": "https://easscan.org/graphql",
"tadaOutputLocation": "src/types/eas.d.ts"
}
// {
// "name": "@0no-co/graphqlsp",
// "schema": "../../indexer/schema.graphql",
// "tadaOutputLocation": "src/types/gg-indexer.d.ts"
// }
]
"plugins": []
},
"include": ["vite.config.ts", "api", "../../indexer/schema.graphql"]
}
12 changes: 7 additions & 5 deletions packages/contracts/script/DeployActionRegistry.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ contract DeployActionRegistry is Script {
vm.startBroadcast();
ActionRegistry newRegistry = new ActionRegistry{ salt: SALT }();

Capital[] memory capitals = new Capital[](1);
Capital[] memory capitals = new Capital[](3);
capitals[0] = Capital.LIVING;
capitals[1] = Capital.CULTURAL;
capitals[2] = Capital.SOCIAL;

string[] memory observeMedia = new string[](3);
observeMedia[0] = "QmVvKqpnfJm8UwRq9SF15V2jgJ86yCBsmMBmpEaoQU92bD";
Expand All @@ -38,16 +40,16 @@ contract DeployActionRegistry is Script {
newRegistry.initialize(address(this));
newRegistry.registerAction(
block.timestamp,
block.timestamp + 30 days,
"Observe",
block.timestamp + 27 days,
"Identify Plants",
"QmX8rLExs7TDGPNAg9w22R8iYeRUYsrkkLg6LUUK8oNDUJ",
capitals,
observeMedia
);
newRegistry.registerAction(
block.timestamp,
block.timestamp + 30 days,
"Plant",
block.timestamp + 27 days,
"Plant Seedlings",
"QmZGJBdZeCVx7S42KqovzUhwrGhqwxVCaoofzUE2YRhb2s",
capitals,
plantMedia
Expand Down
8 changes: 6 additions & 2 deletions packages/contracts/script/DeployGardenToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,26 @@ contract DeployGardenToken is Script {
console.log("GardenToken deployed at:", token);

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

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

gardenAccount = gardenToken.mintGarden(
communityToken,
"Root Planet",
"Observing invasive species and planting natives to improve biodiversity.",
"Rio Claro, S\u00e3o Paulo",
"bafybeie6wzt62apqp57vtpdtkuth6cakc5ir64nfzd3jpjpmw36r3hbriq",
gardeners,
gardenOperators
);
Expand Down
12 changes: 6 additions & 6 deletions packages/contracts/src/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ pragma solidity ^0.8.25;

// GREEN GOODS
address constant GREEN_GOODS_SAFE = 0x1B9Ac97Ea62f69521A14cbe6F45eb24aD6612C19;
address constant ACTION_REGISTRY = 0x9AF3D5Bb1a6d057B99A4948420c5d24ff1e482Ce;
address constant WORK_RESOLVER = 0x4d394ec4dcDC93e451a27C9c9D915Baee9D43A78;
address constant WORK_APPROVAL_RESOLVER = 0xAD93d365C83784F245780d914460D60cBa11d1FA;
address constant ACTION_REGISTRY = 0x933b88Ef33a25d14a68354C88b2eb31e475cd482;
address constant WORK_RESOLVER = 0x1cdDfe922FC92F692bA7db69A2D451d874449c9c;
address constant WORK_APPROVAL_RESOLVER = 0x63279204b744C4fDb7dbE8331F6b13D7F8344a1d;
address constant COMMUNITY_TOKEN_ARBITRUM = 0x633d825006E4c659b061db7FB9378eDEe8bd95f3;
address constant COMMUNITY_TOKEN_SEPOLIA = 0x4cB67033da4FD849a552A4C5553E7F532B93E516;

address constant GARDEN_TOKEN = 0x9EF896a314B7aE98609eC0c0cA43724C768046B4;
address constant GARDEN_ACCOUNT_IMPLEMENTATION = 0x0E69cFBF71cc21490f25c0b61dc833d16BBd4634;
address constant ROOT_PLANET_GARDEN = 0xa9Cb249a3B651Ce82bf9E9cc48BCF41957647F48;
address constant GARDEN_TOKEN = 0x508198C3f071987D5eEb0030825628F9B10c6037;
address constant GARDEN_ACCOUNT_IMPLEMENTATION = 0x83287652b4e1514e101a4053c9bcAFf6a24d051C;
address constant ROOT_PLANET_GARDEN = 0x55fdFb60fb07fCe2Dc8A7CC3ED8a6f1C793FeE68;

// TOKENBOUND (FUTURE PRIMTIVE)
bytes32 constant SALT = 0x6551655165516551655165516551655165516551655165516551655165516551;
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/Schemas.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

struct AsessmentSchema {
struct AssessmentSchema {
string title;
string[] media;
}
Expand Down
10 changes: 9 additions & 1 deletion packages/contracts/src/accounts/Garden.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ contract GardenAccount is AccountV3Upgradable, Initializable {
/// @notice The description of the garden.
string public description;

// TODO: Add banner image property
/// @notice The location of the garden.
string public location;

/// @notice The URL of the banner image of the garden.
string public bannerImage;

/// @notice Mapping of gardener addresses to their status.
mapping(address gardener => bool isGardener) public gardeners;
Expand Down Expand Up @@ -100,12 +104,16 @@ contract GardenAccount is AccountV3Upgradable, Initializable {
address _communityToken,
string calldata _name,
string calldata _description,
string calldata _location,
string calldata _bannerImage,
address[] calldata _gardeners,
address[] calldata _gardenOperators
) external initializer {
communityToken = _communityToken;
name = _name;
description = _description;
location = _location;
bannerImage = _bannerImage;

gardeners[_msgSender()] = true;
gardenOperators[_msgSender()] = true;
Expand Down
21 changes: 17 additions & 4 deletions packages/contracts/src/registries/Action.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,22 @@ 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.
/// @param timestamp The timestamp of the registration.
event ActionRegistered(address indexed owner, uint256 indexed actionUID, Action indexed action, uint256 timestamp);
/// @param startTime The start time of the action.
/// @param endTime The end time of the action.
/// @param title The title of the action.
/// @param instructions The instructions of the action.
/// @param capitals The capitals of the action.
/// @param media The media of the action.
event ActionRegistered(
address owner,
uint256 indexed actionUID,
uint256 indexed startTime,
uint256 indexed endTime,
string title,
string instructions,
Capital[] capitals,
string[] media
);

/// @notice Emitted when an existing action is start time is updated.
/// @param owner The address of the action owner.
Expand Down Expand Up @@ -106,7 +119,7 @@ contract ActionRegistry is UUPSUpgradeable, OwnableUpgradeable {
actionToOwner[actionUID] = _msgSender();
idToAction[actionUID] = Action(_startTime, _endTime, _title, _instructions, _capitals, _media);

emit ActionRegistered(_msgSender(), actionUID, idToAction[actionUID], block.timestamp);
emit ActionRegistered(_msgSender(), actionUID, _startTime, _endTime, _title, _instructions, _capitals, _media);
}

/// @notice Updates the start time of an existing action.
Expand Down
32 changes: 28 additions & 4 deletions packages/contracts/src/tokens/Garden.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,24 @@ contract GardenToken is ERC721Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
address private _gardenAccountImplementation;

/// @notice Emitted when a new Garden is minted.
/// @param owner The owner of the minted Garden token.
/// @param tokenId The unique identifier of the minted Garden token.
/// @param account The address of the associated Garden account.
event GardenMinted(address indexed owner, uint256 indexed tokenId, address indexed account);
/// @param name The name of the Garden.
/// @param description The description of the Garden.
/// @param location The location of the Garden.
/// @param bannerImage The URL of the banner image of the Garden.
/// @param gardeners An array of addresses representing the gardeners of the Garden.
/// @param gardenOperators An array of addresses representing the operators of the Garden.
event GardenMinted(
uint256 indexed tokenId,
address indexed account,
string name,
string description,
string location,
string bannerImage,
address[] gardeners,
address[] gardenOperators
);

/// @custom:oz-upgrades-unsafe-allow constructor
/// @param gardenAccountImplementation The address of the Garden account implementation.
Expand Down Expand Up @@ -48,6 +62,8 @@ contract GardenToken is ERC721Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
address communityToken,
string calldata name,
string calldata description,
string calldata location,
string calldata bannerImage,
address[] calldata gardeners,
address[] calldata gardenOperators
) external onlyOwner returns (address) {
Expand All @@ -56,9 +72,17 @@ contract GardenToken is ERC721Upgradeable, OwnableUpgradeable, UUPSUpgradeable {

address gardenAccount = TBALib.createAccount(_gardenAccountImplementation, address(this), tokenId);

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

emit GardenMinted(_msgSender(), tokenId, gardenAccount);
emit GardenMinted(tokenId, gardenAccount, name, description, location, bannerImage, gardeners, gardenOperators);

return gardenAccount;
}
Expand Down
10 changes: 9 additions & 1 deletion packages/contracts/test/GardenAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ contract GardenAccountTest is Test {
gardeners[0] = address(0x100);
gardenOperators[0] = address(0x200);

gardenAccount.initialize(address(0x555), "Test Garden", "Test Description", gardeners, gardenOperators);
gardenAccount.initialize(
address(0x555),
"Test Garden",
"Test Description",
"Test Location",
"",
gardeners,
gardenOperators
);
}

function testInitialize() public {
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/test/WorkApprovalResolver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ contract WorkApprovalResolverTest is Test {
address(0x555),
"Test Garden",
"Test Description",
"Test Location",
"",
new address[](0),
new address[](0)
);
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/test/WorkResolver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ contract WorkResolverTest is Test {
address(0x545),
"Test Garden",
"Test Description",
"Test Location",
"",
new address[](0),
new address[](0)
);
Expand Down
4 changes: 2 additions & 2 deletions packages/indexer/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ networks:
start_block: 242630858
contracts:
- name: ActionRegistry
address: 0x9AF3D5Bb1a6d057B99A4948420c5d24ff1e482Ce
address: 0x933b88Ef33a25d14a68354C88b2eb31e475cd482
- name: GardenToken
address: 0xf226185e4e76d05EC2cbb9BF1B04e67E25532ecA
address: 0x508198C3f071987D5eEb0030825628F9B10c6037
4 changes: 2 additions & 2 deletions packages/indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"dependencies": {
"chai": "4.3.10",
"envio": "2.1.0",
"ethers": "6.8.0"
"envio": "2.11.6",
"ethers": "6.13.5"
},
"optionalDependencies": {
"generated": "./generated"
Expand Down
Loading

0 comments on commit 39b2473

Please sign in to comment.