/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import { usd, type Amount } from '../../src/money.js'; import type { EntitlementAttributes, Operation, Principal, Recipient } from '../../src/contract.js'; import type { AccountRef } from '../../src/accounts.js'; import type { Leg, Velocity } from '../../src/ports.js'; /** A CREDIT amount from a dollars-and-cents string like '12.34'. */ export declare const credit: (dollars: string) => Amount; export declare const emptyVelocity: (subject: string) => Velocity; /** Builds a USD amount from a dollars-and-cents string like `'12.34'`. */ export { usd }; /** A user actor; users may only act on their own accounts. */ export declare const principal: (userId: string) => Principal; export declare const topUp: (o: { userId: string; amount: Amount; source?: string; actor?: Principal; }) => Operation; export declare const grantPromo: (o: { userId: string; amount: Amount; expiresAt?: number; actor?: Principal; }) => Operation; export declare const spend: (o: { buyerId: string; sku: string; price: Amount; recipients: Recipient[]; ageRestricted?: boolean; giftTo?: string; actor?: Principal; orderId?: string; }) => Operation; export declare const refund: (o: { orderId: string; reason?: string; actor?: Principal; }) => Operation; export declare const clawback: (o: { userId: string; amount: Amount; orderId?: string; key?: string; reason?: string; actor?: Principal; }) => Operation; export declare const requestPayout: (o: { userId: string; amount: Amount; actor?: Principal; }) => Operation; export declare const settlePayout: (o: { sagaId: string; providerRef?: string; providerAmount?: Amount; actor?: Principal; }) => Operation; export declare const subscribe: (o: { userId: string; sellerId: string; sku: string; price: Amount; periodMs?: number; actor?: Principal; }) => Operation; export declare const cancelSubscription: (o: { subscriptionId: string; actor?: Principal; }) => Operation; export declare const grantEntitlement: (o: { userId: string; sku: string; attrs?: EntitlementAttributes; actor?: Principal; }) => Operation; export declare const revokeEntitlement: (o: { userId: string; sku: string; reason?: string; actor?: Principal; }) => Operation; export declare const adjust: (o: { account: AccountRef; amount: Amount; reason: string; actor?: Principal; }) => Operation; export declare const reverse: (o: { txnId: string; reason: string; actor?: Principal; }) => Operation; export declare const reversePayout: (o: { userId: string; sagaId: string; reason?: string; providerReported?: boolean; actor?: Principal; }) => Operation; /** * The reserve posting a payout saga anchors to, byte-for-byte as requestPayout seals it: the * earned debit carries the reserve and the metadata carries the saga id, rate, and quote. Money * fixtures post this (funding `earned` first so the debit clears) before opening the row, because * every money-moving payout step re-proves the row against this anchor. */ export declare function sagaAnchor(saga: { id: string; userId: string; reserve: Amount; rateId: string; txnId: string; payoutUsd: Amount | null; }): { txnId: string; legs: Leg[]; meta: Record; }; /** * The first-charge posting a subscription anchors to, sealing what the renewal guard re-proves: * the subscription id, user, seller, per-period price, and cadence. The guard reads only the * sealed metadata, so the legs are a balance-neutral pair on the overdraft-exempt platform * account — fixtures append this without disturbing the balances their test is about. */ export declare function subscriptionAnchor(sub: { id: string; userId: string; sellerId: string; sku: string; price: Amount; periodMs: number; txnId: string; }): { txnId: string; legs: Leg[]; meta: Record; };