await build({
entryPoints: [
- { out: 'main.min', in: 'dist/main.js' },
- { out: 'global.min', in: 'dist/global.js' }
+ { out: 'main.min', in: './src/main.js' },
+ { out: 'global.min', in: './src/global.js' }
],
outdir: 'dist',
target: 'esnext',
"url": "git+https://zoso.dev/nano-pow.git"
},
"scripts": {
- "build": "rm -rf dist && tsc && node esbuild.mjs"
+ "build": "rm -rf types && tsc && node esbuild.mjs && cp types.d.ts dist"
},
"devDependencies": {
"@types/node": "^22.10.5",
"typescript": "^5.7.3"
},
"type": "module",
- "exports": "./dist/main.js",
- "types": "dist/main.d.ts",
+ "exports": [
+ "./dist/main.min.js",
+ "./types.d.ts"
+ ],
+ "types": "types.d.ts",
"unpkg": "dist/main.min.js"
}
--- /dev/null
+import "@webgpu/types"
+
+declare const NanoPow: typeof NanoPowGl | typeof NanoPowGpu | null
+
+export declare class NanoPowGl {
+ #private
+ /** Compile */
+ static init (): Promise<void>
+ /**
+ * Finds a nonce that satisfies the Nano proof-of-work requirements.
+ *
+ * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts
+ * @param {number} [threshold=0xfffffff8] - Difficulty of proof-of-work calculation
+ */
+ static search (hash: string, threshold?: number): Promise<string>
+ /**
+ * Validates that a nonce satisfies Nano proof-of-work requirements.
+ *
+ * @param {string} work - Hexadecimal proof-of-work value to validate
+ * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts
+ * @param {number} [threshold=0xfffffff8] - Difficulty of proof-of-work calculation
+ */
+ static validate (work: string, hash: string, threshold?: number): Promise<boolean>
+}
+
+/**
+* Nano proof-of-work using WebGPU.
+*/
+export declare class NanoPowGpu {
+ #private
+ static init (): Promise<void>
+ static setup (): void
+ static reset (): void
+ /**
+ * Finds a nonce that satisfies the Nano proof-of-work requirements.
+ *
+ * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts
+ * @param {number} [threshold=0xfffffff8] - Difficulty of proof-of-work calculation
+ */
+ static search (hash: string, threshold?: number): Promise<string>
+ /**
+ * Validates that a nonce satisfies Nano proof-of-work requirements.
+ *
+ * @param {string} work - Hexadecimal proof-of-work value to validate
+ * @param {string} hash - Hexadecimal hash of previous block, or public key for new accounts
+ * @param {number} [threshold=0xfffffff8] - Difficulty of proof-of-work calculation
+ */
+ static validate (work: string, hash: string, threshold?: number): Promise<boolean>
+}
+
+export declare const NanoPowGlFragmentShader: string
+export declare const NanoPowGlVertexShader: string
+export declare const NanoPowGpuComputeShader: any