Return Mediator contract back

This commit is contained in:
ChronosX88 2021-04-19 22:46:49 +03:00
parent f0ecad1cbf
commit fb22d3c4e3
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
4 changed files with 50 additions and 3 deletions

View File

@ -0,0 +1,26 @@
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);
}
}

View File

@ -0,0 +1,6 @@
pragma solidity ^0.8.0;
interface IDioneOracle {
function requestOracles(uint8 _originChain, string memory _requestType, string memory _requestParams, address _callbackAddress, bytes4 _callbackMethodID) external returns (uint256);
function cancelOracleRequest(uint256 _reqID) external;
}

View File

@ -11,4 +11,12 @@ task("accounts", "Prints the list of accounts", async (args, hre) => {
export default { export default {
solidity: "0.8.3", solidity: "0.8.3",
networks: {
ganache: {
url: `http://localhost:7545`,
accounts: {
mnemonic: "test test test test test test test test test test test junk"
}
}
}
}; };

View File

@ -8,6 +8,7 @@ async function main() {
const DioneOracle = await ethers.getContractFactory("DioneOracle"); const DioneOracle = await ethers.getContractFactory("DioneOracle");
const DioneDispute = await ethers.getContractFactory("DioneDispute"); const DioneDispute = await ethers.getContractFactory("DioneDispute");
const DioneStaking = await ethers.getContractFactory("DioneStaking"); const DioneStaking = await ethers.getContractFactory("DioneStaking");
const Mediator = await ethers.getContractFactory("Mediator");
const dioneToken = await DioneToken.deploy(); const dioneToken = await DioneToken.deploy();
await dioneToken.deployed(); await dioneToken.deployed();
@ -15,15 +16,19 @@ async function main() {
const dioneStaking = await DioneStaking.deploy(dioneToken.address, ethers.constants.WeiPerEther.mul(100), 0, ethers.constants.WeiPerEther.mul(5000)); const dioneStaking = await DioneStaking.deploy(dioneToken.address, ethers.constants.WeiPerEther.mul(100), 0, ethers.constants.WeiPerEther.mul(5000));
await dioneStaking.deployed(); await dioneStaking.deployed();
console.log("DioneStaking deployed to:", dioneStaking.address); console.log("staking_contract_address = \"" + dioneStaking.address+ "\"");
const dioneDispute = await DioneDispute.deploy(dioneStaking.address); const dioneDispute = await DioneDispute.deploy(dioneStaking.address);
await dioneDispute.deployed(); await dioneDispute.deployed();
console.log("DioneDispute deployed to:", dioneDispute.address); console.log("dispute_contract_address = \"" + dioneDispute.address+ "\"");
const dioneOracle = await DioneOracle.deploy(dioneStaking.address); const dioneOracle = await DioneOracle.deploy(dioneStaking.address);
await dioneOracle.deployed(); await dioneOracle.deployed();
console.log("DioneOracle deployed to:", dioneOracle.address); console.log("oracle_contract_address = \"" + dioneOracle.address+ "\"");
const mediator = await Mediator.deploy(dioneOracle.address);
await mediator.deployed();
console.log("mediator_contract_address = \"" + mediator.address +"\"")
await dioneStaking.setOracleContractAddress(dioneOracle.address); await dioneStaking.setOracleContractAddress(dioneOracle.address);
await dioneStaking.setDisputeContractAddress(dioneOracle.address); await dioneStaking.setDisputeContractAddress(dioneOracle.address);
@ -37,6 +42,8 @@ async function main() {
await dioneToken.transfer(address, ethers.constants.WeiPerEther.mul(6000)); await dioneToken.transfer(address, ethers.constants.WeiPerEther.mul(6000));
} }
await dioneToken.transferOwnership(dioneStaking.address);
const signers = await ethers.getSigners(); const signers = await ethers.getSigners();
for (var i = 0; i < addresses.length; i++) { for (var i = 0; i < addresses.length; i++) {
const staking = dioneStaking.connect(signers[i]); const staking = dioneStaking.connect(signers[i]);