UNPKG

@arkade-os/boltz-swap

Version:

A production-ready TypeScript package that brings Boltz submarine-swaps to Arkade.

62 lines (59 loc) 2.6 kB
import { D as DefineSwapBackgroundTaskOptions } from '../swapsPollProcessor-C4HQHP9Z.js'; export { P as PersistedSwapBackgroundConfig, S as SWAP_POLL_TASK_TYPE, a as SwapTaskDependencies, s as swapsPollProcessor } from '../swapsPollProcessor-C4HQHP9Z.js'; import '@arkade-os/sdk/worker/expo'; import '@arkade-os/sdk'; import '../types-BKEkNZxK.js'; /** * Define the Expo background task handler for swap polling. * * **Must be called at module/global scope** (before React mounts) so * Expo's TaskManager can resume the task on cold start. * * Pair with {@link registerExpoSwapBackgroundTask} to activate the OS * scheduler — `ExpoArkadeSwaps.setup()` no longer registers the task * for you. * * @example * ```ts * // App entry (e.g. _layout.tsx) — module scope * import { defineExpoSwapBackgroundTask } from "@arkade-os/boltz-swap/expo/background"; * import { AsyncStorageTaskQueue } from "@arkade-os/sdk/worker/expo"; * import AsyncStorage from "@react-native-async-storage/async-storage"; * * const taskQueue = new AsyncStorageTaskQueue(AsyncStorage, "ark:swap-queue"); * defineExpoSwapBackgroundTask("ark-swap-poll", { * taskQueue, * swapRepository, * identityFactory: async () => { * const key = await SecureStore.getItemAsync("ark-private-key"); * return SingleKey.fromHex(key!); * }, * }); * ``` */ declare function defineExpoSwapBackgroundTask(taskName: string, options: DefineSwapBackgroundTaskOptions): void; /** * Activate the OS-level background task scheduler. * * Call once after {@link defineExpoSwapBackgroundTask} — typically right * after `ExpoArkadeSwaps.setup()`. Safe to call again to update the * interval. * * @param taskName - The task name passed to {@link defineExpoSwapBackgroundTask}. * @param options.minimumInterval - Minimum interval in **minutes** (default * 15, the floor enforced by `expo-background-task`). * * @see https://docs.expo.dev/versions/latest/sdk/background-task/#backgroundtaskoptions */ declare function registerExpoSwapBackgroundTask(taskName: string, options?: { minimumInterval?: number; }): Promise<void>; /** * Unregister the swap background task from the OS scheduler. * * `ExpoArkadeSwaps.dispose()` does **not** call this — the OS-level * task lifecycle is the consumer's responsibility, matching the explicit * `register` step. */ declare function unregisterExpoSwapBackgroundTask(taskName: string): Promise<void>; export { DefineSwapBackgroundTaskOptions, defineExpoSwapBackgroundTask, registerExpoSwapBackgroundTask, unregisterExpoSwapBackgroundTask };