chia-agent 11.1.1 → 12.0.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [12.0.0]
4
+ ### Breaking change
5
+ Now the types of `int64`, `uint64`, `uint128`, `uint512` are `number | BigInt` (Originally it was `number`).
6
+ When the numeric value is larger than `Number.MAX_SAFE_INTEGER`, the value is parsed as a `BigInt`.
7
+ You need to check a numeric member of API responses whether it is a `number` or `BigInt`
8
+ if the type of it is either `int64`, `uint64`, `uint128` or `uint512`.
9
+ You may also use `BigInt` for API request inputs wherever the type is one of the above.
10
+
3
11
  ## [11.1.1]
4
12
  Just updated documents.
5
13
  You don't need to update `chia-agent` from `11.1.0` for `chia-blockchain@1.8.1` because there are no API changes.
@@ -1003,6 +1011,7 @@ daemon.sendMessage(destination, get_block_record_by_height_command, data);
1003
1011
  Initial release.
1004
1012
 
1005
1013
  <!-- [Unreleased]: https://github.com/Chia-Mine/chia-agent/compare/v0.0.1...v0.0.2 -->
1014
+ [12.0.0]: https://github.com/Chia-Mine/chia-agent/compare/v11.1.1...v12.0.0
1006
1015
  [11.1.1]: https://github.com/Chia-Mine/chia-agent/compare/v11.1.0...v11.1.1
1007
1016
  [11.1.0]: https://github.com/Chia-Mine/chia-agent/compare/v11.0.0...v11.1.0
1008
1017
  [11.0.0]: https://github.com/Chia-Mine/chia-agent/compare/v10.1.0...v11.0.0
@@ -9,10 +9,10 @@ export declare type int16 = number;
9
9
  export declare type uint16 = number;
10
10
  export declare type int32 = number;
11
11
  export declare type uint32 = number;
12
- export declare type int64 = number;
13
- export declare type uint64 = number;
14
- export declare type uint128 = number;
15
- export declare type int512 = number;
12
+ export declare type int64 = number | BigInt;
13
+ export declare type uint64 = number | BigInt;
14
+ export declare type uint128 = number | BigInt;
15
+ export declare type int512 = number | BigInt;
16
16
  export declare type float = number;
17
17
  export declare type str = string;
18
18
  export declare type bool = boolean;
package/bin/cli.js CHANGED
@@ -39,7 +39,7 @@ if (command === "farm") {
39
39
  if (e.command === "new_farming_info") {
40
40
  const { farming_info } = e.data;
41
41
  const { challenge_hash, passed_filter, proofs, total_plots, timestamp } = farming_info;
42
- const date = new Date(timestamp * 1000);
42
+ const date = new Date(Number(timestamp) * 1000);
43
43
  console.log(`${challenge_hash.substr(0, 32)}... ${passed_filter}/${total_plots} ${proofs} ${date.toLocaleTimeString()}`);
44
44
  sumPassedFilter += passed_filter;
45
45
  sumTotalPlot += total_plots;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chia-agent",
3
- "version": "11.1.1",
3
+ "version": "12.0.0",
4
4
  "author": "ChiaMineJP <admin@chiamine.jp>",
5
5
  "description": "chia rpc/websocket client library",
6
6
  "license": "MIT",
@@ -26,6 +26,7 @@
26
26
  "node": ">=12.13.0"
27
27
  },
28
28
  "dependencies": {
29
+ "json-bigint": "Chia-Mine/json-bigint#v1.0.1",
29
30
  "ws": "^8.5.0",
30
31
  "yaml": "^2.2.2"
31
32
  }
package/rpc/index.js CHANGED
@@ -13,8 +13,13 @@ exports.RPCAgent = exports.getConnectionInfoFromConfig = void 0;
13
13
  const https_1 = require("https");
14
14
  const http_1 = require("http");
15
15
  const fs_1 = require("fs");
16
+ const JSONbigBuilder = require("json-bigint");
16
17
  const logger_1 = require("../logger");
17
18
  const index_1 = require("../config/index");
19
+ const JSONbig = JSONbigBuilder({
20
+ useNativeBigInt: true,
21
+ alwaysParseAsBig: false,
22
+ });
18
23
  function getConnectionInfoFromConfig(destination, config) {
19
24
  let hostname = "localhost";
20
25
  let port = -1;
@@ -153,7 +158,7 @@ class RPCAgent {
153
158
  request(method, path, data) {
154
159
  return __awaiter(this, void 0, void 0, function* () {
155
160
  return new Promise((resolve, reject) => {
156
- const body = data ? JSON.stringify(data) : "{}";
161
+ const body = data ? JSONbig.stringify(data) : "{}";
157
162
  const pathname = `/${path.replace(/^\/+/, "")}`;
158
163
  const METHOD = method.toUpperCase();
159
164
  const options = {
@@ -216,7 +221,7 @@ class RPCAgent {
216
221
  res.on("end", () => {
217
222
  try {
218
223
  if (chunks.length > 0) {
219
- const data = JSON.parse(Buffer.concat(chunks).toString());
224
+ const data = JSONbig.parse(Buffer.concat(chunks).toString());
220
225
  return resolve(data);
221
226
  }
222
227
  // RPC Server should return response like