-
Notifications
You must be signed in to change notification settings - Fork 4
/
WitnessConsumer.sol
49 lines (40 loc) · 1.89 KB
/
WitnessConsumer.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IWitness, Proof } from "./interfaces/IWitness.sol";
import { IWitnessConsumer } from "./interfaces/IWitnessConsumer.sol";
/// @title WitnessConsumer
/// @author sina.eth
/// @custom:coauthor runtheblocks.eth
/// @notice Utility mixin for contracts that want to consume provenance.
/// @dev See IWitnessConsumer.sol for more information.
abstract contract WitnessConsumer is IWitnessConsumer {
/*//////////////////////////////////////////////////////////////////////////
PUBLIC STORAGE
//////////////////////////////////////////////////////////////////////////*/
/// @notice The Witness contract that this contract uses to verify provenance.
/// @inheritdoc IWitnessConsumer
IWitness public immutable WITNESS;
/*//////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/
/// @dev Immutably sets the Witness address.
/// @param _witness The address that's used as the Witness to verify provenance against.
constructor(IWitness _witness) {
WITNESS = _witness;
}
/*//////////////////////////////////////////////////////////////
READ METHODS
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IWitnessConsumer
function getProvenanceHash(bytes calldata data) public view virtual returns (bytes32) {
return keccak256(data);
}
/// @inheritdoc IWitnessConsumer
function verifyProof(Proof calldata proof) public view virtual {
WITNESS.verifyProof(proof);
}
/// @inheritdoc IWitnessConsumer
function safeVerifyProof(Proof calldata proof) public view virtual returns (bool) {
return WITNESS.safeVerifyProof(proof);
}
}