Skip to content

Commit

Permalink
fix(contracts): make releaseValueToRecipient internal (#4989)
Browse files Browse the repository at this point in the history
### Description

- partially fixes
chainlight-io/2024-08-hyperlane#1

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
  • Loading branch information
aroralanuk authored Dec 13, 2024
1 parent fd20bb1 commit 0eb8d52
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-eyes-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/core': minor
---

Made releaseValueToRecipient internal
32 changes: 16 additions & 16 deletions solidity/contracts/isms/hook/AbstractMessageIdAuthorizedIsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,13 @@ abstract contract AbstractMessageIdAuthorizedIsm is
) external virtual returns (bool) {
bool verified = isVerified(message);
if (verified) {
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
}
return verified;
}

// ============ Public Functions ============

/**
* @notice Release the value to the recipient if the message is verified.
* @param message Message to release value for.
*/
function releaseValueToRecipient(bytes calldata message) public {
bytes32 messageId = message.id();
uint256 _msgValue = verifiedMessages[messageId].clearBit(
VERIFIED_MASK_INDEX
);
if (_msgValue > 0) {
verifiedMessages[messageId] -= _msgValue;
payable(message.recipientAddress()).sendValue(_msgValue);
}
}

/**
* @notice Check if a message is verified through preVerifyMessage first.
* @param message Message to check.
Expand Down Expand Up @@ -138,6 +123,21 @@ abstract contract AbstractMessageIdAuthorizedIsm is

// ============ Internal Functions ============

/**
* @notice Release the value to the recipient if the message is verified.
* @param message Message to release value for.
*/
function _releaseValueToRecipient(bytes calldata message) internal {
bytes32 messageId = message.id();
uint256 _msgValue = verifiedMessages[messageId].clearBit(
VERIFIED_MASK_INDEX
);
if (_msgValue > 0) {
verifiedMessages[messageId] -= _msgValue;
payable(message.recipientAddress()).sendValue(_msgValue);
}
}

/**
* @notice Check if sender is authorized to message `preVerifyMessage`.
*/
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/isms/hook/ArbL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract ArbL2ToL1Ism is
_verifyWithOutboxCall(metadata, message);
require(isVerified(message), "ArbL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/isms/hook/OPL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ contract OPL2ToL1Ism is
_verifyWithPortalCall(metadata, message);
require(isVerified(message), "OPL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
return true;
}

Expand Down

0 comments on commit 0eb8d52

Please sign in to comment.