@arkade-os/sdk 0.4.50 → 0.4.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -8
- package/dist/adapters/expo.cjs +4 -4
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +2 -2
- package/dist/adapters/indexedDB.cjs +4 -4
- package/dist/adapters/indexedDB.js +3 -3
- package/dist/{ark-ApoclKQZ.d.cts → ark-B69ugeJw.d.cts} +133 -1
- package/dist/{ark-ApoclKQZ.d.ts → ark-B69ugeJw.d.ts} +133 -1
- package/dist/{asyncStorageTaskQueue-BCWmdVg8.d.ts → asyncStorageTaskQueue-BImF14sj.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-CIjgv1co.d.cts → asyncStorageTaskQueue-DScPdQAy.d.cts} +2 -2
- package/dist/{chunk-Q4K2RSMY.cjs → chunk-3Z5HK35D.cjs} +7 -7
- package/dist/{chunk-Q4K2RSMY.cjs.map → chunk-3Z5HK35D.cjs.map} +1 -1
- package/dist/{chunk-7WSVP7DK.js → chunk-3ZGANANS.js} +3 -3
- package/dist/{chunk-7WSVP7DK.js.map → chunk-3ZGANANS.js.map} +1 -1
- package/dist/{chunk-SNTSB6M2.js → chunk-AXCKRS2D.js} +354 -60
- package/dist/chunk-AXCKRS2D.js.map +1 -0
- package/dist/{chunk-TO3SR7TY.cjs → chunk-E6RT5XYB.cjs} +11 -11
- package/dist/{chunk-TO3SR7TY.cjs.map → chunk-E6RT5XYB.cjs.map} +1 -1
- package/dist/{chunk-SIAVTHMZ.cjs → chunk-FZPYPEWN.cjs} +3 -3
- package/dist/{chunk-SIAVTHMZ.cjs.map → chunk-FZPYPEWN.cjs.map} +1 -1
- package/dist/{chunk-LJQ2VQBE.cjs → chunk-IEMPH7J6.cjs} +52 -44
- package/dist/chunk-IEMPH7J6.cjs.map +1 -0
- package/dist/{chunk-6BQTROB4.cjs → chunk-ML33GFCH.cjs} +538 -243
- package/dist/chunk-ML33GFCH.cjs.map +1 -0
- package/dist/{chunk-MBSYQ3WX.js → chunk-UZLQUWYP.js} +52 -45
- package/dist/chunk-UZLQUWYP.js.map +1 -0
- package/dist/{chunk-ZXRSSBCF.js → chunk-WIVQWYPZ.js} +3 -3
- package/dist/{chunk-ZXRSSBCF.js.map → chunk-WIVQWYPZ.js.map} +1 -1
- package/dist/{chunk-AA4Q2J57.js → chunk-ZK3JITHP.js} +3 -3
- package/dist/{chunk-AA4Q2J57.js.map → chunk-ZK3JITHP.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +7 -7
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +1 -1
- package/dist/{delegate-hJYMZN1D.d.ts → delegate-BU-Cpyjw.d.ts} +1 -1
- package/dist/{delegate-CCHPwQft.d.cts → delegate-C_Y2YrXC.d.cts} +1 -1
- package/dist/{index-5Y9h9OnO.d.ts → index-BWF-C9eh.d.ts} +2 -2
- package/dist/{index-8jE1XJpT.d.cts → index-tzAInyiX.d.cts} +2 -2
- package/dist/index.cjs +161 -157
- package/dist/index.d.cts +24 -8
- package/dist/index.d.ts +24 -8
- package/dist/index.js +3 -3
- package/dist/repositories/realm/index.cjs +18 -18
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +4 -4
- package/dist/repositories/sqlite/index.cjs +17 -17
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +4 -4
- package/dist/{taskRunner-ChvV6Xrh.d.ts → taskRunner-Cf80BqSy.d.ts} +2 -2
- package/dist/{taskRunner-C3YLaM2x.d.cts → taskRunner-ClwI8jU8.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +13 -13
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +5 -5
- package/dist/wallet/expo/index.cjs +13 -13
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +4 -4
- package/dist/{wallet-DIH0gVfW.d.ts → wallet-B6Xiferv.d.cts} +33 -3
- package/dist/{wallet-B260BTJs.d.cts → wallet-CuHAI-eW.d.ts} +33 -3
- package/dist/worker/expo/index.cjs +8 -8
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-6BQTROB4.cjs.map +0 -1
- package/dist/chunk-LJQ2VQBE.cjs.map +0 -1
- package/dist/chunk-MBSYQ3WX.js.map +0 -1
- package/dist/chunk-SNTSB6M2.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transaction, setArkPsbtField, PrevArkTxField, ConditionWitness, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, craftToSpendTx, getArkPsbtFields, CosignerPublicKey, BufferReader, BufferWriter, OP_RETURN_EMPTY_PKSCRIPT, VtxoTaprootTree, baseFetch, Intent, rateGate, maybeArkError, isArkError, ArkErrorName, ProviderUnavailableError, FetchError, isFetchTimeoutError, AssetRef, isEventSourceError, RestArkProvider, RestIndexerProvider, ArkError } from './chunk-
|
|
2
|
-
import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, DefaultVtxo,
|
|
1
|
+
import { Transaction, setArkPsbtField, PrevArkTxField, ConditionWitness, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, craftToSpendTx, getArkPsbtFields, CosignerPublicKey, BufferReader, BufferWriter, OP_RETURN_EMPTY_PKSCRIPT, VtxoTaprootTree, baseFetch, Intent, rateGate, maybeArkError, isArkError, ArkErrorName, ProviderUnavailableError, FetchError, isFetchTimeoutError, AssetRef, isEventSourceError, RestArkProvider, RestIndexerProvider, ArkError } from './chunk-ZK3JITHP.js';
|
|
2
|
+
import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, deriveDescriptorLeafPubKey, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-UZLQUWYP.js';
|
|
3
3
|
import { VtxoScript, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, hasTerminalSpend, getNormalizedVtxos, isVirtualCoin, ArkAddress, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, timelockToSequence, DEFAULT_NETWORK_NAME, normalizeVtxo, getSequence, toBatchExpiry, toOffchainInputFeeParams, canRecoverOnchain, getNetwork, MultisigTapscript, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, canSpendOffchain, toVirtualStatus, resolveTimeHeight, parseLegacyExpiry, networks as networks$1, isExpired, DEFAULT_ARKADE_SERVER_URL, isPastExpiry } from './chunk-EFNLTS6Q.js';
|
|
4
4
|
import { __export } from './chunk-NSBPE2FW.js';
|
|
5
5
|
import { sha256, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
|
|
@@ -2589,6 +2589,9 @@ function parseProgram(text, env) {
|
|
|
2589
2589
|
}
|
|
2590
2590
|
|
|
2591
2591
|
// src/contracts/types.ts
|
|
2592
|
+
function hasCandidates(handler) {
|
|
2593
|
+
return !!handler && typeof handler.candidatesAt === "function";
|
|
2594
|
+
}
|
|
2592
2595
|
function isDiscoverable(handler) {
|
|
2593
2596
|
return !!handler && typeof handler.discoverAt === "function";
|
|
2594
2597
|
}
|
|
@@ -8713,6 +8716,9 @@ function dedupeOutpoints(outpoints) {
|
|
|
8713
8716
|
function areCoalescibleContractTypes(a, b) {
|
|
8714
8717
|
return a === "default" && b === "boarding" || a === "boarding" && b === "default";
|
|
8715
8718
|
}
|
|
8719
|
+
function toWatchOnlyContract(params) {
|
|
8720
|
+
return { ...params, state: params.state ?? "active", createdAt: Date.now() };
|
|
8721
|
+
}
|
|
8716
8722
|
var SCAN_MAX_INDEX = 1e4;
|
|
8717
8723
|
var DEFAULT_SCAN_BATCH = 10;
|
|
8718
8724
|
var ContractManager = class _ContractManager {
|
|
@@ -8725,6 +8731,12 @@ var ContractManager = class _ContractManager {
|
|
|
8725
8731
|
syncDegradedReason;
|
|
8726
8732
|
/** Epoch-ms of the last successful provider sync, if any. */
|
|
8727
8733
|
lastSyncedAt;
|
|
8734
|
+
/** Speculative look-ahead scripts, keyed by script. @see LookAheadEntry */
|
|
8735
|
+
lookAheadEntries = /* @__PURE__ */ new Map();
|
|
8736
|
+
/** In-flight look-ahead drain, if any. @see scheduleLookAheadDrain */
|
|
8737
|
+
lookAheadDrain;
|
|
8738
|
+
/** A refill was requested while a drain was running. */
|
|
8739
|
+
lookAheadDirty = false;
|
|
8728
8740
|
constructor(config) {
|
|
8729
8741
|
this.config = config;
|
|
8730
8742
|
this.watcher = new ContractWatcher({
|
|
@@ -8775,6 +8787,7 @@ var ContractManager = class _ContractManager {
|
|
|
8775
8787
|
for (const contract of contracts) {
|
|
8776
8788
|
await this.watcher.addContract(contract);
|
|
8777
8789
|
}
|
|
8790
|
+
await this.scheduleLookAheadDrain();
|
|
8778
8791
|
try {
|
|
8779
8792
|
await this.reconcileWatched();
|
|
8780
8793
|
this.markSyncOnline();
|
|
@@ -8826,6 +8839,173 @@ var ContractManager = class _ContractManager {
|
|
|
8826
8839
|
console.error("ContractManager: intent reconciliation failed", e);
|
|
8827
8840
|
}
|
|
8828
8841
|
}
|
|
8842
|
+
/** @see IContractManager.refillLookAhead */
|
|
8843
|
+
refillLookAhead() {
|
|
8844
|
+
return this.scheduleLookAheadDrain();
|
|
8845
|
+
}
|
|
8846
|
+
/**
|
|
8847
|
+
* Serialized drain of the look-ahead band: concurrent callers join the
|
|
8848
|
+
* active drain and mark it dirty, an idle call starts a new one. Promotion
|
|
8849
|
+
* can uncover more funded indices, and boot / SSE / rotate / reconnect can
|
|
8850
|
+
* all request a refill at once, so the loop coalesces them instead of
|
|
8851
|
+
* recursing.
|
|
8852
|
+
*/
|
|
8853
|
+
scheduleLookAheadDrain() {
|
|
8854
|
+
if (!this.config.lookAhead) return Promise.resolve();
|
|
8855
|
+
if (this.lookAheadDrain) {
|
|
8856
|
+
this.lookAheadDirty = true;
|
|
8857
|
+
return this.lookAheadDrain;
|
|
8858
|
+
}
|
|
8859
|
+
const drain = (async () => {
|
|
8860
|
+
do {
|
|
8861
|
+
this.lookAheadDirty = false;
|
|
8862
|
+
await this.ensureLookAhead();
|
|
8863
|
+
} while (this.lookAheadDirty);
|
|
8864
|
+
})().finally(() => {
|
|
8865
|
+
this.lookAheadDrain = void 0;
|
|
8866
|
+
});
|
|
8867
|
+
this.lookAheadDrain = drain;
|
|
8868
|
+
return drain;
|
|
8869
|
+
}
|
|
8870
|
+
/**
|
|
8871
|
+
* Request a drain without awaiting it. Used from inside a sync (promotion),
|
|
8872
|
+
* where awaiting the drain that the sync itself is part of would deadlock.
|
|
8873
|
+
*/
|
|
8874
|
+
requestLookAheadDrain() {
|
|
8875
|
+
if (!this.config.lookAhead) return;
|
|
8876
|
+
if (this.lookAheadDrain) {
|
|
8877
|
+
this.lookAheadDirty = true;
|
|
8878
|
+
return;
|
|
8879
|
+
}
|
|
8880
|
+
void this.scheduleLookAheadDrain().catch((err) => {
|
|
8881
|
+
console.error("ContractManager: look-ahead refill failed", err);
|
|
8882
|
+
});
|
|
8883
|
+
}
|
|
8884
|
+
/**
|
|
8885
|
+
* Rebuild the speculative watch band around the allocation watermark.
|
|
8886
|
+
*
|
|
8887
|
+
* NArk needs no analogue because it *is* the address issuer: it persists a
|
|
8888
|
+
* contract row at derivation time, so its watched set is a superset of
|
|
8889
|
+
* every address it ever advertised. This SDK, when a third party issues
|
|
8890
|
+
* addresses from the shared seed, cannot observe those allocations at all —
|
|
8891
|
+
* the window is how a non-issuer compensates.
|
|
8892
|
+
*
|
|
8893
|
+
* Entries are registered with the watcher but NOT persisted: they become
|
|
8894
|
+
* repository rows only once funded (see {@link promoteLookAheadHits}).
|
|
8895
|
+
*
|
|
8896
|
+
* Each index contributes every {@link Discoverable.candidatesAt} candidate —
|
|
8897
|
+
* the same set `restore()`'s gap scan probes, since the wallet cannot know
|
|
8898
|
+
* which variant a third-party issuer handed out.
|
|
8899
|
+
*/
|
|
8900
|
+
async ensureLookAhead() {
|
|
8901
|
+
const lookAhead = this.config.lookAhead;
|
|
8902
|
+
if (!lookAhead) return;
|
|
8903
|
+
const watermark = await lookAhead.currentWatermark();
|
|
8904
|
+
const from = Math.max(0, watermark - lookAhead.size);
|
|
8905
|
+
const to = watermark + lookAhead.size;
|
|
8906
|
+
const deps = lookAhead.candidateDeps();
|
|
8907
|
+
const handlers = contractHandlers.getRegisteredTypes().map((t) => contractHandlers.get(t)).filter(hasCandidates);
|
|
8908
|
+
const band = /* @__PURE__ */ new Map();
|
|
8909
|
+
for (let index = from; index <= to; index++) {
|
|
8910
|
+
const descriptor = lookAhead.materialize(index);
|
|
8911
|
+
for (const handler of handlers) {
|
|
8912
|
+
for (const candidate of handler.candidatesAt(index, descriptor, deps)) {
|
|
8913
|
+
if (band.has(candidate.script)) continue;
|
|
8914
|
+
band.set(candidate.script, {
|
|
8915
|
+
index,
|
|
8916
|
+
params: {
|
|
8917
|
+
...candidate,
|
|
8918
|
+
...speculativeReceiveMetadata(descriptor)
|
|
8919
|
+
}
|
|
8920
|
+
});
|
|
8921
|
+
}
|
|
8922
|
+
}
|
|
8923
|
+
}
|
|
8924
|
+
await this.watcher.withCoalescedSubscription(async () => {
|
|
8925
|
+
const persisted = await this.config.contractRepository.getContracts({
|
|
8926
|
+
script: [...band.keys()]
|
|
8927
|
+
});
|
|
8928
|
+
const persistedScripts = new Set(persisted.map((c) => c.script));
|
|
8929
|
+
for (const [script, { index, params }] of band) {
|
|
8930
|
+
if (persistedScripts.has(script)) {
|
|
8931
|
+
this.lookAheadEntries.delete(script);
|
|
8932
|
+
continue;
|
|
8933
|
+
}
|
|
8934
|
+
if (this.lookAheadEntries.has(script)) continue;
|
|
8935
|
+
const contract = toWatchOnlyContract(params);
|
|
8936
|
+
this.lookAheadEntries.set(script, {
|
|
8937
|
+
index,
|
|
8938
|
+
params,
|
|
8939
|
+
contract,
|
|
8940
|
+
catchUpPending: true
|
|
8941
|
+
});
|
|
8942
|
+
await this.watcher.addContract(contract);
|
|
8943
|
+
}
|
|
8944
|
+
const stale = [...this.lookAheadEntries.keys()].filter((s) => !band.has(s));
|
|
8945
|
+
if (stale.length > 0) {
|
|
8946
|
+
const rows = await this.config.contractRepository.getContracts({ script: stale });
|
|
8947
|
+
const nowPersisted = new Set(rows.map((c) => c.script));
|
|
8948
|
+
for (const script of stale) {
|
|
8949
|
+
this.lookAheadEntries.delete(script);
|
|
8950
|
+
if (!nowPersisted.has(script)) await this.watcher.removeContract(script);
|
|
8951
|
+
}
|
|
8952
|
+
}
|
|
8953
|
+
});
|
|
8954
|
+
await this.runLookAheadCatchUp();
|
|
8955
|
+
}
|
|
8956
|
+
/**
|
|
8957
|
+
* One-time full-history sync for speculative entries the manager has not
|
|
8958
|
+
* successfully caught up on yet.
|
|
8959
|
+
*
|
|
8960
|
+
* Every normal sync uses the cursor-derived delta window and SSE only
|
|
8961
|
+
* delivers events after a script is subscribed, so a script first
|
|
8962
|
+
* registered after its funding time would otherwise be skipped forever
|
|
8963
|
+
* (upgrade migration, or a band that slid over an already-funded index).
|
|
8964
|
+
* The entries are passed as in-memory contracts because `refreshVtxos`
|
|
8965
|
+
* resolves scripts through the repository, where they deliberately do not
|
|
8966
|
+
* exist. Targeted + explicitly windowed, so the global cursor stays put.
|
|
8967
|
+
*/
|
|
8968
|
+
async runLookAheadCatchUp() {
|
|
8969
|
+
const pending = [...this.lookAheadEntries.values()].filter((e) => e.catchUpPending);
|
|
8970
|
+
if (pending.length === 0) return;
|
|
8971
|
+
try {
|
|
8972
|
+
await this.syncContracts({
|
|
8973
|
+
contracts: pending.map((e) => e.contract),
|
|
8974
|
+
window: { after: 0 }
|
|
8975
|
+
});
|
|
8976
|
+
for (const entry of pending) entry.catchUpPending = false;
|
|
8977
|
+
} catch (err) {
|
|
8978
|
+
if (!isRetryableProviderError(err)) throw err;
|
|
8979
|
+
this.markSyncDegraded(err);
|
|
8980
|
+
}
|
|
8981
|
+
}
|
|
8982
|
+
/**
|
|
8983
|
+
* Promote every look-ahead entry funded by `vtxos` into a real repository
|
|
8984
|
+
* row, returning the persisted rows keyed by script.
|
|
8985
|
+
*
|
|
8986
|
+
* MUST run on each raw indexer fetch before `annotateVtxos`:
|
|
8987
|
+
* `extendVirtualCoinForContract` throws when a VTXO's script has no
|
|
8988
|
+
* contract row, so a funded window entry has to be persisted before its
|
|
8989
|
+
* VTXOs are annotated and saved. Callers also swap the returned rows into
|
|
8990
|
+
* the local contract maps they built pre-promotion, so `saveVtxosForContract`
|
|
8991
|
+
* and `onVtxosPersisted` never see the synthetic watcher object.
|
|
8992
|
+
*/
|
|
8993
|
+
async promoteLookAheadHits(vtxos) {
|
|
8994
|
+
const promoted = /* @__PURE__ */ new Map();
|
|
8995
|
+
if (this.lookAheadEntries.size === 0) return promoted;
|
|
8996
|
+
const hits = /* @__PURE__ */ new Map();
|
|
8997
|
+
for (const vtxo of vtxos) {
|
|
8998
|
+
const entry = this.lookAheadEntries.get(vtxo.script);
|
|
8999
|
+
if (entry) hits.set(vtxo.script, entry);
|
|
9000
|
+
}
|
|
9001
|
+
if (hits.size === 0) return promoted;
|
|
9002
|
+
for (const [script, entry] of hits) {
|
|
9003
|
+
promoted.set(script, await this.persistAndWatchContract(entry.params));
|
|
9004
|
+
await this.config.lookAhead?.onPromoted?.(entry.index);
|
|
9005
|
+
}
|
|
9006
|
+
this.requestLookAheadDrain();
|
|
9007
|
+
return promoted;
|
|
9008
|
+
}
|
|
8829
9009
|
/**
|
|
8830
9010
|
* Create and register a new contract.
|
|
8831
9011
|
*
|
|
@@ -8871,6 +9051,11 @@ var ContractManager = class _ContractManager {
|
|
|
8871
9051
|
* `persisted` is `true`.
|
|
8872
9052
|
*/
|
|
8873
9053
|
async upsertContract(params) {
|
|
9054
|
+
const result = await this.upsertContractRow(params);
|
|
9055
|
+
this.lookAheadEntries.delete(params.script);
|
|
9056
|
+
return result;
|
|
9057
|
+
}
|
|
9058
|
+
async upsertContractRow(params) {
|
|
8874
9059
|
const handler = contractHandlers.get(params.type);
|
|
8875
9060
|
if (!handler) {
|
|
8876
9061
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
@@ -9360,6 +9545,7 @@ var ContractManager = class _ContractManager {
|
|
|
9360
9545
|
}
|
|
9361
9546
|
break;
|
|
9362
9547
|
case "connection_reset":
|
|
9548
|
+
await this.scheduleLookAheadDrain();
|
|
9363
9549
|
await this.reconcileWatched();
|
|
9364
9550
|
this.markSyncOnline();
|
|
9365
9551
|
break;
|
|
@@ -9419,11 +9605,16 @@ var ContractManager = class _ContractManager {
|
|
|
9419
9605
|
contracts.map((c) => c.script),
|
|
9420
9606
|
{ pendingOnly: true }
|
|
9421
9607
|
);
|
|
9608
|
+
for (const [script, contract] of await this.promoteLookAheadHits(vtxos)) {
|
|
9609
|
+
scriptToContract.set(script, contract);
|
|
9610
|
+
}
|
|
9422
9611
|
const owned = vtxos.filter((v) => scriptToContract.has(v.script));
|
|
9423
9612
|
const annotated = await this.annotateVtxos(owned);
|
|
9424
9613
|
const byContract = /* @__PURE__ */ new Map();
|
|
9614
|
+
const contractByAddress = /* @__PURE__ */ new Map();
|
|
9425
9615
|
for (const vtxo of annotated) {
|
|
9426
9616
|
const contract = scriptToContract.get(vtxo.script);
|
|
9617
|
+
contractByAddress.set(contract.address, contract);
|
|
9427
9618
|
let arr = byContract.get(contract.address);
|
|
9428
9619
|
if (!arr) {
|
|
9429
9620
|
arr = [];
|
|
@@ -9435,7 +9626,7 @@ var ContractManager = class _ContractManager {
|
|
|
9435
9626
|
});
|
|
9436
9627
|
}
|
|
9437
9628
|
for (const [addr, contractVtxos] of byContract) {
|
|
9438
|
-
const contract =
|
|
9629
|
+
const contract = contractByAddress.get(addr);
|
|
9439
9630
|
const filtered = warnAndFilterVtxosForScript(
|
|
9440
9631
|
contractVtxos,
|
|
9441
9632
|
contract.script,
|
|
@@ -9456,11 +9647,15 @@ var ContractManager = class _ContractManager {
|
|
|
9456
9647
|
}
|
|
9457
9648
|
}
|
|
9458
9649
|
async fetchContractVxosFromIndexer(contracts, pageSize, syncWindow) {
|
|
9459
|
-
const
|
|
9650
|
+
const { vtxosByScript, promoted } = await this.fetchContractVtxosBulk(
|
|
9651
|
+
contracts,
|
|
9652
|
+
pageSize,
|
|
9653
|
+
syncWindow
|
|
9654
|
+
);
|
|
9460
9655
|
const result = /* @__PURE__ */ new Map();
|
|
9461
|
-
for (const [contractScript, vtxos] of
|
|
9656
|
+
for (const [contractScript, vtxos] of vtxosByScript) {
|
|
9462
9657
|
result.set(contractScript, vtxos);
|
|
9463
|
-
const contract = contracts.find((c) => c.script === contractScript);
|
|
9658
|
+
const contract = promoted.get(contractScript) ?? contracts.find((c) => c.script === contractScript);
|
|
9464
9659
|
if (contract) {
|
|
9465
9660
|
const filtered = warnAndFilterVtxosForScript(
|
|
9466
9661
|
vtxos,
|
|
@@ -9488,7 +9683,7 @@ var ContractManager = class _ContractManager {
|
|
|
9488
9683
|
}
|
|
9489
9684
|
async fetchContractVtxosBulk(contracts, pageSize = DEFAULT_PAGE_SIZE, syncWindow) {
|
|
9490
9685
|
if (contracts.length === 0) {
|
|
9491
|
-
return /* @__PURE__ */ new Map();
|
|
9686
|
+
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
9492
9687
|
}
|
|
9493
9688
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9494
9689
|
const result = new Map(
|
|
@@ -9507,6 +9702,10 @@ var ContractManager = class _ContractManager {
|
|
|
9507
9702
|
contracts.map((c) => c.script),
|
|
9508
9703
|
{ ...windowOpts, pageSize }
|
|
9509
9704
|
);
|
|
9705
|
+
const promoted = await this.promoteLookAheadHits(vtxos);
|
|
9706
|
+
for (const [script, contract] of promoted) {
|
|
9707
|
+
scriptToContract.set(script, contract);
|
|
9708
|
+
}
|
|
9510
9709
|
const owned = vtxos.filter((v) => scriptToContract.has(v.script));
|
|
9511
9710
|
const annotated = await this.annotateVtxos(owned);
|
|
9512
9711
|
for (const vtxo of annotated) {
|
|
@@ -9515,7 +9714,7 @@ var ContractManager = class _ContractManager {
|
|
|
9515
9714
|
contractScript: vtxo.script
|
|
9516
9715
|
});
|
|
9517
9716
|
}
|
|
9518
|
-
return result;
|
|
9717
|
+
return { vtxosByScript: result, promoted };
|
|
9519
9718
|
}
|
|
9520
9719
|
/**
|
|
9521
9720
|
* Dispose of the ContractManager and release all resources.
|
|
@@ -9529,6 +9728,7 @@ var ContractManager = class _ContractManager {
|
|
|
9529
9728
|
this.stopWatcherFn?.();
|
|
9530
9729
|
this.stopWatcherFn = void 0;
|
|
9531
9730
|
this.eventCallbacks.clear();
|
|
9731
|
+
this.lookAheadEntries.clear();
|
|
9532
9732
|
this.initialized = false;
|
|
9533
9733
|
}
|
|
9534
9734
|
/**
|
|
@@ -9594,6 +9794,15 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
9594
9794
|
if (settings.lastIndexUsed === void 0) return void 0;
|
|
9595
9795
|
return this.materializeDescriptorAt(settings.lastIndexUsed);
|
|
9596
9796
|
}
|
|
9797
|
+
/**
|
|
9798
|
+
* The most recently allocated index, or `undefined` when nothing has ever
|
|
9799
|
+
* been allocated on this repo. Read-only peek at the watermark that
|
|
9800
|
+
* {@link getNextSigningDescriptor} advances.
|
|
9801
|
+
*/
|
|
9802
|
+
async getLastIndexUsed() {
|
|
9803
|
+
const state = await this.walletRepository.getWalletState();
|
|
9804
|
+
return this.parseSettings(state ?? {}).lastIndexUsed;
|
|
9805
|
+
}
|
|
9597
9806
|
/**
|
|
9598
9807
|
* Monotonically advance the allocation watermark so the next
|
|
9599
9808
|
* `getNextSigningDescriptor()` skips indices discovered by a restore
|
|
@@ -9976,58 +10185,24 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
9976
10185
|
*/
|
|
9977
10186
|
async rotate(wallet) {
|
|
9978
10187
|
const descriptor = await this.provider.getNextSigningDescriptor();
|
|
9979
|
-
const
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
10188
|
+
const { tapscript: newTapscript, params } = buildReceiveContract(
|
|
10189
|
+
wallet.offchainTapscript,
|
|
10190
|
+
descriptor,
|
|
10191
|
+
wallet.network.hrp);
|
|
10192
|
+
const newScript = params.script;
|
|
9983
10193
|
const manager = await wallet.getContractManager();
|
|
9984
|
-
|
|
9985
|
-
const csvTimelockStr = timelockToSequence(csvTimelock).toString();
|
|
9986
|
-
const serverPubKeyHex = hex.encode(newTapscript.options.serverPubKey);
|
|
9987
|
-
const baseParams = {
|
|
9988
|
-
script: newScript,
|
|
9989
|
-
address: newAddress,
|
|
9990
|
-
state: "active",
|
|
9991
|
-
// Persist the materialized signing descriptor alongside the
|
|
9992
|
-
// source tag. The wallet's spending paths read this at sign
|
|
9993
|
-
// time to route inputs locked by a rotated pubkey through
|
|
9994
|
-
// `DescriptorProvider.signWithDescriptor` instead of the
|
|
9995
|
-
// identity's index-0 key. Without it, post-rotation sends
|
|
9996
|
-
// produce unsigned PSBTs that the server rejects with
|
|
9997
|
-
// `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
9998
|
-
metadata: {
|
|
9999
|
-
source: WALLET_RECEIVE_SOURCE,
|
|
10000
|
-
signingDescriptor: descriptor
|
|
10001
|
-
}
|
|
10002
|
-
};
|
|
10003
|
-
if (newTapscript instanceof DelegateVtxo.Script) {
|
|
10004
|
-
await manager.createContract({
|
|
10005
|
-
...baseParams,
|
|
10006
|
-
type: "delegate",
|
|
10007
|
-
params: {
|
|
10008
|
-
pubKey: hex.encode(pubKey),
|
|
10009
|
-
serverPubKey: serverPubKeyHex,
|
|
10010
|
-
delegatePubKey: hex.encode(newTapscript.options.delegatePubKey),
|
|
10011
|
-
csvTimelock: csvTimelockStr
|
|
10012
|
-
}
|
|
10013
|
-
});
|
|
10014
|
-
} else {
|
|
10015
|
-
await manager.createContract({
|
|
10016
|
-
...baseParams,
|
|
10017
|
-
type: "default",
|
|
10018
|
-
params: {
|
|
10019
|
-
pubKey: hex.encode(pubKey),
|
|
10020
|
-
serverPubKey: serverPubKeyHex,
|
|
10021
|
-
csvTimelock: csvTimelockStr
|
|
10022
|
-
}
|
|
10023
|
-
});
|
|
10024
|
-
}
|
|
10194
|
+
await manager.createContract(params);
|
|
10025
10195
|
wallet.setOffchainTapscriptForRotation(newTapscript);
|
|
10026
10196
|
const previousTagged = this.currentTaggedScript;
|
|
10027
10197
|
if (previousTagged !== void 0 && previousTagged !== newScript) {
|
|
10028
10198
|
await manager.setContractState(previousTagged, "inactive");
|
|
10029
10199
|
}
|
|
10030
10200
|
this.currentTaggedScript = newScript;
|
|
10201
|
+
try {
|
|
10202
|
+
await manager.refillLookAhead();
|
|
10203
|
+
} catch (err) {
|
|
10204
|
+
this.logger.error("WalletReceiveRotator: look-ahead refill failed", err);
|
|
10205
|
+
}
|
|
10031
10206
|
}
|
|
10032
10207
|
};
|
|
10033
10208
|
function deriveLeafPubkey(descriptor) {
|
|
@@ -10040,6 +10215,45 @@ function deriveLeafPubkey(descriptor) {
|
|
|
10040
10215
|
);
|
|
10041
10216
|
}
|
|
10042
10217
|
}
|
|
10218
|
+
function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
10219
|
+
const pubKey = deriveLeafPubkey(descriptor);
|
|
10220
|
+
const tapscript = rebuildTapscript(current, pubKey);
|
|
10221
|
+
const serverPubKey = tapscript.options.serverPubKey;
|
|
10222
|
+
const csvTimelock = timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10223
|
+
const base = {
|
|
10224
|
+
script: hex.encode(tapscript.pkScript),
|
|
10225
|
+
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
10226
|
+
state: "active",
|
|
10227
|
+
// The materialized signing descriptor is read at sign time to route
|
|
10228
|
+
// inputs locked by a rotated pubkey through
|
|
10229
|
+
// `DescriptorProvider.signWithDescriptor` instead of the identity's
|
|
10230
|
+
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10231
|
+
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10232
|
+
metadata: {
|
|
10233
|
+
...{ source: WALLET_RECEIVE_SOURCE },
|
|
10234
|
+
signingDescriptor: descriptor
|
|
10235
|
+
}
|
|
10236
|
+
};
|
|
10237
|
+
const params = tapscript instanceof DelegateVtxo.Script ? {
|
|
10238
|
+
...base,
|
|
10239
|
+
type: "delegate",
|
|
10240
|
+
params: {
|
|
10241
|
+
pubKey: hex.encode(pubKey),
|
|
10242
|
+
serverPubKey: hex.encode(serverPubKey),
|
|
10243
|
+
delegatePubKey: hex.encode(tapscript.options.delegatePubKey),
|
|
10244
|
+
csvTimelock
|
|
10245
|
+
}
|
|
10246
|
+
} : {
|
|
10247
|
+
...base,
|
|
10248
|
+
type: "default",
|
|
10249
|
+
params: {
|
|
10250
|
+
pubKey: hex.encode(pubKey),
|
|
10251
|
+
serverPubKey: hex.encode(serverPubKey),
|
|
10252
|
+
csvTimelock
|
|
10253
|
+
}
|
|
10254
|
+
};
|
|
10255
|
+
return { tapscript, params };
|
|
10256
|
+
}
|
|
10043
10257
|
function rebuildTapscript(current, pubKey) {
|
|
10044
10258
|
if (current instanceof DelegateVtxo.Script) {
|
|
10045
10259
|
return new DelegateVtxo.Script({ ...current.options, pubKey });
|
|
@@ -10242,6 +10456,7 @@ function extractArkProviderUrl(provider) {
|
|
|
10242
10456
|
const serverUrl = provider.serverUrl;
|
|
10243
10457
|
return typeof serverUrl === "string" && serverUrl.length > 0 ? serverUrl : void 0;
|
|
10244
10458
|
}
|
|
10459
|
+
var DEFAULT_LOOK_AHEAD_WINDOW = 20;
|
|
10245
10460
|
var MAINNET_UNILATERAL_EXIT_DELAY = 605184n;
|
|
10246
10461
|
function toXOnlyPubKey(pubkey) {
|
|
10247
10462
|
if (pubkey.length === 33) return pubkey.slice(1);
|
|
@@ -11297,6 +11512,14 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11297
11512
|
this._contractManagerInitializing = void 0;
|
|
11298
11513
|
}
|
|
11299
11514
|
}
|
|
11515
|
+
/**
|
|
11516
|
+
* HD look-ahead configuration for the contract manager. Readonly wallets
|
|
11517
|
+
* have no descriptor provider, hence no watermark to look ahead of.
|
|
11518
|
+
* @see Wallet.lookAheadConfig
|
|
11519
|
+
*/
|
|
11520
|
+
lookAheadConfig() {
|
|
11521
|
+
return void 0;
|
|
11522
|
+
}
|
|
11300
11523
|
async initializeContractManager() {
|
|
11301
11524
|
const virtualTxRepository = this.virtualTxRepository;
|
|
11302
11525
|
let onVtxosPersisted;
|
|
@@ -11331,7 +11554,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11331
11554
|
intentRepository: this.intentRepository,
|
|
11332
11555
|
onVtxosPersisted,
|
|
11333
11556
|
onVtxosSpent,
|
|
11334
|
-
watcherConfig: this.watcherConfig
|
|
11557
|
+
watcherConfig: this.watcherConfig,
|
|
11558
|
+
lookAhead: this.lookAheadConfig()
|
|
11335
11559
|
});
|
|
11336
11560
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
11337
11561
|
const delegatePubKey = this.offchainTapscript instanceof DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
@@ -11425,7 +11649,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11425
11649
|
}
|
|
11426
11650
|
};
|
|
11427
11651
|
var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
11428
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider) {
|
|
11652
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow) {
|
|
11429
11653
|
super(
|
|
11430
11654
|
identity,
|
|
11431
11655
|
network,
|
|
@@ -11465,6 +11689,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11465
11689
|
this._serverUnrollScript = serverUnrollScript;
|
|
11466
11690
|
this._receiveRotator = receiveRotator;
|
|
11467
11691
|
this._descriptorProvider = descriptorProvider;
|
|
11692
|
+
this._lookAheadWindow = lookAheadWindow ?? DEFAULT_LOOK_AHEAD_WINDOW;
|
|
11468
11693
|
this._signerRouter = new InputSignerRouter({
|
|
11469
11694
|
identity,
|
|
11470
11695
|
contractRepository,
|
|
@@ -11537,6 +11762,48 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11537
11762
|
* paths only ever take the identity-sign branch.
|
|
11538
11763
|
*/
|
|
11539
11764
|
_descriptorProvider;
|
|
11765
|
+
/** Per-side width of the HD look-ahead band. @see WalletConfig.lookAheadWindow */
|
|
11766
|
+
_lookAheadWindow;
|
|
11767
|
+
/**
|
|
11768
|
+
* Watch a band of missing offchain receive scripts around the HD watermark
|
|
11769
|
+
* so payments to an externally-issued address land without a `restore()`.
|
|
11770
|
+
* Only HD wallets have a watermark to look ahead of; static / `auto`
|
|
11771
|
+
* wallets keep a single index-0 receive address, so the feature stays off.
|
|
11772
|
+
*
|
|
11773
|
+
* `candidateDeps` is read at refill time, so a band rebuilt after
|
|
11774
|
+
* {@link rotateServerSigner} fans the active signer set (persisted
|
|
11775
|
+
* old-signer rows stay watched through the repository).
|
|
11776
|
+
*/
|
|
11777
|
+
lookAheadConfig() {
|
|
11778
|
+
const provider = this._descriptorProvider;
|
|
11779
|
+
if (!(provider instanceof HDDescriptorProvider)) return void 0;
|
|
11780
|
+
return {
|
|
11781
|
+
size: this._lookAheadWindow,
|
|
11782
|
+
currentWatermark: async () => await provider.getLastIndexUsed() ?? -1,
|
|
11783
|
+
materialize: (index) => provider.materializeDescriptorAt(index),
|
|
11784
|
+
candidateDeps: () => this.receiveCandidateDeps(),
|
|
11785
|
+
onPromoted: (index) => provider.advanceLastIndexUsed(index)
|
|
11786
|
+
};
|
|
11787
|
+
}
|
|
11788
|
+
/**
|
|
11789
|
+
* Every axis an externally issued receive script could be anchored to, not
|
|
11790
|
+
* just the wallet's own current shape: an issuer sharing the seed (NArk, a
|
|
11791
|
+
* merchant backend) picks its own contract type, and a band derived from one
|
|
11792
|
+
* variant silently misses the rest until a `restore()`.
|
|
11793
|
+
*
|
|
11794
|
+
* Read from cached state, not a fresh `getInfo`, to stay synchronous and
|
|
11795
|
+
* offline-safe; {@link refreshDeprecatedSigners} and
|
|
11796
|
+
* {@link rotateServerSigner} keep it current and re-trigger a refill.
|
|
11797
|
+
*/
|
|
11798
|
+
receiveCandidateDeps() {
|
|
11799
|
+
return {
|
|
11800
|
+
network: { hrp: this.network.hrp },
|
|
11801
|
+
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
11802
|
+
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => hex.decode(h)),
|
|
11803
|
+
csvTimelocks: this.walletContractTimelocks,
|
|
11804
|
+
delegatePubKey: this.offchainTapscript instanceof DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
11805
|
+
};
|
|
11806
|
+
}
|
|
11540
11807
|
_signerRouter;
|
|
11541
11808
|
/**
|
|
11542
11809
|
* @internal Sole write path for `offchainTapscript` after construction.
|
|
@@ -11649,6 +11916,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11649
11916
|
}
|
|
11650
11917
|
});
|
|
11651
11918
|
this.setBoardingTapscriptForRotation(newBoarding);
|
|
11919
|
+
try {
|
|
11920
|
+
await manager.refillLookAhead();
|
|
11921
|
+
} catch (e) {
|
|
11922
|
+
console.warn("look-ahead refill after boarding allocation failed", e);
|
|
11923
|
+
}
|
|
11652
11924
|
return newBoarding.onchainAddress(this.network);
|
|
11653
11925
|
}
|
|
11654
11926
|
/**
|
|
@@ -11770,6 +12042,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11770
12042
|
this.setBoardingTapscriptForRotation(newBoarding);
|
|
11771
12043
|
this.setArkServerPublicKeyForRotation(xonly);
|
|
11772
12044
|
this.setServerUnrollScriptForRotation(newServerUnrollScript);
|
|
12045
|
+
try {
|
|
12046
|
+
await manager.refillLookAhead();
|
|
12047
|
+
} catch (e) {
|
|
12048
|
+
console.warn("look-ahead refill after server-signer rotation failed", e);
|
|
12049
|
+
}
|
|
11773
12050
|
}
|
|
11774
12051
|
/**
|
|
11775
12052
|
* Async mutex that serializes all operations submitting VTXOs to the Arkade
|
|
@@ -11885,6 +12162,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11885
12162
|
if (hd && result.highestConfirmedUsedIndex >= 0) {
|
|
11886
12163
|
await provider.advanceLastIndexUsed(result.highestConfirmedUsedIndex);
|
|
11887
12164
|
}
|
|
12165
|
+
await manager.refillLookAhead();
|
|
11888
12166
|
await manager.refreshVtxos({ includeInactive: true, after: 0 });
|
|
11889
12167
|
const causes = result.handlerErrors.map(
|
|
11890
12168
|
(e) => e.error instanceof Error ? e.error : new Error(String(e.error))
|
|
@@ -11976,6 +12254,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11976
12254
|
* ```
|
|
11977
12255
|
*/
|
|
11978
12256
|
static async create(config) {
|
|
12257
|
+
if (config.lookAheadWindow !== void 0 && (!Number.isInteger(config.lookAheadWindow) || config.lookAheadWindow <= 0)) {
|
|
12258
|
+
throw new Error(
|
|
12259
|
+
`lookAheadWindow must be a positive integer (got ${String(config.lookAheadWindow)})`
|
|
12260
|
+
);
|
|
12261
|
+
}
|
|
11979
12262
|
const pubkey = await config.identity.xOnlyPublicKey();
|
|
11980
12263
|
if (!pubkey) {
|
|
11981
12264
|
throw new Error("Invalid configured public key");
|
|
@@ -12013,7 +12296,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12013
12296
|
config.settlementConfig,
|
|
12014
12297
|
setup.walletContractTimelocks,
|
|
12015
12298
|
boot?.rotator,
|
|
12016
|
-
boot?.provider
|
|
12299
|
+
boot?.provider,
|
|
12300
|
+
config.lookAheadWindow
|
|
12017
12301
|
);
|
|
12018
12302
|
wallet._serverInfoSource = setup.serverInfoSource;
|
|
12019
12303
|
if (setup.serverInfoSource === "live") {
|
|
@@ -14007,7 +14291,8 @@ var MessageBus = class {
|
|
|
14007
14291
|
delegateProvider,
|
|
14008
14292
|
settlementConfig: config.settlementConfig,
|
|
14009
14293
|
walletMode: config.walletMode,
|
|
14010
|
-
watcherConfig: config.watcherConfig
|
|
14294
|
+
watcherConfig: config.watcherConfig,
|
|
14295
|
+
lookAheadWindow: config.lookAheadWindow
|
|
14011
14296
|
});
|
|
14012
14297
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
14013
14298
|
}
|
|
@@ -16472,6 +16757,9 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16472
16757
|
)
|
|
16473
16758
|
);
|
|
16474
16759
|
},
|
|
16760
|
+
refillLookAhead() {
|
|
16761
|
+
return Promise.resolve();
|
|
16762
|
+
},
|
|
16475
16763
|
async isWatching() {
|
|
16476
16764
|
const message = {
|
|
16477
16765
|
type: "IS_CONTRACT_MANAGER_WATCHING",
|
|
@@ -16521,6 +16809,11 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
16521
16809
|
return serializeSigningIdentity(this.identity);
|
|
16522
16810
|
}
|
|
16523
16811
|
static async create(options) {
|
|
16812
|
+
if (options.lookAheadWindow !== void 0 && (!Number.isInteger(options.lookAheadWindow) || options.lookAheadWindow <= 0)) {
|
|
16813
|
+
throw new Error(
|
|
16814
|
+
`lookAheadWindow must be a positive integer (got ${String(options.lookAheadWindow)})`
|
|
16815
|
+
);
|
|
16816
|
+
}
|
|
16524
16817
|
const walletRepository = options.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
16525
16818
|
const contractRepository = options.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
16526
16819
|
if (!isSigningCapable(options.identity)) {
|
|
@@ -16570,6 +16863,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
16570
16863
|
settlementConfig: options.settlementConfig,
|
|
16571
16864
|
walletMode: options.walletMode,
|
|
16572
16865
|
watcherConfig: options.watcherConfig,
|
|
16866
|
+
lookAheadWindow: options.lookAheadWindow,
|
|
16573
16867
|
messageTimeouts
|
|
16574
16868
|
};
|
|
16575
16869
|
await initializeMessageBus(
|
|
@@ -19877,6 +20171,6 @@ function isArkContract(str) {
|
|
|
19877
20171
|
return str.startsWith(ARKCONTRACT_PREFIX + "=");
|
|
19878
20172
|
}
|
|
19879
20173
|
|
|
19880
|
-
export { ARKADE_MAGIC, ActivityRegistry, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP322, Batch, ChainedTxType, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, RestEmulatorProvider, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, arkade_exports, assertIntentIdUnique, boardingResolver, buildForfeitTx, buildOffchainTx, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, createAssetPacket, createDefaultActivityRegistry, createExitChainResolver, decodeArkContract, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, getMigrationStatus, getRandomId, hasBoardingTxExpired, intentMatchesFilter, intentPageBounds, isArkContract, isBatchSignable, isCooperativelyMigratable, isDiscoverable, isRetryableProviderError, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, mergeChainedTxType, migrateWalletRepository, openDatabase, requiresMigration, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signerSetFromInfo, toXOnlySignerHex, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
|
|
19881
|
-
//# sourceMappingURL=chunk-
|
|
19882
|
-
//# sourceMappingURL=chunk-
|
|
20174
|
+
export { ARKADE_MAGIC, ActivityRegistry, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP322, Batch, ChainedTxType, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, RestEmulatorProvider, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, arkade_exports, assertIntentIdUnique, boardingResolver, buildForfeitTx, buildOffchainTx, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, createAssetPacket, createDefaultActivityRegistry, createExitChainResolver, decodeArkContract, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, isArkContract, isBatchSignable, isCooperativelyMigratable, isDiscoverable, isRetryableProviderError, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, mergeChainedTxType, migrateWalletRepository, openDatabase, requiresMigration, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signerSetFromInfo, toXOnlySignerHex, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
|
|
20175
|
+
//# sourceMappingURL=chunk-AXCKRS2D.js.map
|
|
20176
|
+
//# sourceMappingURL=chunk-AXCKRS2D.js.map
|