@openrai/nano-core 2.1.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
  <h1>@openrai/nano-core</h1>
3
- <p><b>The unopinionated, statically-typed, isomorphic protocol engine for the Nano (XNO) ecosystem.</b></p>
3
+ <p><b>Typed Nano primitives plus practical client utilities for RPC, WebSocket, and work generation.</b></p>
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@openrai/nano-core.svg?style=flat-square)](https://www.npmjs.com/package/@openrai/nano-core)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
@@ -9,20 +9,7 @@
9
9
 
10
10
  ---
11
11
 
12
- Historically, Nano developers have faced a fragmented integration landscape: ranging from "heavy, enterprise:y" backends to lightweight "frontend-only" implementation, suffering either from rigid vendor lock-in or fragile PoW architecture.
13
-
14
- **`@openrai/nano-core`** aims to be the canonical TypeScript Nano package: typed primitives, sane defaults, transport failover, endpoint normalization, auth handling, and a stable first-party API surface even when the internals wrap other best-of-breed libraries.
15
-
16
- ---
17
-
18
- ## 🚀 Key Features
19
-
20
- * **Bypassing the "Frontier Dilemma":** Nano is a state-based block-lattice where each block depends strictly on the exact final state of the previous frontier. This strong design choise is one of the main reasons why Nano can be feeless and energy efficient, but it often becomes a stumbling block for integrations. `@openrai/nano-core` provides internal concurrent Mutex queuing to perfectly sequentialize blocks even under heavy asynchronous loads, eliminating "Fork" or "Gap" errors.
21
- * **Isomorphic Proof-of-Work (JIT Profiling):** Wraps `nano-pow-with-fallback` in a Just-In-Time (JIT) environment profiler via `WorkProvider.auto()`. What it means is that whether running on an Apple Silicon Node.js server (jumping straight to local WebGPU) or on an aging mobile browser (delegating safely to remote servers by default), which generation method to use can be decided dynamically, without UI blocking or interfering with the current user flow.
22
- * **No Primitive-Obsession:** Heavily-typed, precision-safe wrappers for `NanoAmount` and `NanoAddress` entirely eliminate the "Stringly-Typed Money" programming anti-pattern.
23
- * **Resilient RPC / WS / Work Fallbacks:** Endpoint pools validate eagerly, deduplicate, apply endpoint-local exponential backoff, and only fail once all viable options are exhausted.
24
- * **Secret-Safe Endpoint Normalization:** API keys from query params or URL userinfo are converted into structured auth metadata and redacted from canonical URLs and audit output.
25
- * **Cross-Language FFI Preparation**: The TypeScript architecture strictly follows Domain-Driven Design (DDD) to promote close API compatibility across different eventual programming language ports of the library.
12
+ `@openrai/nano-core` provides typed Nano primitives and a small transport layer for applications that need reliable RPC, WebSocket, and work generation behavior without rebuilding endpoint parsing, auth handling, failover, or audit visibility. It is designed for direct use in services, scripts, and browser-capable clients, with explicit defaults and observable transport state.
26
13
 
27
14
  ## 📦 Installation
28
15
 
@@ -34,30 +21,36 @@ npm install @openrai/nano-core
34
21
  ## 🛠 Quick Start
35
22
 
36
23
  ### 1. Minimal Client
37
- The default surface should feel obvious on first read:
24
+ `nano-core` handles endpoint selection, auth redaction, and precision-safe math so you can focus on the task at hand:
38
25
 
39
26
  ```typescript
40
- import { NanoClient } from '@openrai/nano-core';
27
+ import { NanoClient, NanoAddress, NanoAmount } from '@openrai/nano-core';
41
28
 
42
- const client = NanoClient.initialize({
43
- rpc: [
44
- 'https://rpc.primary.example.com?apiKey=secret-rpc',
45
- 'https://rpc.nano.to',
46
- ], // [Optional] Defaults to the April 2026 public RPC set
47
- ws: [
48
- 'wss://ws.primary.example.com?api_key=secret-ws',
49
- 'wss://rpc.nano.to',
50
- ], // [Optional] Defaults to public WebSocket endpoints
51
- work: [
52
- 'https://work.primary.example.com?key=secret-work',
53
- 'https://rpc.nano.to',
54
- ], // [Optional] Defaults to `https://rpc.nano.to` as the current public work endpoint
55
- warn: (message) => console.warn(message), // [Optional] Defaults to console.warn with nano-core prefix
56
- });
29
+ // Start with built-in public endpoints — no config required
30
+ const client = NanoClient.initialize();
31
+
32
+ // Validate a destination address (checksum-verified, throws on bad input)
33
+ const destination = NanoAddress.parse(
34
+ 'nano_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4',
35
+ );
36
+
37
+ // Express value in human-readable NANO — stored as precision-safe raw internally
38
+ const amount = NanoAmount.fromNano('1.25');
57
39
 
58
- console.log(client.getAuditReport());
40
+ // Hydrate a wallet from a seed (keep your seed in an env var, never hard-code it)
41
+ const wallet = await client.hydrateWallet(process.env.NANO_SEED!, { index: 0 });
42
+ const hash = await wallet.send(destination, amount);
43
+
44
+ console.log(`Sent ${amount} NANO → ${destination}`);
45
+ console.log(`Block hash: ${hash}`);
59
46
  ```
60
47
 
48
+ Under the hood, `nano-core` has already:
49
+ - Selected a live RPC from the built-in April 2026 public pool
50
+ - Validated the address checksum and derived the public key
51
+ - Stored `1.25 NANO` as `1250000000000000000000000000000` raw — no float drift
52
+ - Redacted any API keys from audit output
53
+
61
54
  ### 1.1 Observe Endpoint Selection
62
55
 
63
56
  Long-running services can observe which upstream endpoint became active without
@@ -156,12 +149,14 @@ const client = NanoClient.initialize({
156
149
  ```
