@ninsei-labs/sdk 0.44.0 → 0.44.2
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/CHANGELOG.md +25 -0
- package/engine/monero/nodeNetwork.js +7 -3
- package/index.d.ts +0 -14
- package/package.json +5 -1
- package/src/public/core.d.ts +6 -0
- package/src/public/core.mjs +1 -1
- package/src/public/networks.d.ts +50 -0
- package/src/public/networks.mjs +9 -0
- package/src/public/xmr.d.ts +23 -1
- package/src/public/xmr.mjs +3 -0
- package/src/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## 0.44.2 — 2026-10-20
|
|
2
|
+
|
|
3
|
+
REGTEST HAS A NAME THE PACKAGE KNOWS.
|
|
4
|
+
|
|
5
|
+
- `networkFromNode` accepts `fakechain`, the answer a `monerod` in regtest mode gives. Every stand and the CI
|
|
6
|
+
contour run that mode, and the withdrawal page builds its wallet from the recovery file, so refusing the name
|
|
7
|
+
stopped a run against a node the page is meant to test. The answer is passed through as `fakechain`; an unknown
|
|
8
|
+
word is still `null`, not a guess.
|
|
9
|
+
- The type declaration and the wallet-factory check name the fourth answer.
|
|
10
|
+
- The `Swap` type is gone. Nothing in the package returned one, so a reader could build on `swap.sweep()`
|
|
11
|
+
and find it at runtime. The working surfaces are unchanged: `swaps.get`/`swaps.toState`, `actions.markReady`,
|
|
12
|
+
`actions.claim`, `actions.refund`, and `sweep` for the withdrawal.
|
|
13
|
+
|
|
14
|
+
## 0.44.1 — 2026-10-20
|
|
15
|
+
|
|
16
|
+
TWO ENTRIES A BACKEND NEEDS WHEN IT STOPS READING THE PAGE'S SOURCE.
|
|
17
|
+
|
|
18
|
+
- `./networks` names the registry the engine already holds: `CHAINS`, `DEX_CHAINS`, `DEFAULT_CHAIN` and
|
|
19
|
+
`ASYNC_ROUTE_PROVIDERS`. A service that validates a chain id or a token against the same data the page
|
|
20
|
+
reads cannot drift from it. Nothing is re-implemented; the entry only re-exports `engine/core/config.js`.
|
|
21
|
+
- `./core` now also exports `normalizeAmountInput`, the text a person typed reduced to a decimal string, so a
|
|
22
|
+
backend does not carry a second reader of the same field.
|
|
23
|
+
- `./xmr` now names the block walk a watcher runs: `scanRange`, `viewKeyFormForAddress` and `laterBoundary`, all
|
|
24
|
+
from `engine/monero/scan.js`. A backend watching a deposit no longer reaches into the page's source.
|
|
25
|
+
|
|
1
26
|
## 0.44.0 — 2026-10-19
|
|
2
27
|
|
|
3
28
|
THE WITHDRAWAL AND THE NODE NOW ASK THE PACKAGE INSTEAD OF CARRYING THEIR OWN COPIES. Every rule below was
|
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
// mapping used to be a private function of the sweep page, which made "what a node may say" knowledge of one
|
|
6
6
|
// interface.
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
8
|
+
// REGTEST JOINS THEM BY ITS OFFICIAL NAME. monerod in regtest mode answers `fakechain`; the CI contour and every
|
|
9
|
+
// local stand run that mode, and the wallet's own network comes from the recovery file, not from this answer. Without
|
|
10
|
+
// the name the page refuses a node it is supposed to test against. It is a KNOWN name, not a wildcard.
|
|
11
|
+
//
|
|
12
|
+
// AN UNKNOWN ANSWER IS STILL NULL, NOT A GUESS. Defaulting to a network would build a wallet for a chain the node may
|
|
13
|
+
// not serve; the caller can then say which answer it got and stop.
|
|
14
|
+
const KNOWN = new Set(["mainnet", "stagenet", "testnet", "fakechain"]);
|
|
11
15
|
|
|
12
16
|
export function networkFromNode(info) {
|
|
13
17
|
const type = String((info && info.nettype) || "").trim().toLowerCase();
|
package/index.d.ts
CHANGED
|
@@ -1114,20 +1114,6 @@ export interface RecoveryFile {
|
|
|
1114
1114
|
readonly contents: string;
|
|
1115
1115
|
}
|
|
1116
1116
|
|
|
1117
|
-
export interface Swap {
|
|
1118
|
-
readonly id: string;
|
|
1119
|
-
/** The current state. Also arrives in the subscription. */
|
|
1120
|
-
state(): SwapState;
|
|
1121
|
-
/** Subscribe to changes. Returns an unsubscribe function. */
|
|
1122
|
-
on(event: "update", handler: (state: SwapState) => void): () => void;
|
|
1123
|
-
/** The "checked by you" mark: opens the claim to the maker. */
|
|
1124
|
-
markReady(): Promise<SwapState>;
|
|
1125
|
-
/** Withdraw the XMR to the recipient's address. */
|
|
1126
|
-
sweep(): Promise<SwapState>;
|
|
1127
|
-
/** Refund the ETH when the claim did not happen. */
|
|
1128
|
-
refund(): Promise<SwapState>;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
1117
|
export interface SwapState {
|
|
1132
1118
|
readonly id: string;
|
|
1133
1119
|
readonly direction: "buy" | "sell";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninsei-labs/sdk",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -69,6 +69,10 @@
|
|
|
69
69
|
"types": "./src/public/core.d.ts",
|
|
70
70
|
"default": "./src/public/core.mjs"
|
|
71
71
|
},
|
|
72
|
+
"./networks": {
|
|
73
|
+
"types": "./src/public/networks.d.ts",
|
|
74
|
+
"default": "./src/public/networks.mjs"
|
|
75
|
+
},
|
|
72
76
|
"./recovery": {
|
|
73
77
|
"types": "./src/public/recovery.d.ts",
|
|
74
78
|
"default": "./src/public/recovery.mjs"
|
package/src/public/core.d.ts
CHANGED
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function parseAmount(raw: string | number | null | undefined): number | null;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The same field text reduced to something a decimal parser can read: thousands separators removed, a lone comma
|
|
17
|
+
* read as the decimal separator, anything after a second separator dropped. Empty when the text carries no digit.
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeAmountInput(raw: string | number | null | undefined): string;
|
|
20
|
+
|
|
15
21
|
/**
|
|
16
22
|
* ATOMIC UNITS -> A DECIMAL STRING. One XMR is 10^12 atomic units; the conversion uses BigInt, so a value above
|
|
17
23
|
* 2^53 (about 9007 XMR in piconero) is not rounded. Dust does not vanish: 1 unit is "0.000000000001". `trim`
|
package/src/public/core.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// One function today. It is a separate entry because it belongs to neither the XMR side nor the EVM side, and a
|
|
4
4
|
// consumer forced to import it from either would learn a false lesson about where it lives.
|
|
5
5
|
|
|
6
|
-
export { parseAmount } from "../../engine/core/format.js";
|
|
6
|
+
export { normalizeAmountInput, parseAmount } from "../../engine/core/format.js";
|
|
7
7
|
|
|
8
8
|
// XMR AMOUNTS IN ATOMIC UNITS: 12 decimals, bigint, no rounding. `formatXmr` for display and for a field,
|
|
9
9
|
// `parseXmr` for what a person typed.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// DECLARATIONS FOR THE `./networks` ENTRY.
|
|
2
|
+
//
|
|
3
|
+
// src/public/networks.mjs only NAMES what engine/core/config.js already exports. The declarations cover the fields
|
|
4
|
+
// a consumer of the registry reads; the engine's objects carry more (explorers, price feeds, gas hints) and a
|
|
5
|
+
// consumer is free to read them, but nothing here invents a field the engine does not have.
|
|
6
|
+
|
|
7
|
+
/** A token the network accepts. `address` is a 20-byte hex string; `decimals` is what its own contract reports. */
|
|
8
|
+
export interface ChainToken {
|
|
9
|
+
symbol: string;
|
|
10
|
+
address: string;
|
|
11
|
+
decimals: number;
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The DEX deployment on a network, when there is one. */
|
|
16
|
+
export interface ChainUniswap {
|
|
17
|
+
factory?: string;
|
|
18
|
+
quoter?: string;
|
|
19
|
+
/** WETH: the wrapped form of the native coin, used when a route needs an ERC-20. */
|
|
20
|
+
wrapped?: { address: string; decimals: number };
|
|
21
|
+
[field: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Chain {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
vm: string;
|
|
28
|
+
chainId: number;
|
|
29
|
+
caip2?: string;
|
|
30
|
+
testnet?: boolean;
|
|
31
|
+
native: { symbol: string; decimals: number };
|
|
32
|
+
rpcUrl?: string;
|
|
33
|
+
tokens?: ChainToken[];
|
|
34
|
+
uniswap?: ChainUniswap;
|
|
35
|
+
[field: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One entry per async route provider (CoWSwap, UniswapX, ...): what it settles and the networks it serves. */
|
|
39
|
+
export interface AsyncRouteProvider {
|
|
40
|
+
venue?: string;
|
|
41
|
+
shape?: string;
|
|
42
|
+
settles?: string;
|
|
43
|
+
networks?: Record<string, unknown>;
|
|
44
|
+
[field: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare const CHAINS: readonly Chain[];
|
|
48
|
+
export declare const DEX_CHAINS: readonly string[];
|
|
49
|
+
export declare const DEFAULT_CHAIN: string;
|
|
50
|
+
export declare const ASYNC_ROUTE_PROVIDERS: Readonly<Record<string, AsyncRouteProvider>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// THE NETWORK REGISTRY, FOR A CONSUMER THAT IS NOT THE BROWSER.
|
|
2
|
+
//
|
|
3
|
+
// The registry is one structure: each network names its chain id, its native coin, the tokens it accepts and,
|
|
4
|
+
// where it exists, the DEX deployment. A backend that validates a chain id and a token against it must read the
|
|
5
|
+
// same data the page reads, or the two drift apart silently.
|
|
6
|
+
//
|
|
7
|
+
// Names only: the engine owns the values. Nothing here is re-implemented.
|
|
8
|
+
|
|
9
|
+
export { ASYNC_ROUTE_PROVIDERS, CHAINS, DEFAULT_CHAIN, DEX_CHAINS } from "../../engine/core/config.js";
|
package/src/public/xmr.d.ts
CHANGED
|
@@ -322,7 +322,7 @@ export declare function sellWindowSec(request?: {
|
|
|
322
322
|
* mainnet wallet against a stagenet node looks like a broken withdrawal. An answer that is none of `mainnet`,
|
|
323
323
|
* `stagenet`, `testnet` comes back as null - a default would build a wallet for a chain the node may not serve.
|
|
324
324
|
*/
|
|
325
|
-
export declare function networkFromNode(info: unknown): "mainnet" | "stagenet" | "testnet" | null;
|
|
325
|
+
export declare function networkFromNode(info: unknown): "mainnet" | "stagenet" | "testnet" | "fakechain" | null;
|
|
326
326
|
|
|
327
327
|
/** An address read as its network and its public keys. An integrated address's payment id is not returned. */
|
|
328
328
|
export interface AddressKeys {
|
|
@@ -471,3 +471,25 @@ export declare function probeMoneroNode(options: {
|
|
|
471
471
|
fetchImpl?: typeof fetch;
|
|
472
472
|
timeoutMs?: number;
|
|
473
473
|
}): Promise<NodeProbeOk | NodeProbeRefusal>;
|
|
474
|
+
|
|
475
|
+
/** The watch key form that matches the address's view public key, or null when none does. */
|
|
476
|
+
export declare function viewKeyFormForAddress(viewSecret: string, expectedViewPubHex: string): string | null;
|
|
477
|
+
|
|
478
|
+
/** A boundary height derived from a later unlock_time, or null when the time names no height. */
|
|
479
|
+
export declare function laterBoundary(...args: unknown[]): unknown;
|
|
480
|
+
|
|
481
|
+
/** One transaction that carries an output for a watched address. */
|
|
482
|
+
export interface ScannedMatch {
|
|
483
|
+
[field: string]: unknown;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** Walk a block range and return the transactions that pay a watched address. */
|
|
487
|
+
export declare function scanRange(options: {
|
|
488
|
+
daemonUrl: string;
|
|
489
|
+
fromHeight: number;
|
|
490
|
+
toHeight: number;
|
|
491
|
+
watched: unknown;
|
|
492
|
+
log?: (event: unknown) => void;
|
|
493
|
+
concurrency?: number;
|
|
494
|
+
nowSec?: number | null;
|
|
495
|
+
}): Promise<ScannedMatch[]>;
|
package/src/public/xmr.mjs
CHANGED
|
@@ -20,6 +20,9 @@ export {
|
|
|
20
20
|
prefixFor,
|
|
21
21
|
} from "../../engine/monero/address.js";
|
|
22
22
|
|
|
23
|
+
// THE BLOCK WALK A WATCHER RUNS: the same scanner the page uses, without a wallet.
|
|
24
|
+
export { laterBoundary, scanRange, viewKeyFormForAddress } from "../../engine/monero/scan.js";
|
|
25
|
+
|
|
23
26
|
export { createHalves } from "../../engine/atomic/halves.js";
|
|
24
27
|
export { createDleq2 } from "../../engine/atomic/dleq2.js";
|
|
25
28
|
|
package/src/version.mjs
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
// tools/sync-version.mjs. Do not edit it by hand - set the version in package.json and run `npm run sync:version`.
|
|
7
7
|
// The `version` check in tools/check.mjs refuses a mismatch, and refuses a runtime read of package.json here.
|
|
8
8
|
|
|
9
|
-
export const SDK_VERSION = "0.44.
|
|
9
|
+
export const SDK_VERSION = "0.44.2";
|