Skip to content

Commit

Permalink
Finalize to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
pmerkleplant committed Aug 1, 2023
1 parent 6948754 commit 88d3ef6
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[submodule "lib/chronicle-std"]
path = lib/chronicle-std
url = https://github.com/chronicleprotocol/chronicle-std
branch = v1
branch = v2
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Common Changelog](https://common-changelog.org/).

[1.0.0]: https://github.com/chronicleprotocol/greenhouse/releases/tag/v1.0.0

## [1.0.0] - 2023-08-01

### Added

- Initial release
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The contract uses [`chronicle-std/Auth`](https://github.com/chronicleprotocol/ch

Install module via Foundry:
```bash
$ forge install chronicleprotocol/greenhouse
$ forge install chronicleprotocol/greenhouse@v1
```

## Contributing
Expand Down Expand Up @@ -43,4 +43,4 @@ $ forge snapshot [--check]

## Dependencies

- [chronicleprotocol/chronicle-std@v1](https://github.com/chronicleprotocol/chronicle-std/tree/v1)
- [chronicleprotocol/chronicle-std@v2](https://github.com/chronicleprotocol/chronicle-std/tree/v2)
103 changes: 4 additions & 99 deletions script/Greenhouse.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,11 @@ import {Greenhouse} from "src/Greenhouse.sol";
* @title Greenhouse Management Script
*/
contract GreenhouseScript is Script {
/// @dev Deploys a new Greenhouse instance.
///
/// @dev Usage:
///
/// Set the following environment variables:
/// - RPC_URL : The RPC URL
/// - PRIVATE_KEY : The deployer's private key
/// - ETHERSCAN_API_KEY : An Etherscan API key
///
/// Deployment command:
///
/// ```bash
/// forge script \
/// --broadcast \
/// --rpc-url $RPC_URL \
/// --private-key $PRIVATE_KEY \
/// --etherscan-api-key $ETHERSCAN_API_KEY \
/// --verify
/// --sig "deploy()"
/// script/Greenhouse.s.sol:GreenhouseScript
/// ```
function deploy() public {
/// @dev Deploys a new Greenhouse instance with address `initialAuthed`
/// being auth'ed.
function deploy(address initialAuthed) public {
vm.startBroadcast();
IGreenhouse greenhouse = new Greenhouse();
IGreenhouse greenhouse = new Greenhouse(initialAuthed);
vm.stopBroadcast();

console2.log("Deployed at", address(greenhouse));
Expand All @@ -46,25 +27,6 @@ contract GreenhouseScript is Script {
// -- IAuth Functions --

/// @dev Grants auth to address `who`.
///
/// @dev Usage:
///
/// Set the following environment variables:
/// - RPC_URL : The RPC URL
/// - PRIVATE_KEY : The deployer's private key
/// - GREENHOUSE : The Greenhouse instance's address
/// - WHO : The address to grant auth to
///
/// Rely command:
///
/// ```bash
/// forge script \
/// --broadcast \
/// --rpc-url $RPC_URL \
/// --private-key $PRIVATE_KEY \
/// --sig $(cast calldata "rely(address,address)" $GREENHOUSE $WHO)
/// script/Greenhouse.s.sol:GreenhouseScript
/// ```
function rely(address self, address who) public {
vm.startBroadcast();
IAuth(self).rely(who);
Expand All @@ -74,25 +36,6 @@ contract GreenhouseScript is Script {
}

/// @dev Renounces auth from address `who`.
///
/// @dev Usage:
///
/// Set the following environment variables:
/// - RPC_URL : The RPC URL
/// - PRIVATE_KEY : The deployer's private key
/// - GREENHOUSE : The Greenhouse instance's address
/// - WHO : The address to renounce auth from
///
/// Deny command:
///
/// ```bash
/// forge script \
/// --broadcast \
/// --rpc-url $RPC_URL \
/// --private-key $PRIVATE_KEY \
/// --sig $(cast calldata "deny(address,address)" $GREENHOUSE $WHO)
/// script/Greenhouse.s.sol:GreenhouseScript
/// ```
function deny(address self, address who) public {
vm.startBroadcast();
IAuth(self).deny(who);
Expand All @@ -104,25 +47,6 @@ contract GreenhouseScript is Script {
// -- IToll Functions --

/// @dev Grants toll to address `who`.
///
/// @dev Usage:
///
/// Set the following environment variables:
/// - RPC_URL : The RPC URL
/// - PRIVATE_KEY : The deployer's private key
/// - GREENHOUSE : The Greenhouse instance's address
/// - WHO : The address to grant toll to
///
/// Kiss command:
///
/// ```bash
/// forge script \
/// --broadcast \
/// --rpc-url $RPC_URL \
/// --private-key $PRIVATE_KEY \
/// --sig $(cast calldata "kiss(address,address)" $GREENHOUSE $WHO)
/// script/Greenhouse.s.sol:GreenhouseScript
/// ```
function kiss(address self, address who) public {
vm.startBroadcast();
IToll(self).kiss(who);
Expand All @@ -132,25 +56,6 @@ contract GreenhouseScript is Script {
}

/// @dev Renounces toll from address `who`.
///
/// @dev Usage:
///
/// Set the following environment variables:
/// - RPC_URL : The RPC URL
/// - PRIVATE_KEY : The deployer's private key
/// - GREENHOUSE : The Greenhouse instance's address
/// - WHO : The address to renounce toll from
///
/// Diss command:
///
/// ```bash
/// forge script \
/// --broadcast \
/// --rpc-url $RPC_URL \
/// --private-key $PRIVATE_KEY \
/// --sig $(cast calldata "diss(address,address)" $GREENHOUSE $WHO)
/// script/Greenhouse.s.sol:GreenhouseScript
/// ```
function diss(address self, address who) public {
vm.startBroadcast();
IToll(self).diss(who);
Expand Down
101 changes: 101 additions & 0 deletions script/GreenhouseScript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Greenhouse Script

This document describes how to deploy and manage `Greenhouse` instances via the `Greenhouse.s.sol`'s `GreenhouseScript`.

The following environment variables are necessary for all commands:

- `RPC_URL`: The RPC URL of an EVM node
- `PRIVATE_KEY`: The private key to use

Note that foundry offers different wallet options, for more info see `$ forge script -h`.

## Deployment

Set the following environment variables:
- `ETHERSCAN_API_KEY`: The Etherscan API key for the Etherscan's chain instance
- `INITIAL_AUTHED`: The address being auth'ed on the newly deployed `Greenhouse` instance

Run:
```bash
$ forge script \
--private-key $PRIVATE_KEY \
--broadcast \
--rpc-url $RPC_URL \
--etherscan-api-key $ETHERSCAN_API_KEY \
--verify \
--sig $(cast calldata "deploy(address)" $INITIAL_AUTHED) \
-vvv \
script/Greenhouse.s.sol:GreenhouseScript
```


## Management

`Greenhouse` implements `chronicle-std`'s `Auth` and `Toll` modules which can be configured.

Set the following environment variables:
- `GREENHOUSE`: The `Greenhouse` instance's address

### `IAuth::rely`

Set the following environment variables:
- `WHO`: The address to grant auth to

Run:
```bash
$ forge script \
--private-key $PRIVATE_KEY \
--broadcast \
--rpc-url $RPC_URL \
--sig $(cast calldata "rely(address,address)" $GREENHOUSE $WHO) \
-vvv \
script/Greenhouse.s.sol:GreenhouseScript
```

### `IAuth::deny`

Set the following environment variables:
- `WHO`: The address renounce auth from

Run:
```bash
$ forge script \
--private-key $PRIVATE_KEY \
--broadcast \
--rpc-url $RPC_URL \
--sig $(cast calldata "deny(address,address)" $GREENHOUSE $WHO) \
-vvv \
script/Greenhouse.s.sol:GreenhouseScript
```

### `IToll::kiss`

Set the following environment variables:
- `WHO`: The address grant toll to

Run:
```bash
$ forge script \
--private-key $PRIVATE_KEY \
--broadcast \
--rpc-url $RPC_URL \
--sig $(cast calldata "kiss(address,address)" $GREENHOUSE $WHO) \
-vvv \
script/Greenhouse.s.sol:GreenhouseScript
```

### `IToll::diss`

Set the following environment variables:
- `WHO`: The address renounce toll from

Run:
```bash
$ forge script \
--private-key $PRIVATE_KEY \
--broadcast \
--rpc-url $RPC_URL \
--sig $(cast calldata "diss(address,address)" $GREENHOUSE $WHO) \
-vvv \
script/Greenhouse.s.sol:GreenhouseScript
```
38 changes: 19 additions & 19 deletions script/IGreenhouseChaincheck.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ import {IGreenhouse} from "src/IGreenhouse.sol";
* @notice IGreenhouse's `chaincheck` Integration Test
*
* @dev Config Definition:
* ```json
* {
* "IGreenhouse": { },
* "IAuth": {
* "legacy": bool,
* "authed": [
* "<Ethereum address>",
* ...
* ]
* },
* "IToll": {
* "legacy": bool,
* "tolled": [
* "<Ethereum address>",
* ...
* ]
* }
* }
* ```
* ```json
* {
* "IGreenhouse": { },
* "IAuth": {
* "legacy": bool,
* "authed": [
* "<Ethereum address>",
* ...
* ]
* },
* "IToll": {
* "legacy": bool,
* "tolled": [
* "<Ethereum address>",
* ...
* ]
* }
* }
* ```
*/
contract IGreenhouseChaincheck is Chaincheck {
using stdJson for string;
Expand Down
3 changes: 3 additions & 0 deletions src/Greenhouse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {LibCREATE3} from "./libs/LibCREATE3.sol";

/**
* @title Greenhouse
* @custom:version 1.0.0
*
* @notice A greenhouse to plant contracts using CREATE3
*
Expand All @@ -24,6 +25,8 @@ import {LibCREATE3} from "./libs/LibCREATE3.sol";
* contracts.
*/
contract Greenhouse is IGreenhouse, Auth, Toll {
constructor(address initialAuthed) Auth(initialAuthed) {}

/// @inheritdoc IGreenhouse
///
/// @custom:invariant Planted contract's address is deterministic and solely
Expand Down
2 changes: 1 addition & 1 deletion test/Greenhouse.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import {IGreenhouseTest} from "./IGreenhouseTest.sol";

contract GreenhouseTest is IGreenhouseTest {
function setUp() public {
setUp(address(new Greenhouse()));
setUp(address(new Greenhouse(address(this))));
}
}

0 comments on commit 88d3ef6

Please sign in to comment.