Skip to content

Commit baae394

Browse files
committed
fix contract build
1 parent 5020a31 commit baae394

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"solidity.packageDefaultDependenciesContractsDirectory": "src",
3+
"solidity.packageDefaultDependenciesDirectory": "lib"
4+
}
5+

nitro_rpc/src/NitroRPC.sol

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
pragma solidity ^0.8.17;
33

44

5-
import {INitroTypes} from "../lib/nitro/src/interfaces/INitroTypes.sol";
6-
import {NitroUtils} from "../lib/nitro/src/libraries/NitroUtils.sol";
5+
import {INitroTypes} from "nitro/interfaces/INitroTypes.sol";
6+
import {NitroUtils} from "nitro/libraries/NitroUtils.sol";
7+
import {IForceMoveApp} from "nitro/interfaces/IForceMoveApp.sol";
78

89
/**
910
* @title NitroRPC
1011
* @dev Solidity implementation of Nitro RPC protocol structures
1112
*/
12-
interface NitroRPC {
13+
contract NitroRPC is IForceMoveApp {
1314
struct Payload {
1415
uint256 requestId;
1516
uint256 timestamp;
@@ -20,8 +21,8 @@ interface NitroRPC {
2021

2122
struct PayloadSigned {
2223
Payload rpcMessage;
23-
Signature clientSig;
24-
Signature serverSig;
24+
INitroTypes.Signature clientSig;
25+
INitroTypes.Signature serverSig;
2526
}
2627

2728
enum AllocationIndices {
@@ -37,27 +38,27 @@ interface NitroRPC {
3738
* @param candidate Recovered variable part the proof was supplied for.
3839
*/
3940
function stateIsSupported(
40-
FixedPart calldata fixedPart,
41-
RecoveredVariablePart[] calldata proof,
42-
RecoveredVariablePart calldata candidate
41+
INitroTypes.FixedPart calldata fixedPart,
42+
INitroTypes.RecoveredVariablePart[] calldata proof,
43+
INitroTypes.RecoveredVariablePart calldata candidate
4344
) external pure override returns (bool, string memory) {
4445
require(fixedPart.participants.length == uint256(AllocationIndices.Server) + 1, "bad number of participants");
4546

4647
PayloadSigned memory payloadSigned = abi.decode(candidate.variablePart.appData, (PayloadSigned));
47-
requireValidPayload(payloadSigned);
48+
requireValidPayload(fixedPart, payloadSigned);
4849

4950
return (true, "");
5051
}
5152

52-
function requireValidPayload(PayloadSigned memory payloadSigned) internal pure {
53-
require(recoverPayloadSigner(payloadSigned.rpcMessage, payloadSigned.clientSig) == fixedPart.participants[AllocationIndices.Client], "bad client signature");
54-
require(recoverPayloadSigner(payloadSigned.rpcMessage, payloadSigned.serverSig) == fixedPart.participants[AllocationIndices.Server], "bad server signature");
53+
function requireValidPayload(INitroTypes.FixedPart calldata fixedPart, PayloadSigned memory payloadSigned) internal pure {
54+
require(recoverPayloadSigner(payloadSigned.rpcMessage, payloadSigned.clientSig) == fixedPart.participants[uint256(AllocationIndices.Client)], "bad client signature");
55+
require(recoverPayloadSigner(payloadSigned.rpcMessage, payloadSigned.serverSig) == fixedPart.participants[uint256(AllocationIndices.Server)], "bad server signature");
5556

5657
// TODO: verify timestamp and requestId
5758
}
5859

5960
// This pure internal function recovers the signer address from the payload and its signature.
60-
function recoverPayloadSigner(Payload memory payload, Signature memory signature) internal pure returns (address) {
61+
function recoverPayloadSigner(Payload memory payload, INitroTypes.Signature memory signature) internal pure returns (address) {
6162
// Encode and hash the payload data.
6263
// Using abi.encode ensures proper padding and decoding, avoiding potential ambiguities with dynamic types.
6364
bytes32 messageHash = keccak256(

0 commit comments

Comments
 (0)