UNPKG

olympus-module

Version:

Module made by Olympus Labs for easier access to the Olympus protocol through Javascript/Typescript

26 lines (21 loc) 908 B
import { getLatestABI } from './AbiService'; import Promisify from '../utils/Promisify'; import BigNumber from 'bignumber.js'; import Services from '../Services'; export class LockerService extends Services { constructor() { super(); } public async contract(address: string): Promise<any> { return await this.rpcService.contract(await getLatestABI('LOCKER_ABI'), address); } public async checkLockerByTime(productAddress: string, category: string, lockerAddress: string): Promise<boolean> { if (lockerAddress === '0x') { return false; } const contract = await this.rpcService.contract(await getLatestABI('LOCKER_ABI'), lockerAddress); const time = await Promisify(async (cb) => ( await contract.unlockTime(productAddress, this.rpcService.fromAscii(category), cb))) as BigNumber; return Math.floor((new Date().getTime()) / 1000) >= time.toNumber(); } }