@arkade-os/sdk 0.5.10 → 0.5.12
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 +7 -7
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +4 -4
- package/dist/{asyncStorageTaskQueue-CXKwLEgC.d.ts → asyncStorageTaskQueue-Bsty8W7d.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-BSUY0Lz8.d.cts → asyncStorageTaskQueue-DTNS2qfN.d.cts} +2 -2
- package/dist/{chunk-DPFD5KBK.js → chunk-2YXVU5TK.js} +7 -5
- package/dist/chunk-2YXVU5TK.js.map +1 -0
- package/dist/{chunk-4DUTRRXF.js → chunk-3ABF4EMM.js} +3 -3
- package/dist/{chunk-4DUTRRXF.js.map → chunk-3ABF4EMM.js.map} +1 -1
- package/dist/{chunk-ZTZH4KEF.js → chunk-3RO63OPW.js} +4 -4
- package/dist/{chunk-ZTZH4KEF.js.map → chunk-3RO63OPW.js.map} +1 -1
- package/dist/{chunk-QEREPVKU.js → chunk-4OY5BCIE.js} +5 -5
- package/dist/{chunk-QEREPVKU.js.map → chunk-4OY5BCIE.js.map} +1 -1
- package/dist/{chunk-MPE7FTKE.js → chunk-4TMJBLJT.js} +11 -6
- package/dist/chunk-4TMJBLJT.js.map +1 -0
- package/dist/{chunk-UWPYUDO4.cjs → chunk-4X4SY3RH.cjs} +18 -13
- package/dist/chunk-4X4SY3RH.cjs.map +1 -0
- package/dist/{chunk-4MC7NHQT.js → chunk-5NY5EOS2.js} +4 -4
- package/dist/{chunk-4MC7NHQT.js.map → chunk-5NY5EOS2.js.map} +1 -1
- package/dist/{chunk-FMX2FMYH.js → chunk-BA3GPO5C.js} +5 -5
- package/dist/{chunk-FMX2FMYH.js.map → chunk-BA3GPO5C.js.map} +1 -1
- package/dist/{chunk-KOXW2WGD.cjs → chunk-C3NKBKRY.cjs} +52 -52
- package/dist/{chunk-KOXW2WGD.cjs.map → chunk-C3NKBKRY.cjs.map} +1 -1
- package/dist/{chunk-6GEVB7AN.cjs → chunk-CJUVKHK4.cjs} +705 -618
- package/dist/chunk-CJUVKHK4.cjs.map +1 -0
- package/dist/{chunk-UU6GNWEC.cjs → chunk-HNLC6F73.cjs} +20 -20
- package/dist/{chunk-UU6GNWEC.cjs.map → chunk-HNLC6F73.cjs.map} +1 -1
- package/dist/{chunk-UPIQZRNJ.cjs → chunk-JA4SYFC7.cjs} +11 -11
- package/dist/{chunk-UPIQZRNJ.cjs.map → chunk-JA4SYFC7.cjs.map} +1 -1
- package/dist/{chunk-OMZZQTDM.cjs → chunk-PHOJF7OK.cjs} +10 -10
- package/dist/{chunk-OMZZQTDM.cjs.map → chunk-PHOJF7OK.cjs.map} +1 -1
- package/dist/{chunk-XWKQEAZE.cjs → chunk-QDX2HUBK.cjs} +11 -11
- package/dist/{chunk-XWKQEAZE.cjs.map → chunk-QDX2HUBK.cjs.map} +1 -1
- package/dist/{chunk-SJBQW6P4.cjs → chunk-QV7AOZZN.cjs} +21 -21
- package/dist/{chunk-SJBQW6P4.cjs.map → chunk-QV7AOZZN.cjs.map} +1 -1
- package/dist/{chunk-PXEFYEKL.js → chunk-UXLETBNK.js} +4 -4
- package/dist/{chunk-PXEFYEKL.js.map → chunk-UXLETBNK.js.map} +1 -1
- package/dist/{chunk-4HCV67LR.js → chunk-WBZYYRAB.js} +127 -40
- package/dist/chunk-WBZYYRAB.js.map +1 -0
- package/dist/{chunk-WIZCF5IX.cjs → chunk-YAVF2PR6.cjs} +7 -5
- package/dist/chunk-YAVF2PR6.cjs.map +1 -0
- package/dist/compiler.cjs +4 -4
- package/dist/compiler.js +3 -3
- package/dist/contracts/handlers/index.cjs +11 -11
- package/dist/contracts/handlers/index.d.cts +2 -2
- package/dist/contracts/handlers/index.d.ts +2 -2
- package/dist/contracts/handlers/index.js +4 -4
- package/dist/{index-Bq349_ly.d.cts → index-BBmZXXqk.d.cts} +1 -1
- package/dist/{index-Mn2POBPj.d.ts → index-DJ32LpfD.d.ts} +1 -1
- package/dist/{index-Yh5y9G4E.d.ts → index-D_zLtU-F.d.ts} +1 -1
- package/dist/{index-D4ahI0W6.d.cts → index-DenQfCn1.d.cts} +1 -1
- package/dist/index.cjs +350 -350
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/repositories/realm/index.cjs +40 -40
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +8 -8
- package/dist/repositories/sqlite/index.cjs +38 -38
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +8 -8
- package/dist/{taskRunner-1wolHThW.d.cts → taskRunner-BBGaN4cq.d.cts} +2 -2
- package/dist/{taskRunner-C1maPp-c.d.ts → taskRunner-Cck24OnC.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +17 -17
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +9 -9
- package/dist/wallet/expo/index.cjs +18 -18
- package/dist/wallet/expo/index.d.cts +2 -2
- package/dist/wallet/expo/index.d.ts +2 -2
- package/dist/wallet/expo/index.js +8 -8
- package/dist/worker/expo/index.cjs +12 -12
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +8 -8
- package/package.json +1 -1
- package/dist/chunk-4HCV67LR.js.map +0 -1
- package/dist/chunk-6GEVB7AN.cjs.map +0 -1
- package/dist/chunk-DPFD5KBK.js.map +0 -1
- package/dist/chunk-MPE7FTKE.js.map +0 -1
- package/dist/chunk-UWPYUDO4.cjs.map +0 -1
- package/dist/chunk-WIZCF5IX.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RestIndexerProvider, toSubscriptionMessage } from './chunk-
|
|
2
|
-
import { RestOperatorProvider, ARKADE_VERSION_HEADERS, isFetchTimeoutError, sdkVersionHeaders, baseFetch, HttpResponseError, readSseFrames, streamFailureError } from './chunk-
|
|
3
|
-
import { DEFAULT_ARKADE_SERVER_URL } from './chunk-
|
|
1
|
+
import { RestIndexerProvider, toSubscriptionMessage } from './chunk-5NY5EOS2.js';
|
|
2
|
+
import { RestOperatorProvider, ARKADE_VERSION_HEADERS, isFetchTimeoutError, sdkVersionHeaders, baseFetch, HttpResponseError, readSseFrames, streamFailureError } from './chunk-4TMJBLJT.js';
|
|
3
|
+
import { DEFAULT_ARKADE_SERVER_URL } from './chunk-2YXVU5TK.js';
|
|
4
4
|
|
|
5
5
|
// src/providers/expoUtils.ts
|
|
6
6
|
async function getExpoFetch(options) {
|
|
@@ -165,5 +165,5 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
|
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
export { ExpoArkProvider, ExpoIndexerProvider, ExpoOperatorProvider };
|
|
168
|
-
//# sourceMappingURL=chunk-
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
168
|
+
//# sourceMappingURL=chunk-BA3GPO5C.js.map
|
|
169
|
+
//# sourceMappingURL=chunk-BA3GPO5C.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;;AAaA,eAAsB,aAAa,OAAA,EAA4D;AAC3F,EAAA,MAAM,WAAA,GAAc,SAAS,WAAA,IAAe,KAAA;AAE5C,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAAY,CAAA;AACjD,IAAA,OAAA,CAAQ,MAAM,gCAAgC,CAAA;AAC9C,IAAA,OAAO,eAAA,CAAgB,KAAA;AAAA,EAC3B,SAAS,KAAA,EAAO;AACZ,IAAA,IAAI,WAA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CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-FMX2FMYH.js","sourcesContent":["import { baseFetch, fetch } from \"../utils/fetch\";\nimport { HttpResponseError } from \"./errors\";\nimport { readSseFrames } from \"./sseFrames\";\nimport { streamFailureError } from \"./utils\";\n\n/**\n * Dynamically imports expo/fetch, falling back to {@link baseFetch}.\n *\n * Adds no headers of its own: both Expo providers share this function but reach\n * different origins, so each passes its own per request.\n *\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 return expoFetchModule.fetch 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 baseFetch;\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 // `baseFetch`, which bounds any read that brings no signal of its\n // own. Drop this and the stream is truncated at READ_TIMEOUT_MS.\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n await response.body?.cancel().catch(() => {});\n throw new HttpResponseError(\"Unexpected status when fetching SSE stream\", response);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n for await (const { event, data } of readSseFrames(response.body)) {\n if (abortSignal?.aborted) break;\n if (event === \"failure\") throw streamFailureError(data);\n if (event !== \"message\" || !data.trim()) continue;\n\n try {\n const parsed = parseData(JSON.parse(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 } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport {\n RestOperatorProvider,\n SettlementEvent,\n TxNotificationEvent,\n isFetchTimeoutError,\n} from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { ARKADE_VERSION_HEADERS } from \"../utils/fetch\";\n\n/**\n * Expo-compatible operator 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 { ExpoOperatorProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoOperatorProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoOperatorProvider extends RestOperatorProvider {\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(\n url + queryParams,\n signal,\n expoFetch,\n ARKADE_VERSION_HEADERS,\n (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 );\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, ARKADE_VERSION_HEADERS, (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\n/** @deprecated Use {@link ExpoOperatorProvider}. */\nexport const ExpoArkProvider = ExpoOperatorProvider;\n/** @deprecated Use {@link ExpoOperatorProvider}. */\nexport type ExpoArkProvider = ExpoOperatorProvider;\n","import {\n RestIndexerProvider,\n SubscriptionEvent,\n SubscriptionHeartbeat,\n toSubscriptionMessage,\n} from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { sdkVersionHeaders } from \"../utils/sdkVersionHeaders\";\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 protected override async *subscriptionStream(\n url: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionEvent | SubscriptionHeartbeat> {\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({ requireExpo: isReactNative }).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 while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\", ...sdkVersionHeaders() },\n toSubscriptionMessage,\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
|
+
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;;AAaA,eAAsB,aAAa,OAAA,EAA4D;AAC3F,EAAA,MAAM,WAAA,GAAc,SAAS,WAAA,IAAe,KA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AAS,YAAA,EAAc;AACvD,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-BA3GPO5C.js","sourcesContent":["import { baseFetch, fetch } from \"../utils/fetch\";\nimport { HttpResponseError } from \"./errors\";\nimport { readSseFrames } from \"./sseFrames\";\nimport { streamFailureError } from \"./utils\";\n\n/**\n * Dynamically imports expo/fetch, falling back to {@link baseFetch}.\n *\n * Adds no headers of its own: both Expo providers share this function but reach\n * different origins, so each passes its own per request.\n *\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 return expoFetchModule.fetch 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 baseFetch;\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 // `baseFetch`, which bounds any read that brings no signal of its\n // own. Drop this and the stream is truncated at READ_TIMEOUT_MS.\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n await response.body?.cancel().catch(() => {});\n throw new HttpResponseError(\"Unexpected status when fetching SSE stream\", response);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n for await (const { event, data } of readSseFrames(response.body)) {\n if (abortSignal?.aborted) break;\n if (event === \"failure\") throw streamFailureError(data);\n if (event !== \"message\" || !data.trim()) continue;\n\n try {\n const parsed = parseData(JSON.parse(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 } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport {\n RestOperatorProvider,\n SettlementEvent,\n TxNotificationEvent,\n isFetchTimeoutError,\n} from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { ARKADE_VERSION_HEADERS } from \"../utils/fetch\";\n\n/**\n * Expo-compatible operator 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 { ExpoOperatorProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoOperatorProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoOperatorProvider extends RestOperatorProvider {\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(\n url + queryParams,\n signal,\n expoFetch,\n ARKADE_VERSION_HEADERS,\n (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 );\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, ARKADE_VERSION_HEADERS, (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\n/** @deprecated Use {@link ExpoOperatorProvider}. */\nexport const ExpoArkProvider = ExpoOperatorProvider;\n/** @deprecated Use {@link ExpoOperatorProvider}. */\nexport type ExpoArkProvider = ExpoOperatorProvider;\n","import {\n RestIndexerProvider,\n SubscriptionEvent,\n SubscriptionHeartbeat,\n toSubscriptionMessage,\n} from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { sdkVersionHeaders } from \"../utils/sdkVersionHeaders\";\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 protected override async *subscriptionStream(\n url: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionEvent | SubscriptionHeartbeat> {\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({ requireExpo: isReactNative }).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 while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\", ...sdkVersionHeaders() },\n toSubscriptionMessage,\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,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkJA4SYFC7_cjs = require('./chunk-JA4SYFC7.cjs');
|
|
4
|
+
var chunk4X4SY3RH_cjs = require('./chunk-4X4SY3RH.cjs');
|
|
5
|
+
var chunkYAVF2PR6_cjs = require('./chunk-YAVF2PR6.cjs');
|
|
6
6
|
var base = require('@scure/base');
|
|
7
7
|
var descriptorsScure = require('@bitcoinerlab/descriptors-scure');
|
|
8
8
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -46,14 +46,14 @@ var ContractHandlerRegistry = class {
|
|
|
46
46
|
var contractHandlers = new ContractHandlerRegistry();
|
|
47
47
|
exports.DefaultVtxo = void 0;
|
|
48
48
|
((DefaultVtxo2) => {
|
|
49
|
-
class Script2 extends
|
|
49
|
+
class Script2 extends chunkYAVF2PR6_cjs.VtxoScript {
|
|
50
50
|
/** Create the default virtual output script with one forfeit path and one exit path. */
|
|
51
51
|
constructor(options) {
|
|
52
52
|
const { pubKey, serverPubKey, csvTimelock } = options;
|
|
53
|
-
const forfeitScript =
|
|
53
|
+
const forfeitScript = chunkYAVF2PR6_cjs.MultisigTapscript.encode({
|
|
54
54
|
pubkeys: [pubKey, serverPubKey]
|
|
55
55
|
}).script;
|
|
56
|
-
const exitScript =
|
|
56
|
+
const exitScript = chunkYAVF2PR6_cjs.CSVMultisigTapscript.encode({
|
|
57
57
|
timelock: csvTimelock,
|
|
58
58
|
pubkeys: [pubKey]
|
|
59
59
|
}).script;
|
|
@@ -245,7 +245,7 @@ function extractPubKeyBytes(value) {
|
|
|
245
245
|
return base.hex.decode(extractPubKey(normalizeToDescriptor(value)));
|
|
246
246
|
}
|
|
247
247
|
function deserializeCsvTimelock(value) {
|
|
248
|
-
return value !== void 0 && value !== "" ?
|
|
248
|
+
return value !== void 0 && value !== "" ? chunkYAVF2PR6_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
249
249
|
}
|
|
250
250
|
var CLTV_HEIGHT_THRESHOLD = 500000000n;
|
|
251
251
|
function isCltvSatisfied(context, locktime) {
|
|
@@ -416,7 +416,7 @@ function deriveVhtlcTapscripts(script) {
|
|
|
416
416
|
function isCsvSpendable(context, sequence) {
|
|
417
417
|
if (sequence === void 0) return true;
|
|
418
418
|
if (!context.vtxo) return false;
|
|
419
|
-
const timelock =
|
|
419
|
+
const timelock = chunkYAVF2PR6_cjs.sequenceToTimelock(sequence);
|
|
420
420
|
if (timelock.type === "blocks") {
|
|
421
421
|
if (context.blockHeight === void 0 || context.vtxo.status.block_height === void 0) {
|
|
422
422
|
return false;
|
|
@@ -474,14 +474,14 @@ function forfeitExitSpendablePaths(script, contract, context) {
|
|
|
474
474
|
async function detectUsedScripts(indexerProvider, scriptHexes) {
|
|
475
475
|
const used = /* @__PURE__ */ new Set();
|
|
476
476
|
const unique = [...new Set(scriptHexes)];
|
|
477
|
-
for (let offset = 0; offset < unique.length; offset +=
|
|
478
|
-
const scripts = unique.slice(offset, offset +
|
|
477
|
+
for (let offset = 0; offset < unique.length; offset += chunk4X4SY3RH_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
|
|
478
|
+
const scripts = unique.slice(offset, offset + chunk4X4SY3RH_cjs.SCRIPT_QUERY_CHUNK_SIZE);
|
|
479
479
|
const remaining = new Set(scripts);
|
|
480
|
-
for await (const { vtxos } of
|
|
481
|
-
(pageIndex) =>
|
|
480
|
+
for await (const { vtxos } of chunk4X4SY3RH_cjs.indexerPages(
|
|
481
|
+
(pageIndex) => chunk4X4SY3RH_cjs.getNormalizedVtxos(indexerProvider, {
|
|
482
482
|
scripts,
|
|
483
483
|
pageIndex,
|
|
484
|
-
pageSize:
|
|
484
|
+
pageSize: chunk4X4SY3RH_cjs.DEFAULT_PAGE_SIZE
|
|
485
485
|
})
|
|
486
486
|
)) {
|
|
487
487
|
for (const vtxo of vtxos) {
|
|
@@ -547,7 +547,7 @@ var DefaultContractHandler = {
|
|
|
547
547
|
return {
|
|
548
548
|
pubKey: base.hex.encode(params.pubKey),
|
|
549
549
|
serverPubKey: base.hex.encode(params.serverPubKey),
|
|
550
|
-
csvTimelock:
|
|
550
|
+
csvTimelock: chunkYAVF2PR6_cjs.timelockToSequence(params.csvTimelock).toString()
|
|
551
551
|
};
|
|
552
552
|
},
|
|
553
553
|
deserializeParams(params) {
|
|
@@ -594,12 +594,12 @@ function discoverDefaultRange(entries, deps) {
|
|
|
594
594
|
}
|
|
595
595
|
exports.DelegateVtxo = void 0;
|
|
596
596
|
((DelegateVtxo2) => {
|
|
597
|
-
class Script2 extends
|
|
597
|
+
class Script2 extends chunkYAVF2PR6_cjs.VtxoScript {
|
|
598
598
|
/** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
|
|
599
599
|
constructor(options) {
|
|
600
600
|
const defaultVtxo = new exports.DefaultVtxo.Script(options);
|
|
601
601
|
const { delegatePubKey, pubKey, serverPubKey } = options;
|
|
602
|
-
const delegateScript =
|
|
602
|
+
const delegateScript = chunkYAVF2PR6_cjs.MultisigTapscript.encode({
|
|
603
603
|
pubkeys: [pubKey, delegatePubKey, serverPubKey]
|
|
604
604
|
}).script;
|
|
605
605
|
super([...defaultVtxo.scripts, delegateScript]);
|
|
@@ -638,7 +638,7 @@ var DelegateContractHandler = {
|
|
|
638
638
|
pubKey: base.hex.encode(params.pubKey),
|
|
639
639
|
serverPubKey: base.hex.encode(params.serverPubKey),
|
|
640
640
|
delegatePubKey: base.hex.encode(params.delegatePubKey),
|
|
641
|
-
csvTimelock:
|
|
641
|
+
csvTimelock: chunkYAVF2PR6_cjs.timelockToSequence(params.csvTimelock).toString()
|
|
642
642
|
};
|
|
643
643
|
},
|
|
644
644
|
deserializeParams(params) {
|
|
@@ -696,7 +696,7 @@ function discoverDelegateRange(entries, deps) {
|
|
|
696
696
|
}
|
|
697
697
|
exports.VHTLC = void 0;
|
|
698
698
|
((VHTLC2) => {
|
|
699
|
-
class BaseScript extends
|
|
699
|
+
class BaseScript extends chunkYAVF2PR6_cjs.VtxoScript {
|
|
700
700
|
options;
|
|
701
701
|
claimScript;
|
|
702
702
|
refundScript;
|
|
@@ -723,27 +723,27 @@ exports.VHTLC = void 0;
|
|
|
723
723
|
unilateralRefundWithoutReceiverDelay
|
|
724
724
|
} = options;
|
|
725
725
|
const conditionScript = preimageCondition(preimageHash);
|
|
726
|
-
const claimScript =
|
|
726
|
+
const claimScript = chunkYAVF2PR6_cjs.ConditionMultisigTapscript.encode({
|
|
727
727
|
conditionScript,
|
|
728
728
|
pubkeys: [receiver, server]
|
|
729
729
|
}).script;
|
|
730
|
-
const refundScript =
|
|
730
|
+
const refundScript = chunkYAVF2PR6_cjs.MultisigTapscript.encode({
|
|
731
731
|
pubkeys: [sender, receiver, server]
|
|
732
732
|
}).script;
|
|
733
|
-
const refundWithoutReceiverScript =
|
|
733
|
+
const refundWithoutReceiverScript = chunkYAVF2PR6_cjs.CLTVMultisigTapscript.encode({
|
|
734
734
|
absoluteTimelock: refundLocktime,
|
|
735
735
|
pubkeys: [sender, server]
|
|
736
736
|
}).script;
|
|
737
|
-
const unilateralClaimScript =
|
|
737
|
+
const unilateralClaimScript = chunkYAVF2PR6_cjs.ConditionCSVMultisigTapscript.encode({
|
|
738
738
|
conditionScript,
|
|
739
739
|
timelock: unilateralClaimDelay,
|
|
740
740
|
pubkeys: [receiver]
|
|
741
741
|
}).script;
|
|
742
|
-
const unilateralRefundScript =
|
|
742
|
+
const unilateralRefundScript = chunkYAVF2PR6_cjs.CSVMultisigTapscript.encode({
|
|
743
743
|
timelock: unilateralRefundDelay,
|
|
744
744
|
pubkeys: [sender, receiver]
|
|
745
745
|
}).script;
|
|
746
|
-
const unilateralRefundWithoutReceiverScript =
|
|
746
|
+
const unilateralRefundWithoutReceiverScript = chunkYAVF2PR6_cjs.CSVMultisigTapscript.encode({
|
|
747
747
|
timelock: unilateralRefundWithoutReceiverDelay,
|
|
748
748
|
pubkeys: [sender]
|
|
749
749
|
}).script;
|
|
@@ -763,25 +763,25 @@ exports.VHTLC = void 0;
|
|
|
763
763
|
const covenants = options.nonInteractiveParameters;
|
|
764
764
|
if (covenants) {
|
|
765
765
|
arkadeScriptNic = enforcePayToMaybeAsset(covenants.receiverPkScript, options.asset);
|
|
766
|
-
nonInteractiveClaimScript =
|
|
766
|
+
nonInteractiveClaimScript = chunkYAVF2PR6_cjs.ConditionMultisigTapscript.encode({
|
|
767
767
|
conditionScript,
|
|
768
768
|
pubkeys: [
|
|
769
769
|
server,
|
|
770
|
-
|
|
770
|
+
chunkJA4SYFC7_cjs.computeArkadeScriptPublicKey(covenants.emulatorPubkey, arkadeScriptNic)
|
|
771
771
|
]
|
|
772
772
|
}).script;
|
|
773
773
|
scripts.push(nonInteractiveClaimScript);
|
|
774
774
|
arkadeScriptNir = enforcePayToMaybeAsset(covenants.senderPkScript, options.asset);
|
|
775
|
-
const nirCosigner =
|
|
775
|
+
const nirCosigner = chunkJA4SYFC7_cjs.computeArkadeScriptPublicKey(
|
|
776
776
|
covenants.emulatorPubkey,
|
|
777
777
|
arkadeScriptNir
|
|
778
778
|
);
|
|
779
|
-
nonInteractiveRefundScript =
|
|
779
|
+
nonInteractiveRefundScript = chunkYAVF2PR6_cjs.MultisigTapscript.encode({
|
|
780
780
|
pubkeys: [server, receiver, nirCosigner]
|
|
781
781
|
}).script;
|
|
782
782
|
scripts.push(nonInteractiveRefundScript);
|
|
783
783
|
if (covenants.legacy !== "preTimelockedRefund") {
|
|
784
|
-
nonInteractiveRefundWithoutReceiverScript =
|
|
784
|
+
nonInteractiveRefundWithoutReceiverScript = chunkYAVF2PR6_cjs.CLTVMultisigTapscript.encode({
|
|
785
785
|
absoluteTimelock: refundLocktime,
|
|
786
786
|
pubkeys: [server, nirCosigner]
|
|
787
787
|
}).script;
|
|
@@ -999,7 +999,7 @@ function enforcePayTo(destinationPkScript) {
|
|
|
999
999
|
if (!isP2trPkScript(destinationPkScript)) {
|
|
1000
1000
|
throw new Error("invalid P2TR script");
|
|
1001
1001
|
}
|
|
1002
|
-
return
|
|
1002
|
+
return chunkJA4SYFC7_cjs.ArkadeScript.encode(satClause(destinationPkScript));
|
|
1003
1003
|
}
|
|
1004
1004
|
function enforcePayToAsset(destinationPkScript, asset) {
|
|
1005
1005
|
if (!isP2trPkScript(destinationPkScript)) {
|
|
@@ -1014,7 +1014,7 @@ function enforcePayToAsset(destinationPkScript, asset) {
|
|
|
1014
1014
|
);
|
|
1015
1015
|
}
|
|
1016
1016
|
const inspectionTxid = Uint8Array.from(asset.txid).reverse();
|
|
1017
|
-
return
|
|
1017
|
+
return chunkJA4SYFC7_cjs.ArkadeScript.encode([
|
|
1018
1018
|
// The output at the input's index carries at least the input's amount of the asset.
|
|
1019
1019
|
"PUSHCURRENTINPUTINDEX",
|
|
1020
1020
|
inspectionTxid,
|
|
@@ -1057,9 +1057,9 @@ var VHTLCContractHandler = {
|
|
|
1057
1057
|
server: base.hex.encode(params.server),
|
|
1058
1058
|
hash: base.hex.encode(params.preimageHash),
|
|
1059
1059
|
refundLocktime: params.refundLocktime.toString(),
|
|
1060
|
-
claimDelay:
|
|
1061
|
-
refundDelay:
|
|
1062
|
-
refundNoReceiverDelay:
|
|
1060
|
+
claimDelay: chunkYAVF2PR6_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
|
|
1061
|
+
refundDelay: chunkYAVF2PR6_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
|
|
1062
|
+
refundNoReceiverDelay: chunkYAVF2PR6_cjs.timelockToSequence(
|
|
1063
1063
|
params.unilateralRefundWithoutReceiverDelay
|
|
1064
1064
|
).toString()
|
|
1065
1065
|
};
|
|
@@ -1071,9 +1071,9 @@ var VHTLCContractHandler = {
|
|
|
1071
1071
|
server: base.hex.decode(params.server),
|
|
1072
1072
|
preimageHash: base.hex.decode(params.hash),
|
|
1073
1073
|
refundLocktime: BigInt(params.refundLocktime),
|
|
1074
|
-
unilateralClaimDelay:
|
|
1075
|
-
unilateralRefundDelay:
|
|
1076
|
-
unilateralRefundWithoutReceiverDelay:
|
|
1074
|
+
unilateralClaimDelay: chunkYAVF2PR6_cjs.sequenceToTimelock(Number(params.claimDelay)),
|
|
1075
|
+
unilateralRefundDelay: chunkYAVF2PR6_cjs.sequenceToTimelock(Number(params.refundDelay)),
|
|
1076
|
+
unilateralRefundWithoutReceiverDelay: chunkYAVF2PR6_cjs.sequenceToTimelock(
|
|
1077
1077
|
Number(params.refundNoReceiverDelay)
|
|
1078
1078
|
)
|
|
1079
1079
|
};
|
|
@@ -1166,9 +1166,9 @@ var VHTLCV2ContractHandler = {
|
|
|
1166
1166
|
server: base.hex.encode(params.server),
|
|
1167
1167
|
hash: base.hex.encode(params.preimageHash),
|
|
1168
1168
|
refundLocktime: params.refundLocktime.toString(),
|
|
1169
|
-
claimDelay:
|
|
1170
|
-
refundDelay:
|
|
1171
|
-
refundNoReceiverDelay:
|
|
1169
|
+
claimDelay: chunkYAVF2PR6_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
|
|
1170
|
+
refundDelay: chunkYAVF2PR6_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
|
|
1171
|
+
refundNoReceiverDelay: chunkYAVF2PR6_cjs.timelockToSequence(
|
|
1172
1172
|
params.unilateralRefundWithoutReceiverDelay
|
|
1173
1173
|
).toString(),
|
|
1174
1174
|
// Per-leaf on-disk keys predate the grouped param and older rows carry exactly these;
|
|
@@ -1246,9 +1246,9 @@ var VHTLCV2ContractHandler = {
|
|
|
1246
1246
|
preimageHash: base.hex.decode(params.hash),
|
|
1247
1247
|
refundLocktime: BigInt(params.refundLocktime),
|
|
1248
1248
|
...asset && { asset },
|
|
1249
|
-
unilateralClaimDelay:
|
|
1250
|
-
unilateralRefundDelay:
|
|
1251
|
-
unilateralRefundWithoutReceiverDelay:
|
|
1249
|
+
unilateralClaimDelay: chunkYAVF2PR6_cjs.sequenceToTimelock(Number(params.claimDelay)),
|
|
1250
|
+
unilateralRefundDelay: chunkYAVF2PR6_cjs.sequenceToTimelock(Number(params.refundDelay)),
|
|
1251
|
+
unilateralRefundWithoutReceiverDelay: chunkYAVF2PR6_cjs.sequenceToTimelock(
|
|
1252
1252
|
Number(params.refundNoReceiverDelay)
|
|
1253
1253
|
),
|
|
1254
1254
|
...claim && refund && {
|
|
@@ -1382,7 +1382,7 @@ function pathsFor(script, context, opts) {
|
|
|
1382
1382
|
const paths = [];
|
|
1383
1383
|
for (const fn of script.compiled) {
|
|
1384
1384
|
if (fn.arkadeScript) continue;
|
|
1385
|
-
const witness =
|
|
1385
|
+
const witness = chunkJA4SYFC7_cjs.staticWitness(fn.def.tapscript.witness, script.args);
|
|
1386
1386
|
if (witness === null) continue;
|
|
1387
1387
|
const signerHexes = fn.signerKeys.map((s) => base.hex.encode(s));
|
|
1388
1388
|
const requiresServer = signerHexes.includes(serverHex);
|
|
@@ -1391,8 +1391,8 @@ function pathsFor(script, context, opts) {
|
|
|
1391
1391
|
continue;
|
|
1392
1392
|
}
|
|
1393
1393
|
const csvDef = fn.def.tapscript.csv;
|
|
1394
|
-
const csv = csvDef ?
|
|
1395
|
-
const cltv = fn.def.tapscript.cltv !== void 0 ?
|
|
1394
|
+
const csv = csvDef ? chunkJA4SYFC7_cjs.resolveCsvTimelock(csvDef, script.args) : void 0;
|
|
1395
|
+
const cltv = fn.def.tapscript.cltv !== void 0 ? chunkJA4SYFC7_cjs.resolveTimelockValue(fn.def.tapscript.cltv, script.args) : void 0;
|
|
1396
1396
|
if (context.collaborative) {
|
|
1397
1397
|
if (csv) continue;
|
|
1398
1398
|
if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
|
|
@@ -1405,7 +1405,7 @@ function pathsFor(script, context, opts) {
|
|
|
1405
1405
|
continue;
|
|
1406
1406
|
}
|
|
1407
1407
|
if (requiresServer) continue;
|
|
1408
|
-
const sequence = csv ? Number(
|
|
1408
|
+
const sequence = csv ? Number(chunkYAVF2PR6_cjs.timelockToSequence(csv)) : void 0;
|
|
1409
1409
|
if (opts.checkTimelocks && csv && !isCsvSpendable(context, sequence)) continue;
|
|
1410
1410
|
if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
|
|
1411
1411
|
continue;
|
|
@@ -1422,17 +1422,17 @@ var ArkadeContractHandler = {
|
|
|
1422
1422
|
type: "arkade",
|
|
1423
1423
|
createScript(params) {
|
|
1424
1424
|
const typed = this.deserializeParams(params);
|
|
1425
|
-
return new
|
|
1425
|
+
return new chunkJA4SYFC7_cjs.ArkadeProgramScript(typed.program, typed.args, {
|
|
1426
1426
|
serverKey: typed.serverKey,
|
|
1427
1427
|
userKey: typed.userKey,
|
|
1428
1428
|
emulatorKey: typed.emulatorKey
|
|
1429
1429
|
});
|
|
1430
1430
|
},
|
|
1431
1431
|
serializeParams(params) {
|
|
1432
|
-
return
|
|
1432
|
+
return chunkJA4SYFC7_cjs.serializeArkadeContractParams(params);
|
|
1433
1433
|
},
|
|
1434
1434
|
deserializeParams(params) {
|
|
1435
|
-
return
|
|
1435
|
+
return chunkJA4SYFC7_cjs.deserializeArkadeContractParams(params);
|
|
1436
1436
|
},
|
|
1437
1437
|
selectPath(script, _contract, context) {
|
|
1438
1438
|
const paths = pathsFor(script, context, { checkTimelocks: true });
|
|
@@ -1507,5 +1507,5 @@ exports.isMainnetDescriptor = isMainnetDescriptor;
|
|
|
1507
1507
|
exports.normalizeToDescriptor = normalizeToDescriptor;
|
|
1508
1508
|
exports.parseHDDescriptor = parseHDDescriptor;
|
|
1509
1509
|
exports.speculativeReceiveMetadata = speculativeReceiveMetadata;
|
|
1510
|
-
//# sourceMappingURL=chunk-
|
|
1511
|
-
//# sourceMappingURL=chunk-
|
|
1510
|
+
//# sourceMappingURL=chunk-C3NKBKRY.cjs.map
|
|
1511
|
+
//# sourceMappingURL=chunk-C3NKBKRY.cjs.map
|