Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
refactor: Include ValidityPeriod logic
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoAguzzi committed Mar 18, 2024
1 parent 7a22e0a commit ec904b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/price.ts
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
16 changes: 16 additions & 0 deletions src/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

0 comments on commit ec904b9

Please sign in to comment.