@arkade-os/sdk 0.4.58 → 0.4.60

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.
Files changed (88) hide show
  1. package/README.md +34 -6
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +2 -2
  4. package/dist/adapters/expo.d.ts +2 -2
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/adapters/indexedDB.cjs +5 -5
  7. package/dist/adapters/indexedDB.js +4 -4
  8. package/dist/{ark-ClaVUg4e.d.cts → ark-D2_yNhfz.d.cts} +1077 -522
  9. package/dist/{ark-ClaVUg4e.d.ts → ark-D2_yNhfz.d.ts} +1077 -522
  10. package/dist/{asyncStorageTaskQueue-CnYrhpS-.d.cts → asyncStorageTaskQueue-CqijAAPG.d.cts} +1 -1
  11. package/dist/{asyncStorageTaskQueue-Bgau-mvD.d.ts → asyncStorageTaskQueue-Vsp6uk8e.d.ts} +1 -1
  12. package/dist/{chunk-IPPASJE5.js → chunk-2DINXHGQ.js} +1665 -1149
  13. package/dist/chunk-2DINXHGQ.js.map +1 -0
  14. package/dist/{chunk-SYZEQF5D.cjs → chunk-2XLNQHG4.cjs} +10 -10
  15. package/dist/chunk-2XLNQHG4.cjs.map +1 -0
  16. package/dist/{chunk-AGWZXGG2.js → chunk-3Q7BBUWO.js} +4 -4
  17. package/dist/{chunk-AGWZXGG2.js.map → chunk-3Q7BBUWO.js.map} +1 -1
  18. package/dist/{chunk-D6RGHPZ5.cjs → chunk-4A4GRSTB.cjs} +86 -13
  19. package/dist/chunk-4A4GRSTB.cjs.map +1 -0
  20. package/dist/{chunk-SGWMB4W2.js → chunk-B66RYHTB.js} +5 -5
  21. package/dist/chunk-B66RYHTB.js.map +1 -0
  22. package/dist/{chunk-TV2RLVOB.js → chunk-FSKANUV4.js} +12 -5
  23. package/dist/chunk-FSKANUV4.js.map +1 -0
  24. package/dist/{chunk-I4YEGI2R.cjs → chunk-H7JCHFM6.cjs} +17 -17
  25. package/dist/{chunk-I4YEGI2R.cjs.map → chunk-H7JCHFM6.cjs.map} +1 -1
  26. package/dist/{chunk-VROHHJL4.js → chunk-JBULXTCC.js} +77 -14
  27. package/dist/chunk-JBULXTCC.js.map +1 -0
  28. package/dist/{chunk-6PY4WYXI.cjs → chunk-KNS5MTTI.cjs} +3869 -2935
  29. package/dist/chunk-KNS5MTTI.cjs.map +1 -0
  30. package/dist/{chunk-COLJARV4.cjs → chunk-MZNLCMUP.cjs} +1686 -1169
  31. package/dist/chunk-MZNLCMUP.cjs.map +1 -0
  32. package/dist/{chunk-F4C67JYB.cjs → chunk-PRFL62ID.cjs} +22 -15
  33. package/dist/chunk-PRFL62ID.cjs.map +1 -0
  34. package/dist/{chunk-S3BFUTC5.js → chunk-Y54MUBT7.js} +3512 -2593
  35. package/dist/chunk-Y54MUBT7.js.map +1 -0
  36. package/dist/contracts/handlers/index.cjs +12 -8
  37. package/dist/contracts/handlers/index.d.cts +3 -3
  38. package/dist/contracts/handlers/index.d.ts +3 -3
  39. package/dist/contracts/handlers/index.js +2 -2
  40. package/dist/{delegate-CVrkEepn.d.cts → delegate-DNEuM_nK.d.cts} +1 -1
  41. package/dist/{delegate-YDYq1El_.d.ts → delegate-DidNTsKm.d.ts} +1 -1
  42. package/dist/{index-BmqkJBAf.d.cts → index-BP8-zniX.d.cts} +182 -26
  43. package/dist/{index-CuSHBkq7.d.ts → index-DzQbNQUG.d.ts} +182 -26
  44. package/dist/index.cjs +323 -223
  45. package/dist/index.d.cts +311 -51
  46. package/dist/index.d.ts +311 -51
  47. package/dist/index.js +4 -4
  48. package/dist/repositories/realm/index.cjs +43 -23
  49. package/dist/repositories/realm/index.cjs.map +1 -1
  50. package/dist/repositories/realm/index.d.cts +21 -9
  51. package/dist/repositories/realm/index.d.ts +21 -9
  52. package/dist/repositories/realm/index.js +29 -9
  53. package/dist/repositories/realm/index.js.map +1 -1
  54. package/dist/repositories/sqlite/index.cjs +48 -23
  55. package/dist/repositories/sqlite/index.cjs.map +1 -1
  56. package/dist/repositories/sqlite/index.d.cts +9 -3
  57. package/dist/repositories/sqlite/index.d.ts +9 -3
  58. package/dist/repositories/sqlite/index.js +35 -10
  59. package/dist/repositories/sqlite/index.js.map +1 -1
  60. package/dist/{taskRunner-CFN61bBM.d.ts → taskRunner-9gnlYEpb.d.ts} +1 -1
  61. package/dist/{taskRunner-CFkGkD85.d.cts → taskRunner-BEQNFEa4.d.cts} +1 -1
  62. package/dist/wallet/expo/background.cjs +14 -14
  63. package/dist/wallet/expo/background.d.cts +3 -3
  64. package/dist/wallet/expo/background.d.ts +3 -3
  65. package/dist/wallet/expo/background.js +6 -6
  66. package/dist/wallet/expo/index.cjs +17 -14
  67. package/dist/wallet/expo/index.cjs.map +1 -1
  68. package/dist/wallet/expo/index.d.cts +5 -4
  69. package/dist/wallet/expo/index.d.ts +5 -4
  70. package/dist/wallet/expo/index.js +8 -5
  71. package/dist/wallet/expo/index.js.map +1 -1
  72. package/dist/{wallet-hQp2qC_M.d.cts → wallet-C_MYHyOj.d.ts} +176 -17
  73. package/dist/{wallet-DnK09TtT.d.ts → wallet-ipUA1XCp.d.cts} +176 -17
  74. package/dist/worker/expo/index.cjs +9 -9
  75. package/dist/worker/expo/index.d.cts +5 -5
  76. package/dist/worker/expo/index.d.ts +5 -5
  77. package/dist/worker/expo/index.js +5 -5
  78. package/package.json +9 -2
  79. package/dist/chunk-6PY4WYXI.cjs.map +0 -1
  80. package/dist/chunk-COLJARV4.cjs.map +0 -1
  81. package/dist/chunk-D6RGHPZ5.cjs.map +0 -1
  82. package/dist/chunk-F4C67JYB.cjs.map +0 -1
  83. package/dist/chunk-IPPASJE5.js.map +0 -1
  84. package/dist/chunk-S3BFUTC5.js.map +0 -1
  85. package/dist/chunk-SGWMB4W2.js.map +0 -1
  86. package/dist/chunk-SYZEQF5D.cjs.map +0 -1
  87. package/dist/chunk-TV2RLVOB.js.map +0 -1
  88. package/dist/chunk-VROHHJL4.js.map +0 -1
