@arkade-os/sdk 0.4.44 → 0.4.45
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 +35 -0
- 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-I8jfe5VE.d.cts → ark-C-PjOngm.d.cts} +89 -1
- package/dist/{ark-I8jfe5VE.d.ts → ark-C-PjOngm.d.ts} +89 -1
- package/dist/{asyncStorageTaskQueue-Dap7qUlF.d.cts → asyncStorageTaskQueue-BmBPvTyh.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-BtSOVZFn.d.ts → asyncStorageTaskQueue-CHpI3moJ.d.ts} +2 -2
- package/dist/{chunk-V7WIZR2B.js → chunk-BOA4SHCD.js} +3 -3
- package/dist/{chunk-V7WIZR2B.js.map → chunk-BOA4SHCD.js.map} +1 -1
- package/dist/{chunk-X37EKDIH.cjs → chunk-HZ7VIN7P.cjs} +11 -11
- package/dist/{chunk-X37EKDIH.cjs.map → chunk-HZ7VIN7P.cjs.map} +1 -1
- package/dist/{chunk-RJ6XVCX4.cjs → chunk-OFQGANH2.cjs} +7 -7
- package/dist/{chunk-RJ6XVCX4.cjs.map → chunk-OFQGANH2.cjs.map} +1 -1
- package/dist/{chunk-LCQQPOIT.js → chunk-QZ6HZZZK.js} +3 -3
- package/dist/{chunk-LCQQPOIT.js.map → chunk-QZ6HZZZK.js.map} +1 -1
- package/dist/{chunk-XIVCG6EP.cjs → chunk-SRCWBFSZ.cjs} +1000 -322
- package/dist/chunk-SRCWBFSZ.cjs.map +1 -0
- package/dist/{chunk-FMI2GKYO.js → chunk-TGRJ5WAX.js} +919 -243
- package/dist/chunk-TGRJ5WAX.js.map +1 -0
- package/dist/{chunk-UBYY2TPK.cjs → chunk-UHOHLN3C.cjs} +119 -69
- package/dist/chunk-UHOHLN3C.cjs.map +1 -0
- package/dist/{chunk-LJ35HPJW.js → chunk-YBQV7XBC.js} +119 -70
- package/dist/chunk-YBQV7XBC.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-CgjVjYOP.d.ts → delegate-BKNqva1j.d.ts} +1 -1
- package/dist/{delegate-BRqbh2fW.d.cts → delegate-DOEobYwH.d.cts} +1 -1
- package/dist/{index-DHuXlDEg.d.cts → index-BlW4I30l.d.cts} +2 -2
- package/dist/{index-DvWNB_rl.d.ts → index-Cm2fGeox.d.ts} +2 -2
- package/dist/index.cjs +141 -129
- package/dist/index.d.cts +45 -20
- package/dist/index.d.ts +45 -20
- 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-Bptw9UMa.d.ts → taskRunner-BngWSFMi.d.ts} +2 -2
- package/dist/{taskRunner-CeFxKhSH.d.cts → taskRunner-DOiyRuJa.d.cts} +2 -2
- 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 +21 -12
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +11 -4
- package/dist/wallet/expo/index.d.ts +11 -4
- package/dist/wallet/expo/index.js +12 -3
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-BsqRU8KM.d.cts → wallet-B3awP1Nj.d.ts} +105 -3
- package/dist/{wallet-D9z7wssl.d.ts → wallet-DBjumS42.d.cts} +105 -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-FMI2GKYO.js.map +0 -1
- package/dist/chunk-LJ35HPJW.js.map +0 -1
- package/dist/chunk-UBYY2TPK.cjs.map +0 -1
- package/dist/chunk-XIVCG6EP.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -862,6 +862,41 @@ Key properties:
|
|
|
862
862
|
- `validUntil` carries the earliest batch expiry: execute before it, or the operator may
|
|
863
863
|
sweep the expired batch first.
|
|
864
864
|
|
|
865
|
+
### Exit data available offline
|
|
866
|
+
|
|
867
|
+
The exit above resolves a VTXO's transaction chain from the Ark **indexer** at
|
|
868
|
+
exit time. To make a unilateral exit work even when the indexer is unreachable,
|
|
869
|
+
configure a `virtualTxRepository` (SQLite / Realm / IndexedDB / InMemory): the
|
|
870
|
+
wallet then captures each received VTXO's exit branch locally and prunes it on
|
|
871
|
+
spend, and `estimate` / `prepare` read that data **local-first**, falling back to
|
|
872
|
+
the indexer only on a miss.
|
|
873
|
+
|
|
874
|
+
```typescript
|
|
875
|
+
import { Wallet, InMemoryVirtualTxRepository } from '@arkade-os/sdk'
|
|
876
|
+
|
|
877
|
+
const wallet = await Wallet.create({
|
|
878
|
+
identity,
|
|
879
|
+
storage: {
|
|
880
|
+
walletRepository,
|
|
881
|
+
contractRepository,
|
|
882
|
+
virtualTxRepository: new InMemoryVirtualTxRepository(),
|
|
883
|
+
// Optional. `mode` defaults to "lite" (structure only, cheap — most VTXOs
|
|
884
|
+
// never exit). Use "full" to also store the pre-signed PSBTs, so an exit
|
|
885
|
+
// needs no Ark indexer (only an Esplora endpoint to broadcast).
|
|
886
|
+
exitDataCapture: { mode: 'full' },
|
|
887
|
+
},
|
|
888
|
+
})
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
- **Lite (default)** stores only the chain structure; an exit still fetches PSBTs
|
|
892
|
+
from the indexer. **Full** stores the PSBTs too, so the exit is fully
|
|
893
|
+
indexer-independent. `minExitWorthSats` (default 1000) skips dust VTXOs.
|
|
894
|
+
- Capture and prune are best-effort — a persistence failure never blocks sync or
|
|
895
|
+
the exit. Pruning is ref-counted, so tree ancestors shared by other VTXOs survive.
|
|
896
|
+
- **Provider tier:** pass extra sources via `exitDataCapture.sources` to resolve
|
|
897
|
+
exit data from your own service before the indexer — implement the
|
|
898
|
+
`ExitDataSource` interface (`getVtxoChain` / `getVirtualTxs`).
|
|
899
|
+
|
|
865
900
|
### Running the wallet in a service worker
|
|
866
901
|
|
|
867
902
|
The SDK provides a `MessageBus` orchestrator that runs inside a service worker
|
package/dist/adapters/expo.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkHZ7VIN7P_cjs = require('../chunk-HZ7VIN7P.cjs');
|
|
4
|
+
require('../chunk-UHOHLN3C.cjs');
|
|
5
5
|
require('../chunk-HXDZ2QTW.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 chunkHZ7VIN7P_cjs.ExpoArkProvider; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "ExpoIndexerProvider", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkHZ7VIN7P_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 { l as RestArkProvider, j as SettlementEvent, T as TxNotification, m as RestIndexerProvider, n as SubscriptionResponse } from '../ark-
|
|
2
|
-
export { o as ArkProvider, p as IndexerProvider } from '../ark-
|
|
1
|
+
import { l as RestArkProvider, j as SettlementEvent, T as TxNotification, m as RestIndexerProvider, n as SubscriptionResponse } from '../ark-C-PjOngm.cjs';
|
|
2
|
+
export { o as ArkProvider, p as IndexerProvider } from '../ark-C-PjOngm.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 { l as RestArkProvider, j as SettlementEvent, T as TxNotification, m as RestIndexerProvider, n as SubscriptionResponse } from '../ark-
|
|
2
|
-
export { o as ArkProvider, p as IndexerProvider } from '../ark-
|
|
1
|
+
import { l as RestArkProvider, j as SettlementEvent, T as TxNotification, m as RestIndexerProvider, n as SubscriptionResponse } from '../ark-C-PjOngm.js';
|
|
2
|
+
export { o as ArkProvider, p as IndexerProvider } from '../ark-C-PjOngm.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-BOA4SHCD.js';
|
|
2
|
+
import '../chunk-YBQV7XBC.js';
|
|
3
3
|
import '../chunk-BE5MUB7T.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 chunkSRCWBFSZ_cjs = require('../chunk-SRCWBFSZ.cjs');
|
|
4
|
+
require('../chunk-UHOHLN3C.cjs');
|
|
5
5
|
require('../chunk-32YKLQPS.cjs');
|
|
6
6
|
require('../chunk-HXDZ2QTW.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 = chunkSRCWBFSZ_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-TGRJ5WAX.js';
|
|
2
|
+
import '../chunk-YBQV7XBC.js';
|
|
3
3
|
import '../chunk-YNEDJTX2.js';
|
|
4
4
|
import '../chunk-BE5MUB7T.js';
|
|
5
5
|
import '../chunk-NSBPE2FW.js';
|
|
@@ -1836,6 +1836,21 @@ interface ScanContractsOptions {
|
|
|
1836
1836
|
/** Read-only context injected into every `discoverAt` call. */
|
|
1837
1837
|
deps: DiscoveryDeps;
|
|
1838
1838
|
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Freshness of the ContractManager's provider-backed sync. `degraded` means the
|
|
1841
|
+
* most recent sync (boot, best-effort read, or contract hydration) hit a
|
|
1842
|
+
* retryable indexer/operator failure and the manager is serving repository
|
|
1843
|
+
* state; it returns to `online` on the next successful sync. This only
|
|
1844
|
+
* describes sync freshness — never wallet data itself.
|
|
1845
|
+
*/
|
|
1846
|
+
type ContractSyncState = {
|
|
1847
|
+
mode: "online";
|
|
1848
|
+
lastSyncedAt?: number;
|
|
1849
|
+
} | {
|
|
1850
|
+
mode: "degraded";
|
|
1851
|
+
reason: string;
|
|
1852
|
+
lastSyncedAt?: number;
|
|
1853
|
+
};
|
|
1839
1854
|
interface IContractManager extends Disposable {
|
|
1840
1855
|
/**
|
|
1841
1856
|
* Create and register a new contract.
|
|
@@ -1863,6 +1878,11 @@ interface IContractManager extends Disposable {
|
|
|
1863
1878
|
* If no filter is provided, returns all contracts with their virtual outputs.
|
|
1864
1879
|
*/
|
|
1865
1880
|
getContractsWithVtxos(filter?: GetContractsFilter): Promise<ContractWithVtxos[]>;
|
|
1881
|
+
/**
|
|
1882
|
+
* Latest provider-sync health (online vs. degraded to repository data).
|
|
1883
|
+
* See {@link ContractSyncState}.
|
|
1884
|
+
*/
|
|
1885
|
+
getSyncState(): ContractSyncState;
|
|
1866
1886
|
/**
|
|
1867
1887
|
* Stamp raw virtual outputs with the correct per-contract tapscripts
|
|
1868
1888
|
* (forfeit, intent, tap tree).
|
|
@@ -2003,6 +2023,18 @@ interface ContractManagerConfig {
|
|
|
2003
2023
|
* {@link reconcileIntents}. Absent ⇒ no-op.
|
|
2004
2024
|
*/
|
|
2005
2025
|
intentRepository?: IntentRepository;
|
|
2026
|
+
/**
|
|
2027
|
+
* Optional exit-data capture hook. Fired best-effort after VTXOs are
|
|
2028
|
+
* persisted so a configured virtualTxRepository can store each one's
|
|
2029
|
+
* unilateral-exit branch. Absent ⇒ no-op.
|
|
2030
|
+
*/
|
|
2031
|
+
onVtxosPersisted?: (contract: Contract, vtxos: ExtendedVirtualCoin[]) => Promise<void>;
|
|
2032
|
+
/**
|
|
2033
|
+
* Optional exit-data prune hook. Fired best-effort with the spent outpoints
|
|
2034
|
+
* on `vtxo_spent` so a configured virtualTxRepository can drop their branch.
|
|
2035
|
+
* Absent ⇒ no-op.
|
|
2036
|
+
*/
|
|
2037
|
+
onVtxosSpent?: (vtxos: Outpoint[]) => Promise<void>;
|
|
2006
2038
|
/** Watcher configuration */
|
|
2007
2039
|
watcherConfig?: Partial<ContractWatcherConfig>;
|
|
2008
2040
|
}
|
|
@@ -2066,6 +2098,10 @@ declare class ContractManager implements IContractManager {
|
|
|
2066
2098
|
private initialized;
|
|
2067
2099
|
private eventCallbacks;
|
|
2068
2100
|
private stopWatcherFn?;
|
|
2101
|
+
/** `undefined` while online; the failure reason once a sync degrades. */
|
|
2102
|
+
private syncDegradedReason?;
|
|
2103
|
+
/** Epoch-ms of the last successful provider sync, if any. */
|
|
2104
|
+
private lastSyncedAt?;
|
|
2069
2105
|
private constructor();
|
|
2070
2106
|
/**
|
|
2071
2107
|
* Static factory method for creating a new ContractManager.
|
|
@@ -2077,6 +2113,15 @@ declare class ContractManager implements IContractManager {
|
|
|
2077
2113
|
* @param config ContractManagerConfig
|
|
2078
2114
|
*/
|
|
2079
2115
|
static create(config: ContractManagerConfig): Promise<ContractManager>;
|
|
2116
|
+
/**
|
|
2117
|
+
* Latest provider-sync health. See {@link ContractSyncState}. Degradation is
|
|
2118
|
+
* recorded by {@link initialize}, {@link getContractsWithVtxos}, and
|
|
2119
|
+
* {@link createContract}; it flips back to `online` on the next successful
|
|
2120
|
+
* sync. Purely a freshness signal — not a source of truth for wallet data.
|
|
2121
|
+
*/
|
|
2122
|
+
getSyncState(): ContractSyncState;
|
|
2123
|
+
private markSyncOnline;
|
|
2124
|
+
private markSyncDegraded;
|
|
2080
2125
|
private initialize;
|
|
2081
2126
|
/**
|
|
2082
2127
|
* Delta-sync the full watched set and reconcile the pending frontier.
|
|
@@ -3134,6 +3179,36 @@ declare function boardingResolver(): ActivityResolver;
|
|
|
3134
3179
|
/** Default registry with SDK built-ins. */
|
|
3135
3180
|
declare function createDefaultActivityRegistry(): ActivityRegistry;
|
|
3136
3181
|
|
|
3182
|
+
/**
|
|
3183
|
+
* A source of unilateral-exit chain data for a set of VTXOs. Sources are tried
|
|
3184
|
+
* in order by the resolver; a source returns `null` (chain) or omits keys (psbts)
|
|
3185
|
+
* for data it cannot supply — a "miss" — and the resolver falls through.
|
|
3186
|
+
*/
|
|
3187
|
+
interface ExitDataSource {
|
|
3188
|
+
readonly name: string;
|
|
3189
|
+
/** Full ancestry chain for a vtxo (all pages merged), or null on a miss. */
|
|
3190
|
+
getVtxoChain(vtxo: Outpoint): Promise<ChainTx[] | null>;
|
|
3191
|
+
/** Base64 PSBTs this source has, keyed by (unsigned) txid. Absent key = miss. */
|
|
3192
|
+
getVirtualTxs(txids: string[]): Promise<Map<string, string>>;
|
|
3193
|
+
}
|
|
3194
|
+
/** Reads exit chain data through an ordered chain of sources. */
|
|
3195
|
+
interface ExitChainResolver {
|
|
3196
|
+
getVtxoChain(vtxo: Outpoint): Promise<ChainTx[]>;
|
|
3197
|
+
getVirtualTxs(txids: string[]): Promise<string[]>;
|
|
3198
|
+
}
|
|
3199
|
+
/**
|
|
3200
|
+
* Assemble the standard exit-data resolver: local repo (if configured) → any
|
|
3201
|
+
* extra sources (e.g. a future provider) → indexer. Read-through persists to the
|
|
3202
|
+
* repository. With no repository this is exactly the indexer path (a no-op seam).
|
|
3203
|
+
*/
|
|
3204
|
+
declare function createExitChainResolver(params: {
|
|
3205
|
+
indexer: IndexerProvider;
|
|
3206
|
+
repository?: VirtualTxRepository;
|
|
3207
|
+
extraSources?: ExitDataSource[];
|
|
3208
|
+
}): ExitChainResolver;
|
|
3209
|
+
|
|
3210
|
+
type ExitCaptureMode = "lite" | "full";
|
|
3211
|
+
|
|
3137
3212
|
/**
|
|
3138
3213
|
* Wallet receive-address strategy.
|
|
3139
3214
|
*
|
|
@@ -3346,6 +3421,19 @@ type StorageConfig = {
|
|
|
3346
3421
|
* option as experimental until those paths land. Absent ⇒ no-op.
|
|
3347
3422
|
*/
|
|
3348
3423
|
virtualTxRepository?: VirtualTxRepository;
|
|
3424
|
+
/**
|
|
3425
|
+
* Optional exit-data capture settings (only in effect when
|
|
3426
|
+
* `virtualTxRepository` is set). `mode` "lite" (default) stores structure
|
|
3427
|
+
* only; "full" stores PSBTs so a unilateral exit needs no Ark indexer.
|
|
3428
|
+
* `minExitWorthSats` (default 1000) skips dust. `sources` are extra
|
|
3429
|
+
* `ExitDataSource`s (e.g. a wallet-provider) tried before the indexer for
|
|
3430
|
+
* both capture and exit reads.
|
|
3431
|
+
*/
|
|
3432
|
+
exitDataCapture?: {
|
|
3433
|
+
mode?: ExitCaptureMode;
|
|
3434
|
+
minExitWorthSats?: number;
|
|
3435
|
+
sources?: ExitDataSource[];
|
|
3436
|
+
};
|
|
3349
3437
|
};
|
|
3350
3438
|
/**
|
|
3351
3439
|
* Provider class constructor interface for dependency injection.
|
|
@@ -4694,4 +4782,4 @@ declare namespace ProtoTypes {
|
|
|
4694
4782
|
export { };
|
|
4695
4783
|
}
|
|
4696
4784
|
|
|
4697
|
-
export {
|
|
4785
|
+
export { type ArkInfo as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type TreeTxEvent as D, type ExtendedVirtualCoin as E, type TreeSignatureEvent as F, type GetVtxosFilter as G, type DescriptorProvider as H, type IWallet as I, type IReadonlyWallet as J, type ReadonlyIdentity as K, type DelegateProvider as L, type ReadonlyWalletConfig as M, type Network as N, type OnchainProvider as O, type IntentRepository as P, type VirtualTxRepository as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type ExitCaptureMode as U, VtxoScript as V, type WalletRepository as W, type ExitDataSource as X, type IReadonlyAssetManager as Y, type ContractSyncState as Z, type NetworkName as _, type Identity as a, ConditionCSVMultisigTapscript as a$, ArkAddress as a0, type Coin as a1, ContractManager as a2, CSVMultisigTapscript as a3, type SettlementConfig as a4, VtxoManager as a5, type SignerSession as a6, type SignedIntent as a7, Intent as a8, type VtxoRepositoryKey as a9, type PathSelection as aA, type ContractEvent as aB, type AssetDetails as aC, type IssuanceResult as aD, type DelegateInfo as aE, type MigrationGlobalSkipReason as aF, type MigrationLegSkipReason as aG, type SignerStatus as aH, type StorageConfig as aI, type IVtxoManager as aJ, type ExplorerTransaction as aK, type EncodedVtxoScript as aL, type Status as aM, type ChainTx as aN, type PathContext as aO, type ActivityIntent as aP, type ActivityResolver as aQ, type ArkIntentState as aR, type ArkTapscript as aS, type Asset as aT, type AssetMetadata as aU, type BaseWalletConfig as aV, type BatchInfo as aW, type BatchSignableIdentity as aX, CLTVMultisigTapscript as aY, ChainTxType as aZ, type CommitmentTx as a_, type WalletState as aa, type ContractFilter as ab, type ArkIntent as ac, type IntentFilter as ad, type Outpoint as ae, type VirtualTx as af, type VtxoBranch as ag, ChainedTxType as ah, type DescriptorSigningRequest as ai, Transaction as aj, type IntentFeeConfig as ak, type OffchainInput as al, FeeAmount as am, type OnchainInput as an, type FeeOutput as ao, type ContractWatcherConfig as ap, type FeeInfo as aq, type CreateContractParams as ar, type GetContractsFilter as as, type GetSpendablePathsOptions as at, type GetAllSpendingPathsOptions as au, type IssuanceParams as av, type ReissuanceParams as aw, type BurnParams as ax, type RenewVtxosOptions as ay, type ContractWithVtxos as az, type WalletConfig as b, type WalletMode as b$, ConditionMultisigTapscript as b0, type ContractBalance as b1, type ContractEventCallback as b2, type ContractHandler as b3, type ContractManagerConfig as b4, type ContractState as b5, type ContractVtxo as b6, ContractWatcher as b7, DelegateManagerImpl as b8, type DelegateOptions as b9, PartialSig as bA, type ProviderClass as bB, RestDelegateProvider as bC, RestDelegatorProvider as bD, type ScanContractsOptions as bE, type ScanResult as bF, type ScheduledSession as bG, SettlementEventType as bH, type SignRequest as bI, type SignerClassification as bJ, type SignerSet as bK, type SubscriptionEvent as bL, type SubscriptionHeartbeat as bM, type TapLeaves as bN, TapTreeCoder as bO, TapscriptType as bP, type TreeNonces as bQ, type TreePartialSigs as bR, type Tx as bS, type TxHistoryRecord as bT, type TxKey as bU, type TxTreeNode as bV, TxType as bW, type VirtualStatus as bX, type Vtxo as bY, type VtxoChain as bZ, type VtxoType as b_, DelegatorManagerImpl as ba, type DelegatorProvider as bb, type DeprecatedSignerMigrationReport as bc, type DeprecatedSignerReport as bd, DigestMismatchError as be, type Discoverable as bf, type DiscoveredContract as bg, type DiscoveryDeps as bh, ESPLORA_URL as bi, EsploraProvider as bj, type ExitChainResolver as bk, type ExtendedContractVtxo as bl, type GroupMembership as bm, type HandlerError as bn, type IDelegatorManager as bo, INTENT_TERMINAL_STATES as bp, IndexerTxType as bq, type KnownMetadata as br, type MigrateDeprecatedSignerOptions as bs, type MigrationLegReport as bt, type MigrationVtxoRef as bu, MultisigTapscript as bv, type Nonces as bw, type Output as bx, type PageResponse as by, type PaginationOptions as bz, type WalletBalance as c, boardingResolver as c0, classifyAgainstSignerSet as c1, classifyContractSigner as c2, createDefaultActivityRegistry as c3, createExitChainResolver as c4, decodeTapscript as c5, getNetwork as c6, getSequence as c7, isBatchSignable as c8, isCooperativelyMigratable as c9, isDiscoverable as ca, isExpired as cb, isRecoverable as cc, isSpendable as cd, isSubdust as ce, isTerminalIntentState as cf, isVtxoExpiringSoon as cg, networks as ch, signerSetFromInfo as ci, toXOnlySignerHex as cj, type ExtendedCoin as d, ActivityRegistry as e, type Activity as f, type IContractManager as g, type IDelegateManager as h, type SettleParams as i, type SettlementEvent as j, type IAssetManager as k, RestArkProvider as l, RestIndexerProvider as m, type SubscriptionResponse as n, type ArkProvider as o, type IndexerProvider as p, type RelativeTimelock as q, type TapLeafScript as r, type VirtualCoin as s, type Contract as t, type TreeSigningStartedEvent as u, TxTree as v, type TreeNoncesEvent as w, type BatchFinalizationEvent as x, type BatchFinalizedEvent as y, type BatchFailedEvent as z };
|
|
@@ -1836,6 +1836,21 @@ interface ScanContractsOptions {
|
|
|
1836
1836
|
/** Read-only context injected into every `discoverAt` call. */
|
|
1837
1837
|
deps: DiscoveryDeps;
|
|
1838
1838
|
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Freshness of the ContractManager's provider-backed sync. `degraded` means the
|
|
1841
|
+
* most recent sync (boot, best-effort read, or contract hydration) hit a
|
|
1842
|
+
* retryable indexer/operator failure and the manager is serving repository
|
|
1843
|
+
* state; it returns to `online` on the next successful sync. This only
|
|
1844
|
+
* describes sync freshness — never wallet data itself.
|
|
1845
|
+
*/
|
|
1846
|
+
type ContractSyncState = {
|
|
1847
|
+
mode: "online";
|
|
1848
|
+
lastSyncedAt?: number;
|
|
1849
|
+
} | {
|
|
1850
|
+
mode: "degraded";
|
|
1851
|
+
reason: string;
|
|
1852
|
+
lastSyncedAt?: number;
|
|
1853
|
+
};
|
|
1839
1854
|
interface IContractManager extends Disposable {
|
|
1840
1855
|
/**
|
|
1841
1856
|
* Create and register a new contract.
|
|
@@ -1863,6 +1878,11 @@ interface IContractManager extends Disposable {
|
|
|
1863
1878
|
* If no filter is provided, returns all contracts with their virtual outputs.
|
|
1864
1879
|
*/
|
|
1865
1880
|
getContractsWithVtxos(filter?: GetContractsFilter): Promise<ContractWithVtxos[]>;
|
|
1881
|
+
/**
|
|
1882
|
+
* Latest provider-sync health (online vs. degraded to repository data).
|
|
1883
|
+
* See {@link ContractSyncState}.
|
|
1884
|
+
*/
|
|
1885
|
+
getSyncState(): ContractSyncState;
|
|
1866
1886
|
/**
|
|
1867
1887
|
* Stamp raw virtual outputs with the correct per-contract tapscripts
|
|
1868
1888
|
* (forfeit, intent, tap tree).
|
|
@@ -2003,6 +2023,18 @@ interface ContractManagerConfig {
|
|
|
2003
2023
|
* {@link reconcileIntents}. Absent ⇒ no-op.
|
|
2004
2024
|
*/
|
|
2005
2025
|
intentRepository?: IntentRepository;
|
|
2026
|
+
/**
|
|
2027
|
+
* Optional exit-data capture hook. Fired best-effort after VTXOs are
|
|
2028
|
+
* persisted so a configured virtualTxRepository can store each one's
|
|
2029
|
+
* unilateral-exit branch. Absent ⇒ no-op.
|
|
2030
|
+
*/
|
|
2031
|
+
onVtxosPersisted?: (contract: Contract, vtxos: ExtendedVirtualCoin[]) => Promise<void>;
|
|
2032
|
+
/**
|
|
2033
|
+
* Optional exit-data prune hook. Fired best-effort with the spent outpoints
|
|
2034
|
+
* on `vtxo_spent` so a configured virtualTxRepository can drop their branch.
|
|
2035
|
+
* Absent ⇒ no-op.
|
|
2036
|
+
*/
|
|
2037
|
+
onVtxosSpent?: (vtxos: Outpoint[]) => Promise<void>;
|
|
2006
2038
|
/** Watcher configuration */
|
|
2007
2039
|
watcherConfig?: Partial<ContractWatcherConfig>;
|
|
2008
2040
|
}
|
|
@@ -2066,6 +2098,10 @@ declare class ContractManager implements IContractManager {
|
|
|
2066
2098
|
private initialized;
|
|
2067
2099
|
private eventCallbacks;
|
|
2068
2100
|
private stopWatcherFn?;
|
|
2101
|
+
/** `undefined` while online; the failure reason once a sync degrades. */
|
|
2102
|
+
private syncDegradedReason?;
|
|
2103
|
+
/** Epoch-ms of the last successful provider sync, if any. */
|
|
2104
|
+
private lastSyncedAt?;
|
|
2069
2105
|
private constructor();
|
|
2070
2106
|
/**
|
|
2071
2107
|
* Static factory method for creating a new ContractManager.
|
|
@@ -2077,6 +2113,15 @@ declare class ContractManager implements IContractManager {
|
|
|
2077
2113
|
* @param config ContractManagerConfig
|
|
2078
2114
|
*/
|
|
2079
2115
|
static create(config: ContractManagerConfig): Promise<ContractManager>;
|
|
2116
|
+
/**
|
|
2117
|
+
* Latest provider-sync health. See {@link ContractSyncState}. Degradation is
|
|
2118
|
+
* recorded by {@link initialize}, {@link getContractsWithVtxos}, and
|
|
2119
|
+
* {@link createContract}; it flips back to `online` on the next successful
|
|
2120
|
+
* sync. Purely a freshness signal — not a source of truth for wallet data.
|
|
2121
|
+
*/
|
|
2122
|
+
getSyncState(): ContractSyncState;
|
|
2123
|
+
private markSyncOnline;
|
|
2124
|
+
private markSyncDegraded;
|
|
2080
2125
|
private initialize;
|
|
2081
2126
|
/**
|
|
2082
2127
|
* Delta-sync the full watched set and reconcile the pending frontier.
|
|
@@ -3134,6 +3179,36 @@ declare function boardingResolver(): ActivityResolver;
|
|
|
3134
3179
|
/** Default registry with SDK built-ins. */
|
|
3135
3180
|
declare function createDefaultActivityRegistry(): ActivityRegistry;
|
|
3136
3181
|
|
|
3182
|
+
/**
|
|
3183
|
+
* A source of unilateral-exit chain data for a set of VTXOs. Sources are tried
|
|
3184
|
+
* in order by the resolver; a source returns `null` (chain) or omits keys (psbts)
|
|
3185
|
+
* for data it cannot supply — a "miss" — and the resolver falls through.
|
|
3186
|
+
*/
|
|
3187
|
+
interface ExitDataSource {
|
|
3188
|
+
readonly name: string;
|
|
3189
|
+
/** Full ancestry chain for a vtxo (all pages merged), or null on a miss. */
|
|
3190
|
+
getVtxoChain(vtxo: Outpoint): Promise<ChainTx[] | null>;
|
|
3191
|
+
/** Base64 PSBTs this source has, keyed by (unsigned) txid. Absent key = miss. */
|
|
3192
|
+
getVirtualTxs(txids: string[]): Promise<Map<string, string>>;
|
|
3193
|
+
}
|
|
3194
|
+
/** Reads exit chain data through an ordered chain of sources. */
|
|
3195
|
+
interface ExitChainResolver {
|
|
3196
|
+
getVtxoChain(vtxo: Outpoint): Promise<ChainTx[]>;
|
|
3197
|
+
getVirtualTxs(txids: string[]): Promise<string[]>;
|
|
3198
|
+
}
|
|
3199
|
+
/**
|
|
3200
|
+
* Assemble the standard exit-data resolver: local repo (if configured) → any
|
|
3201
|
+
* extra sources (e.g. a future provider) → indexer. Read-through persists to the
|
|
3202
|
+
* repository. With no repository this is exactly the indexer path (a no-op seam).
|
|
3203
|
+
*/
|
|
3204
|
+
declare function createExitChainResolver(params: {
|
|
3205
|
+
indexer: IndexerProvider;
|
|
3206
|
+
repository?: VirtualTxRepository;
|
|
3207
|
+
extraSources?: ExitDataSource[];
|
|
3208
|
+
}): ExitChainResolver;
|
|
3209
|
+
|
|
3210
|
+
type ExitCaptureMode = "lite" | "full";
|
|
3211
|
+
|
|
3137
3212
|
/**
|
|
3138
3213
|
* Wallet receive-address strategy.
|
|
3139
3214
|
*
|
|
@@ -3346,6 +3421,19 @@ type StorageConfig = {
|
|
|
3346
3421
|
* option as experimental until those paths land. Absent ⇒ no-op.
|
|
3347
3422
|
*/
|
|
3348
3423
|
virtualTxRepository?: VirtualTxRepository;
|
|
3424
|
+
/**
|
|
3425
|
+
* Optional exit-data capture settings (only in effect when
|
|
3426
|
+
* `virtualTxRepository` is set). `mode` "lite" (default) stores structure
|
|
3427
|
+
* only; "full" stores PSBTs so a unilateral exit needs no Ark indexer.
|
|
3428
|
+
* `minExitWorthSats` (default 1000) skips dust. `sources` are extra
|
|
3429
|
+
* `ExitDataSource`s (e.g. a wallet-provider) tried before the indexer for
|
|
3430
|
+
* both capture and exit reads.
|
|
3431
|
+
*/
|
|
3432
|
+
exitDataCapture?: {
|
|
3433
|
+
mode?: ExitCaptureMode;
|
|
3434
|
+
minExitWorthSats?: number;
|
|
3435
|
+
sources?: ExitDataSource[];
|
|
3436
|
+
};
|
|
3349
3437
|
};
|
|
3350
3438
|
/**
|
|
3351
3439
|
* Provider class constructor interface for dependency injection.
|
|
@@ -4694,4 +4782,4 @@ declare namespace ProtoTypes {
|
|
|
4694
4782
|
export { };
|
|
4695
4783
|
}
|
|
4696
4784
|
|
|
4697
|
-
export {
|
|
4785
|
+
export { type ArkInfo as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type TreeTxEvent as D, type ExtendedVirtualCoin as E, type TreeSignatureEvent as F, type GetVtxosFilter as G, type DescriptorProvider as H, type IWallet as I, type IReadonlyWallet as J, type ReadonlyIdentity as K, type DelegateProvider as L, type ReadonlyWalletConfig as M, type Network as N, type OnchainProvider as O, type IntentRepository as P, type VirtualTxRepository as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type ExitCaptureMode as U, VtxoScript as V, type WalletRepository as W, type ExitDataSource as X, type IReadonlyAssetManager as Y, type ContractSyncState as Z, type NetworkName as _, type Identity as a, ConditionCSVMultisigTapscript as a$, ArkAddress as a0, type Coin as a1, ContractManager as a2, CSVMultisigTapscript as a3, type SettlementConfig as a4, VtxoManager as a5, type SignerSession as a6, type SignedIntent as a7, Intent as a8, type VtxoRepositoryKey as a9, type PathSelection as aA, type ContractEvent as aB, type AssetDetails as aC, type IssuanceResult as aD, type DelegateInfo as aE, type MigrationGlobalSkipReason as aF, type MigrationLegSkipReason as aG, type SignerStatus as aH, type StorageConfig as aI, type IVtxoManager as aJ, type ExplorerTransaction as aK, type EncodedVtxoScript as aL, type Status as aM, type ChainTx as aN, type PathContext as aO, type ActivityIntent as aP, type ActivityResolver as aQ, type ArkIntentState as aR, type ArkTapscript as aS, type Asset as aT, type AssetMetadata as aU, type BaseWalletConfig as aV, type BatchInfo as aW, type BatchSignableIdentity as aX, CLTVMultisigTapscript as aY, ChainTxType as aZ, type CommitmentTx as a_, type WalletState as aa, type ContractFilter as ab, type ArkIntent as ac, type IntentFilter as ad, type Outpoint as ae, type VirtualTx as af, type VtxoBranch as ag, ChainedTxType as ah, type DescriptorSigningRequest as ai, Transaction as aj, type IntentFeeConfig as ak, type OffchainInput as al, FeeAmount as am, type OnchainInput as an, type FeeOutput as ao, type ContractWatcherConfig as ap, type FeeInfo as aq, type CreateContractParams as ar, type GetContractsFilter as as, type GetSpendablePathsOptions as at, type GetAllSpendingPathsOptions as au, type IssuanceParams as av, type ReissuanceParams as aw, type BurnParams as ax, type RenewVtxosOptions as ay, type ContractWithVtxos as az, type WalletConfig as b, type WalletMode as b$, ConditionMultisigTapscript as b0, type ContractBalance as b1, type ContractEventCallback as b2, type ContractHandler as b3, type ContractManagerConfig as b4, type ContractState as b5, type ContractVtxo as b6, ContractWatcher as b7, DelegateManagerImpl as b8, type DelegateOptions as b9, PartialSig as bA, type ProviderClass as bB, RestDelegateProvider as bC, RestDelegatorProvider as bD, type ScanContractsOptions as bE, type ScanResult as bF, type ScheduledSession as bG, SettlementEventType as bH, type SignRequest as bI, type SignerClassification as bJ, type SignerSet as bK, type SubscriptionEvent as bL, type SubscriptionHeartbeat as bM, type TapLeaves as bN, TapTreeCoder as bO, TapscriptType as bP, type TreeNonces as bQ, type TreePartialSigs as bR, type Tx as bS, type TxHistoryRecord as bT, type TxKey as bU, type TxTreeNode as bV, TxType as bW, type VirtualStatus as bX, type Vtxo as bY, type VtxoChain as bZ, type VtxoType as b_, DelegatorManagerImpl as ba, type DelegatorProvider as bb, type DeprecatedSignerMigrationReport as bc, type DeprecatedSignerReport as bd, DigestMismatchError as be, type Discoverable as bf, type DiscoveredContract as bg, type DiscoveryDeps as bh, ESPLORA_URL as bi, EsploraProvider as bj, type ExitChainResolver as bk, type ExtendedContractVtxo as bl, type GroupMembership as bm, type HandlerError as bn, type IDelegatorManager as bo, INTENT_TERMINAL_STATES as bp, IndexerTxType as bq, type KnownMetadata as br, type MigrateDeprecatedSignerOptions as bs, type MigrationLegReport as bt, type MigrationVtxoRef as bu, MultisigTapscript as bv, type Nonces as bw, type Output as bx, type PageResponse as by, type PaginationOptions as bz, type WalletBalance as c, boardingResolver as c0, classifyAgainstSignerSet as c1, classifyContractSigner as c2, createDefaultActivityRegistry as c3, createExitChainResolver as c4, decodeTapscript as c5, getNetwork as c6, getSequence as c7, isBatchSignable as c8, isCooperativelyMigratable as c9, isDiscoverable as ca, isExpired as cb, isRecoverable as cc, isSpendable as cd, isSubdust as ce, isTerminalIntentState as cf, isVtxoExpiringSoon as cg, networks as ch, signerSetFromInfo as ci, toXOnlySignerHex as cj, type ExtendedCoin as d, ActivityRegistry as e, type Activity as f, type IContractManager as g, type IDelegateManager as h, type SettleParams as i, type SettlementEvent as j, type IAssetManager as k, RestArkProvider as l, RestIndexerProvider as m, type SubscriptionResponse as n, type ArkProvider as o, type IndexerProvider as p, type RelativeTimelock as q, type TapLeafScript as r, type VirtualCoin as s, type Contract as t, type TreeSigningStartedEvent as u, TxTree as v, type TreeNoncesEvent as w, type BatchFinalizationEvent as x, type BatchFinalizedEvent as y, type BatchFailedEvent as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-DOiyRuJa.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Minimal async key-value storage interface.
|
|
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
|
|
|
46
46
|
private writeList;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-BngWSFMi.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Minimal async key-value storage interface.
|
|
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
|
|
|
46
46
|
private writeList;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RestArkProvider, isFetchTimeoutError, RestIndexerProvider, buildVersion, sdkVersion, fetch } from './chunk-
|
|
1
|
+
import { RestArkProvider, isFetchTimeoutError, RestIndexerProvider, buildVersion, sdkVersion, fetch } from './chunk-YBQV7XBC.js';
|
|
2
2
|
import { DEFAULT_ARKADE_SERVER_URL } from './chunk-BE5MUB7T.js';
|
|
3
3
|
|
|
4
4
|
// src/providers/expoUtils.ts
|
|
@@ -212,5 +212,5 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
|
|
|
212
212
|
};
|
|
213
213
|
|
|
214
214
|
export { ExpoArkProvider, ExpoIndexerProvider };
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
216
|
-
//# sourceMappingURL=chunk-
|
|
215
|
+
//# sourceMappingURL=chunk-BOA4SHCD.js.map
|
|
216
|
+
//# sourceMappingURL=chunk-BOA4SHCD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAMA,eAAsB,aAAa,OAAA,EAA4D;AAG3F,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OA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AAA,SACJ;AAAA,MACJ,SAAS,KAAA,EAAO;AACZ,QAAA,IAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,YAAA,EAAc;AACvD,UAAA;AAAA,QACJ;AAIA,QAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAC5B,UAAA,OAAA,CAAQ,MAAM,uBAAuB,CAAA;AACrC,UAAA;AAAA,QACJ;AAEA,QAAA,OAAA,CAAQ,KAAA,CAAM,uBAAuB,KAAK,CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-V7WIZR2B.js","sourcesContent":["import { fetch, buildVersion, sdkVersion } from \"../utils/fetch\";\n\n/**\n * Dynamically imports expo/fetch with fallback to standard fetch.\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n const expoFetchWithHeader = (input: RequestInfo, init?: RequestInit) => {\n const headers = new Headers(init?.headers);\n headers.set(\"X-Build-Version\", buildVersion);\n headers.set(\"X-SDK-VERSION\", sdkVersion);\n return expoFetchModule.fetch(input, { ...init, headers });\n };\n return expoFetchWithHeader as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return fetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Unexpected status ${response.status} when fetching SSE stream`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!abortSignal?.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n\n for (let i = 0; i < lines.length - 1; i++) {\n const line = lines[i].trim();\n if (!line) continue;\n\n if (line.startsWith(\"data:\")) {\n const jsonStr = line.substring(5).trim();\n if (!jsonStr) continue;\n\n try {\n const data = JSON.parse(jsonStr);\n const parsed = parseData(data);\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n }\n\n buffer = lines[lines.length - 1];\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { RestArkProvider, SettlementEvent, TxNotification, isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\n\n/**\n * Expo-compatible Arkade provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';\n *\n * const provider = new ExpoArkProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoArkProvider extends RestArkProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url + queryParams, signal, expoFetch, {}, (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{\n commitmentTx?: TxNotification;\n arkTx?: TxNotification;\n }> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, {}, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n","import { RestIndexerProvider, SubscriptionResponse, Vtxo } from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { VirtualCoin } from \"../wallet\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\n\n// Helper function to convert Vtxo to VirtualCoin (same as in indexer.ts)\nfunction convertVtxo(vtxo: Vtxo): VirtualCoin {\n return {\n txid: vtxo.outpoint.txid,\n vout: vtxo.outpoint.vout,\n value: Number(vtxo.amount),\n status: {\n confirmed: !vtxo.isSwept && !vtxo.isPreconfirmed,\n isLeaf: !vtxo.isPreconfirmed,\n },\n virtualStatus: {\n state: vtxo.isSwept ? \"swept\" : vtxo.isPreconfirmed ? \"preconfirmed\" : \"settled\",\n commitmentTxIds: vtxo.commitmentTxids,\n batchExpiry: vtxo.expiresAt ? Number(vtxo.expiresAt) * 1000 : undefined,\n },\n spentBy: vtxo.spentBy ?? \"\",\n settledBy: vtxo.settledBy,\n arkTxId: vtxo.arkTxid,\n createdAt: new Date(Number(vtxo.createdAt) * 1000),\n isUnrolled: vtxo.isUnrolled,\n isSpent: vtxo.isSpent,\n script: vtxo.script,\n assets: vtxo.assets?.map((a) => ({\n assetId: a.assetId,\n amount: BigInt(a.amount),\n })),\n };\n}\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getSubscription(\n subscriptionId: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionResponse> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch().catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n const url = `${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`;\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\" },\n (data): SubscriptionResponse | null => {\n // Handle new v8 proto format with heartbeat or event\n if (data.heartbeat !== undefined) {\n // Skip heartbeat messages\n return null;\n }\n // Process event messages\n if (data.event) {\n return {\n txid: data.event.txid,\n scripts: data.event.scripts || [],\n newVtxos: (data.event.newVtxos || []).map(convertVtxo),\n spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),\n sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),\n tx: data.event.tx,\n checkpointTxs: data.event.checkpointTxs,\n };\n }\n return null;\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAMA,eAAsB,aAAa,OAAA,EAA4D;AAG3F,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAAY,CAAA;AACjD,IAAA,OAAA,CAAQ,MAAM,gCAAgC,CAAA;AAC9C,IAAA,MAAM,mBAAA,GAAsB,CAAC,KAAA,EAAoB,IAAA,KAAuB;AACpE,MAAA,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ACJ;AAIA,QAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAC5B,UAAA,OAAA,CAAQ,MAAM,uBAAuB,CAAA;AACrC,UAAA;AAAA,QACJ;AAEA,QAAA,OAAA,CAAQ,KAAA,CAAM,uBAAuB,KAAK,CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-BOA4SHCD.js","sourcesContent":["import { fetch, buildVersion, sdkVersion } from \"../utils/fetch\";\n\n/**\n * Dynamically imports expo/fetch with fallback to standard fetch.\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n const expoFetchWithHeader = (input: RequestInfo, init?: RequestInit) => {\n const headers = new Headers(init?.headers);\n headers.set(\"X-Build-Version\", buildVersion);\n headers.set(\"X-SDK-VERSION\", sdkVersion);\n return expoFetchModule.fetch(input, { ...init, headers });\n };\n return expoFetchWithHeader as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return fetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Unexpected status ${response.status} when fetching SSE stream`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!abortSignal?.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n\n for (let i = 0; i < lines.length - 1; i++) {\n const line = lines[i].trim();\n if (!line) continue;\n\n if (line.startsWith(\"data:\")) {\n const jsonStr = line.substring(5).trim();\n if (!jsonStr) continue;\n\n try {\n const data = JSON.parse(jsonStr);\n const parsed = parseData(data);\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n }\n\n buffer = lines[lines.length - 1];\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { RestArkProvider, SettlementEvent, TxNotification, isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\n\n/**\n * Expo-compatible Arkade provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';\n *\n * const provider = new ExpoArkProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoArkProvider extends RestArkProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url + queryParams, signal, expoFetch, {}, (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{\n commitmentTx?: TxNotification;\n arkTx?: TxNotification;\n }> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, {}, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n","import { RestIndexerProvider, SubscriptionResponse, Vtxo } from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { VirtualCoin } from \"../wallet\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\n\n// Helper function to convert Vtxo to VirtualCoin (same as in indexer.ts)\nfunction convertVtxo(vtxo: Vtxo): VirtualCoin {\n return {\n txid: vtxo.outpoint.txid,\n vout: vtxo.outpoint.vout,\n value: Number(vtxo.amount),\n status: {\n confirmed: !vtxo.isSwept && !vtxo.isPreconfirmed,\n isLeaf: !vtxo.isPreconfirmed,\n },\n virtualStatus: {\n state: vtxo.isSwept ? \"swept\" : vtxo.isPreconfirmed ? \"preconfirmed\" : \"settled\",\n commitmentTxIds: vtxo.commitmentTxids,\n batchExpiry: vtxo.expiresAt ? Number(vtxo.expiresAt) * 1000 : undefined,\n },\n spentBy: vtxo.spentBy ?? \"\",\n settledBy: vtxo.settledBy,\n arkTxId: vtxo.arkTxid,\n createdAt: new Date(Number(vtxo.createdAt) * 1000),\n isUnrolled: vtxo.isUnrolled,\n isSpent: vtxo.isSpent,\n script: vtxo.script,\n assets: vtxo.assets?.map((a) => ({\n assetId: a.assetId,\n amount: BigInt(a.amount),\n })),\n };\n}\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getSubscription(\n subscriptionId: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionResponse> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch().catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n const url = `${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`;\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\" },\n (data): SubscriptionResponse | null => {\n // Handle new v8 proto format with heartbeat or event\n if (data.heartbeat !== undefined) {\n // Skip heartbeat messages\n return null;\n }\n // Process event messages\n if (data.event) {\n return {\n txid: data.event.txid,\n scripts: data.event.scripts || [],\n newVtxos: (data.event.newVtxos || []).map(convertVtxo),\n spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),\n sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),\n tx: data.event.tx,\n checkpointTxs: data.event.checkpointTxs,\n };\n }\n return null;\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}
|