import { type JSONColumnType, type Selectable } from 'kysely'; import type * as Db from '../Db.js'; import type * as db_Schema from '../Schema.js'; import * as RoutesIdempotency from './routesIdempotency.js'; /** Columns of the `routes_deposit_addresses` table. */ export type Table = Omit & { /** Private provider request identifiers stored as JSON. */ providerRequestIds: JSONColumnType; }; /** A stored route deposit address. */ export type Record = Selectable; /** Ownership filter derived from the authenticated API key. */ export type Owner = { /** Key environment. */ environment: Record['environment']; /** Owning organization id (`org_…`). */ orgId: string; /** Attributed project id for project-scoped API keys. */ projectId?: string | undefined; }; /** Identity fields that make one reusable address match a caller request. */ export type Match = Owner & { /** Customer destination token key. */ destinationTokenKey: string; /** Tempo account that receives completed deposits. */ recipient: string; /** Source-chain account that receives refunds. */ refundAddress: string; /** Source chain CAIP-2 id. */ sourceChainId: string; /** Source token key. */ sourceTokenKey: string; /** Whether Tempo guarantees normalized 1:1 delivery. */ subsidize: boolean; }; /** Counts durable route deposit addresses for one organization. */ export declare function countByOrganization(db: Db.Db, orgId: string): Promise; /** Lists active addresses that organization deletion will deactivate. */ export declare function listActiveByOrganization(db: Db.Db, orgId: string): Promise; /** Claims address creation under the organization deletion fence. */ export declare function claimCreation(db: Db.Db, options: claimCreation.Options): Promise; export declare namespace claimCreation { /** Claim identity and organization deletion fence. */ type Options = { /** Idempotency identity and lease. */ claim: Omit; /** Organization reserving address capacity. */ orgId: string; }; } /** Validates reserved address capacity, excluding an already reusable match. */ export declare function validateCreationCapacity(db: Db.Db, options: validateCreationCapacity.Options): Promise; export declare namespace validateCreationCapacity { /** Reusable identity and organization capacity bound. */ type Options = { /** Pending claim released atomically when the creator-wide cap is full. */ claim: RoutesIdempotency.release.Input; /** Maximum durable and in-flight addresses for one canonical creator. */ maxPerCreator: number; /** Stable reusable-address identity that does not consume new capacity when present. */ match: Match; /** SHA-256 fingerprint of the canonical reusable match. */ matchHash: string; /** Organization reserving address capacity. */ orgId: string; /** Renewed pending lease duration, in milliseconds. */ pendingTtlMs: number; /** Successful-response replay retention from completion, in milliseconds. */ replayTtlMs: number; /** Older provider checkpoint completed when its durable match already exists. */ recoveredClaim?: RoutesIdempotency.release.Input | undefined; /** Serializes a reusable address into the idempotent response. */ serializeMatchingResponse: (record: Record) => string; }; /** Capacity reservation or reusable recovery result. */ type Result = { record: Record; type: 'existing'; } | { type: 'reserved'; } | { checkpointFresh: boolean; claim: RoutesIdempotency.release.Input; response: string; type: 'resume'; }; } /** Deactivates an organization's addresses so deletion leaves no recurring work. */ export declare function deactivateByOrganization(db: Db.Db, options: deactivateByOrganization.Options): Promise; export declare namespace deactivateByOrganization { /** Organization and timestamp for one bulk deactivation. */ type Options = { /** Timestamp committed to each changed address. */ now: string; /** Owning organization id (`org_…`). */ orgId: string; }; } /** Returns whether an organization owns an irrevocable provider subsidy request. */ export declare function hasSubsidizedRelayAddress(db: Db.Db, orgId: string): Promise; /** Aggregates current deposit-address states for bounded operational metrics. */ export declare function summarizeStates(db: Db.Db): Promise<{ count: string; environment: "production" | "sandbox"; oldestStatusUpdatedAt: string; providerId: string; status: "action-required" | "active" | "deactivated"; }[]>; /** Aggregates active deposit-address checks that are due without a live lease. */ export declare function summarizeOverdue(db: Db.Db, options: summarizeOverdue.Options): Promise<{ count: string; environment: "production" | "sandbox"; oldestNextPollAt: string; providerId: string; }[]>; export declare namespace summarizeOverdue { /** Overdue-address snapshot options. */ type Options = { /** Current timestamp used to classify due and leased addresses. */ now: string; }; } /** Inserts a provisioned route deposit address. */ export declare function insert(db: Db.Db, record: Record): Promise; /** Inserts an address or returns the concurrently-created matching resource. */ export declare function insertOrGet(db: Db.Db, options: insertOrGet.Options): Promise; /** * Inserts or returns a matching address while enforcing its creator's cap. * The caller must provide a transaction so the advisory lock covers the insert. */ export declare function insertOrGetWithinLimit(db: Db.Db, options: insertOrGetWithinLimit.Options): Promise; export declare namespace insertOrGetWithinLimit { /** Record, stable identity, and creator-wide cap for an atomic insert. */ type Options = insertOrGet.Options & { /** Maximum durable deposit addresses one canonical creator may own. */ maxPerCreator: number; }; } /** Inserts an already-provisioned address under the creator locks without applying a new-work cap. */ export declare function insertProvisionedOrGet(db: Db.Db, options: insertProvisionedOrGet.Options): Promise; export declare namespace insertProvisionedOrGet { /** Already-provisioned record and stable reusable identity. */ type Options = insertOrGet.Options; } export declare namespace insertOrGet { /** Record and stable identity used by create-or-get. */ type Options = { /** Stable customer-visible address identity. */ match: Match; /** Provisioned address record to insert. */ record: Record; }; } /** Gets a route deposit address without ownership scoping. */ export declare function get(db: Db.Db, id: string): Promise; /** Gets a route deposit address by its provider-owned address. */ export declare function getByProviderAddress(db: Db.Db, options: getByProviderAddress.Options): Promise; export declare namespace getByProviderAddress { /** Provider address identity received from a reconciliation trigger. */ type Options = { /** Provider-owned reusable deposit address. */ address: string; /** Route provider id. */ providerId: string; }; } /** Gets an owner-visible route deposit address. */ export declare function getOwned(db: Db.Db, owner: Owner, id: string): Promise; /** Lists owner-visible route deposit addresses newest-first. */ export declare function listByOwner(db: Db.Db, options: listByOwner.Options): Promise; export declare namespace listByOwner { /** Ownership and paging options for route deposit addresses. */ type Options = { /** Exclusive lower bound from the previous page. */ cursor?: Cursor | undefined; /** Maximum rows to return. */ limit: number; /** Ownership filter derived from the authenticated API key. */ owner: Owner; }; /** Cursor fields for the last address returned by the previous page. */ type Cursor = { /** Deposit address creation time. */ createdAt: string; /** Deposit address id, used as a deterministic tie-breaker. */ id: string; }; } /** Lists filtered route deposit addresses, newest update first. */ export declare function list(db: Db.Db, options: list.Options): Promise; export declare namespace list { /** Deposit-address filters and page bound. */ type Options = { /** Exclusive lower bound from the previous page. */ cursor?: Cursor | undefined; /** Restricts addresses to one route environment. */ environment?: Record['environment'] | undefined; /** Restricts addresses to any listed route environment. */ environments?: readonly Record['environment'][] | undefined; /** Maximum rows returned. */ limit: number; /** Restricts addresses to one organization. */ orgId?: string | undefined; /** Restricts addresses to one project. */ projectId?: string | undefined; /** Restricts addresses to one provider. */ providerId?: string | undefined; /** Restricts addresses to any listed provider. */ providerIds?: readonly string[] | undefined; /** Exact address resource id, deposit address, or related transaction reference. */ query?: string | undefined; /** Restricts addresses to one source chain. */ sourceChainId?: string | undefined; /** Restricts addresses to any listed source chain. */ sourceChainIds?: readonly string[] | undefined; /** Restricts addresses to one lifecycle status. */ status?: Record['status'] | undefined; /** Restricts addresses to any listed lifecycle status. */ statuses?: readonly Record['status'][] | undefined; }; /** Cursor fields for the last address on the previous page. */ type Cursor = { /** Deposit address id, used as a deterministic tie-breaker. */ id: string; /** Latest material update time. */ updatedAt: string; }; } /** Summarizes deposit addresses that require operator action. */ export declare function summarize(db: Db.Db, options?: summarize.Options): Promise; export declare namespace summarize { /** Attribution and route filters. */ type Options = { /** Restricts addresses to one route environment. */ environment?: Record['environment'] | undefined; /** Restricts addresses to any listed route environment. */ environments?: readonly Record['environment'][] | undefined; /** Restricts addresses to one organization. */ orgId?: string | undefined; /** Restricts addresses to one project. */ projectId?: string | undefined; /** Restricts addresses to one provider. */ providerId?: string | undefined; /** Restricts addresses to any listed provider. */ providerIds?: readonly string[] | undefined; /** Restricts addresses to one source chain. */ sourceChainId?: string | undefined; /** Restricts addresses to any listed source chain. */ sourceChainIds?: readonly string[] | undefined; }; /** Current deposit-address work totals. */ type Result = { /** Addresses that require operator action. */ actionRequired: number; /** Deposit addresses never count as processing work. */ inProgress: 0; /** When the oldest address entered action-required status. */ oldestActiveAt: string | null; }; } /** Gets the reusable address that matches one owner and route identity. */ export declare function getMatching(db: Db.Db, match: Match): Promise; /** Lists active provider addresses for one source-chain token. */ export declare function listActiveSources(db: Db.Db, options: listActiveSources.Options): Promise; export declare namespace listActiveSources { /** Provider and source asset identifying one observer shard. */ type Options = { /** Route provider that owns the deposit addresses. */ providerId: string; /** Source chain CAIP-2 id. */ sourceChainId: string; /** Source token key. */ sourceTokenKey: string; }; } /** Claims a bounded batch of active addresses due for provider reconciliation. */ export declare function claimDue(db: Db.Db, options: claimDue.Options): Promise; export declare namespace claimDue { /** Provider and lease bounds for one reconciliation claim. */ type Options = { /** Exclusive upper bound on rows claimed in one tick. */ limit: number; /** Expiry time assigned to each claimed lease. */ leaseUntil: string; /** Current time used for due and expired-lease comparisons. */ now: string; /** Route provider whose addresses should be claimed. */ providerId: string; }; } /** Claims one active address unless another reconciliation owns its lease. */ export declare function claim(db: Db.Db, options: claim.Options): Promise; export declare namespace claim { /** Identity and lease bounds for one reconciliation claim. */ type Options = { /** Route deposit address id (`rda_…`). */ id: string; /** Expiry time assigned to the claimed lease. */ leaseUntil: string; /** Current time used for expired-lease comparison. */ now: string; }; } /** Extends an active reconciliation lease without changing its fence. */ export declare function renewPoll(db: Db.Db, options: renewPoll.Options): Promise; export declare namespace renewPoll { /** Lease identity and renewed expiry guarded by the current fence. */ type Options = { /** Route deposit address id (`rda_…`). */ id: string; /** Replacement reconciliation lease expiry. */ leaseUntil: string; /** Fencing token returned by the claim operation. */ pollLeaseVersion: number; }; } /** Saves reconciliation progress before processing a page under an owned lease. */ export declare function checkpointPoll(db: Db.Db, options: checkpointPoll.Options): Promise<{ address: string; createdAt: string; creatorUserId: string | null; deliveryStrategy: "provider" | "tempo"; destinationTokenKey: string; environment: "production" | "sandbox"; id: string; lastPolledAt: string | null; nextPollAt: string; orgId: string; pollFailureCount: number; pollLeaseUntil: string | null; pollLeaseVersion: number; projectId: string | null; providerId: string; providerOutputToken: { address: string; currency: string; decimals: number; name: string; standard: string; symbol: string; tokenKey: string; verified: boolean; }; providerRequestIds: readonly string[]; providerState: import("../../internal/routes/DepositAddress.js").ProviderState | null; recipient: string; refundAddress: string; snapshot: { address: string; destinationChain: { addressFormat: "base58" | "base58check" | "hex"; id: string; kind: "evm" | "solana" | "tron"; name: string; }; destinationToken: { address: string; currency: string; decimals: number; name: string; standard: string; symbol: string; tokenKey: string; verified: boolean; }; provider: { id: string; name: string; }; recipient: string; refundAddress: string; sourceChain: { addressFormat: "base58" | "base58check" | "hex"; id: string; kind: "evm" | "solana" | "tron"; name: string; }; sourceToken: { address: string; currency: string; decimals: number; name: string; standard: string; symbol: string; tokenKey: string; verified: boolean; }; subsidize: boolean; }; sourceChainId: string; sourceTokenKey: string; status: "action-required" | "active" | "deactivated"; statusUpdatedAt: string | null; subsidize: boolean; updatedAt: string; version: number; } | undefined>; export declare namespace checkpointPoll { /** Progress update fenced by the address reconciliation lease. */ type Options = Pick; } /** Completes an owned reconciliation lease and schedules the address again. */ export declare function completePoll(db: Db.Db, options: completePoll.Options): Promise; export declare namespace completePoll { /** Successful reconciliation result guarded by the claimed lease version. */ type Options = { /** Route deposit address id (`rda_…`). */ id: string; /** Time when provider reconciliation completed. */ lastPolledAt: string; /** Time when this address becomes due again. */ nextPollAt: string; /** Fencing token returned by {@link claimDue}. */ pollLeaseVersion: number; /** Provider request identifiers retained from address provisioning. */ providerRequestIds: readonly string[]; /** Bounded provider reconciliation state. */ providerState: Record['providerState']; }; } /** Releases an owned reconciliation lease after failure and schedules a retry. */ export declare function failPoll(db: Db.Db, options: failPoll.Options): Promise; export declare namespace failPoll { /** Failed reconciliation result guarded by the claimed lease version. */ type Options = { /** Route deposit address id (`rda_…`). */ id: string; /** Time when this address becomes eligible for retry. */ nextPollAt: string; /** Fencing token returned by {@link claimDue}. */ pollLeaseVersion: number; }; } /** Applies a version-guarded deposit address status update. */ export declare function update(db: Db.Db, options: update.Options): Promise; export declare namespace update { /** Guarded address update fields. */ type Options = { /** Stored version required for the update. */ expectedVersion: number; /** Route deposit address id (`rda_…`). */ id: string; /** Replacement lifecycle status. */ status: Record['status']; /** When the address entered its current status. */ statusUpdatedAt: Record['statusUpdatedAt']; /** New material update time. */ updatedAt: string; /** New material version. */ version: number; }; } /** The capacity claim was replaced before it could be reserved. */ export declare class CapacityClaimNotFoundError extends Error { readonly name = "RoutesDepositAddresses.CapacityClaimNotFoundError"; } /** Provider address conflicted with a different customer-visible identity. */ export declare class ConflictError extends Error { name: string; } /** Organization deposit-address cap reached. */ export declare class LimitExceededError extends Error { name: string; /** Maximum durable deposit addresses the organization may own. */ limit: number; constructor(limit: number); } /** Another request owns provider provisioning for the same reusable match. */ export declare class MatchInProgressError extends Error { readonly name = "RoutesDepositAddresses.MatchInProgressError"; } /** Owning organization disappeared before address persistence. */ export declare class OwnerNotFoundError extends Error { name: string; } //# sourceMappingURL=routesDepositAddresses.d.ts.map