import { ContractRunner, ethers } from 'ethers' import { metricsFactoryAbi } from './abi' import { createAuthenticatedPropertiesCountCaller } from './authenticatedPropertiesCount' import { createMetricsOfPropertyCaller } from './metricsOfProperty' import { createMetricsCountCaller } from './metricsCount' export type MetricsFactoryContract = { readonly authenticatedPropertiesCount: () => Promise readonly metricsCount: () => Promise readonly metricsOfProperty: ( propertyAddress: string, ) => Promise readonly contract: () => ethers.Contract } // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types export const createMetricsFactoryContract = (provider: ContractRunner) => (address: string): MetricsFactoryContract => { const contract = new ethers.Contract( address, [...metricsFactoryAbi], provider, ) return { authenticatedPropertiesCount: createAuthenticatedPropertiesCountCaller(contract), metricsCount: createMetricsCountCaller(contract), metricsOfProperty: createMetricsOfPropertyCaller(contract), contract: () => contract, } }