Skip to content

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Mar 24, 2025

Replaces #13

@Amxx Amxx requested a review from a team as a code owner March 24, 2025 09:48
@Amxx Amxx requested a review from cjcobb23 as a code owner June 25, 2025 13:53
@Amxx Amxx modified the milestone: Interoperability Jul 23, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do the same as #202 and flatten everything down to one contract.

@Amxx Amxx requested a review from frangio August 20, 2025 14:31
payload,
new bytes[](0),
toUniversalAddress(msg.sender),
targetChain,
Copy link
Contributor

@frangio frangio Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the source chain.

https://github.com/wormhole-foundation/wormhole-solidity-sdk/blob/575181b586a315d8f9813eab82e4cb98b45bc381/src/interfaces/IWormholeReceiver.sol#L48

Any reasonable way to do that in this mock? I think it should at least not be the target chain.

* @dev A contract that combines the functionality of both the source and destination gateway
* adapters for the Wormhole Network. Allowing to either send or receive messages across chains.
*
* Note: only EVM chains are currently supported
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because of address encoding?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see we're using sendPayloadToEvm.

}

/// @dev Returns whether a binary interoperable chain id is supported.
function supportedChain(bytes memory chain) public view virtual returns (bool) {
Copy link
Contributor

@frangio frangio Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's clear or intuitive that chain has to be a full interop address. I'd consider renaming the argument at least, possibly the function, and making this explicit in the documentation including a @param.

/// @dev Returns the Wormhole chain id that correspond to a given EVM chain id.
function getWormholeChain(uint256 chainId) public view virtual returns (uint16) {
uint24 wormholeId = _chainIdToWormhole[chainId];
require(wormholeId & MASK == MASK, UnsupportedChainId(chainId));
Copy link
Contributor

@frangio frangio Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check needed? Why? Please add a comment.

Makes me ask why the mapping holds uint24 chain ids since uint16 seems to be the only thing that's supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I understand now that this is necessary for | MASK because a wormhole id may be 0. I would add this in a comment on the mapping and/or the MASK variable.

}

/// @dev Relay a message that was initiated by {sendMessage}.
function requestRelay(bytes32 sendId, uint256 gasLimit, address /*refundRecipient*/) external payable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

uint256 value = msg.value;
uint256 gasLimit = 0;

for (uint256 i = 0; i < attributes.length; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This supports duplicate requestRelay attributes which we probably shouldn't...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


for (uint256 i = 0; i < attributes.length; ++i) {
(relay, value, gasLimit, ) = ERC7786Attributes.tryDecodeRequestRelayCalldata(attributes[i]);
require(relay, UnsupportedAttribute(attributes[i].length < 0x04 ? bytes4(0) : bytes4(attributes[i])));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should probably be a utility function to get the selector from a bytes calldata attribute.

if (relay) {
// TODO: Do we care about the returned "sequence"?
bytes memory encoded = abi.encode(
sendId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This will always be 0!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, we need another way to deduplicate ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants