From 1fa4f1ea6043fd8e7b7df3ff91957efbd409f2a6 Mon Sep 17 00:00:00 2001 From: francois branciard Date: Thu, 12 Apr 2018 14:28:42 +0200 Subject: [PATCH] update migration for testnets --- README.md | 47 ++++++++++++++++---------------- migrations/2_deploy_contracts.js | 45 +++++++++++++++++++++++------- truffle-hdwallet.js | 42 ++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 34 deletions(-) create mode 100644 truffle-hdwallet.js diff --git a/README.md b/README.md index 8ecb7e88..2de62dce 100644 --- a/README.md +++ b/README.md @@ -492,37 +492,36 @@ or ``` -coverage : 10/04/2018 +coverage : 12/04/2018 - 180 passing (12m) - 1 pending +180 passing (13m) +1 pending -----------------------------|----------|----------|----------|----------|----------------| File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines | -----------------------------|----------|----------|----------|----------|----------------| - contracts/ | 100 | 75.16 | 100 | 100 | | - App.sol | 100 | 50 | 100 | 100 | | - AppHub.sol | 100 | 100 | 100 | 100 | | - Dataset.sol | 100 | 50 | 100 | 100 | | - DatasetHub.sol | 100 | 100 | 100 | 100 | | - IexecAPI.sol | 100 | 50 | 100 | 100 | | - IexecCallbackInterface.sol | 100 | 100 | 100 | 100 | | - IexecHub.sol | 100 | 69.83 | 100 | 100 | | - IexecHubAccessor.sol | 100 | 75 | 100 | 100 | | - IexecHubInterface.sol | 100 | 100 | 100 | 100 | | - IexecLib.sol | 100 | 100 | 100 | 100 | | - Marketplace.sol | 100 | 88.89 | 100 | 100 | | - MarketplaceAccessor.sol | 100 | 50 | 100 | 100 | | - MarketplaceInterface.sol | 100 | 100 | 100 | 100 | | - OwnableOZ.sol | 100 | 75 | 100 | 100 | | - SafeMathOZ.sol | 100 | 75 | 100 | 100 | | - TestSha.sol | 100 | 100 | 100 | 100 | | - WorkOrder.sol | 100 | 62.5 | 100 | 100 | | - WorkerPool.sol | 100 | 82.69 | 100 | 100 | | - WorkerPoolHub.sol | 100 | 75 | 100 | 100 | | +contracts/ | 100 | 75.16 | 100 | 100 | | +App.sol | 100 | 50 | 100 | 100 | | +AppHub.sol | 100 | 100 | 100 | 100 | | +Dataset.sol | 100 | 50 | 100 | 100 | | +DatasetHub.sol | 100 | 100 | 100 | 100 | | +IexecAPI.sol | 100 | 50 | 100 | 100 | | +IexecCallbackInterface.sol | 100 | 100 | 100 | 100 | | +IexecHub.sol | 100 | 69.83 | 100 | 100 | | +IexecHubAccessor.sol | 100 | 75 | 100 | 100 | | +IexecHubInterface.sol | 100 | 100 | 100 | 100 | | +IexecLib.sol | 100 | 100 | 100 | 100 | | +Marketplace.sol | 100 | 88.89 | 100 | 100 | | +MarketplaceAccessor.sol | 100 | 50 | 100 | 100 | | +MarketplaceInterface.sol | 100 | 100 | 100 | 100 | | +OwnableOZ.sol | 100 | 75 | 100 | 100 | | +SafeMathOZ.sol | 100 | 75 | 100 | 100 | | +TestSha.sol | 100 | 100 | 100 | 100 | | +WorkOrder.sol | 100 | 62.5 | 100 | 100 | | +WorkerPool.sol | 100 | 82.69 | 100 | 100 | | +WorkerPoolHub.sol | 100 | 75 | 100 | 100 | | -----------------------------|----------|----------|----------|----------|----------------| All files | 100 | 75.16 | 100 | 100 | | -----------------------------|----------|----------|----------|----------|----------------| -``` ## Oyente analyse see [here](./oyente) diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 19ff8436..7ea8f890 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -119,11 +119,15 @@ module.exports = function(deployer) { //mainnet = '0x607F4C5BB672230e8672085532f7e901544a7375' module.exports = function(deployer) { + let aRLCInstance; let aWorkerPoolHubInstance; let aAppHubInstance; let aDatasetHubInstance; - let aTaskRequestHubInstance; let aIexecHub; + let aMarketplaceInstance; + let creator; + aRLCInstance='0xc57538846ec405ea25deb00e0f9b29a432d53507'; + return deployer.deploy(WorkerPoolHub) .then(() => WorkerPoolHub.deployed()) .then(instance => { @@ -141,13 +145,7 @@ module.exports = function(deployer) { .then(instance => { aDatasetHubInstance = instance; console.log("DatasetHub deployed at address: " + instance.address); - return deployer.deploy(TaskRequestHub); - }) - .then(() => TaskRequestHub.deployed()) - .then(instance => { - aTaskRequestHubInstance = instance; - console.log("TaskRequestHub deployed at address: " + instance.address); - return deployer.deploy(IexecHub, '0x7314dc4d7794b5e7894212ca1556ae8e3de58621', aWorkerPoolHubInstance.address, aAppHubInstance.address, aDatasetHubInstance.address, aTaskRequestHubInstance.address); + return deployer.deploy(IexecHub, aRLCInstance, aWorkerPoolHubInstance.address, aAppHubInstance.address, aDatasetHubInstance.address); }) .then(() => IexecHub.deployed()) .then(instance => { @@ -165,9 +163,36 @@ module.exports = function(deployer) { }) .then(() => { console.log("transferOwnership of DatasetHub to IexecHub"); - return aTaskRequestHubInstance.transferOwnership(aIexecHub.address); + return deployer.deploy(Marketplace, aIexecHub.address); + }) + .then(() => Marketplace.deployed()) + .then(instance => { + aMarketplaceInstance = instance; + console.log("Marketplace deployed at address: " + instance.address); + return aIexecHub.attachMarketplace(instance.address); }) - .then(() => console.log("transferOwnership of TaskRequestHub to IexecHub")); + .then(() => { + console.log("attach Marketplace to IexecHub done"); + return aIexecHub.setCategoriesCreator(creator); + }) + .then(() => { + console.log("setCategoriesCreator to "+creator); + return readFileAsync("./config/categories.json"); + }) + .then(categories => { + var categoriesConfigFileJson = JSON.parse(categories); + catagoriesPromises = []; + for(var i = 0; i < categoriesConfigFileJson.categories.length; i++) { + console.log("create category : "+categoriesConfigFileJson.categories[i].name); + catagoriesPromises.push(aIexecHub.createCategory(categoriesConfigFileJson.categories[i].name,JSON.stringify(categoriesConfigFileJson.categories[i].description),categoriesConfigFileJson.categories[i].workClockTimeRef)); + } + return Promise.all(catagoriesPromises); + }) + .then(categoriesCreated => { + return aIexecHub.m_categoriesCount.call() + }) + .then(m_categoriesCount => console.log("m_categoriesCount is now: "+m_categoriesCount)) + ; }; **/ diff --git a/truffle-hdwallet.js b/truffle-hdwallet.js new file mode 100644 index 00000000..f8dc4737 --- /dev/null +++ b/truffle-hdwallet.js @@ -0,0 +1,42 @@ + +var HDWalletProvider = require("truffle-hdwallet-provider"); +var mnemonic = "12 words"; + + +module.exports = { + networks: { + ropsten: { + provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/berv5GTB5cSdOJPPnqOq"), + network_id: "3", + gas: 4400000, + gasPrice: 22000000000, + }, + rinkeby: { + provider: new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/berv5GTB5cSdOJPPnqOq"), + network_id: "4", + gas: 4400000, + gasPrice: 22000000000, + }, + kovan: { + provider: new HDWalletProvider(mnemonic, "https://kovan.infura.io/berv5GTB5cSdOJPPnqOq"), + network_id: "42", + gas: 4400000, + gasPrice: 22000000000, + },/* + mainnet: { + provider: new HDWalletProvider(mnemonic, "https://mainnet.infura.io/berv5GTB5cSdOJPPnqOq"), + network_id: "1", + gas: 4400000, + gasPrice: 22000000000, + },*/ + }, + solc: { + optimizer: { + enabled: true, + runs: 200 + } + }, + mocha: { + enableTimeouts: false + } +};