@ethersphere/bee-js 9.2.1 → 9.4.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/dist/cjs/bee.js CHANGED
@@ -47,6 +47,7 @@ const grantee = __importStar(require("./modules/grantee"));
47
47
  const gsoc = __importStar(require("./modules/gsoc"));
48
48
  const pinning = __importStar(require("./modules/pinning"));
49
49
  const pss = __importStar(require("./modules/pss"));
50
+ const rchash_1 = require("./modules/rchash");
50
51
  const status = __importStar(require("./modules/status"));
51
52
  const stewardship = __importStar(require("./modules/stewardship"));
52
53
  const tag = __importStar(require("./modules/tag"));
@@ -865,6 +866,12 @@ class Bee {
865
866
  reference = new typed_bytes_1.Reference(reference);
866
867
  return (0, envelope_1.postEnvelope)(this.getRequestOptionsForCall(options), postageBatchId, reference);
867
868
  }
869
+ /**
870
+ * Get reserve commitment hash duration seconds
871
+ */
872
+ async rchash(depth, anchor1, anchor2, options) {
873
+ return (0, rchash_1.rchash)(this.getRequestOptionsForCall(options), depth, anchor1, anchor2);
874
+ }
868
875
  /**
869
876
  * Ping the Bee node to see if there is a live Bee node on the given URL.
870
877
  *
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rchash = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
5
+ const http_1 = require("../utils/http");
6
+ const RCHASH_ENDPOINT = 'rchash';
7
+ async function rchash(requestOptions, depth, anchor1, anchor2) {
8
+ const response = await (0, http_1.http)(requestOptions, {
9
+ responseType: 'json',
10
+ url: `${RCHASH_ENDPOINT}/${depth}/${anchor1}/${anchor2}`,
11
+ });
12
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
13
+ return cafe_utility_1.Types.asNumber(body.durationSeconds, { name: 'durationSeconds' });
14
+ }
15
+ exports.rchash = rchash;
@@ -69,5 +69,8 @@ class Bytes {
69
69
  equals(other) {
70
70
  return this.toHex() === new Bytes(other).toHex();
71
71
  }
72
+ represent() {
73
+ return this.toHex();
74
+ }
72
75
  }
73
76
  exports.Bytes = Bytes;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Duration = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
4
5
  class Duration {
5
6
  constructor(seconds) {
6
7
  this.seconds = Math.ceil(seconds);
@@ -47,5 +48,8 @@ class Duration {
47
48
  toEndDate(startDate) {
48
49
  return new Date((startDate ?? new Date()).getTime() + this.seconds * 1000);
49
50
  }
51
+ represent() {
52
+ return cafe_utility_1.Dates.secondsToHumanTime(this.seconds);
53
+ }
50
54
  }
51
55
  exports.Duration = Duration;
@@ -37,5 +37,8 @@ class Size {
37
37
  toFormattedString() {
38
38
  return cafe_utility_1.Numbers.convertBytes(this.bytes, 1000);
39
39
  }
40
+ represent() {
41
+ return this.toFormattedString();
42
+ }
40
43
  }
41
44
  exports.Size = Size;