@arkade-os/boltz-swap 0.3.29 → 0.3.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,75 +1,10 @@
1
1
  import { I as IArkadeSwaps, A as ArkadeSwaps, V as VhtlcTimeouts } from '../arkade-swaps-CS8FZSVL.cjs';
2
- import { A as ArkadeSwapsConfig, m as SwapRepository, p as BoltzSwapProvider, N as Network, n as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, F as FeesResponse, a as BoltzChainSwap, k as ArkToBtcResponse, l as BtcToArkResponse, d as Chain, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-BBI7-KJ0.cjs';
3
- import { Identity, ArkProvider, IndexerProvider, IWallet, ArkInfo, ArkTxInput, VHTLC } from '@arkade-os/sdk';
4
- import { AsyncStorageTaskQueue, TaskProcessor } from '@arkade-os/sdk/worker/expo';
2
+ import { n as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, F as FeesResponse, a as BoltzChainSwap, k as ArkToBtcResponse, l as BtcToArkResponse, d as Chain, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-BBI7-KJ0.cjs';
3
+ import { E as ExpoArkadeSwapsConfig } from '../swapsPollProcessor-BF3uTFae.cjs';
4
+ export { D as DefineSwapBackgroundTaskOptions, c as ExpoArkadeLightningConfig, b as ExpoSwapBackgroundConfig, P as PersistedSwapBackgroundConfig, S as SWAP_POLL_TASK_TYPE, a as SwapTaskDependencies } from '../swapsPollProcessor-BF3uTFae.cjs';
5
+ import { ArkInfo, Identity, ArkTxInput, VHTLC } from '@arkade-os/sdk';
5
6
  import { TransactionOutput } from '@scure/btc-signer/psbt.js';
6
-
7
- /**
8
- * Dependencies injected into every swap processor at runtime.
9
- *
10
- * Unlike the wallet's `TaskDependencies`, these are swap-specific:
11
- * we need the Boltz provider, swap repository, and identity to
12
- * poll status and attempt claim/refund.
13
- */
14
- interface SwapTaskDependencies {
15
- swapRepository: SwapRepository;
16
- swapProvider: BoltzSwapProvider;
17
- arkProvider: ArkProvider;
18
- indexerProvider: IndexerProvider;
19
- identity: Identity;
20
- wallet: IWallet;
21
- }
22
- /**
23
- * Minimal config persisted to AsyncStorage for background rehydration.
24
- *
25
- * The background handler runs in a fresh JS context without access to
26
- * the foreground's in-memory state, so we persist just enough to
27
- * reconstruct providers and identity.
28
- */
29
- interface PersistedSwapBackgroundConfig {
30
- boltzApiUrl: string;
31
- arkServerUrl: string;
32
- network: Network;
33
- }
34
- /**
35
- * Background scheduling configuration for {@link ExpoArkadeSwaps}.
36
- */
37
- interface ExpoSwapBackgroundConfig {
38
- /** Identifier registered with expo-background-task. */
39
- taskName: string;
40
- /** Persistence layer for foreground ↔ background handoff. */
41
- taskQueue: AsyncStorageTaskQueue;
42
- /** If set, acknowledges background results at this interval (ms) while the app is in the foreground. */
43
- foregroundIntervalMs?: number;
44
- /** If set, registers the background task with the OS at this interval (minutes, min 15). */
45
- minimumBackgroundInterval?: number;
46
- }
47
- /**
48
- * Options for {@link defineExpoSwapBackgroundTask}.
49
- */
50
- interface DefineSwapBackgroundTaskOptions {
51
- /** AsyncStorage-backed queue (must match the one passed to ExpoArkadeSwaps.setup). */
52
- taskQueue: AsyncStorageTaskQueue;
53
- /** Swap repository (fresh instance is fine — connects to the same DB). */
54
- swapRepository: SwapRepository;
55
- /** Factory to reconstruct Identity from secure storage in the background. */
56
- identityFactory: () => Promise<Identity>;
57
- }
58
- /**
59
- * Configuration for {@link ExpoArkadeSwaps.setup}.
60
- */
61
- interface ExpoArkadeSwapsConfig extends ArkadeSwapsConfig {
62
- /**
63
- * Ark server base URL (e.g. "https://ark.example.com").
64
- *
65
- * Recommended for type-safe background rehydration. If omitted,
66
- * ExpoArkadeSwaps will attempt to derive it from the ArkProvider.
67
- */
68
- arkServerUrl?: string;
69
- background: ExpoSwapBackgroundConfig;
70
- }
71
- /** @deprecated Use ExpoArkadeSwapsConfig instead */
72
- type ExpoArkadeLightningConfig = ExpoArkadeSwapsConfig;
7
+ import '@arkade-os/sdk/worker/expo';
73
8
 
74
9
  /**
75
10
  * Expo/React Native wrapper for ArkadeSwaps with background task support.
@@ -86,21 +21,31 @@ type ExpoArkadeLightningConfig = ExpoArkadeSwapsConfig;
86
21
  * acknowledges background outbox results and re-seeds the task queue
87
22
  * for the next background wake.
88
23
  *
24
+ * OS-level task registration is the consumer's responsibility — call
25
+ * `registerExpoSwapBackgroundTask` from
26
+ * `@arkade-os/boltz-swap/expo/background` after `setup()`. Keeping
27
+ * registration out of `setup()` lets this entrypoint avoid pulling
28
+ * `expo-task-manager` / `expo-background-task` into the `/expo` bundle.
29
+ *
89
30
  * @example
90
31
  * ```ts
32
+ * import { ExpoArkadeSwaps } from "@arkade-os/boltz-swap/expo";
33
+ * import { registerExpoSwapBackgroundTask } from "@arkade-os/boltz-swap/expo/background";
34
+ *
91
35
  * const arkSwaps = await ExpoArkadeSwaps.setup({
92
36
  * wallet,
93
37
  * arkServerUrl: "https://ark.example.com",
94
38
  * swapProvider,
95
39
  * swapManager: true,
96
40
  * background: {
97
- * taskName: "ark-swap-poll",
98
41
  * taskQueue: swapTaskQueue,
99
42
  * foregroundIntervalMs: 20_000,
100
- * minimumBackgroundInterval: 15,
101
43
  * },
102
44
  * });
103
45
  *
46
+ * // Activate the OS scheduler (Expo Android/iOS only)
47
+ * await registerExpoSwapBackgroundTask("ark-swap-poll", { minimumInterval: 15 });
48
+ *
104
49
  * await arkSwaps.createLightningInvoice({ amount: 1000 });
105
50
  * ```
106
51
  */
@@ -109,16 +54,18 @@ declare class ExpoArkadeSwaps implements IArkadeSwaps {
109
54
  private readonly config;
110
55
  readonly swapRepository: ArkadeSwaps["swapRepository"];
111
56
  private foregroundIntervalId?;
112
- private readonly taskName;
113
57
  private constructor();
114
58
  /**
115
- * Create an ExpoArkadeSwaps with background task support.
59
+ * Create an ExpoArkadeSwaps with foreground/background queue handoff.
116
60
  *
117
61
  * 1. Creates the inner {@link ArkadeSwaps} with SwapManager enabled.
118
62
  * 2. Persists {@link PersistedSwapBackgroundConfig} for background rehydration.
119
63
  * 3. Seeds the task queue with a swap-poll task.
120
- * 4. Registers the background task with the OS scheduler (if configured).
121
- * 5. Starts foreground interval (if configured).
64
+ * 4. Starts the foreground interval (if configured).
65
+ *
66
+ * OS-level scheduling lives in
67
+ * `@arkade-os/boltz-swap/expo/background` and is invoked separately
68
+ * by the consumer.
122
69
  */
123
70
  static setup(config: ExpoArkadeSwapsConfig): Promise<ExpoArkadeSwaps>;
124
71
  private startForegroundPolling;
@@ -224,67 +171,4 @@ declare class ExpoArkadeSwaps implements IArkadeSwaps {
224
171
  /** @deprecated Use ExpoArkadeSwaps instead */
225
172
  declare const ExpoArkadeLightning: typeof ExpoArkadeSwaps;
226
173
 
227
- /**
228
- * Define the Expo background task handler for swap polling.
229
- *
230
- * **Must be called at module/global scope** (before React mounts).
231
- * Internally calls `TaskManager.defineTask()`.
232
- *
233
- * @example
234
- * ```ts
235
- * // At the top of your app entry file (_layout.tsx)
236
- * import { defineExpoSwapBackgroundTask } from "@arkade-os/boltz-swap/expo";
237
- * import { AsyncStorageTaskQueue } from "@arkade-os/sdk/worker/expo";
238
- * import AsyncStorage from "@react-native-async-storage/async-storage";
239
- *
240
- * const taskQueue = new AsyncStorageTaskQueue(AsyncStorage, "ark:swap-queue");
241
- * defineExpoSwapBackgroundTask("ark-swap-poll", {
242
- * taskQueue,
243
- * swapRepository,
244
- * identityFactory: async () => {
245
- * const key = await SecureStore.getItemAsync("ark-private-key");
246
- * return SingleKey.fromHex(key!);
247
- * },
248
- * });
249
- * ```
250
- */
251
- declare function defineExpoSwapBackgroundTask(taskName: string, options: DefineSwapBackgroundTaskOptions): void;
252
- /**
253
- * Activate the OS-level background task scheduler.
254
- *
255
- * Call this after {@link defineExpoSwapBackgroundTask} (typically inside
256
- * {@link ExpoArkadeSwaps.setup}).
257
- *
258
- * @param taskName - The task name registered with defineExpoSwapBackgroundTask.
259
- * @param options - Optional configuration.
260
- * @param options.minimumInterval - Minimum interval in minutes (default 15).
261
- */
262
- declare function registerExpoSwapBackgroundTask(taskName: string, options?: {
263
- minimumInterval?: number;
264
- }): Promise<void>;
265
- /**
266
- * Unregister the swap background task from the OS scheduler.
267
- */
268
- declare function unregisterExpoSwapBackgroundTask(taskName: string): Promise<void>;
269
-
270
- /**
271
- * Task type identifier for {@link swapsPollProcessor}.
272
- */
273
- declare const SWAP_POLL_TASK_TYPE = "swap-poll";
274
- /**
275
- * Stateless processor that polls Boltz for swap status updates and
276
- * attempts best-effort claim/refund for actionable swaps.
277
- *
278
- * Designed for Expo background tasks (~30s window) and follows the
279
- * same `TaskProcessor` pattern as `contractPollProcessor` in ts-sdk.
280
- *
281
- * Steps:
282
- * 1. Read all non-final swaps from SwapRepository
283
- * 2. Poll Boltz HTTP API for each swap's current status
284
- * 3. Persist status changes immediately
285
- * 4. For actionable statuses: attempt claimVHTLC / refundVHTLC (best-effort)
286
- * 5. Return summary metrics
287
- */
288
- declare const swapsPollProcessor: TaskProcessor<SwapTaskDependencies>;
289
-
290
- export { type DefineSwapBackgroundTaskOptions, ExpoArkadeLightning, type ExpoArkadeLightningConfig, ExpoArkadeSwaps, type ExpoArkadeSwapsConfig, type ExpoSwapBackgroundConfig, type PersistedSwapBackgroundConfig, SWAP_POLL_TASK_TYPE, type SwapTaskDependencies, defineExpoSwapBackgroundTask, registerExpoSwapBackgroundTask, swapsPollProcessor, unregisterExpoSwapBackgroundTask };
174
+ export { ExpoArkadeLightning, ExpoArkadeSwaps, ExpoArkadeSwapsConfig };
@@ -1,75 +1,10 @@
1
1
  import { I as IArkadeSwaps, A as ArkadeSwaps, V as VhtlcTimeouts } from '../arkade-swaps-WiKCanCL.js';
2
- import { A as ArkadeSwapsConfig, m as SwapRepository, p as BoltzSwapProvider, N as Network, n as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, F as FeesResponse, a as BoltzChainSwap, k as ArkToBtcResponse, l as BtcToArkResponse, d as Chain, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-BBI7-KJ0.js';
3
- import { Identity, ArkProvider, IndexerProvider, IWallet, ArkInfo, ArkTxInput, VHTLC } from '@arkade-os/sdk';
4
- import { AsyncStorageTaskQueue, TaskProcessor } from '@arkade-os/sdk/worker/expo';
2
+ import { n as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, g as SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, F as FeesResponse, a as BoltzChainSwap, k as ArkToBtcResponse, l as BtcToArkResponse, d as Chain, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-BBI7-KJ0.js';
3
+ import { E as ExpoArkadeSwapsConfig } from '../swapsPollProcessor-wYOMzldd.js';
4
+ export { D as DefineSwapBackgroundTaskOptions, c as ExpoArkadeLightningConfig, b as ExpoSwapBackgroundConfig, P as PersistedSwapBackgroundConfig, S as SWAP_POLL_TASK_TYPE, a as SwapTaskDependencies } from '../swapsPollProcessor-wYOMzldd.js';
5
+ import { ArkInfo, Identity, ArkTxInput, VHTLC } from '@arkade-os/sdk';
5
6
  import { TransactionOutput } from '@scure/btc-signer/psbt.js';
6
-
7
- /**
8
- * Dependencies injected into every swap processor at runtime.
9
- *
10
- * Unlike the wallet's `TaskDependencies`, these are swap-specific:
11
- * we need the Boltz provider, swap repository, and identity to
12
- * poll status and attempt claim/refund.
13
- */
14
- interface SwapTaskDependencies {
15
- swapRepository: SwapRepository;
16
- swapProvider: BoltzSwapProvider;
17
- arkProvider: ArkProvider;
18
- indexerProvider: IndexerProvider;
19
- identity: Identity;
20
- wallet: IWallet;
21
- }
22
- /**
23
- * Minimal config persisted to AsyncStorage for background rehydration.
24
- *
25
- * The background handler runs in a fresh JS context without access to
26
- * the foreground's in-memory state, so we persist just enough to
27
- * reconstruct providers and identity.
28
- */
29
- interface PersistedSwapBackgroundConfig {
30
- boltzApiUrl: string;
31
- arkServerUrl: string;
32
- network: Network;
33
- }
34
- /**
35
- * Background scheduling configuration for {@link ExpoArkadeSwaps}.
36
- */
37
- interface ExpoSwapBackgroundConfig {
38
- /** Identifier registered with expo-background-task. */
39
- taskName: string;
40
- /** Persistence layer for foreground ↔ background handoff. */
41
- taskQueue: AsyncStorageTaskQueue;
42
- /** If set, acknowledges background results at this interval (ms) while the app is in the foreground. */
43
- foregroundIntervalMs?: number;
44
- /** If set, registers the background task with the OS at this interval (minutes, min 15). */
45
- minimumBackgroundInterval?: number;
46
- }
47
- /**
48
- * Options for {@link defineExpoSwapBackgroundTask}.
49
- */
50
- interface DefineSwapBackgroundTaskOptions {
51
- /** AsyncStorage-backed queue (must match the one passed to ExpoArkadeSwaps.setup). */
52
- taskQueue: AsyncStorageTaskQueue;
53
- /** Swap repository (fresh instance is fine — connects to the same DB). */
54
- swapRepository: SwapRepository;
55
- /** Factory to reconstruct Identity from secure storage in the background. */
56
- identityFactory: () => Promise<Identity>;
57
- }
58
- /**
59
- * Configuration for {@link ExpoArkadeSwaps.setup}.
60
- */
61
- interface ExpoArkadeSwapsConfig extends ArkadeSwapsConfig {
62
- /**
63
- * Ark server base URL (e.g. "https://ark.example.com").
64
- *
65
- * Recommended for type-safe background rehydration. If omitted,
66
- * ExpoArkadeSwaps will attempt to derive it from the ArkProvider.
67
- */
68
- arkServerUrl?: string;
69
- background: ExpoSwapBackgroundConfig;
70
- }
71
- /** @deprecated Use ExpoArkadeSwapsConfig instead */
72
- type ExpoArkadeLightningConfig = ExpoArkadeSwapsConfig;
7
+ import '@arkade-os/sdk/worker/expo';
73
8
 
74
9
  /**
75
10
  * Expo/React Native wrapper for ArkadeSwaps with background task support.
@@ -86,21 +21,31 @@ type ExpoArkadeLightningConfig = ExpoArkadeSwapsConfig;
86
21
  * acknowledges background outbox results and re-seeds the task queue
87
22
  * for the next background wake.
88
23
  *
24
+ * OS-level task registration is the consumer's responsibility — call
25
+ * `registerExpoSwapBackgroundTask` from
26
+ * `@arkade-os/boltz-swap/expo/background` after `setup()`. Keeping
27
+ * registration out of `setup()` lets this entrypoint avoid pulling
28
+ * `expo-task-manager` / `expo-background-task` into the `/expo` bundle.
29
+ *
89
30
  * @example
90
31
  * ```ts
32
+ * import { ExpoArkadeSwaps } from "@arkade-os/boltz-swap/expo";
33
+ * import { registerExpoSwapBackgroundTask } from "@arkade-os/boltz-swap/expo/background";
34
+ *
91
35
  * const arkSwaps = await ExpoArkadeSwaps.setup({
92
36
  * wallet,
93
37
  * arkServerUrl: "https://ark.example.com",
94
38
  * swapProvider,
95
39
  * swapManager: true,
96
40
  * background: {
97
- * taskName: "ark-swap-poll",
98
41
  * taskQueue: swapTaskQueue,
99
42
  * foregroundIntervalMs: 20_000,
100
- * minimumBackgroundInterval: 15,
101
43
  * },
102
44
  * });
103
45
  *
46
+ * // Activate the OS scheduler (Expo Android/iOS only)
47
+ * await registerExpoSwapBackgroundTask("ark-swap-poll", { minimumInterval: 15 });
48
+ *
104
49
  * await arkSwaps.createLightningInvoice({ amount: 1000 });
105
50
  * ```
106
51
  */
@@ -109,16 +54,18 @@ declare class ExpoArkadeSwaps implements IArkadeSwaps {
109
54
  private readonly config;
110
55
  readonly swapRepository: ArkadeSwaps["swapRepository"];
111
56
  private foregroundIntervalId?;
112
- private readonly taskName;
113
57
  private constructor();
114
58
  /**
115
- * Create an ExpoArkadeSwaps with background task support.
59
+ * Create an ExpoArkadeSwaps with foreground/background queue handoff.
116
60
  *
117
61
  * 1. Creates the inner {@link ArkadeSwaps} with SwapManager enabled.
118
62
  * 2. Persists {@link PersistedSwapBackgroundConfig} for background rehydration.
119
63
  * 3. Seeds the task queue with a swap-poll task.
120
- * 4. Registers the background task with the OS scheduler (if configured).
121
- * 5. Starts foreground interval (if configured).
64
+ * 4. Starts the foreground interval (if configured).
65
+ *
66
+ * OS-level scheduling lives in
67
+ * `@arkade-os/boltz-swap/expo/background` and is invoked separately
68
+ * by the consumer.
122
69
  */
123
70
  static setup(config: ExpoArkadeSwapsConfig): Promise<ExpoArkadeSwaps>;
124
71
  private startForegroundPolling;
@@ -224,67 +171,4 @@ declare class ExpoArkadeSwaps implements IArkadeSwaps {
224
171
  /** @deprecated Use ExpoArkadeSwaps instead */
225
172
  declare const ExpoArkadeLightning: typeof ExpoArkadeSwaps;
226
173
 
227
- /**
228
- * Define the Expo background task handler for swap polling.
229
- *
230
- * **Must be called at module/global scope** (before React mounts).
231
- * Internally calls `TaskManager.defineTask()`.
232
- *
233
- * @example
234
- * ```ts
235
- * // At the top of your app entry file (_layout.tsx)
236
- * import { defineExpoSwapBackgroundTask } from "@arkade-os/boltz-swap/expo";
237
- * import { AsyncStorageTaskQueue } from "@arkade-os/sdk/worker/expo";
238
- * import AsyncStorage from "@react-native-async-storage/async-storage";
239
- *
240
- * const taskQueue = new AsyncStorageTaskQueue(AsyncStorage, "ark:swap-queue");
241
- * defineExpoSwapBackgroundTask("ark-swap-poll", {
242
- * taskQueue,
243
- * swapRepository,
244
- * identityFactory: async () => {
245
- * const key = await SecureStore.getItemAsync("ark-private-key");
246
- * return SingleKey.fromHex(key!);
247
- * },
248
- * });
249
- * ```
250
- */
251
- declare function defineExpoSwapBackgroundTask(taskName: string, options: DefineSwapBackgroundTaskOptions): void;
252
- /**
253
- * Activate the OS-level background task scheduler.
254
- *
255
- * Call this after {@link defineExpoSwapBackgroundTask} (typically inside
256
- * {@link ExpoArkadeSwaps.setup}).
257
- *
258
- * @param taskName - The task name registered with defineExpoSwapBackgroundTask.
259
- * @param options - Optional configuration.
260
- * @param options.minimumInterval - Minimum interval in minutes (default 15).
261
- */
262
- declare function registerExpoSwapBackgroundTask(taskName: string, options?: {
263
- minimumInterval?: number;
264
- }): Promise<void>;
265
- /**
266
- * Unregister the swap background task from the OS scheduler.
267
- */
268
- declare function unregisterExpoSwapBackgroundTask(taskName: string): Promise<void>;
269
-
270
- /**
271
- * Task type identifier for {@link swapsPollProcessor}.
272
- */
273
- declare const SWAP_POLL_TASK_TYPE = "swap-poll";
274
- /**
275
- * Stateless processor that polls Boltz for swap status updates and
276
- * attempts best-effort claim/refund for actionable swaps.
277
- *
278
- * Designed for Expo background tasks (~30s window) and follows the
279
- * same `TaskProcessor` pattern as `contractPollProcessor` in ts-sdk.
280
- *
281
- * Steps:
282
- * 1. Read all non-final swaps from SwapRepository
283
- * 2. Poll Boltz HTTP API for each swap's current status
284
- * 3. Persist status changes immediately
285
- * 4. For actionable statuses: attempt claimVHTLC / refundVHTLC (best-effort)
286
- * 5. Return summary metrics
287
- */
288
- declare const swapsPollProcessor: TaskProcessor<SwapTaskDependencies>;
289
-
290
- export { type DefineSwapBackgroundTaskOptions, ExpoArkadeLightning, type ExpoArkadeLightningConfig, ExpoArkadeSwaps, type ExpoArkadeSwapsConfig, type ExpoSwapBackgroundConfig, type PersistedSwapBackgroundConfig, SWAP_POLL_TASK_TYPE, type SwapTaskDependencies, defineExpoSwapBackgroundTask, registerExpoSwapBackgroundTask, swapsPollProcessor, unregisterExpoSwapBackgroundTask };
174
+ export { ExpoArkadeLightning, ExpoArkadeSwaps, ExpoArkadeSwapsConfig };
@@ -1,39 +1,48 @@
1
1
  import {
2
- SWAP_POLL_TASK_TYPE,
3
- defineExpoSwapBackgroundTask,
4
- registerExpoSwapBackgroundTask,
5
- swapsPollProcessor,
6
- unregisterExpoSwapBackgroundTask
7
- } from "../chunk-X3JNWDAR.js";
2
+ SWAP_POLL_TASK_TYPE
3
+ } from "../chunk-NHBWNN6H.js";
8
4
  import {
9
5
  ArkadeSwaps
10
- } from "../chunk-LWUXSE5N.js";
11
- import "../chunk-3RG5ZIWI.js";
6
+ } from "../chunk-B3Q4TFWT.js";
12
7
 
13
8
  // src/expo/arkade-lightning.ts
14
9
  function getRandomId() {
15
10
  return Math.random().toString(36).slice(2) + Date.now().toString(36);
16
11
  }
12
+ function warnOnRemovedBackgroundFields(bg) {
13
+ if (!bg || typeof bg !== "object") return;
14
+ const removed = [];
15
+ if ("taskName" in bg) removed.push("taskName");
16
+ if ("minimumBackgroundInterval" in bg) {
17
+ removed.push("minimumBackgroundInterval");
18
+ }
19
+ if (removed.length === 0) return;
20
+ console.warn(
21
+ `[boltz-swap] ExpoArkadeSwaps.setup: ignoring removed background field(s): ${removed.join(", ")}. OS-task registration moved to "@arkade-os/boltz-swap/expo/background". See https://github.com/arkade-os/boltz-swap/issues/136`
22
+ );
23
+ }
17
24
  var ExpoArkadeSwaps = class _ExpoArkadeSwaps {
18
25
  constructor(inner, config) {
19
26
  this.inner = inner;
20
27
  this.config = config;
21
- this.taskName = config.background.taskName;
22
28
  this.swapRepository = inner.swapRepository;
23
29
  }
24
30
  swapRepository;
25
31
  foregroundIntervalId;
26
- taskName;
27
32
  /**
28
- * Create an ExpoArkadeSwaps with background task support.
33
+ * Create an ExpoArkadeSwaps with foreground/background queue handoff.
29
34
  *
30
35
  * 1. Creates the inner {@link ArkadeSwaps} with SwapManager enabled.
31
36
  * 2. Persists {@link PersistedSwapBackgroundConfig} for background rehydration.
32
37
  * 3. Seeds the task queue with a swap-poll task.
33
- * 4. Registers the background task with the OS scheduler (if configured).
34
- * 5. Starts foreground interval (if configured).
38
+ * 4. Starts the foreground interval (if configured).
39
+ *
40
+ * OS-level scheduling lives in
41
+ * `@arkade-os/boltz-swap/expo/background` and is invoked separately
42
+ * by the consumer.
35
43
  */
36
44
  static async setup(config) {
45
+ warnOnRemovedBackgroundFields(config.background);
37
46
  const inner = new ArkadeSwaps({
38
47
  ...config,
39
48
  swapManager: config.swapManager ?? true
@@ -54,28 +63,6 @@ var ExpoArkadeSwaps = class _ExpoArkadeSwaps {
54
63
  await taskQueue.persistConfig(bgConfig);
55
64
  const instance = new _ExpoArkadeSwaps(inner, config);
56
65
  await instance.seedSwapPollTask();
57
- if (config.background.minimumBackgroundInterval) {
58
- try {
59
- const { registerExpoSwapBackgroundTask: registerExpoSwapBackgroundTask2 } = await import("../background-UQDFQCGM.js");
60
- await registerExpoSwapBackgroundTask2(
61
- config.background.taskName,
62
- {
63
- minimumInterval: config.background.minimumBackgroundInterval
64
- }
65
- );
66
- } catch (err) {
67
- const message = err instanceof Error ? err.message : String(err);
68
- const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
69
- const codeString = typeof code === "string" ? code : void 0;
70
- const isModuleNotFound = codeString === "MODULE_NOT_FOUND" || /cannot find module/i.test(message) || /module not found/i.test(message);
71
- if (!isModuleNotFound) {
72
- console.warn(
73
- `[boltz-swap] Failed to register background task "${config.background.taskName}":`,
74
- err
75
- );
76
- }
77
- }
78
- }
79
66
  if (config.background.foregroundIntervalMs && config.background.foregroundIntervalMs > 0) {
80
67
  instance.startForegroundPolling(
81
68
  config.background.foregroundIntervalMs
@@ -128,21 +115,6 @@ var ExpoArkadeSwaps = class _ExpoArkadeSwaps {
128
115
  this.foregroundIntervalId = void 0;
129
116
  }
130
117
  await this.inner.dispose();
131
- try {
132
- const { unregisterExpoSwapBackgroundTask: unregisterExpoSwapBackgroundTask2 } = await import("../background-UQDFQCGM.js");
133
- await unregisterExpoSwapBackgroundTask2(this.taskName);
134
- } catch (err) {
135
- const message = err instanceof Error ? err.message : String(err);
136
- const code = typeof err === "object" && err !== null && "code" in err ? err.code : void 0;
137
- const codeString = typeof code === "string" ? code : void 0;
138
- const isModuleNotFound = codeString === "MODULE_NOT_FOUND" || /cannot find module/i.test(message) || /module not found/i.test(message);
139
- if (!isModuleNotFound) {
140
- console.warn(
141
- `[boltz-swap] Failed to unregister background task "${this.taskName}":`,
142
- err
143
- );
144
- }
145
- }
146
118
  }
147
119
  async [Symbol.asyncDispose]() {
148
120
  await this.dispose();
@@ -286,9 +258,5 @@ var ExpoArkadeLightning = ExpoArkadeSwaps;
286
258
  export {
287
259
  ExpoArkadeLightning,
288
260
  ExpoArkadeSwaps,
289
- SWAP_POLL_TASK_TYPE,
290
- defineExpoSwapBackgroundTask,
291
- registerExpoSwapBackgroundTask,
292
- swapsPollProcessor,
293
- unregisterExpoSwapBackgroundTask
261
+ SWAP_POLL_TASK_TYPE
294
262
  };
package/dist/index.cjs CHANGED
@@ -430,7 +430,7 @@ var BoltzSwapProvider = class {
430
430
  /** @param config Provider configuration with network and optional API URL. */
431
431
  constructor(config) {
432
432
  this.network = config.network;
433
- this.referralId = config.referralId;
433
+ this.referralId = config.referralId ?? "arkade-ts-sdk";
434
434
  const apiUrl = config.apiUrl || BASE_URLS[config.network];
435
435
  if (!apiUrl)
436
436
  throw new Error(
@@ -5338,6 +5338,13 @@ var ArkadeSwaps = class _ArkadeSwaps {
5338
5338
  // src/serviceWorker/arkade-swaps-message-handler.ts
5339
5339
  var import_sdk9 = require("@arkade-os/sdk");
5340
5340
  var DEFAULT_MESSAGE_TAG = "ARKADE_SWAPS_UPDATER";
5341
+ var HANDLER_NOT_INITIALIZED = "ArkadeSwaps handler not initialized";
5342
+ var HandlerNotInitializedError = class extends Error {
5343
+ constructor() {
5344
+ super(HANDLER_NOT_INITIALIZED);
5345
+ this.name = "HandlerNotInitializedError";
5346
+ }
5347
+ };
5341
5348
  var LONG_RUNNING_ARKADE_SWAPS_REQUEST_TYPES = /* @__PURE__ */ new Set([
5342
5349
  "SEND_LIGHTNING_PAYMENT",
5343
5350
  "CLAIM_VHTLC",
@@ -5439,7 +5446,7 @@ var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
5439
5446
  if (!this.handler || !this.wallet) {
5440
5447
  return this.tagged({
5441
5448
  id,
5442
- error: new Error("handler not initialized")
5449
+ error: new HandlerNotInitializedError()
5443
5450
  });
5444
5451
  }
5445
5452
  try {
@@ -5883,6 +5890,9 @@ var import_sdk10 = require("@arkade-os/sdk");
5883
5890
  function isMessageBusNotInitializedError(error) {
5884
5891
  return error instanceof Error && error.message.includes(import_sdk10.MESSAGE_BUS_NOT_INITIALIZED);
5885
5892
  }
5893
+ function isHandlerNotInitializedError(error) {
5894
+ return error instanceof Error && error.message.includes(HANDLER_NOT_INITIALIZED);
5895
+ }
5886
5896
  var DEFAULT_MESSAGE_TIMEOUT_MS = 3e4;
5887
5897
  var NO_MESSAGE_TIMEOUT_MS = 0;
5888
5898
  var DEDUPABLE_REQUEST_TYPES = /* @__PURE__ */ new Set([
@@ -6630,7 +6640,8 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
6630
6640
  try {
6631
6641
  return await this.sendMessageDirect(request, timeoutMs);
6632
6642
  } catch (error) {
6633
- if (!isMessageBusNotInitializedError(error) || attempt >= maxRetries) {
6643
+ const recoverable = isMessageBusNotInitializedError(error) || isHandlerNotInitializedError(error);
6644
+ if (!recoverable || attempt >= maxRetries) {
6634
6645
  throw error;
6635
6646
  }
6636
6647
  await this.reinitialize();
package/dist/index.js CHANGED
@@ -51,8 +51,7 @@ import {
51
51
  updateReverseSwapStatus,
52
52
  updateSubmarineSwapStatus,
53
53
  verifySignatures
54
- } from "./chunk-LWUXSE5N.js";
55
- import "./chunk-3RG5ZIWI.js";
54
+ } from "./chunk-B3Q4TFWT.js";
56
55
 
57
56
  // src/serviceWorker/arkade-swaps-message-handler.ts
58
57
  import {
@@ -60,6 +59,13 @@ import {
60
59
  RestIndexerProvider
61
60
  } from "@arkade-os/sdk";
62
61
  var DEFAULT_MESSAGE_TAG = "ARKADE_SWAPS_UPDATER";
62
+ var HANDLER_NOT_INITIALIZED = "ArkadeSwaps handler not initialized";
63
+ var HandlerNotInitializedError = class extends Error {
64
+ constructor() {
65
+ super(HANDLER_NOT_INITIALIZED);
66
+ this.name = "HandlerNotInitializedError";
67
+ }
68
+ };
63
69
  var LONG_RUNNING_ARKADE_SWAPS_REQUEST_TYPES = /* @__PURE__ */ new Set([
64
70
  "SEND_LIGHTNING_PAYMENT",
65
71
  "CLAIM_VHTLC",
@@ -161,7 +167,7 @@ var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
161
167
  if (!this.handler || !this.wallet) {
162
168
  return this.tagged({
163
169
  id,
164
- error: new Error("handler not initialized")
170
+ error: new HandlerNotInitializedError()
165
171
  });
166
172
  }
167
173
  try {
@@ -608,6 +614,9 @@ import {
608
614
  function isMessageBusNotInitializedError(error) {
609
615
  return error instanceof Error && error.message.includes(MESSAGE_BUS_NOT_INITIALIZED);
610
616
  }
617
+ function isHandlerNotInitializedError(error) {
618
+ return error instanceof Error && error.message.includes(HANDLER_NOT_INITIALIZED);
619
+ }
611
620
  var DEFAULT_MESSAGE_TIMEOUT_MS = 3e4;
612
621
  var NO_MESSAGE_TIMEOUT_MS = 0;
613
622
  var DEDUPABLE_REQUEST_TYPES = /* @__PURE__ */ new Set([
@@ -1355,7 +1364,8 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
1355
1364
  try {
1356
1365
  return await this.sendMessageDirect(request, timeoutMs);
1357
1366
  } catch (error) {
1358
- if (!isMessageBusNotInitializedError(error) || attempt >= maxRetries) {
1367
+ const recoverable = isMessageBusNotInitializedError(error) || isHandlerNotInitializedError(error);
1368
+ if (!recoverable || attempt >= maxRetries) {
1359
1369
  throw error;
1360
1370
  }
1361
1371
  await this.reinitialize();
@@ -1,5 +1,3 @@
1
- import "../../chunk-3RG5ZIWI.js";
2
-
3
1
  // src/repositories/realm/swap-repository.ts
4
2
  var RealmSwapRepository = class {
5
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,5 +1,3 @@
1
- import "../../chunk-3RG5ZIWI.js";
2
-
3
1
  // src/repositories/sqlite/swap-repository.ts
4
2
  var SQLiteSwapRepository = class {
5
3
  constructor(executor) {