@arkade-os/sdk 0.4.48-rc.0 → 0.4.48
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/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-CoJgwTi_.d.cts → ark-CjE0KkGp.d.cts} +405 -250
- package/dist/{ark-CoJgwTi_.d.ts → ark-CjE0KkGp.d.ts} +405 -250
- package/dist/{asyncStorageTaskQueue-CwknfM_j.d.cts → asyncStorageTaskQueue-CeLZhZFU.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-D2Zl7yAB.d.ts → asyncStorageTaskQueue-D9SOPMPC.d.ts} +1 -1
- package/dist/{chunk-XN3554FT.js → chunk-4VVTRPH3.js} +4 -4
- package/dist/chunk-4VVTRPH3.js.map +1 -0
- package/dist/{chunk-RQSA7ADZ.cjs → chunk-5XMVTK5S.cjs} +37 -37
- package/dist/chunk-5XMVTK5S.cjs.map +1 -0
- package/dist/{chunk-L5ND2FJJ.cjs → chunk-7TXSPRN5.cjs} +161 -2
- package/dist/chunk-7TXSPRN5.cjs.map +1 -0
- package/dist/{chunk-GM6JRQP5.js → chunk-BHHLRZCS.js} +169 -42
- package/dist/chunk-BHHLRZCS.js.map +1 -0
- package/dist/{chunk-CFQO5MCM.cjs → chunk-EB3ALGTM.cjs} +178 -50
- package/dist/chunk-EB3ALGTM.cjs.map +1 -0
- package/dist/{chunk-3HUZAIKI.cjs → chunk-ENDNQPZA.cjs} +17 -44
- package/dist/chunk-ENDNQPZA.cjs.map +1 -0
- package/dist/{chunk-RJMFTTRJ.cjs → chunk-ENZ4YPR2.cjs} +614 -592
- package/dist/chunk-ENZ4YPR2.cjs.map +1 -0
- package/dist/{chunk-4AIHKC65.js → chunk-G6J6AEMH.js} +5 -4
- package/dist/chunk-G6J6AEMH.js.map +1 -0
- package/dist/{chunk-SV4PCGKM.js → chunk-NYR5H6GR.js} +348 -323
- package/dist/chunk-NYR5H6GR.js.map +1 -0
- package/dist/{chunk-EA3IWZ4W.cjs → chunk-SYDANBJI.cjs} +9 -8
- package/dist/chunk-SYDANBJI.cjs.map +1 -0
- package/dist/{chunk-ZRY2KSK5.js → chunk-XFMGIFBL.js} +4 -31
- package/dist/chunk-XFMGIFBL.js.map +1 -0
- package/dist/{chunk-C7TXXTMS.js → chunk-ZDDBTFVO.js} +146 -3
- package/dist/chunk-ZDDBTFVO.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +8 -8
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-Dl87_zMA.d.cts → delegate-D3dY-2vS.d.cts} +1 -1
- package/dist/{delegate-CuaDqqQi.d.ts → delegate-DhGZk1r2.d.ts} +1 -1
- package/dist/{index-BC_G0VTh.d.cts → index-D6RQROds.d.cts} +2 -2
- package/dist/{index-CKwpZEpw.d.ts → index-DK4_iWYy.d.ts} +2 -2
- package/dist/index.cjs +208 -188
- package/dist/index.d.cts +35 -18
- package/dist/index.d.ts +35 -18
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-Df8YQpn1.d.ts → taskRunner-B-2MHCYG.d.ts} +1 -1
- package/dist/{taskRunner-RYihSj9E.d.cts → taskRunner-Brnak0Rc.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-B6s7_5bJ.d.cts → wallet-B5bwixQa.d.ts} +31 -31
- package/dist/{wallet-C61huH8i.d.ts → wallet-DiOrtYic.d.cts} +31 -31
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +3 -2
- package/dist/chunk-3HUZAIKI.cjs.map +0 -1
- package/dist/chunk-4AIHKC65.js.map +0 -1
- package/dist/chunk-C7TXXTMS.js.map +0 -1
- package/dist/chunk-CFQO5MCM.cjs.map +0 -1
- package/dist/chunk-EA3IWZ4W.cjs.map +0 -1
- package/dist/chunk-GM6JRQP5.js.map +0 -1
- package/dist/chunk-L5ND2FJJ.cjs.map +0 -1
- package/dist/chunk-RJMFTTRJ.cjs.map +0 -1
- package/dist/chunk-RQSA7ADZ.cjs.map +0 -1
- package/dist/chunk-SV4PCGKM.js.map +0 -1
- package/dist/chunk-XN3554FT.js.map +0 -1
- package/dist/chunk-ZRY2KSK5.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Transaction } from '@scure/btc-signer';
|
|
2
2
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
3
|
-
import { J as BatchStartedEvent, K as TreeSigningStartedEvent, L as TxTree, M as TreeNoncesEvent,
|
|
3
|
+
import { J as BatchStartedEvent, K as TreeSigningStartedEvent, L as TxTree, M as TreeNoncesEvent, P as BatchFinalizationEvent, Q as BatchFinalizedEvent, U as BatchFailedEvent, X as TreeTxEvent, Y as TreeSignatureEvent, i as SettlementEvent, b as WalletConfig, W as WalletRepository, C as ContractRepository, Z as DescriptorProvider, f as IContractManager, _ as IReadonlyWallet, $ as ReadonlyIdentity, a0 as Network, a1 as OnchainProvider, o as IndexerProvider, a2 as DelegateProvider, a3 as ReadonlyWalletConfig, x as IntentRepository, B as VirtualTxRepository, a4 as ExitCaptureMode, a5 as ExitDataSource, p as RelativeTimelock, d as ActivityRegistry, a6 as IReadonlyAssetManager, a7 as ContractSyncState, n as ArkProvider, a8 as NetworkName, a9 as ArkInfo, aa as ArkAddress, c as WalletBalance, G as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, A as ArkTransaction, e as Activity, E as ExtendedCoin, ab as Coin, t as ExtendedVirtualCoin, ac as ContractManager, I as IWallet, a as Identity, ad as CSVMultisigTapscript, ae as SettlementConfig, j as IAssetManager, af as VtxoManager, g as IDelegateManager, S as SendBitcoinParams, h as SettleParams, R as Recipient, ag as SignerSession, ah as SignedIntent, ai as Intent, aj as TimeHeight } from './ark-CjE0KkGp.js';
|
|
4
4
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
5
|
-
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-
|
|
5
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-DhGZk1r2.js';
|
|
6
6
|
|
|
7
7
|
declare class ArkError extends Error {
|
|
8
8
|
readonly code: number;
|
|
@@ -487,7 +487,7 @@ interface BoardingUtxoGroup {
|
|
|
487
487
|
coins: ExtendedCoin[];
|
|
488
488
|
}
|
|
489
489
|
/**
|
|
490
|
-
* Why a VTXO at an
|
|
490
|
+
* Why a VTXO at an arkadeCash address could not be swept by {@link Wallet.claimCash}.
|
|
491
491
|
*
|
|
492
492
|
* - `swept` — the server swept the batch at expiry. Recoverable in principle,
|
|
493
493
|
* but only through a settlement, which the thin sweep cannot do.
|
|
@@ -497,14 +497,14 @@ interface BoardingUtxoGroup {
|
|
|
497
497
|
* - `has-assets` — asset-bearing; the BTC-only sweep would burn the assets.
|
|
498
498
|
* - `sweep-failed` — spendable, but its own sweep was rejected.
|
|
499
499
|
*/
|
|
500
|
-
type
|
|
500
|
+
type ArkadeCashUnclaimedReason = "swept" | "subdust" | "already-spent" | "has-assets" | "sweep-failed";
|
|
501
501
|
/** A VTXO {@link Wallet.claimCash} left behind, with the reason why. */
|
|
502
|
-
interface
|
|
502
|
+
interface ArkadeCashUnclaimedVtxo {
|
|
503
503
|
txid: string;
|
|
504
504
|
vout: number;
|
|
505
505
|
/** Value in satoshis. */
|
|
506
506
|
value: number;
|
|
507
|
-
reason:
|
|
507
|
+
reason: ArkadeCashUnclaimedReason;
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* Outcome of {@link Wallet.claimCash}: what was swept, and what was not.
|
|
@@ -512,13 +512,13 @@ interface ArkCashUnclaimedVtxo {
|
|
|
512
512
|
* The shape is open — further buckets may be added alongside `unclaimed` as
|
|
513
513
|
* more of the non-sweepable states become claimable.
|
|
514
514
|
*/
|
|
515
|
-
interface
|
|
515
|
+
interface ArkadeCashClaimResult {
|
|
516
516
|
/** Satoshis swept to this wallet. */
|
|
517
517
|
swept: number;
|
|
518
518
|
unclaimed: {
|
|
519
519
|
/** Satoshis left behind. */
|
|
520
520
|
amount: number;
|
|
521
|
-
vtxos:
|
|
521
|
+
vtxos: ArkadeCashUnclaimedVtxo[];
|
|
522
522
|
};
|
|
523
523
|
}
|
|
524
524
|
/**
|
|
@@ -531,13 +531,13 @@ interface ArkCashClaimResult {
|
|
|
531
531
|
* cannot rule out a post-submit failure must persist `cash` — passing it to
|
|
532
532
|
* {@link Wallet.claimCash} recovers the funds whether or not the send landed.
|
|
533
533
|
*/
|
|
534
|
-
declare class
|
|
535
|
-
/** The encoded
|
|
534
|
+
declare class ArkadeCashCreateError extends Error {
|
|
535
|
+
/** The encoded arkadeCash token controlling the funded output. */
|
|
536
536
|
readonly cash: string;
|
|
537
537
|
/** The original failure from `send`. */
|
|
538
538
|
readonly cause: unknown;
|
|
539
539
|
constructor(
|
|
540
|
-
/** The encoded
|
|
540
|
+
/** The encoded arkadeCash token controlling the funded output. */
|
|
541
541
|
cash: string,
|
|
542
542
|
/** The original failure from `send`. */
|
|
543
543
|
cause: unknown);
|
|
@@ -793,7 +793,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
793
793
|
*
|
|
794
794
|
* @param filter - Optional flags controlling whether recoverable or unrolled VTXOs are included
|
|
795
795
|
*/
|
|
796
|
-
getVtxos(filter?: GetVtxosFilter): Promise<
|
|
796
|
+
getVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
|
|
797
797
|
/**
|
|
798
798
|
* Outpoints of VTXOs whose deprecated signer is past its cutoff (EXPIRED) and
|
|
799
799
|
* which have not yet been swept — unspendable until they recover. Offline:
|
|
@@ -1256,9 +1256,9 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1256
1256
|
* renewal / offboard) is not a board and leaves the boarding address
|
|
1257
1257
|
* untouched.
|
|
1258
1258
|
*
|
|
1259
|
-
* Boarding inputs are the non-VTXO coins (no `
|
|
1259
|
+
* Boarding inputs are the non-VTXO coins (no `script`), the same
|
|
1260
1260
|
* discriminator {@link handleSettlementFinalizationEvent} uses; the
|
|
1261
|
-
* `typeof` guard skips arknote
|
|
1261
|
+
* `typeof` guard skips the arknote strings settle also accepts.
|
|
1262
1262
|
*
|
|
1263
1263
|
* No-ops for static / `auto` wallets (no descriptor provider — boarding
|
|
1264
1264
|
* stays on its fixed index-0 address). Best-effort and non-fatal: the
|
|
@@ -1321,14 +1321,14 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1321
1321
|
private hasPendingTxFlag;
|
|
1322
1322
|
private setPendingTxFlag;
|
|
1323
1323
|
/**
|
|
1324
|
-
* Create an
|
|
1324
|
+
* Create an ArkadeCash bearer instrument.
|
|
1325
1325
|
*
|
|
1326
1326
|
* Generates a fresh keypair, sends the specified amount to a DefaultVtxo
|
|
1327
|
-
* controlled by the new key, and returns the encoded
|
|
1327
|
+
* controlled by the new key, and returns the encoded arkadeCash string.
|
|
1328
1328
|
* The receiver can claim the funds using `claimCash()` without ever
|
|
1329
1329
|
* sharing their address.
|
|
1330
1330
|
*
|
|
1331
|
-
*
|
|
1331
|
+
* ArkadeCash is a short-lived instrument: it carries a private key, so it is
|
|
1332
1332
|
* meant to be handed over and claimed promptly, not held. A note left
|
|
1333
1333
|
* unclaimed past its batch expiry is swept by the server and `claimCash`
|
|
1334
1334
|
* can only report it, not move it.
|
|
@@ -1336,31 +1336,31 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1336
1336
|
* @param amount - Amount in satoshis to send. Must be a whole number of
|
|
1337
1337
|
* sats at or above the dust threshold — a below-dust amount would mint an
|
|
1338
1338
|
* OP_RETURN output that is unspendable as cash.
|
|
1339
|
-
* @returns The encoded
|
|
1339
|
+
* @returns The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
1340
1340
|
*/
|
|
1341
1341
|
createCash(amount: number): Promise<string>;
|
|
1342
1342
|
/**
|
|
1343
|
-
* Claim an
|
|
1343
|
+
* Claim an ArkadeCash bearer instrument: sweep what can be swept, report the
|
|
1344
1344
|
* rest.
|
|
1345
1345
|
*
|
|
1346
|
-
* Every spendable VTXO at the
|
|
1347
|
-
* its own offchain transaction, signed with the key carried by the
|
|
1346
|
+
* Every spendable VTXO at the arkadeCash address is swept to this wallet in
|
|
1347
|
+
* its own offchain transaction, signed with the key carried by the arkadeCash
|
|
1348
1348
|
* string. Nothing is ever persisted: no contract is imported, and the
|
|
1349
|
-
*
|
|
1349
|
+
* arkadeCash key is not stored. Anything that cannot be swept — server-swept,
|
|
1350
1350
|
* subdust, already claimed, or asset-bearing — is returned in `unclaimed`
|
|
1351
1351
|
* with a per-VTXO reason and otherwise ignored.
|
|
1352
1352
|
*
|
|
1353
|
-
* The
|
|
1353
|
+
* The arkadeCash string is the recovery token: a claim interrupted between
|
|
1354
1354
|
* submit and finalize is completed by simply re-running `claimCash`, which
|
|
1355
|
-
* drains any pending
|
|
1355
|
+
* drains any pending arkadeCash transaction on the server before sweeping.
|
|
1356
1356
|
*
|
|
1357
|
-
* @param cashStr - The encoded
|
|
1357
|
+
* @param cashStr - The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
1358
1358
|
* @returns The swept total and the report of what was left behind. The
|
|
1359
1359
|
* shape is open: further buckets may be added alongside `unclaimed`.
|
|
1360
1360
|
*/
|
|
1361
|
-
claimCash(cashStr: string): Promise<
|
|
1361
|
+
claimCash(cashStr: string): Promise<ArkadeCashClaimResult>;
|
|
1362
1362
|
/**
|
|
1363
|
-
* Split the VTXOs at an
|
|
1363
|
+
* Split the VTXOs at an arkadeCash address into the ones the thin sweep can
|
|
1364
1364
|
* move and the ones it can only report.
|
|
1365
1365
|
*/
|
|
1366
1366
|
private classifyCashVtxos;
|
|
@@ -1368,7 +1368,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1368
1368
|
private fetchAllVtxos;
|
|
1369
1369
|
/**
|
|
1370
1370
|
* Complete any sweep a previous `claimCash` registered but never finalized.
|
|
1371
|
-
* A thin variant of {@link finalizePendingTxs}, scoped to the
|
|
1371
|
+
* A thin variant of {@link finalizePendingTxs}, scoped to the arkadeCash key:
|
|
1372
1372
|
* the intent is signed with it, and so are the returned checkpoints.
|
|
1373
1373
|
*
|
|
1374
1374
|
* A drained sweep is not automatically *ours*. Whoever registered it chose
|
|
@@ -1377,7 +1377,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1377
1377
|
* completing it unsticks the funds), but only the value it actually pays to
|
|
1378
1378
|
* `myPkScript` may be counted as claimed here.
|
|
1379
1379
|
*
|
|
1380
|
-
* @param vtxos - VTXOs at the
|
|
1380
|
+
* @param vtxos - VTXOs at the arkadeCash contract's own pkScript, spent ones
|
|
1381
1381
|
* included (a registered sweep marks its input spent). Any other outpoint —
|
|
1382
1382
|
* subdust above all — would make the proof invalid, since it describes every
|
|
1383
1383
|
* input by that pkScript.
|
|
@@ -1429,7 +1429,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1429
1429
|
* there is no separate change output. It records no `TxSent` history — the
|
|
1430
1430
|
* funds never leave the wallet.
|
|
1431
1431
|
*/
|
|
1432
|
-
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[]): Promise<string>;
|
|
1432
|
+
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[], now?: TimeHeight): Promise<string>;
|
|
1433
1433
|
/**
|
|
1434
1434
|
* Build an offchain transaction from the given inputs and outputs,
|
|
1435
1435
|
* sign it, submit to the Arkade provider, and finalize.
|
|
@@ -1459,4 +1459,4 @@ declare function selectVirtualCoins(coins: ExtendedVirtualCoin[], targetAmount:
|
|
|
1459
1459
|
*/
|
|
1460
1460
|
declare function waitForIncomingFunds(wallet: Wallet): Promise<IncomingFunds>;
|
|
1461
1461
|
|
|
1462
|
-
export {
|
|
1462
|
+
export { ArkError as A, Batch as B, type IncomingFunds as I, type ProviderConnectionState as P, ReadonlyWallet as R, type ServerInfoSource as S, Wallet as W, type ReceiveRotatorFactory as a, type ReceiveRotatorBootOpts as b, type ReceiveRotatorBoot as c, ArkErrorName as d, type ArkadeCashClaimResult as e, ArkadeCashCreateError as f, type ArkadeCashUnclaimedReason as g, type ArkadeCashUnclaimedVtxo as h, type BoardingUtxoGroup as i, type ProviderKind as j, ProviderUnavailableError as k, isArkError as l, maybeArkError as m, selectVirtualCoins as s, waitForIncomingFunds as w };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Transaction } from '@scure/btc-signer';
|
|
2
2
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
3
|
-
import { J as BatchStartedEvent, K as TreeSigningStartedEvent, L as TxTree, M as TreeNoncesEvent,
|
|
3
|
+
import { J as BatchStartedEvent, K as TreeSigningStartedEvent, L as TxTree, M as TreeNoncesEvent, P as BatchFinalizationEvent, Q as BatchFinalizedEvent, U as BatchFailedEvent, X as TreeTxEvent, Y as TreeSignatureEvent, i as SettlementEvent, b as WalletConfig, W as WalletRepository, C as ContractRepository, Z as DescriptorProvider, f as IContractManager, _ as IReadonlyWallet, $ as ReadonlyIdentity, a0 as Network, a1 as OnchainProvider, o as IndexerProvider, a2 as DelegateProvider, a3 as ReadonlyWalletConfig, x as IntentRepository, B as VirtualTxRepository, a4 as ExitCaptureMode, a5 as ExitDataSource, p as RelativeTimelock, d as ActivityRegistry, a6 as IReadonlyAssetManager, a7 as ContractSyncState, n as ArkProvider, a8 as NetworkName, a9 as ArkInfo, aa as ArkAddress, c as WalletBalance, G as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, A as ArkTransaction, e as Activity, E as ExtendedCoin, ab as Coin, t as ExtendedVirtualCoin, ac as ContractManager, I as IWallet, a as Identity, ad as CSVMultisigTapscript, ae as SettlementConfig, j as IAssetManager, af as VtxoManager, g as IDelegateManager, S as SendBitcoinParams, h as SettleParams, R as Recipient, ag as SignerSession, ah as SignedIntent, ai as Intent, aj as TimeHeight } from './ark-CjE0KkGp.cjs';
|
|
4
4
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
5
|
-
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-
|
|
5
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-D3dY-2vS.cjs';
|
|
6
6
|
|
|
7
7
|
declare class ArkError extends Error {
|
|
8
8
|
readonly code: number;
|
|
@@ -487,7 +487,7 @@ interface BoardingUtxoGroup {
|
|
|
487
487
|
coins: ExtendedCoin[];
|
|
488
488
|
}
|
|
489
489
|
/**
|
|
490
|
-
* Why a VTXO at an
|
|
490
|
+
* Why a VTXO at an arkadeCash address could not be swept by {@link Wallet.claimCash}.
|
|
491
491
|
*
|
|
492
492
|
* - `swept` — the server swept the batch at expiry. Recoverable in principle,
|
|
493
493
|
* but only through a settlement, which the thin sweep cannot do.
|
|
@@ -497,14 +497,14 @@ interface BoardingUtxoGroup {
|
|
|
497
497
|
* - `has-assets` — asset-bearing; the BTC-only sweep would burn the assets.
|
|
498
498
|
* - `sweep-failed` — spendable, but its own sweep was rejected.
|
|
499
499
|
*/
|
|
500
|
-
type
|
|
500
|
+
type ArkadeCashUnclaimedReason = "swept" | "subdust" | "already-spent" | "has-assets" | "sweep-failed";
|
|
501
501
|
/** A VTXO {@link Wallet.claimCash} left behind, with the reason why. */
|
|
502
|
-
interface
|
|
502
|
+
interface ArkadeCashUnclaimedVtxo {
|
|
503
503
|
txid: string;
|
|
504
504
|
vout: number;
|
|
505
505
|
/** Value in satoshis. */
|
|
506
506
|
value: number;
|
|
507
|
-
reason:
|
|
507
|
+
reason: ArkadeCashUnclaimedReason;
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* Outcome of {@link Wallet.claimCash}: what was swept, and what was not.
|
|
@@ -512,13 +512,13 @@ interface ArkCashUnclaimedVtxo {
|
|
|
512
512
|
* The shape is open — further buckets may be added alongside `unclaimed` as
|
|
513
513
|
* more of the non-sweepable states become claimable.
|
|
514
514
|
*/
|
|
515
|
-
interface
|
|
515
|
+
interface ArkadeCashClaimResult {
|
|
516
516
|
/** Satoshis swept to this wallet. */
|
|
517
517
|
swept: number;
|
|
518
518
|
unclaimed: {
|
|
519
519
|
/** Satoshis left behind. */
|
|
520
520
|
amount: number;
|
|
521
|
-
vtxos:
|
|
521
|
+
vtxos: ArkadeCashUnclaimedVtxo[];
|
|
522
522
|
};
|
|
523
523
|
}
|
|
524
524
|
/**
|
|
@@ -531,13 +531,13 @@ interface ArkCashClaimResult {
|
|
|
531
531
|
* cannot rule out a post-submit failure must persist `cash` — passing it to
|
|
532
532
|
* {@link Wallet.claimCash} recovers the funds whether or not the send landed.
|
|
533
533
|
*/
|
|
534
|
-
declare class
|
|
535
|
-
/** The encoded
|
|
534
|
+
declare class ArkadeCashCreateError extends Error {
|
|
535
|
+
/** The encoded arkadeCash token controlling the funded output. */
|
|
536
536
|
readonly cash: string;
|
|
537
537
|
/** The original failure from `send`. */
|
|
538
538
|
readonly cause: unknown;
|
|
539
539
|
constructor(
|
|
540
|
-
/** The encoded
|
|
540
|
+
/** The encoded arkadeCash token controlling the funded output. */
|
|
541
541
|
cash: string,
|
|
542
542
|
/** The original failure from `send`. */
|
|
543
543
|
cause: unknown);
|
|
@@ -793,7 +793,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
793
793
|
*
|
|
794
794
|
* @param filter - Optional flags controlling whether recoverable or unrolled VTXOs are included
|
|
795
795
|
*/
|
|
796
|
-
getVtxos(filter?: GetVtxosFilter): Promise<
|
|
796
|
+
getVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
|
|
797
797
|
/**
|
|
798
798
|
* Outpoints of VTXOs whose deprecated signer is past its cutoff (EXPIRED) and
|
|
799
799
|
* which have not yet been swept — unspendable until they recover. Offline:
|
|
@@ -1256,9 +1256,9 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1256
1256
|
* renewal / offboard) is not a board and leaves the boarding address
|
|
1257
1257
|
* untouched.
|
|
1258
1258
|
*
|
|
1259
|
-
* Boarding inputs are the non-VTXO coins (no `
|
|
1259
|
+
* Boarding inputs are the non-VTXO coins (no `script`), the same
|
|
1260
1260
|
* discriminator {@link handleSettlementFinalizationEvent} uses; the
|
|
1261
|
-
* `typeof` guard skips arknote
|
|
1261
|
+
* `typeof` guard skips the arknote strings settle also accepts.
|
|
1262
1262
|
*
|
|
1263
1263
|
* No-ops for static / `auto` wallets (no descriptor provider — boarding
|
|
1264
1264
|
* stays on its fixed index-0 address). Best-effort and non-fatal: the
|
|
@@ -1321,14 +1321,14 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1321
1321
|
private hasPendingTxFlag;
|
|
1322
1322
|
private setPendingTxFlag;
|
|
1323
1323
|
/**
|
|
1324
|
-
* Create an
|
|
1324
|
+
* Create an ArkadeCash bearer instrument.
|
|
1325
1325
|
*
|
|
1326
1326
|
* Generates a fresh keypair, sends the specified amount to a DefaultVtxo
|
|
1327
|
-
* controlled by the new key, and returns the encoded
|
|
1327
|
+
* controlled by the new key, and returns the encoded arkadeCash string.
|
|
1328
1328
|
* The receiver can claim the funds using `claimCash()` without ever
|
|
1329
1329
|
* sharing their address.
|
|
1330
1330
|
*
|
|
1331
|
-
*
|
|
1331
|
+
* ArkadeCash is a short-lived instrument: it carries a private key, so it is
|
|
1332
1332
|
* meant to be handed over and claimed promptly, not held. A note left
|
|
1333
1333
|
* unclaimed past its batch expiry is swept by the server and `claimCash`
|
|
1334
1334
|
* can only report it, not move it.
|
|
@@ -1336,31 +1336,31 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1336
1336
|
* @param amount - Amount in satoshis to send. Must be a whole number of
|
|
1337
1337
|
* sats at or above the dust threshold — a below-dust amount would mint an
|
|
1338
1338
|
* OP_RETURN output that is unspendable as cash.
|
|
1339
|
-
* @returns The encoded
|
|
1339
|
+
* @returns The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
1340
1340
|
*/
|
|
1341
1341
|
createCash(amount: number): Promise<string>;
|
|
1342
1342
|
/**
|
|
1343
|
-
* Claim an
|
|
1343
|
+
* Claim an ArkadeCash bearer instrument: sweep what can be swept, report the
|
|
1344
1344
|
* rest.
|
|
1345
1345
|
*
|
|
1346
|
-
* Every spendable VTXO at the
|
|
1347
|
-
* its own offchain transaction, signed with the key carried by the
|
|
1346
|
+
* Every spendable VTXO at the arkadeCash address is swept to this wallet in
|
|
1347
|
+
* its own offchain transaction, signed with the key carried by the arkadeCash
|
|
1348
1348
|
* string. Nothing is ever persisted: no contract is imported, and the
|
|
1349
|
-
*
|
|
1349
|
+
* arkadeCash key is not stored. Anything that cannot be swept — server-swept,
|
|
1350
1350
|
* subdust, already claimed, or asset-bearing — is returned in `unclaimed`
|
|
1351
1351
|
* with a per-VTXO reason and otherwise ignored.
|
|
1352
1352
|
*
|
|
1353
|
-
* The
|
|
1353
|
+
* The arkadeCash string is the recovery token: a claim interrupted between
|
|
1354
1354
|
* submit and finalize is completed by simply re-running `claimCash`, which
|
|
1355
|
-
* drains any pending
|
|
1355
|
+
* drains any pending arkadeCash transaction on the server before sweeping.
|
|
1356
1356
|
*
|
|
1357
|
-
* @param cashStr - The encoded
|
|
1357
|
+
* @param cashStr - The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
1358
1358
|
* @returns The swept total and the report of what was left behind. The
|
|
1359
1359
|
* shape is open: further buckets may be added alongside `unclaimed`.
|
|
1360
1360
|
*/
|
|
1361
|
-
claimCash(cashStr: string): Promise<
|
|
1361
|
+
claimCash(cashStr: string): Promise<ArkadeCashClaimResult>;
|
|
1362
1362
|
/**
|
|
1363
|
-
* Split the VTXOs at an
|
|
1363
|
+
* Split the VTXOs at an arkadeCash address into the ones the thin sweep can
|
|
1364
1364
|
* move and the ones it can only report.
|
|
1365
1365
|
*/
|
|
1366
1366
|
private classifyCashVtxos;
|
|
@@ -1368,7 +1368,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1368
1368
|
private fetchAllVtxos;
|
|
1369
1369
|
/**
|
|
1370
1370
|
* Complete any sweep a previous `claimCash` registered but never finalized.
|
|
1371
|
-
* A thin variant of {@link finalizePendingTxs}, scoped to the
|
|
1371
|
+
* A thin variant of {@link finalizePendingTxs}, scoped to the arkadeCash key:
|
|
1372
1372
|
* the intent is signed with it, and so are the returned checkpoints.
|
|
1373
1373
|
*
|
|
1374
1374
|
* A drained sweep is not automatically *ours*. Whoever registered it chose
|
|
@@ -1377,7 +1377,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1377
1377
|
* completing it unsticks the funds), but only the value it actually pays to
|
|
1378
1378
|
* `myPkScript` may be counted as claimed here.
|
|
1379
1379
|
*
|
|
1380
|
-
* @param vtxos - VTXOs at the
|
|
1380
|
+
* @param vtxos - VTXOs at the arkadeCash contract's own pkScript, spent ones
|
|
1381
1381
|
* included (a registered sweep marks its input spent). Any other outpoint —
|
|
1382
1382
|
* subdust above all — would make the proof invalid, since it describes every
|
|
1383
1383
|
* input by that pkScript.
|
|
@@ -1429,7 +1429,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet {
|
|
|
1429
1429
|
* there is no separate change output. It records no `TxSent` history — the
|
|
1430
1430
|
* funds never leave the wallet.
|
|
1431
1431
|
*/
|
|
1432
|
-
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[]): Promise<string>;
|
|
1432
|
+
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[], now?: TimeHeight): Promise<string>;
|
|
1433
1433
|
/**
|
|
1434
1434
|
* Build an offchain transaction from the given inputs and outputs,
|
|
1435
1435
|
* sign it, submit to the Arkade provider, and finalize.
|
|
@@ -1459,4 +1459,4 @@ declare function selectVirtualCoins(coins: ExtendedVirtualCoin[], targetAmount:
|
|
|
1459
1459
|
*/
|
|
1460
1460
|
declare function waitForIncomingFunds(wallet: Wallet): Promise<IncomingFunds>;
|
|
1461
1461
|
|
|
1462
|
-
export {
|
|
1462
|
+
export { ArkError as A, Batch as B, type IncomingFunds as I, type ProviderConnectionState as P, ReadonlyWallet as R, type ServerInfoSource as S, Wallet as W, type ReceiveRotatorFactory as a, type ReceiveRotatorBootOpts as b, type ReceiveRotatorBoot as c, ArkErrorName as d, type ArkadeCashClaimResult as e, ArkadeCashCreateError as f, type ArkadeCashUnclaimedReason as g, type ArkadeCashUnclaimedVtxo as h, type BoardingUtxoGroup as i, type ProviderKind as j, ProviderUnavailableError as k, isArkError as l, maybeArkError as m, selectVirtualCoins as s, waitForIncomingFunds as w };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
5
|
-
require('../../chunk-
|
|
6
|
-
require('../../chunk-
|
|
7
|
-
require('../../chunk-
|
|
3
|
+
var chunkSYDANBJI_cjs = require('../../chunk-SYDANBJI.cjs');
|
|
4
|
+
require('../../chunk-ENZ4YPR2.cjs');
|
|
5
|
+
require('../../chunk-EB3ALGTM.cjs');
|
|
6
|
+
require('../../chunk-5XMVTK5S.cjs');
|
|
7
|
+
require('../../chunk-7TXSPRN5.cjs');
|
|
8
8
|
require('../../chunk-5BLDMQED.cjs');
|
|
9
9
|
|
|
10
10
|
// src/worker/expo/taskQueue.ts
|
|
@@ -121,19 +121,19 @@ var AsyncStorageTaskQueue = class {
|
|
|
121
121
|
|
|
122
122
|
Object.defineProperty(exports, "CONTRACT_POLL_TASK_TYPE", {
|
|
123
123
|
enumerable: true,
|
|
124
|
-
get: function () { return
|
|
124
|
+
get: function () { return chunkSYDANBJI_cjs.CONTRACT_POLL_TASK_TYPE; }
|
|
125
125
|
});
|
|
126
126
|
Object.defineProperty(exports, "contractPollProcessor", {
|
|
127
127
|
enumerable: true,
|
|
128
|
-
get: function () { return
|
|
128
|
+
get: function () { return chunkSYDANBJI_cjs.contractPollProcessor; }
|
|
129
129
|
});
|
|
130
130
|
Object.defineProperty(exports, "createTaskDependencies", {
|
|
131
131
|
enumerable: true,
|
|
132
|
-
get: function () { return
|
|
132
|
+
get: function () { return chunkSYDANBJI_cjs.createTaskDependencies; }
|
|
133
133
|
});
|
|
134
134
|
Object.defineProperty(exports, "runTasks", {
|
|
135
135
|
enumerable: true,
|
|
136
|
-
get: function () { return
|
|
136
|
+
get: function () { return chunkSYDANBJI_cjs.runTasks; }
|
|
137
137
|
});
|
|
138
138
|
exports.AsyncStorageTaskQueue = AsyncStorageTaskQueue;
|
|
139
139
|
exports.InMemoryTaskQueue = InMemoryTaskQueue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { T as TaskProcessor } from '../../taskRunner-
|
|
2
|
-
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, b as TaskDependencies, c as TaskItem, a as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-
|
|
3
|
-
export { a as AsyncStorageLike, A as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-
|
|
4
|
-
import '../../ark-
|
|
1
|
+
import { T as TaskProcessor } from '../../taskRunner-Brnak0Rc.cjs';
|
|
2
|
+
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, b as TaskDependencies, c as TaskItem, a as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-Brnak0Rc.cjs';
|
|
3
|
+
export { a as AsyncStorageLike, A as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-CeLZhZFU.cjs';
|
|
4
|
+
import '../../ark-CjE0KkGp.cjs';
|
|
5
5
|
import '@scure/btc-signer/transaction.js';
|
|
6
6
|
import '@scure/btc-signer/utils.js';
|
|
7
7
|
import '@scure/btc-signer/psbt.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { T as TaskProcessor } from '../../taskRunner-
|
|
2
|
-
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, b as TaskDependencies, c as TaskItem, a as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-
|
|
3
|
-
export { a as AsyncStorageLike, A as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-
|
|
4
|
-
import '../../ark-
|
|
1
|
+
import { T as TaskProcessor } from '../../taskRunner-B-2MHCYG.js';
|
|
2
|
+
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, b as TaskDependencies, c as TaskItem, a as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-B-2MHCYG.js';
|
|
3
|
+
export { a as AsyncStorageLike, A as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-D9SOPMPC.js';
|
|
4
|
+
import '../../ark-CjE0KkGp.js';
|
|
5
5
|
import '@scure/btc-signer/transaction.js';
|
|
6
6
|
import '@scure/btc-signer/utils.js';
|
|
7
7
|
import '@scure/btc-signer/psbt.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { CONTRACT_POLL_TASK_TYPE, contractPollProcessor, createTaskDependencies, runTasks } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
1
|
+
export { CONTRACT_POLL_TASK_TYPE, contractPollProcessor, createTaskDependencies, runTasks } from '../../chunk-G6J6AEMH.js';
|
|
2
|
+
import '../../chunk-NYR5H6GR.js';
|
|
3
|
+
import '../../chunk-BHHLRZCS.js';
|
|
4
|
+
import '../../chunk-4VVTRPH3.js';
|
|
5
|
+
import '../../chunk-ZDDBTFVO.js';
|
|
6
6
|
import '../../chunk-NSBPE2FW.js';
|
|
7
7
|
|
|
8
8
|
// src/worker/expo/taskQueue.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkade-os/sdk",
|
|
3
|
-
"version": "0.4.48
|
|
3
|
+
"version": "0.4.48",
|
|
4
4
|
"description": "TypeScript SDK for building Bitcoin wallets using the Arkade protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -199,6 +199,7 @@
|
|
|
199
199
|
"build": "tsup",
|
|
200
200
|
"smoke:dist": "node scripts/smoke-dist.mjs",
|
|
201
201
|
"typecheck": "tsc --noEmit",
|
|
202
|
+
"check:vtxo": "node scripts/check-virtual-status.mjs && node scripts/check-provider-boundary.mjs",
|
|
202
203
|
"docs:build": "pnpm run typecheck && pnpm typedoc",
|
|
203
204
|
"docs:open": "open ../../docs/index.html",
|
|
204
205
|
"test": "vitest run",
|
|
@@ -215,7 +216,7 @@
|
|
|
215
216
|
"test:watch": "vitest",
|
|
216
217
|
"test:coverage": "vitest run --coverage",
|
|
217
218
|
"format": "prettier --write src test examples",
|
|
218
|
-
"lint": "prettier --check src test examples",
|
|
219
|
+
"lint": "prettier --check src test examples && pnpm run check:vtxo",
|
|
219
220
|
"audit": "pnpm audit"
|
|
220
221
|
}
|
|
221
222
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":["buildVersion","sdkVersion","fetch","RestArkProvider","DEFAULT_ARKADE_SERVER_URL","isFetchTimeoutError","RestIndexerProvider"],"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,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AACzC,MAAA,OAAA,CAAQ,GAAA,CAAI,mBAAmBA,8BAAY,CAAA;AAC3C,MAAA,OAAA,CAAQ,GAAA,CAAI,iBAAiBC,4BAAU,CAAA;AACvC,MAAA,OAAO,gBAAgB,KAAA,CAAM,KAAA,EAAO,EAAE,GAAG,IAAA,EAAM,SAAS,CAAA;AAAA,IAC5D,CAAA;AACA,IAAA,OAAO,mBAAA;AAAA,EACX,SAAS,KAAA,EAAO;AAQZ,IAAA,OAAA,CAAQ,IAAA;AAAA,MACJ,wGAAA;AAAA,MAEA;AAAA,KACJ;AACA,IAAA,OAAOC,uBAAA;AAAA,EACX;AACJ;AAYA,gBAAuB,iBAAA,CACnB,GAAA,EACA,WAAA,EACA,OAAA,EACA,SACA,SAAA,EACgC;AAChC,EAAA,MAAM,eAAA,GAAkB,IAAI,eAAA,EAAgB;AAC5C,EAAA,MAAM,OAAA,GAAU,MAAM,eAAA,CAAgB,KAAA,EAAM;AAC5C,EAAA,WAAA,EAAa,iBAAiB,OAAA,EAAS,OAAA,EAAS,EAAE,IAAA,EAAM,MAAM,CAAA;AAE9D,EAAA,IAAI;AACA,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,GAAA,EAA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a,IAAA,CAAK,KAAA,CAAM,cAAc,EAAC,EAAG,IAAI,WAAW,CAAA;AAAA,gBACzD,aAAa,IAAA,CAAK,KAAA,CAAM,cAAc,EAAC,EAAG,IAAI,WAAW,CAAA;AAAA,gBACzD,EAAA,EAAI,KAAK,KAAA,CAAM,EAAA;AAAA,gBACf,aAAA,EAAe,KAAK,KAAA,CAAM;AAAA,eAC9B;AAAA,YACJ;AACA,YAAA,OAAO,IAAA;AAAA,UACX;AAAA,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,IAAIC,qCAAA,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-3HUZAIKI.cjs","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 +0,0 @@
|
|
|
1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UAAA,CAAW,IAAA,EAAM,QAAQ,CAAC,CAAA;AAAA,QAC5C;AAEA,QAAA,OAAA,GAAU,IAAA,GAAO,KAAA,CAAM,MAAA,KAAW,QAAA,GAAW,KAAA;AAC7C,QAAA,SAAA,EAAA;AAAA,MACJ;AAKA,MAAA,MAAM,QAAA,GAAW,2BAAA;AAAA,QACb,QAAA;AAAA,QACA,QAAA,CAAS,MAAA;AAAA,QACT;AAAA,OACJ;AACA,MAAA,MAAM,oBAAA,CAAqB,gBAAA,EAAkB,QAAA,EAAU,QAAQ,CAAA;AAC/D,MAAA,UAAA,IAAc,QAAA,CAAS,MAAA;AACvB,MAAA,kBAAA,EAAA;AAAA,IACJ;AAEA,IAAA,OAAO;AAAA,MACH,YAAY,IAAA,CAAK,EAAA;AAAA,MACjB,IAAA,EAAM,uBAAA;AAAA,MACN,MAAA,EAAQ,SAAA;AAAA,MACR,IAAA,EAAM,EAAE,kBAAA,EAAoB,UAAA;AAAW,KAC3C;AAAA,EACJ;AACJ","file":"chunk-4AIHKC65.js","sourcesContent":["import type { TaskItem, TaskResult, TaskQueue } from \"./taskQueue\";\nimport type { WalletRepository } from \"../../repositories/walletRepository\";\nimport type { ContractRepository } from \"../../repositories/contractRepository\";\nimport type { IndexerProvider } from \"../../providers/indexer\";\nimport type { ArkProvider } from \"../../providers/ark\";\nimport type { ExtendedVirtualCoin, VirtualCoin } from \"../../wallet\";\nimport type { Contract } from \"../../contracts/types\";\nimport { getRandomId, extendVirtualCoinForContract } from \"../../wallet/utils\";\n\n/**\n * Shared dependencies injected into every processor at runtime.\n *\n * `extendVtxo` requires the owning contract — processors must resolve each\n * vtxo's `script` to a known contract (via the contract repository) before\n * calling this. The strict signature prevents the footgun where a missing\n * contract silently falls back to the wallet's default tapscript.\n */\nexport interface TaskDependencies {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: ArkProvider;\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) => ExtendedVirtualCoin;\n}\n\n/**\n * A stateless unit that handles one type of task item.\n *\n * Processors must not keep in-memory state across invocations —\n * all coordination lives in the @see TaskQueue and repositories.\n *\n * The `TDeps` parameter defaults to @see TaskDependencies but\n * can be overridden for domain-specific processors (e.g. swap processing).\n */\nexport interface TaskProcessor<TDeps = TaskDependencies> {\n readonly taskType: string;\n execute(item: TaskItem, deps: TDeps): Promise<Omit<TaskResult, \"id\" | \"executedAt\">>;\n}\n\n/**\n * Run all pending tasks from the queue through matching processors.\n *\n * For each task in the inbox:\n * 1. Find the processor whose `taskType` matches `task.type`.\n * 2. Execute it, producing a @see TaskResult.\n * 3. Push the result to the outbox and remove the task from the inbox.\n *\n * Tasks with no matching processor produce a `\"noop\"` result.\n * Processor errors produce a `\"failed\"` result with the error message.\n */\nexport async function runTasks<TDeps = TaskDependencies>(\n queue: TaskQueue,\n processors: TaskProcessor<TDeps>[],\n deps: TDeps,\n): Promise<TaskResult[]> {\n const tasks = await queue.getTasks();\n const processorMap = new Map(processors.map((p) => [p.taskType, p]));\n const results: TaskResult[] = [];\n\n for (const task of tasks) {\n const processor = processorMap.get(task.type);\n\n let partial: Omit<TaskResult, \"id\" | \"executedAt\">;\n\n if (!processor) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"noop\",\n };\n } else {\n try {\n partial = await processor.execute(task, deps);\n } catch (error) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"failed\",\n data: {\n error: error instanceof Error ? error.message : String(error),\n },\n };\n }\n }\n\n const result: TaskResult = {\n ...partial,\n id: getRandomId(),\n executedAt: Date.now(),\n };\n\n await queue.pushResult(result);\n await queue.removeTask(task.id);\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Options for @see createTaskDependencies.\n */\nexport interface CreateTaskDependenciesOptions {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: ArkProvider;\n}\n\n/**\n * Build the @see TaskDependencies needed by task processors\n * (e.g. `src/worker/expo/processors/contractPollProcessor.ts`)\n *\n * This is the same construction that `defineExpoBackgroundTask` does\n * internally, extracted so that consumers with custom schedulers\n * (e.g. bare React Native with `react-native-background-fetch`)\n * can build deps without depending on Expo.\n */\nexport function createTaskDependencies(options: CreateTaskDependenciesOptions): TaskDependencies {\n return {\n ...options,\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) =>\n extendVirtualCoinForContract(vtxo, contract),\n };\n}\n","import type { TaskItem, TaskResult } from \"../taskQueue\";\nimport type { TaskProcessor, TaskDependencies } from \"../taskRunner\";\nimport type { ExtendedVirtualCoin } from \"../../../wallet\";\nimport {\n warnAndFilterVtxosForScript,\n saveVtxosForContract,\n} from \"../../../contracts/vtxoOwnership\";\n\nexport const CONTRACT_POLL_TASK_TYPE = \"contract-poll\";\n\n/**\n * Polls the indexer for the latest VTXO state of every contract and\n * persists the results to the wallet repository.\n *\n * Replicates the polling subset of @see ContractManager.initialize:\n * 1. Load all contracts from the contract repository.\n * 2. Paginated fetch of every VTXO (including spent) from the indexer.\n * 3. Extend each VTXO with tapscript data.\n * 4. Save to the wallet repository.\n *\n * NOTE: the indexer query deliberately omits `spendableOnly`. Every\n * repository implements `saveVtxos` as an upsert with no batch delete,\n * so filtering to spendable-only would leave VTXOs that became spent\n * between polls marked as spendable forever. Fetching the full set lets\n * the upsert overwrite stale records with their latest state.\n */\nexport const contractPollProcessor: TaskProcessor = {\n taskType: CONTRACT_POLL_TASK_TYPE,\n\n async execute(\n item: TaskItem,\n deps: TaskDependencies,\n ): Promise<Omit<TaskResult, \"id\" | \"executedAt\">> {\n const { contractRepository, walletRepository, indexerProvider, extendVtxo } = deps;\n\n const contracts = await contractRepository.getContracts();\n let contractsProcessed = 0;\n let vtxosSaved = 0;\n\n for (const contract of contracts) {\n // Paginated fetch of spendable virtual outputs\n const pageSize = 100;\n let pageIndex = 0;\n let hasMore = true;\n const allVtxos: ExtendedVirtualCoin[] = [];\n\n while (hasMore) {\n const { vtxos, page } = await indexerProvider.getVtxos({\n scripts: [contract.script],\n pageIndex,\n pageSize,\n });\n\n for (const vtxo of vtxos) {\n allVtxos.push(extendVtxo(vtxo, contract));\n }\n\n hasMore = page ? vtxos.length === pageSize : false;\n pageIndex++;\n }\n\n // Skip wrong-script rows (legacy duplicates or indexer drift)\n // before persisting; the loop must keep going for the remaining\n // contracts even when one row is rejected.\n const filtered = warnAndFilterVtxosForScript(\n allVtxos,\n contract.script,\n \"contractPollProcessor\",\n );\n await saveVtxosForContract(walletRepository, contract, filtered);\n vtxosSaved += filtered.length;\n contractsProcessed++;\n }\n\n return {\n taskItemId: item.id,\n type: CONTRACT_POLL_TASK_TYPE,\n status: \"success\",\n data: { contractsProcessed, vtxosSaved },\n };\n },\n};\n"]}
|