chia-agent 16.1.1 → 16.1.3
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 +9 -0
- package/api/rpc/full_node/index.d.ts +3 -3
- package/package.json +1 -1
- package/rpc/index.d.ts +4 -0
- package/rpc/index.js +16 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [16.1.3]
|
|
4
|
+
### Fixed
|
|
5
|
+
- RPC failures now reject with a typed `RpcError` instead of a raw response object
|
|
6
|
+
|
|
7
|
+
## [16.1.2]
|
|
8
|
+
### Fixed
|
|
9
|
+
- Fixed `TGetCoinRecordsByPuzzleHashRequest` type definition
|
|
10
|
+
- Made `start_height`, `end_height`, and `include_spent_coins` optional parameters
|
|
11
|
+
|
|
3
12
|
## [16.1.1]
|
|
4
13
|
### Fixed
|
|
5
14
|
- Fixed incorrect response type for [`get_auto_farming`](./src/api/rpc/full_node/README.md#get_auto_farmingagent)
|
|
@@ -198,9 +198,9 @@ export declare const get_coin_records_by_puzzle_hash_command = "get_coin_records
|
|
|
198
198
|
export type get_coin_records_by_puzzle_hash_command = typeof get_coin_records_by_puzzle_hash_command;
|
|
199
199
|
export type TGetCoinRecordsByPuzzleHashRequest = {
|
|
200
200
|
puzzle_hash: str;
|
|
201
|
-
start_height
|
|
202
|
-
end_height
|
|
203
|
-
include_spent_coins
|
|
201
|
+
start_height?: uint32;
|
|
202
|
+
end_height?: uint32;
|
|
203
|
+
include_spent_coins?: bool;
|
|
204
204
|
};
|
|
205
205
|
export type TGetCoinRecordsByPuzzleHashResponse = {
|
|
206
206
|
coin_records: CoinRecordBackwardCompatible[];
|
package/package.json
CHANGED
package/rpc/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { Agent as HttpsAgent } from "https";
|
|
|
2
2
|
import { Agent as HttpAgent } from "http";
|
|
3
3
|
import { TConfig } from "../config/index";
|
|
4
4
|
import { APIAgent } from "../agent/index";
|
|
5
|
+
export declare class RpcError extends Error {
|
|
6
|
+
response: unknown;
|
|
7
|
+
constructor(message: string, response: unknown);
|
|
8
|
+
}
|
|
5
9
|
type TDestination = "farmer" | "harvester" | "full_node" | "wallet" | "data_layer" | "daemon" | "pool";
|
|
6
10
|
export declare function getConnectionInfoFromConfig(destination: TDestination, config: TConfig): {
|
|
7
11
|
hostname: string;
|
package/rpc/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPCAgent = void 0;
|
|
3
|
+
exports.RPCAgent = exports.RpcError = void 0;
|
|
4
4
|
exports.getConnectionInfoFromConfig = getConnectionInfoFromConfig;
|
|
5
5
|
exports.getConf = getConf;
|
|
6
6
|
exports.loadCertFilesFromConfig = loadCertFilesFromConfig;
|
|
@@ -14,6 +14,14 @@ const JSONbig = JSONbigBuilder({
|
|
|
14
14
|
useNativeBigInt: true,
|
|
15
15
|
alwaysParseAsBig: false,
|
|
16
16
|
});
|
|
17
|
+
class RpcError extends Error {
|
|
18
|
+
constructor(message, response) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "RpcError";
|
|
21
|
+
this.response = response;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.RpcError = RpcError;
|
|
17
25
|
function getConnectionInfoFromConfig(destination, config) {
|
|
18
26
|
let hostname = "localhost";
|
|
19
27
|
let port = -1;
|
|
@@ -313,8 +321,13 @@ class RPCAgent {
|
|
|
313
321
|
return reject(new Error(`Response has no 'success' property: ${serializedData}`));
|
|
314
322
|
}
|
|
315
323
|
if (!d.success) {
|
|
316
|
-
|
|
317
|
-
|
|
324
|
+
const errorMessage = typeof d.error === "string"
|
|
325
|
+
? d.error
|
|
326
|
+
: typeof d.error_message === "string"
|
|
327
|
+
? d.error_message
|
|
328
|
+
: `RPC request failed: ${(0, logger_1.stringify)(d)}`;
|
|
329
|
+
(0, logger_1.getLogger)().info(`API failure: ${errorMessage}`);
|
|
330
|
+
return reject(new RpcError(errorMessage, d));
|
|
318
331
|
}
|
|
319
332
|
(0, logger_1.getLogger)().debug(() => `RPC response received from ${this._protocol}//${this._host}:${this._port}${options.path}`);
|
|
320
333
|
(0, logger_1.getLogger)().trace(() => `RPC response data: ${(0, logger_1.stringify)(d)}`);
|