Skip to content
This repository was archived by the owner on Jun 15, 2021. It is now read-only.
Merged
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
6 changes: 6 additions & 0 deletions ecosystem.deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
npx oz publish $@
npx oz push $@
npx truffle compile --all
npx oz create BancorCurveService --no-interactive $@
npx oz create BondingCurveFactory --no-interactive $@
truffle exec ./ecosystem.initialize.js $@
104 changes: 104 additions & 0 deletions ecosystem.initialize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* eslint-disable no-console */
require('dotenv').config();

const fs = require('fs');

const App = artifacts.require('App');

const contractNames = {
StaticCurveLogic: 'StaticCurveLogic',
BancorCurveLogic: 'BancorCurveLogic',
BondedToken: 'BondedToken',
DividendPool: 'DividendPool',
BondingCurve: 'BondingCurve',
BondingCurveFactory: 'BondingCurveFactory',
BancorCurveService: 'BancorCurveService'
};

const BancorCurveService = artifacts.require('BancorCurveService');
const BondingCurveFactory = artifacts.require('BondingCurveFactory');

const truffleConfig = require('./truffle-config.js');

const BC_DAO_PACKAGE = '@dorg/bc-dao';

function activeNetwork() {
const networkIndex = process.argv.lastIndexOf('--network');
if (networkIndex < 2) {
return 'development';
}
return process.argv[networkIndex + 1];
}

function activeNetworkName() {
return activeNetwork() === 'development' ? `dev-${App.network_id}` : activeNetwork();
}

/*
* Get zos config info for specified networkId.
*/
function getOZNetworkConfig(networkName) {
const zosNetworkFile = fs.readFileSync(`./.openzeppelin/${networkName}.json`);
return JSON.parse(zosNetworkFile);
}

function getAppAddress() {
const ozNetworkConfig = getOZNetworkConfig(activeNetworkName());
return ozNetworkConfig.app.address;
}

function getLatestProxy(contractName) {
const ozNetworkConfig = getOZNetworkConfig(activeNetworkName());
const proxies = ozNetworkConfig.proxies[`${BC_DAO_PACKAGE}/${contractName}`];
if (!proxies || proxies.length <= 1) {
throw Error(`No deployed proxies of contract ${contractName} found`);
}
return proxies[proxies.length - 1];
}

function helpers() {
return {
constants: {
ZERO_ADDRESS: '0x0000000000000000000000000000000000000000'
}
};
}

async function initializeBancorCurveService(contractAddress) {
const contract = await BancorCurveService.at(contractAddress);
return contract.initialize();
}

async function initializeBondingCurveFactory(contractAddress) {
const ozNetworkConfig = getOZNetworkConfig(activeNetworkName());
const contract = await BondingCurveFactory.at(contractAddress);

return contract.initialize(
ozNetworkConfig.contracts.StaticCurveLogic.address,
ozNetworkConfig.contracts.BancorCurveLogic.address,
ozNetworkConfig.contracts.BondedToken.address,
ozNetworkConfig.contracts.BondingCurve.address,
ozNetworkConfig.contracts.DividendPool.address,
getLatestProxy(contractNames.BancorCurveService).address
);
}

module.exports = async () => {
const {constants} = helpers();
try {
const bancorCurveServiceAddress = getLatestProxy(contractNames.BancorCurveService).address;
const bondingCurveFactoryAddress = getLatestProxy(contractNames.BondingCurveFactory).address;
console.log(`${contractNames.BancorCurveService} to initialize:`, bancorCurveServiceAddress);
console.log(`${contractNames.BondingCurveFactory} to initialize:`, bondingCurveFactoryAddress);

let initializeTx = await initializeBancorCurveService(bancorCurveServiceAddress);
console.log(`${contractNames.BancorCurveService} initialization tx:`, initializeTx.tx);

initializeTx = await initializeBondingCurveFactory(bondingCurveFactoryAddress);
console.log(`${contractNames.BondingCurveFactory} initialization tx:`, initializeTx.tx);
} catch (e) {
console.error(e);
}

process.exit();
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"truffle-config.js"
],
"scripts": {
"test": "oz push --network development && truffle test",
"test": "oz publish --network development && oz push --network development && truffle test",
"compile": "truffle compile --all",
"build": "oz publish --network development && oz push --network development",
"build": "rimraf build && truffle compile",
"deploy": "sh ecosystem.deploy.sh",
"eslint": "./node_modules/.bin/eslint ./",
"eslint:fix": "./node_modules/.bin/eslint ./ --fix",
"solhint": "./node_modules/.bin/solhint contracts/**/*.sol",
Expand Down Expand Up @@ -55,6 +56,7 @@
"husky": "^3.0.0",
"prettier": "^1.18.2",
"prettier-plugin-solidity": "^1.0.0-alpha.27",
"rimraf": "^2.6.3",
"solhint": "^2.1.0",
"solhint-plugin-prettier": "0.0.3",
"solidity-coverage": "^0.5.11"
Expand Down