Return Mediator contract back
This commit is contained in:
parent
f0ecad1cbf
commit
fb22d3c4e3
26
eth-contracts/contracts/Mediator.sol
Normal file
26
eth-contracts/contracts/Mediator.sol
Normal 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);
|
||||
}
|
||||
}
|
6
eth-contracts/contracts/interfaces/IDioneOracle.sol
Normal file
6
eth-contracts/contracts/interfaces/IDioneOracle.sol
Normal 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;
|
||||
}
|
@ -11,4 +11,12 @@ task("accounts", "Prints the list of accounts", async (args, hre) => {
|
||||
|
||||
export default {
|
||||
solidity: "0.8.3",
|
||||
networks: {
|
||||
ganache: {
|
||||
url: `http://localhost:7545`,
|
||||
accounts: {
|
||||
mnemonic: "test test test test test test test test test test test junk"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@ -8,6 +8,7 @@ async function main() {
|
||||
const DioneOracle = await ethers.getContractFactory("DioneOracle");
|
||||
const DioneDispute = await ethers.getContractFactory("DioneDispute");
|
||||
const DioneStaking = await ethers.getContractFactory("DioneStaking");
|
||||
const Mediator = await ethers.getContractFactory("Mediator");
|
||||
|
||||
const dioneToken = await DioneToken.deploy();
|
||||
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));
|
||||
await dioneStaking.deployed();
|
||||
console.log("DioneStaking deployed to:", dioneStaking.address);
|
||||
console.log("staking_contract_address = \"" + dioneStaking.address+ "\"");
|
||||
|
||||
const dioneDispute = await DioneDispute.deploy(dioneStaking.address);
|
||||
await dioneDispute.deployed();
|
||||
console.log("DioneDispute deployed to:", dioneDispute.address);
|
||||
console.log("dispute_contract_address = \"" + dioneDispute.address+ "\"");
|
||||
|
||||
const dioneOracle = await DioneOracle.deploy(dioneStaking.address);
|
||||
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.setDisputeContractAddress(dioneOracle.address);
|
||||
@ -37,6 +42,8 @@ async function main() {
|
||||
await dioneToken.transfer(address, ethers.constants.WeiPerEther.mul(6000));
|
||||
}
|
||||
|
||||
await dioneToken.transferOwnership(dioneStaking.address);
|
||||
|
||||
const signers = await ethers.getSigners();
|
||||
for (var i = 0; i < addresses.length; i++) {
|
||||
const staking = dioneStaking.connect(signers[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user