import { providers } from 'ethers'; import BaseService from '../commons/BaseService'; import { eEthereumTxType, transactionType } from '../commons/types'; import { HelperContract } from './typechain/HelperContract'; import { HelperContract__factory } from './typechain/HelperContract__factory'; export class HelperContractService extends BaseService { instance: HelperContract; constructor(provider: providers.Provider, address: string) { super(provider, HelperContract__factory); this.instance = this.getContractInstance(address); } public convertApeCoinToPCApe(amount: string, receiver: string) { const tx: () => Promise = this.generateTxCallback({ rawTxMethod: async () => this.instance.populateTransaction.convertApeCoinToPCApe(amount), from: receiver, }); return { tx, txType: eEthereumTxType.OTHERS, gas: this.generateTxPriceEstimation([], tx), }; } public convertPCApeToApeCoin(amount: string, receiver: string) { const tx: () => Promise = this.generateTxCallback({ rawTxMethod: async () => this.instance.populateTransaction.convertPCApeToApeCoin(amount), from: receiver, }); return { tx, txType: eEthereumTxType.OTHERS, gas: this.generateTxPriceEstimation([], tx), }; } }