import type { Amount } from "./types.js"; /** Why an amount was refused. Lets one caller phrase its own message for one case without * re-deriving the arithmetic (`grants.ts` does this for its sub-cent wording). */ export type AmountErrorCode = "not-finite" | "unknown-currency" | "currency-mismatch" | "too-large" | "sub-unit"; /** A refused amount. `RangeError` so existing `toThrow(RangeError)` callers keep working. */ export declare class AmountError extends RangeError { readonly code: AmountErrorCode; constructor(code: AmountErrorCode, message: string); } /** * Minor-unit exponent for an ISO-4217 code (USD → 2, JPY → 0, KWD → 3). * * Throws on a code it does not know. Defaulting an unrecognised code to 2 reads a typo * (`"JYP"`) as an ordinary two-decimal currency — a 100× error for JPY, which is precisely * the case the table is here to catch. */ export declare function exponentFor(currency: string): number; /** * Major units (19.99) → minor units (1999). Refuses anything it cannot convert exactly. * * The conversion runs through a fixed-decimal STRING rather than `Math.round(v * 100)`, * because that multiplication is wrong for values a catalog really holds * (`1.13 * 100 === 112.99999999999999`). Formatting first makes it exact. */ export declare function toMinorUnits(major: number, currency: string): number; /** Minor units (1999) → major units (19.99). For DISPLAY and legacy interop only. */ export declare function toMajorUnits(minor: number, currency: string): number; /** Build an AP2 `Amount` from the gate's historical float. Currency is normalised upper-case. */ export declare function amountFrom(major: number, currency: string): Amount; /** An AP2 `Amount` straight from minor units — no conversion, for values already integral. * No `MAX_CONVERTIBLE` ceiling here: an integer already IS the minor-unit value, so it is * exact anywhere a safe integer is. */ export declare function amountOfMinor(minor: number, currency: string): Amount; /** * Do two amounts denote the same money? Currency-strict: a USD amount and a EUR amount with * equal integers are NOT equal. * * A mismatch answers `false` rather than throwing, and that is deliberate: this predicate * guards amount binding, where the amount being compared can come off the wire. Throwing * would turn an attacker-chosen currency into a 500 instead of a clean refusal, so the * currency check fails CLOSED. `sumAmounts` throws instead, because a mixed-currency sum has * no fail-closed answer to give. */ export declare function amountsEqual(a: Amount, b: Amount): boolean; /** * Sum amounts in a single currency. * * Throws on a mixed-currency sum rather than guessing, on a non-integer member (a float here * means someone skipped `toMinorUnits`, and invariant 3's whole point is that these * comparisons are integer), and on a running total that leaves the safe-integer range. */ export declare function sumAmounts(amounts: ReadonlyArray, currency: string): Amount; /** Human-readable, for pages and refusal messages. Never used in a comparison. */ export declare function formatAmount(a: Amount): string;