From d8c8fb4cb28b87c629339452645be9434551ced0 Mon Sep 17 00:00:00 2001 From: Lawrence Wang Date: Tue, 17 Dec 2019 22:07:19 -0800 Subject: [PATCH] simplify dai-plugin-migrations config --- .../contracts/abiMap.json | 3 +- .../contracts/addresses/testnet.json | 2 - packages/dai-plugin-migrations/src/index.js | 38 +++++-------------- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/packages/dai-plugin-migrations/contracts/abiMap.json b/packages/dai-plugin-migrations/contracts/abiMap.json index e313a5799..1fc091a05 100644 --- a/packages/dai-plugin-migrations/contracts/abiMap.json +++ b/packages/dai-plugin-migrations/contracts/abiMap.json @@ -10,5 +10,6 @@ "MIGRATION": "ScdMcdMigration", "MIGRATION_PROXY_ACTIONS": "MigrationProxyActions", "OLD_CHIEF": "DSChief", - "OLD_VOTE_PROXY_FACTORY": "VoteProxyFactory" + "OLD_VOTE_PROXY_FACTORY": "VoteProxyFactory", + "OLD_MKR": "DSToken" } diff --git a/packages/dai-plugin-migrations/contracts/addresses/testnet.json b/packages/dai-plugin-migrations/contracts/addresses/testnet.json index 9982d9107..fb18d969b 100644 --- a/packages/dai-plugin-migrations/contracts/addresses/testnet.json +++ b/packages/dai-plugin-migrations/contracts/addresses/testnet.json @@ -8,8 +8,6 @@ "MCD_POT_1": "0x1fbf51a780232f0cf01195d7021e1bb76612462a", "REDEEMER": "0x396c36f467e6db6c14722e02605d31e9198ae7cf", "OLD_MKR": "0x1e1e0cb82b75fda8d3653bef925bf1babd160067", - "MIGRATION": "0x1f8d3148c725de9d31751c9f8cb764c8ee6d9719", - "MIGRATION_PROXY_ACTIONS": "0x5f295c5589118d2f8eab6488c366d42c0f54882c", "OLD_CHIEF": "0xe50ff8544b50e2e0f25cab27bc85a7a905d5671a", "OLD_VOTE_PROXY_FACTORY": "0x17d4edea99fad126ce0b3ed46646587d067f4f8c" } diff --git a/packages/dai-plugin-migrations/src/index.js b/packages/dai-plugin-migrations/src/index.js index 2c73ffa8b..a63942efd 100644 --- a/packages/dai-plugin-migrations/src/index.js +++ b/packages/dai-plugin-migrations/src/index.js @@ -34,15 +34,10 @@ export const SAI = createCurrency('DAI'); export const DAI = createCurrency('MDAI'); export const MKR = createCurrency('MKR'); -function overrideContractAddresses(network, addressOverrides, contracts) { +function overrideContractAddresses(addressOverrides, contracts) { Object.entries(addressOverrides).forEach(([name, overrideAddress]) => { if (contracts[name]) { - contracts[name] = { - ...contracts[name], - address: { - [network]: overrideAddress || contracts[name].address[network] - } - }; + contracts[name] = { ...contracts[name], address: overrideAddress }; } }); @@ -52,34 +47,21 @@ function overrideContractAddresses(network, addressOverrides, contracts) { export const MDAI_1 = createCurrency('MDAI_1'); export default { - addConfig: (_, { network = 'mainnet', addressOverrides } = {}) => { - const oldMkrData = { - currency: OLD_MKR, - abi: require('../contracts/abis/DSToken.json'), - address: require(`../contracts/addresses/${network}.json`).OLD_MKR, - decimals: 18 - }; - + addConfig: (_, { addressOverrides } = {}) => { const addContracts = addressOverrides - ? overrideContractAddresses(network, addressOverrides, allContracts) + ? overrideContractAddresses(addressOverrides, allContracts) : allContracts; - // remove contracts that don't have an address for the given network - for (let c of Object.keys(addContracts)) { - if ( - typeof addContracts[c].address === 'object' && - !addContracts[c].address[network] - ) { - delete addContracts[c]; - } - } - return { smartContract: { addContracts }, token: { erc20: [ - oldMkrData, - { currency: MDAI_1, address: addContracts.MCD_DAI_1.address[network] } + { + currency: OLD_MKR, + decimals: 18, + address: addContracts.OLD_MKR.address + }, + { currency: MDAI_1, address: addContracts.MCD_DAI_1.address } ] }, additionalServices: [MIGRATION],