Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove transceiver instructions parameter #16

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions script/cast/CastBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ contract CastBase is Script, Utils {
bytes32 refundAddress_,
uint256 value_
) internal returns (bytes32 messageId_) {
return
IHubPortal(hubPortal_).sendMTokenIndex{ value: value_ }(destinationChainId_, refundAddress_, new bytes(1));
return IHubPortal(hubPortal_).sendMTokenIndex{ value: value_ }(destinationChainId_, refundAddress_);
}

function _sendRegistrarKey(
Expand All @@ -35,13 +34,7 @@ contract CastBase is Script, Utils {
bytes32 refundAddress_,
uint256 value_
) internal returns (bytes32 messageId_) {
return
IHubPortal(hubPortal_).sendRegistrarKey{ value: value_ }(
destinationChainId_,
key_,
refundAddress_,
new bytes(1)
);
return IHubPortal(hubPortal_).sendRegistrarKey{ value: value_ }(destinationChainId_, key_, refundAddress_);
}

function _sendRegistrarListStatus(
Expand All @@ -57,8 +50,7 @@ contract CastBase is Script, Utils {
destinationChainId_,
listName_,
account_,
refundAddress_,
new bytes(1)
refundAddress_
);
}
}
24 changes: 12 additions & 12 deletions src/HubPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { TypeConverter } from "./libs/TypeConverter.sol";
*/
contract HubPortal is IHubPortal, Portal {
using TypeConverter for address;

/// @dev Use only standard WormholeTransceiver with relaying enabled
bytes public constant DEFAULT_TRANSCEIVER_INSTRUCTIONS = new bytes(1);

/* ============ Variables ============ */

/// @dev Registrar key holding value of whether the earners list can be ignored or not.
Expand Down Expand Up @@ -49,12 +53,11 @@ contract HubPortal is IHubPortal, Portal {
/// @inheritdoc IHubPortal
function sendMTokenIndex(
uint16 destinationChainId_,
bytes32 refundAddress_,
bytes memory transceiverInstructions_
bytes32 refundAddress_
) external payable returns (bytes32 messageId_) {
uint128 index_ = _currentIndex();
bytes memory payload_ = PayloadEncoder.encodeIndex(index_, destinationChainId_);
messageId_ = _sendMessage(destinationChainId_, refundAddress_, payload_, transceiverInstructions_);
messageId_ = _sendMessage(destinationChainId_, refundAddress_, payload_);

emit MTokenIndexSent(destinationChainId_, messageId_, index_);
}
Expand All @@ -63,12 +66,11 @@ contract HubPortal is IHubPortal, Portal {
function sendRegistrarKey(
uint16 destinationChainId_,
bytes32 key_,
bytes32 refundAddress_,
bytes memory transceiverInstructions_
bytes32 refundAddress_
) external payable returns (bytes32 messageId_) {
bytes32 value_ = IRegistrarLike(registrar).get(key_);
bytes memory payload_ = PayloadEncoder.encodeKey(key_, value_, destinationChainId_);
messageId_ = _sendMessage(destinationChainId_, refundAddress_, payload_, transceiverInstructions_);
messageId_ = _sendMessage(destinationChainId_, refundAddress_, payload_);

emit RegistrarKeySent(destinationChainId_, messageId_, key_, value_);
}
Expand All @@ -78,12 +80,11 @@ contract HubPortal is IHubPortal, Portal {
uint16 destinationChainId_,
bytes32 listName_,
address account_,
bytes32 refundAddress_,
bytes memory transceiverInstructions_
bytes32 refundAddress_
) external payable returns (bytes32 messageId_) {
bool status_ = IRegistrarLike(registrar).listContains(listName_, account_);
bytes memory payload_ = PayloadEncoder.encodeListUpdate(listName_, account_, status_, destinationChainId_);
messageId_ = _sendMessage(destinationChainId_, refundAddress_, payload_, transceiverInstructions_);
messageId_ = _sendMessage(destinationChainId_, refundAddress_, payload_);

emit RegistrarListStatusSent(destinationChainId_, messageId_, listName_, account_, status_);
}
Expand Down Expand Up @@ -136,8 +137,7 @@ contract HubPortal is IHubPortal, Portal {
function _sendMessage(
uint16 destinationChainId_,
bytes32 refundAddress_,
bytes memory payload_,
bytes memory transceiverInstructions_
bytes memory payload_
) private returns (bytes32 messageId_) {
if (refundAddress_ == bytes32(0)) revert InvalidRefundAddress();

Expand All @@ -146,7 +146,7 @@ contract HubPortal is IHubPortal, Portal {
TransceiverStructs.TransceiverInstruction[] memory instructions_,
uint256[] memory priceQuotes_,

) = _prepareForTransfer(destinationChainId_, transceiverInstructions_);
) = _prepareForTransfer(destinationChainId_, DEFAULT_TRANSCEIVER_INSTRUCTIONS);

TransceiverStructs.NttManagerMessage memory message_ = TransceiverStructs.NttManagerMessage(
bytes32(uint256(_useMessageSequence())),
Expand Down
15 changes: 3 additions & 12 deletions src/interfaces/IHubPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,21 @@ interface IHubPortal is IPortal {
* @notice Sends the M token index to the destination chain.
* @param destinationChainId The Wormhole destination chain ID.
* @param refundAddress Refund address to receive excess native gas.
* @param transceiverInstructions Additional instructions to be forwarded to the destination chain.
* @return ID uniquely identifying the message
*/
function sendMTokenIndex(
uint16 destinationChainId,
bytes32 refundAddress,
bytes memory transceiverInstructions
) external payable returns (bytes32);
function sendMTokenIndex(uint16 destinationChainId, bytes32 refundAddress) external payable returns (bytes32);

/**
* @notice Sends the Registrar key to the destination chain.
* @param destinationChainId The Wormhole destination chain ID.
* @param key The key to dispatch.
* @param refundAddress Refund address to receive excess native gas.
* @param transceiverInstructions Additional instructions to be forwarded to the destination chain.
* @return ID uniquely identifying the message
*/
function sendRegistrarKey(
uint16 destinationChainId,
bytes32 key,
bytes32 refundAddress,
bytes memory transceiverInstructions
bytes32 refundAddress
) external payable returns (bytes32);

/**
Expand All @@ -109,15 +102,13 @@ interface IHubPortal is IPortal {
* @param listName The name of the list.
* @param account The account.
* @param refundAddress Refund address to receive excess native gas.
* @param transceiverInstructions Additional instructions to be forwarded to the destination chain.
* @return ID uniquely identifying the message
*/
function sendRegistrarListStatus(
uint16 destinationChainId,
bytes32 listName,
address account,
bytes32 refundAddress,
bytes memory transceiverInstructions
bytes32 refundAddress
) external payable returns (bytes32);

/// @notice Enables earning for the Hub Portal if allowed by TTG.
Expand Down
17 changes: 3 additions & 14 deletions test/unit/HubPortal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ contract HubPortalTests is UnitTestBase {
emit IHubPortal.MTokenIndexSent(_REMOTE_CHAIN_ID, messageId_, index_);

vm.prank(_alice);
_portal.sendMTokenIndex{ value: fee_ }(_REMOTE_CHAIN_ID, refundAddress_, _encodedEmptyTransceiverInstructions);
_portal.sendMTokenIndex{ value: fee_ }(_REMOTE_CHAIN_ID, refundAddress_);
}

/* ============ sendRegistrarKey ============ */
Expand Down Expand Up @@ -226,12 +226,7 @@ contract HubPortalTests is UnitTestBase {
emit IHubPortal.RegistrarKeySent(_REMOTE_CHAIN_ID, messageId_, key_, value_);

vm.prank(_alice);
_portal.sendRegistrarKey{ value: fee_ }(
_REMOTE_CHAIN_ID,
key_,
refundAddress_,
_encodedEmptyTransceiverInstructions
);
_portal.sendRegistrarKey{ value: fee_ }(_REMOTE_CHAIN_ID, key_, refundAddress_);
}

/* ============ sendRegistrarListStatus ============ */
Expand Down Expand Up @@ -270,13 +265,7 @@ contract HubPortalTests is UnitTestBase {
emit IHubPortal.RegistrarListStatusSent(_REMOTE_CHAIN_ID, messageId_, listName_, account_, status_);

vm.prank(_alice);
_portal.sendRegistrarListStatus{ value: fee_ }(
_REMOTE_CHAIN_ID,
listName_,
account_,
refundAddress_,
_encodedEmptyTransceiverInstructions
);
_portal.sendRegistrarListStatus{ value: fee_ }(_REMOTE_CHAIN_ID, listName_, account_, refundAddress_);
}

/* ============ transfer ============ */
Expand Down
Loading