157
150
 
158
151
  ### 4. Isomorphic Work Calibration
159
- It's critical not to freeze the browser threads. On boot, evaluate the environment. `nano-core` remembers the hardware constraints across sessions.
152
+ `nano-core` can probe remote and local work capabilities asynchronously, then build an execution plan without doing any heavyweight work in constructors. When `profiler.mode` is `auto`, call `probe()` or `calibrate()` explicitly during startup and reuse the resulting plan for later work generation.
160
153
 
161
154
  ```typescript
162
- // Auto-detects whether local WebGPU/WASM is faster than network latency to remotes
155
+ const plan = await client.workProvider.probe();
156
+ console.log(plan.steps);
157
+
163
158
  const profile = await client.workProvider.calibrate();
164
- console.log(`Determined active PoW strategy: ${profile.activeStrategy} at ${profile.measuredMhs} MH/s.`);
159
+ console.log(profile.activeStrategy);
165
160
  ```
166
161
 
167
162
  ### 5. Precision-Safe Execution
@@ -206,29 +201,26 @@ For collaboration, please refer to the `github.com/OpenRai/nano-core` issues boa
206
201
 
207
202
  ---
208
203
 
209
- ## Addendum II: Browser Hostility & The Isomorphic Sandbox
204
+ See `docs/architecture/transport-auth.md` for the transport/auth design. More advanced local-vs-remote work profiling is planned but not implemented in the current release.
210
205
 
211
- ### 1. The Browser Execution Reality
206
+ ## Release Flow
212
207
 
213
- While Node.js provides unthrottled access to host silicon (delivering ~104 MH/s on Apple M1 architectures), browsers operate under strict security and power-management sandboxes. Empirical testing across modern Chromium (Brave) and WebKit (Safari) engines reveals that relying on static hardware fallbacks in a web environment is a critical architectural risk.
208
+ `@openrai/nano-core` is a single-package repo, so versioning is manual and publishing is automated.
214
209
 
215
- Browser engines dynamically throttle compute APIs based on task duration and thread count, leading to three distinct phenomena that the SDK must navigate:
210
+ Typical release steps:
216
211
 
217
- #### A. The WebGPU "Throttle Cliff" (Sprint vs. Marathon)
218
- WebGPU is highly unpredictable in the browser.
219
- * **The Burst:** On low-difficulty thresholds (e.g., `Open/Receive`), browsers allow WebGPU to run at maximum voltage, completing the task in milliseconds (bursting up to ~2,000 MH/s in Safari).
220
- * **The Throttle:** [Inference] On high-difficulty thresholds (e.g., `Send/Change`), the task takes longer. Once the compute shader runs past a specific time budget (often 1-2 seconds), browser watchdogs classify it as a runaway script or a crypto-miner. The engine violently throttles the GPU context to protect the UI thread, causing HashRates to collapse by up to 98% (e.g., dropping from 336 MH/s to 7.5 MH/s in Chromium).
212
+ 1. Bump the package version:
221
213
 
222
- #### B. The WASM "Death Spiral" (Thread Starvation)
223
- Counter-intuitively, spawning multiple Web Workers for WASM computation degrades performance in aggressive sandboxes like Safari.
224
- * [Inference] When the SDK requests 8 parallel WASM threads for a sustained `Send/Change` calculation, the browser's resource scheduler intervenes to prevent thermal throttling and battery drain. It starves the workers of CPU cycles, resulting in multi-threaded executions taking significantly *longer* than single-threaded executions (e.g., spanning upwards of 4.5 minutes for a single block).
214
+ ```bash
215
+ pnpm version patch
216
+ ```
225
217
 
226
- #### C. WebGL: The Predictable Baseline
227
- Across all tested engines, WebGL is the most consistently paced API. Because it taps into the legacy rendering pipeline, browsers are less likely to violently throttle it mid-task. It maintains a slow but predictable ~15 MH/s regardless of the threshold difficulty.
218
+ or, without git side effects:
228
219
 
229
- ### 2. Conclusion: The Necessity of JIT Profiling
220
+ ```bash
221
+ pnpm version patch --no-git-tag-version
222
+ ```
230
223
 
231
- These findings conclusively validate the `WorkProvider.auto()` architecture. The SDK cannot assume local hardware is safe just because `navigator.gpu` exists.
224
+ 2. Push the version commit and tag to `main`.
232
225
 
233
- The JIT Environment Profiler must execute a sub-50ms micro-probe on load. If the probe detects a sandboxed environment where a `Send` block will trigger the "Throttle Cliff" (taking >5 seconds), the SDK must intelligently route the work to a remote BPoW server, ensuring the application remains responsive and the user's battery is preserved.
234
- See `docs/architecture/transport-auth.md` for the full transport/auth design.
226
+ GitHub Actions then builds, tests, and publishes from `.github/workflows/release.yml` using npm Trusted Publisher.
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HttpEndpointPool } from './transport/http.js';
2
2
  import { WsEndpointPool } from './transport/ws.js';
