Skip to content

Commit

Permalink
Fix end to end deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova committed Nov 27, 2020
1 parent 85d662d commit c2e213a
Show file tree
Hide file tree
Showing 27 changed files with 225 additions and 286 deletions.
22 changes: 12 additions & 10 deletions deployment/1_setup_test_environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* global artifacts */

global.web3 = web3;

const ENSRegistry = artifacts.require("ENSRegistry");
const ENSRegistryWithFallback = artifacts.require("ENSRegistryWithFallback");
const UniswapFactory = artifacts.require("../lib/uniswap/UniswapFactory");
Expand All @@ -14,7 +16,7 @@ const PartnerDeployer = artifacts.require("PartnerDeployer");
const KyberAdapter = artifacts.require("Kyber");

const utils = require("../utils/utilities.js");
const DeployManager = require("../utils/deploy-manager.js");
const deployManager = require("../utils/deploy-manager.js");

const BYTES32_NULL = "0x0000000000000000000000000000000000000000000000000000000000000000";

Expand Down Expand Up @@ -56,14 +58,8 @@ async function deployParaswap(deploymentAccount) {
return { paraswap: paraswap.address, kyberAdapter: kyberAdapter.address };
}

module.exports = async (callback) => {
// TODO: Maybe get the signer account a better way?
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];

