Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
require contract abis from within abiMap
Browse files Browse the repository at this point in the history
  • Loading branch information
jparklev committed May 22, 2020
1 parent 378bac3 commit 65d75d6
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 96 deletions.
43 changes: 43 additions & 0 deletions packages/dai-plugin-mcd/contracts/abiMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
exports.default = {
REP: require('./abis/REP.json'),
ZRX: require('./abis/ZRX.json'),
OMG: require('./abis/OMG.json'),
BAT: require('./abis/BAT.json'),
DGD: require('./abis/DGD.json'),
GNT: require('./abis/GNT.json'),
SAI: require('./abis/DSToken.json'),
CDP_MANAGER: require('./abis/DssCdpManager.json'),
ETH: require('./abis/WETH9_.json'),
GET_CDPS: require('./abis/GetCdps.json'),
MCD_ADM: require('./abis/DSRoles.json'),
MCD_CAT: require('./abis/Cat.json'),
MCD_DAI: require('./abis/DSToken.json'),
MCD_DAI_GUARD: require('./abis/DSGuard.json'),
MCD_DEPLOY: require('./abis/DssDeploy.json'),
MCD_FLAP: require('./abis/Flapper.json'),
'MCD_FLIP_*': require('./abis/Flipper.json'),
MCD_FLOP: require('./abis/Flopper.json'),
MCD_GOV: require('./abis/DSToken.json'),
'MCD_JOIN_*': require('./abis/GemJoin.json'),
MCD_JOIN_OMG_A: require('./abis/GemJoin2.json'),
MCD_JOIN_DGD_A: require('./abis/GemJoin2.json'),
MCD_JOIN_GNT_A: require('./abis/GemJoin4.json'),
MCD_JOIN_DAI: require('./abis/DaiJoin.json'),
MCD_JUG: require('./abis/Jug.json'),
MCD_END: require('./abis/End.json'),
MCD_ESM: require('./abis/ESM.json'),
MCD_PAUSE: require('./abis/DSPause.json'),
MCD_PAUSE_PROXY: require('./abis/Plan.json'),
MCD_POT: require('./abis/Pot.json'),
MCD_SPOT: require('./abis/Spotter.json'),
MCD_VAT: require('./abis/Vat.json'),
MCD_VOW: require('./abis/Vow.json'),
MULTICALL: require('./abis/MultiCall.json'),
'PIP_*': require('./abis/DSValue.json'),
PROXY_ACTIONS: require('./abis/DssProxyActions.json'),
PROXY_ACTIONS_DSR: require('./abis/DssProxyActionsDsr.json'),
MIGRATION: require('./abis/ScdMcdMigration.json'),
MIGRATION_PROXY_ACTIONS: require('./abis/MigrationProxyActions.json'),
USDC: require('./abis/USDC.json'),
WBTC: require('./abis/WBTC.json')
};
45 changes: 0 additions & 45 deletions packages/dai-plugin-mcd/contracts/abiMap.json

This file was deleted.

