Skip to content

Commit

Permalink
Update deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kalambet committed Jul 2, 2018
1 parent e0273fe commit eec4480
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 58 deletions.
3 changes: 3 additions & 0 deletions env.js
Expand Up @@ -40,5 +40,8 @@ module.exports = {
fourthAirdropAddress: "0xBc6dce860486c4B31E422b12e54512C4025db356"

},
},
helpers: {
error: function(e) {console.log(e);}
}
}
6 changes: 5 additions & 1 deletion migrations/1_initial_migration.js
@@ -1,5 +1,9 @@
var Migrations = artifacts.require("./Migrations.sol");
var env = require("../env.js");

module.exports = function(deployer, network) {
var options = env[network];
console.log("Using env for network: '" + options.name + "'");

module.exports = function(deployer) {
deployer.deploy(Migrations);
};
57 changes: 0 additions & 57 deletions migrations/2_deploy_contracts.js

This file was deleted.

6 changes: 6 additions & 0 deletions migrations/2_deploy_ndf.js
@@ -0,0 +1,6 @@
var SKYFNetworkDevelopmentFund = artifacts.require("./SKYFNetworkDevelopmentFund.sol");
var env = require("../env.js");

module.exports = function(deployer) {
return deployer.deploy(SKYFNetworkDevelopmentFund).catch(env.helpers.error);
};
6 changes: 6 additions & 0 deletions migrations/3_deploy_reserve.js
@@ -0,0 +1,6 @@
var SKYFReserveFund = artifacts.require("./SKYFReserveFund.sol");
var env = require("../env.js");

module.exports = function(deployer) {
return deployer.deploy(SKYFReserveFund).catch(env.helpers.error);
};
6 changes: 6 additions & 0 deletions migrations/4_deploy_team.js
@@ -0,0 +1,6 @@
var SKYFTeamFund = artifacts.require("./SKYFTeamFund.sol");
var env = require("../env.js");

module.exports = function(deployer) {
return deployer.deploy(SKYFTeamFund).catch(env.helpers.error);
};
30 changes: 30 additions & 0 deletions migrations/5_deploy_token.js
@@ -0,0 +1,30 @@
var SKYFToken = artifacts.require("./SKYFToken.sol");
var SKYFNetworkDevelopmentFund = artifacts.require("./SKYFNetworkDevelopmentFund.sol");
var SKYFReserveFund = artifacts.require("./SKYFReserveFund.sol");
var SKYFTeamFund = artifacts.require("./SKYFTeamFund.sol");
var env = require("../env.js");

module.exports = function(deployer, network) {
var options = env[network];

return SKYFNetworkDevelopmentFund.deployed().then(function(ndf){
return SKYFReserveFund.deployed().then(function(rf){
return SKYFTeamFund.deployed().then(function(tf){
return deployer.deploy(SKYFToken
, options.accounts.crowdsaleWallet
, ndf.address
, options.accounts.communityDevelopmentWallet
, rf.address
, options.accounts.bountyWallet
, tf.address
, options.accounts.siteAccount).then(function(){
return ndf.setToken(SKYFToken.address).then(function() {
return tf.setToken(SKYFToken.address).then(function() {
return rf.setToken(SKYFToken.address).catch(env.helpers.error);
}).catch(env.helpers.error);
}).catch(env.helpers.error);
}).catch(env.helpers.error);
}).catch(env.helpers.error);
}).catch(env.helpers.error);
}).catch(env.helpers.error);
};
15 changes: 15 additions & 0 deletions migrations/6_set_token.js.bak
@@ -0,0 +1,15 @@
// var SKYFToken = artifacts.require("./SKYFToken.sol");
// var SKYFNetworkDevelopmentFund = artifacts.require("./SKYFNetworkDevelopmentFund.sol");
// var SKYFReserveFund = artifacts.require("./SKYFReserveFund.sol");
// var SKYFTeamFund = artifacts.require("./SKYFTeamFund.sol");
// var env = require("../env.js");

// module.exports = function(deployer) {
// return SKYFNetworkDevelopmentFund.deployed().then(function(ndf){
// return SKYFReserveFund.deployed().then(function(rf){
// return SKYFTeamFund.deployed().then(function(tf){
// return SKYFToken.deployed().then(function(token){
// }).catch(env.helpers.error);
// }).catch(env.helpers.error);
// }).catch(env.helpers.error);
// };
60 changes: 60 additions & 0 deletions tools/update-tx.js
@@ -0,0 +1,60 @@
onst web3 = new Web3(new Web3.providers.HttpProvider(String(config.get('eth-network-address'))))
const cjson = require('../ethereum/abi.json')
const Contract = new web3.eth.Contract(cjson, String(config.get('chaincodeAddress')), { gas: 300000 }) /* gasPrice: 20000000000 */

module.exports.reloadTx = await (req, res, next) => {
const methodName = loggerName + '[reloadTx]'

const nonce = req.body.nonce
const secret = req.body.secret
const gasPrice = req.body.gasPrice // 4000000000
const gasLimit = req.body.gasLimit // 600000

if (!nonce || !gasPrice || !gasLimit) {
return res.status(httpStatuses.BAD_REQUEST).json('Invalid input parameters')
}

if (secret !== String(config.get('secret'))) {
return res.status(httpStatuses.BAD_REQUEST).json('Secret is not correct')
}

// Protect from DDOS and RACE Condition
// Plugin handles on his own
// Verified by: Kanat Tulbassiyev
await systemQueue.handleOrRelease (req, res)

// Anomaly Detector
// Handles seed hacks, random generator hacks
// Verified by: Kanat Tulbassiyev
await anomaly.handleOrRealse(req, res)

// Detects CSRF, XSS, SQL Injects
// Written by: Kanat Tulbassiyev
// Verified by: Vinod Morkile
await inputHanlder.blockIPOrRelease(nonce, secret, gasPrice, gasLimit)

web3.eth.personal.unlockAccount(config.get('dashboardWalletAddress'),
config.get('dashboardWalletPwd'), config.get('unlockTimePeriod'), (err, unlocked) => {
if (err) {
logger.error(methodName, err)
}

const txData = {
from: config.get('dashboardWalletAddress'),
to: config.get('dashboardWalletAddress'),
value: 0,
gasPrice: gasPrice,
gasLimit: gasLimit,
nonce: nonce
}

web3.eth.sendTransaction(txData, (err, data) => {
if (err) {
logger.error(methodName, err)
return res.json(err.message)
}

res.json(data)
})
})
}

0 comments on commit eec4480

Please sign in to comment.