import { providers } from 'ethers'; import BaseService from '../commons/BaseService'; import { eEthereumTxType, transactionType } from '../commons/types'; import { TimeLock } from './typechain/TimeLock'; import { TimeLock__factory } from './typechain/TimeLock__factory'; export class TimeLockService extends BaseService { public instance: TimeLock; constructor(provider: providers.Provider, contractAddr: string) { super(provider, TimeLock__factory); this.instance = this.getContractInstance(contractAddr); } public async claim(agreementIds: string[], user: string) { const txCallback: () => Promise = this.generateTxCallback({ rawTxMethod: async () => this.instance.populateTransaction.claim(agreementIds), from: user, }); return { tx: txCallback, txType: eEthereumTxType.OTHERS, gas: this.generateTxPriceEstimation([], txCallback), }; } public async claimMoonbirds(agreementIds: string[], user: string) { const txCallback: () => Promise = this.generateTxCallback({ rawTxMethod: async () => this.instance.populateTransaction.claimMoonBirds(agreementIds), from: user, }); return { tx: txCallback, txType: eEthereumTxType.OTHERS, gas: this.generateTxPriceEstimation([], txCallback), }; } public async claimETH(agreementIds: string[], user: string) { const txCallback: () => Promise = this.generateTxCallback({ rawTxMethod: async () => this.instance.populateTransaction.claimETH(agreementIds), from: user, }); return { tx: txCallback, txType: eEthereumTxType.OTHERS, gas: this.generateTxPriceEstimation([], txCallback), }; } public async claimPunks(agreementIds: string[], user: string) { const txCallback: () => Promise = this.generateTxCallback({ rawTxMethod: async () => this.instance.populateTransaction.claimPunk(agreementIds), from: user, }); return { tx: txCallback, txType: eEthereumTxType.OTHERS, gas: this.generateTxPriceEstimation([], txCallback), }; } public async getAgreement(agreementId: string) { return this.instance.getAgreement(agreementId); } public async getContractFrozenStatus() { return this.instance.frozen(); } }