@arkade-os/sdk 0.5.3 → 0.5.4
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 +36 -34
- package/dist/adapters/expo.cjs +9 -5
- package/dist/adapters/expo.d.cts +11 -7
- package/dist/adapters/expo.d.ts +11 -7
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-B3U5gQ-i.d.ts → asyncStorageTaskQueue-DHMIxY04.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-C9PkPcW_.d.cts → asyncStorageTaskQueue-DTBa8EH7.d.cts} +2 -2
- package/dist/{chunk-P7B4LQ3H.js → chunk-6CUP6ZIF.js} +4 -4
- package/dist/{chunk-P7B4LQ3H.js.map → chunk-6CUP6ZIF.js.map} +1 -1
- package/dist/{chunk-OPX2HRWM.js → chunk-AG4TFD6F.js} +137 -59
- package/dist/chunk-AG4TFD6F.js.map +1 -0
- package/dist/{chunk-5WRA66RV.cjs → chunk-B6VNKGIH.cjs} +10 -10
- package/dist/chunk-B6VNKGIH.cjs.map +1 -0
- package/dist/{chunk-6FL4N4S2.js → chunk-BTRCN4JJ.js} +22 -19
- package/dist/chunk-BTRCN4JJ.js.map +1 -0
- package/dist/{chunk-ZPF4I3K2.cjs → chunk-DNITZVNG.cjs} +28 -47
- package/dist/chunk-DNITZVNG.cjs.map +1 -0
- package/dist/{chunk-BYPBVHVA.cjs → chunk-E6OOJEHL.cjs} +49 -49
- package/dist/{chunk-BYPBVHVA.cjs.map → chunk-E6OOJEHL.cjs.map} +1 -1
- package/dist/{chunk-OUTWUYJ4.cjs → chunk-F3FAE7VJ.cjs} +769 -619
- package/dist/chunk-F3FAE7VJ.cjs.map +1 -0
- package/dist/{chunk-KW7ZEWYS.cjs → chunk-GHUUT54D.cjs} +140 -58
- package/dist/chunk-GHUUT54D.cjs.map +1 -0
- package/dist/{chunk-Y4BL3YYX.js → chunk-MWVAWFX6.js} +4 -4
- package/dist/chunk-MWVAWFX6.js.map +1 -0
- package/dist/{chunk-T7C3E2HL.js → chunk-TUOLZBNC.js} +19 -39
- package/dist/chunk-TUOLZBNC.js.map +1 -0
- package/dist/{chunk-ZMSM3NOH.cjs → chunk-WXNSISXK.cjs} +37 -34
- package/dist/chunk-WXNSISXK.cjs.map +1 -0
- package/dist/{chunk-HAQAWBYG.js → chunk-ZJHLLDBP.js} +283 -136
- package/dist/chunk-ZJHLLDBP.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- 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-ByfKszb6.d.cts → delegate-f4_t864Z.d.cts} +1 -1
- package/dist/{delegate-Cd28gxpM.d.ts → delegate-xrSBNybC.d.ts} +1 -1
- package/dist/{index-DgH_0j14.d.cts → index-BJDz15ms.d.ts} +5 -5
- package/dist/{index-B6X2E7W_.d.ts → index-BjiVGtp8.d.cts} +5 -5
- package/dist/{index-BURzbRup.d.ts → index-DRwe0UDN.d.cts} +182 -114
- package/dist/{index-BURzbRup.d.cts → index-DRwe0UDN.d.ts} +182 -114
- package/dist/index.cjs +333 -313
- package/dist/index.d.cts +66 -44
- package/dist/index.d.ts +66 -44
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +65 -36
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +7 -3
- package/dist/repositories/realm/index.d.ts +7 -3
- package/dist/repositories/realm/index.js +35 -6
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +176 -110
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +23 -13
- package/dist/repositories/sqlite/index.d.ts +23 -13
- package/dist/repositories/sqlite/index.js +148 -83
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-i56-drQV.d.cts → taskRunner-BPPU-YHG.d.cts} +4 -4
- package/dist/{taskRunner-BaNCSxqK.d.ts → taskRunner-CDlNeth0.d.ts} +4 -4
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +7 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +15 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +6 -6
- package/dist/wallet/expo/index.d.ts +6 -6
- package/dist/wallet/expo/index.js +6 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-BjQugVUt.d.cts → wallet-Oc3Wd5gv.d.ts} +22 -18
- package/dist/{wallet-BnmhohgZ.d.ts → wallet-jVBDQl6R.d.cts} +22 -18
- 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 +1 -1
- package/dist/chunk-5WRA66RV.cjs.map +0 -1
- package/dist/chunk-6FL4N4S2.js.map +0 -1
- package/dist/chunk-HAQAWBYG.js.map +0 -1
- package/dist/chunk-KW7ZEWYS.cjs.map +0 -1
- package/dist/chunk-OPX2HRWM.js.map +0 -1
- package/dist/chunk-OUTWUYJ4.cjs.map +0 -1
- package/dist/chunk-T7C3E2HL.js.map +0 -1
- package/dist/chunk-Y4BL3YYX.js.map +0 -1
- package/dist/chunk-ZMSM3NOH.cjs.map +0 -1
- package/dist/chunk-ZPF4I3K2.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { W as WalletRepository, P as PageRequest,
|
|
2
|
-
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
1
|
+
import { W as WalletRepository, P as PageRequest, F as Outpoint, H as PageResult, D as ExtendedVirtualCoin, J as ScriptVtxoCursor, K as ScriptVtxoPageOptions, L as StoredVtxo, M as VtxoRepositoryKey, E as ExtendedCoin, Q as TransactionHistoryPageFilter, U as TransactionHistoryPageCursor, h as ArkTransaction, X as AtomicWalletState, Y as WalletState, a5 as DescriptorProvider, a6 as DescriptorSigningRequest, a7 as Transaction, l as GetNewAddressesOptions, m as NewAddress, a as Identity, x as RelativeTimelock, a8 as Network, a9 as BatchStartedEvent, aa as TreeSigningStartedEvent, ab as TxTree, ac as TreeNoncesEvent, ad as BatchFinalizationEvent, ae as BatchFinalizedEvent, af as BatchFailedEvent, ag as TreeTxEvent, ah as TreeSignatureEvent, o as SettlementEvent, b as WalletConfig, C as ContractRepository, k as IContractManager, ai as IReadonlyWallet, aj as ReadonlyIdentity, ak as OnchainProvider, O as OperatorProvider, w as IndexerProvider, al as DelegateProvider, am as ReadonlyWalletConfig, _ as IntentRepository, a1 as VirtualTxRepository, an as ExitCaptureMode, ao as ExitDataSource, i as ActivityRegistry, ap as IReadonlyAssetManager, aq as ContractSyncState, ar as RecipientArkadeAddressContext, G as GetArkadeInfoOptions, A as ArkadeInfo, c as ArkadeReader, as as EsploraProvider, at as NetworkName, au as OperatorInfo, av as ArkAddress, e as WalletBalance, f as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, g as GetSpendableVtxosFilter, aw as ContractWithVtxos, ax as selectPendingRecoveryOutpoints, j as Activity, ay as Coin, az as ContractManager, aA as ContractManagerConfig, I as IWallet, aB as CSVMultisigTapscript, aC as SettlementConfig, d as ArkadeBroadcaster, q as IAssetManager, aD as VtxoManager, n as IDelegateManager, S as SettleParams, R as Recipient, aE as SignerSession, aF as SignedIntent, aG as Intent, aH as SignedProof, aI as Proof, p as SendParams, aJ as TimeHeight } from './index-DRwe0UDN.js';
|
|
3
2
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
|
-
import {
|
|
3
|
+
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
4
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-xrSBNybC.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* IndexedDB-based implementation of WalletRepository.
|
|
@@ -9,7 +9,10 @@ import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-ByfKszb6.cjs';
|
|
|
9
9
|
declare class IndexedDBWalletRepository implements WalletRepository {
|
|
10
10
|
readonly version: 2;
|
|
11
11
|
private readonly connection;
|
|
12
|
-
|
|
12
|
+
/** persistentWalletState asserts persistence beyond this process; it cannot detect browser eviction. */
|
|
13
|
+
constructor(dbName?: string, options?: {
|
|
14
|
+
persistentWalletState?: boolean;
|
|
15
|
+
});
|
|
13
16
|
clear(): Promise<void>;
|
|
14
17
|
[Symbol.asyncDispose](): Promise<void>;
|
|
15
18
|
getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
|
|
@@ -25,6 +28,7 @@ declare class IndexedDBWalletRepository implements WalletRepository {
|
|
|
25
28
|
getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
|
|
26
29
|
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
27
30
|
deleteTransactions(address: string): Promise<void>;
|
|
31
|
+
readonly atomicWalletState: AtomicWalletState;
|
|
28
32
|
getWalletState(): Promise<WalletState | null>;
|
|
29
33
|
saveWalletState(state: WalletState): Promise<void>;
|
|
30
34
|
private getDB;
|
|
@@ -431,7 +435,7 @@ type ServerInfoSource = "live" | "cache";
|
|
|
431
435
|
* const handler = wallet.createBatchHandler(intentId, inputs, expectedRecipients, musig2session);
|
|
432
436
|
*
|
|
433
437
|
* const abortController = new AbortController();
|
|
434
|
-
* // Get event stream from the
|
|
438
|
+
* // Get event stream from the operator provider
|
|
435
439
|
* const eventStream = arkProvider.getEventStream(
|
|
436
440
|
* abortController.signal,
|
|
437
441
|
* ['your-topic-1', 'your-topic-2']
|
|
@@ -831,7 +835,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
831
835
|
readonly network: Network;
|
|
832
836
|
readonly onchainProvider: OnchainProvider;
|
|
833
837
|
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
834
|
-
protected readonly arkProvider: Pick<
|
|
838
|
+
protected readonly arkProvider: Pick<OperatorProvider, "getInfo">;
|
|
835
839
|
readonly indexerProvider: IndexerProvider;
|
|
836
840
|
readonly dustAmount: bigint;
|
|
837
841
|
readonly walletRepository: WalletRepository;
|
|
@@ -905,7 +909,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
905
909
|
getContractSyncState(): ContractSyncState;
|
|
906
910
|
protected constructor(identity: ReadonlyIdentity, network: Network, onchainProvider: OnchainProvider,
|
|
907
911
|
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
908
|
-
arkProvider: Pick<
|
|
912
|
+
arkProvider: Pick<OperatorProvider, "getInfo">, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider | undefined, watcherConfig?: ReadonlyWalletConfig["watcherConfig"], walletContractTimelocks?: RelativeTimelock[]);
|
|
909
913
|
/**
|
|
910
914
|
* x-only hex → cutoff of the operator's deprecated signers, cached for OFFLINE read/watch.
|
|
911
915
|
* Boarding watch/history fan out over {current} ∪ this set so deposits at addresses minted
|
|
@@ -974,7 +978,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
974
978
|
protected notifyBoardingRotation(): void;
|
|
975
979
|
/** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
|
|
976
980
|
protected static setupWalletConfig(config: ReadonlyWalletConfig, pubKey: Uint8Array): Promise<{
|
|
977
|
-
arkProvider:
|
|
981
|
+
arkProvider: OperatorProvider;
|
|
978
982
|
indexerProvider: IndexerProvider;
|
|
979
983
|
onchainProvider: OnchainProvider | EsploraProvider;
|
|
980
984
|
network: Network;
|
|
@@ -985,7 +989,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
985
989
|
dustAmount: bigint;
|
|
986
990
|
walletRepository: WalletRepository | IndexedDBWalletRepository;
|
|
987
991
|
contractRepository: ContractRepository;
|
|
988
|
-
info:
|
|
992
|
+
info: OperatorInfo;
|
|
989
993
|
serverInfoSource: ServerInfoSource;
|
|
990
994
|
serverInfoLastOnlineAt: number | undefined;
|
|
991
995
|
delegateProvider: DelegateProvider | undefined;
|
|
@@ -1214,14 +1218,14 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1214
1218
|
* // Create a wallet with providers
|
|
1215
1219
|
* const wallet = await Wallet.create({
|
|
1216
1220
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
1217
|
-
*
|
|
1221
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
1218
1222
|
* onchainProvider: new EsploraProvider()
|
|
1219
1223
|
* });
|
|
1220
1224
|
*
|
|
1221
1225
|
* // Use custom providers and/or URLs (e.g., for Expo/React Native)
|
|
1222
1226
|
* const wallet = await Wallet.create({
|
|
1223
1227
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
1224
|
-
*
|
|
1228
|
+
* operatorProvider: new ExpoOperatorProvider('https://arkade.computer'),
|
|
1225
1229
|
* indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
|
|
1226
1230
|
* onchainProvider: new EsploraProvider('https://mempool.space/api')
|
|
1227
1231
|
* });
|
|
@@ -1521,13 +1525,13 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1521
1525
|
/** @see WalletConfig.concurrentSpending */
|
|
1522
1526
|
get concurrentSpending(): boolean;
|
|
1523
1527
|
/** Public here; `ReadonlyWallet` keeps it protected so a readonly view can't submit. */
|
|
1524
|
-
readonly arkProvider:
|
|
1528
|
+
readonly arkProvider: OperatorProvider;
|
|
1525
1529
|
/**
|
|
1526
1530
|
* Broadcast access bound to this wallet's server, so a plugin needs only the wallet. Not on
|
|
1527
1531
|
* {@link ReadonlyWallet}: a readonly wallet or `toReadonly()` view must not be able to submit.
|
|
1528
1532
|
*/
|
|
1529
1533
|
getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
|
|
1530
|
-
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider:
|
|
1534
|
+
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider: OperatorProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, serverUnrollScript: CSVMultisigTapscript.Type, forfeitOutputScript: Bytes, forfeitPubkey: Bytes, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider, watcherConfig?: WalletConfig["watcherConfig"], settlementConfig?: WalletConfig["settlementConfig"], walletContractTimelocks?: RelativeTimelock[], receiveRotator?: WalletReceiveRotator, descriptorProvider?: DescriptorProvider, keyring?: KeyringDescriptorProvider, lookAheadWindow?: number,
|
|
1531
1535
|
/** Overrides for the `batchExpiry` bounds; defaults derive from `network`. */
|
|
1532
1536
|
batchExpiryPolicy?: Partial<BatchExpiryPolicy> | undefined,
|
|
1533
1537
|
/** @see WalletConfig.oneShotSubmit */
|
|
@@ -1544,7 +1548,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1544
1548
|
* ```typescript
|
|
1545
1549
|
* const wallet = await Wallet.create({
|
|
1546
1550
|
* identity,
|
|
1547
|
-
*
|
|
1551
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
1548
1552
|
* });
|
|
1549
1553
|
* ```
|
|
1550
1554
|
*/
|
|
@@ -1619,9 +1623,9 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1619
1623
|
signInputsByWitnessScript(tx: Transaction): Promise<Transaction>;
|
|
1620
1624
|
signOnchainBoardingTx(tx: Transaction): Promise<Transaction>;
|
|
1621
1625
|
safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
|
|
1622
|
-
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<
|
|
1623
|
-
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<
|
|
1624
|
-
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<
|
|
1626
|
+
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedProof<Proof.RegisterMessage>>;
|
|
1627
|
+
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedProof<Proof.DeleteMessage>>;
|
|
1628
|
+
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<SignedProof<Proof.GetPendingTxMessage>>;
|
|
1625
1629
|
/**
|
|
1626
1630
|
* Finalizes pending transactions by retrieving them from the server and finalizing each one.
|
|
1627
1631
|
* Skips the server check entirely when no send was interrupted (no pending tx flag set).
|
|
@@ -1784,7 +1788,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1784
1788
|
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[], now?: TimeHeight): Promise<string>;
|
|
1785
1789
|
/**
|
|
1786
1790
|
* Build an offchain transaction from the given inputs and outputs,
|
|
1787
|
-
* sign it, submit to the
|
|
1791
|
+
* sign it, submit to the operator provider, and finalize.
|
|
1788
1792
|
*
|
|
1789
1793
|
* Signs whatever it is handed, ungated — see {@link settle} for the trade.
|
|
1790
1794
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { W as WalletRepository, P as PageRequest,
|
|
2
|
-
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
1
|
+
import { W as WalletRepository, P as PageRequest, F as Outpoint, H as PageResult, D as ExtendedVirtualCoin, J as ScriptVtxoCursor, K as ScriptVtxoPageOptions, L as StoredVtxo, M as VtxoRepositoryKey, E as ExtendedCoin, Q as TransactionHistoryPageFilter, U as TransactionHistoryPageCursor, h as ArkTransaction, X as AtomicWalletState, Y as WalletState, a5 as DescriptorProvider, a6 as DescriptorSigningRequest, a7 as Transaction, l as GetNewAddressesOptions, m as NewAddress, a as Identity, x as RelativeTimelock, a8 as Network, a9 as BatchStartedEvent, aa as TreeSigningStartedEvent, ab as TxTree, ac as TreeNoncesEvent, ad as BatchFinalizationEvent, ae as BatchFinalizedEvent, af as BatchFailedEvent, ag as TreeTxEvent, ah as TreeSignatureEvent, o as SettlementEvent, b as WalletConfig, C as ContractRepository, k as IContractManager, ai as IReadonlyWallet, aj as ReadonlyIdentity, ak as OnchainProvider, O as OperatorProvider, w as IndexerProvider, al as DelegateProvider, am as ReadonlyWalletConfig, _ as IntentRepository, a1 as VirtualTxRepository, an as ExitCaptureMode, ao as ExitDataSource, i as ActivityRegistry, ap as IReadonlyAssetManager, aq as ContractSyncState, ar as RecipientArkadeAddressContext, G as GetArkadeInfoOptions, A as ArkadeInfo, c as ArkadeReader, as as EsploraProvider, at as NetworkName, au as OperatorInfo, av as ArkAddress, e as WalletBalance, f as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, g as GetSpendableVtxosFilter, aw as ContractWithVtxos, ax as selectPendingRecoveryOutpoints, j as Activity, ay as Coin, az as ContractManager, aA as ContractManagerConfig, I as IWallet, aB as CSVMultisigTapscript, aC as SettlementConfig, d as ArkadeBroadcaster, q as IAssetManager, aD as VtxoManager, n as IDelegateManager, S as SettleParams, R as Recipient, aE as SignerSession, aF as SignedIntent, aG as Intent, aH as SignedProof, aI as Proof, p as SendParams, aJ as TimeHeight } from './index-DRwe0UDN.cjs';
|
|
3
2
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
|
-
import {
|
|
3
|
+
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
4
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-f4_t864Z.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* IndexedDB-based implementation of WalletRepository.
|
|
@@ -9,7 +9,10 @@ import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-Cd28gxpM.js';
|
|
|
9
9
|
declare class IndexedDBWalletRepository implements WalletRepository {
|
|
10
10
|
readonly version: 2;
|
|
11
11
|
private readonly connection;
|
|
12
|
-
|
|
12
|
+
/** persistentWalletState asserts persistence beyond this process; it cannot detect browser eviction. */
|
|
13
|
+
constructor(dbName?: string, options?: {
|
|
14
|
+
persistentWalletState?: boolean;
|
|
15
|
+
});
|
|
13
16
|
clear(): Promise<void>;
|
|
14
17
|
[Symbol.asyncDispose](): Promise<void>;
|
|
15
18
|
getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
|
|
@@ -25,6 +28,7 @@ declare class IndexedDBWalletRepository implements WalletRepository {
|
|
|
25
28
|
getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
|
|
26
29
|
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
27
30
|
deleteTransactions(address: string): Promise<void>;
|
|
31
|
+
readonly atomicWalletState: AtomicWalletState;
|
|
28
32
|
getWalletState(): Promise<WalletState | null>;
|
|
29
33
|
saveWalletState(state: WalletState): Promise<void>;
|
|
30
34
|
private getDB;
|
|
@@ -431,7 +435,7 @@ type ServerInfoSource = "live" | "cache";
|
|
|
431
435
|
* const handler = wallet.createBatchHandler(intentId, inputs, expectedRecipients, musig2session);
|
|
432
436
|
*
|
|
433
437
|
* const abortController = new AbortController();
|
|
434
|
-
* // Get event stream from the
|
|
438
|
+
* // Get event stream from the operator provider
|
|
435
439
|
* const eventStream = arkProvider.getEventStream(
|
|
436
440
|
* abortController.signal,
|
|
437
441
|
* ['your-topic-1', 'your-topic-2']
|
|
@@ -831,7 +835,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
831
835
|
readonly network: Network;
|
|
832
836
|
readonly onchainProvider: OnchainProvider;
|
|
833
837
|
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
834
|
-
protected readonly arkProvider: Pick<
|
|
838
|
+
protected readonly arkProvider: Pick<OperatorProvider, "getInfo">;
|
|
835
839
|
readonly indexerProvider: IndexerProvider;
|
|
836
840
|
readonly dustAmount: bigint;
|
|
837
841
|
readonly walletRepository: WalletRepository;
|
|
@@ -905,7 +909,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
905
909
|
getContractSyncState(): ContractSyncState;
|
|
906
910
|
protected constructor(identity: ReadonlyIdentity, network: Network, onchainProvider: OnchainProvider,
|
|
907
911
|
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
908
|
-
arkProvider: Pick<
|
|
912
|
+
arkProvider: Pick<OperatorProvider, "getInfo">, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider | undefined, watcherConfig?: ReadonlyWalletConfig["watcherConfig"], walletContractTimelocks?: RelativeTimelock[]);
|
|
909
913
|
/**
|
|
910
914
|
* x-only hex → cutoff of the operator's deprecated signers, cached for OFFLINE read/watch.
|
|
911
915
|
* Boarding watch/history fan out over {current} ∪ this set so deposits at addresses minted
|
|
@@ -974,7 +978,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
974
978
|
protected notifyBoardingRotation(): void;
|
|
975
979
|
/** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
|
|
976
980
|
protected static setupWalletConfig(config: ReadonlyWalletConfig, pubKey: Uint8Array): Promise<{
|
|
977
|
-
arkProvider:
|
|
981
|
+
arkProvider: OperatorProvider;
|
|
978
982
|
indexerProvider: IndexerProvider;
|
|
979
983
|
onchainProvider: OnchainProvider | EsploraProvider;
|
|
980
984
|
network: Network;
|
|
@@ -985,7 +989,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
985
989
|
dustAmount: bigint;
|
|
986
990
|
walletRepository: WalletRepository | IndexedDBWalletRepository;
|
|
987
991
|
contractRepository: ContractRepository;
|
|
988
|
-
info:
|
|
992
|
+
info: OperatorInfo;
|
|
989
993
|
serverInfoSource: ServerInfoSource;
|
|
990
994
|
serverInfoLastOnlineAt: number | undefined;
|
|
991
995
|
delegateProvider: DelegateProvider | undefined;
|
|
@@ -1214,14 +1218,14 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1214
1218
|
* // Create a wallet with providers
|
|
1215
1219
|
* const wallet = await Wallet.create({
|
|
1216
1220
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
1217
|
-
*
|
|
1221
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
1218
1222
|
* onchainProvider: new EsploraProvider()
|
|
1219
1223
|
* });
|
|
1220
1224
|
*
|
|
1221
1225
|
* // Use custom providers and/or URLs (e.g., for Expo/React Native)
|
|
1222
1226
|
* const wallet = await Wallet.create({
|
|
1223
1227
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
1224
|
-
*
|
|
1228
|
+
* operatorProvider: new ExpoOperatorProvider('https://arkade.computer'),
|
|
1225
1229
|
* indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
|
|
1226
1230
|
* onchainProvider: new EsploraProvider('https://mempool.space/api')
|
|
1227
1231
|
* });
|
|
@@ -1521,13 +1525,13 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1521
1525
|
/** @see WalletConfig.concurrentSpending */
|
|
1522
1526
|
get concurrentSpending(): boolean;
|
|
1523
1527
|
/** Public here; `ReadonlyWallet` keeps it protected so a readonly view can't submit. */
|
|
1524
|
-
readonly arkProvider:
|
|
1528
|
+
readonly arkProvider: OperatorProvider;
|
|
1525
1529
|
/**
|
|
1526
1530
|
* Broadcast access bound to this wallet's server, so a plugin needs only the wallet. Not on
|
|
1527
1531
|
* {@link ReadonlyWallet}: a readonly wallet or `toReadonly()` view must not be able to submit.
|
|
1528
1532
|
*/
|
|
1529
1533
|
getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
|
|
1530
|
-
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider:
|
|
1534
|
+
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider: OperatorProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, serverUnrollScript: CSVMultisigTapscript.Type, forfeitOutputScript: Bytes, forfeitPubkey: Bytes, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider, watcherConfig?: WalletConfig["watcherConfig"], settlementConfig?: WalletConfig["settlementConfig"], walletContractTimelocks?: RelativeTimelock[], receiveRotator?: WalletReceiveRotator, descriptorProvider?: DescriptorProvider, keyring?: KeyringDescriptorProvider, lookAheadWindow?: number,
|
|
1531
1535
|
/** Overrides for the `batchExpiry` bounds; defaults derive from `network`. */
|
|
1532
1536
|
batchExpiryPolicy?: Partial<BatchExpiryPolicy> | undefined,
|
|
1533
1537
|
/** @see WalletConfig.oneShotSubmit */
|
|
@@ -1544,7 +1548,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1544
1548
|
* ```typescript
|
|
1545
1549
|
* const wallet = await Wallet.create({
|
|
1546
1550
|
* identity,
|
|
1547
|
-
*
|
|
1551
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
1548
1552
|
* });
|
|
1549
1553
|
* ```
|
|
1550
1554
|
*/
|
|
@@ -1619,9 +1623,9 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1619
1623
|
signInputsByWitnessScript(tx: Transaction): Promise<Transaction>;
|
|
1620
1624
|
signOnchainBoardingTx(tx: Transaction): Promise<Transaction>;
|
|
1621
1625
|
safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
|
|
1622
|
-
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<
|
|
1623
|
-
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<
|
|
1624
|
-
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<
|
|
1626
|
+
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedProof<Proof.RegisterMessage>>;
|
|
1627
|
+
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedProof<Proof.DeleteMessage>>;
|
|
1628
|
+
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<SignedProof<Proof.GetPendingTxMessage>>;
|
|
1625
1629
|
/**
|
|
1626
1630
|
* Finalizes pending transactions by retrieving them from the server and finalizing each one.
|
|
1627
1631
|
* Skips the server check entirely when no send was interrupted (no pending tx flag set).
|
|
@@ -1784,7 +1788,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1784
1788
|
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[], now?: TimeHeight): Promise<string>;
|
|
1785
1789
|
/**
|
|
1786
1790
|
* Build an offchain transaction from the given inputs and outputs,
|
|
1787
|
-
* sign it, submit to the
|
|
1791
|
+
* sign it, submit to the operator provider, and finalize.
|
|
1788
1792
|
*
|
|
1789
1793
|
* Signs whatever it is handed, ungated — see {@link settle} for the trade.
|
|
1790
1794
|
*
|
|
@@ -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 chunkB6VNKGIH_cjs = require('../../chunk-B6VNKGIH.cjs');
|
|
4
|
+
require('../../chunk-F3FAE7VJ.cjs');
|
|
5
|
+
require('../../chunk-WXNSISXK.cjs');
|
|
6
|
+
require('../../chunk-E6OOJEHL.cjs');
|
|
7
|
+
require('../../chunk-GHUUT54D.cjs');
|
|
8
8
|
|
|
9
9
|
// src/worker/expo/taskQueue.ts
|
|
10
10
|
var InMemoryTaskQueue = class {
|
|
@@ -120,19 +120,19 @@ var AsyncStorageTaskQueue = class {
|
|
|
120
120
|
|
|
121
121
|
Object.defineProperty(exports, "CONTRACT_POLL_TASK_TYPE", {
|
|
122
122
|
enumerable: true,
|
|
123
|
-
get: function () { return
|
|
123
|
+
get: function () { return chunkB6VNKGIH_cjs.CONTRACT_POLL_TASK_TYPE; }
|
|
124
124
|
});
|
|
125
125
|
Object.defineProperty(exports, "contractPollProcessor", {
|
|
126
126
|
enumerable: true,
|
|
127
|
-
get: function () { return
|
|
127
|
+
get: function () { return chunkB6VNKGIH_cjs.contractPollProcessor; }
|
|
128
128
|
});
|
|
129
129
|
Object.defineProperty(exports, "createTaskDependencies", {
|
|
130
130
|
enumerable: true,
|
|
131
|
-
get: function () { return
|
|
131
|
+
get: function () { return chunkB6VNKGIH_cjs.createTaskDependencies; }
|
|
132
132
|
});
|
|
133
133
|
Object.defineProperty(exports, "runTasks", {
|
|
134
134
|
enumerable: true,
|
|
135
|
-
get: function () { return
|
|
135
|
+
get: function () { return chunkB6VNKGIH_cjs.runTasks; }
|
|
136
136
|
});
|
|
137
137
|
exports.AsyncStorageTaskQueue = AsyncStorageTaskQueue;
|
|
138
138
|
exports.InMemoryTaskQueue = InMemoryTaskQueue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { T as TaskProcessor } from '../../taskRunner-
|
|
2
|
-
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue,
|
|
3
|
-
export {
|
|
4
|
-
import '../../index-
|
|
1
|
+
import { T as TaskProcessor } from '../../taskRunner-BPPU-YHG.cjs';
|
|
2
|
+
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, a as TaskDependencies, b as TaskItem, c as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-BPPU-YHG.cjs';
|
|
3
|
+
export { A as AsyncStorageLike, a as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-DTBa8EH7.cjs';
|
|
4
|
+
import '../../index-DRwe0UDN.cjs';
|
|
5
5
|
import '@scure/btc-signer/utils.js';
|
|
6
6
|
import '@scure/btc-signer/psbt.js';
|
|
7
7
|
import '@scure/btc-signer';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { T as TaskProcessor } from '../../taskRunner-
|
|
2
|
-
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue,
|
|
3
|
-
export {
|
|
4
|
-
import '../../index-
|
|
1
|
+
import { T as TaskProcessor } from '../../taskRunner-CDlNeth0.js';
|
|
2
|
+
export { C as CreateTaskDependenciesOptions, I as InMemoryTaskQueue, a as TaskDependencies, b as TaskItem, c as TaskQueue, d as TaskResult, e as createTaskDependencies, r as runTasks } from '../../taskRunner-CDlNeth0.js';
|
|
3
|
+
export { A as AsyncStorageLike, a as AsyncStorageTaskQueue } from '../../asyncStorageTaskQueue-DHMIxY04.js';
|
|
4
|
+
import '../../index-DRwe0UDN.js';
|
|
5
5
|
import '@scure/btc-signer/utils.js';
|
|
6
6
|
import '@scure/btc-signer/psbt.js';
|
|
7
7
|
import '@scure/btc-signer';
|
|
@@ -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-MWVAWFX6.js';
|
|
2
|
+
import '../../chunk-ZJHLLDBP.js';
|
|
3
|
+
import '../../chunk-BTRCN4JJ.js';
|
|
4
|
+
import '../../chunk-6CUP6ZIF.js';
|
|
5
|
+
import '../../chunk-AG4TFD6F.js';
|
|
6
6
|
|
|
7
7
|
// src/worker/expo/taskQueue.ts
|
|
8
8
|
var InMemoryTaskQueue = class {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/worker/expo/taskRunner.ts","../src/worker/expo/processors/contractPollProcessor.ts"],"names":["getRandomId","extendVirtualCoinForContract","collectContracts","getNormalizedVtxos","warnAndFilterVtxosForScript","saveVtxosForContract"],"mappings":"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","file":"chunk-5WRA66RV.cjs","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 { collectContracts } from \"../../../repositories/contractRepository\";\nimport type { TaskItem, TaskResult } from \"../taskQueue\";\nimport type { TaskProcessor, TaskDependencies } from \"../taskRunner\";\nimport type { ExtendedVirtualCoin } from \"../../../wallet\";\nimport { getNormalizedVtxos } from \"../../../wallet/vtxo\";\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 every watched contract 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 // Background channel, so it covers exactly what the watcher's\n // subscription covers: `retained` rows are kept for reads only.\n const contracts = await collectContracts(contractRepository, {\n watch: [\"watched\", \"awaiting-funds\"],\n });\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 getNormalizedVtxos(indexerProvider, {\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"]}
|