Skip to content

Commit

Permalink
feat: transfer-ownership to gnosis-safe + script
Browse files Browse the repository at this point in the history
  • Loading branch information
TravellerOnTheRun committed Dec 16, 2024
1 parent 11d4944 commit a61ece3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './ownerships'
export * from './stRifUpgradeV1-v2'
export * from './updateIpfsFolder'
export * from './withdrawTreasury'
export * from './transfer-ownership'
43 changes: 43 additions & 0 deletions tasks/transfer-ownership.ts
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)
}
})

0 comments on commit a61ece3

Please sign in to comment.