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 typo in deploy/replay.ts #19

Closed
wants to merge 8 commits into from
Closed
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
10 changes: 6 additions & 4 deletions packages/evm/contracts/Yaho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ contract Yaho is IMessageDispatcher, MessageHashCalculator {
function relayMessagesToAdapters(
uint256[] memory messageIds,
address[] memory adapters,
address[] memory destinationAdapters
address[] memory destinationAdapters,
uint256 gas
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this should either be an array of gas values or if destination adapters should be a struct like this?

struct DestinationAdapter {
    address adapter,
    uint256 gas
}

The reason being that different adapters may or may not need this value, and of those that do, they may use use it for very different things.

) external payable returns (bytes32[] memory) {
if (messageIds.length == 0) revert NoMessageIdsGiven(address(this));
if (adapters.length == 0) revert NoAdaptersGiven(address(this));
if (adapters.length != destinationAdapters.length) revert UnequalArrayLengths(address(this));
bytes32[] memory adapterReciepts = new bytes32[](adapters.length);
for (uint256 i = 0; i < adapters.length; i++) {
adapterReciepts[i] = IMessageRelay(adapters[i]).relayMessages(messageIds, destinationAdapters[i]);
adapterReciepts[i] = IMessageRelay(adapters[i]).relayMessages(messageIds, destinationAdapters[i], gas);
}
return adapterReciepts;
}
Expand All @@ -59,7 +60,8 @@ contract Yaho is IMessageDispatcher, MessageHashCalculator {
function dispatchMessagesToAdapters(
Message[] memory messages,
address[] memory adapters,
address[] memory destinationAdapters
address[] memory destinationAdapters,
uint256 gas
) external payable returns (bytes32[] memory messageIds, bytes32[] memory) {
if (adapters.length == 0) revert NoAdaptersGiven(address(this));
messageIds = dispatchMessages(messages);
Expand All @@ -69,7 +71,7 @@ contract Yaho is IMessageDispatcher, MessageHashCalculator {
}
bytes32[] memory adapterReciepts = new bytes32[](adapters.length);
for (uint256 i = 0; i < adapters.length; i++) {
adapterReciepts[i] = IMessageRelay(adapters[i]).relayMessages(uintIds, destinationAdapters[i]);
adapterReciepts[i] = IMessageRelay(adapters[i]).relayMessages(uintIds, destinationAdapters[i], gas);
}
return (messageIds, adapterReciepts);
}
Expand Down
8 changes: 6 additions & 2 deletions packages/evm/contracts/adapters/AMB/AMBMessageRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ contract AMBMessageRelay is IMessageRelay {
yaho = _yaho;
}

function relayMessages(uint256[] memory messageIds, address ambAdapter) public payable returns (bytes32 receipt) {
function relayMessages(
uint256[] memory messageIds,
address ambAdapter,
uint256 gas
) public payable returns (bytes32 receipt) {
bytes32[] memory hashes = new bytes32[](messageIds.length);
for (uint256 i = 0; i < messageIds.length; i++) {
uint256 id = messageIds[i];
hashes[i] = yaho.hashes(id);
emit MessageRelayed(address(this), messageIds[i]);
}
bytes memory data = abi.encodeCall(AMBAdapter.storeHashes, (messageIds, hashes));
receipt = amb.requireToPassMessage(ambAdapter, data, 0);
receipt = amb.requireToPassMessage(ambAdapter, data, gas);
}
}
6 changes: 5 additions & 1 deletion packages/evm/contracts/interfaces/IMessageRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
pragma solidity ^0.8.17;

interface IMessageRelay {
function relayMessages(uint256[] memory messageIds, address adapter) external payable returns (bytes32 receipts);
function relayMessages(
uint256[] memory messageIds,
address adapter,
uint256 gas
) external payable returns (bytes32 receipts);
}
2 changes: 1 addition & 1 deletion packages/evm/contracts/test/MockMessageRealy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IMessageRelay } from "../interfaces/IMessageRelay.sol";
contract MockMessageRelay is IMessageRelay {
uint256 public count;

function relayMessages(uint256[] memory, address) external payable returns (bytes32 receipts) {
function relayMessages(uint256[] memory, address, uint256) external payable returns (bytes32 receipts) {
receipts = bytes32(count);
count++;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/tasks/deploy/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const deploy = async ({ networks }: { networks: string[] }, hre: HardhatR

// deploy hashi module
try {
console.log(`\x1B[4mHeader Storage\x1B[0m`)
console.log(`\x1B[4mHashi Module\x1B[0m`)
const hashiModuleFactory: HashiModule__factory = <HashiModule__factory>(
await hre.ethers.getContractFactory("HashiModule")
)
Expand Down
Loading