package/README.md CHANGED
@@ -914,6 +914,7 @@ import {
914
914
  WalletMessageHandler,
915
915
  IndexedDBWalletRepository,
916
916
  IndexedDBContractRepository,
917
+ IndexedDBIntentRepository,
917
918
  } from '@arkade-os/sdk'
918
919
 
919
920
  const walletRepo = new IndexedDBWalletRepository()
@@ -922,6 +923,10 @@ const contractRepo = new IndexedDBContractRepository()
922
923
  const bus = new MessageBus(walletRepo, contractRepo, {
923
924
  messageHandlers: [new WalletMessageHandler()],
924
925
  tickIntervalMs: 10_000, // default 10s
926
+ // Optional, same opt-in as `storage.intentRepository` on a main-thread
927
+ // wallet. Omit it and the worker persists no settlement intent, reconciles
928
+ // none on restart, and counts intent-locked VTXOs as available.
929
+ intentRepository: new IndexedDBIntentRepository(),
925
930
  })
926
931
 
927
932
  bus.start()
@@ -1141,7 +1146,7 @@ const wallet = await Wallet.create({
1141
1146
 
1142
1147
  ### Using with Node.js
1143
1148
 
1144
- Node.js does not provide a global `EventSource` implementation. The SDK relies on `EventSource` for Server-Sent Events during settlement (onboarding/offboarding) and contract watching. You must polyfill it before using the SDK:
1149
+ Node.js does not provide a global `EventSource` implementation (24.x has one behind `--experimental-eventsource`). The SDK relies on `EventSource` for Server-Sent Events during settlement (onboarding/offboarding) and contract watching, so tell it which one to use:
1145
1150
 
1146
1151
  ```bash
1147
1152
  npm install eventsource
@@ -1149,12 +1154,15 @@ npm install eventsource
1149
1154
 
1150
1155
  ```typescript
1151
1156
  import { EventSource } from "eventsource";
1152
- (globalThis as any).EventSource = EventSource;
1157
+ import { configureEventSource, Wallet } from "@arkade-os/sdk";
1153
1158
 
1154
- // Use dynamic import so the polyfill is set before the SDK evaluates
1155
- const { Wallet } = await import("@arkade-os/sdk");
1159
+ configureEventSource((url) => new EventSource(url));
1156
1160
  ```
1157
1161
 
1162
+ Order does not matter: the factory is resolved when a stream opens, not when the SDK is imported, so no dynamic-import dance is needed. A single provider can override it — `new RestIndexerProvider(url, { eventSource })` — for a process that needs different transports per connection.
1163
+
1164
+ Assigning `globalThis.EventSource` still works and is still the last resort in the resolution order (per-provider option → `configureEventSource` → global).
1165
+
1158
1166
  If you also need IndexedDB persistence (e.g. for `WalletRepository`), set up the shim before any SDK import:
1159
1167
 
1160
1168
  ```typescript
@@ -1168,8 +1176,10 @@ setGlobalVars(null, { checkOrigin: false });
1168
1176
  ```
1169
1177
 
1170
1178
  > **Note:** `eventsource` and `indexeddbshim` are optional peer dependencies.
1171
- > Without the `EventSource` polyfill, settlement operations will fail with
1172
- > `ReferenceError: EventSource is not defined`.
1179
+ > With no `EventSource` available, settlement fails with a typed
1180
+ > `EventSourceUnavailableError` naming the remedy, and contract watching warns
1181
+ > once and falls back to its failsafe polling — it does not retry a missing
1182
+ > global, and it does not go quiet either.
1173
1183
 
1174
1184
  See [`examples/node/multiple-wallets.ts`](examples/node/multiple-wallets.ts) for a complete working example.
1175
1185
 
@@ -1351,6 +1361,24 @@ Contract freshness behavior:
1351
1361
  - **Failsafe polling** every 20 seconds by default to catch missed events, configurable via `watcherConfig.failsafePollIntervalMs`
1352
1362
  - **Manual refresh** through `manager.refreshVtxos()`; pass `{ includeInactive: true }` to sweep every repository contract
1353
1363
 
1364
+ Which contracts get that coverage is `contract.watch`, and it is independent of
1365
+ `contract.state` (which only governs receive-address selection — a retired
1366
+ receive address stays watched, because it can still be paid):
1367
+
1368
+ ```typescript
1369
+ // Watch a one-shot destination only until it is funded; the manager
1370
+ // demotes it to `retained` itself once a VTXO lands.
1371
+ await manager.createContract({ ...params, watch: 'awaiting-funds' })
1372
+
1373
+ // A finished contract — a settled swap lockup, say. The row stays for
1374
+ // history, annotation and restore; it just leaves the subscription and
1375
+ // the poll. Unlike `deleteContract`, nothing is lost.
1376
+ await manager.setContractWatchState(script, 'retained')
1377
+ ```
1378
+
1379
+ A row with no `watch` value is `watched`, so contracts written by earlier SDK
1380
+ versions keep the coverage they have today.
1381
+
1354
1382
  ### Repository Pattern
1355
1383
 
1356
1384
  Most users don't need to touch repositories directly — `Wallet` reads through them and `ContractManager` owns VTXO/contract synchronization into them. They are documented here for advanced integrations (custom storage backends, offline-first apps, repository inspection).
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkI4YEGI2R_cjs = require('../chunk-I4YEGI2R.cjs');
4
- require('../chunk-F4C67JYB.cjs');
5
- require('../chunk-D6RGHPZ5.cjs');
3
+ var chunkH7JCHFM6_cjs = require('../chunk-H7JCHFM6.cjs');
4
+ require('../chunk-PRFL62ID.cjs');
5
+ require('../chunk-4A4GRSTB.cjs');
6
6
  require('../chunk-5BLDMQED.cjs');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "ExpoArkProvider", {
11
11
  enumerable: true,
12
- get: function () { return chunkI4YEGI2R_cjs.ExpoArkProvider; }
12
+ get: function () { return chunkH7JCHFM6_cjs.ExpoArkProvider; }
13
13
  });
14
14
  Object.defineProperty(exports, "ExpoIndexerProvider", {
15
15
  enumerable: true,
16
- get: function () { return chunkI4YEGI2R_cjs.ExpoIndexerProvider; }
16
+ get: function () { return chunkH7JCHFM6_cjs.ExpoIndexerProvider; }
17
17
  });
18
18
  //# sourceMappingURL=expo.cjs.map
19
19
  //# sourceMappingURL=expo.cjs.map
@@ -1,5 +1,5 @@
1
- import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-ClaVUg4e.cjs';
2
- export { n as ArkProvider, o as IndexerProvider } from '../ark-ClaVUg4e.cjs';
1
+ import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-D2_yNhfz.cjs';
2
+ export { n as ArkProvider, o as IndexerProvider } from '../ark-D2_yNhfz.cjs';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
@@ -1,5 +1,5 @@
1
- import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-ClaVUg4e.js';
2
- export { n as ArkProvider, o as IndexerProvider } from '../ark-ClaVUg4e.js';
1
+ import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-D2_yNhfz.js';
2
+ export { n as ArkProvider, o as IndexerProvider } from '../ark-D2_yNhfz.js';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
@@ -1,6 +1,6 @@
1
- export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-AGWZXGG2.js';
2
- import '../chunk-TV2RLVOB.js';
3
- import '../chunk-VROHHJL4.js';
1
+ export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-3Q7BBUWO.js';
2
+ import '../chunk-FSKANUV4.js';
3
+ import '../chunk-JBULXTCC.js';
4
4
  import '../chunk-NSBPE2FW.js';
5
5
  //# sourceMappingURL=expo.js.map
6
6
  //# sourceMappingURL=expo.js.map
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunk6PY4WYXI_cjs = require('../chunk-6PY4WYXI.cjs');
4
- require('../chunk-F4C67JYB.cjs');
5
- require('../chunk-COLJARV4.cjs');
6
- require('../chunk-D6RGHPZ5.cjs');
3
+ var chunkKNS5MTTI_cjs = require('../chunk-KNS5MTTI.cjs');
4
+ require('../chunk-PRFL62ID.cjs');
5
+ require('../chunk-MZNLCMUP.cjs');
6
+ require('../chunk-4A4GRSTB.cjs');
7
7
  require('../chunk-5BLDMQED.cjs');
8
8
 
9
9
  // src/storage/indexedDB.ts
@@ -11,7 +11,7 @@ var IndexedDBStorageAdapter = class {
11
11
  dbName;
12
12
  version;
13
13
  db = null;
14
- constructor(dbName, version = chunk6PY4WYXI_cjs.DB_VERSION) {
14
+ constructor(dbName, version = chunkKNS5MTTI_cjs.DB_VERSION) {
15
15
  this.dbName = dbName;
16
16
  this.version = version;
17
17
  }
@@ -1,7 +1,7 @@
1
- import { DB_VERSION } from '../chunk-S3BFUTC5.js';
2
- import '../chunk-TV2RLVOB.js';
3
- import '../chunk-IPPASJE5.js';
4
- import '../chunk-VROHHJL4.js';
1
+ import { DB_VERSION } from '../chunk-Y54MUBT7.js';
2
+ import '../chunk-FSKANUV4.js';
3
+ import '../chunk-2DINXHGQ.js';
4
+ import '../chunk-JBULXTCC.js';
5
5
  import '../chunk-NSBPE2FW.js';
6
6
 
7
7
  // src/storage/indexedDB.ts