diff --git a/src/price.ts b/src/price.ts index 62065e1..b6a0a0b 100644 --- a/src/price.ts +++ b/src/price.ts @@ -1,10 +1,10 @@ import { Currency, PriceCurrencyFormat } from "./currency"; import { approxScaleBigInt } from "./number"; -export type Price = { +export interface Price { value: bigint; currency: Currency; -}; +} // An ExchangeRates object maps different currencies to their rate in USD, // which is a number value. One example of an ExchangeRates object would be: diff --git a/src/time.ts b/src/time.ts index 1f6b680..52acea8 100644 --- a/src/time.ts +++ b/src/time.ts @@ -134,3 +134,19 @@ export function prettyTimestampDiffFromNow(timestamp: bigint): string { return "less than an hour"; } } + +export interface ValidityPeriod { + validFrom: bigint; + validUntil: bigint; +} + +export const createValidityPeriod = ( + validFrom: bigint, + validUntil: bigint +): ValidityPeriod => { + if (validFrom > validUntil) + throw new Error( + "Error creating ValidityPeriod. validFrom must be less than validUntil" + ); + return { validFrom, validUntil }; +};