Skip to content

Commit

Permalink
Merge pull request #731 from clrfund/feat/maci-v1-deployer-subgraph
Browse files Browse the repository at this point in the history
Add ClrFundDeployer subgraph mapping
  • Loading branch information
yuetloo authored Mar 28, 2024
2 parents 7425c45 + 1de0fa8 commit f0073b1
Show file tree
Hide file tree
Showing 20 changed files with 993 additions and 228 deletions.
18 changes: 18 additions & 0 deletions docs/deploy-clrFundDeployer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Deploy the ClrFundDeployer contract

The ClrFundDeployer contract is used to deploy `ClrFund` instances from the [ClrFund Admin](https://github.com/clrfund/clrfund-admin).

1. Follow the steps in the [deployment guide](./deployment.md) to install the dependencies, download the zkeys, setup BrightId (if applicable), and configure the `.env` and `deploy-config.json` files in the `contracts` folder

2. Run the deployment script

Run the following command in the contracts folder. Make sure you backup the `deployed-contracts.json` file (if exists) as the following command will overwrite the file.

```sh
yarn hardhat new-deployer --verify --network {network}
```

Use the `--verify` flag to verify the newly deployed contracts. Make sure the `etherscan` API key is setup in the hardhat.config file
Use the `--incremental` flag to resume a deployment if it was interrupted due to error.
Use the `--manage-nonce` flag to let the script manually set the nonce (as opposed to getting the nonce from the node). This is useful if using testnet public node like `optimism-sepolia` where the node may occasionally give `nonce too low` error.

20 changes: 12 additions & 8 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ cp deploy-config-example.json deploy-config.json
Update the `VkRegistry.paramsDirectory` with the circuit parameter folder. If you ran the `monorepo/.github/scripts/download-6-9-2-3.sh` in the `contracts` folder, it should be `./params`.


### Run the deploy script
Use the `-h` switch to print the command line help menu for all the scripts in the `cli` folder. For hardhat help, use `yarn hardhat help`.

### Run the deployment scripts
Use `yarn hardhat help` to print the command line help menu for all available commands. Note that the following steps are for deploying a standalone ClrFund instance. To deploy an instance of the ClrFundDeployer contract, please refer to the [ClrFundDeployer Deployment Guide](./deploy-clrFundDeployer.md)

1. Deploy an instance of ClrFund

Expand Down Expand Up @@ -128,14 +127,19 @@ Currently, we are using the [Hosted Service](https://thegraph.com/docs/en/hosted

Inside `/subgraph`:

1. Prepare the `subgraph.yaml` with the correct network data
- Update or create a new JSON file which you want to use, under `/config`
1. Prepare the config file
- Under the `/config` folder, create a new JSON file or update an existing one
- If you deployed a standalone ClrFund contract, use the `xdai.json` as a template to create your config file
- If you deployed a ClrFundDeployer contract, use the `deployer-arbitrum-sepolia.json` as a template
2. Prepare the `schema.graphql` file
- Run `npx mustache <your-config-file> schema.template.graphql > schema.graphql`
2. Prepare the `subgraph.yaml` file
- Run `npx mustache <your-config-file> subgraph.template.yaml > subgraph.yaml`
2. Build:
3. Build:
- `yarn codegen`
- `yarn build`
3. Authenticate with `yarn graph auth --product hosted-service <ACCESS_TOKEN>`
4. Deploy it by running `yarn graph deploy --product hosted-service USERNAME/SUBGRAPH`
4. Authenticate with `yarn graph auth --product hosted-service <ACCESS_TOKEN>`
5. Deploy it by running `yarn graph deploy --product hosted-service USERNAME/SUBGRAPH`


### Deploy the user interface
Expand Down
237 changes: 237 additions & 0 deletions subgraph/abis/ClrFundDeployer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_clrfundTemplate",
"type": "address"
},
{
"internalType": "address",
"name": "_maciFactory",
"type": "address"
},
{
"internalType": "address",
"name": "_roundFactory",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "ClrFundAlreadyRegistered",
"type": "error"
},
{
"inputs": [],
"name": "InvalidClrFundTemplate",
"type": "error"
},
{
"inputs": [],
"name": "InvalidFundingRoundFactory",
"type": "error"
},
{
"inputs": [],
"name": "InvalidMaciFactory",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "newTemplate",
"type": "address"
}
],
"name": "NewClrfundTemplate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "newTemplate",
"type": "address"
}
],
"name": "NewFundingRoundTemplate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "clrfund",
"type": "address"
}
],
"name": "NewInstance",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "clrfund",
"type": "address"
},
{
"indexed": false,
"internalType": "string",
"name": "metadata",
"type": "string"
}
],
"name": "Register",
"type": "event"
},
{
"inputs": [],
"name": "clrfundTemplate",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "clrfunds",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "deployClrFund",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "maciFactory",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "roundFactory",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_clrfundTemplate",
"type": "address"
}
],
"name": "setClrFundTemplate",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
6 changes: 0 additions & 6 deletions subgraph/config/arbitrum-goerli.json

This file was deleted.

6 changes: 0 additions & 6 deletions subgraph/config/arbitrum-rinkeby.json

This file was deleted.

2 changes: 1 addition & 1 deletion subgraph/config/arbitrum-sepolia.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "arbitrum-sepolia",
"address": "0xEd7dD059294dE1B053B2B50Fb6A73a559219F678",
"clrFundAddress": "0xEd7dD059294dE1B053B2B50Fb6A73a559219F678",
"clrFundStartBlock": 22697290,
"recipientRegistryStartBlock": 22697290
}
2 changes: 1 addition & 1 deletion subgraph/config/arbitrum.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "arbitrum-one",
"address": "0x2e89494a8fE02891511a43f7877b726787E0C160",
"clrFundAddress": "0x2e89494a8fE02891511a43f7877b726787E0C160",
"clrFundStartBlock": 3461582,
"recipientRegistryStartBlock": 3461582
}
6 changes: 6 additions & 0 deletions subgraph/config/deployer-arbitrum-sepolia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"network": "arbitrum-sepolia",
"clrFundDeployerAddress": "0xC0F9054083D42b61C9bbA8EB3533fF3f0208C1fb",
"clrFundDeployerStartBlock": 24627080,
"recipientRegistryStartBlock": 24627080
}
6 changes: 0 additions & 6 deletions subgraph/config/goerli.json

This file was deleted.

2 changes: 1 addition & 1 deletion subgraph/config/hardhat.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "hardhat",
"address": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"clrFundAddress": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"clrFundStartBlock": 0,
"recipientRegistryStartBlock": 0
}
2 changes: 1 addition & 1 deletion subgraph/config/optimism-sepolia.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "optimism-sepolia",
"address": "0x9deB2f0A56FeCEe7ECE9B742Ab4f5Bc21A634F83",
"clrFundAddress": "0x9deB2f0A56FeCEe7ECE9B742Ab4f5Bc21A634F83",
"clrFundStartBlock": 8973710,
"recipientRegistryStartBlock": 8973710
}
2 changes: 1 addition & 1 deletion subgraph/config/xdai.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "xdai",
"address": "0x4ede8f30d9c2dc96a9d6787e9c4a478424fb960a",
"clrFundAddress": "0x4ede8f30d9c2dc96a9d6787e9c4a478424fb960a",
"clrFundStartBlock": 15217676,
"recipientRegistryStartBlock": 15217676
}
Loading

0 comments on commit f0073b1

Please sign in to comment.