import { AbiItem } from "web3-utils";

// seems like web3 typings for AbiItems are broken. use 'require' for abi jsons instead of import.
export function getAbi(fileName: string): AbiItem[] {
  // CAUTION: the explicit listing of each abi is required for browser support (otherwise webpack does not include the abis in the output bundle)
  switch (fileName) {
    case "MasterDAOFactory.json":
      return require("./MasterDAOFactory.json");
    case "DAORegistry.json":
      return require("./DAORegistry.json");
    case "DAOMemberStorage.json":
      return require("./DAOMemberStorage.json");
    case "DAOParameterStorage.json":
      return require("./DAOParameterStorage.json");
    case "DAOVault.json":
      return require("./DAOVault.json");
    case "PermissionManager.json":
      return require("./PermissionManager.json");
    case "DAOVoting.json":
      return require("./DAOVoting.json");
    default:
      throw new RangeError("Unknown abi file name: " + fileName);
  }
}
