Skip to content

Commit

Permalink
🧹audit reviews (#1299)
Browse files Browse the repository at this point in the history
Signed-off-by: shankar <[email protected]>
  • Loading branch information
shankars99 authored Feb 18, 2025
1 parent dc8ed45 commit 42a069b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/oft-alt/test/foundry/MyOFTAlt.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ contract MyOFTAltTest is TestHelperOz5 {
vm.startPrank(userA);
nativeTokenMock_A.mint(userA, quoteFee.nativeFee);
IERC20(nativeTokenMock_A).approve(address(aOFT), quoteFee.nativeFee);
(MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) = aOFT.send{ value: quoteFee.nativeFee }(
(MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) = aOFT.send(
sendParam,
quoteFee,
payable(address(this))
Expand Down
8 changes: 6 additions & 2 deletions packages/oapp-alt-evm/contracts/oapp/OAppSenderAlt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ abstract contract OAppSenderAlt is OAppSender {
// Additional error messages for the OAppSenderAlt contract.
error NativeTokenUnavailable();

address public immutable nativeToken;

constructor() {
nativeToken = endpoint.nativeToken();
}

/**
* @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message.
* @param _dstEid The destination endpoint ID.
Expand Down Expand Up @@ -59,8 +65,6 @@ abstract contract OAppSenderAlt is OAppSender {
* @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time.
*/
function _payNative(uint256 _nativeFee) internal override returns (uint256 nativeFee) {
// @dev Cannot cache the token because it is not immutable in the endpoint.
address nativeToken = endpoint.nativeToken();
if (nativeToken == address(0)) revert NativeTokenUnavailable();

// Pay Native token fee by sending tokens to the endpoint.
Expand Down
6 changes: 5 additions & 1 deletion packages/oft-alt-evm/contracts/OFTAltCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ abstract contract OFTAltCore is IOFT, OAppAlt, OAppPreCrimeSimulator, OAppOption
SendParam calldata _sendParam,
MessagingFee calldata _fee,
address _refundAddress
) external payable virtual returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) {
) external payable virtual override returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) {
if (msg.value > 0) {
revert("OFTAltCore::send does not take msg.value. msg.value should be 0");
}

return _send(_sendParam, _fee, _refundAddress);
}

Expand Down
12 changes: 7 additions & 5 deletions packages/oft-alt-evm/test/OFTAlt.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ contract OFTAltTest is TestHelperOz5 {
)
);



// config and wire the ofts
address[] memory ofts = new address[](3);
ofts[0] = address(aOFT);
Expand Down Expand Up @@ -224,7 +222,7 @@ contract OFTAltTest is TestHelperOz5 {
vm.startPrank(userA);
nativeTokenMock_A.mint(userA, quoteFee.nativeFee);
IERC20(nativeTokenMock_A).approve(address(aOFT), quoteFee.nativeFee);
(MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) = aOFT.send{ value: quoteFee.nativeFee }(
(MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) = aOFT.send(
sendParam,
quoteFee,
payable(address(this))
Expand Down Expand Up @@ -267,7 +265,8 @@ contract OFTAltTest is TestHelperOz5 {
amountCreditLD,
abi.encodePacked(addressToBytes32(msg.sender), composeMsg)
);
(uint64 nonce_, uint32 srcEid_, uint256 amountCreditLD_, bytes32 composeFrom_, bytes memory composeMsg_) = this.decodeOFTComposeMsgCodec(message);
(uint64 nonce_, uint32 srcEid_, uint256 amountCreditLD_, bytes32 composeFrom_, bytes memory composeMsg_) = this
.decodeOFTComposeMsgCodec(message);

assertEq(nonce_, nonce);
assertEq(srcEid_, srcEid);
Expand Down Expand Up @@ -318,7 +317,10 @@ contract OFTAltTest is TestHelperOz5 {
}

function test_toLD(uint64 amountSD) public {
assertEq(amountSD * OFTAltMock(address(aOFT)).decimalConversionRate(), aOFT.asOFTAltMock().toLD(uint64(amountSD)));
assertEq(
amountSD * OFTAltMock(address(aOFT)).decimalConversionRate(),
aOFT.asOFTAltMock().toLD(uint64(amountSD))
);
}

function test_toSD(uint256 amountLD) public {
Expand Down

0 comments on commit 42a069b

Please sign in to comment.