import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import { contracts } from "./contract.constants";
export const getContractCodes = (chainNetwork, category) => contracts.filter(contract => !category || contract.category === category).map(contract => ({
  name: contract.name,
  code: contract.code[chainNetwork]
}));
export const getContractCode = (chainNetwork, contractName) => {
  var _contracts$find$code$, _contracts$find;
  return (_contracts$find$code$ = (_contracts$find = contracts.find(contract => contract.name === contractName)) === null || _contracts$find === void 0 ? void 0 : _contracts$find.code[chainNetwork]) !== null && _contracts$find$code$ !== void 0 ? _contracts$find$code$ : -1;
};
export const getContractAddress = (chainNetwork, contractName) => {
  var _contracts$find$addre, _contracts$find2;
  const addresses = (_contracts$find$addre = (_contracts$find2 = contracts.find(contract => contract.name === contractName)) === null || _contracts$find2 === void 0 ? void 0 : _contracts$find2.address) !== null && _contracts$find$addre !== void 0 ? _contracts$find$addre : {};
  return addresses[chainNetwork];
};
export const getContractData = (chainNetwork, contractName) => {
  const data = contracts.find(contract => contract.name === contractName);
  return data !== null && data !== void 0 && data.code ? _objectSpread(_objectSpread({}, data), {}, {
    code: data.code[chainNetwork],
    address: data.address[chainNetwork]
  }) : undefined;
};