-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add deployment script for Nio governance contracts and update NioElection initialization to accept owner address. * Update migration script to correct contract address storage and adjust salt calculation for NioGovernor deployment. * Add vm.broadcast call before deploying NioGovernor contract in migration script for better deployment tracking. * Add new JSON files for Nio governance broadcast and update addresses.json with new contract addresses for AccessManager, NioElection, NioGovernor, and NioGuardians. * Refactor: Improve readability by reformatting long lines in 138-nio-governance.s.sol for better code clarity. * Add migration script for transferring treasury ownership and update constants with NIO roles and execution delay. * Refactor migration script for better readability by adjusting spacing and line breaks in function calls. * Add slither annotations to disable uninitialized-state warnings for rateLimit, costLimit, and globalRateLimit mappings.
- Loading branch information
Showing
10 changed files
with
1,990 additions
and
2 deletions.
There are no files selected for viewing
472 changes: 472 additions & 0 deletions
472
broadcast/138-nio-governance.s.sol/7887/run-1729791297.json
Large diffs are not rendered by default.
Oops, something went wrong.
472 changes: 472 additions & 0 deletions
472
broadcast/138-nio-governance.s.sol/7887/run-latest.json
Large diffs are not rendered by default.
Oops, something went wrong.
446 changes: 446 additions & 0 deletions
446
broadcast/139-transfer-treasury-ownership.s.sol/7887/run-1729806576.json
Large diffs are not rendered by default.
Oops, something went wrong.
446 changes: 446 additions & 0 deletions
446
broadcast/139-transfer-treasury-ownership.s.sol/7887/run-latest.json
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
import {NioElection} from "@kinto-core/governance/NioElection.sol"; | ||
import {NioGuardians} from "@kinto-core/tokens/NioGuardians.sol"; | ||
import {BridgedKinto} from "@kinto-core/tokens/bridged/BridgedKinto.sol"; | ||
import {UUPSProxy} from "@kinto-core-test/helpers/UUPSProxy.sol"; | ||
import {AccessManager} from "@openzeppelin-5.0.1/contracts/access/manager/AccessManager.sol"; | ||
import {NioGovernor} from "@kinto-core/governance/NioGovernor.sol"; | ||
import {IKintoID} from "@kinto-core/interfaces/IKintoID.sol"; | ||
|
||
import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; | ||
|
||
contract DeployScript is MigrationHelper { | ||
function run() public override { | ||
super.run(); | ||
|
||
(bytes32 salt, address expectedAddress) = mineSalt( | ||
keccak256(abi.encodePacked(type(NioGuardians).creationCode, abi.encode(kintoAdminWallet))), "010000" | ||
); | ||
|
||
vm.broadcast(deployerPrivateKey); | ||
NioGuardians nioNFT = new NioGuardians{salt: salt}(address(kintoAdminWallet)); | ||
|
||
assertEq(address(nioNFT), address(expectedAddress)); | ||
assertEq(nioNFT.owner(), address(kintoAdminWallet)); | ||
|
||
saveContractAddress("NioGuardians", address(nioNFT)); | ||
|
||
vm.broadcast(deployerPrivateKey); | ||
NioElection election = new NioElection{salt: 0}( | ||
BridgedKinto(_getChainDeployment("KINTO")), nioNFT, IKintoID(_getChainDeployment("KintoID")) | ||
); | ||
|
||
assertEq(address(election.kToken()), _getChainDeployment("KINTO")); | ||
assertEq(address(election.nioNFT()), address(nioNFT)); | ||
assertEq(address(election.kintoID()), _getChainDeployment("KintoID")); | ||
|
||
saveContractAddress("NioElectionV1-impl", address(election)); | ||
|
||
(salt, expectedAddress) = | ||
mineSalt(keccak256(abi.encodePacked(type(UUPSProxy).creationCode, abi.encode(election, ""))), "010E1E"); | ||
|
||
vm.broadcast(deployerPrivateKey); | ||
address proxy = address(new UUPSProxy{salt: salt}(address(election), "")); | ||
|
||
assertEq(proxy, address(expectedAddress)); | ||
|
||
_whitelistApp(proxy); | ||
|
||
_handleOps(abi.encodeWithSelector(NioElection.initialize.selector, kintoAdminWallet), proxy); | ||
|
||
assertEq(NioElection(proxy).owner(), kintoAdminWallet); | ||
|
||
saveContractAddress("NioElection", proxy); | ||
|
||
(salt, expectedAddress) = mineSalt( | ||
keccak256(abi.encodePacked(type(AccessManager).creationCode, abi.encode(kintoAdminWallet))), "ACC000" | ||
); | ||
|
||
vm.broadcast(deployerPrivateKey); | ||
AccessManager accessManager = new AccessManager{salt: salt}(kintoAdminWallet); | ||
|
||
assertEq(address(accessManager), address(expectedAddress)); | ||
(bool isMember,) = accessManager.hasRole(0, kintoAdminWallet); | ||
assertTrue(isMember); | ||
|
||
saveContractAddress("AccessManager", address(accessManager)); | ||
|
||
(salt, expectedAddress) = mineSalt( | ||
keccak256(abi.encodePacked(type(NioGovernor).creationCode, abi.encode(nioNFT, accessManager))), "010600" | ||
); | ||
vm.broadcast(deployerPrivateKey); | ||
NioGovernor governor = new NioGovernor{salt: salt}(nioNFT, address(accessManager)); | ||
assertEq(address(governor), address(expectedAddress)); | ||
|
||
assertEq(governor.quorum(block.number), 5); | ||
assertEq(governor.proposalThreshold(), 1); | ||
|
||
saveContractAddress("NioGovernor", address(governor)); | ||
} | ||
} |
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,60 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
import {Treasury} from "@kinto-core/treasury/Treasury.sol"; | ||
import {NioElection} from "@kinto-core/governance/NioElection.sol"; | ||
import {NioGuardians} from "@kinto-core/tokens/NioGuardians.sol"; | ||
import {BridgedKinto} from "@kinto-core/tokens/bridged/BridgedKinto.sol"; | ||
import {UUPSProxy} from "@kinto-core-test/helpers/UUPSProxy.sol"; | ||
import {AccessManager} from "@openzeppelin-5.0.1/contracts/access/manager/AccessManager.sol"; | ||
import {Ownable} from "@openzeppelin-5.0.1/contracts/access/Ownable.sol"; | ||
import {NioGovernor} from "@kinto-core/governance/NioGovernor.sol"; | ||
import {IKintoID} from "@kinto-core/interfaces/IKintoID.sol"; | ||
|
||
import {MigrationHelper} from "@kinto-core-script/utils/MigrationHelper.sol"; | ||
|
||
contract DeployScript is MigrationHelper { | ||
function run() public override { | ||
super.run(); | ||
|
||
AccessManager accessManager = AccessManager(_getChainDeployment("AccessManager")); | ||
address treasury = _getChainDeployment("Treasury"); | ||
address governor = _getChainDeployment("NioGovernor "); | ||
|
||
_whitelistApp(address(accessManager)); | ||
|
||
bytes4[] memory selectors = new bytes4[](3); | ||
selectors[0] = Treasury.sendFunds.selector; | ||
selectors[1] = Treasury.sendETH.selector; | ||
selectors[2] = Treasury.batchSendFunds.selector; | ||
|
||
_handleOps( | ||
abi.encodeWithSelector(AccessManager.setTargetFunctionRole.selector, treasury, selectors, NIO_GOVERNOR_ROLE), | ||
address(accessManager) | ||
); | ||
|
||
_handleOps( | ||
abi.encodeWithSelector( | ||
AccessManager.grantRole.selector, NIO_GOVERNOR_ROLE, governor, uint32(NIO_EXECUTION_DELAY) | ||
), | ||
address(accessManager) | ||
); | ||
|
||
_handleOps( | ||
abi.encodeWithSelector(AccessManager.labelRole.selector, NIO_GOVERNOR_ROLE, "NIO_GOVERNOR_ROLE"), | ||
address(accessManager) | ||
); | ||
|
||
_handleOps(abi.encodeWithSelector(Ownable.transferOwnership.selector, accessManager), address(treasury)); | ||
|
||
assertEq(Treasury(payable(treasury)).owner(), address(accessManager)); | ||
|
||
(bool immediate, uint32 delay) = accessManager.canCall(governor, treasury, Treasury.sendFunds.selector); | ||
assertFalse(immediate); | ||
assertEq(delay, NIO_EXECUTION_DELAY); | ||
|
||
(bool isMember, uint32 currentDelay) = accessManager.hasRole(NIO_GOVERNOR_ROLE, governor); | ||
assertTrue(isMember); | ||
assertEq(currentDelay, NIO_EXECUTION_DELAY); | ||
} | ||
} |
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
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