Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[don't pull]add deployer with enhancedStepsReserve #1050

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ jspm_packages
.DS_Store

report

.env
15 changes: 14 additions & 1 deletion buidler.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,17 @@ module.exports = {
mocha: {
enableTimeouts: false
}
};
};

require('dotenv').config()

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

if (INFURA_API_KEY != undefined && PRIVATE_KEY != undefined) {
module.exports.networks.ropsten = {
url: `https://ropsten.infura.io/v3/${INFURA_API_KEY}`,
accounts: [PRIVATE_KEY],
timeout: 20000
}
}
81 changes: 43 additions & 38 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 @@
"chai-as-promised": "7.1.1",
"compare-versions": "3.5.1",
"ethers": "5.0.4",
"dotenv": "^8.2.0",
"ganache-cli": "6.8.2",
"mathjs": "4.4.2",
"rlp": "2.2.4",
Expand Down
15 changes: 15 additions & 0 deletions web3deployment/reserveDeploy/fpr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Step to deploy reserve:
### Tranditional way:
- config the .env variable *PRIVATE_KEY*
- run command
```
node web3deployment/reserveDeploy/fpr/enhancedStepsDeployer2.js --rpcUrl https://ropsten.infura.io/v3/YOUR_INFURA_ID --gas-price-gwei 5
```

### Buidler way:
- config the .env varialbe *PRIVATE_KEY* and *INFURA_API_KEY*
- run command
```
npx buidler run --no-compile --network ropsten web3deployment/reserveDeploy/fpr/enhancedStepsDeployer.js
```
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;
let conversionRate;
let conversionRateAddr;
let wrapper;
let wrapperAddr;

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

async function main() {
const accounts = await web3.eth.getAccounts();
deployer = accounts[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plan is to send funds to this address?
if so how to return back remaining funds when done?
have private key?
consider saving it locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you set the network is ropsten in the script, accounts[0] will be the address from the privatekey in .env file

console.log(`deployer address at ${deployer}`);

gasPrice = new BN(2).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);
});
Loading