-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathModifiedMockClient.sol
34 lines (30 loc) · 1.35 KB
/
ModifiedMockClient.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.9;
import "../../../../contracts/clients/MockClient.sol";
/**
* @dev ModifiedMockClient is a modified MockClient implementation for testing purposes.
*/
contract ModifiedMockClient is MockClient {
using BytesLib for bytes;
using IBCHeight for Height.Data;
constructor(address _ibcHandler) MockClient(_ibcHandler) {}
/**
* @dev verifyMembership is a generic proof verification method which verifies a proof of the existence of a value at a given CommitmentPath at the specified height.
* The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24).
*/
function verifyMembership(
string calldata clientId,
Height.Data calldata height,
uint64,
uint64,
bytes calldata proof,
bytes calldata prefix,
bytes memory path,
bytes calldata value
) external view override returns (bool) {
require(consensusStates[clientId][height.toUint128()].timestamp != 0, "consensus state not found");
require(keccak256(IBCHandler(ibcHandler).getCommitmentPrefix()) == keccak256(prefix), "invalid prefix");
return sha256(abi.encodePacked(height.toUint128(), sha256(prefix), sha256(path), sha256(value)))
== proof.toBytes32(0);
}
}