Skip to content

Commit

Permalink
Merge pull request #345 from Thetta/dev-enkogu-sept
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyAkentiev authored Sep 28, 2018
2 parents 0d733c5 + fbc17ff commit ed54c59
Showing 1 changed file with 54 additions and 47 deletions.
101 changes: 54 additions & 47 deletions scripts/migrateLibs.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,64 @@
function migrateLibs (artifacts, additionalContracts, deployer, network, accounts) {

return deployer.then(async () => {
var UtilsLib = artifacts.require("./UtilsLib");
var GenericCallerLib = artifacts.require("./GenericCallerLib");
var VotingLib = artifacts.require("./VotingLib");
var DaoBaseLib = artifacts.require("./DaoBaseLib");

async function linkIfExist(contractName){
try {
await deployer.link(UtilsLib, artifacts.require(contractName));
await deployer.link(VotingLib, artifacts.require(contractName));
await deployer.link(GenericCallerLib, artifacts.require(contractName));
await deployer.link(DaoBaseLib, artifacts.require(contractName));
} catch(error) {}
async function linkContractsWithLibrary(deployer, artifacts, lib, contractNames) {
for(let contractName of contractNames) {
try {
await deployer.link(lib, artifacts.require(contractName));
} catch(error) {
console.log('Not linked:', contractName);
}
}
}

await deployer.deploy(UtilsLib);
await deployer.link(UtilsLib, VotingLib);
await deployer.deploy(VotingLib);
await deployer.link(VotingLib, GenericCallerLib);
await deployer.deploy(GenericCallerLib);
await deployer.deploy(DaoBaseLib);
let thettaContracts = [
"./DaoBase",
"./DaoBaseAuto",
"./DaoBaseImpersonated",
"./DaoBaseMock",
"./DaoBaseWithUnpackers",
"./DaoBaseWithUnpackersMock",
"./DaoStorage",
"./GenericCaller",
"./MoneyflowAuto",
"./StdDaoToken",
"./Voting",
"./VotingLib",
"./GenericCallerLib"
]

contractsArr = [ "./DaoBaseImpersonated"
, "./DaoBaseWithUnpackers"
, "./GenericCaller"
, "./VotingLib"
, "./DaoBaseAuto"
, "./DaoBaseWithUnpackersMock"
, "./DaoBaseMock"
, "./DaoStorage"
, "./StdDaoToken"
, "./Voting"
, "./GenericCallerLib"
, "./GenericCaller"
, "./MoneyflowAuto"
, "./DaoBaseAuto"
, "./GenericCaller"
, "./MoneyflowAuto"
, "./DaoBaseAuto"
, "./DaoBase"
, "./DaoBaseWithUnpackers"
, "./DaoBaseWithUnpackersMock"
, "./DaoBaseMock"
]
function migrateLibs (artifacts, additionalContracts, deployer, network, accounts) {
return deployer.then(async () => {
let contractsArr = thettaContracts.concat(additionalContracts);

try {
let UtilsLib = artifacts.require("./UtilsLib");
await deployer.deploy(UtilsLib);
await linkContractsWithLibrary(deployer, artifacts, UtilsLib, contractsArr);
} catch(error) {
console.log('Thetta.UtilsLib is not deployed');
}

contractsArr = contractsArr.concat(additionalContracts);
try {
let VotingLib = artifacts.require("./VotingLib");
await deployer.deploy(VotingLib);
await linkContractsWithLibrary(deployer, artifacts, VotingLib, contractsArr);
} catch(error) {
console.log('Thetta.VotingLib is not deployed');
}

for(let contract of contractsArr){
await linkIfExist(contract);
try {
let GenericCallerLib = artifacts.require("./GenericCallerLib");
await deployer.deploy(GenericCallerLib);
await linkContractsWithLibrary(deployer, artifacts, GenericCallerLib, contractsArr);
} catch(error) {
console.log('Thetta.GenericCallerLib is not deployed');
}


try {
let DaoBaseLib = artifacts.require("./DaoBaseLib");
await deployer.deploy(DaoBaseLib);
await linkContractsWithLibrary(deployer, artifacts, DaoBaseLib, contractsArr);
} catch(error) {
console.log('Thetta.DaoBaseLib is not deployed');
}
});
};

Expand Down

0 comments on commit ed54c59

Please sign in to comment.