@neuraiproject/neurai-rpc 0.6.2 → 0.7.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/CHANGELOG.md +11 -0
- package/README.md +8 -0
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +11 -0
- package/index.ts +14 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.7.0] - 2026-09-27
|
|
9
|
+
|
|
10
|
+
### Reset testnet
|
|
11
|
+
|
|
12
|
+
- Export the new testnet and mainnet genesis hashes and `assertRpcGenesis` so
|
|
13
|
+
clients can reject an endpoint from the previous testnet before reading
|
|
14
|
+
balances or sending transactions.
|
|
15
|
+
- Preserve JSON-RPC errors returned with HTTP 200 as rejections.
|
|
16
|
+
- Verify genesis, asset marker and RPC error propagation against a node built
|
|
17
|
+
from Neurai-DePIN commit `0fe5a74943210508ec3be34c78e0f9192b7fefec`.
|
|
18
|
+
|
|
8
19
|
## [0.6.2] - 2026-09-22
|
|
9
20
|
|
|
10
21
|
### Documentation — neurai-key 5 address types
|
package/README.md
CHANGED
|
@@ -127,3 +127,11 @@ strings remain quoted strings: use the representation required by the RPC
|
|
|
127
127
|
method. Unsafe integer numbers, NaN and Infinity are rejected. No global
|
|
128
128
|
BigInt.prototype mutation is performed. `parseRpcJson` and `stringifyRpcJson`
|
|
129
129
|
are exported for callers implementing their own transport.
|
|
130
|
+
|
|
131
|
+
## Verify the chain before using a testnet RPC
|
|
132
|
+
|
|
133
|
+
`TESTNET_GENESIS_HASH` identifies the reset testnet. Call
|
|
134
|
+
`await assertRpcGenesis(rpc, TESTNET_GENESIS_HASH)` after constructing an RPC
|
|
135
|
+
client and before reading balances or building transactions. The port and
|
|
136
|
+
`getblockchaininfo.chain` label alone do not distinguish the previous testnet.
|
|
137
|
+
`MAINNET_GENESIS_HASH` is also exported for mainnet clients.
|
package/dist/index.cjs
CHANGED
|
@@ -19,6 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// index.ts
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
|
+
MAINNET_GENESIS_HASH: () => MAINNET_GENESIS_HASH,
|
|
23
|
+
TESTNET_GENESIS_HASH: () => TESTNET_GENESIS_HASH,
|
|
24
|
+
assertRpcGenesis: () => assertRpcGenesis,
|
|
22
25
|
getRPC: () => getRPC,
|
|
23
26
|
methods: () => methods,
|
|
24
27
|
parseRpcJson: () => parseRpcJson,
|
|
@@ -5054,6 +5057,14 @@ var methods = {
|
|
|
5054
5057
|
};
|
|
5055
5058
|
|
|
5056
5059
|
// index.ts
|
|
5060
|
+
var MAINNET_GENESIS_HASH = "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806";
|
|
5061
|
+
var TESTNET_GENESIS_HASH = "0000008b384aeffecdab182575dc4e86c9f07f90318c65088532660ed9a8a021";
|
|
5062
|
+
async function assertRpcGenesis(rpc, expectedGenesisHash) {
|
|
5063
|
+
const actual = await rpc("getblockhash", [0]);
|
|
5064
|
+
if (typeof actual !== "string" || actual.toLowerCase() !== expectedGenesisHash.toLowerCase()) {
|
|
5065
|
+
throw new Error(`Unexpected genesis block: expected ${expectedGenesisHash}, received ${String(actual)}`);
|
|
5066
|
+
}
|
|
5067
|
+
}
|
|
5057
5068
|
function rpcNumber(value) {
|
|
5058
5069
|
return new import_lossless_json.LosslessNumber(value);
|
|
5059
5070
|
}
|
|
@@ -5169,6 +5180,9 @@ async function postData(url = "", data = {}, username, password) {
|
|
|
5169
5180
|
}
|
|
5170
5181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5171
5182
|
0 && (module.exports = {
|
|
5183
|
+
MAINNET_GENESIS_HASH,
|
|
5184
|
+
TESTNET_GENESIS_HASH,
|
|
5185
|
+
assertRpcGenesis,
|
|
5172
5186
|
getRPC,
|
|
5173
5187
|
methods,
|
|
5174
5188
|
parseRpcJson,
|
package/dist/index.d.cts
CHANGED
|
@@ -201,6 +201,10 @@ interface IMethods {
|
|
|
201
201
|
}
|
|
202
202
|
declare const methods: IMethods;
|
|
203
203
|
|
|
204
|
+
declare const MAINNET_GENESIS_HASH = "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806";
|
|
205
|
+
declare const TESTNET_GENESIS_HASH = "0000008b384aeffecdab182575dc4e86c9f07f90318c65088532660ed9a8a021";
|
|
206
|
+
/** Reject an RPC endpoint that serves a different chain with the same network label. */
|
|
207
|
+
declare function assertRpcGenesis(rpc: (method: string, params: any[]) => Promise<unknown>, expectedGenesisHash: string): Promise<void>;
|
|
204
208
|
/** Exact decimal parameter, emitted as a JSON number rather than a quoted string. */
|
|
205
209
|
declare function rpcNumber(value: string): LosslessNumber;
|
|
206
210
|
/** Preserve unsafe JSON numeric tokens as strings; retain safe number compatibility. */
|
|
@@ -208,4 +212,4 @@ declare function parseRpcJson(text: string): any;
|
|
|
208
212
|
declare function stringifyRpcJson(value: unknown): string;
|
|
209
213
|
declare function getRPC(username: string, password: string, URL: string): (method: string, params: any[]) => Promise<unknown>;
|
|
210
214
|
|
|
211
|
-
export { getRPC, methods, parseRpcJson, rpcNumber, stringifyRpcJson };
|
|
215
|
+
export { MAINNET_GENESIS_HASH, TESTNET_GENESIS_HASH, assertRpcGenesis, getRPC, methods, parseRpcJson, rpcNumber, stringifyRpcJson };
|
package/dist/index.d.ts
CHANGED
|
@@ -201,6 +201,10 @@ interface IMethods {
|
|
|
201
201
|
}
|
|
202
202
|
declare const methods: IMethods;
|
|
203
203
|
|
|
204
|
+
declare const MAINNET_GENESIS_HASH = "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806";
|
|
205
|
+
declare const TESTNET_GENESIS_HASH = "0000008b384aeffecdab182575dc4e86c9f07f90318c65088532660ed9a8a021";
|
|
206
|
+
/** Reject an RPC endpoint that serves a different chain with the same network label. */
|
|
207
|
+
declare function assertRpcGenesis(rpc: (method: string, params: any[]) => Promise<unknown>, expectedGenesisHash: string): Promise<void>;
|
|
204
208
|
/** Exact decimal parameter, emitted as a JSON number rather than a quoted string. */
|
|
205
209
|
declare function rpcNumber(value: string): LosslessNumber;
|
|
206
210
|
/** Preserve unsafe JSON numeric tokens as strings; retain safe number compatibility. */
|
|
@@ -208,4 +212,4 @@ declare function parseRpcJson(text: string): any;
|
|
|
208
212
|
declare function stringifyRpcJson(value: unknown): string;
|
|
209
213
|
declare function getRPC(username: string, password: string, URL: string): (method: string, params: any[]) => Promise<unknown>;
|
|
210
214
|
|
|
211
|
-
export { getRPC, methods, parseRpcJson, rpcNumber, stringifyRpcJson };
|
|
215
|
+
export { MAINNET_GENESIS_HASH, TESTNET_GENESIS_HASH, assertRpcGenesis, getRPC, methods, parseRpcJson, rpcNumber, stringifyRpcJson };
|
package/dist/index.mjs
CHANGED
|
@@ -5027,6 +5027,14 @@ var methods = {
|
|
|
5027
5027
|
};
|
|
5028
5028
|
|
|
5029
5029
|
// index.ts
|
|
5030
|
+
var MAINNET_GENESIS_HASH = "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806";
|
|
5031
|
+
var TESTNET_GENESIS_HASH = "0000008b384aeffecdab182575dc4e86c9f07f90318c65088532660ed9a8a021";
|
|
5032
|
+
async function assertRpcGenesis(rpc, expectedGenesisHash) {
|
|
5033
|
+
const actual = await rpc("getblockhash", [0]);
|
|
5034
|
+
if (typeof actual !== "string" || actual.toLowerCase() !== expectedGenesisHash.toLowerCase()) {
|
|
5035
|
+
throw new Error(`Unexpected genesis block: expected ${expectedGenesisHash}, received ${String(actual)}`);
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5030
5038
|
function rpcNumber(value) {
|
|
5031
5039
|
return new LosslessNumber(value);
|
|
5032
5040
|
}
|
|
@@ -5141,6 +5149,9 @@ async function postData(url = "", data = {}, username, password) {
|
|
|
5141
5149
|
return response;
|
|
5142
5150
|
}
|
|
5143
5151
|
export {
|
|
5152
|
+
MAINNET_GENESIS_HASH,
|
|
5153
|
+
TESTNET_GENESIS_HASH,
|
|
5154
|
+
assertRpcGenesis,
|
|
5144
5155
|
getRPC,
|
|
5145
5156
|
methods,
|
|
5146
5157
|
parseRpcJson,
|
package/index.ts
CHANGED
|
@@ -3,6 +3,20 @@ import { methods } from "./docs";
|
|
|
3
3
|
|
|
4
4
|
export { methods };
|
|
5
5
|
|
|
6
|
+
export const MAINNET_GENESIS_HASH = "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806";
|
|
7
|
+
export const TESTNET_GENESIS_HASH = "0000008b384aeffecdab182575dc4e86c9f07f90318c65088532660ed9a8a021";
|
|
8
|
+
|
|
9
|
+
/** Reject an RPC endpoint that serves a different chain with the same network label. */
|
|
10
|
+
export async function assertRpcGenesis(
|
|
11
|
+
rpc: (method: string, params: any[]) => Promise<unknown>,
|
|
12
|
+
expectedGenesisHash: string,
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
const actual = await rpc("getblockhash", [0]);
|
|
15
|
+
if (typeof actual !== "string" || actual.toLowerCase() !== expectedGenesisHash.toLowerCase()) {
|
|
16
|
+
throw new Error(`Unexpected genesis block: expected ${expectedGenesisHash}, received ${String(actual)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
/** Exact decimal parameter, emitted as a JSON number rather than a quoted string. */
|
|
7
21
|
export function rpcNumber(value: string): LosslessNumber {
|
|
8
22
|
return new LosslessNumber(value);
|