-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: transfer-ownership to gnosis-safe + script
- Loading branch information
1 parent
11d4944
commit a61ece3
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { task } from 'hardhat/config' | ||
|
||
interface Params { | ||
owner: string | ||
to: string | ||
} | ||
|
||
task('transfer-ownership') | ||
.addParam('to') | ||
.setAction(async ({ to }: Params, hre) => { | ||
try { | ||
const toParam = to.toLowerCase() | ||
const isCorrect = hre.ethers.isAddress(toParam) | ||
console.log('TO', toParam, isCorrect) | ||
if (!isCorrect || toParam === hre.ethers.ZeroAddress) { | ||
throw new Error('To parameter is supposed to be real address') | ||
} | ||
const account0 = (await hre.ethers.getSigners())[0] | ||
console.log('account0', account0) | ||
|
||
// make sure you set the correct address | ||
const governor = await hre.ethers.getContractAt( | ||
'GovernorRootstockCollective', | ||
'0x2109FF4a9D5548a21F877cA937Ac5847Fde49694', | ||
) | ||
|
||
const owner = await governor.owner() | ||
console.log('OWNER', owner) | ||
|
||
if (owner !== account0.address) { | ||
throw new Error('Operation cannot be performed') | ||
} | ||
|
||
const tx = await governor.transferOwnership(toParam) | ||
const receipt = await tx.wait() | ||
|
||
const newOwner = await governor.owner() | ||
console.log('OPERATION SUCCESS', receipt) | ||
console.log('NEW OWNER', newOwner) | ||
} catch (err) { | ||
console.log('ERROR OCCURED WHEN TRANSFERRING OWNERSHIP', err) | ||
} | ||
}) |