Skip to content

Commit

Permalink
feat: transfer ownership of messengers
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbn committed Aug 19, 2021
1 parent 4766d64 commit a7552bf
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 20 deletions.
1 change: 0 additions & 1 deletion exported-data/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const develop = {
MessengerRegistry: '0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66',
PeriodRegistry: '0x9b1f7F645351AF3631a656421eD2e40f2802E6c0',
StakeRegistry: '0xA57B8a5584442B467b4689F1144D269d096A3daF',
Details: '0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC',
PreCoordinator: '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7',
StringUtils: '0x0290FB167208Af455bB137780163b7B7a9a10C16',
DSLAToken: '0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab.json',
Expand Down
1 change: 0 additions & 1 deletion exported-data/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const ethereum = {
MessengerRegistry: '0x2208A83ac05A9c284f147d3d415C5b9C4810a833',
PeriodRegistry: '0xEe5359f02FA1A4D0CB212706b85BF76adA7447AA',
StakeRegistry: '0x9F22934D07e68e6b20a4096407E3D5c849FBC62e',
Details: '0xCf50b7bd3f42C847042B88c763fBF523852b114F',
PreCoordinator: '0xD33181E6B30a4d09971926B4CfCE03967d3b2650',
StringUtils: '0x6Dc1147ca16C020579642D90042CeA252474fD67',
DSLAToken: '0x3aFfCCa64c2A6f4e3B6Bd9c64CD2C969EFd1ECBe.json',
Expand Down
1 change: 0 additions & 1 deletion exported-data/harmony.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const harmony = {
MessengerRegistry: '0x551264EBEdd316A173680Ea956dB0a7cE2864682',
PeriodRegistry: '0x96f6620265d3f206f221990e5c9160D82428A862',
StakeRegistry: '0xcfbEF648380D891D7037A8da1741fc7Af64053e1',
Details: '0xd3AD8e22C96Fa8Cc7328A15B31d7f384fcC12616',
PreCoordinator: '0x6879fdACa49e6c1daF9e0FE0919650b124728cfB',
StringUtils: '0x9B86Fd872f5E6b29171796F4591F9Ab279fE7A1b',
DSLAToken: '0x34704c70e9eC9fB9A921da6DAAD7D3e19f43c734.json',
Expand Down
4 changes: 4 additions & 0 deletions exported-data/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { develop } from './develop';
export { ethereum } from './ethereum';
export { harmony } from './harmony';
export { polygon } from './polygon';
export { rinkeby } from './rinkeby';
1 change: 0 additions & 1 deletion exported-data/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const polygon = {
MessengerRegistry: '0xB4E5ea2F77F63514365Cbe901f0ad2E5159fBB2D',
PeriodRegistry: '0x8B87CCC1A4E0485691BD173D1c96cd1f84e4f436',
StakeRegistry: '0x700CEf3A4F86C7D3724584723061A43554b297ab',
Details: '0x8f1bF86471E941Af29d5D8025bd68e6CB401CA8a',
PreCoordinator: '0x444a01A89D979B87c5A132C166316252D190CC68',
StringUtils: '0x22f67aA9b3F079066c55e32990F83Bfa889c6756',
DSLAToken: '0xa0E390e9ceA0D0e8cd40048ced9fA9EA10D71639.json',
Expand Down
1 change: 0 additions & 1 deletion exported-data/rinkeby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const rinkeby = {
MessengerRegistry: '0x45D5E52AFB831a56B7c667222522c944f797A858',
PeriodRegistry: '0x3E89f98519D9577A9370D9fbd74d642EEf733915',
StakeRegistry: '0x598C8BeD2fA8d82959550DD82d9C942B917B9b99',
Details: '0xcf260a4c94a5DC28Ef70e802C1C37a2112F76094',
PreCoordinator: '0xa9303c679996781177DC1D1173Da0c81Cd236789',
StringUtils: '0x3800DD5fDbDC4A9013cAC87ef0e2590B891624d4',
DSLAToken: '0x973f2ECb8c7585061854e22628d9b1d972aED2aF.json',
Expand Down
12 changes: 6 additions & 6 deletions networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { NETWORKS } from '../constants';

export const networks = [
{ name: NETWORKS.DEVELOP, enabled: true, exportable: true },
{ name: NETWORKS.KOVAN, enabled: false, exportable: true },
{ name: NETWORKS.MUMBAI, enabled: false, exportable: false },
{ name: NETWORKS.HARMONYTESTNET, enabled: false, exportable: false },
{ name: NETWORKS.ETHEREUM, enabled: false, exportable: true },
{ name: NETWORKS.KOVAN, enabled: true, exportable: true },
{ name: NETWORKS.MUMBAI, enabled: true, exportable: false },
{ name: NETWORKS.HARMONYTESTNET, enabled: true, exportable: false },
{ name: NETWORKS.ETHEREUM, enabled: true, exportable: true },
{ name: NETWORKS.HARMONY, enabled: true, exportable: true },
{ name: NETWORKS.POLYGON, enabled: false, exportable: false },
{ name: NETWORKS.RINKEBY, enabled: false, exportable: true },
{ name: NETWORKS.POLYGON, enabled: true, exportable: false },
{ name: NETWORKS.RINKEBY, enabled: true, exportable: true },
];
4 changes: 2 additions & 2 deletions networks/polygon.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ if (error) {

export const polygon: NetworkUserConfig = {
chainId: 137,
gasPrice: 50 * 10 ** 9,
gas: 19000000,
gasPrice: 200 * 10 ** 9,
gas: 10000000,
accounts: [process.env.PRIV_KEY],
// accounts: {
// mnemonic: process.env.MAINNET_MNEMONIC,
Expand Down
35 changes: 28 additions & 7 deletions subtasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export enum SUB_TASK_NAMES {
PROVIDER_WITHDRAW = 'PROVIDER_WITHDRAW',
UNLOCK_TOKENS = 'UNLOCK_TOKENS',
GET_SLA_FROM_TX = 'GET_SLA_FROM_TX',
GET_TOKEN_BALANCES = 'GET_TOKEN_BALANCES',
}

subtask(SUB_TASK_NAMES.GET_SLA_FROM_TX, undefined).setAction(
Expand Down Expand Up @@ -669,9 +670,6 @@ subtask(SUB_TASK_NAMES.EXPORT_NETWORKS, undefined).setAction(
`${appRoot}/deployments/${network}/StakeRegistry.json`
)
);
const Details = JSON.parse(
fs.readFileSync(`${appRoot}/deployments/${network}/Details.json`)
);
const PreCoordinator = JSON.parse(
fs.readFileSync(
`${appRoot}/deployments/${network}/PreCoordinator.json`
Expand All @@ -687,7 +685,6 @@ subtask(SUB_TASK_NAMES.EXPORT_NETWORKS, undefined).setAction(
MessengerRegistry: MessengerRegistry.address,
PeriodRegistry: PeriodRegistry.address,
StakeRegistry: StakeRegistry.address,
Details: Details.address,
PreCoordinator: PreCoordinator.address,
StringUtils: StringUtils.address,
...tokens.reduce(
Expand Down Expand Up @@ -1702,6 +1699,7 @@ subtask(SUB_TASK_NAMES.CHECK_CONTRACTS_ALLOWANCE, undefined).setAction(
let allowance = await token.allowance(owner, contract.address);
console.log('Allowance: ' + fromWei(allowance.toString()));
const ownerBalance = await token.balanceOf(owner);
console.log('Allower address: ' + owner);
console.log('Allower balance: ' + fromWei(ownerBalance.toString()));
}
}
Expand Down Expand Up @@ -1989,7 +1987,9 @@ subtask(SUB_TASK_NAMES.GET_MESSENGER, undefined).setAction(

subtask(SUB_TASK_NAMES.TRANSFER_OWNERSHIP, undefined).setAction(
async (taskArgs, hre: HardhatRuntimeEnvironment) => {
const { ethers } = hre;
const { ethers, network, getNamedAccounts } = hre;
const { stacktical } = network.config;
const { deployer } = await getNamedAccounts();
const periodRegistry = <PeriodRegistry>(
await ethers.getContract(CONTRACT_NAMES.PeriodRegistry)
);
Expand All @@ -2003,7 +2003,7 @@ subtask(SUB_TASK_NAMES.TRANSFER_OWNERSHIP, undefined).setAction(
consola.info('StakeRegistry owner address:', stakeRegistryOwner);
consola.info('New owner address:', newOwner);
let tx;
if (newOwner !== periodRegistryOwner) {
if (newOwner !== periodRegistryOwner && periodRegistryOwner === deployer) {
printSeparator();
consola.info('Transferring PeriodRegistry ownership');
tx = await periodRegistry.transferOwnership(newOwner);
Expand All @@ -2014,7 +2014,7 @@ subtask(SUB_TASK_NAMES.TRANSFER_OWNERSHIP, undefined).setAction(
await periodRegistry.owner()
);
}
if (newOwner !== stakeRegistryOwner) {
if (newOwner !== stakeRegistryOwner && stakeRegistryOwner === deployer) {
printSeparator();
consola.info('Transferring StakeRegistry ownership');
tx = await stakeRegistry.transferOwnership(newOwner);
Expand All @@ -2025,6 +2025,27 @@ subtask(SUB_TASK_NAMES.TRANSFER_OWNERSHIP, undefined).setAction(
);
consola.info(tx);
}

for (let messenger of stacktical.messengers) {
const messengerContract: IMessenger = await ethers.getContract(
messenger.contract
);
const messengerOwner = await messengerContract.owner();
consola.info(`${messenger.useCaseName} owner: ${messengerOwner}`);
if (newOwner !== messengerOwner && messengerOwner === deployer) {
printSeparator();
consola.info(
`Transferring ${messenger.useCaseName} messenger ownership`
);
tx = await messengerContract.transferOwnership(newOwner);
await tx.wait();
consola.success(
`${messenger.useCaseName} ownership successfully transferred, new owner: `,
await messengerContract.owner()
);
consola.info(tx);
}
}
printSeparator();
}
);
Expand Down

0 comments on commit a7552bf

Please sign in to comment.