const manager = new DeployManager(deploymentAccount);
await manager.setup();
const { configurator } = manager;
async function main() {
const { configurator, deploymentAccount } = await deployManager.getProps();
const { config } = configurator;

if (config.ENS.deployOwnRegistry) {
Expand Down Expand Up @@ -98,5 +94,11 @@ module.exports = async (callback) => {

// save configuration
await configurator.save();
callback();

console.log("## completed deployment script 1 ##");
}

// For truffle exec
module.exports = function (callback) {
main().then(() => callback()).catch((err) => callback(err));
};
26 changes: 12 additions & 14 deletions deployment/2_deploy_contracts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* global artifacts */
global.web3 = web3;

const GuardianStorage = artifacts.require("GuardianStorage");
const TransferStorage = artifacts.require("TransferStorage");
const LockStorage = artifacts.require("LockStorage");
Expand All @@ -20,21 +22,11 @@ const MakerRegistry = artifacts.require("MakerRegistry");
const ScdMcdMigration = artifacts.require("ScdMcdMigration");

const utils = require("../utils/utilities.js");

const DeployManager = require("../utils/deploy-manager.js");
const deployManager = require("../utils/deploy-manager.js");
const MultisigExecutor = require("../utils/multisigexecutor.js");

module.exports = async (callback) => {
// TODO: Maybe get the signer account a better way?
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];

const manager = new DeployManager(deploymentAccount);
await manager.setup();

const { configurator } = manager;
const { abiUploader } = manager;

async function main() {
const { deploymentAccount, configurator, abiUploader } = await deployManager.getProps();
const newConfig = configurator.config;
const prevConfig = configurator.copyConfig();

Expand Down Expand Up @@ -164,5 +156,11 @@ module.exports = async (callback) => {
abiUploader.upload(DexRegistryWrapper, "contracts"),
abiUploader.upload(BaseWalletWrapper, "contracts"),
]);
callback();

console.log("## completed deployment script 2 ##");
}

// For truffle exec
module.exports = function (callback) {
main().then(() => callback()).catch((err) => callback(err));
};
25 changes: 13 additions & 12 deletions deployment/3_setup_contracts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* global artifacts */
global.web3 = web3;

const ModuleRegistry = artifacts.require("ModuleRegistry");
const ENSManager = artifacts.require("ArgentENSManager");
const ENSResolver = artifacts.require("ArgentENSResolver");
Expand All @@ -7,17 +9,10 @@ const TokenPriceRegistry = artifacts.require("TokenPriceRegistry");
const CompoundRegistry = artifacts.require("CompoundRegistry");
const DexRegistry = artifacts.require("DexRegistry");

const DeployManager = require("../utils/deploy-manager.js");

module.exports = async (callback) => {
// TODO: Maybe get the signer account a better way?
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];

const manager = new DeployManager(deploymentAccount);
await manager.setup();
const deployManager = require("../utils/deploy-manager.js");

const { configurator } = manager;
async function main() {
const { configurator } = await deployManager.getProps();
const { config } = configurator;

const ENSResolverWrapper = await ENSResolver.at(config.contracts.ENSResolver);
Expand Down Expand Up @@ -70,8 +65,14 @@ module.exports = async (callback) => {

for (let idx = 0; idx < wrappers.length; idx += 1) {
const wrapper = wrappers[idx];
console.log(`Set the MultiSig as the owner of ${wrapper._contract.contractName}`);
console.log(`Set the MultiSig as the owner of ${wrapper.constructor.contractName}`);
await wrapper.changeOwner(config.contracts.MultiSigWallet);
}
callback();

console.log("## completed deployment script 3 ##");
}

// For truffle exec
module.exports = function (callback) {
main().then(() => callback()).catch((err) => callback(err));
};
30 changes: 14 additions & 16 deletions deployment/4_finalise_test_environment.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
/* global artifacts */

global.web3 = web3;

const ENS = artifacts.require("ENSRegistryWithFallback");
const ENSReverseRegistrar = artifacts.require("ReverseRegistrar");

const utils = require("../utils/utilities.js");
const DeployManager = require("../utils/deploy-manager.js");
const deployManager = require("../utils/deploy-manager.js");

const BYTES32_NULL = "0x0000000000000000000000000000000000000000000000000000000000000000";

async function deployENSReverseRegistrar(config, owner, overrides) {
async function deployENSReverseRegistrar(config, owner) {
const ENSRegistryWrapper = await ENS.at(config.ENS.ensRegistry);
const ENSReverseRegistrarWrapper = await ENSReverseRegistrar.new(config.ENS.ensRegistry, config.contracts.ENSResolver);

console.log("Create the reverse namespace");
await ENSRegistryWrapper.setSubnodeOwner(BYTES32_NULL, utils.sha3("reverse"), owner, overrides);
await ENSRegistryWrapper.setSubnodeOwner(BYTES32_NULL, utils.sha3("reverse"), owner);

console.log("Create the addr.reverse namespace and make the ENS reverse registrar the owner");
await ENSRegistryWrapper.setSubnodeOwner(
utils.namehash("reverse"),
utils.sha3("addr"),
ENSReverseRegistrarWrapper.address,
overrides,
);
ENSReverseRegistrarWrapper.address);
}

module.exports = async (callback) => {
// TODO: Maybe get the signer account a better way?
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];

const manager = new DeployManager(deploymentAccount);
await manager.setup();

const { configurator } = manager;
async function main() {
const { deploymentAccount, configurator } = await deployManager.getProps();
const { config } = configurator;

if (config.ENS.deployOwnRegistry) {
await deployENSReverseRegistrar(config, deploymentAccount);
}

callback();
console.log("## completed deployment script 4 ##");
}

// For truffle exec
module.exports = function (callback) {
main().then(() => callback()).catch((err) => callback(err));
};
26 changes: 12 additions & 14 deletions deployment/5_deploy_modules.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* global artifacts */

global.web3 = web3;

const childProcess = require("child_process");

const ApprovedTransfer = artifacts.require("ApprovedTransfer");
Expand All @@ -13,24 +16,14 @@ const TransferManager = artifacts.require("TransferManager");
const RelayerManager = artifacts.require("RelayerManager");
const VersionManager = artifacts.require("VersionManager");

const DeployManager = require("../utils/deploy-manager.js");
const deployManager = require("../utils/deploy-manager.js");

// ///////////////////////////////////////////////////////
// Version 2.1
// ///////////////////////////////////////////////////////

module.exports = async (callback) => {
// TODO: Maybe get the signer account a better way?
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];

const manager = new DeployManager(deploymentAccount);
const { network } = manager;
await manager.setup();

const { configurator } = manager;
const { abiUploader } = manager;

async function main() {
const { network, configurator, abiUploader } = await deployManager.getProps();
const { config } = configurator;
console.log(config);

Expand Down Expand Up @@ -173,5 +166,10 @@ module.exports = async (callback) => {
abiUploader.upload(VersionManagerWrapper, "modules"),
]);

callback();
console.log("## completed deployment script 5 ##");
}

// For truffle exec
module.exports = function (callback) {
main().then(() => callback()).catch((err) => callback(err));
};
56 changes: 27 additions & 29 deletions deployment/6_register_modules.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* global artifacts */

global.web3 = web3;

const ModuleRegistry = artifacts.require("ModuleRegistry");
const MultiSig = artifacts.require("MultiSigWallet");

Expand All @@ -16,36 +18,27 @@ const RelayerManager = artifacts.require("RelayerManager");
const VersionManager = artifacts.require("VersionManager");

const utils = require("../utils/utilities.js");

const DeployManager = require("../utils/deploy-manager.js");
const deployManager = require("../utils/deploy-manager.js");
const MultisigExecutor = require("../utils/multisigexecutor.js");

module.exports = async (callback) => {
// TODO: Maybe get the signer account a better way?
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];

const manager = new DeployManager(deploymentAccount);
await manager.setup();

const { configurator } = manager;
const { versionUploader } = manager;
async function main() {
const { deploymentAccount, configurator, versionUploader } = await deployManager.getProps();
const { config } = configurator;

const GuardianManagerWrapper = await GuardianManager.new(config.modules.GuardianManager);
const LockManagerWrapper = await LockManager.new(config.modules.LockManager);
const RecoveryManagerWrapper = await RecoveryManager.new(config.modules.RecoveryManager);
const ApprovedTransferWrapper = await ApprovedTransfer.new(config.modules.ApprovedTransfer);
const TransferManagerWrapper = await TransferManager.new(config.modules.TransferManager);
const TokenExchangerWrapper = await TokenExchanger.new(config.modules.TokenExchanger);
const NftTransferWrapper = await NftTransfer.new(config.modules.NftTransfer);
const CompoundManagerWrapper = await CompoundManager.new(config.modules.CompoundManager);
const MakerV2ManagerWrapper = await MakerV2Manager.new(config.modules.MakerV2Manager);
const RelayerManagerWrapper = await RelayerManager.new(config.modules.RelayerManager);
const VersionManagerWrapper = await VersionManager.new(config.modules.VersionManager);

const ModuleRegistryWrapper = await ModuleRegistry.new(config.contracts.ModuleRegistry);
const MultiSigWrapper = await MultiSig.new(config.contracts.MultiSigWallet);
const GuardianManagerWrapper = await GuardianManager.at(config.modules.GuardianManager);
const LockManagerWrapper = await LockManager.at(config.modules.LockManager);
const RecoveryManagerWrapper = await RecoveryManager.at(config.modules.RecoveryManager);
const ApprovedTransferWrapper = await ApprovedTransfer.at(config.modules.ApprovedTransfer);
const TransferManagerWrapper = await TransferManager.at(config.modules.TransferManager);
const TokenExchangerWrapper = await TokenExchanger.at(config.modules.TokenExchanger);
const NftTransferWrapper = await NftTransfer.at(config.modules.NftTransfer);
const CompoundManagerWrapper = await CompoundManager.at(config.modules.CompoundManager);
const MakerV2ManagerWrapper = await MakerV2Manager.at(config.modules.MakerV2Manager);
const RelayerManagerWrapper = await RelayerManager.at(config.modules.RelayerManager);
const VersionManagerWrapper = await VersionManager.at(config.modules.VersionManager);

const ModuleRegistryWrapper = await ModuleRegistry.at(config.contracts.ModuleRegistry);
const MultiSigWrapper = await MultiSig.at(config.contracts.MultiSigWallet);

const wrappers = [VersionManagerWrapper];

Expand Down Expand Up @@ -86,7 +79,7 @@ module.exports = async (callback) => {
for (let idx = 0; idx < wrappers.length; idx += 1) {
const wrapper = wrappers[idx];
await multisigExecutor.executeCall(ModuleRegistryWrapper, "registerModule",
[wrapper.address, utils.asciiToBytes32(wrapper._contract.contractName)]);
[wrapper.address, utils.asciiToBytes32(wrapper.constructor.contractName)]);
}

console.log("Set the MultiSig as the owner of VersionManagerWrapper");
Expand All @@ -96,7 +89,7 @@ module.exports = async (callback) => {
// Upload Version
// //////////////////////////////////

const modules = wrappers.map((wrapper) => ({ address: wrapper.address, name: wrapper._contract.contractName }));
const modules = wrappers.map((wrapper) => ({ address: wrapper.address, name: wrapper.constructor.contractName }));
const version = {
modules,
fingerprint: utils.versionFingerprint(modules),
Expand All @@ -105,5 +98,10 @@ module.exports = async (callback) => {
};
await versionUploader.upload(version);

callback();
console.log("## completed deployment script 6 ##");
}

// For truffle exec
module.exports = function (callback) {
main().then(() => callback()).catch((err) => callback(err));
};
16 changes: 6 additions & 10 deletions scripts/deploy_custom_upgrader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ const MultiSig = artifacts.require("MultiSigWallet");
const Upgrader = artifacts.require("SimpleUpgrader");

const utils = require("../utils/utilities.js");
const DeployManager = require("../utils/deploy-manager.js");
const deployManager = require("../utils/deploy-manager.js");
const MultisigExecutor = require("../utils/multisigexecutor.js");

async function main() {
const { configurator } = await deployManager.getProps();
const { config } = configurator;
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];

const modulesToRemove = [];
const modulesToAdd = [
"0x624EbBd0f4169E2e11861618045491b6A4e29E77",
Expand All @@ -19,15 +24,6 @@ async function main() {
];
const upgraderName = "0x4ef2f261_0xee7263da";

// TODO: Maybe get the signer account a better way?
const accounts = await web3.eth.getAccounts();
const deploymentAccount = accounts[0];
const manager = new DeployManager(deploymentAccount);
await manager.setup();

const { configurator } = manager;
const { config } = configurator;

const ModuleRegistryWrapper = await ModuleRegistry.at(config.contracts.ModuleRegistry);
const MultiSigWrapper = await MultiSig.at(config.contracts.MultiSigWallet);
const multisigExecutor = new MultisigExecutor(MultiSigWrapper, deploymentAccount, config.multisig.autosign);
Expand Down
Loading

0 comments on commit c2e213a

Please sign in to comment.