"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const R = __importStar(require("ramda"));
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
var Contracts;
(function (Contracts) {
    Contracts["Accounting"] = "Accounting";
    Contracts["AccountingFactory"] = "AccountingFactory";
    Contracts["AmguConsumer"] = "AmguConsumer";
    Contracts["AssetBlacklist"] = "AssetBlacklist";
    Contracts["AssetWhitelist"] = "AssetWhitelist";
    Contracts["BurnableToken"] = "BurnableToken";
    Contracts["CanonicalPriceFeed"] = "CanonicalPriceFeed";
    Contracts["ConversionRates"] = "ConversionRates";
    Contracts["Engine"] = "Engine";
    Contracts["EthfinexExchangeEfx"] = "ExchangeEfx";
    Contracts["EthfinexAdapter"] = "EthfinexAdapter";
    Contracts["ERC20Proxy"] = "ERC20Proxy";
    Contracts["ExchangeAdapter"] = "ExchangeAdapter";
    Contracts["FalsePolicy"] = "FalsePolicy";
    Contracts["FeeManager"] = "FeeManager";
    Contracts["FeeManagerFactory"] = "FeeManagerFactory";
    Contracts["FundFactory"] = "FundFactory";
    Contracts["FundRanking"] = "FundRanking";
    Contracts["Hub"] = "Hub";
    Contracts["KyberAdapter"] = "KyberAdapter";
    Contracts["KyberNetwork"] = "KyberNetwork";
    Contracts["KyberNetworkProxy"] = "KyberNetworkProxy";
    Contracts["KyberPriceFeed"] = "KyberPriceFeed";
    Contracts["KyberReserve"] = "KyberReserve";
    Contracts["KyberWhiteList"] = "KyberWhiteList";
    Contracts["MaliciousToken"] = "MaliciousToken";
    Contracts["ManagementFee"] = "ManagementFee";
    Contracts["MatchingMarket"] = "MatchingMarket";
    Contracts["MatchingMarketAdapter"] = "MatchingMarketAdapter";
    Contracts["MatchingMarketAccessor"] = "MatchingMarketAccessor";
    Contracts["MaxConcentration"] = "MaxConcentration";
    Contracts["MaxPositions"] = "MaxPositions";
    Contracts["MockAccounting"] = "MockAccounting";
    Contracts["MockAdapter"] = "MockAdapter";
    Contracts["MockFee"] = "MockFee";
    Contracts["MockFeeManager"] = "MockFeeManager";
    Contracts["MockHub"] = "MockHub";
    Contracts["MockRegistry"] = "MockRegistry";
    Contracts["MockShares"] = "MockShares";
    Contracts["MockVersion"] = "MockVersion";
    Contracts["Participation"] = "Participation";
    Contracts["ParticipationFactory"] = "ParticipationFactory";
    Contracts["PerformanceFee"] = "PerformanceFee";
    Contracts["PermissiveAuthority"] = "PermissiveAuthority";
    Contracts["PolicyManager"] = "PolicyManager";
    Contracts["PolicyManagerFactory"] = "PolicyManagerFactory";
    Contracts["PreminedToken"] = "PreminedToken";
    Contracts["PriceSourceInterface"] = "PriceSourceInterface";
    Contracts["PriceTolerance"] = "PriceTolerance";
    Contracts["Registry"] = "Registry";
    Contracts["SelfDestructing"] = "SelfDestructing";
    Contracts["Shares"] = "Shares";
    Contracts["SharesFactory"] = "SharesFactory";
    Contracts["Spoke"] = "Spoke";
    Contracts["StakingPriceFeed"] = "StakingPriceFeed";
    Contracts["StandardToken"] = "StandardToken";
    Contracts["TestingPriceFeed"] = "TestingPriceFeed";
    Contracts["Trading"] = "Trading";
    Contracts["TradingFactory"] = "TradingFactory";
    Contracts["TruePolicy"] = "TruePolicy";
    Contracts["UserWhitelist"] = "UserWhitelist";
    Contracts["Vault"] = "Vault";
    Contracts["VaultFactory"] = "VaultFactory";
    Contracts["Version"] = "Version";
    Contracts["Weth"] = "WETH";
    Contracts["WrapperLock"] = "WrapperLock";
    Contracts["WrapperLockEth"] = "WrapperLockEth";
    Contracts["WrapperRegistryEFX"] = "WrapperRegistryEFX";
    Contracts["ZeroExAdapter"] = "ZeroExV2Adapter";
    Contracts["ZeroExExchange"] = "Exchange";
})(Contracts = exports.Contracts || (exports.Contracts = {}));
// HINT: Link the interfaces instead of the implementations wherever possible
// (to maintain extensibility)
// prettier-ignore
exports.requireMap = {
    [Contracts.Accounting]: require('../out/Accounting.abi.json'),
    [Contracts.AccountingFactory]: require(`../out/${Contracts.AccountingFactory}.abi.json`),
    [Contracts.AmguConsumer]: require('../out/AmguConsumer.abi.json'),
    [Contracts.AssetBlacklist]: require('../out/AssetBlacklist.abi.json'),
    [Contracts.AssetWhitelist]: require('../out/AssetWhitelist.abi.json'),
    [Contracts.BurnableToken]: require(`../out/${Contracts.BurnableToken}.abi.json`),
    [Contracts.CanonicalPriceFeed]: require(`../out/${Contracts.CanonicalPriceFeed}.abi.json`),
    [Contracts.ERC20Proxy]: require(`../out/${Contracts.ERC20Proxy}.abi.json`),
    [Contracts.Engine]: require('../out/Engine.abi.json'),
    [Contracts.EthfinexAdapter]: require(`../out/${Contracts.EthfinexAdapter}.abi.json`),
    [Contracts.EthfinexExchangeEfx]: require(`../out/${Contracts.EthfinexExchangeEfx}.abi.json`),
    [Contracts.ExchangeAdapter]: require(`../out/${Contracts.ExchangeAdapter}.abi.json`),
    [Contracts.FalsePolicy]: require('../out/FalsePolicy.abi.json'),
    [Contracts.FeeManager]: require('../out/FeeManager.abi.json'),
    [Contracts.FeeManagerFactory]: require(`../out/${Contracts.FeeManagerFactory}.abi.json`),
    [Contracts.FundFactory]: require('../out/FundFactory.abi.json'),
    [Contracts.FundRanking]: require('../out/FundRanking.abi.json'),
    [Contracts.Hub]: require('../out/Hub.abi.json'),
    [Contracts.MockAdapter]: require('../out/MockAdapter.abi.json'),
    [Contracts.ManagementFee]: require('../out/ManagementFee.abi.json'),
    [Contracts.MatchingMarket]: require('../out/MatchingMarket.abi.json'),
    [Contracts.MatchingMarketAdapter]: require('../out/MatchingMarketAdapter.abi.json'),
    [Contracts.MatchingMarketAccessor]: require('../out/MatchingMarketAccessor.abi.json'),
    [Contracts.KyberNetwork]: require('../out/KyberNetwork.abi.json'),
    [Contracts.KyberPriceFeed]: require(`../out/${Contracts.KyberPriceFeed}.abi.json`),
    [Contracts.KyberReserve]: require('../out/KyberReserve.abi.json'),
    [Contracts.KyberNetworkProxy]: require('../out/KyberNetworkProxy.abi.json'),
    [Contracts.KyberAdapter]: require('../out/KyberAdapter.abi.json'),
    [Contracts.ConversionRates]: require('../out/ConversionRates.abi.json'),
    [Contracts.KyberWhiteList]: require('../out/KyberWhiteList.abi.json'),
    [Contracts.MaliciousToken]: require('../out/MaliciousToken.abi.json'),
    [Contracts.MaxPositions]: require('../out/MaxPositions.abi.json'),
    [Contracts.MaxConcentration]: require('../out/MaxConcentration.abi.json'),
    [Contracts.MockAccounting]: require('../out/MockAccounting.abi.json'),
    [Contracts.MockFeeManager]: require('../out/MockFeeManager.abi.json'),
    [Contracts.MockFee]: require('../out/MockFee.abi.json'),
    [Contracts.MockHub]: require('../out/MockHub.abi.json'),
    [Contracts.MockRegistry]: require('../out/MockRegistry.abi.json'),
    [Contracts.MockShares]: require('../out/MockShares.abi.json'),
    [Contracts.MockVersion]: require('../out/MockVersion.abi.json'),
    [Contracts.MatchingMarket]: require('../out/MatchingMarket.abi.json'),
    [Contracts.MatchingMarketAdapter]: require('../out/MatchingMarketAdapter.abi.json'),
    [Contracts.Participation]: require('../out/Participation.abi.json'),
    [Contracts.ParticipationFactory]: require(`../out/${Contracts.ParticipationFactory}.abi.json`),
    [Contracts.PerformanceFee]: require('../out/PerformanceFee.abi.json'),
    [Contracts.PermissiveAuthority]: require(`../out/${Contracts.PermissiveAuthority}.abi.json`),
    [Contracts.PolicyManager]: require('../out/PolicyManager.abi.json'),
    [Contracts.PolicyManagerFactory]: require(`../out/${Contracts.PolicyManagerFactory}.abi.json`),
    [Contracts.PreminedToken]: require('../out/PreminedToken.abi.json'),
    [Contracts.PriceTolerance]: require(`../out/${Contracts.PriceTolerance}.abi.json`),
    [Contracts.Registry]: require('../out/Registry.abi.json'),
    [Contracts.PriceSourceInterface]: require('../out/PriceSourceInterface.abi.json'),
    [Contracts.SelfDestructing]: require('../out/SelfDestructing.abi.json'),
    [Contracts.Shares]: require('../out/Shares.abi.json'),
    [Contracts.SharesFactory]: require(`../out/${Contracts.SharesFactory}.abi.json`),
    [Contracts.Spoke]: require(`../out/${Contracts.Spoke}.abi.json`),
    [Contracts.StakingPriceFeed]: require(`../out/${Contracts.StakingPriceFeed}.abi.json`),
    [Contracts.StandardToken]: require('../out/StandardToken.abi.json'),
    [Contracts.TestingPriceFeed]: require('../out/TestingPriceFeed.abi.json'),
    [Contracts.Trading]: require('../out/Trading.abi.json'),
    [Contracts.TradingFactory]: require(`../out/${Contracts.TradingFactory}.abi.json`),
    [Contracts.TruePolicy]: require('../out/TruePolicy.abi.json'),
    [Contracts.UserWhitelist]: require(`../out/${Contracts.UserWhitelist}.abi.json`),
    [Contracts.Vault]: require('../out/Vault.abi.json'),
    [Contracts.VaultFactory]: require('../out/VaultFactory.abi.json'),
    [Contracts.Version]: require('../out/Version.abi.json'),
    [Contracts.Weth]: require('../out/WETH.abi.json'),
    [Contracts.WrapperLock]: require(`../out/${Contracts.WrapperLock}.abi.json`),
    [Contracts.WrapperLockEth]: require(`../out/${Contracts.WrapperLockEth}.abi.json`),
    [Contracts.WrapperRegistryEFX]: require(`../out/${Contracts.WrapperRegistryEFX}.abi.json`),
    [Contracts.ZeroExExchange]: require('../out/Exchange.abi.json'),
    [Contracts.ZeroExAdapter]: require('../out/ZeroExV2Adapter.abi.json'),
};
const allAbis = R.toPairs(exports.requireMap);
const onlyEvents = R.propEq('type', 'event');
exports.eventSignatureABIMap = allAbis.reduce((carry, [contract, abi]) => {
    const events = R.filter(onlyEvents, abi);
    const signatureToEvents = R.map(eventAbi => [
        web3_eth_abi_1.default.encodeEventSignature(eventAbi),
        eventAbi,
    ])(events);
    return Object.assign({}, carry, R.fromPairs(signatureToEvents));
}, {});
// Note: We need this as a string enum to have a readable export to JSON
var Exchanges;
(function (Exchanges) {
    Exchanges["MatchingMarket"] = "MatchingMarket";
    Exchanges["KyberNetwork"] = "KyberNetwork";
    Exchanges["ZeroEx"] = "ZeroEx";
    Exchanges["Ethfinex"] = "Ethfinex";
})(Exchanges = exports.Exchanges || (exports.Exchanges = {}));
