@@ -20,6 +20,17 @@ import "../struct/GasParameters.sol";
2020
2121import "./OVM_GasPriceOracle.sol " ;
2222
23+ struct MessagingParams {
24+ uint16 version;
25+ uint256 gasLimit;
26+ uint256 gasPrice;
27+ uint16 dstEid;
28+ address sender;
29+ bytes message;
30+ bool payInLzToken;
31+ bytes options;
32+ }
33+
2334/**
2435 * @title Holograph LayerZero Module
2536 * @author https://github.com/holographxyz
@@ -142,9 +153,10 @@ contract LayerZeroModuleV2 is Admin, Initializable, CrossChainMessageInterface,
142153 /**
143154 * @dev Need to add an extra function to get LZ gas amount needed for their internal cross-chain message verification
144155 */
156+
145157 function send (
146- uint256 /* gasLimit*/ ,
147- uint256 /* gasPrice*/ ,
158+ uint256 gasLimit ,
159+ uint256 gasPrice ,
148160 uint32 toChain ,
149161 address msgSender ,
150162 uint256 msgValue ,
@@ -156,18 +168,27 @@ contract LayerZeroModuleV2 is Admin, Initializable, CrossChainMessageInterface,
156168 lZEndpoint := sload (_lZEndpointSlot)
157169 }
158170 GasParameters memory gasParameters = _gasParameters (toChain);
159- // need to recalculate the gas amounts for LZ to deliver message
171+ uint16 lzEid = uint16 (_interfaces ().getChainId (ChainIdType.HOLOGRAPH, uint256 (toChain), ChainIdType.LAYERZERO)) +
172+ 30000 ; // Adjust for V2
173+
174+ MessagingParams memory params = MessagingParams ({
175+ version: 1 ,
176+ gasLimit: gasParameters.msgBaseGas + (crossChainPayload.length * gasParameters.msgGasPerByte),
177+ gasPrice: gasPrice,
178+ dstEid: lzEid,
179+ sender: msgSender,
180+ message: crossChainPayload,
181+ payInLzToken: false ,
182+ options: ""
183+ });
184+
160185 lZEndpoint.send {value: msgValue}(
161- // uint16(_interfaces().getChainId(ChainIdType.HOLOGRAPH, uint256(toChain), ChainIdType.LAYERZERO)),
162- 40245 , // TEMPORARY: hardcoded LZ V2 chain eid for Base Sepolia
186+ params.dstEid,
163187 abi.encodePacked (address (this ), address (this )),
164- crossChainPayload ,
165- payable (msgSender ),
188+ params.message ,
189+ payable (params.sender ),
166190 address (this ),
167- abi.encodePacked (
168- uint16 (1 ),
169- uint256 (gasParameters.msgBaseGas + (crossChainPayload.length * gasParameters.msgGasPerByte))
170- )
191+ abi.encodePacked (params.version, uint256 (params.gasLimit))
171192 );
172193 }
173194
@@ -188,7 +209,7 @@ contract LayerZeroModuleV2 is Admin, Initializable, CrossChainMessageInterface,
188209 ) external view returns (uint256 hlgFee , uint256 msgFee , uint256 dstGasPrice ) {
189210 uint16 lzEid = uint16 (_interfaces ().getChainId (ChainIdType.HOLOGRAPH, uint256 (toChain), ChainIdType.LAYERZERO));
190211 uint16 lzV2Eid = lzEid + 30000 ; // 30000 is the difference between LZ V1 and LZ V2 chain eids (i.e. Ethereum eid is 101 on V1 and 30101 on V2)
191-
212+
192213 LayerZeroOverrides lZEndpoint;
193214 assembly {
194215 lZEndpoint := sload (_lZEndpointSlot)
0 commit comments