Skip to content

Commit

Permalink
add deployer with enhancedStepsReserve
Browse files Browse the repository at this point in the history
  • Loading branch information
ducquangkstn committed Jul 31, 2020
1 parent 9928909 commit 6d3689f
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ jspm_packages

# Optional REPL history
.node_repl_history

.env
14 changes: 13 additions & 1 deletion buidler.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
usePlugin("@nomiclabs/buidler-truffle5");
usePlugin("@nomiclabs/buidler-web3");


require('dotenv').config()

const INFURA_API_KEY = process.env.INFURA_API_KEY
const PRIVATE_KEY = process.env.PRIVATE_KEY

module.exports = {
defaultNetwork: "develop",

Expand All @@ -9,14 +15,20 @@ module.exports = {
url: "http://127.0.0.1:8545",
gas: 6000000,
timeout: 20000
},

ropsten: {
url: `https://ropsten.infura.io/v3/${INFURA_API_KEY}`,
accounts: [PRIVATE_KEY],
timeout: 20000
}
},

solc: {
version: "0.5.11",
optimizer: {
enabled: true,
runs: 200
runs: 1000000
}
},

Expand Down
2 changes: 1 addition & 1 deletion buidlerConfigV4.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
version: "0.4.18",
optimizer: {
enabled: true,
runs: 200
runs: 1000000
}
},

Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@nomiclabs/buidler-truffle5": "1.0.2",
"chai-as-promised": "7.1.1",
"compare-versions": "3.5.1",
"dotenv": "^8.2.0",
"ganache-cli": "6.8.2",
"mathjs": "4.4.2",
"rlp": "2.2.4",
Expand Down
76 changes: 76 additions & 0 deletions web3deployment/reserveDeploy/fpr/enhancedStepsDeployer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const KyberReserveHighRate = artifacts.require("KyberReserveHighRate.sol");
const ConversionRateEnhancedSteps = artifacts.require("ConversionRateEnhancedSteps.sol");
const WrapConversionRateEnhancedSteps = artifacts.require("WrapConversionRateEnhancedSteps.sol");

const BN = web3.utils.BN;

let reserve;
let reserveAddr = "0xad123f7Aa08B751e584E561F4d8f9ebf681530Ea";
let conversionRate;
let conversionRateAddr = "0xEf17a9E8A12EdE9888803f53555573BFBC531A14";
let wrapper;
let wrapperAddr = "0x49408B13A8D6814456d2a7ad0ce4882F2C6e2bf7";

let networkAddr = "0x920b322d4b8bab34fb6233646f5c87f87e79952b";
let admin= "0xf3D872b9E8d314820dc8E99DAfBe1A3FeEDc27D5";
let deployer;

async function main() {
const accounts = await web3.eth.getAccounts();
deployer = accounts[0];
console.log(`deployer address at ${deployer}`);

gasPrice = new BN(75).mul(new BN(10).pow(new BN(9)))

if(conversionRateAddr == undefined) {
conversionRate = await ConversionRateEnhancedSteps.new(deployer, {gasPrice: gasPrice});
console.log(`deploy conversionRate at ${conversionRate.address}`);
}else {
conversionRate = await ConversionRateEnhancedSteps.at(conversionRateAddr);
}

if (reserveAddr == undefined){
reserve = await KyberReserveHighRate.new(
networkAddr,
conversionRate.address,
deployer,
{gasPrice: gasPrice}
);
console.log(`deploy reserve at ${reserve.address}`);
reserveAddr = reserve.address;
} else {
reserve = await KyberReserveHighRate.at(reserveAddr);
}

if (wrapperAddr == undefined) {
wrapper = await WrapConversionRateEnhancedSteps.new(conversionRate.address, {gasPrice:gasPrice});
console.log(`deploy wrapper at ${wrapper.address}`);
wrapperAddr = wrapper.address;
} else {
wrapper = await WrapConversionRateEnhancedSteps.at(wrapperAddr);
}

if(await conversionRate.admin() != wrapperAddr) {
console.log(`set conversionRate admin to wrapper contract`);
await conversionRate.transferAdmin(wrapperAddr, {gasPrice: gasPrice});
await wrapper.claimWrappedContractAdmin({gasPrice: gasPrice});
}

if(await reserve.admin() != admin) {
console.log(`set new admin to reserve ${admin}`);
await reserve.transferAdminQuickly(admin, {gasPrice: gasPrice});
}

if(await wrapper.admin() != admin) {
console.log(`set new admin to wrapper ${admin}`);
await wrapper.transferAdminQuickly(admin, {gasPrice: gasPrice});
}
}


main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});

0 comments on commit 6d3689f

Please sign in to comment.