dione/eth-contracts/contracts/Mediator.sol

26 lines
758 B
Solidity
Raw Normal View History

2021-04-19 19:46:49 +00:00
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IDioneOracle.sol";
contract Mediator {
event DataReceived(
uint256 reqID,
string data
);
IDioneOracle dioneOracle;
constructor(IDioneOracle _dioneOracle) {
dioneOracle = _dioneOracle;
}
function request(uint8 originChain, string memory requestType, string memory requestParams) public returns (uint256) {
return dioneOracle.requestOracles(originChain, requestType, requestParams, address(this), bytes4(keccak256("_receiveDataCallback(uint256, string)")));
}
function _receiveDataCallback(uint256 reqID, string memory data) public {
require(msg.sender == address(dioneOracle));
emit DataReceived(reqID, data);
}
}