From c807593ac83542ebb3509b77895f02699f37e457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 12 Oct 2023 14:09:54 -0300 Subject: [PATCH] chore: deploy registry contract to arbitrum goerli MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- contracts/README.md | 11 ++++++++ contracts/addresses.json | 3 ++- contracts/hardhat.config.ts | 2 +- contracts/tasks/deploy.ts | 50 +++++++++++++++++++++++++++++-------- 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/contracts/README.md b/contracts/README.md index b67be46..420c90a 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -2,6 +2,7 @@ ## Contract Deployment +### Subscriptions contract To deploy the contract run: ```bash @@ -10,6 +11,16 @@ PRIVATE_KEY=<> hh deploy --token --network hh deploy:registry --owner --network +``` + +Note that the `--owner` flag is optional, if not passed the deployer address will be set as the contract owner. +Alternatively you can use the env var `MNEMONIC` to deploy the contract and it will pick the first derived address. + ## Tests To test the contract run: diff --git a/contracts/addresses.json b/contracts/addresses.json index 183a093..147dc09 100644 --- a/contracts/addresses.json +++ b/contracts/addresses.json @@ -3,6 +3,7 @@ "Subscriptions": "0x482f58d3513E386036670404b35cB3F2DF67a750" }, "421613": { - "Subscriptions": "0x29f49a438c747e7Dd1bfe7926b03783E47f9447B" + "Subscriptions": "0x29f49a438c747e7Dd1bfe7926b03783E47f9447B", + "Registry": "0x5cef4D079c64C2fCeE51ED7A2818aF59Ae1976cF" } } diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 4c42289..6591590 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -1,7 +1,7 @@ import {HardhatUserConfig, task} from 'hardhat/config'; import '@nomiclabs/hardhat-ethers'; import '@typechain/hardhat'; -import "@nomiclabs/hardhat-etherscan"; +import '@nomiclabs/hardhat-etherscan'; import './tasks/deploy'; task('accounts', 'Print a list of accounts', async (_, hre) => { diff --git a/contracts/tasks/deploy.ts b/contracts/tasks/deploy.ts index 23bd32e..41910d0 100644 --- a/contracts/tasks/deploy.ts +++ b/contracts/tasks/deploy.ts @@ -1,22 +1,50 @@ -import { Wallet } from 'ethers' -import { task, types } from 'hardhat/config' -import { HardhatRuntimeEnvironment } from 'hardhat/types' +import {Wallet, ethers} from 'ethers'; +import {task, types} from 'hardhat/config'; +import {HardhatRuntimeEnvironment} from 'hardhat/types'; -import { deploySubscriptions } from '../utils/deploy' +import {deploySubscriptions, deployRegistry} from '../utils/deploy'; task('deploy', 'Deploy the subscription contract (use L2 network!)') .addParam('token', 'Address of the ERC20 token') .addOptionalParam('epochSeconds', 'Epoch length in seconds.', 3, types.int) .setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => { - const accounts = await hre.ethers.getSigners() + const accounts = await hre.ethers.getSigners(); if (accounts.length === 0) { - throw new Error('No accounts available, set PRIVATE_KEY or MNEMONIC env variables') + throw new Error( + 'No accounts available, set PRIVATE_KEY or MNEMONIC env variables' + ); } - console.log('Deploying subscriptions contract with the account:', accounts[0].address); - + console.log( + 'Deploying subscriptions contract with the account:', + accounts[0].address + ); + await deploySubscriptions( [taskArgs.token, taskArgs.epochSeconds], - accounts[0] as unknown as Wallet, - ) - }) \ No newline at end of file + accounts[0] as unknown as Wallet + ); + }); + +task('deploy:registry', 'Deploy the registry contract (use L2 network!)') + .addOptionalParam('owner', 'Address of the contract owner') + .setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => { + const accounts = await hre.ethers.getSigners(); + + if (accounts.length === 0) { + throw new Error( + 'No accounts available, set PRIVATE_KEY or MNEMONIC env variables' + ); + } + console.log( + 'Deploying registry contract with the account:', + accounts[0].address + ); + + const registry = await deployRegistry(accounts[0] as unknown as Wallet); + + if (ethers.utils.isAddress(taskArgs.owner)) { + console.log(`Transferring ownership to ${taskArgs.owner}`); + await registry.connect(accounts[0]).transferOwnership(taskArgs.owner); + } + });