//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
+import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from 'nano-pow'
import { isHex32, isHex8, Logger, stats } from 'nano-pow/utils'
import { Serializable, spawn } from 'node:child_process'
import { getRandomValues } from 'node:crypto'
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
+import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from 'nano-pow'
import { isHex32, isHex8, Logger } from 'nano-pow/utils'
import { Serializable } from 'node:child_process'
import { hash } from 'node:crypto'
+++ /dev/null
-//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
-//! SPDX-License-Identifier: GPL-3.0-or-later
-
-/**
-* Provide consumer with error information in response to request.
-*
-* @param {string} error - Informative message about error.
-*/
-export type WorkErrorResponse = {
- error: string
-}
-
-/**
-* Structure of response to `work_generate` call.
-*
-* @param {string} hash - Hash from generate request
-* @param {string} work - Valid proof-of-work nonce generated for input hash
-* @param {string} difficulty - BLAKE2b output which met or exceeded specified minimum threshold
-*/
-export type WorkGenerateResponse = {
- hash: string
- work: string
- difficulty: string
-}
-
-/**
-* Structure of response to `work_validate` call.
-*
-* @param {string} hash - Hash from validate request
-* @param {string} work - Nonce from validate request
-* @param {string} difficulty - BLAKE2b output of `work` + `hash` which is compared to specified minimum threshold to determine validity
-* @param {string} valid_all - 1 for true if nonce is valid for send blocks, else 0 for false
-* @param {string} valid_receive - 1 for true if nonce is valid for receive blocks, else 0 for false
-* @param {string} [valid] - Excluded if optional difficulty was not included in the request. 1 for true if nonce is valid for requested difficulty, else 0 for false
-*/
-export type WorkValidateResponse = {
- hash: string
- work: string
- difficulty: string
- valid_all: '0' | '1'
- valid_receive: '0' | '1'
- valid?: '0' | '1'
-}
//! SPDX-License-Identifier: GPL-3.0-or-later
import { NanoPowOptions } from '#lib/config'
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
import { generate, validate } from './lib'
+declare global {
+ interface Window {
+ NanoPow: typeof NanoPow
+ }
+}
+
+/**
+ * Provide consumer with error information in response to request.
+ *
+ * @param {string} error - Informative message about error.
+ */
+export type WorkErrorResponse = {
+ error: string
+}
+
+/**
+ * Structure of response to `work_generate` call.
+ *
+ * @param {string} hash - Hash from generate request
+ * @param {string} work - Valid proof-of-work nonce generated for input hash
+ * @param {string} difficulty - BLAKE2b output which met or exceeded specified minimum threshold
+ */
+export type WorkGenerateResponse = {
+ hash: string
+ work: string
+ difficulty: string
+}
+
+/**
+ * Structure of response to `work_validate` call.
+ *
+ * @param {string} hash - Hash from validate request
+ * @param {string} work - Nonce from validate request
+ * @param {string} difficulty - BLAKE2b output of `work` + `hash` which is compared to specified minimum threshold to determine validity
+ * @param {string} valid_all - 1 for true if nonce is valid for send blocks, else 0 for false
+ * @param {string} valid_receive - 1 for true if nonce is valid for receive blocks, else 0 for false
+ * @param {string} [valid] - Excluded if optional difficulty was not included in the request. 1 for true if nonce is valid for requested difficulty, else 0 for false
+ */
+export type WorkValidateResponse = {
+ hash: string
+ work: string
+ difficulty: string
+ valid_all: '0' | '1'
+ valid_receive: '0' | '1'
+ valid?: '0' | '1'
+}
+
/**
* Finds a nonce that satisfies the Nano proof-of-work requirements.
*
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
+import { WorkGenerateResponse } from 'nano-pow'
import { NanoPowValidate } from '#lib/validate'
-import { WorkGenerateResponse } from '#types'
import { bigintRandom, Logger } from '#utils'
const logger = new Logger()
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
+import { WorkGenerateResponse } from 'nano-pow'
import { NanoPowValidate } from '#lib/validate'
-import { WorkGenerateResponse } from '#types'
import { bigintRandom, bigintToHex, Logger } from '#utils'
import { NanoPowWasmWorker } from './worker.js'
//! SPDX-FileContributor: Ben Green <ben@latenightsketches.com>
//! SPDX-License-Identifier: GPL-3.0-or-later AND MIT
-import { downsampleSource, drawSource, quadSource } from './shaders'
-import { WorkGenerateResponse } from '#types'
+import { WorkGenerateResponse } from 'nano-pow'
import { bigintAsUintNArray, bigintRandom, bigintToHex, Logger } from '#utils'
+import { downsampleSource, drawSource, quadSource } from './shaders'
/**
* Used to create WebGL framebuffer objects.
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import { default as NanoPowGpuComputeShader } from './shaders/compute.wgsl'
-import { WorkGenerateResponse } from '#types'
+import { WorkGenerateResponse } from 'nano-pow'
import { bigintAsUintNArray, bigintRandom, bigintToHex, Logger, Queue } from '#utils'
+import { default as NanoPowGpuComputeShader } from './shaders/compute.wgsl'
type NanoPowDeviceStatus = 'Idle' | 'Starting' | 'Unsupported' | 'Ready' | 'Restoring' | 'Crashed'
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
+import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from 'nano-pow'
import { NanoPowConfig } from '#lib/config'
import { NanoPowCpu, NanoPowWasm, NanoPowWebgl, NanoPowWebgpu } from '#lib/generate'
import { NanoPowValidate } from '#lib/validate'
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
import { bigintFrom, Cache, Logger, Queue } from '#utils'
const logger = new Logger()
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import { WorkValidateResponse } from '#types'
+import { WorkValidateResponse } from 'nano-pow'
import { bigintAsUintNArray, bigintToHex, Logger, RECEIVE, SEND } from '#utils'
const logger = new Logger()
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import { WorkGenerateResponse } from "#types"
+import { WorkGenerateResponse } from "nano-pow"
import { bigintFrom } from "#utils"
export class Cache {
"#lib/*": [
"./src/lib/*"
],
- "#types": [
- "./src/index.d.ts"
- ],
"#utils": [
"./src/utils/index.ts"
]