3
3
  import { WorkProvider } from './work/WorkProvider.js';
4
- import type { EndpointActivityEvent } from './transport/types.js';
4
+ import type { EndpointActivityEvent, EndpointAuditRecord } from './transport/types.js';
5
5
  export interface TransportFallback {
6
6
  urls: string[];
7
7
  }
@@ -22,6 +22,12 @@ export interface NanoClientActiveEndpoints {
22
22
  ws?: string;
23
23
  work?: string;
24
24
  }
25
+ export interface NanoClientAuditReport {
26
+ network: 'mainnet' | 'testnet' | 'beta';
27
+ rpc: EndpointAuditRecord[];
28
+ ws: EndpointAuditRecord[];
29
+ workProvider: ReturnType<WorkProvider['getAuditReport']>;
30
+ }
25
31
  export declare class NanoClient {
26
32
  workProvider: WorkProvider;
27
33
  rpcPool: HttpEndpointPool;
@@ -37,7 +43,7 @@ export declare class NanoClient {
37
43
  * Generates a minimal JSON-serializable report of the active configuration.
38
44
  * Useful for deploy-time auditing and startup logs to detect misconfigurations.
39
45
  */
40
- getAuditReport(): Record<string, any>;
46
+ getAuditReport(): NanoClientAuditReport;
41
47
  hydrateWallet(seed: string, options?: {
42
48
  index?: number;
43
49
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAsB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,YAAY,EAA4B,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAgB,MAAM,sBAAsB,CAAC;AAEhF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB;eACjB,MAAM,EAAE,KAAG,iBAAiB;CACxC,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IACzC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,UAAU;IACd,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,EAAE,cAAc,CAAC;IAC9B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA8C;IAChF,OAAO,CAAC,QA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B;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IACxC,GAAG,EAAE,mBAAmB,EAAE,CAAC;IAC3B,EAAE,EAAE,mBAAmB,EAAE,CAAC;IAC1B,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;CAC1D;AAED,qBAAa,UAAU;IACd,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,EAAE,cAAc,CAAC;IAC9B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA8C;IAChF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwC;IAExE,OAAO;WAsDO,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU;IAI9D,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAAG,MAAM,IAAI;IAK9E,kBAAkB,IAAI,yBAAyB;IAQtD;;;OAGG;IACI,cAAc,IAAI,qBAAqB;IASjC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO;wBAG/C,GAAG,UAAU,GAAG;;CAK3C"}
package/dist/client.js CHANGED
@@ -89,7 +89,7 @@ export class NanoClient {
89
89
  network: this.options.network ?? 'mainnet',
90
90
  rpc: this.rpcPool.getAuditReport(),
91
91
  ws: this.wsPool.getAuditReport(),
92
- workProvider: this.workProvider.getAuditReport()
92
+ workProvider: this.workProvider.getAuditReport(),
93
93
  };
94
94
  }
95
95
  async hydrateWallet(seed, options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":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1E,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,cAAc;QACnB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS;YAC1C,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YAClC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;YAChC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE;SACjD,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,UAA8B,EAAE;QACvE,wCAAwC;QACxC,OAAO;YACL,IAAI,EAAE,KAAK,EAAE,OAAY,EAAE,MAAW,EAAE,EAAE;gBACxC,OAAO,YAAY,CAAC;YACtB,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { NanoAddress } from './primitives/NanoAddress.js';
2
2
  export { NanoAmount } from './primitives/NanoAmount.js';
3
+ export { NOMS } from './signing/noms.js';
3
4
  export { WorkProvider, RemoteWorkServer, LocalCompute, type WorkProviderOptions } from './work/WorkProvider.js';
4
- export { NanoClient, TransportFallback, type NanoClientOptions, type NanoClientActiveEndpoints } from './client.js';
5
+ export { NanoClient, TransportFallback, type NanoClientOptions, type NanoClientActiveEndpoints, type NanoClientAuditReport } from './client.js';
5
6
  export { EndpointPool, HttpEndpointPool, NanoTransportConfigError, WsEndpointPool, normalizeEndpoints, } from './transport/index.js';
6
7
  export type { AuthSource, EndpointActivityEvent, EndpointAuditRecord, EndpointAuth, EndpointKind, EndpointPoolOptions, EndpointState, NormalizedEndpoint, TransportPolicy, } from './transport/index.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAA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export { NanoAddress } from './primitives/NanoAddress.js';
2
2
  export { NanoAmount } from './primitives/NanoAmount.js';
3
+ export { NOMS } from './signing/noms.js';
3
4
  export { WorkProvider, RemoteWorkServer, LocalCompute } from './work/WorkProvider.js';
4
5
  export { NanoClient, TransportFallback } from './client.js';
5
6
  export { EndpointPool, HttpEndpointPool, NanoTransportConfigError, WsEndpointPool, normalizeEndpoints, } from './transport/index.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAA4B,MAAM,wBAAwB,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAA0D,MAAM,aAAa,CAAC;AACpH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,kBAAkB,GACnB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAA4B,MAAM,wBAAwB,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAsF,MAAM,aAAa,CAAC;AAChJ,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,kBAAkB,GACnB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Nano Off-chain Message Signing (NOMS) implementation (ORIS-001).
3
+ */
4
+ export declare const NOMS: {
5
+ /**
6
+ * Constructs the binary payload for an off-chain message as per ORIS-001.
7
+ * Format: MAGIC_HEADER (25 bytes) || MESSAGE_LENGTH (4 bytes uint32be) || MESSAGE (UTF-8)
8
+ */
9
+ createPayload(message: string): Uint8Array;
10
+ /**
11
+ * Computes the 32-byte Blake2b hash of the NOMS payload.
12
+ */
13
+ hashMessage(message: string): string;
14
+ /**
15
+ * Signs an off-chain message using standard Nano Ed25519 behavior.
16
+ * @param message The UTF-8 string message to sign.
17
+ * @param secretKey The 32-byte private key in hexadecimal format.
18
+ * @returns The 64-byte signature in hexadecimal format (128 characters).
19
+ */
20
+ signMessage(message: string, secretKey: string): string;
21
+ /**
22
+ * Verifies an off-chain message signature against a public key.
23
+ * @param message The UTF-8 string message that was signed.
24
+ * @param signature The 64-byte signature in hexadecimal format.
25
+ * @param publicKey The 32-byte public key in hexadecimal format.
26
+ * @returns True if the signature is valid for the given message and public key.
27
+ */
28
+ verifyMessage(message: string, signature: string, publicKey: string): boolean;
29
+ };
30
+ //# sourceMappingURL=noms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noms.d.ts","sourceRoot":"","sources":["../../src/signing/noms.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,IAAI;IACf;;;OAGG;2BACoB,MAAM,GAAG,UAAU;IAa1C;;OAEG;yBACkB,MAAM,GAAG,MAAM;IAKpC;;;;;OAKG;yBACkB,MAAM,aAAa,MAAM,GAAG,MAAM;IAKvD;;;;;;OAMG;2BACoB,MAAM,aAAa,MAAM,aAAa,MAAM,GAAG,OAAO;CAI9E,CAAC"}
@@ -0,0 +1,53 @@
1
+ import blake from 'blakejs';
2
+ import * as nanocurrency from 'nanocurrency';
3
+ const { blake2bHex } = blake;
4
+ const MAGIC_HEADER_TEXT = '\x18Nano Off-chain Message:\n';
5
+ const MAGIC_HEADER_BYTES = new TextEncoder().encode(MAGIC_HEADER_TEXT);
6
+ /**
7
+ * Nano Off-chain Message Signing (NOMS) implementation (ORIS-001).
8
+ */
9
+ export const NOMS = {
10
+ /**
11
+ * Constructs the binary payload for an off-chain message as per ORIS-001.
12
+ * Format: MAGIC_HEADER (25 bytes) || MESSAGE_LENGTH (4 bytes uint32be) || MESSAGE (UTF-8)
13
+ */
14
+ createPayload(message) {
15
+ const messageBytes = new TextEncoder().encode(message);
16
+ const lengthBytes = new Uint8Array(4);
17
+ new DataView(lengthBytes.buffer).setUint32(0, messageBytes.length, false);
18
+ const payload = new Uint8Array(MAGIC_HEADER_BYTES.length + lengthBytes.length + messageBytes.length);
19
+ payload.set(MAGIC_HEADER_BYTES, 0);
20
+ payload.set(lengthBytes, MAGIC_HEADER_BYTES.length);
21
+ payload.set(messageBytes, MAGIC_HEADER_BYTES.length + lengthBytes.length);
22
+ return payload;
23
+ },
24
+ /**
25
+ * Computes the 32-byte Blake2b hash of the NOMS payload.
26
+ */
27
+ hashMessage(message) {
28
+ const payload = this.createPayload(message);
29
+ return blake2bHex(payload, undefined, 32);
30
+ },
31
+ /**
32
+ * Signs an off-chain message using standard Nano Ed25519 behavior.
33
+ * @param message The UTF-8 string message to sign.
34
+ * @param secretKey The 32-byte private key in hexadecimal format.
35
+ * @returns The 64-byte signature in hexadecimal format (128 characters).
36
+ */
37
+ signMessage(message, secretKey) {
38
+ const hash = this.hashMessage(message);
39
+ return nanocurrency.signBlock({ hash, secretKey }).toLowerCase();
40
+ },
41
+ /**
42
+ * Verifies an off-chain message signature against a public key.
43
+ * @param message The UTF-8 string message that was signed.
44
+ * @param signature The 64-byte signature in hexadecimal format.
45
+ * @param publicKey The 32-byte public key in hexadecimal format.
46
+ * @returns True if the signature is valid for the given message and public key.
47
+ */
48
+ verifyMessage(message, signature, publicKey) {
49
+ const hash = this.hashMessage(message);
50
+ return nanocurrency.verifyBlock({ hash, signature, publicKey });
51
+ },
52
+ };
53
+ //# sourceMappingURL=noms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noms.js","s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;;;OAKG;IACH,WAAW,CAAC,OAAe,EAAE,SAAiB;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,OAAe,EAAE,SAAiB,EAAE,SAAiB;QACjE,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,YAAY,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;IAClE,CAAC;CACF,CAAC"}
@@ -1,16 +1,38 @@
1
- import type { EndpointActivityEvent } from '../transport/types.js';
2
- /**
3
- * Local compute engines available.
4
- */
1
+ import type { EndpointActivityEvent, EndpointAuditRecord } from '../transport/types.js';
2
+ import { PowBackendName } from 'nano-pow-with-fallback';
5
3
  export declare enum LocalCompute {
6
4
  WEBGPU = "webgpu",
7
5
  WEBGL = "webgl",
8
- WASM_THREADS = "wasm",
9
- CPU = "cpu"
6
+ WASM = "wasm"
7
+ }
8
+ type PowBackendNameValue = typeof PowBackendName[keyof typeof PowBackendName];
9
+ type WorkPlanStepKind = 'remote' | 'webgpu' | 'webgl' | 'wasm';
10
+ export interface WorkCalibrationProfile {
11
+ measuredMhs: number;
12
+ activeStrategy: 'remote-first' | 'planned';
13
+ }
14
+ export interface WorkGenerationTrace {
15
+ mode: 'remote' | 'local';
16
+ backend?: PowBackendNameValue;
17
+ }
18
+ export interface WorkProbeResult {
19
+ kind: WorkPlanStepKind;
20
+ available: boolean;
21
+ durationMs?: number;
22
+ reason?: string;
23
+ }
24
+ export interface WorkPlanStep {
25
+ kind: WorkPlanStepKind;
26
+ }
27
+ export interface WorkExecutionPlan {
28
+ source: 'default' | 'probe';
29
+ steps: WorkPlanStep[];
30
+ disabledLocalBackends: PowBackendNameValue[];
31
+ probeResults: WorkProbeResult[];
10
32
  }
11
33
  export declare class RemoteWorkServer {
12
- private _url;
13
- private _timeoutMs;
34
+ private readonly _url;
35
+ private readonly _timeoutMs;
14
36
  constructor(url: string, timeoutMs: number);
15
37
  get url(): string;
16
38
  get timeoutMs(): number;
@@ -25,6 +47,7 @@ export interface WorkProviderOptions {
25
47
  defaults?: string[];
26
48
  warn?: (message: string) => void;
27
49
  onActiveEndpointChange?: (event: EndpointActivityEvent) => void;
50
+ timeoutMs?: number;
28
51
  remotes?: RemoteWorkServer[];
29
52
  localChain?: LocalCompute[];
30
53
  profiler?: {
@@ -34,25 +57,41 @@ export interface WorkProviderOptions {
34
57
  };
35
58
  }
36
59
  export declare class WorkProvider {
37
- private options;
38
- private remotePool;
60
+ private readonly options;
61
+ private readonly remotePool;
62
+ private readonly warn;
63
+ private readonly localTimeoutMs;
64
+ private lastGenerationTrace;
65
+ private lastProbeResults;
66
+ private executionPlan;
67
+ private probePromise;
39
68
  private constructor();
40
69
  static auto(options: WorkProviderOptions): WorkProvider;
41
- /**
42
- * Generates a minimal JSON-serializable report of the work provider's active configuration.
43
- */
44
- getAuditReport(): Record<string, any>;
45
- /**
46
- * Calibrates the work provider based on the environment.
47
- * Runs a dummy hash to determine optimal strategy.
48
- */
49
- calibrate(): Promise<{
50
- measuredMhs: number;
51
- activeStrategy: string;
52
- }>;
53
- /**
54
- * Generate Proof-of-Work for a given hash.
55
- */
70
+ getRemoteAuditReport(): EndpointAuditRecord[];
71
+ getAuditReport(): {
72
+ remotePool: EndpointAuditRecord[];
73
+ remotes: Array<{
74
+ url: string;
75
+ timeoutMs: number;
76
+ }>;
77
+ localChain: LocalCompute[];
78
+ profiler: WorkProviderOptions['profiler'] | 'default';
79
+ localBackend: PowBackendNameValue | null;
80
+ lastGenerationTrace: WorkGenerationTrace | null;
81
+ executionPlan: WorkExecutionPlan;
82
+ };
83
+ calibrate(): Promise<WorkCalibrationProfile>;
84
+ probe(): Promise<WorkExecutionPlan>;
85
+ private buildDefaultPlan;
86
+ private createLocalPowService;
87
+ private probeRemote;
88
+ private probeLocalBackend;
89
+ private buildPlanFromProbeResults;
90
+ private runProbe;
91
+ private generateRemote;
92
+ private generateLocalWithBackend;
93
+ private executePlan;
56
94
  generate(hash: string, difficulty: string): Promise<string>;
57
95
  }
96
+ export {};
58
97
  //# sourceMappingURL=WorkProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WorkProvider.d.ts","sourceRoot":"","sources":["../../src/work/WorkProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGnE;;GAEG;AACH,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,YAAY,SAAS;IACrB,GAAG,QAAQ;CACZ;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAS;gBAEf,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAK1C,IAAW,GAAG,IAAI,MAAM,CAAsB;IAC9C,IAAW,SAAS,IAAI,MAAM,CAA4B;IAE1D,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAO;CAGvF;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChE,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,UAAU,CAAC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CnB,QAAQ;YAaR,cAAc;YAmBd,wBAAwB;YAYxB,WAAW;IAkBZ,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAKzE"}
@@ -1,13 +1,10 @@
1
1
  import { HttpEndpointPool } from '../transport/http.js';
2
- /**
3
- * Local compute engines available.
4
- */
2
+ import { PowBackendName, PowService } from 'nano-pow-with-fallback';
5
3
  export var LocalCompute;
6
4
  (function (LocalCompute) {
7
5
  LocalCompute["WEBGPU"] = "webgpu";
8
6
  LocalCompute["WEBGL"] = "webgl";
9
- LocalCompute["WASM_THREADS"] = "wasm";
10
- LocalCompute["CPU"] = "cpu";
7
+ LocalCompute["WASM"] = "wasm";
11
8
  })(LocalCompute || (LocalCompute = {}));
12
9
  export class RemoteWorkServer {
13
10
  _url;
@@ -22,73 +19,285 @@ export class RemoteWorkServer {
22
19
  return new RemoteWorkServer(url, options.timeoutMs ?? 5000);
23
20
  }
24
21
  }
22
+ const DEFAULT_LOCAL_CHAIN = [LocalCompute.WEBGPU, LocalCompute.WEBGL, LocalCompute.WASM];
23
+ const DEFAULT_LOCAL_TIMEOUT_MS = 10_000;
24
+ const PROBE_HASH = 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789';
25
+ const PROBE_DIFFICULTY = 'fffffe0000000000';
26
+ function localComputeToBackendName(compute) {
27
+ switch (compute) {
28
+ case LocalCompute.WEBGPU:
29
+ return PowBackendName.WEBGPU;
30
+ case LocalCompute.WEBGL:
31
+ return PowBackendName.WEBGL;
32
+ case LocalCompute.WASM:
33
+ return PowBackendName.WASM;
34
+ }
35
+ }
36
+ function localComputeToPlanStep(compute) {
37
+ switch (compute) {
38
+ case LocalCompute.WEBGPU:
39
+ return 'webgpu';
40
+ case LocalCompute.WEBGL:
41
+ return 'webgl';
42
+ case LocalCompute.WASM:
43
+ return 'wasm';
44
+ }
45
+ }
46
+ function planStepToBackendName(kind) {
47
+ switch (kind) {
48
+ case 'webgpu':
49
+ return PowBackendName.WEBGPU;
50
+ case 'webgl':
51
+ return PowBackendName.WEBGL;
52
+ case 'wasm':
53
+ return PowBackendName.WASM;
54
+ case 'remote':
55
+ throw new Error('remote plan step does not map to a local backend');
56
+ }
57
+ }
58
+ function isLocalStepKind(kind) {
59
+ return kind !== 'remote';
60
+ }
61
+ function withTimeout(promise, timeoutMs, onTimeout) {
62
+ return new Promise((resolve, reject) => {
63
+ const timer = setTimeout(() => {
64
+ onTimeout?.();
65
+ reject(new Error(`Timed out after ${timeoutMs}ms`));
66
+ }, timeoutMs);
67
+ promise.then((value) => {
68
+ clearTimeout(timer);
69
+ resolve(value);
70
+ }, (error) => {
71
+ clearTimeout(timer);
72
+ reject(error);
73
+ });
74
+ });
75
+ }
25
76
  export class WorkProvider {
26
77
  options;
27
78
  remotePool;
79
+ warn;
80
+ localTimeoutMs;
81
+ lastGenerationTrace = null;
82
+ lastProbeResults = [];
83
+ executionPlan;
84
+ probePromise = null;
28
85
  constructor(options) {
29
86
  this.options = options;
87
+ this.warn = options.warn ?? ((message) => console.warn(`[nano-core] ${message}`));
88
+ this.localTimeoutMs = DEFAULT_LOCAL_TIMEOUT_MS;
30
89
  const hasRemotePool = (options.urls && options.urls.length > 0) || options.env || (options.defaults && options.defaults.length > 0);
31
90
  if (!hasRemotePool) {
32
91
  this.remotePool = null;
33
- return;
34
92
  }
35
- const remotePoolOptions = {
36
- kind: 'work',
37
- defaults: options.defaults ?? [],
38
- transportPolicy: 'bearer-and-json-body-key',
39
- };
40
- if (options.urls && options.urls.length > 0)
41
- remotePoolOptions.urls = options.urls;
42
- if (options.env)
43
- remotePoolOptions.env = options.env;
44
- if (options.warn)
45
- remotePoolOptions.warn = options.warn;
46
- if (options.onActiveEndpointChange)
47
- remotePoolOptions.onActiveEndpointChange = options.onActiveEndpointChange;
48
- this.remotePool = new HttpEndpointPool(remotePoolOptions);
93
+ else {
94
+ const remotePoolOptions = {
95
+ kind: 'work',
96
+ defaults: options.defaults ?? [],
97
+ transportPolicy: 'bearer-and-json-body-key',
98
+ ...(options.timeoutMs ? { timeoutMs: options.timeoutMs } : {}),
99
+ };
100
+ if (options.urls && options.urls.length > 0)
101
+ remotePoolOptions.urls = options.urls;
102
+ if (options.env)
103
+ remotePoolOptions.env = options.env;
104
+ if (options.warn)
105
+ remotePoolOptions.warn = options.warn;
106
+ if (options.onActiveEndpointChange)
107
+ remotePoolOptions.onActiveEndpointChange = options.onActiveEndpointChange;
108
+ this.remotePool = new HttpEndpointPool(remotePoolOptions);
109
+ }
110
+ this.executionPlan = this.buildDefaultPlan();
49
111
  }
50
112
  static auto(options) {
51
113
  return new WorkProvider(options);
52
114
  }
53
- /**
54
- * Generates a minimal JSON-serializable report of the work provider's active configuration.
55
- */
115
+ getRemoteAuditReport() {
116
+ return this.remotePool?.getAuditReport() ?? [];
117
+ }
56
118
  getAuditReport() {
119
+ const localStep = this.lastGenerationTrace?.mode === 'local' ? this.lastGenerationTrace.backend ?? null : null;
57
120
  return {
58
- remotePool: this.remotePool?.getAuditReport() ?? [],
59
- remotes: this.options.remotes?.map(r => ({ url: r.url, timeoutMs: r.timeoutMs })) || [],
60
- localChain: this.options.localChain || [],
61
- profiler: this.options.profiler || 'default'
121
+ remotePool: this.getRemoteAuditReport(),
122
+ remotes: this.options.remotes?.map((remote) => ({ url: remote.url, timeoutMs: remote.timeoutMs })) ?? [],
123
+ localChain: this.options.localChain ?? DEFAULT_LOCAL_CHAIN,
124
+ profiler: this.options.profiler ?? 'default',
125
+ localBackend: localStep,
126
+ lastGenerationTrace: this.lastGenerationTrace,
127
+ executionPlan: this.executionPlan,
62
128
  };
63
129
  }
64
- /**
65
- * Calibrates the work provider based on the environment.
66
- * Runs a dummy hash to determine optimal strategy.
67
- */
68
130
  async calibrate() {
69
- // In a real implementation this would benchmark nano-pow-with-fallback.
70
- // For scaffolding, we return a simulated profile.
71
- // Simulate picking WASM/WebGL based on fallback strategy
131
+ const plan = await this.probe();
132
+ const localProbeDurations = plan.probeResults
133
+ .filter((result) => result.available && result.kind !== 'remote' && typeof result.durationMs === 'number')
134
+ .map((result) => result.durationMs);
135
+ const bestLocalDuration = localProbeDurations.length > 0 ? Math.min(...localProbeDurations) : 0;
136
+ const measuredMhs = bestLocalDuration > 0 ? Number((1_000 / bestLocalDuration).toFixed(2)) : 0;
72
137
  return {
73
- measuredMhs: 104.2, // simulated Node M1 webgpu speed
74
- activeStrategy: 'local-primary'
138
+ measuredMhs,
139
+ activeStrategy: plan.source === 'probe' ? 'planned' : 'remote-first',
75
140
  };
76
141
  }
77
- /**
78
- * Generate Proof-of-Work for a given hash.
79
- */
80
- async generate(hash, difficulty) {
142
+ async probe() {
143
+ if (this.probePromise) {
144
+ return this.probePromise;
145
+ }
146
+ this.probePromise = this.runProbe();
147
+ try {
148
+ const plan = await this.probePromise;
149
+ this.executionPlan = plan;
150
+ return plan;
151
+ }
152
+ finally {
153
+ this.probePromise = null;
154
+ }
155
+ }
156
+ buildDefaultPlan() {
157
+ const localChain = this.options.localChain ?? DEFAULT_LOCAL_CHAIN;
158
+ const steps = [];
81
159
  if (this.remotePool) {
82
- const response = await this.remotePool.postJson({
83
- action: 'work_generate',
84
- hash,
85
- difficulty,
86
- });
87
- if (response.work)
88
- return response.work;
89
- }
90
- // In real implementation, this would route to local fallback engines.
91
- return '0000000000000000';
160
+ steps.push({ kind: 'remote' });
161
+ }
162
+ for (const compute of localChain) {
163
+ steps.push({ kind: localComputeToPlanStep(compute) });
164
+ }
165
+ return {
166
+ source: 'default',
167
+ steps,
168
+ disabledLocalBackends: [],
169
+ probeResults: [],
170
+ };
171
+ }
172
+ createLocalPowService(backend) {
173
+ const disabledBackends = Object.values(PowBackendName).filter((candidate) => candidate !== backend);
174
+ return new PowService({ disabledBackends });
175
+ }
176
+ async probeRemote() {
177
+ if (!this.remotePool) {
178
+ return { kind: 'remote', available: false, reason: 'remote pool not configured' };
179
+ }
180
+ const startedAt = performance.now();
181
+ try {
182
+ await this.remotePool.postJson({ action: 'version' });
183
+ return {
184
+ kind: 'remote',
185
+ available: true,
186
+ durationMs: performance.now() - startedAt,
187
+ };
188
+ }
189
+ catch (error) {
190
+ return {
191
+ kind: 'remote',
192
+ available: false,
193
+ reason: error instanceof Error ? error.message : String(error),
194
+ };
195
+ }
196
+ }
197
+ async probeLocalBackend(compute) {
198
+ const backend = localComputeToBackendName(compute);
199
+ const startedAt = performance.now();
200
+ const powService = this.createLocalPowService(backend);
201
+ try {
202
+ await powService.ready;
203
+ await withTimeout(powService.getProofOfWork({ hash: PROBE_HASH, threshold: PROBE_DIFFICULTY }), this.localTimeoutMs, () => powService.cancel());
204
+ return {
205
+ kind: localComputeToPlanStep(compute),
206
+ available: true,
207
+ durationMs: performance.now() - startedAt,
208
+ };
209
+ }
210
+ catch (error) {
211
+ return {
212
+ kind: localComputeToPlanStep(compute),
213
+ available: false,
214
+ reason: error instanceof Error ? error.message : String(error),
215
+ };
216
+ }
217
+ }
218
+ buildPlanFromProbeResults(results) {
219
+ const remote = results.find((result) => result.kind === 'remote');
220
+ const locals = results.filter((result) => isLocalStepKind(result.kind));
221
+ const availableLocals = locals
222
+ .filter((result) => result.available)
223
+ .sort((a, b) => (a.durationMs ?? Number.POSITIVE_INFINITY) - (b.durationMs ?? Number.POSITIVE_INFINITY));
224
+ const disabledLocalBackends = locals
225
+ .filter((result) => !result.available)
226
+ .map((result) => planStepToBackendName(result.kind));
227
+ const steps = [];
228
+ if (availableLocals.length > 0) {
229
+ steps.push({ kind: availableLocals[0].kind });
230
+ if (remote?.available) {
231
+ steps.push({ kind: 'remote' });
232
+ }
233
+ for (const local of availableLocals.slice(1)) {
234
+ steps.push({ kind: local.kind });
235
+ }
236
+ }
237
+ else if (remote?.available) {
238
+ steps.push({ kind: 'remote' });
239
+ }
240
+ if (steps.length === 0) {
241
+ return this.buildDefaultPlan();
242
+ }
243
+ return {
244
+ source: 'probe',
245
+ steps,
246
+ disabledLocalBackends,
247
+ probeResults: results,
248
+ };
249
+ }
250
+ async runProbe() {
251
+ const localChain = this.options.localChain ?? DEFAULT_LOCAL_CHAIN;
252
+ const results = [];
253
+ results.push(await this.probeRemote());
254
+ for (const compute of localChain) {
255
+ results.push(await this.probeLocalBackend(compute));
256
+ }
257
+ this.lastProbeResults = results;
258
+ return this.buildPlanFromProbeResults(results);
259
+ }
260
+ async generateRemote(hash, difficulty) {
261
+ if (!this.remotePool) {
262
+ throw new Error('Remote work pool is not configured');
263
+ }
264
+ const response = await this.remotePool.postJson({
265
+ action: 'work_generate',
266
+ hash,
267
+ difficulty,
268
+ });
269
+ if (!response.work || response.work === '0000000000000000') {
270
+ throw new Error('Remote work provider returned invalid/zero nonce');
271
+ }
272
+ this.lastGenerationTrace = { mode: 'remote' };
273
+ return response.work;
274
+ }
275
+ async generateLocalWithBackend(hash, difficulty, backend) {
276
+ const powService = this.createLocalPowService(backend);
277
+ await powService.ready;
278
+ const result = await withTimeout(powService.getProofOfWork({ hash, threshold: difficulty }), this.localTimeoutMs, () => powService.cancel());
279
+ this.lastGenerationTrace = { mode: 'local', backend: result.backend };
280
+ return result.proofOfWork;
281
+ }
282
+ async executePlan(hash, difficulty, plan) {
283
+ let lastError;
284
+ for (const step of plan.steps) {
285
+ try {
286
+ if (step.kind === 'remote') {
287
+ return await this.generateRemote(hash, difficulty);
288
+ }
289
+ return await this.generateLocalWithBackend(hash, difficulty, planStepToBackendName(step.kind));
290
+ }
291
+ catch (error) {
292
+ lastError = error;
293
+ }
294
+ }
295
+ throw lastError instanceof Error ? lastError : new Error('No work generation strategy succeeded');
296
+ }
297
+ async generate(hash, difficulty) {
298
+ const shouldProbe = this.options.profiler?.mode === 'auto';
299
+ const plan = shouldProbe ? await this.probe() : this.executionPlan;
300
+ return await this.executePlan(hash, difficulty, plan);
92
301
  }
93
302
  }
94
303
  //# sourceMappingURL=WorkProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WorkProvider.js","sourceRoot":"","sources":["../../src/work/WorkProvider.ts"],"names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AAM,CAAC,OAA8B,EAAE,CAAC;QAC7F,OAAO,MAAM,CAAC,WAAW,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,UAAkB,EAAE,IAAuB;QACjF,IAAI,SAAkB,CAAC;QAEvB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,CAAC;gBACH,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC3B,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBACrD,CAAC;gBAED,OAAO,MAAM,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,UAAU,EAAE,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACjG,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,SAAS,GAAG,KAAK,CAAC;YACpB,CAAC;QACH,CAAC;QAED,MAAM,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACpG,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,UAAkB;QACpD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,KAAK,MAAM,CAAC;QAC3D,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;QACnE,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@openrai/nano-core",
3
- "version": "2.1.0",
3
+ "version": "2.4.0",
4
4
  "description": "Protocol engine for Nano integration ecosystem",
5
+ "repository": "https://github.com/OpenRai/nano-core",
5
6
  "type": "module",
6
7
  "main": "./dist/index.js",
7
8
  "types": "./dist/index.d.ts",
@@ -25,7 +26,8 @@
25
26
  },
26
27
  "scripts": {
27
28
  "build": "tsc",
28
- "test": "vitest run"
29
+ "test": "vitest run",
30
+ "release": "pnpm publish --access public --no-git-checks"
29
31
  },
30
32
  "keywords": [
31
33
  "nano",
@@ -41,6 +43,7 @@
41
43
  "dist"
42
44
  ],
43
45
  "dependencies": {
46
+ "blakejs": "^1.2.1",
44
47
  "nano-pow-with-fallback": "^1.1.2",
45
48
  "nanocurrency": "^2.5.0"
46
49
  },