diff --git a/web/js/algorithms/fast.ts b/web/js/algorithms/fast.ts index 82a9a778..32f0eaa1 100644 --- a/web/js/algorithms/fast.ts +++ b/web/js/algorithms/fast.ts @@ -1,3 +1,5 @@ +import { ChallengeResult } from "./types"; + type ProgressCallback = (nonce: number) => void; interface ProcessOptions { @@ -17,7 +19,7 @@ export default function process( signal: AbortSignal | null = null, progressCallback?: ProgressCallback, threads: number = Math.trunc(Math.max(getHardwareConcurrency() / 2, 1)), -): Promise { +): Promise { console.debug("fast algo"); // Choose worker based on secure context. diff --git a/web/js/algorithms/index.ts b/web/js/algorithms/index.ts index 2781aef0..d67b4829 100644 --- a/web/js/algorithms/index.ts +++ b/web/js/algorithms/index.ts @@ -1,5 +1,7 @@ import fast from "./fast"; +export type { ChallengeResult } from "./types"; + export default { fast: fast, slow: fast, // XXX(Xe): slow is deprecated, but keep this around in case anything goes bad diff --git a/web/js/algorithms/types.ts b/web/js/algorithms/types.ts new file mode 100644 index 00000000..03cc7157 --- /dev/null +++ b/web/js/algorithms/types.ts @@ -0,0 +1,6 @@ +export interface ChallengeResult { + hash: string; + data: string; + difficulty: number; + nonce: number; +} \ No newline at end of file diff --git a/web/js/main.tsx b/web/js/main.tsx index 32e39ad3..40ae427e 100644 --- a/web/js/main.tsx +++ b/web/js/main.tsx @@ -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 = {}) => { @@ -211,7 +211,7 @@ function App({ anubisVersion, basePrefix }: AppProps) { } }, ) - .then((result: any) => { + .then((result: ChallengeResult) => { const t1 = Date.now(); const { hash, nonce } = result;