diff --git a/.github/workflows/mantle_finalize_round.yml b/.github/workflows/mantle_finalize_round.yml index 1298cd77c..0ccf766d7 100644 --- a/.github/workflows/mantle_finalize_round.yml +++ b/.github/workflows/mantle_finalize_round.yml @@ -22,7 +22,6 @@ on: env: NODE_VERSION: 16.x - NETWORK: "arbitrum-goerli" COORDINATOR_ETH_PK: ${{ secrets.MANTLE_TESTNET_COORDINATOR_WALLET_PRIVATE_KEY }} COORDINATOR_PK: ${{ secrets.MANTLE_TESTNET_COORDINATOR_MACI_PRIVATE_KEY }} @@ -69,8 +68,8 @@ jobs: echo "MACI_START_BLOCK:" $MACI_START_BLOCK # tally and finalize cd contracts - yarn hardhat tally --round-address "${ROUND_ADDRESS}" --network "${NETWORK}" + yarn hardhat tally --round-address "${ROUND_ADDRESS}" --network "${{ github.event.inputs.network }}" curl --location --request POST 'https://api.pinata.cloud/pinning/pinFileToIPFS' \ --header "Authorization: Bearer ${{ secrets.PINATA_JWT }}" \ --form 'file=@"tally.json"' - yarn hardhat run --network "${NETWORK}" scripts/finalize.ts + yarn hardhat run --network "${{ github.event.inputs.network }}" scripts/finalize.ts diff --git a/.github/workflows/mantle_new_recipient_registry.yml b/.github/workflows/mantle_new_recipient_registry.yml new file mode 100644 index 000000000..d2d65b8e9 --- /dev/null +++ b/.github/workflows/mantle_new_recipient_registry.yml @@ -0,0 +1,43 @@ +name: Mantle testnet - New Recipient Registry + +on: + workflow_dispatch: + inputs: + branch_name: + description: 'Clrfund branch name' + required: true + default: 'cohort/EthSingapore' + factory: + description: 'Clrfund factory address' + required: true + default: '0x006f39E6a6D15323334Be1db34C73088550BB20a' + network: + description: 'Network' + required: true + default: 'mantle-testnet' + +env: + NODE_VERSION: 16.x + WALLET_PRIVATE_KEY: ${{ secrets.MANTLE_TESTNET_COORDINATOR_WALLET_PRIVATE_KEY }} + +jobs: + new-recipient-registry: + runs-on: ubuntu-22.04 + steps: + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Checkout source code + uses: actions/checkout@v3 + - name: Build CLR + run: | + yarn && yarn build + - name: Create new recipient registry + run: | + cd contracts + export FACTORY_ADDRESS="${{ github.event.inputs.factory }}" + yarn hardhat deploy-recipient-registry \ + --network "${{ github.event.inputs.network }}" \ + --factory "${{ github.event.inputs.factory }}" \ + --type "optimistic" diff --git a/contracts/tasks/deployRecipientRegistry.ts b/contracts/tasks/deployRecipientRegistry.ts new file mode 100644 index 000000000..0a8662585 --- /dev/null +++ b/contracts/tasks/deployRecipientRegistry.ts @@ -0,0 +1,76 @@ +/** + * Deploy a new recipient registry + * + * Sample usage: + * + * yarn hardhat deploy-recipient-registry \ + * --network arbitrum-goerli \ + * --factory 0x85802c7871e7e778Ec376F097b56BD7299250b8D \ + * --type optimistic + */ +import { task, types } from 'hardhat/config' +import { Contract } from 'ethers' + +// Number.MAX_SAFE_INTEGER - 1 +const challengePeriodSeconds = 9007199254740990 + +task('deploy-recipient-registry', 'Deploy a new recipient registry') + .addParam('factory', 'The funding round factory contract address') + .addParam( + 'type', + 'The recipient registry type, e.g. simple, optimistic', + 'optimistic' + ) + .addOptionalParam( + 'deposit', + 'The base deposit for optimistic recipient registry', + '0.001' + ) + .addOptionalParam( + 'challengePeriod', + 'The challenge period in seconds for optimistic recipient registry', + challengePeriodSeconds, + types.int + ) + .setAction( + async ({ factory, type, deposit, challengePeriod }, { ethers }) => { + const [deployer] = await ethers.getSigners() + const fundingRoundFactory = await ethers.getContractAt( + 'FundingRoundFactory', + factory + ) + + let recipientRegistry: Contract + if (type === 'simple') { + const SimpleRecipientRegistry = await ethers.getContractFactory( + 'SimpleRecipientRegistry', + deployer + ) + recipientRegistry = await SimpleRecipientRegistry.deploy( + fundingRoundFactory.address + ) + } else if (type === 'optimistic') { + const OptimisticRecipientRegistry = await ethers.getContractFactory( + 'OptimisticRecipientRegistry', + deployer + ) + recipientRegistry = await OptimisticRecipientRegistry.deploy( + ethers.utils.parseUnits(deposit), + challengePeriod, + fundingRoundFactory.address + ) + } else { + throw new Error('unsupported recipient registry type') + } + + await recipientRegistry.deployTransaction.wait() + console.log(`Recipient registry deployed: ${recipientRegistry.address}`) + + const setRecipientRegistryTx = + await fundingRoundFactory.setRecipientRegistry( + recipientRegistry.address + ) + await setRecipientRegistryTx.wait() + console.log('Done!') + } + )