Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

improvement: upgrade to new bridge #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MNENOMIC=
INFURA_API_KEY=
ETHERSCAN_API_KEY=
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ coverage.json
.idea
.vscode

.secret
.secret

.env

/1

yarn.lock
package-lock.json
contracts/flattened
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 80
}
2 changes: 2 additions & 0 deletions .soliumignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
contracts/flattened
contracts/requests
2 changes: 1 addition & 1 deletion .soliumrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"quotes": ["error", "double"],
"indentation": ["error", 2],
"linebreak-style": ["error", "unix"],
"security/no-block-members": "off"
"error-reason": "off"
}
}
3 changes: 1 addition & 2 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pragma solidity ^0.5.0;

pragma solidity >=0.5.3 <0.7.0;

contract Migrations {
address public owner;
Expand Down
7 changes: 3 additions & 4 deletions contracts/TokenPriceContest.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
pragma solidity ^0.5.0;
pragma solidity >=0.5.3 <0.7.0;
pragma experimental ABIEncoderV2;

import "witnet-ethereum-bridge/contracts/UsingWitnet.sol";
import "./requests/TokenGradient.sol";


/**
* @title Token Price Contest
* @notice Contract for creating a contest in which one can bet on token prices
Expand Down Expand Up @@ -95,7 +94,7 @@ contract TokenPriceContest is UsingWitnet {

/// @dev Gets the timestamp of the current block as seconds since unix epoch
/// @return timestamp
function getTimestamp() public view returns (uint256) {
function getTimestamp() public view virtual returns (uint256) {
return block.timestamp;
}

Expand Down Expand Up @@ -230,7 +229,7 @@ contract TokenPriceContest is UsingWitnet {
/// @param _day contest day
/// @return true, if result is ready
function isResultReady(uint8 _day) public view returns(bool) {
(,,,bytes memory result,,,) = wbi.requests(dayInfos[_day].witnetRequestId);
bytes memory result = wrb.readResult(dayInfos[_day].witnetRequestId);
return result.length > 0;
}

Expand Down
Empty file removed contracts/requests/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions contracts/requests/TokenGradient.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.5.0;
pragma solidity >=0.5.3 <0.7.0;

import "witnet-ethereum-bridge/contracts/Request.sol";

// The bytecode of the TokenGradient request that will be sent to Witnet
contract TokenGradientRequest is Request {
constructor () Request(hex"0ae70608a9d1ddec0512ae01122568747470733a2f2f6170692e636f696e6c6f72652e636f6d2f6170692f7469636b6572732f1a8401871845187482186164646174611870821853838218616673796d626f6c1875831844aa64414c474ff563425443f563454f53f563455443f563455448f5644c494e4bf5634d4b52f563524550f56358545af5635a4543f5f4821859828218616673796d626f6c1875821856828218617270657263656e745f6368616e67655f323468187212a801122068747470733a2f2f6170692e636f696e6361702e696f2f76322f6173736574731a8301871845187482186164646174611870821853838218616673796d626f6c1875831844aa64414c474ff563425443f563454f53f563455443f563455448f5644c494e4bf5634d4b52f563524550f56358545af5635a4543f5f4821859828218616673796d626f6c187582185682821861716368616e676550657263656e7432344872187212ba01122668747470733a2f2f6170692e636f696e70617072696b612e636f6d2f76312f7469636b6572731a8f018518451870821853838218616673796d626f6c1875831844aa64414c474ff563425443f563454f53f563455443f563455448f5644c494e4bf5634d4b52f563524550f56358545af5635a4543f5f4821859828218616673796d626f6c1875821856868218616671756f74657318748218616355534418748218617270657263656e745f6368616e67655f323468187212e901124d68747470733a2f2f62696c6c626f6172642e736572766963652e63727970746f7761742e63682f6173736574733f71756f74653d757364266c696d69743d33303026736f72743d766f6c756d651a9701891845187482186166726573756c74187482186164726f77731870821853838218616673796d626f6c1875831844aa64616c676ff563627463f563656f73f563657463f563657468f5646c696e6bf5636d6b72f563726570f56378747af5637a6563f5f4821859828218616673796d626f6c1875821856858218616b706572666f726d616e6365187482186163323468187282183818641a280a2684821853821851821824098218538218518218250b83185305fb4000cccccccccccd8218570322300a2e85821853821851821824098218538218518218250b83185305fa3fc000008218570382185682821838192710183c10eb0718022002280130013801") public { }
constructor () Request(hex"0af5050891eda9f40512a201122568747470733a2f2f6170692e636f696e6c6f72652e636f6d2f6170692f7469636b6572732f1a7985187782186164646174618211828218676673796d626f6c831875aa64414c474ff563425443f563454f53f563455443f563455448f5644c494e4bf5634d4b52f563524550f56358545af5635a4543f5f482181d818218676673796d626f6c82181a818218647270657263656e745f6368616e67655f323468129c01122068747470733a2f2f6170692e636f696e6361702e696f2f76322f6173736574731a7885187782186164646174618211828218676673796d626f6c831875aa64414c474ff563425443f563454f53f563455443f563455448f5644c494e4bf5634d4b52f563524550f56358545af5635a4543f5f482181d818218676673796d626f6c82181a81821864716368616e676550657263656e743234487212ad01122668747470733a2f2f6170692e636f696e70617072696b612e636f6d2f76312f7469636b6572731a82018418768211828218676673796d626f6c831875aa64414c474ff563425443f563454f53f563455443f563455448f5644c494e4bf5634d4b52f563524550f56358545af5635a4543f5f482181d818218676673796d626f6c82181a838218666671756f746573821866635553448218647270657263656e745f6368616e67655f32346812da01124d68747470733a2f2f62696c6c626f6172642e736572766963652e63727970746f7761742e63682f6173736574733f71756f74653d757364266c696d69743d33303026736f72743d766f6c756d651a880186187782186666726573756c7482186164726f77738211828218676673796d626f6c831875aa64616c676ff563627463f563656f73f563657463f563657468f5646c696e6bf5636d6b72f563726570f56378747af5637a6563f5f482181d818218676673796d626f6c82181a838218666b706572666f726d616e63658218646332346882185718641a110a0d08051209fb4000cccccccccccd100322090a0508051201011003100a18042001280130013801400248055046") public { }
}
36 changes: 36 additions & 0 deletions flattened-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const HDWalletProvider = require("@truffle/hdwallet-provider");
require("dotenv").config();

module.exports = {
compilers: {
solc: {
version: "0.6.4",
settings: { optimizer: { enabled: true, runs: 200 } }
},
},
contracts_directory: "./contracts/flattened/",
networks: {
rinkeby: {
provider: () =>
new HDWalletProvider(
process.env.MNENOMIC,
"https://rinkeby.infura.io/v3/" + process.env.INFURA_API_KEY,
0
),
network_id: 4,
gas: 3000000,
gasPrice: 10000000000
},
goerli: {
provider: () =>
new HDWalletProvider(
process.env.MNENOMIC,
"https://goerli.infura.io/v3/" + process.env.INFURA_API_KEY,
0
),
network_id: 5,
gas: 3000000,
gasPrice: 10000000000
},
},
}
34 changes: 18 additions & 16 deletions migrations/2_witnet_core.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
// WARNING: DO NOT DELETE THIS FILE
// This file was auto-generated by the Witnet compiler, any manual changes will be overwritten.
const BlockRelay = artifacts.require("BlockRelay")
const WitnetBridgeInterface = artifacts.require("WitnetBridgeInterface")
const WitnetRequestsBoardProxy = artifacts.require("WitnetRequestsBoardProxy")
const MockWitnetRequestsBoard = artifacts.require("MockWitnetRequestsBoard")
const CBOR = artifacts.require("CBOR")
const Witnet = artifacts.require("Witnet")

const addresses = {
"rinkeby": {
"BlockRelay": "0x88fEF6805ADD0029a919981D6c5579238B008577",
"CBOR": "0x22091dB676f634E3e1ecAADc3b4f922984fA842b",
"Witnet": "0xFECE4CAe3fFAABd59F161045f4b93CC9D894EB99",
"WitnetBridgeInterface": "0xf0C67374D08e72dd7424982F76870AE0D6F2055e",
},
"goerli": {
"BlockRelay": "0xf84dcE5f5fc334a88c2FCbe68bEA04C343a1530c",
"CBOR": "0xB154e5AF823eEe145B3A7A0301c6D673E9Fa6248",
"Witnet": "0x820E08993084c6685ee5295470936496607d164A",
"WitnetBridgeInterface": "0x1053c33f1DcFF9c8F6F6DC07e3F8cb84e46232A1",
"BlockRelayProxy": "0xbF36475B8245a51B6f5F4ABeF852725ED302DD9b",
"CBOR": "0x26D81f33AaCfa5B68B944C52f98Db9733CcaB3c4",
"Witnet": "0x559A2af1F61c3aE990fCC4B370857fB1F95525ca",
"WitnetRequestsBoardProxy": "0xFBd67d672C12B130b61320026E5B681f9040bCd3",
},
"rinkeby": {
"BlockRelayProxy": "0x21FC161EB3b958f256bF303dEb32755cFe33bbbd",
"CBOR": "0x609217CE0352D0935cA82cE1B1b04A4d54A3A849",
"Witnet": "0x36a9B745C5d531C1b51fcD9fB87902b3d1876cFd",
"WitnetRequestsBoardProxy": "0x996Be500EBF09537EDde024f70fFdFA55089E939",
},
}

module.exports = function (deployer, network) {
network = network.split("-")[0]
if (network in addresses) {
Witnet.address = addresses[network]["Witnet"]
WitnetBridgeInterface.address = addresses["rinkeby"]["WitnetBridgeInterface"]
WitnetRequestsBoardProxy.address = addresses[network]["WitnetRequestsBoardProxy"]
} else {
deployer.deploy(BlockRelay).then(() => {
return deployer.deploy(WitnetBridgeInterface, BlockRelay.address)
})
deployer.deploy(CBOR)
deployer.link(CBOR, Witnet)
deployer.deploy(Witnet)
deployer.deploy(MockWitnetRequestsBoard).then(function() {
return deployer.deploy(WitnetRequestsBoardProxy, MockWitnetRequestsBoard.address)
})

}
}
5 changes: 2 additions & 3 deletions migrations/3_user_contracts.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This file was auto-generated by the Witnet compiler, any manual changes will be overwritten except
// each contracts' constructor arguments (you can freely edit those and the compiler will respect them).
const Witnet = artifacts.require("Witnet")
const WitnetBridgeInterface = artifacts.require("WitnetBridgeInterface")
const WitnetRequestsBoardProxy = artifacts.require("WitnetRequestsBoardProxy")
const TokenPriceContest = artifacts.require("TokenPriceContest")

module.exports = function (deployer) {
deployer.link(Witnet, [TokenPriceContest])
deployer.deploy(TokenPriceContest, 1569928300, 300, 10, WitnetBridgeInterface.address, 1, 1)
deployer.deploy(TokenPriceContest, 1569928300, 300, 10, WitnetRequestsBoardProxy.address, 1, 1)
}
Loading