@arkade-os/sdk 0.5.0-rc.5 → 0.5.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-AZkDlEZ0.d.cts → asyncStorageTaskQueue-BHOhjFiF.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-BVcOhuOc.d.ts → asyncStorageTaskQueue-BedBOEpT.d.ts} +2 -2
- package/dist/{chunk-FZ2BTDWY.js → chunk-2JU54RGB.js} +37 -11
- package/dist/chunk-2JU54RGB.js.map +1 -0
- package/dist/{chunk-FLPP5KNW.js → chunk-4MB3Z33G.js} +8 -4
- package/dist/chunk-4MB3Z33G.js.map +1 -0
- package/dist/{chunk-ORRKOSQK.js → chunk-7B2QAHQU.js} +123 -47
- package/dist/chunk-7B2QAHQU.js.map +1 -0
- package/dist/{chunk-AEDYZK7T.cjs → chunk-A2T3GGAK.cjs} +50 -50
- package/dist/{chunk-AEDYZK7T.cjs.map → chunk-A2T3GGAK.cjs.map} +1 -1
- package/dist/{chunk-GQWHCQLD.cjs → chunk-EIMOVGBV.cjs} +549 -473
- package/dist/chunk-EIMOVGBV.cjs.map +1 -0
- package/dist/{chunk-QWWOD7M2.cjs → chunk-GLLBSULU.cjs} +30 -4
- package/dist/chunk-GLLBSULU.cjs.map +1 -0
- package/dist/{chunk-NPG5FAOW.js → chunk-H7KLBU6G.js} +30 -5
- package/dist/chunk-H7KLBU6G.js.map +1 -0
- package/dist/{chunk-3ZIEFYL3.js → chunk-L6MGV7ZA.js} +3 -3
- package/dist/{chunk-3ZIEFYL3.js.map → chunk-L6MGV7ZA.js.map} +1 -1
- package/dist/{chunk-YFILTMLF.js → chunk-LFIORZO3.js} +4 -4
- package/dist/{chunk-YFILTMLF.js.map → chunk-LFIORZO3.js.map} +1 -1
- package/dist/{chunk-OMJIILNG.cjs → chunk-VUR6RP73.cjs} +10 -10
- package/dist/{chunk-OMJIILNG.cjs.map → chunk-VUR6RP73.cjs.map} +1 -1
- package/dist/{chunk-BUYG7QK3.cjs → chunk-XIPWLWPU.cjs} +21 -17
- package/dist/chunk-XIPWLWPU.cjs.map +1 -0
- package/dist/{chunk-NEVMOIQL.cjs → chunk-XOT73T36.cjs} +52 -26
- package/dist/chunk-XOT73T36.cjs.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-B5cd_m9h.d.cts → delegate-Dv8aEvSp.d.cts} +1 -1
- package/dist/{delegate-BeAa3vil.d.ts → delegate-Hl92NVgS.d.ts} +1 -1
- package/dist/{hdWalletCapable-CqJnNn-i.d.ts → hdWalletCapable-Bqcb-XtC.d.ts} +2 -2
- package/dist/{hdWalletCapable-DjjIw6-Q.d.cts → hdWalletCapable-QiCK1B9d.d.cts} +2 -2
- package/dist/{index-Cg8_sNpz.d.ts → index-BwEO0Yb-.d.ts} +2 -2
- package/dist/{index-BNybgFmf.d.cts → index-CeC9FiJt.d.cts} +2 -2
- package/dist/{index-KCU4cxhL.d.cts → index-F-X4BWxi.d.cts} +38 -3
- package/dist/{index-KCU4cxhL.d.ts → index-F-X4BWxi.d.ts} +38 -3
- package/dist/index.cjs +293 -289
- package/dist/index.d.cts +46 -10
- package/dist/index.d.ts +46 -10
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +20 -20
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +19 -19
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-BywoLcvo.d.ts → taskRunner-BdU_d__J.d.ts} +2 -2
- package/dist/{taskRunner-CRetv4-8.d.cts → taskRunner-CDCz7MTW.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- 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-BUYG7QK3.cjs.map +0 -1
- package/dist/chunk-FLPP5KNW.js.map +0 -1
- package/dist/chunk-FZ2BTDWY.js.map +0 -1
- package/dist/chunk-GQWHCQLD.cjs.map +0 -1
- package/dist/chunk-NEVMOIQL.cjs.map +0 -1
- package/dist/chunk-NPG5FAOW.js.map +0 -1
- package/dist/chunk-ORRKOSQK.js.map +0 -1
- package/dist/chunk-QWWOD7M2.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAMA,eAAsB,aAAa,OAAA,EAA4D;AAG3F,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAAY,CAAA;AACjD,IAAA,OAAA,CAAQ,MAAM,gCAAgC,CAAA;AAC9C,IAAA,MAAM,mBAAA,GAAsB,CAAC,KAAA,EAAoB,IAAA,KAAuB;AACpE,MAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AACzC,MAAA,OAAA,CAAQ,GAAA,CAAI,mBAAmB,YAAY,CAAA;A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UAAA;AAAA,QACJ;AAIA,QAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAC5B,UAAA,OAAA,CAAQ,MAAM,uBAAuB,CAAA;AACrC,UAAA;AAAA,QACJ;AAEA,QAAA,OAAA,CAAQ,KAAA,CAAM,uBAAuB,KAAK,CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-4MB3Z33G.js","sourcesContent":["import { fetch, buildVersion, sdkVersion } from \"../utils/fetch\";\n\n/**\n * Dynamically imports expo/fetch with fallback to standard fetch.\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n const expoFetchWithHeader = (input: RequestInfo, init?: RequestInit) => {\n const headers = new Headers(init?.headers);\n headers.set(\"X-Build-Version\", buildVersion);\n headers.set(\"X-SDK-VERSION\", sdkVersion);\n return expoFetchModule.fetch(input, { ...init, headers });\n };\n return expoFetchWithHeader as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return fetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n // Required, not just for cancellation: `getExpoFetch` falls back to\n // the Ark `fetch` wrapper, which routes through `baseFetch` and so\n // bounds any read that brings no signal of its own. Drop this and\n // the stream is truncated at READ_TIMEOUT_MS.\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Unexpected status ${response.status} when fetching SSE stream`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!abortSignal?.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n\n for (let i = 0; i < lines.length - 1; i++) {\n const line = lines[i].trim();\n if (!line) continue;\n\n if (line.startsWith(\"data:\")) {\n const jsonStr = line.substring(5).trim();\n if (!jsonStr) continue;\n\n try {\n const data = JSON.parse(jsonStr);\n const parsed = parseData(data);\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n }\n\n buffer = lines[lines.length - 1];\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { RestArkProvider, SettlementEvent, TxNotificationEvent, isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\n\n/**\n * Expo-compatible Arkade provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';\n *\n * const provider = new ExpoArkProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoArkProvider extends RestArkProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url + queryParams, signal, expoFetch, {}, (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(\n signal: AbortSignal,\n ): AsyncIterableIterator<TxNotificationEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, {}, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n","import { RestIndexerProvider, SubscriptionResponse } from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { convertVtxo } from \"../wallet/vtxo\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getSubscription(\n subscriptionId: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionResponse> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch().catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n const url = `${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`;\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\" },\n (data): SubscriptionResponse | null => {\n // Handle new v8 proto format with heartbeat or event\n if (data.heartbeat !== undefined) {\n // Skip heartbeat messages\n return null;\n }\n // Process event messages\n if (data.event) {\n return {\n txid: data.event.txid,\n scripts: data.event.scripts || [],\n newVtxos: (data.event.newVtxos || []).map(convertVtxo),\n spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),\n sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),\n tx: data.event.tx,\n checkpointTxs: data.event.checkpointTxs,\n };\n }\n return null;\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } 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, toXOnly, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-
|
|
3
|
-
import { VtxoScript, __export, Transaction, isVirtualCoin, canRecoverOnchain, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, ServerResponseMismatchError, getArkPsbtFields, CosignerPublicKey, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, normalizeVtxo, assertAllowedSighashTypes, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, formatSighash, getSequence, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, getNetwork, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, DEFAULT_ARKADE_SERVER_URL, networkFromArkadeInfo, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, INFO_FETCH_TIMEOUT_MS, PrevoutTxField, EXPIRY_MIN_PLAUSIBLE_MS, ProviderUnavailableError, networks as networks$1
|
|
1
|
+
import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-2JU54RGB.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, toXOnly, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-L6MGV7ZA.js';
|
|
3
|
+
import { VtxoScript, __export, Transaction, isVirtualCoin, canRecoverOnchain, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, ServerResponseMismatchError, getArkPsbtFields, CosignerPublicKey, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, normalizeVtxo, assertAllowedSighashTypes, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, formatSighash, getSequence, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, getNetwork, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, DEFAULT_ARKADE_SERVER_URL, networkFromArkadeInfo, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, INFO_FETCH_TIMEOUT_MS, PrevoutTxField, fetchVtxoCreatedAtByTxid, EXPIRY_MIN_PLAUSIBLE_MS, ProviderUnavailableError, networks as networks$1 } from './chunk-H7KLBU6G.js';
|
|
4
4
|
import { sha256 as sha256$1, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
|
|
5
5
|
import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
|
|
6
6
|
import { hex, base58, base64, bech32m } from '@scure/base';
|
|
@@ -3916,9 +3916,18 @@ function gatedContracts(contracts) {
|
|
|
3916
3916
|
}
|
|
3917
3917
|
return gated;
|
|
3918
3918
|
}
|
|
3919
|
+
function gatedFrom(snapshot) {
|
|
3920
|
+
return gatedContracts(snapshot.map((entry) => entry.contract));
|
|
3921
|
+
}
|
|
3922
|
+
function gatedTypeOf(vtxo, gated) {
|
|
3923
|
+
return vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3924
|
+
}
|
|
3925
|
+
function isGatedVtxo(vtxo, gated) {
|
|
3926
|
+
return gatedTypeOf(vtxo, gated) !== void 0;
|
|
3927
|
+
}
|
|
3919
3928
|
function gateExclusion(gated) {
|
|
3920
3929
|
return (vtxo) => {
|
|
3921
|
-
const type = vtxo
|
|
3930
|
+
const type = gatedTypeOf(vtxo, gated);
|
|
3922
3931
|
if (type === void 0) return void 0;
|
|
3923
3932
|
if (!contractHandlers.has(type)) {
|
|
3924
3933
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
@@ -6880,6 +6889,24 @@ var Batch;
|
|
|
6880
6889
|
})(Batch || (Batch = {}));
|
|
6881
6890
|
|
|
6882
6891
|
// src/utils/transactionHistory.ts
|
|
6892
|
+
function localCreatedAtByTxid(vtxos) {
|
|
6893
|
+
const createdAt = /* @__PURE__ */ new Map();
|
|
6894
|
+
for (const vtxo of vtxos) {
|
|
6895
|
+
if (vtxo.txid && !createdAt.has(vtxo.txid)) {
|
|
6896
|
+
createdAt.set(vtxo.txid, vtxo.createdAt.getTime());
|
|
6897
|
+
}
|
|
6898
|
+
}
|
|
6899
|
+
return createdAt;
|
|
6900
|
+
}
|
|
6901
|
+
function gatedTouchpoints(gated) {
|
|
6902
|
+
const paidIn = /* @__PURE__ */ new Set();
|
|
6903
|
+
const paidOut = /* @__PURE__ */ new Set();
|
|
6904
|
+
for (const vtxo of gated) {
|
|
6905
|
+
if (vtxo.txid) paidIn.add(vtxo.txid);
|
|
6906
|
+
if (vtxo.isSpent && vtxo.arkTxId) paidOut.add(vtxo.arkTxId);
|
|
6907
|
+
}
|
|
6908
|
+
return { paidIn, paidOut };
|
|
6909
|
+
}
|
|
6883
6910
|
var txKey = {
|
|
6884
6911
|
commitmentTxid: "",
|
|
6885
6912
|
boardingTxid: "",
|
|
@@ -6931,24 +6958,27 @@ function subtractAssets(spent, change) {
|
|
|
6931
6958
|
if (map.size === 0) return void 0;
|
|
6932
6959
|
return Array.from(map, ([assetId, amount]) => ({ assetId, amount }));
|
|
6933
6960
|
}
|
|
6934
|
-
function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
6935
|
-
const ownTxids = new Set(vtxos.map((v) => v.txid));
|
|
6961
|
+
function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
6936
6962
|
const txids = /* @__PURE__ */ new Set();
|
|
6937
6963
|
for (const vtxo of vtxos) {
|
|
6938
|
-
if (vtxo.isSpent && vtxo.arkTxId && !
|
|
6964
|
+
if (vtxo.isSpent && vtxo.arkTxId && !localCreatedAt.has(vtxo.arkTxId)) {
|
|
6939
6965
|
txids.add(vtxo.arkTxId);
|
|
6940
6966
|
}
|
|
6941
6967
|
}
|
|
6942
6968
|
return [...txids];
|
|
6943
6969
|
}
|
|
6944
|
-
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
6945
|
-
const
|
|
6946
|
-
const
|
|
6970
|
+
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
6971
|
+
const normalized = vtxos.map(normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
6972
|
+
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
6973
|
+
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
6974
|
+
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
6975
|
+
const { paidIn: paidIntoGated, paidOut: paidOutOfGated } = gatedTouchpoints(gatedVtxos);
|
|
6976
|
+
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(ownVtxos, localCreatedAt) : [];
|
|
6947
6977
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
6948
6978
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
6949
6979
|
const sent = [];
|
|
6950
6980
|
let received = [];
|
|
6951
|
-
for (const vtxo of
|
|
6981
|
+
for (const vtxo of ownVtxos) {
|
|
6952
6982
|
if (vtxo.status.isLeaf) {
|
|
6953
6983
|
const commitmentTxid = vtxo.commitmentTxIds[0];
|
|
6954
6984
|
const vtxoCreatedAt = vtxo.createdAt.getTime();
|
|
@@ -6958,7 +6988,7 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
6958
6988
|
unmatchedSettledBoardingTxs,
|
|
6959
6989
|
(tx) => tx.createdAt <= vtxoCreatedAt && (tx.key.commitmentTxid === commitmentTxid || tx.key.commitmentTxid === vtxo.settledBy)
|
|
6960
6990
|
);
|
|
6961
|
-
} else if (
|
|
6991
|
+
} else if (ownVtxos.filter((v) => v.settledBy === vtxo.commitmentTxIds[0]).length === 0) {
|
|
6962
6992
|
const duplicateBoardingReceive = consumeBoardingReceive(
|
|
6963
6993
|
unmatchedSettledBoardingTxs,
|
|
6964
6994
|
(tx) => tx.amount === vtxo.value && tx.createdAt <= vtxoCreatedAt
|
|
@@ -6979,11 +7009,14 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
6979
7009
|
});
|
|
6980
7010
|
}
|
|
6981
7011
|
}
|
|
6982
|
-
} else if (
|
|
7012
|
+
} else if (ownVtxos.filter((v) => v.arkTxId === vtxo.txid).length === 0) {
|
|
6983
7013
|
const assets = collectAssets([vtxo]);
|
|
6984
7014
|
received.push({
|
|
6985
7015
|
key: { ...txKey, arkTxid: vtxo.txid },
|
|
6986
|
-
|
|
7016
|
+
// The escrow paying out: a swap fill or a cancel spends the
|
|
7017
|
+
// gated coin and lands the proceeds here. Nothing else about
|
|
7018
|
+
// the row changes — the tag only names the counterparty.
|
|
7019
|
+
tag: paidOutOfGated.has(vtxo.txid) ? "gated" : "offchain",
|
|
6987
7020
|
type: "RECEIVED" /* TxReceived */,
|
|
6988
7021
|
amount: vtxo.value,
|
|
6989
7022
|
settled: vtxo.status.isLeaf || vtxo.isSpent,
|
|
@@ -6993,8 +7026,8 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
6993
7026
|
}
|
|
6994
7027
|
if (vtxo.isSpent) {
|
|
6995
7028
|
if (vtxo.arkTxId && !sent.some((s) => s.key.arkTxid === vtxo.arkTxId)) {
|
|
6996
|
-
const changes =
|
|
6997
|
-
const allSpent =
|
|
7029
|
+
const changes = ownVtxos.filter((_) => _.txid === vtxo.arkTxId);
|
|
7030
|
+
const allSpent = ownVtxos.filter((v) => v.arkTxId === vtxo.arkTxId);
|
|
6998
7031
|
const spentAmount = allSpent.reduce((acc, v) => acc + v.value, 0);
|
|
6999
7032
|
let txAmount = 0;
|
|
7000
7033
|
let txTime = 0;
|
|
@@ -7004,13 +7037,16 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
7004
7037
|
txTime = changes[0].createdAt.getTime();
|
|
7005
7038
|
} else {
|
|
7006
7039
|
txAmount = spentAmount;
|
|
7007
|
-
txTime = resolvedCreatedAt.get(vtxo.arkTxId) ?? vtxo.createdAt.getTime() + 1;
|
|
7040
|
+
txTime = localCreatedAt.get(vtxo.arkTxId) ?? resolvedCreatedAt.get(vtxo.arkTxId) ?? vtxo.createdAt.getTime() + 1;
|
|
7008
7041
|
}
|
|
7009
7042
|
const assets = subtractAssets(allSpent, changes);
|
|
7010
7043
|
if (txAmount !== 0 || assets) {
|
|
7011
7044
|
sent.push({
|
|
7012
7045
|
key: { ...txKey, arkTxid: vtxo.arkTxId },
|
|
7013
|
-
|
|
7046
|
+
// Funding the escrow: an output of this tx landed on a
|
|
7047
|
+
// gated contract of the wallet's, so the send is to the
|
|
7048
|
+
// user's own covenant rather than to a stranger.
|
|
7049
|
+
tag: paidIntoGated.has(vtxo.arkTxId) ? "gated" : "offchain",
|
|
7014
7050
|
type: "SENT" /* TxSent */,
|
|
7015
7051
|
amount: txAmount,
|
|
7016
7052
|
settled: true,
|
|
@@ -7020,10 +7056,10 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
7020
7056
|
}
|
|
7021
7057
|
}
|
|
7022
7058
|
if (vtxo.settledBy && !commitmentsToIgnore.has(vtxo.settledBy) && !sent.some((s) => s.key.commitmentTxid === vtxo.settledBy)) {
|
|
7023
|
-
const changes =
|
|
7059
|
+
const changes = ownVtxos.filter(
|
|
7024
7060
|
(v) => v.status.isLeaf && v.commitmentTxIds.length > 0 && v.commitmentTxIds.every((_) => vtxo.settledBy === _)
|
|
7025
7061
|
);
|
|
7026
|
-
const forfeitVtxos =
|
|
7062
|
+
const forfeitVtxos = ownVtxos.filter((v) => v.settledBy === vtxo.settledBy);
|
|
7027
7063
|
const forfeitAmount = forfeitVtxos.reduce((acc, v) => acc + v.value, 0);
|
|
7028
7064
|
if (changes.length > 0) {
|
|
7029
7065
|
const settledAmount = changes.reduce((acc, v) => acc + v.value, 0);
|
|
@@ -9491,6 +9527,7 @@ var ContractManager = class _ContractManager {
|
|
|
9491
9527
|
syncDegradedReason;
|
|
9492
9528
|
/** Epoch-ms of the last successful provider sync, if any. */
|
|
9493
9529
|
lastSyncedAt;
|
|
9530
|
+
syncedAtByScript = /* @__PURE__ */ new Map();
|
|
9494
9531
|
/** Last chain tip read, with the epoch-ms it was read at. @see currentChainTip */
|
|
9495
9532
|
chainTipCache;
|
|
9496
9533
|
/** In-flight chain tip read, so concurrent cache misses share one. */
|
|
@@ -9544,6 +9581,10 @@ var ContractManager = class _ContractManager {
|
|
|
9544
9581
|
lastSyncedAt: this.lastSyncedAt
|
|
9545
9582
|
};
|
|
9546
9583
|
}
|
|
9584
|
+
/** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
|
|
9585
|
+
setVtxoSyncMaxAge(maxAgeMs) {
|
|
9586
|
+
this.config.vtxoSyncMaxAgeMs = maxAgeMs;
|
|
9587
|
+
}
|
|
9547
9588
|
markSyncOnline() {
|
|
9548
9589
|
this.lastSyncedAt = Date.now();
|
|
9549
9590
|
this.syncDegradedReason = this.annotationDegradedReason();
|
|
@@ -10106,12 +10147,16 @@ var ContractManager = class _ContractManager {
|
|
|
10106
10147
|
}
|
|
10107
10148
|
async getContractsWithVtxos(filter, pageSize) {
|
|
10108
10149
|
const contracts = await this.getContracts(filter);
|
|
10109
|
-
|
|
10110
|
-
await this.
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10150
|
+
if (this.syncedWithin(contracts, this.config.vtxoSyncMaxAgeMs ?? 0)) {
|
|
10151
|
+
await this.demoteFundedAwaitingContracts(contracts);
|
|
10152
|
+
} else {
|
|
10153
|
+
try {
|
|
10154
|
+
await this.syncContracts({ contracts, pageSize });
|
|
10155
|
+
this.markSyncOnline();
|
|
10156
|
+
} catch (err) {
|
|
10157
|
+
if (!isRetryableProviderError(err)) throw err;
|
|
10158
|
+
this.markSyncDegraded(err);
|
|
10159
|
+
}
|
|
10115
10160
|
}
|
|
10116
10161
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
10117
10162
|
return contracts.map((contract) => ({
|
|
@@ -10526,6 +10571,7 @@ var ContractManager = class _ContractManager {
|
|
|
10526
10571
|
}
|
|
10527
10572
|
break;
|
|
10528
10573
|
case "connection_reset":
|
|
10574
|
+
this.syncedAtByScript.clear();
|
|
10529
10575
|
await this.scheduleLookAheadDrain();
|
|
10530
10576
|
await this.reconcileWatched();
|
|
10531
10577
|
this.markSyncOnline();
|
|
@@ -10572,9 +10618,21 @@ var ContractManager = class _ContractManager {
|
|
|
10572
10618
|
const cutoff = cursorCutoff(requestStartedAt);
|
|
10573
10619
|
await advanceSyncCursor(this.config.walletRepository, cutoff);
|
|
10574
10620
|
}
|
|
10621
|
+
if (options.window === void 0) {
|
|
10622
|
+
for (const contract of contracts) {
|
|
10623
|
+
this.syncedAtByScript.set(contract.script, requestStartedAt);
|
|
10624
|
+
}
|
|
10625
|
+
}
|
|
10575
10626
|
await this.demoteFundedAwaitingContracts(contracts);
|
|
10576
10627
|
return result;
|
|
10577
10628
|
}
|
|
10629
|
+
syncedWithin(contracts, maxAgeMs) {
|
|
10630
|
+
if (maxAgeMs <= 0) return false;
|
|
10631
|
+
const floor = Date.now() - maxAgeMs;
|
|
10632
|
+
return contracts.every(
|
|
10633
|
+
(contract) => (this.syncedAtByScript.get(contract.script) ?? 0) >= floor
|
|
10634
|
+
);
|
|
10635
|
+
}
|
|
10578
10636
|
/**
|
|
10579
10637
|
* Demote every `awaiting-funds` contract in `contracts` that has been
|
|
10580
10638
|
* funded — the automatic half of {@link ContractWatchState}.
|
|
@@ -12755,7 +12813,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12755
12813
|
const vtxos = filterSnapshotVtxos(snapshot, filter, this._pendingSpendOutpoints);
|
|
12756
12814
|
const { gated, pendingRecovery } = this.spendabilityView(snapshot);
|
|
12757
12815
|
const selectable = vtxos.filter(
|
|
12758
|
-
(vtxo) => !
|
|
12816
|
+
(vtxo) => !isGatedVtxo(vtxo, gated) && !pendingRecovery.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
12759
12817
|
);
|
|
12760
12818
|
const unlocked = await spendableVtxosExcludingLocked(selectable, this.intentRepository);
|
|
12761
12819
|
logExcludedVtxos("getSpendableVtxos", vtxos, [
|
|
@@ -12853,7 +12911,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12853
12911
|
*/
|
|
12854
12912
|
spendabilityView(snapshot) {
|
|
12855
12913
|
return {
|
|
12856
|
-
gated:
|
|
12914
|
+
gated: gatedFrom(snapshot),
|
|
12857
12915
|
pendingRecovery: this.selectPendingRecovery(snapshot)
|
|
12858
12916
|
};
|
|
12859
12917
|
}
|
|
@@ -12868,7 +12926,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12868
12926
|
return {
|
|
12869
12927
|
now: { timestamp: /* @__PURE__ */ new Date() },
|
|
12870
12928
|
isPendingRecovery: (vtxo) => pendingRecovery.has(`${vtxo.txid}:${vtxo.vout}`),
|
|
12871
|
-
isGenericallySpendable: (vtxo) => !
|
|
12929
|
+
isGenericallySpendable: (vtxo) => !isGatedVtxo(vtxo, gated),
|
|
12872
12930
|
isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
12873
12931
|
};
|
|
12874
12932
|
}
|
|
@@ -12908,16 +12966,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12908
12966
|
* Return wallet transaction history derived from Arkade state and boarding transactions.
|
|
12909
12967
|
*/
|
|
12910
12968
|
async getTransactionHistory() {
|
|
12911
|
-
const
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12969
|
+
const [snapshot, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
|
|
12970
|
+
this.contractSnapshot(),
|
|
12971
|
+
this.getBoardingTxs()
|
|
12972
|
+
]);
|
|
12973
|
+
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
12915
12974
|
const resolveTxCreatedAt = (txids) => fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
12916
12975
|
return buildTransactionHistory(
|
|
12917
12976
|
allVtxos,
|
|
12918
12977
|
boardingTxs,
|
|
12919
12978
|
commitmentsToIgnore,
|
|
12920
|
-
resolveTxCreatedAt
|
|
12979
|
+
resolveTxCreatedAt,
|
|
12980
|
+
gatedFrom(snapshot)
|
|
12921
12981
|
);
|
|
12922
12982
|
}
|
|
12923
12983
|
/**
|
|
@@ -17559,8 +17619,7 @@ var WalletMessageHandler = class {
|
|
|
17559
17619
|
});
|
|
17560
17620
|
}
|
|
17561
17621
|
case "GET_TRANSACTION_HISTORY": {
|
|
17562
|
-
const
|
|
17563
|
-
const transactions = await this.buildTransactionHistoryFromCache(allVtxos) ?? [];
|
|
17622
|
+
const transactions = await this.buildTransactionHistoryFromCache() ?? [];
|
|
17564
17623
|
return this.tagged({
|
|
17565
17624
|
id,
|
|
17566
17625
|
type: "TRANSACTION_HISTORY",
|
|
@@ -18043,7 +18102,7 @@ var WalletMessageHandler = class {
|
|
|
18043
18102
|
unconfirmed += utxo.value;
|
|
18044
18103
|
}
|
|
18045
18104
|
}
|
|
18046
|
-
const gated =
|
|
18105
|
+
const gated = gatedFrom(snapshot);
|
|
18047
18106
|
const unlocked = new Set(
|
|
18048
18107
|
(await spendableVtxosExcludingLocked(allVtxos, this.readonlyWallet?.intentRepository)).map((vtxo) => `${vtxo.txid}:${vtxo.vout}`)
|
|
18049
18108
|
);
|
|
@@ -18051,7 +18110,7 @@ var WalletMessageHandler = class {
|
|
|
18051
18110
|
const offchain = computeOffchainBalance(allVtxos, {
|
|
18052
18111
|
now: { timestamp: /* @__PURE__ */ new Date() },
|
|
18053
18112
|
isPendingRecovery: (vtxo) => pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`),
|
|
18054
|
-
isGenericallySpendable: (vtxo) => !
|
|
18113
|
+
isGenericallySpendable: (vtxo) => !isGatedVtxo(vtxo, gated),
|
|
18055
18114
|
isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
18056
18115
|
});
|
|
18057
18116
|
return {
|
|
@@ -18191,7 +18250,6 @@ var WalletMessageHandler = class {
|
|
|
18191
18250
|
if (!this.readonlyWallet || !this.walletRepository) {
|
|
18192
18251
|
return;
|
|
18193
18252
|
}
|
|
18194
|
-
const vtxos = await this.getVtxosFromRepo();
|
|
18195
18253
|
const boardingAddresses = await this.readonlyWallet.getBoardingAddresses();
|
|
18196
18254
|
const fresh = await this.readonlyWallet.getBoardingUtxos();
|
|
18197
18255
|
const freshKeys = new Set(fresh.map((u) => `${u.txid}:${u.vout}`));
|
|
@@ -18203,7 +18261,7 @@ var WalletMessageHandler = class {
|
|
|
18203
18261
|
if (kept.length > 0) await this.walletRepository.saveUtxos(addr, kept);
|
|
18204
18262
|
}
|
|
18205
18263
|
const address = await this.readonlyWallet.getAddress();
|
|
18206
|
-
const txs = await this.buildTransactionHistoryFromCache(
|
|
18264
|
+
const txs = await this.buildTransactionHistoryFromCache();
|
|
18207
18265
|
if (txs) await this.walletRepository.saveTransactions(address, txs);
|
|
18208
18266
|
}
|
|
18209
18267
|
/**
|
|
@@ -18394,13 +18452,29 @@ var WalletMessageHandler = class {
|
|
|
18394
18452
|
/**
|
|
18395
18453
|
* Build transaction history from cached virtual outputs, hitting the indexer only for
|
|
18396
18454
|
* uncached timestamps. Best-effort, like the plain Wallet path.
|
|
18397
|
-
|
|
18398
|
-
|
|
18455
|
+
*
|
|
18456
|
+
* Takes its own {@link repoSnapshot} rather than a caller-supplied VTXO
|
|
18457
|
+
* list: the coins and the gate that judges them have to come off one read
|
|
18458
|
+
* or they answer about different instants, and being the worker's only
|
|
18459
|
+
* history builder means neither caller can supply one without the other.
|
|
18460
|
+
* The snapshot and the boarding read are independent, so they run together
|
|
18461
|
+
* — the same pairing `handleGetBalance` makes.
|
|
18462
|
+
*/
|
|
18463
|
+
async buildTransactionHistoryFromCache() {
|
|
18399
18464
|
if (!this.readonlyWallet) return null;
|
|
18400
|
-
const { boardingTxs, commitmentsToIgnore } = await
|
|
18465
|
+
const [{ snapshot, vtxos }, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
|
|
18466
|
+
this.repoSnapshot(),
|
|
18467
|
+
this.readonlyWallet.getBoardingTxs()
|
|
18468
|
+
]);
|
|
18401
18469
|
const indexerProvider = this.indexerProvider;
|
|
18402
18470
|
const resolveTxCreatedAt = indexerProvider ? (txids) => fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
18403
|
-
return buildTransactionHistory(
|
|
18471
|
+
return buildTransactionHistory(
|
|
18472
|
+
vtxos,
|
|
18473
|
+
boardingTxs,
|
|
18474
|
+
commitmentsToIgnore,
|
|
18475
|
+
resolveTxCreatedAt,
|
|
18476
|
+
gatedFrom(snapshot)
|
|
18477
|
+
);
|
|
18404
18478
|
}
|
|
18405
18479
|
async ensureContractEventBroadcasting() {
|
|
18406
18480
|
const wallet = this.readonlyWallet;
|
|
@@ -21403,7 +21477,7 @@ var RestEmulatorProvider = class {
|
|
|
21403
21477
|
serverUrl;
|
|
21404
21478
|
async getInfo() {
|
|
21405
21479
|
const url = `${this.serverUrl}/v1/info`;
|
|
21406
|
-
const response = await
|
|
21480
|
+
const response = await baseFetch(url);
|
|
21407
21481
|
if (!response.ok) {
|
|
21408
21482
|
const errorText2 = await response.text();
|
|
21409
21483
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -21801,6 +21875,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21801
21875
|
const inputs = [];
|
|
21802
21876
|
let totalAmount = 0n;
|
|
21803
21877
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
21878
|
+
const walletDescriptor = hex.encode(await wallet.identity.xOnlyPublicKey());
|
|
21804
21879
|
for (const vtxo of vtxos) {
|
|
21805
21880
|
if (!canSweepOnchain(vtxo)) {
|
|
21806
21881
|
throw new Error(
|
|
@@ -21815,6 +21890,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21815
21890
|
vtxo,
|
|
21816
21891
|
scriptHex: hex.encode(VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
21817
21892
|
contractRepository: wallet.contractRepository,
|
|
21893
|
+
walletDescriptor,
|
|
21818
21894
|
currentTime: Date.now()
|
|
21819
21895
|
});
|
|
21820
21896
|
const spendingLeaf = resolved.selection.leaf;
|
|
@@ -23844,5 +23920,5 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
23844
23920
|
*/
|
|
23845
23921
|
|
|
23846
23922
|
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, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_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, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestEmulatorProvider, SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertNoAssets, assertRecipientArkadeAddress, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, decodeArkContract, defaultBatchExpiryPolicy, defaultCheckpointExitDelayPolicy, deleteByIndex, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, exitObserverFor, extendVirtualCoinForContract, extractArkProviderUrl, gateExclusion, gatedContracts, getAllByIndexValues, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isAddressAllocationCapable, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isContractVtxoEvent, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, isWatchedContract, legacyVtxoFacts, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, promisifyRequest, provisionClaimSecret, provisionRefundKey, resolveAssetAmount, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
|
|
23847
|
-
//# sourceMappingURL=chunk-
|
|
23848
|
-
//# sourceMappingURL=chunk-
|
|
23923
|
+
//# sourceMappingURL=chunk-7B2QAHQU.js.map
|
|
23924
|
+
//# sourceMappingURL=chunk-7B2QAHQU.js.map
|