import { BigNumber } from 'ethers' ; import { FutureBoolean } from './boolean' ; import { Future , MaybeFuture } from './future' ; export type NumberLike = MaybeFuture < number > | MaybeFuture < BigNumber > ; export function resolveNumberLike ( value ) { const resolved = Future . resolve ( value ) ; return BigNumber . from ( resolved ) ; } export class FutureNumber extends Future < BigNumber > { add ( other ) { return new FutureNumber ( ( ) => this . resolve ( ) . add ( resolveNumberLike ( other ) ) ) ; } sub ( other ) { return new FutureNumber ( ( ) => this . resolve ( ) . sub ( resolveNumberLike ( other ) ) ) ; } mul ( other ) { return new FutureNumber ( ( ) => this . resolve ( ) . mul ( resolveNumberLike ( other ) ) ) ; } div ( other ) { return new FutureNumber ( ( ) => this . resolve ( ) . div ( resolveNumberLike ( other ) ) ) ; } mod ( other ) { return new FutureNumber ( ( ) => this . resolve ( ) . mod ( resolveNumberLike ( other ) ) ) ; } pow ( other ) { return new FutureNumber ( ( ) => this . resolve ( ) . pow ( resolveNumberLike ( other ) ) ) ; } lt ( other ) { return new FutureBoolean ( ( ) => this . resolve ( ) . lt ( resolveNumberLike ( other ) ) ) ; } lte ( other ) { return new FutureBoolean ( ( ) => this . resolve ( ) . lte ( resolveNumberLike ( other ) ) ) ; } gt ( other ) { return new FutureBoolean ( ( ) => this . resolve ( ) . gt ( resolveNumberLike ( other ) ) ) ; } gte ( other ) { return new FutureBoolean ( ( ) => this . resolve ( ) . gte ( resolveNumberLike ( other ) ) ) ; } equals ( other ) { return new FutureBoolean ( ( ) => this . resolve ( ) . eq ( resolveNumberLike ( other ) ) ) ; } }