Skip to content

Commit

Permalink
Update deployment script for 1.6 release patch
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova committed Jun 17, 2020
1 parent a10b4dc commit 5d6015a
Showing 1 changed file with 3 additions and 72 deletions.
75 changes: 3 additions & 72 deletions deployment/7_upgrade_1_6.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
const semver = require("semver");
const childProcess = require("child_process");
const ApprovedTransfer = require("../build/ApprovedTransfer");
const RecoveryManager = require("../build/RecoveryManager");
const MultiSig = require("../build/MultiSigWallet");
const ModuleRegistry = require("../build/ModuleRegistry");
const Upgrader = require("../build/SimpleUpgrader");
const DeployManager = require("../utils/deploy-manager.js");
const MultisigExecutor = require("../utils/multisigexecutor.js");
const TokenPriceProvider = require("../build/TokenPriceProvider");
const MakerRegistry = require("../build/MakerRegistry");
const ScdMcdMigration = require("../build/ScdMcdMigration");
const MakerV2Manager = require("../build/MakerV2Manager");
const TransferManager = require("../build/TransferManager");

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

const TARGET_VERSION = "1.6.0";
const MODULES_TO_ENABLE = ["ApprovedTransfer", "RecoveryManager", "MakerV2Manager", "TransferManager"];
const MODULES_TO_DISABLE = ["UniswapManager"];
const MODULES_TO_ENABLE = ["RecoveryManager"];
const MODULES_TO_DISABLE = [];

const BACKWARD_COMPATIBILITY = 1;
const BACKWARD_COMPATIBILITY = 2;

const deploy = async (network) => {
if (!["kovan", "kovan-fork", "staging", "prod"].includes(network)) {
Expand Down Expand Up @@ -50,33 +44,10 @@ const deploy = async (network) => {
const MultiSigWrapper = await deployer.wrapDeployedContract(MultiSig, config.contracts.MultiSigWallet);
const multisigExecutor = new MultisigExecutor(MultiSigWrapper, deploymentWallet, config.multisig.autosign, { gasPrice });

// //////////////////////////////////
// Deploy infrastructure contracts
// //////////////////////////////////

// Deploy and configure Maker Registry
const ScdMcdMigrationWrapper = await deployer.wrapDeployedContract(ScdMcdMigration, config.defi.maker.migration);
const vatAddress = await ScdMcdMigrationWrapper.vat();
const MakerRegistryWrapper = await deployer.deploy(MakerRegistry, {}, vatAddress);
const wethJoinAddress = await ScdMcdMigrationWrapper.wethJoin();
const addCollateralTransaction = await MakerRegistryWrapper.contract.addCollateral(wethJoinAddress, { gasPrice });
await MakerRegistryWrapper.verboseWaitForTransaction(addCollateralTransaction, `Adding join adapter ${wethJoinAddress} to the MakerRegistry`);
const changeMakerRegistryOwnerTx = await MakerRegistryWrapper.contract.changeOwner(config.contracts.MultiSigWallet, { gasPrice });
await MakerRegistryWrapper.verboseWaitForTransaction(changeMakerRegistryOwnerTx, "Set the MultiSig as the owner of the MakerRegistry");
const TokenPriceProviderWrapper = await deployer.wrapDeployedContract(TokenPriceProvider, config.contracts.TokenPriceProvider);

// //////////////////////////////////
// Deploy new modules
// //////////////////////////////////

const ApprovedTransferWrapper = await deployer.deploy(
ApprovedTransfer,
{},
config.contracts.ModuleRegistry,
config.modules.GuardianStorage,
);
newModuleWrappers.push(ApprovedTransferWrapper);

const RecoveryManagerWrapper = await deployer.deploy(
RecoveryManager,
{},
Expand All @@ -89,58 +60,20 @@ const deploy = async (network) => {
);
newModuleWrappers.push(RecoveryManagerWrapper);

const MakerV2ManagerWrapper = await deployer.deploy(
MakerV2Manager,
{},
config.contracts.ModuleRegistry,
config.modules.GuardianStorage,
config.defi.maker.migration,
config.defi.maker.pot,
config.defi.maker.jug,
MakerRegistryWrapper.contractAddress,
config.defi.uniswap.factory,
);
newModuleWrappers.push(MakerV2ManagerWrapper);

const TransferManagerWrapper = await deployer.deploy(
TransferManager,
{},
config.contracts.ModuleRegistry,
config.modules.TransferStorage,
config.modules.GuardianStorage,
TokenPriceProviderWrapper.contractAddress,
config.settings.securityPeriod || 0,
config.settings.securityWindow || 0,
config.settings.defaultLimit || "1000000000000000000",
["test", "staging", "prod"].includes(network) ? config.modules.TransferManager : "0x0000000000000000000000000000000000000000",
);
newModuleWrappers.push(TransferManagerWrapper);

// /////////////////////////////////////////////////
// Update config and Upload ABIs
// /////////////////////////////////////////////////

configurator.updateModuleAddresses({
ApprovedTransfer: ApprovedTransferWrapper.contractAddress,
RecoveryManager: RecoveryManagerWrapper.contractAddress,
MakerV2Manager: MakerV2ManagerWrapper.contractAddress,
TransferManager: TransferManagerWrapper.contractAddress,
});

configurator.updateInfrastructureAddresses({
MakerRegistry: MakerRegistryWrapper.contractAddress,
});

const gitHash = childProcess.execSync("git rev-parse HEAD").toString("utf8").replace(/\n$/, "");
configurator.updateGitHash(gitHash);
await configurator.save();

await Promise.all([
abiUploader.upload(ApprovedTransferWrapper, "modules"),
abiUploader.upload(RecoveryManagerWrapper, "modules"),
abiUploader.upload(MakerV2ManagerWrapper, "modules"),
abiUploader.upload(TransferManagerWrapper, "modules"),
abiUploader.upload(MakerRegistryWrapper, "contracts"),
]);

// //////////////////////////////////
Expand All @@ -157,7 +90,6 @@ const deploy = async (network) => {
// Deploy and Register upgraders
// //////////////////////////////////


let fingerprint;
const versions = await versionUploader.load(BACKWARD_COMPATIBILITY);
for (let idx = 0; idx < versions.length; idx += 1) {
Expand Down Expand Up @@ -208,7 +140,6 @@ const deploy = async (network) => {
await versionUploader.upload(newVersion);
};


module.exports = {
deploy,
};

0 comments on commit 5d6015a

Please sign in to comment.