@arkade-os/sdk 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -34
- package/dist/adapters/expo.cjs +9 -5
- package/dist/adapters/expo.d.cts +11 -7
- package/dist/adapters/expo.d.ts +11 -7
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-B3U5gQ-i.d.ts → asyncStorageTaskQueue-DHMIxY04.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-C9PkPcW_.d.cts → asyncStorageTaskQueue-DTBa8EH7.d.cts} +2 -2
- package/dist/{chunk-P7B4LQ3H.js → chunk-6CUP6ZIF.js} +4 -4
- package/dist/{chunk-P7B4LQ3H.js.map → chunk-6CUP6ZIF.js.map} +1 -1
- package/dist/{chunk-OPX2HRWM.js → chunk-AG4TFD6F.js} +137 -59
- package/dist/chunk-AG4TFD6F.js.map +1 -0
- package/dist/{chunk-5WRA66RV.cjs → chunk-B6VNKGIH.cjs} +10 -10
- package/dist/chunk-B6VNKGIH.cjs.map +1 -0
- package/dist/{chunk-6FL4N4S2.js → chunk-BTRCN4JJ.js} +22 -19
- package/dist/chunk-BTRCN4JJ.js.map +1 -0
- package/dist/{chunk-ZPF4I3K2.cjs → chunk-DNITZVNG.cjs} +28 -47
- package/dist/chunk-DNITZVNG.cjs.map +1 -0
- package/dist/{chunk-BYPBVHVA.cjs → chunk-E6OOJEHL.cjs} +49 -49
- package/dist/{chunk-BYPBVHVA.cjs.map → chunk-E6OOJEHL.cjs.map} +1 -1
- package/dist/{chunk-OUTWUYJ4.cjs → chunk-F3FAE7VJ.cjs} +769 -619
- package/dist/chunk-F3FAE7VJ.cjs.map +1 -0
- package/dist/{chunk-KW7ZEWYS.cjs → chunk-GHUUT54D.cjs} +140 -58
- package/dist/chunk-GHUUT54D.cjs.map +1 -0
- package/dist/{chunk-Y4BL3YYX.js → chunk-MWVAWFX6.js} +4 -4
- package/dist/chunk-MWVAWFX6.js.map +1 -0
- package/dist/{chunk-T7C3E2HL.js → chunk-TUOLZBNC.js} +19 -39
- package/dist/chunk-TUOLZBNC.js.map +1 -0
- package/dist/{chunk-ZMSM3NOH.cjs → chunk-WXNSISXK.cjs} +37 -34
- package/dist/chunk-WXNSISXK.cjs.map +1 -0
- package/dist/{chunk-HAQAWBYG.js → chunk-ZJHLLDBP.js} +283 -136
- package/dist/chunk-ZJHLLDBP.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-ByfKszb6.d.cts → delegate-f4_t864Z.d.cts} +1 -1
- package/dist/{delegate-Cd28gxpM.d.ts → delegate-xrSBNybC.d.ts} +1 -1
- package/dist/{index-DgH_0j14.d.cts → index-BJDz15ms.d.ts} +5 -5
- package/dist/{index-B6X2E7W_.d.ts → index-BjiVGtp8.d.cts} +5 -5
- package/dist/{index-BURzbRup.d.ts → index-DRwe0UDN.d.cts} +182 -114
- package/dist/{index-BURzbRup.d.cts → index-DRwe0UDN.d.ts} +182 -114
- package/dist/index.cjs +333 -313
- package/dist/index.d.cts +66 -44
- package/dist/index.d.ts +66 -44
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +65 -36
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +7 -3
- package/dist/repositories/realm/index.d.ts +7 -3
- package/dist/repositories/realm/index.js +35 -6
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +176 -110
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +23 -13
- package/dist/repositories/sqlite/index.d.ts +23 -13
- package/dist/repositories/sqlite/index.js +148 -83
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-i56-drQV.d.cts → taskRunner-BPPU-YHG.d.cts} +4 -4
- package/dist/{taskRunner-BaNCSxqK.d.ts → taskRunner-CDlNeth0.d.ts} +4 -4
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +7 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +15 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +6 -6
- package/dist/wallet/expo/index.d.ts +6 -6
- package/dist/wallet/expo/index.js +6 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-BjQugVUt.d.cts → wallet-Oc3Wd5gv.d.ts} +22 -18
- package/dist/{wallet-BnmhohgZ.d.ts → wallet-jVBDQl6R.d.cts} +22 -18
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-5WRA66RV.cjs.map +0 -1
- package/dist/chunk-6FL4N4S2.js.map +0 -1
- package/dist/chunk-HAQAWBYG.js.map +0 -1
- package/dist/chunk-KW7ZEWYS.cjs.map +0 -1
- package/dist/chunk-OPX2HRWM.js.map +0 -1
- package/dist/chunk-OUTWUYJ4.cjs.map +0 -1
- package/dist/chunk-T7C3E2HL.js.map +0 -1
- package/dist/chunk-Y4BL3YYX.js.map +0 -1
- package/dist/chunk-ZMSM3NOH.cjs.map +0 -1
- package/dist/chunk-ZPF4I3K2.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getRandomId, extendVirtualCoinForContract, collectContracts, warnAndFilterVtxosForScript, saveVtxosForContract } from './chunk-
|
|
2
|
-
import { getNormalizedVtxos } from './chunk-
|
|
1
|
+
import { getRandomId, extendVirtualCoinForContract, collectContracts, warnAndFilterVtxosForScript, saveVtxosForContract } from './chunk-ZJHLLDBP.js';
|
|
2
|
+
import { getNormalizedVtxos } from './chunk-AG4TFD6F.js';
|
|
3
3
|
|
|
4
4
|
// src/worker/expo/taskRunner.ts
|
|
5
5
|
async function runTasks(queue, processors, deps) {
|
|
@@ -94,5 +94,5 @@ var contractPollProcessor = {
|
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
export { CONTRACT_POLL_TASK_TYPE, contractPollProcessor, createTaskDependencies, runTasks };
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
98
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-MWVAWFX6.js.map
|
|
98
|
+
//# sourceMappingURL=chunk-MWVAWFX6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/worker/expo/taskRunner.ts","../src/worker/expo/processors/contractPollProcessor.ts"],"names":[],"mappings":";;;;AAkDA,eAAsB,QAAA,CAClB,KAAA,EACA,UAAA,EACA,IAAA,EACqB;AACrB,EAAA,MAAM,KAAA,GAAQ,MAAM,KAAA,CAAM,QAAA,EAAS;AACnC,EAAA,MAAM,YAAA,GAAe,IAAI,GAAA,CAAI,UAAA,CAAW,GAAA,CAAI,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,QAAA,EAAU,CAAC,CAAC,CAAC,CAAA;AACnE,EAAA,MAAM,UAAwB,EAAC;AAE/B,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACtB,IAAA,MAAM,SAAA,GAAY,YAAA,CAAa,GAAA,CAAI,IAAA,CAAK,IAAI,CAAA;AAE5C,IAAA,IAAI,OAAA;AAEJ,IAAA,IAAI,CAAC,SAAA,EAAW;AACZ,MAAA,OAAA,GAAU;AAAA,QACN,YAAY,IAAA,CAAK,EAAA;AAAA,QACjB,MAAM,IAAA,CAAK,IAAA;AAAA,QACX,MAAA,EAAQ;AAAA,OACZ;AAAA,IACJ,CAAA,MAAO;AACH,MAAA,IAAI;AACA,QAAA,O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from \"./taskQueue\";\nimport type { WalletRepository } from \"../../repositories/walletRepository\";\nimport type { ContractRepository } from \"../../repositories/contractRepository\";\nimport type { IndexerProvider } from \"../../providers/indexer\";\nimport type { OperatorProvider } from \"../../providers/ark\";\nimport type { ExtendedVirtualCoin, VirtualCoin } from \"../../wallet\";\nimport type { Contract } from \"../../contracts/types\";\nimport { getRandomId, extendVirtualCoinForContract } from \"../../wallet/utils\";\n\n/**\n * Shared dependencies injected into every processor at runtime.\n *\n * `extendVtxo` requires the owning contract — processors must resolve each\n * vtxo's `script` to a known contract (via the contract repository) before\n * calling this. The strict signature prevents the footgun where a missing\n * contract silently falls back to the wallet's default tapscript.\n */\nexport interface TaskDependencies {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: OperatorProvider;\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) => ExtendedVirtualCoin;\n}\n\n/**\n * A stateless unit that handles one type of task item.\n *\n * Processors must not keep in-memory state across invocations —\n * all coordination lives in the @see TaskQueue and repositories.\n *\n * The `TDeps` parameter defaults to @see TaskDependencies but\n * can be overridden for domain-specific processors (e.g. swap processing).\n */\nexport interface TaskProcessor<TDeps = TaskDependencies> {\n readonly taskType: string;\n execute(item: TaskItem, deps: TDeps): Promise<Omit<TaskResult, \"id\" | \"executedAt\">>;\n}\n\n/**\n * Run all pending tasks from the queue through matching processors.\n *\n * For each task in the inbox:\n * 1. Find the processor whose `taskType` matches `task.type`.\n * 2. Execute it, producing a @see TaskResult.\n * 3. Push the result to the outbox and remove the task from the inbox.\n *\n * Tasks with no matching processor produce a `\"noop\"` result.\n * Processor errors produce a `\"failed\"` result with the error message.\n */\nexport async function runTasks<TDeps = TaskDependencies>(\n queue: TaskQueue,\n processors: TaskProcessor<TDeps>[],\n deps: TDeps,\n): Promise<TaskResult[]> {\n const tasks = await queue.getTasks();\n const processorMap = new Map(processors.map((p) => [p.taskType, p]));\n const results: TaskResult[] = [];\n\n for (const task of tasks) {\n const processor = processorMap.get(task.type);\n\n let partial: Omit<TaskResult, \"id\" | \"executedAt\">;\n\n if (!processor) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"noop\",\n };\n } else {\n try {\n partial = await processor.execute(task, deps);\n } catch (error) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"failed\",\n data: {\n error: error instanceof Error ? error.message : String(error),\n },\n };\n }\n }\n\n const result: TaskResult = {\n ...partial,\n id: getRandomId(),\n executedAt: Date.now(),\n };\n\n await queue.pushResult(result);\n await queue.removeTask(task.id);\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Options for @see createTaskDependencies.\n */\nexport interface CreateTaskDependenciesOptions {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: OperatorProvider;\n}\n\n/**\n * Build the @see TaskDependencies needed by task processors\n * (e.g. `src/worker/expo/processors/contractPollProcessor.ts`)\n *\n * This is the same construction that `defineExpoBackgroundTask` does\n * internally, extracted so that consumers with custom schedulers\n * (e.g. bare React Native with `react-native-background-fetch`)\n * can build deps without depending on Expo.\n */\nexport function createTaskDependencies(options: CreateTaskDependenciesOptions): TaskDependencies {\n return {\n ...options,\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) =>\n extendVirtualCoinForContract(vtxo, contract),\n };\n}\n","import { collectContracts } from \"../../../repositories/contractRepository\";\nimport type { TaskItem, TaskResult } from \"../taskQueue\";\nimport type { TaskProcessor, TaskDependencies } from \"../taskRunner\";\nimport type { ExtendedVirtualCoin } from \"../../../wallet\";\nimport { getNormalizedVtxos } from \"../../../wallet/vtxo\";\nimport {\n warnAndFilterVtxosForScript,\n saveVtxosForContract,\n} from \"../../../contracts/vtxoOwnership\";\n\nexport const CONTRACT_POLL_TASK_TYPE = \"contract-poll\";\n\n/**\n * Polls the indexer for the latest VTXO state of every contract and\n * persists the results to the wallet repository.\n *\n * Replicates the polling subset of @see ContractManager.initialize:\n * 1. Load every watched contract from the contract repository.\n * 2. Paginated fetch of every VTXO (including spent) from the indexer.\n * 3. Extend each VTXO with tapscript data.\n * 4. Save to the wallet repository.\n *\n * NOTE: the indexer query deliberately omits `spendableOnly`. Every\n * repository implements `saveVtxos` as an upsert with no batch delete,\n * so filtering to spendable-only would leave VTXOs that became spent\n * between polls marked as spendable forever. Fetching the full set lets\n * the upsert overwrite stale records with their latest state.\n */\nexport const contractPollProcessor: TaskProcessor = {\n taskType: CONTRACT_POLL_TASK_TYPE,\n\n async execute(\n item: TaskItem,\n deps: TaskDependencies,\n ): Promise<Omit<TaskResult, \"id\" | \"executedAt\">> {\n const { contractRepository, walletRepository, indexerProvider, extendVtxo } = deps;\n\n // Background channel, so it covers exactly what the watcher's\n // subscription covers: `retained` rows are kept for reads only.\n const contracts = await collectContracts(contractRepository, {\n watch: [\"watched\", \"awaiting-funds\"],\n });\n let contractsProcessed = 0;\n let vtxosSaved = 0;\n\n for (const contract of contracts) {\n // Paginated fetch of spendable virtual outputs\n const pageSize = 100;\n let pageIndex = 0;\n let hasMore = true;\n const allVtxos: ExtendedVirtualCoin[] = [];\n\n while (hasMore) {\n const { vtxos, page } = await getNormalizedVtxos(indexerProvider, {\n scripts: [contract.script],\n pageIndex,\n pageSize,\n });\n\n for (const vtxo of vtxos) {\n allVtxos.push(extendVtxo(vtxo, contract));\n }\n\n hasMore = page ? vtxos.length === pageSize : false;\n pageIndex++;\n }\n\n // Skip wrong-script rows (legacy duplicates or indexer drift)\n // before persisting; the loop must keep going for the remaining\n // contracts even when one row is rejected.\n const filtered = warnAndFilterVtxosForScript(\n allVtxos,\n contract.script,\n \"contractPollProcessor\",\n );\n await saveVtxosForContract(walletRepository, contract, filtered);\n vtxosSaved += filtered.length;\n contractsProcessed++;\n }\n\n return {\n taskItemId: item.id,\n type: CONTRACT_POLL_TASK_TYPE,\n status: \"success\",\n data: { contractsProcessed, vtxosSaved },\n };\n },\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RestIndexerProvider, toSubscriptionMessage } from './chunk-
|
|
2
|
-
import {
|
|
1
|
+
import { RestIndexerProvider, toSubscriptionMessage } from './chunk-BTRCN4JJ.js';
|
|
2
|
+
import { RestOperatorProvider, DEFAULT_ARKADE_SERVER_URL, ARKADE_VERSION_HEADERS, isFetchTimeoutError, baseFetch, readSseFrames, streamFailureError } from './chunk-AG4TFD6F.js';
|
|
3
3
|
|
|
4
4
|
// src/providers/expoUtils.ts
|
|
5
5
|
async function getExpoFetch(options) {
|
|
@@ -42,35 +42,19 @@ async function* sseStreamIterator(url, abortSignal, fetchFn, headers, parseData)
|
|
|
42
42
|
if (!response.body) {
|
|
43
43
|
throw new Error("Response body is null");
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
buffer += decoder.decode(value, { stream: true });
|
|
54
|
-
const lines = buffer.split("\n");
|
|
55
|
-
for (let i = 0; i < lines.length - 1; i++) {
|
|
56
|
-
const line = lines[i].trim();
|
|
57
|
-
if (!line) continue;
|
|
58
|
-
if (line.startsWith("data:")) {
|
|
59
|
-
const jsonStr = line.substring(5).trim();
|
|
60
|
-
if (!jsonStr) continue;
|
|
61
|
-
try {
|
|
62
|
-
const data = JSON.parse(jsonStr);
|
|
63
|
-
const parsed = parseData(data);
|
|
64
|
-
if (parsed !== null) {
|
|
65
|
-
yield parsed;
|
|
66
|
-
}
|
|
67
|
-
} catch (parseError) {
|
|
68
|
-
console.error("Failed to parse SSE data:", parseError);
|
|
69
|
-
throw parseError;
|
|
70
|
-
}
|
|
45
|
+
for await (const { event, data } of readSseFrames(response.body)) {
|
|
46
|
+
if (abortSignal?.aborted) break;
|
|
47
|
+
if (event === "failure") throw streamFailureError(data);
|
|
48
|
+
if (event !== "message" || !data.trim()) continue;
|
|
49
|
+
try {
|
|
50
|
+
const parsed = parseData(JSON.parse(data));
|
|
51
|
+
if (parsed !== null) {
|
|
52
|
+
yield parsed;
|
|
71
53
|
}
|
|
54
|
+
} catch (parseError) {
|
|
55
|
+
console.error("Failed to parse SSE data:", parseError);
|
|
56
|
+
throw parseError;
|
|
72
57
|
}
|
|
73
|
-
buffer = lines[lines.length - 1];
|
|
74
58
|
}
|
|
75
59
|
} finally {
|
|
76
60
|
abortSignal?.removeEventListener("abort", cleanup);
|
|
@@ -78,7 +62,7 @@ async function* sseStreamIterator(url, abortSignal, fetchFn, headers, parseData)
|
|
|
78
62
|
}
|
|
79
63
|
|
|
80
64
|
// src/providers/expoArk.ts
|
|
81
|
-
var
|
|
65
|
+
var ExpoOperatorProvider = class extends RestOperatorProvider {
|
|
82
66
|
constructor(serverUrl = DEFAULT_ARKADE_SERVER_URL) {
|
|
83
67
|
super(serverUrl);
|
|
84
68
|
}
|
|
@@ -136,6 +120,7 @@ var ExpoArkProvider = class extends RestArkProvider {
|
|
|
136
120
|
}
|
|
137
121
|
}
|
|
138
122
|
};
|
|
123
|
+
var ExpoArkProvider = ExpoOperatorProvider;
|
|
139
124
|
|
|
140
125
|
// src/providers/expoIndexer.ts
|
|
141
126
|
var ExpoIndexerProvider = class extends RestIndexerProvider {
|
|
@@ -159,12 +144,7 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
|
|
|
159
144
|
abortSignal,
|
|
160
145
|
expoFetch,
|
|
161
146
|
{ "Content-Type": "application/json" },
|
|
162
|
-
|
|
163
|
-
const message = toSubscriptionMessage(data);
|
|
164
|
-
if (message) return message;
|
|
165
|
-
if (data.code !== void 0) throw streamFailureError(data);
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
147
|
+
toSubscriptionMessage
|
|
168
148
|
);
|
|
169
149
|
} catch (error) {
|
|
170
150
|
if (error instanceof Error && error.name === "AbortError") {
|
|
@@ -181,6 +161,6 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
|
|
|
181
161
|
}
|
|
182
162
|
};
|
|
183
163
|
|
|
184
|
-
export { ExpoArkProvider, ExpoIndexerProvider };
|
|
185
|
-
//# sourceMappingURL=chunk-
|
|
186
|
-
//# sourceMappingURL=chunk-
|
|
164
|
+
export { ExpoArkProvider, ExpoIndexerProvider, ExpoOperatorProvider };
|
|
165
|
+
//# sourceMappingURL=chunk-TUOLZBNC.js.map
|
|
166
|
+
//# sourceMappingURL=chunk-TUOLZBNC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAYA,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,WAAA,EAAa;AACb,MAAA,MAAM,IAAI,KAAA;AAAA,QACN;AAAA,OAEJ;AAAA,IACJ;AAEA,IAAA,OAAA,CAAQ,IAAA;AAAA,MACJ,wGAAA;AAAA,MAEA;AAAA,KACJ;AACA,IAAA,OAAO,SAAA;AAAA,EACX;AACJ;AAYA,gBAAuB,iBAAA,CACnB,GAAA,EACA,WAAA,EACA,OAAA,EACA,SACA,SAAA,EACgC;AAChC,EAAA,MAAM,eAAA,GAAkB,IAAI,eAAA,EAAgB;AAC5C,EAAA,MAAM,OAAA,GAAU,MAAM,eAAA,CAAgB,KAAA,EAAM;AAC5C,EAAA,WAAA,EAAa,iBAAiB,OAAA,EAAS,OAAA,EAAS,EAAE,IAAA,EAAM,MAAM,CAAA;AAE9D,EAAA,IAAI;AACA,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,GAAA,EAAK;AAAA,MAChC,OAAA,EAAS;AAAA,QACL,MAAA,EAAQ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;AACA,MAAA,MAAM,KAAA;AAAA,IACV,CAAC,CAAA;AAED,IAAA,OAAO,CAAC,YAAY,OAAA,EAAS;AACzB,MAAA,IAAI;AACA,QAAA,OAAO,iBAAA;AAAA,UACH,GAAA;AAAA,UACA,WAAA;AAAA,UACA,SAAA;AAAA,UACA,EAAE,gBAAgB,kBAAA,EAAmB;AAAA,UACrC;AAAA,SACJ;AAAA,MACJ,SAAS,KAAA,EAAO;AACZ,QAAA,IAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,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-TUOLZBNC.js","sourcesContent":["import { baseFetch, fetch } from \"../utils/fetch\";\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 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 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\";\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\" },\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,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGHUUT54D_cjs = require('./chunk-GHUUT54D.cjs');
|
|
4
4
|
var base = require('@scure/base');
|
|
5
5
|
var secp256k1_js = require('@noble/curves/secp256k1.js');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
|
|
8
8
|
// src/extension/asset/index.ts
|
|
9
9
|
var asset_exports = {};
|
|
10
|
-
|
|
10
|
+
chunkGHUUT54D_cjs.__export(asset_exports, {
|
|
11
11
|
ASSET_ID_VECTORS: () => ASSET_ID_VECTORS,
|
|
12
12
|
AssetGroup: () => AssetGroup,
|
|
13
13
|
AssetId: () => AssetId,
|
|
@@ -30,6 +30,7 @@ var AssetInputType = /* @__PURE__ */ ((AssetInputType2) => {
|
|
|
30
30
|
AssetInputType2[AssetInputType2["Unspecified"] = 0] = "Unspecified";
|
|
31
31
|
AssetInputType2[AssetInputType2["Local"] = 1] = "Local";
|
|
32
32
|
AssetInputType2[AssetInputType2["Intent"] = 2] = "Intent";
|
|
33
|
+
AssetInputType2[AssetInputType2["Proof"] = 2] = "Proof";
|
|
33
34
|
return AssetInputType2;
|
|
34
35
|
})(AssetInputType || {});
|
|
35
36
|
var AssetRefType = /* @__PURE__ */ ((AssetRefType2) => {
|
|
@@ -413,8 +414,8 @@ var AssetInput = class _AssetInput {
|
|
|
413
414
|
input.validate();
|
|
414
415
|
return input;
|
|
415
416
|
}
|
|
416
|
-
/** Create
|
|
417
|
-
static
|
|
417
|
+
/** Create a proof-backed asset input referencing an external proof transaction. */
|
|
418
|
+
static createProof(txid, vin, amount) {
|
|
418
419
|
if (!txid || txid.length === 0) {
|
|
419
420
|
throw new Error("missing input intent txid");
|
|
420
421
|
}
|
|
@@ -423,7 +424,7 @@ var AssetInput = class _AssetInput {
|
|
|
423
424
|
throw new Error("invalid input intent txid length");
|
|
424
425
|
}
|
|
425
426
|
const input = new _AssetInput({
|
|
426
|
-
type: 2 /*
|
|
427
|
+
type: 2 /* Proof */,
|
|
427
428
|
txid: buf,
|
|
428
429
|
vin,
|
|
429
430
|
amount: typeof amount === "number" ? BigInt(amount) : amount
|
|
@@ -431,6 +432,8 @@ var AssetInput = class _AssetInput {
|
|
|
431
432
|
input.validate();
|
|
432
433
|
return input;
|
|
433
434
|
}
|
|
435
|
+
/** @deprecated Use {@link createProof}. */
|
|
436
|
+
static createIntent = _AssetInput.createProof;
|
|
434
437
|
/** Decode an asset input from its hex string form. */
|
|
435
438
|
static fromString(s) {
|
|
436
439
|
return _AssetInput.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
@@ -455,7 +458,7 @@ var AssetInput = class _AssetInput {
|
|
|
455
458
|
switch (this.input.type) {
|
|
456
459
|
case 1 /* Local */:
|
|
457
460
|
break;
|
|
458
|
-
case 2 /*
|
|
461
|
+
case 2 /* Proof */:
|
|
459
462
|
if (isZeroBytes(this.input.txid)) {
|
|
460
463
|
throw new Error("missing input intent txid");
|
|
461
464
|
}
|
|
@@ -477,7 +480,7 @@ var AssetInput = class _AssetInput {
|
|
|
477
480
|
});
|
|
478
481
|
break;
|
|
479
482
|
}
|
|
480
|
-
case 2 /*
|
|
483
|
+
case 2 /* Proof */: {
|
|
481
484
|
if (reader.remaining() < TX_HASH_SIZE) {
|
|
482
485
|
throw new Error("invalid input intent txid length");
|
|
483
486
|
}
|
|
@@ -485,7 +488,7 @@ var AssetInput = class _AssetInput {
|
|
|
485
488
|
const vin = reader.readUint16LE();
|
|
486
489
|
const amount = reader.readVarUint();
|
|
487
490
|
input = new _AssetInput({
|
|
488
|
-
type: 2 /*
|
|
491
|
+
type: 2 /* Proof */,
|
|
489
492
|
txid: new Uint8Array(txid),
|
|
490
493
|
vin,
|
|
491
494
|
amount
|
|
@@ -503,7 +506,7 @@ var AssetInput = class _AssetInput {
|
|
|
503
506
|
/** Serialize the asset input into an existing buffer writer. */
|
|
504
507
|
serializeTo(writer) {
|
|
505
508
|
writer.writeByte(this.input.type);
|
|
506
|
-
if (this.input.type === 2 /*
|
|
509
|
+
if (this.input.type === 2 /* Proof */) {
|
|
507
510
|
writer.write(this.input.txid);
|
|
508
511
|
}
|
|
509
512
|
writer.writeUint16LE(this.input.vin);
|
|
@@ -942,7 +945,7 @@ var AssetGroup = class _AssetGroup {
|
|
|
942
945
|
*
|
|
943
946
|
* @returns `true` when the group has an asset id and outputs exceed local inputs
|
|
944
947
|
* @remarks
|
|
945
|
-
* Only local inputs contribute to the comparison;
|
|
948
|
+
* Only local inputs contribute to the comparison; proof-backed inputs contribute `0` here.
|
|
946
949
|
*/
|
|
947
950
|
isReissuance() {
|
|
948
951
|
const sumReducer = (s, { amount }) => s + amount;
|
|
@@ -984,14 +987,14 @@ var AssetGroup = class _AssetGroup {
|
|
|
984
987
|
}
|
|
985
988
|
}
|
|
986
989
|
/**
|
|
987
|
-
* Convert the group into its batch-leaf representation for the given
|
|
990
|
+
* Convert the group into its batch-leaf representation for the given proof txid.
|
|
988
991
|
*
|
|
989
|
-
* @param
|
|
992
|
+
* @param proofTxid - Proof transaction id used to build the leaf input reference
|
|
990
993
|
* @returns Batch-leaf asset group
|
|
991
|
-
* @see AssetInput.
|
|
994
|
+
* @see AssetInput.createProof
|
|
992
995
|
*/
|
|
993
|
-
toBatchLeafAssetGroup(
|
|
994
|
-
const leafInput = AssetInput.
|
|
996
|
+
toBatchLeafAssetGroup(proofTxid) {
|
|
997
|
+
const leafInput = AssetInput.createProof(base.hex.encode(proofTxid), 0, 0);
|
|
995
998
|
return new _AssetGroup(
|
|
996
999
|
this.assetId,
|
|
997
1000
|
this.controlAsset,
|
|
@@ -1106,9 +1109,9 @@ var Packet = class _Packet {
|
|
|
1106
1109
|
type() {
|
|
1107
1110
|
return _Packet.PACKET_TYPE;
|
|
1108
1111
|
}
|
|
1109
|
-
/** Convert the packet into the batch-leaf form for a specific
|
|
1110
|
-
leafTxPacket(
|
|
1111
|
-
const leafGroups = this.groups.map((group) => group.toBatchLeafAssetGroup(
|
|
1112
|
+
/** Convert the packet into the batch-leaf form for a specific proof transaction id. */
|
|
1113
|
+
leafTxPacket(proofTxid) {
|
|
1114
|
+
const leafGroups = this.groups.map((group) => group.toBatchLeafAssetGroup(proofTxid));
|
|
1112
1115
|
return new _Packet(leafGroups);
|
|
1113
1116
|
}
|
|
1114
1117
|
/**
|
|
@@ -1316,10 +1319,10 @@ async function indexerFetch(input, init) {
|
|
|
1316
1319
|
const lastAttempt = attempt >= maxAttempts;
|
|
1317
1320
|
let res;
|
|
1318
1321
|
try {
|
|
1319
|
-
res = await
|
|
1322
|
+
res = await chunkGHUUT54D_cjs.rateGate.runHttp(input, () => chunkGHUUT54D_cjs.baseFetch(input, init));
|
|
1320
1323
|
} catch (err) {
|
|
1321
|
-
const mapped =
|
|
1322
|
-
if (lastAttempt || !(mapped instanceof
|
|
1324
|
+
const mapped = chunkGHUUT54D_cjs.toProviderUnavailable(err, "indexer");
|
|
1325
|
+
if (lastAttempt || !(mapped instanceof chunkGHUUT54D_cjs.ProviderUnavailableError)) throw mapped;
|
|
1323
1326
|
await sleep(retryDelayMs(attempt));
|
|
1324
1327
|
continue;
|
|
1325
1328
|
}
|
|
@@ -1331,7 +1334,7 @@ async function indexerFetch(input, init) {
|
|
|
1331
1334
|
body = void 0;
|
|
1332
1335
|
}
|
|
1333
1336
|
try {
|
|
1334
|
-
|
|
1337
|
+
chunkGHUUT54D_cjs.throwIfHttpUnavailable(res, "indexer", body);
|
|
1335
1338
|
} catch (err) {
|
|
1336
1339
|
if (lastAttempt) throw err;
|
|
1337
1340
|
await sleep(retryDelayMs(attempt));
|
|
@@ -1360,7 +1363,7 @@ var ChainTxType = /* @__PURE__ */ ((ChainTxType2) => {
|
|
|
1360
1363
|
return ChainTxType2;
|
|
1361
1364
|
})(ChainTxType || {});
|
|
1362
1365
|
var RestIndexerProvider = class {
|
|
1363
|
-
constructor(serverUrl =
|
|
1366
|
+
constructor(serverUrl = chunkGHUUT54D_cjs.DEFAULT_ARKADE_SERVER_URL, options = {}) {
|
|
1364
1367
|
this.serverUrl = serverUrl;
|
|
1365
1368
|
this.eventSource = options.eventSource;
|
|
1366
1369
|
}
|
|
@@ -1487,8 +1490,8 @@ var RestIndexerProvider = class {
|
|
|
1487
1490
|
try {
|
|
1488
1491
|
while (!abortSignal?.aborted) {
|
|
1489
1492
|
try {
|
|
1490
|
-
const currentIterator =
|
|
1491
|
-
|
|
1493
|
+
const currentIterator = chunkGHUUT54D_cjs.eventSourceIterator(
|
|
1494
|
+
chunkGHUUT54D_cjs.resolveEventSource(override)(url)
|
|
1492
1495
|
);
|
|
1493
1496
|
iterator = currentIterator;
|
|
1494
1497
|
for await (const event of currentIterator) {
|
|
@@ -1505,14 +1508,14 @@ var RestIndexerProvider = class {
|
|
|
1505
1508
|
if (abortSignal?.aborted || error instanceof Error && error.name === "AbortError") {
|
|
1506
1509
|
break;
|
|
1507
1510
|
}
|
|
1508
|
-
if (
|
|
1511
|
+
if (chunkGHUUT54D_cjs.isFetchTimeoutError(error)) {
|
|
1509
1512
|
console.debug("Timeout error ignored");
|
|
1510
1513
|
continue;
|
|
1511
1514
|
}
|
|
1512
|
-
if (
|
|
1515
|
+
if (chunkGHUUT54D_cjs.isEventSourceError(error)) {
|
|
1513
1516
|
throw error;
|
|
1514
1517
|
}
|
|
1515
|
-
if (
|
|
1518
|
+
if (chunkGHUUT54D_cjs.isEventSourceUnavailableError(error)) throw error;
|
|
1516
1519
|
console.error("Subscription error:", error);
|
|
1517
1520
|
throw error;
|
|
1518
1521
|
} finally {
|
|
@@ -1641,7 +1644,7 @@ var RestIndexerProvider = class {
|
|
|
1641
1644
|
}
|
|
1642
1645
|
const data = await this.fetchVtxosJson(url);
|
|
1643
1646
|
return {
|
|
1644
|
-
vtxos: data.vtxos.map(
|
|
1647
|
+
vtxos: data.vtxos.map(chunkGHUUT54D_cjs.convertVtxo),
|
|
1645
1648
|
page: data.page
|
|
1646
1649
|
};
|
|
1647
1650
|
}
|
|
@@ -1750,9 +1753,9 @@ function toSubscriptionResponse(event) {
|
|
|
1750
1753
|
return {
|
|
1751
1754
|
txid: event.txid,
|
|
1752
1755
|
scripts: event.scripts || [],
|
|
1753
|
-
newVtxos: (event.newVtxos || []).map(
|
|
1754
|
-
spentVtxos: (event.spentVtxos || []).map(
|
|
1755
|
-
sweptVtxos: (event.sweptVtxos || []).map(
|
|
1756
|
+
newVtxos: (event.newVtxos || []).map(chunkGHUUT54D_cjs.convertVtxo),
|
|
1757
|
+
spentVtxos: (event.spentVtxos || []).map(chunkGHUUT54D_cjs.convertVtxo),
|
|
1758
|
+
sweptVtxos: (event.sweptVtxos || []).map(chunkGHUUT54D_cjs.convertVtxo),
|
|
1756
1759
|
tx: event.tx,
|
|
1757
1760
|
checkpointTxs: event.checkpointTxs
|
|
1758
1761
|
};
|
|
@@ -1864,5 +1867,5 @@ exports.Packet = Packet;
|
|
|
1864
1867
|
exports.RestIndexerProvider = RestIndexerProvider;
|
|
1865
1868
|
exports.asset_exports = asset_exports;
|
|
1866
1869
|
exports.toSubscriptionMessage = toSubscriptionMessage;
|
|
1867
|
-
//# sourceMappingURL=chunk-
|
|
1868
|
-
//# sourceMappingURL=chunk-
|
|
1870
|
+
//# sourceMappingURL=chunk-WXNSISXK.cjs.map
|
|
1871
|
+
//# sourceMappingURL=chunk-WXNSISXK.cjs.map
|