-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttestationService.sol
63 lines (49 loc) · 2.09 KB
/
AttestationService.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "@ensdomains/ens/contracts/ENS.sol";
import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
contract AttestationService is ChainlinkClient {
using Chainlink for Chainlink.Request;
struct Association {
address owner;
string ensName;
bytes entityData;
uint256 timestamp;
}
mapping(address => Association) public addressToAssociation;
address public admin;
constructor() {
admin = msg.sender;
setPublicChainlinkToken();
}
modifier onlyAdmin() {
require(msg.sender == admin, "Only admin can perform this action");
_;
}
event AssociationAdded(address indexed owner, string ensName, uint256 timestamp);
event AssociationRemoved(address indexed owner);
event BatchSigned(address[] indexed owners);
event CrossChainCommunication(string message);
function addAttestation(address _owner, string memory _ensName, bytes memory _entityData) public onlyAdmin {
addressToAssociation[_owner] = Association(_owner, _ensName, _entityData, block.timestamp);
emit AssociationAdded(_owner, _ensName, block.timestamp);
}
function removeAttestation(address _owner) public onlyAdmin {
delete addressToAssociation[_owner];
emit AssociationRemoved(_owner);
}
function verifyAttestation(address _owner) public view returns (bool) {
return addressToAssociation[_owner].owner != address(0);
}
function signBatch(address[] memory _owners) public onlyAdmin {
emit BatchSigned(_owners);
}
function requestCrossChainCommunication(string memory message, address oracle, bytes32 jobId, uint256 fee) public onlyAdmin {
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
request.add("message", message);
sendChainlinkRequestTo(oracle, request, fee);
}
function fulfill(bytes32 _requestId, string memory message) public recordChainlinkFulfillment(_requestId) {
emit CrossChainCommunication(message);
}
}