Skip to content

Commit

Permalink
use modern syntax for fn selector
Browse files Browse the repository at this point in the history
  • Loading branch information
geoknee committed Nov 6, 2024
1 parent fa87c86 commit ddeab4b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/InteropPow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ interface IInteropPoW {
event AllResults(bytes results);
}

interface IWorker {
function run(uint256 returnDestination, address returnAddress) external;
}

contract InteropPoW is IInteropPoW {
IL2ToL2CrossDomainMessenger xdm = IL2ToL2CrossDomainMessenger(0x4200000000000000000000000000000000000023);
address target; // TODO this should be the Worker contract, same address on all chains
Expand All @@ -23,8 +27,8 @@ contract InteropPoW is IInteropPoW {

function runOnChain(uint256 chainId) public {
// prepare the x-domain message
bytes4 selector = bytes4(keccak256("run(uint256,address)"));
bytes memory data = abi.encodeWithSelector(selector, block.chainid, this);
bytes memory data =
abi.encodeWithSelector(IL2ToL2CrossDomainMessenger.sendMessage.selector, block.chainid, this);

// send the x-domain message
xdm.sendMessage(chainId, target, data);
Expand All @@ -42,10 +46,6 @@ contract InteropPoW is IInteropPoW {
}
}

interface IWorker {
function run(uint256 returnDestination, address returnAddress) external;
}

contract Worker is IWorker {
IL2ToL2CrossDomainMessenger xdm = IL2ToL2CrossDomainMessenger(0x4200000000000000000000000000000000000023);
bytes32 constant difficulty = bytes32(uint256(2 ** 250 - 1));
Expand All @@ -55,8 +55,7 @@ contract Worker is IWorker {
bytes memory results = compute();

// Prepare the X-domain message
bytes4 selector = bytes4(keccak256("sendMessage(uint256,address,bytes)"));
bytes memory data = abi.encodeWithSelector(selector, results);
bytes memory data = abi.encodeWithSelector(IL2ToL2CrossDomainMessenger.sendMessage.selector, results);

// Send the X-domain message
xdm.sendMessage(returnDestination, returnAddress, data);
Expand Down

0 comments on commit ddeab4b

Please sign in to comment.