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

require abis in abi maps #231

Merged
merged 5 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/dai-plugin-mcd/contracts/abiMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// not run through babel, so we must use an ES5-safe export
module.exports = {
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 @@ -26,18 +26,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
26 changes: 26 additions & 0 deletions packages/dai-plugin-migrations/contracts/abiMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// not run through babel, so we must use an ES5-safe export
module.exports = {
TUB: require('./abis/SaiTub.json'),
MCD_END_1: require('./abis/End.json'),
MCD_VAT_1: require('./abis/Vat.json'),
GET_CDPS_1: require('./abis/GetCdps.json'),
CDP_MANAGER_1: require('./abis/DssCdpManager.json'),
MCD_DAI_1: require('./abis/Dai.json'),
MCD_POT_1: require('./abis/Pot.json'),
MCD_END: require('./abis/End.json'),
MCD_VAT: require('./abis/Vat.json'),
GET_CDPS: require('./abis/GetCdps.json'),
CDP_MANAGER: require('./abis/DssCdpManager.json'),
MCD_DAI: require('./abis/Dai.json'),
MCD_POT: require('./abis/Pot.json'),
REDEEMER: require('./abis/Redeemer.json'),
MIGRATION: require('./abis/ScdMcdMigration.json'),
MIGRATION_PROXY_ACTIONS: require('./abis/MigrationProxyActions.json'),
OLD_CHIEF: require('./abis/DSChief.json'),
OLD_VOTE_PROXY_FACTORY: require('./abis/VoteProxyFactory.json'),
OLD_MKR: require('./abis/DSToken.json'),
'MCD_JOIN_*': require('./abis/GemJoin.json'),
PROXY_ACTIONS_END: require('./abis/DssProxyActionsEnd.json'),
SAI_CAGEFREE: require('./abis/CageFree.json'),
MCD_ESM: require('./abis/ESM.json')
};
25 changes: 0 additions & 25 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
21 changes: 21 additions & 0 deletions packages/dai-plugin-scd/contracts/abiMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// might not be run through babel in the future, so we must use an ES5-safe export
module.exports = {
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