@arkade-os/sdk 0.5.0-rc.9 → 0.5.0
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 +231 -50
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +5 -5
- package/dist/adapters/expo.d.ts +5 -5
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-DZYrAWN8.d.ts → asyncStorageTaskQueue-BFv2O1y1.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-ChKX-D51.d.cts → asyncStorageTaskQueue-qRRQUOE8.d.cts} +2 -2
- package/dist/{chunk-PKD5VPYX.cjs → chunk-AU77RYOC.cjs} +6086 -4522
- package/dist/chunk-AU77RYOC.cjs.map +1 -0
- package/dist/{chunk-VMVHRKXM.cjs → chunk-GN2K4WBP.cjs} +494 -1122
- package/dist/chunk-GN2K4WBP.cjs.map +1 -0
- package/dist/{chunk-PO2ZDZZC.cjs → chunk-GOM26K6H.cjs} +12 -10
- package/dist/chunk-GOM26K6H.cjs.map +1 -0
- package/dist/{chunk-3TCWQPAC.js → chunk-GWJWXVUB.js} +5793 -4249
- package/dist/chunk-GWJWXVUB.js.map +1 -0
- package/dist/{chunk-J2K7WWMJ.js → chunk-HABGVRLF.js} +112 -243
- package/dist/chunk-HABGVRLF.js.map +1 -0
- package/dist/{chunk-V4JZOFYT.cjs → chunk-IQWLFYT2.cjs} +124 -254
- package/dist/chunk-IQWLFYT2.cjs.map +1 -0
- package/dist/{chunk-7OL2P5TV.cjs → chunk-JT5YVMCJ.cjs} +39 -46
- package/dist/chunk-JT5YVMCJ.cjs.map +1 -0
- package/dist/{chunk-FQCMEAWN.js → chunk-K2E6X6JT.js} +32 -39
- package/dist/chunk-K2E6X6JT.js.map +1 -0
- package/dist/{chunk-R4KRWX7R.js → chunk-K352GMVL.js} +427 -1078
- package/dist/chunk-K352GMVL.js.map +1 -0
- package/dist/{chunk-Z3QM5XFY.js → chunk-TZSKLERU.js} +7 -5
- package/dist/chunk-TZSKLERU.js.map +1 -0
- package/dist/{chunk-VTXMC4N7.cjs → chunk-UUSKJOSX.cjs} +548 -399
- package/dist/chunk-UUSKJOSX.cjs.map +1 -0
- package/dist/{chunk-JFZBKPSV.js → chunk-ZOEB53NQ.js} +541 -400
- package/dist/chunk-ZOEB53NQ.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +5 -5
- package/dist/contracts/handlers/index.d.ts +5 -5
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-Cyv2suFd.d.cts → delegate-B5BmYkEY.d.cts} +1 -1
- package/dist/{delegate-CyBnNY9v.d.ts → delegate-DNbiUgy8.d.ts} +1 -1
- package/dist/index-B4QuO9sH.d.cts +645 -0
- package/dist/index-CYeyT3kn.d.ts +645 -0
- package/dist/{index-BIL9boGL.d.ts → index-CZw-MMfY.d.cts} +1644 -2291
- package/dist/{index-BIL9boGL.d.cts → index-CZw-MMfY.d.ts} +1644 -2291
- package/dist/index.cjs +399 -311
- package/dist/index.d.cts +950 -1124
- package/dist/index.d.ts +950 -1124
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +165 -103
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +18 -14
- package/dist/repositories/realm/index.d.ts +18 -14
- package/dist/repositories/realm/index.js +153 -91
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +226 -184
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +22 -21
- package/dist/repositories/sqlite/index.d.ts +22 -21
- package/dist/repositories/sqlite/index.js +218 -176
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-DxpSuKmh.d.cts → taskRunner-B3SLvUfL.d.cts} +2 -2
- package/dist/{taskRunner-Cu4uO1to.d.ts → taskRunner-wm1bhmtP.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +10 -16
- package/dist/wallet/expo/background.d.ts +10 -16
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +19 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +8 -6
- package/dist/wallet/expo/index.d.ts +8 -6
- package/dist/wallet/expo/index.js +10 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/wallet-DCZ2-Bea.d.cts +1874 -0
- package/dist/wallet-DGLXuwXT.d.ts +1874 -0
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +6 -6
- package/dist/worker/expo/index.d.ts +6 -6
- package/dist/worker/expo/index.js +5 -5
- package/package.json +10 -11
- package/dist/chunk-3TCWQPAC.js.map +0 -1
- package/dist/chunk-7OL2P5TV.cjs.map +0 -1
- package/dist/chunk-FQCMEAWN.js.map +0 -1
- package/dist/chunk-J2K7WWMJ.js.map +0 -1
- package/dist/chunk-JFZBKPSV.js.map +0 -1
- package/dist/chunk-PKD5VPYX.cjs.map +0 -1
- package/dist/chunk-PO2ZDZZC.cjs.map +0 -1
- package/dist/chunk-R4KRWX7R.js.map +0 -1
- package/dist/chunk-V4JZOFYT.cjs.map +0 -1
- package/dist/chunk-VMVHRKXM.cjs.map +0 -1
- package/dist/chunk-VTXMC4N7.cjs.map +0 -1
- package/dist/chunk-Z3QM5XFY.js.map +0 -1
- package/dist/hdWalletCapable-D1ImQqlu.d.cts +0 -2214
- package/dist/hdWalletCapable-DvumVrKW.d.ts +0 -2214
- package/dist/index-DleNQcz5.d.cts +0 -850
- package/dist/index-QVhQgYvU.d.ts +0 -850
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS,
|
|
2
|
-
export { ChainTxType, DEFAULT_VTXO_PAGE_SIZE, IndexerTxType, RestIndexerProvider, asset_exports as asset } from './chunk-
|
|
3
|
-
export { ArkadeContractHandler, BoardingContractHandler, DefaultContractHandler, DefaultVtxo, DelegateContractHandler, DelegateVtxo, VHTLC, VHTLCContractHandler, VHTLCV2ContractHandler, contractHandlers, deriveDescriptorLeafCompressedPubKey, deriveDescriptorLeafPubKey, identityDescriptor, isCltvSatisfied, isCsvSpendable, normalizeToDescriptor, parseHDDescriptor, toXOnly } from './chunk-
|
|
4
|
-
export { ArkAddress, ArkError, ArkErrorName, ArkPsbtFieldKey, ArkPsbtFieldKeyType, BITCOIN_EMULATOR_PUBKEY, CLTVMultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, ConditionWitness, CosignerPublicKey, DigestMismatchError, EventSourceUnavailableError, FetchError, Intent, MUTINYNET_EMULATOR_PUBKEY, MultisigTapscript, PrevArkTxField, PrevoutTxField, ProviderUnavailableError, READ_TIMEOUT_MS, REGTEST_EMULATOR_PUBKEY, RestArkProvider, ServerResponseMismatchError, SettlementEventType, TapTreeCoder, Transaction, VtxoScript, VtxoTaprootTree, VtxoTreeExpiry, assembleBtcdTaprootTree, assertAllowedSighashTypes, buildVersion, canRecoverOnchain, canSpendOffchain, canSweepOnchain, configureEventSource, decodeTapscript, defaultEmulatorPubkey, getAllNormalizedVtxos, getArkPsbtFields, getConfiguredEventSource, getNetwork, getNormalizedVtxos, getSequence,
|
|
1
|
+
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, Arkade, ArkadeCash, ArkadeCashCreateError, ArkadeCashOperatorMismatchError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, ForeignDescriptorError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, KeyringDescriptorProvider, MAX_PAGE_SIZE, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, OversizedChangeError, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestEmulatorProvider, SeedIdentity, SendDeadlineExceededError, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, StaticDescriptorProvider, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, VtxoReservedError, Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, arkade_exports as arkade, assertFinalCommitmentMatchesValidated, assertNoAssets, assertNoSelection, assertPageRequest, assertRecipientArkadeAddress, assertSendDeadline, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, captureSendDeadline, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, collectContracts, collectIntents, collectPages, collectScriptVtxos, collectTransactionHistory, collectUtxos, collectVtxos, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, decodeArkContract, defaultBatchExpiryPolicy, deleteByIndex, deserializeExitPackage, encodeArkContract, exitObserverFor, gateExclusion, gatedContracts, getAllByIndexValues, getRandomId, hasBoardingTxExpired, hasCandidates, invoiceTarget, isAddressAllocationCapable, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isContractVtxoEvent, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, iteratePages, logExcludedVtxos, makeHandle, matchServerCheckpoints, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, pageResult, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, resolveAssetAmount, resolveBatchExpiryPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, selectCoinsWithAsset, selectVirtualCoins, selectionOf, serializeExitPackage, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, submitViaEmulator, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, withPrevTxs } from './chunk-GWJWXVUB.js';
|
|
2
|
+
export { ChainTxType, DEFAULT_VTXO_PAGE_SIZE, IndexerTxType, RestIndexerProvider, asset_exports as asset } from './chunk-HABGVRLF.js';
|
|
3
|
+
export { ArkadeContractHandler, BoardingContractHandler, DefaultContractHandler, DefaultVtxo, DelegateContractHandler, DelegateVtxo, UnsupportedProgramVersionError, VHTLC, VHTLCContractHandler, VHTLCV2ContractHandler, contractHandlers, deriveDescriptorLeafCompressedPubKey, deriveDescriptorLeafPubKey, identityDescriptor, isCltvSatisfied, isCsvSpendable, normalizeToDescriptor, parseHDDescriptor, toXOnly } from './chunk-K352GMVL.js';
|
|
4
|
+
export { ArkAddress, ArkError, ArkErrorName, ArkPsbtFieldKey, ArkPsbtFieldKeyType, BITCOIN_EMULATOR_PUBKEY, CLTVMultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, ConditionWitness, CosignerPublicKey, DEFAULT_ARKADE_EMULATOR_URL, DigestMismatchError, EventSourceUnavailableError, FetchError, Intent, MUTINYNET_EMULATOR_PUBKEY, MultisigTapscript, PrevArkTxField, PrevoutTxField, ProviderUnavailableError, READ_TIMEOUT_MS, REGTEST_EMULATOR_PUBKEY, RestArkProvider, ServerResponseMismatchError, SettlementEventType, TapTreeCoder, Transaction, VtxoScript, VtxoTaprootTree, VtxoTreeExpiry, assembleBtcdTaprootTree, assertAllowedSighashTypes, assertNonNegativeMs, assertTimerMs, buildVersion, canRecoverOnchain, canSpendOffchain, canSweepOnchain, configureEventSource, decodeTapscript, defaultEmulatorPubkey, getAllNormalizedVtxos, getArkPsbtFields, getConfiguredEventSource, getNetwork, getNormalizedVtxos, getSequence, isArkError, isEventSourceUnavailableError, isPastExpiry, isRetryableProviderError, isVirtualCoin, isVtxoSpent, maybeArkError, networkFromArkadeInfo, networks, resolveEmulatorPubkey, resolveEventSource, scriptFromTapLeafScript, sdkVersion, sequenceToTimelock, setArkPsbtField, timelockToSequence, toOffchainInputFeeParams } from './chunk-ZOEB53NQ.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
5
|
-
require('../../chunk-
|
|
6
|
-
require('../../chunk-
|
|
3
|
+
var chunkAU77RYOC_cjs = require('../../chunk-AU77RYOC.cjs');
|
|
4
|
+
require('../../chunk-IQWLFYT2.cjs');
|
|
5
|
+
require('../../chunk-GN2K4WBP.cjs');
|
|
6
|
+
var chunkUUSKJOSX_cjs = require('../../chunk-UUSKJOSX.cjs');
|
|
7
7
|
|
|
8
8
|
// src/repositories/realm/walletRepository.ts
|
|
9
9
|
var RealmWalletRepository = class {
|
|
@@ -11,7 +11,7 @@ var RealmWalletRepository = class {
|
|
|
11
11
|
this.realm = realm;
|
|
12
12
|
}
|
|
13
13
|
realm;
|
|
14
|
-
version =
|
|
14
|
+
version = 2;
|
|
15
15
|
// ── Lifecycle ──────────────────────────────────────────────────────
|
|
16
16
|
async ensureInit() {
|
|
17
17
|
}
|
|
@@ -28,16 +28,14 @@ var RealmWalletRepository = class {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
// ── VTXO management ────────────────────────────────────────────────
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
const results = this.realm.objects("ArkVtxo").filtered("address == $0", address);
|
|
34
|
-
return [...results].map(vtxoObjectToDomain);
|
|
31
|
+
async getVtxosPage(address, page) {
|
|
32
|
+
return this.pageByAddress("ArkVtxo", address, page, vtxoObjectToDomain);
|
|
35
33
|
}
|
|
36
34
|
async saveVtxos(address, vtxos) {
|
|
37
35
|
await this.ensureInit();
|
|
38
36
|
this.realm.write(() => {
|
|
39
37
|
for (const vtxo of vtxos) {
|
|
40
|
-
const s =
|
|
38
|
+
const s = chunkAU77RYOC_cjs.serializeVtxo(vtxo);
|
|
41
39
|
this.realm.create(
|
|
42
40
|
"ArkVtxo",
|
|
43
41
|
{
|
|
@@ -52,13 +50,13 @@ var RealmWalletRepository = class {
|
|
|
52
50
|
intentCb: s.intentTapLeafScript.cb,
|
|
53
51
|
intentS: s.intentTapLeafScript.s,
|
|
54
52
|
statusJson: JSON.stringify(s.status),
|
|
55
|
-
createdAt:
|
|
53
|
+
createdAt: chunkAU77RYOC_cjs.createdAtToIso(s.createdAt),
|
|
56
54
|
isUnrolled: s.isUnrolled ?? false,
|
|
57
55
|
isSpent: s.isSpent === void 0 ? null : s.isSpent,
|
|
58
56
|
isSwept: s.isSwept === void 0 ? null : s.isSwept,
|
|
59
57
|
isPreconfirmed: s.isPreconfirmed === void 0 ? null : s.isPreconfirmed,
|
|
60
58
|
commitmentTxIdsJson: s.commitmentTxIds ? JSON.stringify(s.commitmentTxIds) : null,
|
|
61
|
-
expiresAt: s.expiresAt === void 0 ? null :
|
|
59
|
+
expiresAt: s.expiresAt === void 0 ? null : new Date(s.expiresAt).toISOString(),
|
|
62
60
|
expiresAtHeight: s.expiresAtHeight ?? null,
|
|
63
61
|
spentBy: s.spentBy ?? null,
|
|
64
62
|
settledBy: s.settledBy ?? null,
|
|
@@ -73,48 +71,84 @@ var RealmWalletRepository = class {
|
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
73
|
async deleteVtxos(address) {
|
|
76
|
-
|
|
77
|
-
this.realm.write(() => {
|
|
78
|
-
const toDelete = this.realm.objects("ArkVtxo").filtered("address == $0", address);
|
|
79
|
-
this.realm.delete(toDelete);
|
|
80
|
-
});
|
|
74
|
+
return this.deleteWhere("ArkVtxo", "address", address);
|
|
81
75
|
}
|
|
82
|
-
async
|
|
76
|
+
async getVtxosForScriptPage(script, page, options) {
|
|
77
|
+
chunkAU77RYOC_cjs.assertPageRequest(page);
|
|
83
78
|
await this.ensureInit();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
let results = this.realm.objects("ArkVtxo").filtered("script == $0", script);
|
|
80
|
+
if (options?.unspentOnly) {
|
|
81
|
+
results = results.filtered(
|
|
82
|
+
"(isSpent == null OR isSpent == $0) AND (spentBy == null OR spentBy == $1) AND (settledBy == null OR settledBy == $1)",
|
|
83
|
+
false,
|
|
84
|
+
""
|
|
85
|
+
);
|
|
90
86
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
if (page.after) {
|
|
88
|
+
results = results.filtered(
|
|
89
|
+
"address > $0 OR (address == $0 AND (txid > $1 OR (txid == $1 AND vout > $2)))",
|
|
90
|
+
page.after.address,
|
|
91
|
+
page.after.txid,
|
|
92
|
+
page.after.vout
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const rows = [];
|
|
96
|
+
for (const row of results.sorted([
|
|
97
|
+
["address", false],
|
|
98
|
+
["txid", false],
|
|
99
|
+
["vout", false]
|
|
100
|
+
])) {
|
|
101
|
+
rows.push({ address: row.address, vtxo: vtxoObjectToDomain(row) });
|
|
102
|
+
if (rows.length > page.limit) break;
|
|
97
103
|
}
|
|
98
|
-
|
|
104
|
+
const result = chunkAU77RYOC_cjs.pageResult(rows, page.limit, (row) => ({
|
|
105
|
+
address: row.address,
|
|
106
|
+
txid: row.vtxo.txid,
|
|
107
|
+
vout: row.vtxo.vout
|
|
108
|
+
}));
|
|
109
|
+
return options?.unspentOnly ? { ...result, items: result.items.filter((row) => !chunkUUSKJOSX_cjs.isVtxoSpent(row.vtxo)) } : result;
|
|
110
|
+
}
|
|
111
|
+
async saveVtxosForScript(key, vtxos) {
|
|
112
|
+
return this.saveVtxos(chunkAU77RYOC_cjs.checkSaveVtxosForScript("RealmWalletRepository", key, vtxos), vtxos);
|
|
99
113
|
}
|
|
100
114
|
async deleteVtxosForScript(script) {
|
|
101
|
-
|
|
102
|
-
this.realm.write(() => {
|
|
103
|
-
const toDelete = this.realm.objects("ArkVtxo").filtered("script == $0", script);
|
|
104
|
-
this.realm.delete(toDelete);
|
|
105
|
-
});
|
|
115
|
+
return this.deleteWhere("ArkVtxo", "script", script);
|
|
106
116
|
}
|
|
107
117
|
// ── UTXO management ────────────────────────────────────────────────
|
|
108
|
-
async
|
|
118
|
+
async getUtxosPage(address, page) {
|
|
119
|
+
return this.pageByAddress("ArkUtxo", address, page, utxoObjectToDomain);
|
|
120
|
+
}
|
|
121
|
+
async pageByAddress(schema, address, page, deserialize) {
|
|
122
|
+
chunkAU77RYOC_cjs.assertPageRequest(page);
|
|
109
123
|
await this.ensureInit();
|
|
110
|
-
|
|
111
|
-
|
|
124
|
+
let results = this.realm.objects(schema).filtered("address == $0", address);
|
|
125
|
+
if (page.after) {
|
|
126
|
+
results = results.filtered(
|
|
127
|
+
"txid > $0 OR (txid == $0 AND vout > $1)",
|
|
128
|
+
page.after.txid,
|
|
129
|
+
page.after.vout
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const rows = [];
|
|
133
|
+
for (const row of results.sorted([
|
|
134
|
+
["txid", false],
|
|
135
|
+
["vout", false]
|
|
136
|
+
])) {
|
|
137
|
+
rows.push({ key: { txid: row.txid, vout: row.vout }, item: deserialize(row) });
|
|
138
|
+
if (rows.length > page.limit) break;
|
|
139
|
+
}
|
|
140
|
+
const result = chunkAU77RYOC_cjs.pageResult(rows, page.limit, (row) => row.key);
|
|
141
|
+
return { items: result.items.map((row) => row.item), nextCursor: result.nextCursor };
|
|
112
142
|
}
|
|
113
|
-
async saveUtxos(
|
|
143
|
+
async saveUtxos(addressOrBatch, utxos) {
|
|
114
144
|
await this.ensureInit();
|
|
145
|
+
const rows = chunkAU77RYOC_cjs.utxoEntries(addressOrBatch, utxos).flatMap(
|
|
146
|
+
([address, list]) => list.map((utxo) => ({ address, utxo }))
|
|
147
|
+
);
|
|
148
|
+
if (rows.length === 0) return;
|
|
115
149
|
this.realm.write(() => {
|
|
116
|
-
for (const utxo of
|
|
117
|
-
const s =
|
|
150
|
+
for (const { address, utxo } of rows) {
|
|
151
|
+
const s = chunkAU77RYOC_cjs.serializeUtxo(utxo);
|
|
118
152
|
this.realm.create(
|
|
119
153
|
"ArkUtxo",
|
|
120
154
|
{
|
|
@@ -137,19 +171,31 @@ var RealmWalletRepository = class {
|
|
|
137
171
|
});
|
|
138
172
|
}
|
|
139
173
|
async deleteUtxos(address) {
|
|
140
|
-
|
|
141
|
-
this.realm.write(() => {
|
|
142
|
-
const toDelete = this.realm.objects("ArkUtxo").filtered("address == $0", address);
|
|
143
|
-
this.realm.delete(toDelete);
|
|
144
|
-
});
|
|
174
|
+
return this.deleteWhere("ArkUtxo", "address", address);
|
|
145
175
|
}
|
|
146
176
|
// ── Transaction history ────────────────────────────────────────────
|
|
147
|
-
async
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
177
|
+
async getTransactionHistoryPage(filter, page) {
|
|
178
|
+
chunkAU77RYOC_cjs.assertPageRequest(page);
|
|
179
|
+
chunkAU77RYOC_cjs.assertHistoryPageFilter(filter);
|
|
180
|
+
let results = this.realm.objects("ArkTransaction").filtered("address == $0", filter.address);
|
|
181
|
+
results = results.filtered(
|
|
182
|
+
"createdAt >= $0",
|
|
183
|
+
Math.max(filter.since ?? 0, page.after?.createdAt ?? 0)
|
|
184
|
+
);
|
|
185
|
+
const rows = [];
|
|
186
|
+
for (const row of results.sorted([
|
|
187
|
+
["createdAt", false],
|
|
188
|
+
["boardingTxid", false],
|
|
189
|
+
["commitmentTxid", false],
|
|
190
|
+
["arkTxid", false]
|
|
191
|
+
])) {
|
|
192
|
+
const tx = txObjectToDomain(row);
|
|
193
|
+
if (page.after !== void 0 && chunkAU77RYOC_cjs.compareHistoryCursors({ createdAt: tx.createdAt, key: tx.key }, page.after) <= 0)
|
|
194
|
+
continue;
|
|
195
|
+
rows.push(tx);
|
|
196
|
+
if (rows.length > page.limit) break;
|
|
197
|
+
}
|
|
198
|
+
return chunkAU77RYOC_cjs.pageResult(rows, page.limit, (tx) => ({ createdAt: tx.createdAt, key: tx.key }));
|
|
153
199
|
}
|
|
154
200
|
async saveTransactions(address, txs) {
|
|
155
201
|
await this.ensureInit();
|
|
@@ -167,7 +213,7 @@ var RealmWalletRepository = class {
|
|
|
167
213
|
amount: tx.amount,
|
|
168
214
|
settled: tx.settled,
|
|
169
215
|
createdAt: tx.createdAt,
|
|
170
|
-
assetsJson: tx.assets ? JSON.stringify(
|
|
216
|
+
assetsJson: tx.assets ? JSON.stringify(chunkAU77RYOC_cjs.serializeAssets(tx.assets)) : null
|
|
171
217
|
},
|
|
172
218
|
"modified"
|
|
173
219
|
);
|
|
@@ -175,9 +221,12 @@ var RealmWalletRepository = class {
|
|
|
175
221
|
});
|
|
176
222
|
}
|
|
177
223
|
async deleteTransactions(address) {
|
|
224
|
+
return this.deleteWhere("ArkTransaction", "address", address);
|
|
225
|
+
}
|
|
226
|
+
async deleteWhere(objectType, field, value) {
|
|
178
227
|
await this.ensureInit();
|
|
179
228
|
this.realm.write(() => {
|
|
180
|
-
const toDelete = this.realm.objects(
|
|
229
|
+
const toDelete = this.realm.objects(objectType).filtered(`${field} == $0`, value);
|
|
181
230
|
this.realm.delete(toDelete);
|
|
182
231
|
});
|
|
183
232
|
}
|
|
@@ -241,9 +290,9 @@ function vtxoObjectToDomain(obj) {
|
|
|
241
290
|
// Post-migration every row has `script`, but the backfill is
|
|
242
291
|
// idempotent: derive from `address` if the legacy column is still
|
|
243
292
|
// null (e.g. the migration hasn't run yet on this handle).
|
|
244
|
-
script: obj.script ??
|
|
293
|
+
script: obj.script ?? chunkAU77RYOC_cjs.scriptFromArkAddress(obj.address)
|
|
245
294
|
};
|
|
246
|
-
return
|
|
295
|
+
return chunkAU77RYOC_cjs.deserializeVtxo(serialized);
|
|
247
296
|
}
|
|
248
297
|
function utxoObjectToDomain(obj) {
|
|
249
298
|
const serialized = {
|
|
@@ -262,7 +311,7 @@ function utxoObjectToDomain(obj) {
|
|
|
262
311
|
status: JSON.parse(obj.statusJson),
|
|
263
312
|
extraWitness: obj.extraWitnessJson ? JSON.parse(obj.extraWitnessJson) : void 0
|
|
264
313
|
};
|
|
265
|
-
return
|
|
314
|
+
return chunkAU77RYOC_cjs.deserializeUtxo(serialized);
|
|
266
315
|
}
|
|
267
316
|
function txObjectToDomain(obj) {
|
|
268
317
|
const tx = {
|
|
@@ -277,7 +326,7 @@ function txObjectToDomain(obj) {
|
|
|
277
326
|
createdAt: obj.createdAt
|
|
278
327
|
};
|
|
279
328
|
if (obj.assetsJson) {
|
|
280
|
-
tx.assets =
|
|
329
|
+
tx.assets = chunkAU77RYOC_cjs.deserializeAssets(JSON.parse(obj.assetsJson));
|
|
281
330
|
}
|
|
282
331
|
return tx;
|
|
283
332
|
}
|
|
@@ -288,7 +337,7 @@ var RealmContractRepository = class {
|
|
|
288
337
|
this.realm = realm;
|
|
289
338
|
}
|
|
290
339
|
realm;
|
|
291
|
-
version =
|
|
340
|
+
version = 3;
|
|
292
341
|
// ── Lifecycle ──────────────────────────────────────────────────────
|
|
293
342
|
async ensureInit() {
|
|
294
343
|
}
|
|
@@ -302,41 +351,47 @@ var RealmContractRepository = class {
|
|
|
302
351
|
});
|
|
303
352
|
}
|
|
304
353
|
// ── Contract management ────────────────────────────────────────────
|
|
305
|
-
async
|
|
306
|
-
|
|
354
|
+
async getContractsPage(filter, page) {
|
|
355
|
+
chunkAU77RYOC_cjs.assertPageRequest(page);
|
|
356
|
+
if (chunkAU77RYOC_cjs.contractFilterMatchesNothing(filter)) return { items: [] };
|
|
357
|
+
const toPage = (rows) => chunkAU77RYOC_cjs.pageResult(rows.map(contractObjectToDomain), page.limit, (contract) => contract.script);
|
|
358
|
+
if (filter?.watch === void 0 || filter.script !== void 0) {
|
|
359
|
+
return toPage(this.readRows(filter, page));
|
|
360
|
+
}
|
|
361
|
+
const merged = [...new Set([filter.watch].flat())].flatMap((state) => state === "watched" ? [state, null] : [state]).flatMap(
|
|
362
|
+
(state) => state === "retained" ? this.readRows({ ...filter, watch: state }, page) : this.readRows({ ...filter, watch: void 0 }, page, state)
|
|
363
|
+
).map((row) => ({ script: row.script, row })).sort((a, b) => a.script < b.script ? -1 : a.script > b.script ? 1 : 0);
|
|
364
|
+
return toPage(merged.slice(0, page.limit + 1).map(({ row }) => row));
|
|
365
|
+
}
|
|
366
|
+
/** Up to `limit + 1` rows in script order, led by `watch == leadingWatch` when one is given. */
|
|
367
|
+
readRows(filter, page, leadingWatch) {
|
|
307
368
|
let results = this.realm.objects("ArkContract");
|
|
369
|
+
const parts = [];
|
|
370
|
+
const args = [];
|
|
371
|
+
let argIndex = 0;
|
|
308
372
|
if (filter) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
argIndex = this.
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
filter.state,
|
|
324
|
-
argIndex
|
|
325
|
-
);
|
|
326
|
-
argIndex = this.addFilterCondition(
|
|
327
|
-
filterParts,
|
|
328
|
-
filterArgs,
|
|
329
|
-
"type",
|
|
330
|
-
filter.type,
|
|
331
|
-
argIndex
|
|
332
|
-
);
|
|
333
|
-
argIndex = this.addWatchCondition(filterParts, filterArgs, filter.watch, argIndex);
|
|
334
|
-
if (filterParts.length > 0) {
|
|
335
|
-
const query = filterParts.join(" AND ");
|
|
336
|
-
results = results.filtered(query, ...filterArgs);
|
|
337
|
-
}
|
|
373
|
+
argIndex = this.addFilterCondition(parts, args, "script", filter.script, argIndex);
|
|
374
|
+
argIndex = this.addFilterCondition(parts, args, "state", filter.state, argIndex);
|
|
375
|
+
argIndex = this.addFilterCondition(parts, args, "type", filter.type, argIndex);
|
|
376
|
+
argIndex = this.addWatchCondition(parts, args, filter.watch, argIndex);
|
|
377
|
+
}
|
|
378
|
+
if (page.after !== void 0) {
|
|
379
|
+
parts.push(`script > $${argIndex}`);
|
|
380
|
+
args.push(page.after);
|
|
381
|
+
}
|
|
382
|
+
let query = parts.join(" AND ");
|
|
383
|
+
if (leadingWatch !== void 0) {
|
|
384
|
+
const lead = leadingWatch === null ? "watch == null" : `watch == $${args.length}`;
|
|
385
|
+
if (leadingWatch !== null) args.push(leadingWatch);
|
|
386
|
+
query = query ? `${lead} AND (${query})` : lead;
|
|
338
387
|
}
|
|
339
|
-
|
|
388
|
+
if (query) results = results.filtered(query, ...args);
|
|
389
|
+
const rows = [];
|
|
390
|
+
for (const row of results.sorted("script")) {
|
|
391
|
+
rows.push(row);
|
|
392
|
+
if (rows.length > page.limit) break;
|
|
393
|
+
}
|
|
394
|
+
return rows;
|
|
340
395
|
}
|
|
341
396
|
async saveContract(contract) {
|
|
342
397
|
await this.ensureInit();
|
|
@@ -457,7 +512,7 @@ var RealmIntentRepository = class {
|
|
|
457
512
|
const clashes = [
|
|
458
513
|
...this.realm.objects("ArkIntent").filtered("intentId == $0", intent.intentId)
|
|
459
514
|
].map(toIntent);
|
|
460
|
-
|
|
515
|
+
chunkAU77RYOC_cjs.assertIntentIdUnique(intent, clashes);
|
|
461
516
|
}
|
|
462
517
|
this.realm.create(
|
|
463
518
|
"ArkIntent",
|
|
@@ -484,16 +539,23 @@ var RealmIntentRepository = class {
|
|
|
484
539
|
);
|
|
485
540
|
});
|
|
486
541
|
}
|
|
487
|
-
async
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
542
|
+
async getIntentsPage(filter, page) {
|
|
543
|
+
chunkAU77RYOC_cjs.assertPageRequest(page);
|
|
544
|
+
let results = this.realm.objects("ArkIntent");
|
|
545
|
+
if (page.after !== void 0) results = results.filtered("intentTxId > $0", page.after);
|
|
546
|
+
const rows = [];
|
|
547
|
+
for (const row of results.sorted("intentTxId")) {
|
|
548
|
+
const intent = toIntent(row);
|
|
549
|
+
if (filter && !chunkAU77RYOC_cjs.intentMatchesFilter(intent, filter)) continue;
|
|
550
|
+
rows.push(intent);
|
|
551
|
+
if (rows.length > page.limit) break;
|
|
552
|
+
}
|
|
553
|
+
return chunkAU77RYOC_cjs.pageResult(rows, page.limit, (intent) => intent.intentTxId);
|
|
492
554
|
}
|
|
493
555
|
async getLockedVtxoOutpoints() {
|
|
494
556
|
const out = [];
|
|
495
557
|
for (const o of [...this.realm.objects("ArkIntent")].map(toIntent))
|
|
496
|
-
if (!
|
|
558
|
+
if (!chunkAU77RYOC_cjs.isTerminalIntentState(o.state)) out.push(...o.intentVtxos);
|
|
497
559
|
return out;
|
|
498
560
|
}
|
|
499
561
|
async [Symbol.asyncDispose]() {
|
|
@@ -535,7 +597,7 @@ var RealmVirtualTxRepository = class {
|
|
|
535
597
|
txid: t.txid,
|
|
536
598
|
psbt: t.psbt ?? prev?.psbt ?? null,
|
|
537
599
|
expiresAt: t.expiresAt ?? prev?.expiresAt ?? null,
|
|
538
|
-
type:
|
|
600
|
+
type: chunkAU77RYOC_cjs.mergeChainedTxType(t.type, prev?.type)
|
|
539
601
|
},
|
|
540
602
|
"modified"
|
|
541
603
|
);
|
|
@@ -780,9 +842,9 @@ function runArkRealmMigrations(oldRealm, newRealm) {
|
|
|
780
842
|
for (let i = 0; i < newVtxos.length; i++) {
|
|
781
843
|
const newVtxo = newVtxos[i];
|
|
782
844
|
if (!newVtxo.script) {
|
|
783
|
-
newVtxo.script =
|
|
845
|
+
newVtxo.script = chunkAU77RYOC_cjs.scriptFromArkAddress(newVtxo.address);
|
|
784
846
|
}
|
|
785
|
-
const facts =
|
|
847
|
+
const facts = chunkAU77RYOC_cjs.legacyVtxoFacts(legacyByPk.get(newVtxo.pk));
|
|
786
848
|
if (facts) {
|
|
787
849
|
if (newVtxo.isSpent == null) newVtxo.isSpent = facts.isSpent;
|
|
788
850
|
if (newVtxo.isSwept == null) newVtxo.isSwept = facts.isSwept;
|
|
@@ -812,7 +874,7 @@ function runArkRealmMigrations(oldRealm, newRealm) {
|
|
|
812
874
|
|
|
813
875
|
Object.defineProperty(exports, "ChainedTxType", {
|
|
814
876
|
enumerable: true,
|
|
815
|
-
get: function () { return
|
|
877
|
+
get: function () { return chunkAU77RYOC_cjs.ChainedTxType; }
|
|
816
878
|
});
|
|
817
879
|
exports.ARK_REALM_SCHEMA_VERSION = ARK_REALM_SCHEMA_VERSION;
|
|
818
880
|
exports.ArkExperimentalRealmSchemas = ArkExperimentalRealmSchemas;
|