@venusprotocol/governance-contracts 2.5.0-dev.1 → 2.5.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ import { ethers, network } from "hardhat";
2
+ import { DeployFunction } from "hardhat-deploy/types";
3
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
4
+ import { ACMCommandsAggregator } from "typechain";
5
+
6
+ import { SUPPORTED_NETWORKS } from "../helpers/deploy/constants";
7
+ import { guardian } from "../helpers/deploy/deploymentUtils";
8
+
9
+ const functionSignatures = {
10
+ normal: [
11
+ "setSendVersion(uint16)",
12
+ "setReceiveVersion(uint16)",
13
+ "setMaxDailyReceiveLimit(uint256)",
14
+ "pause()",
15
+ "setPrecrime(address)",
16
+ "setMinDstGas(uint16,uint16,uint256)",
17
+ "setPayloadSizeLimit(uint16,uint256)",
18
+ "setConfig(uint16,uint16,uint256,bytes)",
19
+ "addTimelocks(address[])",
20
+ "setTrustedRemoteAddress(uint16,bytes)",
21
+ "setTimelockPendingAdmin(address,uint8)",
22
+ "retryMessage(uint16,bytes,uint64,bytes)",
23
+ "setGuardian(address)",
24
+ "setSrcChainId(uint16)",
25
+ "transferBridgeOwnership(address)",
26
+ ],
27
+ fasttrack: [
28
+ "setReceiveVersion(uint16)",
29
+ "setMaxDailyReceiveLimit(uint256)",
30
+ "pause()",
31
+ "setConfig(uint16,uint16,uint256,bytes)",
32
+ "addTimelocks(address[])",
33
+ "retryMessage(uint16,bytes,uint64,bytes)",
34
+ ],
35
+ critical: [
36
+ "setReceiveVersion(uint16)",
37
+ "setMaxDailyReceiveLimit(uint256)",
38
+ "pause()",
39
+ "setConfig(uint16,uint16,uint256,bytes)",
40
+ "addTimelocks(address[])",
41
+ "retryMessage(uint16,bytes,uint64,bytes)",
42
+ ],
43
+ guardian: [
44
+ "setReceiveVersion(uint16)",
45
+ "forceResumeReceive(uint16,bytes)",
46
+ "setMaxDailyReceiveLimit(uint256)",
47
+ "pause()",
48
+ "unpause()",
49
+ "setConfig(uint16,uint16,uint256,bytes)",
50
+ "addTimelocks(address[])",
51
+ "setTrustedRemoteAddress(uint16,bytes)",
52
+ "setTimelockPendingAdmin(address,uint8)",
53
+ "retryMessage(uint16,bytes,uint64,bytes)",
54
+ "setSrcChainId(uint16)",
55
+ "transferBridgeOwnership(address)",
56
+ ],
57
+ };
58
+
59
+ const grantPermissions = (
60
+ OMNICHAIN_EXECUTOR_OWNER: string,
61
+ functionSigs: string[],
62
+ account: string,
63
+ ): ACMCommandsAggregator.PermissionStruct[] =>
64
+ functionSigs.map(functionSig => ({
65
+ contractAddress: OMNICHAIN_EXECUTOR_OWNER,
66
+ functionSig: functionSig,
67
+ account: account,
68
+ }));
69
+
70
+ const func: DeployFunction = async function () {
71
+ const NORMAL_TIMELOCK = await ethers.getContract("NormalTimelock");
72
+ const FASTTRACK_TIMELOCK = await ethers.getContract("FastTrackTimelock");
73
+ const CRITICAL_TIMELOCK = await ethers.getContract("CriticalTimelock");
74
+ const OMNICHAIN_EXECUTOR_OWNER = await ethers.getContract("OmnichainExecutorOwner");
75
+ const GUARDIAN = await guardian(network.name as SUPPORTED_NETWORKS);
76
+ const acmCommandsAggregator: ACMCommandsAggregator = await ethers.getContract("ACMCommandsAggregator");
77
+
78
+ // Grant permissions for each category
79
+ const normalGrantPermissions = grantPermissions(
80
+ OMNICHAIN_EXECUTOR_OWNER.address,
81
+ functionSignatures.normal,
82
+ NORMAL_TIMELOCK.address,
83
+ );
84
+ const fasttrackGrantPermissions = grantPermissions(
85
+ OMNICHAIN_EXECUTOR_OWNER.address,
86
+ functionSignatures.fasttrack,
87
+ FASTTRACK_TIMELOCK.address,
88
+ );
89
+ const criticalGrantPermissions = grantPermissions(
90
+ OMNICHAIN_EXECUTOR_OWNER.address,
91
+ functionSignatures.critical,
92
+ CRITICAL_TIMELOCK.address,
93
+ );
94
+ const guardianGrantPermissions = grantPermissions(
95
+ OMNICHAIN_EXECUTOR_OWNER.address,
96
+ functionSignatures.guardian,
97
+ GUARDIAN,
98
+ );
99
+
100
+ const allGrantPermissions: ACMCommandsAggregator.PermissionStruct[] = [
101
+ ...normalGrantPermissions,
102
+ ...fasttrackGrantPermissions,
103
+ ...criticalGrantPermissions,
104
+ ...guardianGrantPermissions,
105
+ ];
106
+
107
+ try {
108
+ const tx = await acmCommandsAggregator.addGrantPermissions(allGrantPermissions);
109
+
110
+ const receipt = await tx.wait();
111
+ const events = receipt.events?.filter(event => event.event === "GrantPermissionsAdded");
112
+ console.log(`Grant Permissions for ${network.name} added with indexes: `, events?.[0].args?.index.toString());
113
+ } catch (error) {
114
+ console.error("Error adding grant permissions:", error);
115
+ }
116
+ };
117
+ func.tags = ["multichain-governance-permissions"];
118
+
119
+ func.skip = async (hre: HardhatRuntimeEnvironment) =>
120
+ hre.network.name === "bsctestnet" || hre.network.name === "bscmainnet";
121
+
122
+ export default func;