@arkade-os/sdk 0.4.77 → 0.4.78
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-MmJyAnu-.d.cts → asyncStorageTaskQueue-DiXxP-nQ.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-DTl0WM7E.d.ts → asyncStorageTaskQueue-YW2t31_o.d.ts} +2 -2
- package/dist/{chunk-52OA3UIC.js → chunk-7KIGEOYT.js} +8 -4
- package/dist/chunk-7KIGEOYT.js.map +1 -0
- package/dist/{chunk-HKOFYHZP.js → chunk-CTFYT24G.js} +3 -3
- package/dist/{chunk-HKOFYHZP.js.map → chunk-CTFYT24G.js.map} +1 -1
- package/dist/{chunk-4LP6XOMW.cjs → chunk-DFWLP3MD.cjs} +17 -17
- package/dist/{chunk-4LP6XOMW.cjs.map → chunk-DFWLP3MD.cjs.map} +1 -1
- package/dist/{chunk-H62OOAS4.cjs → chunk-IAM5IEVT.cjs} +17 -17
- package/dist/{chunk-H62OOAS4.cjs.map → chunk-IAM5IEVT.cjs.map} +1 -1
- package/dist/{chunk-Y4YK44IM.cjs → chunk-KEEZSFLI.cjs} +10 -10
- package/dist/{chunk-Y4YK44IM.cjs.map → chunk-KEEZSFLI.cjs.map} +1 -1
- package/dist/{chunk-MLOZHTBN.js → chunk-LKAASQTL.js} +87 -40
- package/dist/chunk-LKAASQTL.js.map +1 -0
- package/dist/{chunk-YKNTUOUG.js → chunk-OUHUC26M.js} +4 -4
- package/dist/{chunk-YKNTUOUG.js.map → chunk-OUHUC26M.js.map} +1 -1
- package/dist/{chunk-T6MGH4V4.js → chunk-P766MOPU.js} +4 -4
- package/dist/{chunk-T6MGH4V4.js.map → chunk-P766MOPU.js.map} +1 -1
- package/dist/{chunk-CJN4CUEU.cjs → chunk-PWIESIO6.cjs} +8 -3
- package/dist/chunk-PWIESIO6.cjs.map +1 -0
- package/dist/{chunk-YJEWWLOQ.cjs → chunk-VJ7M6WKB.cjs} +535 -488
- package/dist/chunk-VJ7M6WKB.cjs.map +1 -0
- package/dist/{chunk-LUWSY2QO.cjs → chunk-Y7BVR6SQ.cjs} +49 -49
- package/dist/{chunk-LUWSY2QO.cjs.map → chunk-Y7BVR6SQ.cjs.map} +1 -1
- package/dist/{chunk-ACPANSOX.js → chunk-ZOCJ7E6M.js} +3 -3
- package/dist/{chunk-ACPANSOX.js.map → chunk-ZOCJ7E6M.js.map} +1 -1
- 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-QPCGaD_z.d.cts → delegate-DaNNUI_B.d.cts} +1 -1
- package/dist/{delegate-CjcysR7s.d.ts → delegate-b2Wiymoj.d.ts} +1 -1
- package/dist/{hdWalletCapable--pMncWbC.d.ts → hdWalletCapable-B2XVTOvu.d.ts} +2 -2
- package/dist/{hdWalletCapable-Bp_p0WLj.d.cts → hdWalletCapable-D6PqWpuW.d.cts} +2 -2
- package/dist/{index-BMY272ns.d.cts → index-BlB97fYl.d.cts} +2 -2
- package/dist/{index-Ie_ak2zY.d.ts → index-CAS4GyN-.d.cts} +1 -0
- package/dist/{index-Ie_ak2zY.d.cts → index-CAS4GyN-.d.ts} +1 -0
- package/dist/{index-m-EM-e8D.d.ts → index-CYsKAXog.d.ts} +2 -2
- package/dist/index.cjs +304 -304
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- 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-CqrlrJEt.d.ts → taskRunner-BJj7xe35.d.ts} +2 -2
- package/dist/{taskRunner-BgRowCqB.d.cts → taskRunner-HS2d2oda.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-52OA3UIC.js.map +0 -1
- package/dist/chunk-CJN4CUEU.cjs.map +0 -1
- package/dist/chunk-MLOZHTBN.js.map +0 -1
- package/dist/chunk-YJEWWLOQ.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkVJ7M6WKB_cjs = require('./chunk-VJ7M6WKB.cjs');
|
|
4
|
+
var chunkPWIESIO6_cjs = require('./chunk-PWIESIO6.cjs');
|
|
5
5
|
|
|
6
6
|
// src/worker/expo/taskRunner.ts
|
|
7
7
|
async function runTasks(queue, processors, deps) {
|
|
@@ -33,7 +33,7 @@ async function runTasks(queue, processors, deps) {
|
|
|
33
33
|
}
|
|
34
34
|
const result = {
|
|
35
35
|
...partial,
|
|
36
|
-
id:
|
|
36
|
+
id: chunkVJ7M6WKB_cjs.getRandomId(),
|
|
37
37
|
executedAt: Date.now()
|
|
38
38
|
};
|
|
39
39
|
await queue.pushResult(result);
|
|
@@ -45,7 +45,7 @@ async function runTasks(queue, processors, deps) {
|
|
|
45
45
|
function createTaskDependencies(options) {
|
|
46
46
|
return {
|
|
47
47
|
...options,
|
|
48
|
-
extendVtxo: (vtxo, contract) =>
|
|
48
|
+
extendVtxo: (vtxo, contract) => chunkVJ7M6WKB_cjs.extendVirtualCoinForContract(vtxo, contract)
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -55,7 +55,7 @@ var contractPollProcessor = {
|
|
|
55
55
|
taskType: CONTRACT_POLL_TASK_TYPE,
|
|
56
56
|
async execute(item, deps) {
|
|
57
57
|
const { contractRepository, walletRepository, indexerProvider, extendVtxo } = deps;
|
|
58
|
-
const contracts = (await contractRepository.getContracts()).filter(
|
|
58
|
+
const contracts = (await contractRepository.getContracts()).filter(chunkVJ7M6WKB_cjs.isWatchedContract);
|
|
59
59
|
let contractsProcessed = 0;
|
|
60
60
|
let vtxosSaved = 0;
|
|
61
61
|
for (const contract of contracts) {
|
|
@@ -64,7 +64,7 @@ var contractPollProcessor = {
|
|
|
64
64
|
let hasMore = true;
|
|
65
65
|
const allVtxos = [];
|
|
66
66
|
while (hasMore) {
|
|
67
|
-
const { vtxos, page } = await
|
|
67
|
+
const { vtxos, page } = await chunkPWIESIO6_cjs.getNormalizedVtxos(indexerProvider, {
|
|
68
68
|
scripts: [contract.script],
|
|
69
69
|
pageIndex,
|
|
70
70
|
pageSize
|
|
@@ -75,12 +75,12 @@ var contractPollProcessor = {
|
|
|
75
75
|
hasMore = page ? vtxos.length === pageSize : false;
|
|
76
76
|
pageIndex++;
|
|
77
77
|
}
|
|
78
|
-
const filtered =
|
|
78
|
+
const filtered = chunkVJ7M6WKB_cjs.warnAndFilterVtxosForScript(
|
|
79
79
|
allVtxos,
|
|
80
80
|
contract.script,
|
|
81
81
|
"contractPollProcessor"
|
|
82
82
|
);
|
|
83
|
-
await
|
|
83
|
+
await chunkVJ7M6WKB_cjs.saveVtxosForContract(walletRepository, contract, filtered);
|
|
84
84
|
vtxosSaved += filtered.length;
|
|
85
85
|
contractsProcessed++;
|
|
86
86
|
}
|
|
@@ -97,5 +97,5 @@ exports.CONTRACT_POLL_TASK_TYPE = CONTRACT_POLL_TASK_TYPE;
|
|
|
97
97
|
exports.contractPollProcessor = contractPollProcessor;
|
|
98
98
|
exports.createTaskDependencies = createTaskDependencies;
|
|
99
99
|
exports.runTasks = runTasks;
|
|
100
|
-
//# sourceMappingURL=chunk-
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
100
|
+
//# sourceMappingURL=chunk-KEEZSFLI.cjs.map
|
|
101
|
+
//# sourceMappingURL=chunk-KEEZSFLI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/worker/expo/taskRunner.ts","../src/worker/expo/processors/contractPollProcessor.ts"],"names":["getRandomId","extendVirtualCoinForContract","isWatchedContract","getNormalizedVtxos","warnAndFilterVtxosForScript","saveVtxosForContract"],"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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{ WalletRepository } from \"../../repositories/walletRepository\";\nimport type { ContractRepository } from \"../../repositories/contractRepository\";\nimport type { IndexerProvider } from \"../../providers/indexer\";\nimport type { ArkProvider } 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: ArkProvider;\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: ArkProvider;\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 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\";\nimport { isWatchedContract } from \"../../../contracts/types\";\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 contractRepository.getContracts()).filter(isWatchedContract);\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
|
+
{"version":3,"sources":["../src/worker/expo/taskRunner.ts","../src/worker/expo/processors/contractPollProcessor.ts"],"names":["getRandomId","extendVirt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CAAS,IAAA,CAAK,UAAA,CAAW,IAAA,EAAM,QAAQ,CAAC,CAAA;AAAA,QAC5C;AAEA,QAAA,OAAA,GAAU,IAAA,GAAO,KAAA,CAAM,MAAA,KAAW,QAAA,GAAW,KAAA;AAC7C,QAAA,SAAA,EAAA;AAAA,MACJ;AAKA,MAAA,MAAM,QAAA,GAAWC,6CAAA;AAAA,QACb,QAAA;AAAA,QACA,QAAA,CAAS,MAAA;AAAA,QACT;AAAA,OACJ;AACA,MAAA,MAAMC,sCAAA,CAAqB,gBAAA,EAAkB,QAAA,EAAU,QAAQ,CAAA;AAC/D,MAAA,UAAA,IAAc,QAAA,CAAS,MAAA;AACvB,MAAA,kBAAA,EAAA;AAAA,IACJ;AAEA,IAAA,OAAO;AAAA,MACH,YAAY,IAAA,CAAK,EAAA;AAAA,MACjB,IAAA,EAAM,uBAAA;AAAA,MACN,MAAA,EAAQ,SAAA;AAAA,MACR,IAAA,EAAM,EAAE,kBAAA,EAAoB,UAAA;AAAW,KAC3C;AAAA,EACJ;AACJ","file":"chunk-KEEZSFLI.cjs","sourcesContent":["import type { TaskItem, TaskResult, TaskQueue } from \"./taskQueue\";\nimport type { WalletRepository } from \"../../repositories/walletRepository\";\nimport type { ContractRepository } from \"../../repositories/contractRepository\";\nimport type { IndexerProvider } from \"../../providers/indexer\";\nimport type { ArkProvider } 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: ArkProvider;\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: ArkProvider;\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 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\";\nimport { isWatchedContract } from \"../../../contracts/types\";\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 contractRepository.getContracts()).filter(isWatchedContract);\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,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, Transaction,
|
|
1
|
+
import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-CTFYT24G.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-ZOCJ7E6M.js';
|
|
3
|
+
import { VtxoScript, Transaction, requiresForfeit, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, isVtxoSpent, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, timelockToSequence, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, assertAllowedSighashTypes, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, formatSighash, normalizeVtxo, getSequence, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isRecoverable, isExpired, PrevoutTxField, fetchVtxoCreatedAtByTxid, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError } from './chunk-7KIGEOYT.js';
|
|
4
4
|
import { __export } from './chunk-NSBPE2FW.js';
|
|
5
5
|
import { sha256 as sha256$1, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
|
|
6
6
|
import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
|
|
@@ -5957,8 +5957,8 @@ function noteTapscript(preimageHash) {
|
|
|
5957
5957
|
return Script.encode(["SHA256", preimageHash, "EQUAL"]);
|
|
5958
5958
|
}
|
|
5959
5959
|
var ArkadeCash = class _ArkadeCash {
|
|
5960
|
-
constructor(privateKey, serverPubKey,
|
|
5961
|
-
this.csvTimelock =
|
|
5960
|
+
constructor(privateKey, serverPubKey, csvTimelock2, hrp = _ArkadeCash.DefaultHRP) {
|
|
5961
|
+
this.csvTimelock = csvTimelock2;
|
|
5962
5962
|
this.hrp = hrp;
|
|
5963
5963
|
if (privateKey.length !== 32) {
|
|
5964
5964
|
throw new Error(
|
|
@@ -5998,8 +5998,8 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5998
5998
|
get publicKey() {
|
|
5999
5999
|
return this._publicKey.slice();
|
|
6000
6000
|
}
|
|
6001
|
-
static generate(serverPubKey,
|
|
6002
|
-
return new _ArkadeCash(randomPrivateKeyBytes(), serverPubKey,
|
|
6001
|
+
static generate(serverPubKey, csvTimelock2, hrp) {
|
|
6002
|
+
return new _ArkadeCash(randomPrivateKeyBytes(), serverPubKey, csvTimelock2, hrp);
|
|
6003
6003
|
}
|
|
6004
6004
|
static fromString(encoded) {
|
|
6005
6005
|
const decoded = bech32m.decodeUnsafe(encoded.trim().toLowerCase(), 1023);
|
|
@@ -6019,8 +6019,8 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6019
6019
|
const privateKey = data.slice(1, 33);
|
|
6020
6020
|
const serverPubKey = data.slice(33, 65);
|
|
6021
6021
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
6022
|
-
const
|
|
6023
|
-
return new _ArkadeCash(privateKey, serverPubKey,
|
|
6022
|
+
const csvTimelock2 = sequenceToTimelock(sequence);
|
|
6023
|
+
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
|
|
6024
6024
|
}
|
|
6025
6025
|
toString() {
|
|
6026
6026
|
const data = new Uint8Array(_ArkadeCash.PayloadLength);
|
|
@@ -7803,7 +7803,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7803
7803
|
Address(getNetwork(network)).decode(forfeitAddress)
|
|
7804
7804
|
);
|
|
7805
7805
|
const forfeits = await Promise.all(
|
|
7806
|
-
vtxos.filter((v) =>
|
|
7806
|
+
vtxos.filter((v) => requiresForfeit(v)).map(async (coin) => {
|
|
7807
7807
|
const forfeit = await makeDelegateForfeitTx(
|
|
7808
7808
|
coin,
|
|
7809
7809
|
dust,
|
|
@@ -8703,9 +8703,10 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8703
8703
|
`${context}: refusing to persist ${mismatches.length} VTXO(s) whose script does not match ${script}: ${detail}`
|
|
8704
8704
|
);
|
|
8705
8705
|
}
|
|
8706
|
-
async function getVtxosForContract(repo, contract) {
|
|
8707
|
-
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8708
|
-
|
|
8706
|
+
async function getVtxosForContract(repo, contract, options) {
|
|
8707
|
+
const vtxos = options?.unspentOnly && repo.getVtxosForScripts ? await repo.getVtxosForScripts([contract.script], options) : repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8708
|
+
const normalized = vtxos.map(normalizeVtxo);
|
|
8709
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !isVtxoSpent(vtxo)) : normalized;
|
|
8709
8710
|
}
|
|
8710
8711
|
function hasRecordedSpend(vtxo) {
|
|
8711
8712
|
return vtxo.isSpent === true && (!!vtxo.spentBy || !!vtxo.arkTxId || !!vtxo.settledBy);
|
|
@@ -12523,7 +12524,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12523
12524
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
12524
12525
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
12525
12526
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
12526
|
-
const
|
|
12527
|
+
const csvTimelock2 = timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
12527
12528
|
const base = {
|
|
12528
12529
|
script: hex.encode(tapscript.pkScript),
|
|
12529
12530
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -12545,7 +12546,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12545
12546
|
pubKey: hex.encode(pubKey),
|
|
12546
12547
|
serverPubKey: hex.encode(serverPubKey),
|
|
12547
12548
|
delegatePubKey: hex.encode(tapscript.options.delegatePubKey),
|
|
12548
|
-
csvTimelock
|
|
12549
|
+
csvTimelock: csvTimelock2
|
|
12549
12550
|
}
|
|
12550
12551
|
} : {
|
|
12551
12552
|
...base,
|
|
@@ -12553,7 +12554,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12553
12554
|
params: {
|
|
12554
12555
|
pubKey: hex.encode(pubKey),
|
|
12555
12556
|
serverPubKey: hex.encode(serverPubKey),
|
|
12556
|
-
csvTimelock
|
|
12557
|
+
csvTimelock: csvTimelock2
|
|
12557
12558
|
}
|
|
12558
12559
|
};
|
|
12559
12560
|
return { tapscript, params };
|
|
@@ -12908,6 +12909,34 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12908
12909
|
return true;
|
|
12909
12910
|
});
|
|
12910
12911
|
}
|
|
12912
|
+
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
12913
|
+
const candidates = inputs.filter(isVirtualCoin).map(normalizeVtxo).filter((v) => !v.isSwept);
|
|
12914
|
+
if (candidates.length === 0) return inputs;
|
|
12915
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
12916
|
+
const suspects = candidates.filter(
|
|
12917
|
+
(v) => isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
12918
|
+
);
|
|
12919
|
+
if (suspects.length === 0) return inputs;
|
|
12920
|
+
let sweptNow;
|
|
12921
|
+
try {
|
|
12922
|
+
const manager = await wallet.getContractManager();
|
|
12923
|
+
await manager.refreshOutpoints(suspects.map(({ txid, vout }) => ({ txid, vout })));
|
|
12924
|
+
const suspectKeys = new Set(suspects.map((v) => `${v.txid}:${v.vout}`));
|
|
12925
|
+
const fresh = await wallet.getVtxos({ withRecoverable: true });
|
|
12926
|
+
sweptNow = new Set(
|
|
12927
|
+
fresh.filter((v) => v.isSwept && suspectKeys.has(`${v.txid}:${v.vout}`)).map((v) => `${v.txid}:${v.vout}`)
|
|
12928
|
+
);
|
|
12929
|
+
} catch (e) {
|
|
12930
|
+
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
12931
|
+
throw isRetryableProviderError(e) ? new ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
12932
|
+
}
|
|
12933
|
+
if (sweptNow.size === 0) return inputs;
|
|
12934
|
+
return inputs.map((input) => {
|
|
12935
|
+
if (!isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
12936
|
+
const swept = { ...normalizeVtxo(input), isSwept: true };
|
|
12937
|
+
return { ...swept, virtualStatus: toVirtualStatus(swept) };
|
|
12938
|
+
});
|
|
12939
|
+
}
|
|
12911
12940
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
12912
12941
|
var UNROLLED_REASON = "was unilaterally exited and lives onchain \u2014 `Unroll.completeUnroll` is the only spend that reaches it";
|
|
12913
12942
|
function omittedOutpoints(before, after) {
|
|
@@ -13407,7 +13436,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13407
13436
|
async getBalance() {
|
|
13408
13437
|
const [boardingUtxos, snapshot] = await Promise.all([
|
|
13409
13438
|
this.getBoardingUtxos(),
|
|
13410
|
-
|
|
13439
|
+
// The bucketer drops every spent coin and the gate reads contracts only.
|
|
13440
|
+
this.contractSnapshot(void 0, { unspentOnly: true })
|
|
13411
13441
|
]);
|
|
13412
13442
|
const vtxos = filterSnapshotVtxos(
|
|
13413
13443
|
snapshot,
|
|
@@ -13460,7 +13490,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13460
13490
|
*/
|
|
13461
13491
|
async getVtxos(filter) {
|
|
13462
13492
|
return filterSnapshotVtxos(
|
|
13463
|
-
|
|
13493
|
+
// Only an unrolled coin is returned spent, so no other read needs spent rows.
|
|
13494
|
+
await this.contractSnapshot(void 0, { unspentOnly: !filter?.withUnrolled }),
|
|
13464
13495
|
filter,
|
|
13465
13496
|
this._pendingSpendOutpoints
|
|
13466
13497
|
);
|
|
@@ -14140,12 +14171,12 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14140
14171
|
];
|
|
14141
14172
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
14142
14173
|
for (const serverPubKey of baselineSigners) {
|
|
14143
|
-
for (const
|
|
14144
|
-
const csvTimelockStr = timelockToSequence(
|
|
14174
|
+
for (const csvTimelock2 of this.walletContractTimelocks) {
|
|
14175
|
+
const csvTimelockStr = timelockToSequence(csvTimelock2).toString();
|
|
14145
14176
|
const defaultScript = new DefaultVtxo.Script({
|
|
14146
14177
|
pubKey: baselinePubkey,
|
|
14147
14178
|
serverPubKey,
|
|
14148
|
-
csvTimelock
|
|
14179
|
+
csvTimelock: csvTimelock2
|
|
14149
14180
|
});
|
|
14150
14181
|
const defaultScriptHex = hex.encode(defaultScript.pkScript);
|
|
14151
14182
|
if (!seenBaselineScripts.has(defaultScriptHex)) {
|
|
@@ -14167,7 +14198,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14167
14198
|
pubKey: baselinePubkey,
|
|
14168
14199
|
serverPubKey,
|
|
14169
14200
|
delegatePubKey,
|
|
14170
|
-
csvTimelock
|
|
14201
|
+
csvTimelock: csvTimelock2
|
|
14171
14202
|
});
|
|
14172
14203
|
const delegateScriptHex = hex.encode(delegateScript.pkScript);
|
|
14173
14204
|
if (seenBaselineScripts.has(delegateScriptHex)) continue;
|
|
@@ -14712,7 +14743,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14712
14743
|
...this._boardingTapscript.options,
|
|
14713
14744
|
pubKey
|
|
14714
14745
|
});
|
|
14715
|
-
const
|
|
14746
|
+
const csvTimelock2 = tapscript.options.csvTimelock ?? DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14716
14747
|
return {
|
|
14717
14748
|
tapscript,
|
|
14718
14749
|
params: {
|
|
@@ -14720,7 +14751,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14720
14751
|
params: {
|
|
14721
14752
|
pubKey: hex.encode(pubKey),
|
|
14722
14753
|
serverPubKey: hex.encode(tapscript.options.serverPubKey),
|
|
14723
|
-
csvTimelock: timelockToSequence(
|
|
14754
|
+
csvTimelock: timelockToSequence(csvTimelock2).toString()
|
|
14724
14755
|
},
|
|
14725
14756
|
script: hex.encode(tapscript.pkScript),
|
|
14726
14757
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
@@ -15456,6 +15487,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15456
15487
|
outputs: [output]
|
|
15457
15488
|
};
|
|
15458
15489
|
}
|
|
15490
|
+
params = {
|
|
15491
|
+
...params,
|
|
15492
|
+
inputs: await refreshSweptStateOfExpiredInputs(this, params.inputs)
|
|
15493
|
+
};
|
|
15459
15494
|
const onchainOutputIndexes = [];
|
|
15460
15495
|
const outputs = [];
|
|
15461
15496
|
let hasOffchainOutputs = false;
|
|
@@ -15728,7 +15763,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15728
15763
|
}
|
|
15729
15764
|
continue;
|
|
15730
15765
|
}
|
|
15731
|
-
if (
|
|
15766
|
+
if (!requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15732
15767
|
continue;
|
|
15733
15768
|
}
|
|
15734
15769
|
if (connectorsLeaves.length === 0) {
|
|
@@ -19000,7 +19035,8 @@ var WalletMessageHandler = class {
|
|
|
19000
19035
|
async handleGetBalance() {
|
|
19001
19036
|
const [boardingUtxos, { snapshot, vtxos: allVtxos }] = await Promise.all([
|
|
19002
19037
|
this.getAllBoardingUtxos(),
|
|
19003
|
-
|
|
19038
|
+
// The bucketer drops every spent coin and the gate reads contracts only.
|
|
19039
|
+
this.repoSnapshot({ unspentOnly: true })
|
|
19004
19040
|
]);
|
|
19005
19041
|
const pendingOutpoints = this.readonlyWallet?.pendingRecoveryOutpointsIn(snapshot) ?? /* @__PURE__ */ new Set();
|
|
19006
19042
|
let confirmed = 0;
|
|
@@ -19267,9 +19303,9 @@ var WalletMessageHandler = class {
|
|
|
19267
19303
|
if (!this.readonlyWallet) {
|
|
19268
19304
|
throw new WalletNotInitializedError();
|
|
19269
19305
|
}
|
|
19270
|
-
const allVtxos = await this.getVtxosFromRepo();
|
|
19271
|
-
const dustAmount = this.readonlyWallet.dustAmount;
|
|
19272
19306
|
const withUnrolled = message.payload.filter?.withUnrolled ?? false;
|
|
19307
|
+
const allVtxos = await this.getVtxosFromRepo({ unspentOnly: !withUnrolled });
|
|
19308
|
+
const dustAmount = this.readonlyWallet.dustAmount;
|
|
19273
19309
|
const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
|
|
19274
19310
|
return allVtxos.filter((v) => {
|
|
19275
19311
|
if (v.isUnrolled) {
|
|
@@ -19319,8 +19355,8 @@ var WalletMessageHandler = class {
|
|
|
19319
19355
|
* Read all virtual outputs from the repository, aggregated across all contract
|
|
19320
19356
|
* addresses and the wallet's primary address, with deduplication.
|
|
19321
19357
|
*/
|
|
19322
|
-
async getVtxosFromRepo() {
|
|
19323
|
-
return (await this.repoSnapshot()).vtxos;
|
|
19358
|
+
async getVtxosFromRepo(options) {
|
|
19359
|
+
return (await this.repoSnapshot(options)).vtxos;
|
|
19324
19360
|
}
|
|
19325
19361
|
/**
|
|
19326
19362
|
* The worker's equivalent of `ReadonlyWallet.contractSnapshot`: contracts
|
|
@@ -19335,7 +19371,7 @@ var WalletMessageHandler = class {
|
|
|
19335
19371
|
* what it knows is closed — so the coins of a just-registered escrowed
|
|
19336
19372
|
* contract would count as available until the next poll.
|
|
19337
19373
|
*/
|
|
19338
|
-
async repoSnapshot() {
|
|
19374
|
+
async repoSnapshot(options) {
|
|
19339
19375
|
if (!this.walletRepository || !this.readonlyWallet) return { snapshot: [], vtxos: [] };
|
|
19340
19376
|
const seen = /* @__PURE__ */ new Set();
|
|
19341
19377
|
const allVtxos = [];
|
|
@@ -19357,7 +19393,9 @@ var WalletMessageHandler = class {
|
|
|
19357
19393
|
for (const contract of contracts) {
|
|
19358
19394
|
snapshot.push({
|
|
19359
19395
|
contract,
|
|
19360
|
-
vtxos: addVtxos(
|
|
19396
|
+
vtxos: addVtxos(
|
|
19397
|
+
await getVtxosForContract(this.walletRepository, contract, options)
|
|
19398
|
+
)
|
|
19361
19399
|
});
|
|
19362
19400
|
}
|
|
19363
19401
|
const walletAddress = await this.readonlyWallet.getAddress();
|
|
@@ -19370,10 +19408,11 @@ var WalletMessageHandler = class {
|
|
|
19370
19408
|
);
|
|
19371
19409
|
}
|
|
19372
19410
|
addVtxos(
|
|
19373
|
-
await getVtxosForContract(
|
|
19374
|
-
|
|
19375
|
-
address: walletAddress
|
|
19376
|
-
|
|
19411
|
+
await getVtxosForContract(
|
|
19412
|
+
this.walletRepository,
|
|
19413
|
+
{ script: walletScript, address: walletAddress },
|
|
19414
|
+
options
|
|
19415
|
+
)
|
|
19377
19416
|
);
|
|
19378
19417
|
return { snapshot, vtxos: allVtxos };
|
|
19379
19418
|
}
|
|
@@ -23837,7 +23876,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23837
23876
|
boardingIndices.push(boardingIdx);
|
|
23838
23877
|
continue;
|
|
23839
23878
|
}
|
|
23840
|
-
if (
|
|
23879
|
+
if (!requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
23841
23880
|
continue;
|
|
23842
23881
|
}
|
|
23843
23882
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -24048,6 +24087,14 @@ function providedWitness(witness) {
|
|
|
24048
24087
|
return !item.injected && item.type !== "signature";
|
|
24049
24088
|
});
|
|
24050
24089
|
}
|
|
24090
|
+
function csvTimelock(leafName, operand) {
|
|
24091
|
+
if (typeof operand === "string") return { type: "blocks", value: operand };
|
|
24092
|
+
const timelock = operand >= 0n && operand < 0x80000000n ? sequenceToTimelock(Number(operand)) : void 0;
|
|
24093
|
+
if (!timelock || BigInt(timelockToSequence(timelock)) !== operand) {
|
|
24094
|
+
fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
|
|
24095
|
+
}
|
|
24096
|
+
return timelock;
|
|
24097
|
+
}
|
|
24051
24098
|
function parseLeaf(leaf, hasCovenant, instantiations, extras) {
|
|
24052
24099
|
const asm = leaf.asm;
|
|
24053
24100
|
let index = 0;
|
|
@@ -24062,7 +24109,7 @@ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
|
|
|
24062
24109
|
let cltv;
|
|
24063
24110
|
if (asm.length >= index + 3 && asm[index + 2] === "OP_DROP") {
|
|
24064
24111
|
const operand = asm[index].startsWith("<") && asm[index].endsWith(">") ? `$${asm[index].slice(1, -1)}` : BigInt(asm[index]);
|
|
24065
|
-
if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv =
|
|
24112
|
+
if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv = csvTimelock(leaf.name, operand);
|
|
24066
24113
|
else if (asm[index + 1] === "OP_CHECKLOCKTIMEVERIFY") cltv = operand;
|
|
24067
24114
|
else fail(`leaf '${leaf.name}': unexpected timelock opcode ${asm[index + 1]}`);
|
|
24068
24115
|
index += 3;
|
|
@@ -25114,5 +25161,5 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
25114
25161
|
*/
|
|
25115
25162
|
|
|
25116
25163
|
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, ContractRepositoryImpl, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, 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, MIGRATION_KEY, MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, OversizedChangeError, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, 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, WalletRepositoryImpl, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertNoAssets, assertNoSelection, 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, getMigrationStatus, 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, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, requiresMigration, resolveAssetAmount, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, selectionOf, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
|
|
25117
|
-
//# sourceMappingURL=chunk-
|
|
25118
|
-
//# sourceMappingURL=chunk-
|
|
25164
|
+
//# sourceMappingURL=chunk-LKAASQTL.js.map
|
|
25165
|
+
//# sourceMappingURL=chunk-LKAASQTL.js.map
|