|
| 1 | +import { ContractTransactionReceipt } from "ethers"; |
1 | 2 | import { ethers } from "hardhat";
|
2 | 3 |
|
3 | 4 | import { loadContract } from "lib/contract";
|
@@ -36,107 +37,135 @@ export async function main() {
|
36 | 37 | const stakingRouterAdmin = testnetAdmin;
|
37 | 38 | const withdrawalQueueAdmin = testnetAdmin;
|
38 | 39 |
|
| 40 | + const waitTransactionsGroup: Promise<ContractTransactionReceipt>[] = []; |
| 41 | + |
39 | 42 | // Initialize NodeOperatorsRegistry
|
40 | 43 |
|
41 | 44 | // https://github.com/ethereum/solidity-examples/blob/master/docs/bytes/Bytes.md#description
|
42 | 45 | const encodeStakingModuleTypeId = (stakingModuleTypeId: string): string =>
|
43 | 46 | "0x" + ethers.AbiCoder.defaultAbiCoder().encode(["string"], [stakingModuleTypeId]).slice(-64);
|
44 | 47 |
|
45 | 48 | const nodeOperatorsRegistry = await loadContract("NodeOperatorsRegistry", nodeOperatorsRegistryAddress);
|
46 |
| - await makeTx( |
47 |
| - nodeOperatorsRegistry, |
48 |
| - "initialize", |
49 |
| - [ |
50 |
| - lidoLocatorAddress, |
51 |
| - encodeStakingModuleTypeId(nodeOperatorsRegistryParams.stakingModuleTypeId), |
52 |
| - nodeOperatorsRegistryParams.stuckPenaltyDelay, |
53 |
| - ], |
54 |
| - { from: deployer }, |
| 49 | + waitTransactionsGroup.push( |
| 50 | + makeTx( |
| 51 | + nodeOperatorsRegistry, |
| 52 | + "initialize", |
| 53 | + [ |
| 54 | + lidoLocatorAddress, |
| 55 | + encodeStakingModuleTypeId(nodeOperatorsRegistryParams.stakingModuleTypeId), |
| 56 | + nodeOperatorsRegistryParams.stuckPenaltyDelay, |
| 57 | + ], |
| 58 | + { from: deployer }, |
| 59 | + ), |
55 | 60 | );
|
56 | 61 |
|
57 | 62 | const simpleDvtRegistry = await loadContract("NodeOperatorsRegistry", simpleDvtRegistryAddress);
|
58 |
| - await makeTx( |
59 |
| - simpleDvtRegistry, |
60 |
| - "initialize", |
61 |
| - [ |
62 |
| - lidoLocatorAddress, |
63 |
| - encodeStakingModuleTypeId(simpleDvtRegistryParams.stakingModuleTypeId), |
64 |
| - simpleDvtRegistryParams.stuckPenaltyDelay, |
65 |
| - ], |
66 |
| - { from: deployer }, |
| 63 | + waitTransactionsGroup.push( |
| 64 | + makeTx( |
| 65 | + simpleDvtRegistry, |
| 66 | + "initialize", |
| 67 | + [ |
| 68 | + lidoLocatorAddress, |
| 69 | + encodeStakingModuleTypeId(simpleDvtRegistryParams.stakingModuleTypeId), |
| 70 | + simpleDvtRegistryParams.stuckPenaltyDelay, |
| 71 | + ], |
| 72 | + { from: deployer }, |
| 73 | + ), |
67 | 74 | );
|
68 | 75 |
|
69 | 76 | // Initialize Lido
|
70 | 77 | const bootstrapInitBalance = 10n; // wei
|
71 | 78 | const lido = await loadContract("Lido", lidoAddress);
|
72 |
| - await makeTx(lido, "initialize", [lidoLocatorAddress, eip712StETHAddress], { |
73 |
| - value: bootstrapInitBalance, |
74 |
| - from: deployer, |
75 |
| - }); |
| 79 | + waitTransactionsGroup.push( |
| 80 | + makeTx(lido, "initialize", [lidoLocatorAddress, eip712StETHAddress], { |
| 81 | + value: bootstrapInitBalance, |
| 82 | + from: deployer, |
| 83 | + }), |
| 84 | + ); |
76 | 85 |
|
77 | 86 | // Initialize LegacyOracle
|
78 | 87 | const legacyOracle = await loadContract("LegacyOracle", legacyOracleAddress);
|
79 |
| - await makeTx(legacyOracle, "initialize", [lidoLocatorAddress, hashConsensusForAccountingAddress], { from: deployer }); |
| 88 | + waitTransactionsGroup.push( |
| 89 | + makeTx(legacyOracle, "initialize", [lidoLocatorAddress, hashConsensusForAccountingAddress], { |
| 90 | + from: deployer, |
| 91 | + }), |
| 92 | + ); |
80 | 93 |
|
81 | 94 | const zeroLastProcessingRefSlot = 0;
|
82 | 95 |
|
83 | 96 | // Initialize AccountingOracle
|
84 | 97 | const accountingOracle = await loadContract("AccountingOracle", accountingOracleAddress);
|
85 |
| - await makeTx( |
86 |
| - accountingOracle, |
87 |
| - "initializeWithoutMigration", |
88 |
| - [ |
89 |
| - accountingOracleAdmin, |
90 |
| - hashConsensusForAccountingAddress, |
91 |
| - accountingOracleParams.consensusVersion, |
92 |
| - zeroLastProcessingRefSlot, |
93 |
| - ], |
94 |
| - { from: deployer }, |
| 98 | + waitTransactionsGroup.push( |
| 99 | + makeTx( |
| 100 | + accountingOracle, |
| 101 | + "initializeWithoutMigration", |
| 102 | + [ |
| 103 | + accountingOracleAdmin, |
| 104 | + hashConsensusForAccountingAddress, |
| 105 | + accountingOracleParams.consensusVersion, |
| 106 | + zeroLastProcessingRefSlot, |
| 107 | + ], |
| 108 | + { from: deployer }, |
| 109 | + ), |
95 | 110 | );
|
96 | 111 |
|
97 | 112 | // Initialize ValidatorsExitBusOracle
|
98 | 113 | const validatorsExitBusOracle = await loadContract("ValidatorsExitBusOracle", ValidatorsExitBusOracleAddress);
|
99 |
| - await makeTx( |
100 |
| - validatorsExitBusOracle, |
101 |
| - "initialize", |
102 |
| - [ |
103 |
| - exitBusOracleAdmin, |
104 |
| - hashConsensusForValidatorsExitBusOracleAddress, |
105 |
| - validatorsExitBusOracleParams.consensusVersion, |
106 |
| - zeroLastProcessingRefSlot, |
107 |
| - ], |
108 |
| - { from: deployer }, |
| 114 | + waitTransactionsGroup.push( |
| 115 | + makeTx( |
| 116 | + validatorsExitBusOracle, |
| 117 | + "initialize", |
| 118 | + [ |
| 119 | + exitBusOracleAdmin, |
| 120 | + hashConsensusForValidatorsExitBusOracleAddress, |
| 121 | + validatorsExitBusOracleParams.consensusVersion, |
| 122 | + zeroLastProcessingRefSlot, |
| 123 | + ], |
| 124 | + { from: deployer }, |
| 125 | + ), |
109 | 126 | );
|
110 | 127 |
|
111 | 128 | // Initialize WithdrawalQueue
|
112 | 129 | const withdrawalQueue = await loadContract("WithdrawalQueueERC721", withdrawalQueueAddress);
|
113 |
| - await makeTx(withdrawalQueue, "initialize", [withdrawalQueueAdmin], { from: deployer }); |
| 130 | + waitTransactionsGroup.push(makeTx(withdrawalQueue, "initialize", [withdrawalQueueAdmin], { from: deployer })); |
114 | 131 |
|
115 | 132 | // Set WithdrawalQueue base URI if provided
|
116 | 133 | const withdrawalQueueBaseUri = state["withdrawalQueueERC721"].deployParameters.baseUri;
|
117 | 134 | if (withdrawalQueueBaseUri !== null && withdrawalQueueBaseUri !== "") {
|
118 | 135 | const MANAGE_TOKEN_URI_ROLE = await withdrawalQueue.getFunction("MANAGE_TOKEN_URI_ROLE")();
|
119 |
| - await makeTx(withdrawalQueue, "grantRole", [MANAGE_TOKEN_URI_ROLE, deployer], { from: deployer }); |
120 |
| - await makeTx(withdrawalQueue, "setBaseURI", [withdrawalQueueBaseUri], { from: deployer }); |
121 |
| - await makeTx(withdrawalQueue, "renounceRole", [MANAGE_TOKEN_URI_ROLE, deployer], { from: deployer }); |
| 136 | + waitTransactionsGroup.push( |
| 137 | + makeTx(withdrawalQueue, "grantRole", [MANAGE_TOKEN_URI_ROLE, deployer], { from: deployer }), |
| 138 | + ); |
| 139 | + waitTransactionsGroup.push(makeTx(withdrawalQueue, "setBaseURI", [withdrawalQueueBaseUri], { from: deployer })); |
| 140 | + waitTransactionsGroup.push( |
| 141 | + makeTx(withdrawalQueue, "renounceRole", [MANAGE_TOKEN_URI_ROLE, deployer], { from: deployer }), |
| 142 | + ); |
122 | 143 | }
|
123 | 144 |
|
124 | 145 | // Initialize StakingRouter
|
125 | 146 | const withdrawalCredentials = `0x010000000000000000000000${withdrawalVaultAddress.slice(2)}`;
|
126 | 147 | const stakingRouter = await loadContract("StakingRouter", stakingRouterAddress);
|
127 |
| - await makeTx(stakingRouter, "initialize", [stakingRouterAdmin, lidoAddress, withdrawalCredentials], { |
128 |
| - from: deployer, |
129 |
| - }); |
| 148 | + waitTransactionsGroup.push( |
| 149 | + makeTx(stakingRouter, "initialize", [stakingRouterAdmin, lidoAddress, withdrawalCredentials], { |
| 150 | + from: deployer, |
| 151 | + }), |
| 152 | + ); |
130 | 153 |
|
131 | 154 | // Set OracleDaemonConfig parameters
|
132 | 155 | const oracleDaemonConfig = await loadContract("OracleDaemonConfig", oracleDaemonConfigAddress);
|
133 | 156 | const CONFIG_MANAGER_ROLE = await oracleDaemonConfig.getFunction("CONFIG_MANAGER_ROLE")();
|
134 | 157 | await makeTx(oracleDaemonConfig, "grantRole", [CONFIG_MANAGER_ROLE, testnetAdmin], { from: testnetAdmin });
|
135 | 158 |
|
136 | 159 | // Set each parameter in the OracleDaemonConfig
|
137 |
| - for (const [key, value] of Object.entries(state.oracleDaemonConfig.deployParameters)) { |
138 |
| - await makeTx(oracleDaemonConfig, "set", [key, en0x(value as number)], { from: deployer }); |
139 |
| - } |
| 160 | + const txPromises = Object.entries(state.oracleDaemonConfig.deployParameters).map(([key, value]) => { |
| 161 | + return makeTx(oracleDaemonConfig, "set", [key, en0x(value as number)], { from: deployer }); |
| 162 | + }); |
| 163 | + |
| 164 | + await Promise.all(txPromises); |
| 165 | + |
| 166 | + waitTransactionsGroup.push( |
| 167 | + makeTx(oracleDaemonConfig, "renounceRole", [CONFIG_MANAGER_ROLE, testnetAdmin], { from: testnetAdmin }), |
| 168 | + ); |
140 | 169 |
|
141 |
| - await makeTx(oracleDaemonConfig, "renounceRole", [CONFIG_MANAGER_ROLE, testnetAdmin], { from: testnetAdmin }); |
| 170 | + await Promise.all(waitTransactionsGroup); |
142 | 171 | }
|
0 commit comments