chia-agent 13.2.0 → 14.0.0-beta.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 +6 -0
- package/README.md +3 -3
- package/api/rpc/common/index.d.ts +6 -6
- package/api/rpc/crawler/index.d.ts +2 -2
- package/api/rpc/data_layer/index.d.ts +30 -30
- package/api/rpc/farmer/index.d.ts +13 -13
- package/api/rpc/full_node/index.d.ts +37 -37
- package/api/rpc/harvester/index.d.ts +8 -8
- package/api/rpc/wallet/index.d.ts +137 -137
- package/config/index.js +1 -1
- package/daemon/index.js +2 -3
- package/package.json +1 -1
- package/rpc/index.d.ts +1 -5
- package/rpc/index.js +16 -2
package/config/index.js
CHANGED
|
@@ -43,7 +43,7 @@ function getConfig(configFilePath) {
|
|
|
43
43
|
exports.getConfig = getConfig;
|
|
44
44
|
function buildConfigObj(config, currentPath = [], product = {}) {
|
|
45
45
|
for (const propName in config) {
|
|
46
|
-
if (!
|
|
46
|
+
if (!Object.prototype.hasOwnProperty.call(config, propName)) {
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
49
|
const value = config[propName];
|
package/daemon/index.js
CHANGED
|
@@ -119,7 +119,6 @@ class Daemon {
|
|
|
119
119
|
reject("Not connected");
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
let timer = null;
|
|
123
122
|
const message = this.createMessageTemplate(command, destination, data || {});
|
|
124
123
|
const reqId = message.request_id;
|
|
125
124
|
this._responseQueue[reqId] = resolve;
|
|
@@ -262,7 +261,7 @@ class Daemon {
|
|
|
262
261
|
}
|
|
263
262
|
this._messageEventListeners.forEach(l => l(event));
|
|
264
263
|
for (const o in this._messageListeners) {
|
|
265
|
-
if (!
|
|
264
|
+
if (!Object.prototype.hasOwnProperty.call(this._messageListeners, o)) {
|
|
266
265
|
continue;
|
|
267
266
|
}
|
|
268
267
|
const listeners = this._messageListeners[o];
|
|
@@ -283,7 +282,7 @@ class Daemon {
|
|
|
283
282
|
this._subscriptions = [];
|
|
284
283
|
this._closeEventListeners.forEach(l => l(event));
|
|
285
284
|
this.clearAllEventListeners();
|
|
286
|
-
logger_1.getLogger().info(
|
|
285
|
+
logger_1.getLogger().info("Closed ws connection");
|
|
287
286
|
if (this._onClosePromise) {
|
|
288
287
|
this._onClosePromise();
|
|
289
288
|
this._onClosePromise = undefined;
|
package/package.json
CHANGED
package/rpc/index.d.ts
CHANGED
|
@@ -32,10 +32,6 @@ export declare type TRPCAgentProps = {
|
|
|
32
32
|
configPath?: string;
|
|
33
33
|
skip_hostname_verification?: boolean;
|
|
34
34
|
};
|
|
35
|
-
export declare type ErrorResponse = {
|
|
36
|
-
error: string;
|
|
37
|
-
success: false;
|
|
38
|
-
};
|
|
39
35
|
export declare class RPCAgent {
|
|
40
36
|
protected _protocol: "http" | "https";
|
|
41
37
|
protected _hostname: string;
|
|
@@ -52,7 +48,7 @@ export declare class RPCAgent {
|
|
|
52
48
|
clientKey: Buffer;
|
|
53
49
|
caCert: Buffer;
|
|
54
50
|
};
|
|
55
|
-
sendMessage<M extends unknown>(destination: string, command: string, data?: Record<string, unknown>): Promise<M
|
|
51
|
+
sendMessage<M extends unknown>(destination: string, command: string, data?: Record<string, unknown>): Promise<M>;
|
|
56
52
|
request<R>(method: string, path: string, data?: any): Promise<R>;
|
|
57
53
|
}
|
|
58
54
|
export declare type TRPCAgent = InstanceType<typeof RPCAgent>;
|
package/rpc/index.js
CHANGED
|
@@ -198,7 +198,7 @@ class RPCAgent {
|
|
|
198
198
|
}
|
|
199
199
|
p += "?";
|
|
200
200
|
for (const key in data) {
|
|
201
|
-
if (
|
|
201
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
202
202
|
p += `${key}=${data[key]}`;
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -228,7 +228,21 @@ class RPCAgent {
|
|
|
228
228
|
res.on("end", () => {
|
|
229
229
|
try {
|
|
230
230
|
if (chunks.length > 0) {
|
|
231
|
-
const
|
|
231
|
+
const entireChunks = Buffer.concat(chunks);
|
|
232
|
+
const serializedData = entireChunks.toString();
|
|
233
|
+
const d = JSONbig.parse(serializedData);
|
|
234
|
+
if (typeof d !== "object" || !d) {
|
|
235
|
+
logger_1.getLogger().error(`Response is expected to be an object but received: ${serializedData}`);
|
|
236
|
+
return reject(new Error(`Unexpected response format: ${serializedData}`));
|
|
237
|
+
}
|
|
238
|
+
else if (!Object.prototype.hasOwnProperty.call(d, "success")) {
|
|
239
|
+
logger_1.getLogger().error("Response has no 'success' property");
|
|
240
|
+
return reject(new Error(`Response has no 'success' property: ${serializedData}`));
|
|
241
|
+
}
|
|
242
|
+
if (!d.success) {
|
|
243
|
+
logger_1.getLogger().error(`API failure: ${d.error}`);
|
|
244
|
+
return reject(d);
|
|
245
|
+
}
|
|
232
246
|
return resolve(d);
|
|
233
247
|
}
|
|
234
248
|
// RPC Server should return response like
|