@@ -16,9 +16,8 @@ import { ReadCodecV1, EVMCallComputeV1, EVMCallRequestV1 } from "@layerzerolabs/
1616import { OAppOptionsType3 } from "@layerzerolabs/oapp-evm/contracts/oapp/libs/OAppOptionsType3.sol " ;
1717import { AddressCast } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol " ;
1818import { IXvsVault } from "../interfaces/IXvsVault.sol " ;
19- import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol " ;
2019
21- contract VotingPowerAggregator is Pausable , OAppRead , OAppOptionsType3 , Initializable {
20+ contract VotingPowerAggregator is Pausable , OAppRead , OAppOptionsType3 {
2221 using ExcessivelySafeCall for address ;
2322
2423 struct NetworkProposalBlockDetails {
@@ -154,16 +153,14 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
154153 */
155154 error LZReceiveProposalNotExists (string reason );
156155
157- constructor (address endpoint_ , address delegate ) OAppRead (endpoint_, delegate) {
158- _disableInitializers ();
159- }
160-
161- function initialize (
156+ constructor (
157+ address endpoint_ ,
158+ address delegate ,
162159 uint32 readChannel ,
163160 address warehouseAddress ,
164161 address governorBravoAddress ,
165162 address bscXvsVaultAddress
166- ) external initializer {
163+ ) OAppRead (endpoint_, delegate) {
167164 ensureNonzeroAddress (warehouseAddress);
168165 ensureNonzeroAddress (governorBravoAddress);
169166 ensureNonzeroAddress (bscXvsVaultAddress);
@@ -172,8 +169,7 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
172169 bscXvsVault = IXvsVault (bscXvsVaultAddress);
173170
174171 // Set the read channel
175- READ_CHANNEL = readChannel;
176- setReadChannel (READ_CHANNEL, true );
172+ setReadChannel (readChannel, true );
177173 }
178174
179175 /**
@@ -192,16 +188,6 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
192188 _unpause ();
193189 }
194190
195- /**
196- * @notice Sets the LayerZero read channel, enabling or disabling it based on `_active`.
197- * @param _channelId The channel ID to set.
198- * @param _active Flag to activate or deactivate the channel.
199- */
200- function setReadChannel (uint32 _channelId , bool _active ) public override onlyOwner {
201- _setPeer (_channelId, _active ? AddressCast.toBytes32 (address (this )) : bytes32 (0 ));
202- READ_CHANNEL = _channelId;
203- }
204-
205191 /**
206192 * @notice Updates the network configuration for a given chain ID.
207193 * @param remoteChainEid The chain ID for which to update the configuration.
@@ -291,7 +277,10 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
291277 }
292278 }
293279
294- proposalBlockDetails[pId][BSC_CHAIN_ID] = NetworkProposalBlockDetails (block .number - 1 , blockhash (block .number - 1 ));
280+ proposalBlockDetails[pId][BSC_CHAIN_ID] = NetworkProposalBlockDetails (
281+ block .number - 1 ,
282+ blockhash (block .number - 1 )
283+ );
295284
296285 uint96 power = getVotingPower (proposer, pId, proposerVotingProofs);
297286 if (power < proposalThreshold) {
@@ -302,7 +291,26 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
302291 }
303292
304293 /**
305- * @notice Sends a read request to LayerZero, querying Uniswap QuoterV2 for WETH/USDC prices on configured chains.
294+ * @notice Sets the LayerZero read channel, enabling or disabling it based on `_active`.
295+ * @param _channelId The channel ID to set.
296+ * @param _active Flag to activate or deactivate the channel.
297+ */
298+ function setReadChannel (uint32 _channelId , bool _active ) public override onlyOwner {
299+ _setPeer (_channelId, _active ? AddressCast.toBytes32 (address (this )) : bytes32 (0 ));
300+ READ_CHANNEL = _channelId;
301+ }
302+
303+ /**
304+ * @notice It will change the delegate in the endpoint.
305+ * @param delegate delegate is authorized by the oapp to configure anything in layerzero
306+ */
307+ function setEndpointDelegate (address delegate ) external onlyOwner {
308+ endpoint.setDelegate (delegate);
309+ }
310+
311+ /**
312+ * @notice Sends a read request to LayerZero, querying block hashes from remote chains for a given proposal.
313+ * @param proposalId Unique Id of the proposal.
306314 * @param _extraOptions Additional messaging options, including gas and fee settings.
307315 * @return receipt The LayerZero messaging receipt for the request.
308316 */
@@ -332,7 +340,10 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
332340 }
333341
334342 /**
335- * @notice Quotes the estimated messaging fee for querying Uniswap QuoterV2 for WETH/USDC prices.
343+ * @notice Quotes the estimated messaging fee for querying block hashes from remote chains for a given proposal.
344+ * @param proposalId Unique id of a proposal .
345+ * @param remoteTargetEids Array of LayerZero Endpoint ids for the target remote chains.
346+ * @param blockNumbers Array of block numbers to query hashes for on the remote chains.
336347 * @param _extraOptions Additional messaging options.
337348 * @param _payInLzToken Boolean flag indicating whether to pay in LayerZero tokens.
338349 * @return fee The estimated messaging fee.
@@ -350,6 +361,9 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
350361
351362 /**
352363 * @notice Constructs a command to query the Uniswap QuoterV2 for WETH/USDC prices on all configured chains.
364+ * @param proposalId Unique id of proposal.
365+ * @param remoteTargetEids Array of LayerZero Endpoint IDs for the target remote chains.
366+ * @param blockNumbers Array of block numbers to query hashes for on the remote chains.
353367 * @return cmd The encoded command to request Uniswap quotes.
354368 */
355369 function getCmd (
0 commit comments