12 changes: 6 additions & 6 deletions packages/dai-plugin-mcd/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createCurrency, createCurrencyRatio } from '@makerdao/currency';
import testnetAddresses from '../contracts/addresses/testnet.json';
import kovanAddresses from '../contracts/addresses/kovan.json';
import mainnetAddresses from '../contracts/addresses/mainnet.json';
import abiMap from '../contracts/abiMap.json';
import abiMap from '../contracts/abiMap';
import CdpManager from './CdpManager';
import SavingsService from './SavingsService';
import CdpTypeService from './CdpTypeService';
Expand All @@ -25,18 +25,18 @@ const { CDP_MANAGER, CDP_TYPE, SYSTEM_DATA, AUCTION, SAVINGS } = ServiceRoles;
let addContracts = reduce(
testnetAddresses,
(result, testnetAddress, name) => {
let abiName = abiMap[name];
if (!abiName) {
let abi = abiMap[name];
if (!abi) {
const prefix = Object.keys(abiMap).find(
k =>
k.substring(k.length - 1) == '*' &&
k.substring(0, k.length - 1) == name.substring(0, k.length - 1)
);
if (prefix) abiName = abiMap[prefix];
if (prefix) abi = abiMap[prefix];
}
if (abiName) {
if (abi) {
result[name] = {
abi: require(`../contracts/abis/${abiName}.json`),
abi,
address: {
testnet: testnetAddress,
kovan: kovanAddresses[name],
Expand Down
15 changes: 15 additions & 0 deletions packages/dai-plugin-migrations/contracts/abiMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
exports.default = {
TUB: require('./abis/SaiTub'),
MCD_END_1: require('./abis/End'),
MCD_VAT_1: require('./abis/Vat'),
GET_CDPS_1: require('./abis/GetCdps'),
CDP_MANAGER_1: require('./abis/DssCdpManager'),
MCD_DAI_1: require('./abis/Dai'),
MCD_POT_1: require('./abis/Pot'),
REDEEMER: require('./abis/Redeemer'),
MIGRATION: require('./abis/ScdMcdMigration'),
MIGRATION_PROXY_ACTIONS: require('./abis/MigrationProxyActions'),
OLD_CHIEF: require('./abis/DSChief'),
OLD_VOTE_PROXY_FACTORY: require('./abis/VoteProxyFactory'),
OLD_MKR: require('./abis/DSToken')
};
15 changes: 0 additions & 15 deletions packages/dai-plugin-migrations/contracts/abiMap.json

This file was deleted.

8 changes: 4 additions & 4 deletions packages/dai-plugin-migrations/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createCurrency } from '@makerdao/currency';
import testnetAddresses from '../contracts/addresses/testnet.json';
import kovanAddresses from '../contracts/addresses/kovan.json';
import mainnetAddresses from '../contracts/addresses/mainnet.json';
import abiMap from '../contracts/abiMap.json';
import abiMap from '../contracts/abiMap';
import MigrationService from './MigrationService';
import { ServiceRoles as ServiceRoles_ } from './constants';
export const ServiceRoles = ServiceRoles_;
Expand All @@ -11,11 +11,11 @@ const { MIGRATION } = ServiceRoles;
// this implementation assumes that all contracts in kovan.json, mainnet.json are also in testnet.json
const allContracts = Object.entries(testnetAddresses).reduce(
(contracts, [name, testnetAddress]) => {
const abiName = abiMap[name];
const abi = abiMap[name];

if (abiName) {
if (abi) {
contracts[name] = {
abi: require(`../contracts/abis/${abiName}.json`),
abi,
address: {
testnet: testnetAddress,
kovan: kovanAddresses[name],
Expand Down
20 changes: 20 additions & 0 deletions packages/dai-plugin-scd/contracts/abiMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
exports.default = {
SAI_PIP: require('./abis/DSValue'),
SAI_PEP: require('./abis/DSValue'),
SAI_PIT: require('./abis/GemPit'),
SAI_SIN: require('./abis/ERC20'),
SAI_MOM: require('./abis/SaiMom'),
SAI_VOX: require('./abis/SaiVox'),
SAI_TUB: require('./abis/SaiTub'),
SAI_TAP: require('./abis/SaiTap'),
SAI_TOP: require('./abis/SaiTop'),
SAI_SKR: require('./abis/ERC20'),
SAI_GEM: require('./abis/WETH9'),
SAI_GOV: require('./abis/ERC20'),
SAI: require('./abis/ERC20'),
SAI_PROXY: require('./abis/SaiProxyCreateAndExecute'),
PROXY_REGISTRY: require('./abis/ProxyRegistry'),
DS_PROXY_FACTORY: require('./abis/DSProxyFactory'),
DS_PROXY: require('./abis/DSProxy'),
MULTICALL: require('./abis/Multicall')
};
20 changes: 0 additions & 20 deletions packages/dai-plugin-scd/contracts/abiMap.json

This file was deleted.

12 changes: 6 additions & 6 deletions packages/dai-plugin-scd/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createCurrency, createCurrencyRatio } from '@makerdao/currency';
import testnetAddresses from '../contracts/addresses/testnet.json';
import kovanAddresses from '../contracts/addresses/kovan.json';
import mainnetAddresses from '../contracts/addresses/mainnet.json';
import abiMap from '../contracts/abiMap.json';
import abiMap from '../contracts/abiMap';
import EthereumCdpService from './EthereumCdpService';
import PriceService from './PriceService';
import TokenConversionService from './TokenConversionService';
Expand All @@ -21,18 +21,18 @@ const { CDP, PRICE, CONVERSION } = ServiceRoles;
let addContracts = reduce(
testnetAddresses,
(result, testnetAddress, name) => {
let abiName = abiMap[name];
if (!abiName) {
let abi = abiMap[name];
if (!abi) {
const prefix = Object.keys(abiMap).find(
k =>
k.substring(k.length - 1) == '*' &&
k.substring(0, k.length - 1) == name.substring(0, k.length - 1)
);
if (prefix) abiName = abiMap[prefix];
if (prefix) abi = abiMap[prefix];
}
if (abiName) {
if (abi) {
result[name] = {
abi: require(`../contracts/abis/${abiName}.json`),
abi,
address: {
testnet: testnetAddress,
kovan: kovanAddresses[name],
Expand Down

0 comments on commit 65d75d6

Please sign in to comment.