fix(js): add typed ChallengeResult interface for PoW worker results

The process() function in fast.ts declared Promise<string> but actually
resolved with the full worker message object { hash, data, difficulty,
nonce }. main.tsx papered over this with `any`. Introduce a shared
ChallengeResult type so the contract between workers, algorithms, and
the main component is enforced by the type checker.

Assisted-by: Claude Opus 4.6 via Claude Code
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2026-03-20 11:34:13 +00:00
parent e010d605e8
commit f5a51b8bbd
4 changed files with 13 additions and 3 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
import { render } from "preact";
import { useState, useEffect, useRef } from "preact/hooks";
import algorithms from "./algorithms";
import algorithms, { ChallengeResult } from "./algorithms";
// from Xeact
const u = (url: string = "", params: Record<string, any> = {}) => {
@@ -211,7 +211,7 @@ function App({ anubisVersion, basePrefix }: AppProps) {
}
},
)
.then((result: any) => {
.then((result: ChallengeResult) => {
const t1 = Date.now();
const { hash, nonce } = result;