forked from aragon/osx-plugin-template-hardhat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved over and adapted multisig script
- Loading branch information
1 parent
a76ae73
commit a997fe8
Showing
9 changed files
with
318 additions
and
215 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
111 changes: 111 additions & 0 deletions
111
packages/contracts/deploy/40_conclude/41_transfer_ownership.ts
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,111 @@ | ||
import {findPluginRepo, getManagementDao} from '../../utils/helpers'; | ||
import { | ||
DAO_PERMISSIONS, | ||
Operation, | ||
PERMISSION_MANAGER_FLAGS, | ||
PLUGIN_REPO_PERMISSIONS, | ||
} from '@aragon/osx-commons-sdk'; | ||
import {DAOStructs} from '@aragon/osx-ethers'; | ||
import {DeployFunction} from 'hardhat-deploy/types'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
import path from 'path'; | ||
|
||
/** | ||
* Creates a plugin repo under Aragon's ENS base domain with subdomain requested in the `./plugin-settings.ts` file. | ||
* @param {HardhatRuntimeEnvironment} hre | ||
*/ | ||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
// Get PluginRepo | ||
const {pluginRepo, ensDomain} = await findPluginRepo(hre); | ||
if (pluginRepo === null) { | ||
throw `PluginRepo '${ensDomain}' does not exist yet.`; | ||
} | ||
|
||
// Get the management DAO address | ||
const managementDao = await getManagementDao(hre); | ||
const [deployer] = await hre.ethers.getSigners(); | ||
|
||
console.log( | ||
`Transferring ownership of the '${ensDomain}' plugin repo at '${pluginRepo.address}' from the deployer '${deployer.address}' to the management DAO at '${managementDao.address}'...` | ||
); | ||
|
||
const permissions: DAOStructs.MultiTargetPermissionStruct[] = [ | ||
// Grant to the managment DAO | ||
{ | ||
operation: Operation.Grant, | ||
where: pluginRepo.address, | ||
who: managementDao.address, | ||
condition: PERMISSION_MANAGER_FLAGS.NO_CONDITION, | ||
permissionId: PLUGIN_REPO_PERMISSIONS.MAINTAINER_PERMISSION_ID, | ||
}, | ||
{ | ||
operation: Operation.Grant, | ||
where: pluginRepo.address, | ||
who: managementDao.address, | ||
condition: PERMISSION_MANAGER_FLAGS.NO_CONDITION, | ||
permissionId: PLUGIN_REPO_PERMISSIONS.UPGRADE_REPO_PERMISSION_ID, | ||
}, | ||
{ | ||
operation: Operation.Grant, | ||
where: pluginRepo.address, | ||
who: managementDao.address, | ||
condition: PERMISSION_MANAGER_FLAGS.NO_CONDITION, | ||
permissionId: DAO_PERMISSIONS.ROOT_PERMISSION_ID, | ||
}, | ||
// Revoke from deployer | ||
{ | ||
operation: Operation.Revoke, | ||
where: pluginRepo.address, | ||
who: deployer.address, | ||
condition: PERMISSION_MANAGER_FLAGS.NO_CONDITION, | ||
permissionId: PLUGIN_REPO_PERMISSIONS.MAINTAINER_PERMISSION_ID, | ||
}, | ||
{ | ||
operation: Operation.Revoke, | ||
where: pluginRepo.address, | ||
who: deployer.address, | ||
condition: PERMISSION_MANAGER_FLAGS.NO_CONDITION, | ||
permissionId: PLUGIN_REPO_PERMISSIONS.UPGRADE_REPO_PERMISSION_ID, | ||
}, | ||
{ | ||
operation: Operation.Revoke, | ||
where: pluginRepo.address, | ||
who: deployer.address, | ||
condition: PERMISSION_MANAGER_FLAGS.NO_CONDITION, | ||
permissionId: DAO_PERMISSIONS.ROOT_PERMISSION_ID, | ||
}, | ||
]; | ||
|
||
await pluginRepo.connect(deployer).applyMultiTargetPermissions(permissions); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['TransferOwnershipToManagmentDao']; | ||
|
||
/** | ||
* Skips the transfer of ownership if it has already been transferred to the management DAO | ||
* @param {HardhatRuntimeEnvironment} hre | ||
*/ | ||
func.skip = async (hre: HardhatRuntimeEnvironment) => { | ||
console.log(`\n🏗️ ${path.basename(__filename)}:`); | ||
|
||
const {pluginRepo, ensDomain} = await findPluginRepo(hre); | ||
if (pluginRepo === null) { | ||
throw `PluginRepo '${ensDomain}' does not exist yet.`; | ||
} | ||
const managementDao = await getManagementDao(hre); | ||
|
||
const mgmtDaoHasRootPerm = await pluginRepo.isGranted( | ||
pluginRepo.address, | ||
managementDao.address, | ||
DAO_PERMISSIONS.ROOT_PERMISSION_ID, | ||
[] | ||
); | ||
|
||
if (mgmtDaoHasRootPerm) | ||
console.log( | ||
`The ownership of the plugin repo '${ensDomain}' has already been transferred to the management DAO. Skipping...` | ||
); | ||
|
||
return mgmtDaoHasRootPerm; | ||
}; |
File renamed without changes.
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
Oops, something went wrong.