]> zoso.dev Git - nano-pow.git/commitdiff
Reorder typings in generally descending order.
authorChris Duncan <chris@zoso.dev>
Fri, 28 Mar 2025 05:53:28 +0000 (22:53 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 28 Mar 2025 05:53:28 +0000 (22:53 -0700)
src/types.d.ts

index 1f7bcc80f94709f7d305402e15cf7292c8bbfcb3..4780ed3e0c4eacc7267b461c930b2e818ae0c144 100644 (file)
@@ -7,6 +7,101 @@ declare global {
        }
 }
 
+declare const NanoPow: typeof NanoPowGl | typeof NanoPowGpu | null
+
+/**
+* Nano proof-of-work using WebGL 2.0.
+*/
+export declare class NanoPowGl {
+       static [key: string]: (...args: any[]) => any
+       #private
+       /**
+       * Constructs canvas, gets WebGL context, initializes buffers, and compiles
+       * shaders.
+       */
+       static init (): Promise<void>
+       /**
+       * On WebGL context loss, attempts to clear all program variables and then
+       * reinitialize them by calling `init()`.
+       */
+       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 {NanoPowOptions} options - Options used to configure search execution
+       */
+       static work_generate (hash: string, options?: NanoPowOptions): Promise<WorkGenerateResponse>
+       /**
+       * 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 {NanoPowOptions} options - Options used to configure search execution
+       */
+       static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise<WorkValidateResponse>
+}
+
+/**
+* Nano proof-of-work using WebGPU.
+*/
+export declare class NanoPowGpu {
+       #private
+       static [key: string]: (...args: any[]) => any
+       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 {NanoPowOptions} options - Used to configure search execution
+       */
+       static work_generate (hash: string, options?: NanoPowOptions): Promise<WorkGenerateResponse>
+       /**
+       * 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 {NanoPowOptions} options - Options used to configure search execution
+       */
+       static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise<WorkValidateResponse>
+}
+
+/**
+* Used to configure NanoPow.
+*
+* @param {boolean} [debug=false] - Enables additional debug logging to the console. Default: false
+* @param {number} [effort=0x8] - Multiplier for dispatching work search. Larger values are not necessarily better since they can quickly overwhelm the GPU. Ignored when validating. Default: 0x8
+* @param {bigint|string} [difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000
+*/
+export type NanoPowOptions = {
+       debug?: boolean
+       effort?: number
+       difficulty?: bigint | string
+}
+
+/**
+* Used to create WebGL framebuffer objects.
+*
+* @param {WebGLTexture} - Defines storage size
+* @param {WebGLFramebuffer} - Holds texture data
+* @param {size} - 2D lengths of texture
+*/
+export type FBO = {
+       texture: WebGLTexture
+       framebuffer: WebGLFramebuffer
+       size: {
+               x: number
+               y: number
+       }
+}
+
+export declare const NanoPowGlDownsampleShader: string
+export declare const NanoPowGlDrawShader: string
+export declare const NanoPowGlVertexShader: string
+export declare const NanoPowGpuComputeShader: any
+
 /**
 * Used by work server for inbound requests to `work_generate`.
 *
@@ -70,98 +165,3 @@ type WorkValidateResponse = {
        valid_all: '0' | '1'
        valid_receive: '0' | '1'
 }
-
-export declare const NanoPowGlDownsampleShader: string
-export declare const NanoPowGlDrawShader: string
-export declare const NanoPowGlVertexShader: string
-export declare const NanoPowGpuComputeShader: any
-
-declare const NanoPow: typeof NanoPowGl | typeof NanoPowGpu | null
-
-/**
-* Used to create WebGL framebuffer objects.
-*
-* @param {WebGLTexture} - Defines storage size
-* @param {WebGLFramebuffer} - Holds texture data
-* @param {size} - 2D lengths of texture
-*/
-export type FBO = {
-       texture: WebGLTexture
-       framebuffer: WebGLFramebuffer
-       size: {
-               x: number
-               y: number
-       }
-}
-
-/**
-* Used to configure NanoPow.
-*
-* @param {boolean} [debug=false] - Enables additional debug logging to the console. Default: false
-* @param {number} [effort=0x8] - Multiplier for dispatching work search. Larger values are not necessarily better since they can quickly overwhelm the GPU. Ignored when validating. Default: 0x8
-* @param {bigint|string} [difficulty=0xfffffff800000000] - Minimum value result of `BLAKE2b(nonce||blockhash)`. Default: 0xFFFFFFF800000000
-*/
-export type NanoPowOptions = {
-       debug?: boolean
-       effort?: number
-       difficulty?: bigint | string
-}
-
-/**
-* Nano proof-of-work using WebGL 2.0.
-*/
-export declare class NanoPowGl {
-       static [key: string]: (...args: any[]) => any
-       #private
-       /**
-       * Constructs canvas, gets WebGL context, initializes buffers, and compiles
-       * shaders.
-       */
-       static init (): Promise<void>
-       /**
-       * On WebGL context loss, attempts to clear all program variables and then
-       * reinitialize them by calling `init()`.
-       */
-       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 {NanoPowOptions} options - Options used to configure search execution
-       */
-       static work_generate (hash: string, options?: NanoPowOptions): Promise<WorkGenerateResponse>
-       /**
-       * 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 {NanoPowOptions} options - Options used to configure search execution
-       */
-       static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise<WorkValidateResponse>
-}
-
-/**
-* Nano proof-of-work using WebGPU.
-*/
-export declare class NanoPowGpu {
-       #private
-       static [key: string]: (...args: any[]) => any
-       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 {NanoPowOptions} options - Used to configure search execution
-       */
-       static work_generate (hash: string, options?: NanoPowOptions): Promise<WorkGenerateResponse>
-       /**
-       * 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 {NanoPowOptions} options - Options used to configure search execution
-       */
-       static work_validate (work: string, hash: string, options?: NanoPowOptions): Promise<WorkValidateResponse>
-}