@arkade-os/sdk 0.4.49 → 0.4.51
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.
- package/README.md +33 -8
- package/dist/adapters/expo.cjs +4 -4
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +2 -2
- package/dist/adapters/indexedDB.cjs +3 -3
- package/dist/adapters/indexedDB.js +2 -2
- package/dist/{ark-nkSiPYNf.d.cts → ark-9V45Anrs.d.cts} +164 -53
- package/dist/{ark-nkSiPYNf.d.ts → ark-9V45Anrs.d.ts} +164 -53
- package/dist/{asyncStorageTaskQueue-DdxhsEz6.d.cts → asyncStorageTaskQueue-B6nXJv7m.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-DCaEE83p.d.ts → asyncStorageTaskQueue-BZjR843B.d.ts} +1 -1
- package/dist/{chunk-CPO2UB7L.js → chunk-3AOTJZQ4.js} +3 -3
- package/dist/{chunk-CPO2UB7L.js.map → chunk-3AOTJZQ4.js.map} +1 -1
- package/dist/{chunk-6UI5BFE7.cjs → chunk-3E4GDBYU.cjs} +7 -7
- package/dist/{chunk-6UI5BFE7.cjs.map → chunk-3E4GDBYU.cjs.map} +1 -1
- package/dist/{chunk-BLJQV3N4.js → chunk-4KGT3IP2.js} +3 -3
- package/dist/{chunk-BLJQV3N4.js.map → chunk-4KGT3IP2.js.map} +1 -1
- package/dist/{chunk-XOLH3LFO.cjs → chunk-5AT2NV5G.cjs} +11 -11
- package/dist/{chunk-XOLH3LFO.cjs.map → chunk-5AT2NV5G.cjs.map} +1 -1
- package/dist/{chunk-HN25T276.js → chunk-6T5BBPKO.js} +3 -3
- package/dist/{chunk-HN25T276.js.map → chunk-6T5BBPKO.js.map} +1 -1
- package/dist/{chunk-2LAJ3RTH.cjs → chunk-6XF6ZATZ.cjs} +458 -203
- package/dist/chunk-6XF6ZATZ.cjs.map +1 -0
- package/dist/{chunk-QDXQULVM.cjs → chunk-FHDUEBBC.cjs} +3 -3
- package/dist/{chunk-QDXQULVM.cjs.map → chunk-FHDUEBBC.cjs.map} +1 -1
- package/dist/{chunk-5QVBJUOG.js → chunk-TS2MTRP4.js} +354 -99
- package/dist/chunk-TS2MTRP4.js.map +1 -0
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/{delegate-D6Orvyq7.d.ts → delegate-CJkolr2s.d.ts} +1 -1
- package/dist/{delegate-Cqqw1T1J.d.cts → delegate-tVTPM4fm.d.cts} +1 -1
- package/dist/{index-CWoogah0.d.ts → index-B5Fdwzs_.d.ts} +2 -2
- package/dist/{index-Yd4hecbM.d.cts → index-BBAffp_8.d.cts} +2 -2
- package/dist/index.cjs +145 -145
- package/dist/index.d.cts +24 -8
- package/dist/index.d.ts +24 -8
- package/dist/index.js +2 -2
- package/dist/repositories/realm/index.cjs +17 -17
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +3 -3
- package/dist/repositories/sqlite/index.cjs +16 -16
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +3 -3
- package/dist/{taskRunner-BjB5QINR.d.cts → taskRunner-4CrJaWHv.d.cts} +1 -1
- package/dist/{taskRunner-Dw7xs60Q.d.ts → taskRunner-TgdjRf_b.d.ts} +1 -1
- package/dist/wallet/expo/background.cjs +12 -12
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +4 -4
- package/dist/wallet/expo/index.cjs +12 -12
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +3 -3
- package/dist/{wallet-DyUHrPyN.d.ts → wallet-BBfhZx_Z.d.cts} +22 -3
- package/dist/{wallet-CGkWu3xV.d.cts → wallet-CSSTN8Yc.d.ts} +22 -3
- package/dist/worker/expo/index.cjs +7 -7
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-2LAJ3RTH.cjs.map +0 -1
- package/dist/chunk-5QVBJUOG.js.map +0 -1
package/README.md
CHANGED
|
@@ -1247,9 +1247,33 @@ This is required for MuSig2 settlements and cryptographic operations.
|
|
|
1247
1247
|
|
|
1248
1248
|
### Contract Management
|
|
1249
1249
|
|
|
1250
|
-
Both `Wallet` and `ServiceWorkerWallet` use a `ContractManager` internally to watch for virtual outputs. This provides resilient connection handling with automatic reconnection and failsafe polling - for your wallet's default address and any external contracts you register (Boltz swaps, HTLCs, etc.).
|
|
1250
|
+
Both `Wallet` and `ServiceWorkerWallet` use a `ContractManager` internally to watch for virtual outputs and persist them into repositories. This provides resilient connection handling with automatic reconnection and failsafe polling - for your wallet's default address and any external contracts you register (Boltz swaps, HTLCs, etc.).
|
|
1251
1251
|
|
|
1252
|
-
When you call `wallet.notifyIncomingFunds()` or use `waitForIncomingFunds()`, it uses the ContractManager under the hood, giving you automatic reconnection and
|
|
1252
|
+
When you call `wallet.notifyIncomingFunds()` or use `waitForIncomingFunds()`, it uses the ContractManager under the hood, giving you automatic reconnection and repository-backed event replay for free - no code changes needed.
|
|
1253
|
+
|
|
1254
|
+
`watcherConfig.failsafePollIntervalMs` (default `20_000`) controls how often the watcher replays repository changes into contract events; it does not fetch fresh VTXOs from the indexer.
|
|
1255
|
+
|
|
1256
|
+
#### HD look-ahead window
|
|
1257
|
+
|
|
1258
|
+
HD wallets (`walletMode: 'hd'`, or an explicit HD `DescriptorProvider`) also watch a band of *unused* offchain receive scripts around their allocation watermark, so a payment to an address that some other party issued from the same seed — a merchant backend such as BTCPay Server — arrives without the user calling `restore()`. `lookAheadWindow` (default `20`) is the per-side width of that band: the wallet watches `[watermark - N, watermark + N]`. Speculative entries are subscription-only; they become contract rows, and enter balances, only once funded.
|
|
1259
|
+
|
|
1260
|
+
```typescript
|
|
1261
|
+
const wallet = await Wallet.create({
|
|
1262
|
+
identity,
|
|
1263
|
+
walletMode: 'hd',
|
|
1264
|
+
lookAheadWindow: 50, // issuer hands out long runs of unpaid invoices
|
|
1265
|
+
})
|
|
1266
|
+
|
|
1267
|
+
// Same option on the service-worker wallet; it is forwarded to the worker's inner wallet.
|
|
1268
|
+
const swWallet = await ServiceWorkerWallet.setup({
|
|
1269
|
+
serviceWorkerPath: '/service-worker.js',
|
|
1270
|
+
identity,
|
|
1271
|
+
walletMode: 'hd',
|
|
1272
|
+
lookAheadWindow: 50,
|
|
1273
|
+
})
|
|
1274
|
+
```
|
|
1275
|
+
|
|
1276
|
+
Raise it when the external issuer is expected to burn more than `N` consecutive addresses without any of them being paid — every index in such a run is a miss, and the funded one sits past the band. When that happens the funds are invisible until a `restore()` whose `gapLimit` is large enough to cross the run (`wallet.restore({ gapLimit: 200 })`); a default restore closes its gap window before reaching the funded index. Keep the value modest: the band adds up to `2N + 1` script filters to the wallet's subscription.
|
|
1253
1277
|
|
|
1254
1278
|
For advanced use cases, you can access the ContractManager directly to register external contracts:
|
|
1255
1279
|
|
|
@@ -1312,21 +1336,22 @@ const allPaths = await manager.getAllSpendingPaths({
|
|
|
1312
1336
|
// Fetch contracts together with their current virtual outputs
|
|
1313
1337
|
const contractsWithVtxos = await manager.getContractsWithVtxos()
|
|
1314
1338
|
|
|
1315
|
-
// Force
|
|
1339
|
+
// Force an indexer refresh of the watched contracts when needed
|
|
1316
1340
|
await manager.refreshVtxos()
|
|
1317
1341
|
|
|
1318
1342
|
// Stop watching
|
|
1319
1343
|
unsubscribe()
|
|
1320
1344
|
```
|
|
1321
1345
|
|
|
1322
|
-
|
|
1323
|
-
- **Automatic reconnection** with exponential backoff (1s →
|
|
1324
|
-
- **
|
|
1325
|
-
- **
|
|
1346
|
+
Contract freshness behavior:
|
|
1347
|
+
- **Automatic reconnection** with exponential backoff (1s → 5s max)
|
|
1348
|
+
- **Immediate sync** on manager initialization, subscription reconnect, and contract events
|
|
1349
|
+
- **Failsafe polling** every 20 seconds by default to catch missed events, configurable via `watcherConfig.failsafePollIntervalMs`
|
|
1350
|
+
- **Manual refresh** through `manager.refreshVtxos()`; pass `{ includeInactive: true }` to sweep every repository contract
|
|
1326
1351
|
|
|
1327
1352
|
### Repository Pattern
|
|
1328
1353
|
|
|
1329
|
-
Most users don't need to touch repositories directly — `Wallet` and `ContractManager`
|
|
1354
|
+
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).
|
|
1330
1355
|
|
|
1331
1356
|
```typescript
|
|
1332
1357
|
// Wallet repository — VTXOs, UTXOs, transaction history, settings
|
package/dist/adapters/expo.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunk5AT2NV5G_cjs = require('../chunk-5AT2NV5G.cjs');
|
|
4
|
+
require('../chunk-FHDUEBBC.cjs');
|
|
5
5
|
require('../chunk-E7HB3GKK.cjs');
|
|
6
6
|
require('../chunk-5BLDMQED.cjs');
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ require('../chunk-5BLDMQED.cjs');
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "ExpoArkProvider", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunk5AT2NV5G_cjs.ExpoArkProvider; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "ExpoIndexerProvider", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunk5AT2NV5G_cjs.ExpoIndexerProvider; }
|
|
17
17
|
});
|
|
18
18
|
//# sourceMappingURL=expo.cjs.map
|
|
19
19
|
//# sourceMappingURL=expo.cjs.map
|
package/dist/adapters/expo.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-
|
|
2
|
-
export { n as ArkProvider, o as IndexerProvider } from '../ark-
|
|
1
|
+
import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-9V45Anrs.cjs';
|
|
2
|
+
export { n as ArkProvider, o as IndexerProvider } from '../ark-9V45Anrs.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';
|
package/dist/adapters/expo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-
|
|
2
|
-
export { n as ArkProvider, o as IndexerProvider } from '../ark-
|
|
1
|
+
import { k as RestArkProvider, i as SettlementEvent, T as TxNotification, l as RestIndexerProvider, m as SubscriptionResponse } from '../ark-9V45Anrs.js';
|
|
2
|
+
export { n as ArkProvider, o as IndexerProvider } from '../ark-9V45Anrs.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';
|
package/dist/adapters/expo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-6T5BBPKO.js';
|
|
2
|
+
import '../chunk-3AOTJZQ4.js';
|
|
3
3
|
import '../chunk-EFNLTS6Q.js';
|
|
4
4
|
import '../chunk-NSBPE2FW.js';
|
|
5
5
|
//# sourceMappingURL=expo.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunk6XF6ZATZ_cjs = require('../chunk-6XF6ZATZ.cjs');
|
|
4
|
+
require('../chunk-FHDUEBBC.cjs');
|
|
5
5
|
require('../chunk-LJQ2VQBE.cjs');
|
|
6
6
|
require('../chunk-E7HB3GKK.cjs');
|
|
7
7
|
require('../chunk-5BLDMQED.cjs');
|
|
@@ -11,7 +11,7 @@ var IndexedDBStorageAdapter = class {
|
|
|
11
11
|
dbName;
|
|
12
12
|
version;
|
|
13
13
|
db = null;
|
|
14
|
-
constructor(dbName, version =
|
|
14
|
+
constructor(dbName, version = chunk6XF6ZATZ_cjs.DB_VERSION) {
|
|
15
15
|
this.dbName = dbName;
|
|
16
16
|
this.version = version;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DB_VERSION } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { DB_VERSION } from '../chunk-TS2MTRP4.js';
|
|
2
|
+
import '../chunk-3AOTJZQ4.js';
|
|
3
3
|
import '../chunk-MBSYQ3WX.js';
|
|
4
4
|
import '../chunk-EFNLTS6Q.js';
|
|
5
5
|
import '../chunk-NSBPE2FW.js';
|
|
@@ -1890,22 +1890,30 @@ interface VirtualTxRepository extends AsyncDisposable {
|
|
|
1890
1890
|
}
|
|
1891
1891
|
|
|
1892
1892
|
type RefreshVtxosOptions = {
|
|
1893
|
+
/**
|
|
1894
|
+
* Narrow the refresh to these scripts. A subset query, so the
|
|
1895
|
+
* cursor is not advanced: contracts outside the list may have data
|
|
1896
|
+
* we'd skip.
|
|
1897
|
+
*/
|
|
1893
1898
|
scripts?: string[];
|
|
1899
|
+
/**
|
|
1900
|
+
* Time window overriding the cursor-derived one. The cursor never
|
|
1901
|
+
* advances on a windowed query because the window may skip data
|
|
1902
|
+
* outside its bounds.
|
|
1903
|
+
*/
|
|
1894
1904
|
after?: number;
|
|
1905
|
+
/** @see after */
|
|
1895
1906
|
before?: number;
|
|
1896
1907
|
/**
|
|
1897
1908
|
* When true and `scripts` is not set, refresh every contract in
|
|
1898
|
-
* the repository
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
* Because this is a *superset* of the watcher's watched set, the
|
|
1904
|
-
* cursor invariant still holds and the cursor advances normally
|
|
1905
|
-
* (unless an explicit `after` / `before` window is also supplied).
|
|
1909
|
+
* the repository rather than the watcher's watched set — which
|
|
1910
|
+
* differs only for rows the watcher never registered, since
|
|
1911
|
+
* retirement doesn't narrow that set
|
|
1912
|
+
* (see {@link ContractWatcher.getWatchedContracts}).
|
|
1906
1913
|
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1914
|
+
* Because this is a *superset* of the watched set, the cursor
|
|
1915
|
+
* invariant still holds and the cursor advances normally (unless
|
|
1916
|
+
* `after` / `before` is also supplied).
|
|
1909
1917
|
*
|
|
1910
1918
|
* @defaultValue `false`
|
|
1911
1919
|
*/
|
|
@@ -2044,11 +2052,14 @@ interface IContractManager extends Disposable {
|
|
|
2044
2052
|
*/
|
|
2045
2053
|
updateContract(script: string, updates: Partial<Omit<Contract, "script" | "createdAt">>): Promise<Contract>;
|
|
2046
2054
|
/**
|
|
2047
|
-
* Convenience helper to update only the contract state.
|
|
2055
|
+
* Convenience helper to update only the contract state. Note
|
|
2056
|
+
* `inactive` does not stop watching; see {@link ContractState} and
|
|
2057
|
+
* {@link deleteContract}.
|
|
2048
2058
|
*/
|
|
2049
2059
|
setContractState(script: string, state: ContractState): Promise<void>;
|
|
2050
2060
|
/**
|
|
2051
|
-
* Delete a contract by script and stop watching it
|
|
2061
|
+
* Delete a contract by script and stop watching it. This — not
|
|
2062
|
+
* retiring via {@link setContractState} — is the stop-watching path.
|
|
2052
2063
|
*/
|
|
2053
2064
|
deleteContract(script: string): Promise<void>;
|
|
2054
2065
|
/**
|
|
@@ -2091,6 +2102,15 @@ interface IContractManager extends Disposable {
|
|
|
2091
2102
|
* Outpoints not owned by any tracked contract are silently dropped.
|
|
2092
2103
|
*/
|
|
2093
2104
|
refreshOutpoints(outpoints: Outpoint[]): Promise<void>;
|
|
2105
|
+
/**
|
|
2106
|
+
* Rebuild the HD look-ahead watch window around the current allocation
|
|
2107
|
+
* watermark. No-op when the manager was configured without `lookAhead`.
|
|
2108
|
+
*
|
|
2109
|
+
* Call after anything that moves the watermark (restore, boarding
|
|
2110
|
+
* allocation, receive rotation, server-signer rotation). Concurrent calls
|
|
2111
|
+
* coalesce into a single drain.
|
|
2112
|
+
*/
|
|
2113
|
+
refillLookAhead(): Promise<void>;
|
|
2094
2114
|
/**
|
|
2095
2115
|
* Explicit, gap-limit contract discovery used by `wallet.restore()`.
|
|
2096
2116
|
*
|
|
@@ -2181,6 +2201,27 @@ interface ContractManagerConfig {
|
|
|
2181
2201
|
onVtxosSpent?: (vtxos: Outpoint[]) => Promise<void>;
|
|
2182
2202
|
/** Watcher configuration */
|
|
2183
2203
|
watcherConfig?: Partial<ContractWatcherConfig>;
|
|
2204
|
+
/**
|
|
2205
|
+
* Enables the HD look-ahead watch window. Absent ⇒ feature off (static /
|
|
2206
|
+
* non-HD wallets, third-party embedders). See
|
|
2207
|
+
* {@link ContractManager.refillLookAhead}.
|
|
2208
|
+
*/
|
|
2209
|
+
lookAhead?: LookAheadConfig;
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Wallet-injected surface backing the HD look-ahead window. Kept as a
|
|
2213
|
+
* callback bundle so the contracts layer never learns what an HD descriptor
|
|
2214
|
+
* is (mirrors {@link ScanContractsOptions.materialize}).
|
|
2215
|
+
*/
|
|
2216
|
+
interface LookAheadConfig {
|
|
2217
|
+
/** Per-side band bound: the window spans `[max(0, w - size), w + size]`. */
|
|
2218
|
+
size: number;
|
|
2219
|
+
/** Current allocation watermark (`lastIndexUsed ?? -1`). */
|
|
2220
|
+
currentWatermark(): Promise<number>;
|
|
2221
|
+
/** Offchain receive contract params at an HD index. Pure derivation. */
|
|
2222
|
+
materialize(index: number): CreateContractParams;
|
|
2223
|
+
/** Fired after a speculative entry at `index` is promoted to a real row. */
|
|
2224
|
+
onPromoted?(index: number): Promise<void>;
|
|
2184
2225
|
}
|
|
2185
2226
|
/**
|
|
2186
2227
|
* Parameters for creating a new contract.
|
|
@@ -2246,13 +2287,19 @@ declare class ContractManager implements IContractManager {
|
|
|
2246
2287
|
private syncDegradedReason?;
|
|
2247
2288
|
/** Epoch-ms of the last successful provider sync, if any. */
|
|
2248
2289
|
private lastSyncedAt?;
|
|
2290
|
+
/** Speculative look-ahead scripts, keyed by script. @see LookAheadEntry */
|
|
2291
|
+
private lookAheadEntries;
|
|
2292
|
+
/** In-flight look-ahead drain, if any. @see scheduleLookAheadDrain */
|
|
2293
|
+
private lookAheadDrain?;
|
|
2294
|
+
/** A refill was requested while a drain was running. */
|
|
2295
|
+
private lookAheadDirty;
|
|
2249
2296
|
private constructor();
|
|
2250
2297
|
/**
|
|
2251
2298
|
* Static factory method for creating a new ContractManager.
|
|
2252
2299
|
* Initialize the manager by loading persisted contracts and starting to watch.
|
|
2253
2300
|
*
|
|
2254
|
-
* After initialization, the manager automatically watches
|
|
2255
|
-
*
|
|
2301
|
+
* After initialization, the manager automatically watches every persisted
|
|
2302
|
+
* contract. Use `onContractEvent()` to register event callbacks.
|
|
2256
2303
|
*
|
|
2257
2304
|
* @param config ContractManagerConfig
|
|
2258
2305
|
*/
|
|
@@ -2287,6 +2334,59 @@ declare class ContractManager implements IContractManager {
|
|
|
2287
2334
|
* a failure is logged and sync continues. No-op without an intent store.
|
|
2288
2335
|
*/
|
|
2289
2336
|
private reconcileStaleIntents;
|
|
2337
|
+
/** @see IContractManager.refillLookAhead */
|
|
2338
|
+
refillLookAhead(): Promise<void>;
|
|
2339
|
+
/**
|
|
2340
|
+
* Serialized drain of the look-ahead band: concurrent callers join the
|
|
2341
|
+
* active drain and mark it dirty, an idle call starts a new one. Promotion
|
|
2342
|
+
* can uncover more funded indices, and boot / SSE / rotate / reconnect can
|
|
2343
|
+
* all request a refill at once, so the loop coalesces them instead of
|
|
2344
|
+
* recursing.
|
|
2345
|
+
*/
|
|
2346
|
+
private scheduleLookAheadDrain;
|
|
2347
|
+
/**
|
|
2348
|
+
* Request a drain without awaiting it. Used from inside a sync (promotion),
|
|
2349
|
+
* where awaiting the drain that the sync itself is part of would deadlock.
|
|
2350
|
+
*/
|
|
2351
|
+
private requestLookAheadDrain;
|
|
2352
|
+
/**
|
|
2353
|
+
* Rebuild the speculative watch band around the allocation watermark.
|
|
2354
|
+
*
|
|
2355
|
+
* NArk needs no analogue because it *is* the address issuer: it persists a
|
|
2356
|
+
* contract row at derivation time, so its watched set is a superset of
|
|
2357
|
+
* every address it ever advertised. This SDK, when a third party issues
|
|
2358
|
+
* addresses from the shared seed, cannot observe those allocations at all —
|
|
2359
|
+
* the window is how a non-issuer compensates.
|
|
2360
|
+
*
|
|
2361
|
+
* Entries are registered with the watcher but NOT persisted: they become
|
|
2362
|
+
* repository rows only once funded (see {@link promoteLookAheadHits}).
|
|
2363
|
+
*/
|
|
2364
|
+
private ensureLookAhead;
|
|
2365
|
+
/**
|
|
2366
|
+
* One-time full-history sync for speculative entries the manager has not
|
|
2367
|
+
* successfully caught up on yet.
|
|
2368
|
+
*
|
|
2369
|
+
* Every normal sync uses the cursor-derived delta window and SSE only
|
|
2370
|
+
* delivers events after a script is subscribed, so a script first
|
|
2371
|
+
* registered after its funding time would otherwise be skipped forever
|
|
2372
|
+
* (upgrade migration, or a band that slid over an already-funded index).
|
|
2373
|
+
* The entries are passed as in-memory contracts because `refreshVtxos`
|
|
2374
|
+
* resolves scripts through the repository, where they deliberately do not
|
|
2375
|
+
* exist. Targeted + explicitly windowed, so the global cursor stays put.
|
|
2376
|
+
*/
|
|
2377
|
+
private runLookAheadCatchUp;
|
|
2378
|
+
/**
|
|
2379
|
+
* Promote every look-ahead entry funded by `vtxos` into a real repository
|
|
2380
|
+
* row, returning the persisted rows keyed by script.
|
|
2381
|
+
*
|
|
2382
|
+
* MUST run on each raw indexer fetch before `annotateVtxos`:
|
|
2383
|
+
* `extendVirtualCoinForContract` throws when a VTXO's script has no
|
|
2384
|
+
* contract row, so a funded window entry has to be persisted before its
|
|
2385
|
+
* VTXOs are annotated and saved. Callers also swap the returned rows into
|
|
2386
|
+
* the local contract maps they built pre-promotion, so `saveVtxosForContract`
|
|
2387
|
+
* and `onVtxosPersisted` never see the synthetic watcher object.
|
|
2388
|
+
*/
|
|
2389
|
+
private promoteLookAheadHits;
|
|
2290
2390
|
/**
|
|
2291
2391
|
* Create and register a new contract.
|
|
2292
2392
|
*
|
|
@@ -2313,6 +2413,7 @@ declare class ContractManager implements IContractManager {
|
|
|
2313
2413
|
* `persisted` is `true`.
|
|
2314
2414
|
*/
|
|
2315
2415
|
private upsertContract;
|
|
2416
|
+
private upsertContractRow;
|
|
2316
2417
|
/**
|
|
2317
2418
|
* Explicit, gap-limit contract discovery (see {@link IContractManager.scanContracts}).
|
|
2318
2419
|
*
|
|
@@ -2398,11 +2499,15 @@ declare class ContractManager implements IContractManager {
|
|
|
2398
2499
|
*/
|
|
2399
2500
|
updateContractParams(script: string, updates: Contract["params"]): Promise<Contract>;
|
|
2400
2501
|
/**
|
|
2401
|
-
* Set a contract's state.
|
|
2502
|
+
* Set a contract's state. Retiring (`inactive`) keeps it watched;
|
|
2503
|
+
* see {@link ContractState}. To stop watching, use
|
|
2504
|
+
* {@link deleteContract}.
|
|
2402
2505
|
*/
|
|
2403
2506
|
setContractState(script: string, state: ContractState): Promise<void>;
|
|
2404
2507
|
/**
|
|
2405
|
-
* Delete a contract.
|
|
2508
|
+
* Delete a contract. Also removes it from the watcher — the only way
|
|
2509
|
+
* to stop watching a contract (retiring it via
|
|
2510
|
+
* {@link setContractState} does not).
|
|
2406
2511
|
*
|
|
2407
2512
|
* @param script - Contract script
|
|
2408
2513
|
*/
|
|
@@ -2442,22 +2547,10 @@ declare class ContractManager implements IContractManager {
|
|
|
2442
2547
|
/**
|
|
2443
2548
|
* Force refresh virtual outputs from the indexer.
|
|
2444
2549
|
*
|
|
2445
|
-
* Without options, re-fetches
|
|
2446
|
-
*
|
|
2447
|
-
*
|
|
2448
|
-
*
|
|
2449
|
-
* cursor is not advanced because contracts outside the list may
|
|
2450
|
-
* have data we'd skip).
|
|
2451
|
-
*
|
|
2452
|
-
* `includeInactive: true` (and no `scripts`) widens the refresh to
|
|
2453
|
-
* every contract in the repository, including ones marked
|
|
2454
|
-
* `inactive` and ones that have dropped out of the watcher's
|
|
2455
|
-
* active set. This is a *superset* of the watched set, so the
|
|
2456
|
-
* cursor invariant still holds and the cursor advances normally.
|
|
2457
|
-
*
|
|
2458
|
-
* `after` / `before` apply a caller-supplied time window. The
|
|
2459
|
-
* cursor never advances on a windowed query because the window
|
|
2460
|
-
* may skip data outside its bounds.
|
|
2550
|
+
* Without options, re-fetches the watcher's watched set and
|
|
2551
|
+
* advances the global cursor. Each option narrows or widens that
|
|
2552
|
+
* scope and may hold the cursor back — see
|
|
2553
|
+
* {@link RefreshVtxosOptions}.
|
|
2461
2554
|
*/
|
|
2462
2555
|
refreshVtxos(opts?: RefreshVtxosOptions): Promise<void>;
|
|
2463
2556
|
refreshOutpoints(outpoints: Outpoint[]): Promise<void>;
|
|
@@ -2478,11 +2571,10 @@ declare class ContractManager implements IContractManager {
|
|
|
2478
2571
|
* Sync virtual outputs for the given contracts against the indexer.
|
|
2479
2572
|
*
|
|
2480
2573
|
* When `options.contracts` is omitted the sync covers the full
|
|
2481
|
-
* watched set (
|
|
2482
|
-
*
|
|
2483
|
-
*
|
|
2484
|
-
*
|
|
2485
|
-
* pick up.
|
|
2574
|
+
* watched set ({@link ContractWatcher.getWatchedContracts}) and the
|
|
2575
|
+
* global cursor is advanced on success. Passing an explicit subset
|
|
2576
|
+
* leaves the cursor alone so a narrow poll can't hide data that
|
|
2577
|
+
* other contracts still need to pick up.
|
|
2486
2578
|
*/
|
|
2487
2579
|
private syncContracts;
|
|
2488
2580
|
/**
|
|
@@ -2516,7 +2608,12 @@ declare class ContractManager implements IContractManager {
|
|
|
2516
2608
|
}
|
|
2517
2609
|
|
|
2518
2610
|
/**
|
|
2519
|
-
* Contract state
|
|
2611
|
+
* Contract lifecycle state. Both states stay monitored — the watcher
|
|
2612
|
+
* subscribes and sweeps every registered contract regardless
|
|
2613
|
+
* (see {@link ContractWatcher.getWatchedContracts}), because a retired
|
|
2614
|
+
* receive address can still be paid. `inactive` only demotes a contract
|
|
2615
|
+
* out of receive-address selection; it does **not** unsubscribe it.
|
|
2616
|
+
* Use {@link IContractManager.deleteContract} to stop watching.
|
|
2520
2617
|
*/
|
|
2521
2618
|
type ContractState = "active" | "inactive";
|
|
2522
2619
|
/**
|
|
@@ -2985,10 +3082,10 @@ declare class ContractWatcher {
|
|
|
2985
3082
|
/**
|
|
2986
3083
|
* Add a contract to be watched.
|
|
2987
3084
|
*
|
|
2988
|
-
*
|
|
3085
|
+
* Once watching, every contract is subscribed and polled whatever
|
|
3086
|
+
* its state.
|
|
2989
3087
|
*
|
|
2990
|
-
*
|
|
2991
|
-
* (which may cause them to be watched even if inactive).
|
|
3088
|
+
* @see getWatchedContracts
|
|
2992
3089
|
*/
|
|
2993
3090
|
addContract(contract: Contract): Promise<void>;
|
|
2994
3091
|
/**
|
|
@@ -3012,15 +3109,15 @@ declare class ContractWatcher {
|
|
|
3012
3109
|
*/
|
|
3013
3110
|
getAllContracts(): Contract[];
|
|
3014
3111
|
/**
|
|
3015
|
-
*
|
|
3016
|
-
* - all active contracts, plus
|
|
3017
|
-
* - inactive contracts that still hold known virtual outputs
|
|
3018
|
-
* (the subscription keeps watching them so `vtxo_spent` events for
|
|
3019
|
-
* those unspent outputs are still observed).
|
|
3112
|
+
* Every registered contract, retired (`inactive`) ones included.
|
|
3020
3113
|
*
|
|
3021
|
-
*
|
|
3022
|
-
*
|
|
3023
|
-
*
|
|
3114
|
+
* Feeds both the subscription and the indexer sweep scope, so
|
|
3115
|
+
* narrowing it drops a contract from every background channel at
|
|
3116
|
+
* once. Nothing may be narrowed out: an Ark receive address can be
|
|
3117
|
+
* paid again after the wallet has rotated past it, and a payment
|
|
3118
|
+
* that lands outside every background channel is invisible until
|
|
3119
|
+
* some foreground read happens to sweep it. Retirement therefore
|
|
3120
|
+
* governs receive-address selection, not coverage.
|
|
3024
3121
|
*/
|
|
3025
3122
|
getWatchedContracts(): Contract[];
|
|
3026
3123
|
/**
|
|
@@ -3029,7 +3126,7 @@ declare class ContractWatcher {
|
|
|
3029
3126
|
*/
|
|
3030
3127
|
private getContractVtxos;
|
|
3031
3128
|
/**
|
|
3032
|
-
* Start watching for virtual output events across all
|
|
3129
|
+
* Start watching for virtual output events across all watched contracts.
|
|
3033
3130
|
*/
|
|
3034
3131
|
startWatching(callback: ContractEventCallback): Promise<() => void>;
|
|
3035
3132
|
/**
|
|
@@ -3045,7 +3142,7 @@ declare class ContractWatcher {
|
|
|
3045
3142
|
*/
|
|
3046
3143
|
getConnectionState(): ConnectionState;
|
|
3047
3144
|
/**
|
|
3048
|
-
* Force a poll of all
|
|
3145
|
+
* Force a poll of all watched contracts.
|
|
3049
3146
|
* Useful for manual refresh or after app resume.
|
|
3050
3147
|
*/
|
|
3051
3148
|
forcePoll(): Promise<void>;
|
|
@@ -3091,7 +3188,7 @@ declare class ContractWatcher {
|
|
|
3091
3188
|
/**
|
|
3092
3189
|
* Update the subscription with scripts that should be watched.
|
|
3093
3190
|
*
|
|
3094
|
-
*
|
|
3191
|
+
* @see getWatchedContracts
|
|
3095
3192
|
*/
|
|
3096
3193
|
private updateSubscription;
|
|
3097
3194
|
/**
|
|
@@ -3617,6 +3714,20 @@ interface WalletConfig extends ReadonlyWalletConfig {
|
|
|
3617
3714
|
* @defaultValue `'auto'`
|
|
3618
3715
|
*/
|
|
3619
3716
|
walletMode?: WalletMode;
|
|
3717
|
+
/**
|
|
3718
|
+
* Per-side width of the HD look-ahead watch window: the wallet watches
|
|
3719
|
+
* missing offchain receive scripts across `[watermark - N, watermark + N]`
|
|
3720
|
+
* so funds paid to an address issued by an external party (a merchant
|
|
3721
|
+
* backend sharing the seed) arrive without an explicit `restore()`.
|
|
3722
|
+
*
|
|
3723
|
+
* Only meaningful for HD wallets (`walletMode: 'hd'` or an HD
|
|
3724
|
+
* {@link DescriptorProvider}); ignored otherwise. Raise it when the issuer
|
|
3725
|
+
* is expected to hand out more than `N` consecutive addresses without any
|
|
3726
|
+
* of them being paid. Must be a positive integer.
|
|
3727
|
+
*
|
|
3728
|
+
* @defaultValue `20`
|
|
3729
|
+
*/
|
|
3730
|
+
lookAheadWindow?: number;
|
|
3620
3731
|
}
|
|
3621
3732
|
/**
|
|
3622
3733
|
* Repository implementations used to store wallet and contract state.
|
|
@@ -5027,4 +5138,4 @@ declare namespace ProtoTypes {
|
|
|
5027
5138
|
export { };
|
|
5028
5139
|
}
|
|
5029
5140
|
|
|
5030
|
-
export { type
|
|
5141
|
+
export { type ReadonlyIdentity as $, type ArkTransaction as A, type VirtualTxRepository as B, type ContractRepository as C, type VirtualTx as D, type ExtendedCoin as E, type VtxoBranch as F, type GetVtxosFilter as G, ChainedTxType as H, type IWallet as I, type BatchStartedEvent as J, type TreeSigningStartedEvent as K, TxTree as L, type TreeNoncesEvent as M, type NormalizedExtendedVirtualCoin as N, type Outpoint as O, type BatchFinalizationEvent as P, type BatchFinalizedEvent as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type BatchFailedEvent as U, VtxoScript as V, type WalletRepository as W, type TreeTxEvent as X, type TreeSignatureEvent as Y, type DescriptorProvider as Z, type IReadonlyWallet as _, type Identity as a, CLTVMultisigTapscript as a$, type Network as a0, type OnchainProvider as a1, type DelegateProvider as a2, type ReadonlyWalletConfig as a3, type ExitCaptureMode as a4, type ExitDataSource as a5, type IReadonlyAssetManager as a6, type ContractSyncState as a7, type NetworkName as a8, type ArkInfo as a9, type ReissuanceParams as aA, type BurnParams as aB, type RenewVtxosOptions as aC, type ContractWithVtxos as aD, type PathSelection as aE, type ContractEvent as aF, type AssetDetails as aG, type IssuanceResult as aH, type DelegateInfo as aI, type MigrationGlobalSkipReason as aJ, type MigrationLegSkipReason as aK, type SignerStatus as aL, type StorageConfig as aM, type IVtxoManager as aN, type ExplorerTransaction as aO, type EncodedVtxoScript as aP, type Status as aQ, type ChainTx as aR, type PathContext as aS, type ActivityIntent as aT, type ActivityResolver as aU, type ArkIntentState as aV, type ArkTapscript as aW, type AssetMetadata as aX, type BaseWalletConfig as aY, type BatchInfo as aZ, type BatchSignableIdentity as a_, ArkAddress as aa, type Coin as ab, ContractManager as ac, type ContractManagerConfig as ad, CSVMultisigTapscript as ae, type SettlementConfig as af, VtxoManager as ag, type SignerSession as ah, type SignedIntent as ai, Intent as aj, type TimeHeight as ak, type DescriptorSigningRequest as al, Transaction as am, type IntentFeeConfig as an, type OffchainInput as ao, FeeAmount as ap, type OnchainInput as aq, type FeeOutput as ar, type ContractWatcherConfig as as, type Asset as at, type FeeInfo as au, type CreateContractParams as av, type GetContractsFilter as aw, type GetSpendablePathsOptions as ax, type GetAllSpendingPathsOptions as ay, type IssuanceParams as az, type WalletConfig as b, type VtxoChain as b$, ChainTxType as b0, type CommitmentTx as b1, ConditionCSVMultisigTapscript as b2, ConditionMultisigTapscript as b3, type ContractBalance as b4, type ContractEventCallback as b5, type ContractHandler as b6, type ContractState as b7, type ContractVtxo as b8, ContractWatcher as b9, type PageResponse as bA, type PaginationOptions as bB, PartialSig as bC, type ProviderClass as bD, RestDelegateProvider as bE, RestDelegatorProvider as bF, type ScanContractsOptions as bG, type ScanResult as bH, type ScheduledSession as bI, SettlementEventType as bJ, type SignRequest as bK, type SignerClassification as bL, type SignerSet as bM, type SubscriptionEvent as bN, type SubscriptionHeartbeat as bO, type TapLeaves as bP, TapTreeCoder as bQ, TapscriptType as bR, type TreeNonces as bS, type TreePartialSigs as bT, type Tx as bU, type TxHistoryRecord as bV, type TxKey as bW, type TxTreeNode as bX, TxType as bY, type VirtualStatus as bZ, type Vtxo as b_, DelegateManagerImpl as ba, type DelegateOptions as bb, DelegatorManagerImpl as bc, type DelegatorProvider as bd, type DeprecatedSignerMigrationReport as be, type DeprecatedSignerReport as bf, DigestMismatchError as bg, type Discoverable as bh, type DiscoveredContract as bi, type DiscoveryDeps as bj, ESPLORA_URL as bk, EsploraProvider as bl, type ExitChainResolver as bm, type ExtendedContractVtxo as bn, type GroupMembership as bo, type HandlerError as bp, type IDelegatorManager as bq, INTENT_TERMINAL_STATES as br, IndexerTxType as bs, type KnownMetadata as bt, type MigrateDeprecatedSignerOptions as bu, type MigrationLegReport as bv, type MigrationVtxoRef as bw, MultisigTapscript as bx, type Nonces as by, type Output as bz, type WalletBalance as c, type VtxoType as c0, type WalletMode as c1, boardingResolver as c2, canRecoverOnchain as c3, canSpendOffchain as c4, classifyAgainstSignerSet as c5, classifyContractSigner as c6, createDefaultActivityRegistry as c7, createExitChainResolver as c8, decodeTapscript as c9, getNetwork as ca, getSequence as cb, hasTerminalSpend as cc, isBatchSignable as cd, isCooperativelyMigratable as ce, isDiscoverable as cf, isExpired as cg, isPastExpiry as ch, isRecoverable as ci, isSpendable as cj, isSubdust as ck, isTerminalIntentState as cl, isVirtualCoin as cm, isVtxoExpiringSoon as cn, networks as co, signerSetFromInfo as cp, toXOnlySignerHex as cq, type TapscriptDeriving as cr, ActivityRegistry as d, type Activity as e, type IContractManager as f, type IDelegateManager as g, type SettleParams as h, type SettlementEvent as i, type IAssetManager as j, RestArkProvider as k, RestIndexerProvider as l, type SubscriptionResponse as m, type ArkProvider as n, type IndexerProvider as o, type RelativeTimelock as p, type TapLeafScript as q, type VirtualCoin as r, type Contract as s, type ExtendedVirtualCoin as t, type VtxoRepositoryKey as u, type WalletState as v, type ContractFilter as w, type IntentRepository as x, type ArkIntent as y, type IntentFilter as z };
|