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

feat: add threshold and adapters to IJushin.onMessage & remove _setDomainThreshold from ShuSho #62

Merged
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
13 changes: 10 additions & 3 deletions packages/evm/contracts/Yaru.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ contract Yaru is IYaru, MessageIdCalculator, MessageHashCalculator, ReentrancyGu
)
) revert ThresholdNotMet();

try IJushin(message.receiver).onMessage(SOURCE_CHAIN_ID, messageId, message.sender, message.data) returns (
bytes memory returnData
) {
try
IJushin(message.receiver).onMessage(
messageId,
SOURCE_CHAIN_ID,
message.sender,
message.threshold,
message.adapters,
message.data
)
returns (bytes memory returnData) {
returnDatas[i] = returnData;
} catch {
revert CallFailed();
Expand Down
10 changes: 8 additions & 2 deletions packages/evm/contracts/interfaces/IJushin.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.0;

import { IAdapter } from "./IAdapter.sol";

/**
* @title IJushin
*/
interface IJushin {
/**
* @dev Handles the incoming message from a specified chain.
* @param sourceChainId - The ID of the origin chain from which the message originates.
* @param messageId - The unique identifier of the message.
* @param sourceChainId - The ID of the origin chain from which the message originates.
* @param sender - The address of the sender of the message on the origin chain.
* @param threshold - The minimum number of adapters required to have stored the same message.
* @param data - The data contained in the message, in bytes.
* @param adapters - An array of `IAdapter` contracts.
* @return result bytes at the user's choice
*/
function onMessage(
uint256 sourceChainId,
uint256 messageId,
uint256 sourceChainId,
address sender,
uint256 threshold,
IAdapter[] calldata adapters,
bytes calldata data
) external returns (bytes memory);
}
4 changes: 0 additions & 4 deletions packages/evm/contracts/ownable/ShuSo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,4 @@ abstract contract ShuSo is IShuSho, OwnableUpgradeable {
_domains[domain].threshold = threshold;
emit ThresholdSet(domain, threshold);
}

function _setDomainThreshold(uint256 domainId, uint256 threshold) internal {
_domains[domainId].threshold = threshold;
}
}
10 changes: 9 additions & 1 deletion packages/evm/contracts/test/PingPong.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.20;

import { IJushin } from "../interfaces/IJushin.sol";
import { IAdapter } from "../interfaces/IAdapter.sol";

contract PingPong is IJushin {
uint256 public count;
Expand All @@ -13,7 +14,14 @@ contract PingPong is IJushin {
emit Pong(count);
}

function onMessage(uint256, uint256, address, bytes calldata) external returns (bytes memory) {
function onMessage(
uint256,
uint256,
address,
uint256,
IAdapter[] calldata,
bytes calldata
) external returns (bytes memory) {
count++;
emit Pong(count);
return abi.encode(0);
Expand Down
Loading