@ethersphere/bee-js 12.2.2 → 12.3.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.
Files changed (137) hide show
  1. package/dist/cjs/bee.js +56 -23
  2. package/dist/cjs/chunk/cac.js +4 -2
  3. package/dist/cjs/feed/index.js +3 -1
  4. package/dist/cjs/modules/bytes.js +6 -4
  5. package/dist/cjs/modules/bzz.js +5 -4
  6. package/dist/cjs/modules/chunk.js +3 -2
  7. package/dist/cjs/modules/debug/balance.js +5 -29
  8. package/dist/cjs/modules/debug/chequebook.js +9 -58
  9. package/dist/cjs/modules/debug/connectivity.js +5 -82
  10. package/dist/cjs/modules/debug/settlements.js +3 -22
  11. package/dist/cjs/modules/debug/stake.js +8 -33
  12. package/dist/cjs/modules/debug/stamps.js +27 -53
  13. package/dist/cjs/modules/debug/states.js +6 -31
  14. package/dist/cjs/modules/debug/status.js +5 -37
  15. package/dist/cjs/modules/debug/transactions.js +5 -26
  16. package/dist/cjs/modules/envelope.js +6 -6
  17. package/dist/cjs/modules/feed.js +3 -4
  18. package/dist/cjs/modules/grantee.js +8 -10
  19. package/dist/cjs/modules/pinning.js +5 -11
  20. package/dist/cjs/modules/rchash.js +2 -3
  21. package/dist/cjs/modules/soc.js +3 -2
  22. package/dist/cjs/modules/status.js +3 -3
  23. package/dist/cjs/modules/stewardship.js +2 -3
  24. package/dist/cjs/modules/tag.js +4 -35
  25. package/dist/cjs/stamper/stamper.js +2 -1
  26. package/dist/cjs/types/schema/balance.js +14 -0
  27. package/dist/cjs/types/schema/chequebook.js +49 -0
  28. package/dist/cjs/types/schema/connectivity.js +46 -0
  29. package/dist/cjs/types/schema/envelope.js +11 -0
  30. package/dist/cjs/types/schema/grantee.js +10 -0
  31. package/dist/cjs/types/schema/pinning.js +7 -0
  32. package/dist/cjs/types/schema/rchash.js +7 -0
  33. package/dist/cjs/types/schema/settlements.js +17 -0
  34. package/dist/cjs/types/schema/stake.js +33 -0
  35. package/dist/cjs/types/schema/stamps.js +48 -0
  36. package/dist/cjs/types/schema/states.js +34 -0
  37. package/dist/cjs/types/schema/status.js +39 -0
  38. package/dist/cjs/types/schema/stewardship.js +7 -0
  39. package/dist/cjs/types/schema/tag.js +20 -0
  40. package/dist/cjs/types/schema/transactions.js +24 -0
  41. package/dist/cjs/types/schema/upload.js +8 -0
  42. package/dist/cjs/utils/bad-ports.js +92 -0
  43. package/dist/cjs/utils/bytes.js +5 -3
  44. package/dist/cjs/utils/error.js +1 -0
  45. package/dist/cjs/utils/headers.js +19 -13
  46. package/dist/cjs/utils/hex-schema.js +8 -0
  47. package/dist/cjs/utils/http.js +92 -52
  48. package/dist/cjs/utils/resource-locator.js +4 -3
  49. package/dist/cjs/utils/schema.js +88 -0
  50. package/dist/cjs/utils/stamps.js +2 -1
  51. package/dist/cjs/utils/type.js +12 -130
  52. package/dist/cjs/utils/url.js +24 -0
  53. package/dist/index.browser.min.js +1 -1
  54. package/dist/index.browser.min.js.map +1 -1
  55. package/dist/mjs/bee.js +59 -30
  56. package/dist/mjs/chunk/cac.js +5 -3
  57. package/dist/mjs/feed/index.js +4 -2
  58. package/dist/mjs/modules/bytes.js +8 -8
  59. package/dist/mjs/modules/bzz.js +6 -9
  60. package/dist/mjs/modules/chunk.js +4 -7
  61. package/dist/mjs/modules/debug/balance.js +5 -61
  62. package/dist/mjs/modules/debug/chequebook.js +9 -114
  63. package/dist/mjs/modules/debug/connectivity.js +5 -145
  64. package/dist/mjs/modules/debug/settlements.js +3 -46
  65. package/dist/mjs/modules/debug/stake.js +8 -85
  66. package/dist/mjs/modules/debug/stamps.js +24 -126
  67. package/dist/mjs/modules/debug/states.js +6 -71
  68. package/dist/mjs/modules/debug/status.js +5 -91
  69. package/dist/mjs/modules/debug/transactions.js +5 -60
  70. package/dist/mjs/modules/envelope.js +6 -20
  71. package/dist/mjs/modules/feed.js +6 -7
  72. package/dist/mjs/modules/grantee.js +8 -26
  73. package/dist/mjs/modules/pinning.js +7 -21
  74. package/dist/mjs/modules/rchash.js +2 -7
  75. package/dist/mjs/modules/soc.js +4 -5
  76. package/dist/mjs/modules/status.js +4 -4
  77. package/dist/mjs/modules/stewardship.js +2 -7
  78. package/dist/mjs/modules/tag.js +4 -93
  79. package/dist/mjs/stamper/stamper.js +2 -1
  80. package/dist/mjs/types/schema/balance.js +13 -0
  81. package/dist/mjs/types/schema/chequebook.js +53 -0
  82. package/dist/mjs/types/schema/connectivity.js +41 -0
  83. package/dist/mjs/types/schema/envelope.js +8 -0
  84. package/dist/mjs/types/schema/grantee.js +7 -0
  85. package/dist/mjs/types/schema/pinning.js +4 -0
  86. package/dist/mjs/types/schema/rchash.js +4 -0
  87. package/dist/mjs/types/schema/settlements.js +22 -0
  88. package/dist/mjs/types/schema/stake.js +40 -0
  89. package/dist/mjs/types/schema/stamps.js +47 -0
  90. package/dist/mjs/types/schema/states.js +34 -0
  91. package/dist/mjs/types/schema/status.js +36 -0
  92. package/dist/mjs/types/schema/stewardship.js +4 -0
  93. package/dist/mjs/types/schema/tag.js +14 -0
  94. package/dist/mjs/types/schema/transactions.js +25 -0
  95. package/dist/mjs/types/schema/upload.js +5 -0
  96. package/dist/mjs/utils/bad-ports.js +6 -0
  97. package/dist/mjs/utils/bytes.js +6 -8
  98. package/dist/mjs/utils/error.js +5 -0
  99. package/dist/mjs/utils/headers.js +19 -13
  100. package/dist/mjs/utils/hex-schema.js +2 -0
  101. package/dist/mjs/utils/http.js +97 -59
  102. package/dist/mjs/utils/resource-locator.js +4 -3
  103. package/dist/mjs/utils/schema.js +81 -0
  104. package/dist/mjs/utils/stamps.js +2 -1
  105. package/dist/mjs/utils/type.js +13 -233
  106. package/dist/mjs/utils/url.js +23 -0
  107. package/dist/types/bee.d.ts +23 -0
  108. package/dist/types/modules/debug/connectivity.d.ts +2 -2
  109. package/dist/types/modules/debug/stamps.d.ts +2 -0
  110. package/dist/types/types/debug.d.ts +1 -0
  111. package/dist/types/types/schema/balance.d.ts +12 -0
  112. package/dist/types/types/schema/chequebook.d.ts +104 -0
  113. package/dist/types/types/schema/connectivity.d.ts +49 -0
  114. package/dist/types/types/schema/envelope.d.ts +7 -0
  115. package/dist/types/types/schema/grantee.d.ts +7 -0
  116. package/dist/types/types/schema/pinning.d.ts +4 -0
  117. package/dist/types/types/schema/rchash.d.ts +4 -0
  118. package/dist/types/types/schema/settlements.d.ts +16 -0
  119. package/dist/types/types/schema/stake.d.ts +29 -0
  120. package/dist/types/types/schema/stamps.d.ts +77 -0
  121. package/dist/types/types/schema/states.d.ts +26 -0
  122. package/dist/types/types/schema/status.d.ts +38 -0
  123. package/dist/types/types/schema/stewardship.d.ts +4 -0
  124. package/dist/types/types/schema/tag.d.ts +23 -0
  125. package/dist/types/types/schema/transactions.d.ts +29 -0
  126. package/dist/types/types/schema/upload.d.ts +5 -0
  127. package/dist/types/utils/bad-ports.d.ts +6 -0
  128. package/dist/types/utils/error.d.ts +5 -0
  129. package/dist/types/utils/hex-schema.d.ts +2 -0
  130. package/dist/types/utils/http.d.ts +18 -3
  131. package/dist/types/utils/schema.d.ts +90 -0
  132. package/dist/types/utils/stamps.d.ts +1 -0
  133. package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
  134. package/dist/types/utils/tar-uploader.d.ts +1 -1
  135. package/dist/types/utils/type.d.ts +1 -16
  136. package/dist/types/utils/url.d.ts +9 -0
  137. package/package.json +9 -9
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.postEnvelope = postEnvelope;
4
- const cafe_utility_1 = require("cafe-utility");
4
+ const envelope_1 = require("../types/schema/envelope");
5
5
  const http_1 = require("../utils/http");
6
6
  const ENVELOPE_ENDPOINT = 'envelope';
7
7
  async function postEnvelope(requestOptions, postageBatchId, reference) {
@@ -13,12 +13,12 @@ async function postEnvelope(requestOptions, postageBatchId, reference) {
13
13
  'swarm-postage-batch-id': postageBatchId.toHex(),
14
14
  },
15
15
  });
16
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
16
+ const body = envelope_1.PostEnvelopeBodyResponse.parse(response.data);
17
17
  return {
18
- issuer: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.issuer, { name: 'issuer', byteLength: 20 })),
19
- index: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.index, { name: 'index', byteLength: 8 })),
20
- timestamp: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.timestamp, { name: 'timestamp', byteLength: 8 })),
21
- signature: cafe_utility_1.Binary.hexToUint8Array(cafe_utility_1.Types.asHexString(body.signature, { name: 'signature', byteLength: 65 })),
18
+ issuer: body.issuer,
19
+ index: body.index,
20
+ timestamp: body.timestamp,
21
+ signature: body.signature,
22
22
  batchId: postageBatchId,
23
23
  };
24
24
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFeedManifest = createFeedManifest;
4
4
  exports.fetchLatestFeedUpdate = fetchLatestFeedUpdate;
5
5
  exports.probeFeed = probeFeed;
6
- const cafe_utility_1 = require("cafe-utility");
6
+ const upload_1 = require("../types/schema/upload");
7
7
  const bytes_1 = require("../utils/bytes");
8
8
  const error_1 = require("../utils/error");
9
9
  const headers_1 = require("../utils/headers");
@@ -26,8 +26,7 @@ async function createFeedManifest(requestOptions, owner, topic, stamp, options)
26
26
  url: `${feedEndpoint}/${owner}/${topic}`,
27
27
  headers: (0, headers_1.prepareRequestHeaders)(stamp, options),
28
28
  });
29
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
30
- return new typed_bytes_1.Reference(cafe_utility_1.Types.asHexString(body.reference));
29
+ return upload_1.UploadResultBody.parse(response.data).reference;
31
30
  }
32
31
  function readFeedUpdateHeaders(headers) {
33
32
  const feedIndex = headers['swarm-feed-index'];
@@ -60,7 +59,7 @@ async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
60
59
  const response = await (0, http_1.http)(requestOptions, {
61
60
  responseType: 'arraybuffer',
62
61
  url: `${feedEndpoint}/${owner}/${topic}`,
63
- params: options,
62
+ params: { ...options },
64
63
  });
65
64
  return {
66
65
  payload: new bytes_1.Bytes(response.data),
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGrantees = getGrantees;
4
4
  exports.createGrantees = createGrantees;
5
5
  exports.patchGrantees = patchGrantees;
6
- const cafe_utility_1 = require("cafe-utility");
6
+ const grantee_1 = require("../types/schema/grantee");
7
7
  const headers_1 = require("../utils/headers");
8
8
  const http_1 = require("../utils/http");
9
- const typed_bytes_1 = require("../utils/typed-bytes");
10
9
  const granteeEndpoint = 'grantee';
11
10
  async function getGrantees(reference, requestOptions) {
12
11
  const response = await (0, http_1.http)(requestOptions, {
@@ -14,11 +13,10 @@ async function getGrantees(reference, requestOptions) {
14
13
  url: `${granteeEndpoint}/${reference}`,
15
14
  responseType: 'json',
16
15
  });
17
- const body = cafe_utility_1.Types.asArray(response.data, { name: 'response.data' }).map(x => new typed_bytes_1.PublicKey(cafe_utility_1.Types.asString(x, { name: 'grantee' })));
18
16
  return {
19
17
  status: response.status,
20
18
  statusText: response.statusText,
21
- grantees: body,
19
+ grantees: grantee_1.GetGranteesBodyResponse.parse(response.data),
22
20
  };
23
21
  }
24
22
  async function createGrantees(requestOptions, postageBatchId, grantees) {
@@ -29,12 +27,12 @@ async function createGrantees(requestOptions, postageBatchId, grantees) {
29
27
  headers: (0, headers_1.prepareRequestHeaders)(postageBatchId),
30
28
  responseType: 'json',
31
29
  });
32
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
30
+ const body = grantee_1.GranteesResultBodyResponse.parse(response.data);
33
31
  return {
34
32
  status: response.status,
35
33
  statusText: response.statusText,
36
- ref: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.ref, { name: 'ref' })),
37
- historyref: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.historyref, { name: 'historyref' })),
34
+ ref: body.ref,
35
+ historyref: body.historyref,
38
36
  };
39
37
  }
40
38
  async function patchGrantees(postageBatchId, reference, historyRef, grantees, requestOptions) {
@@ -51,11 +49,11 @@ async function patchGrantees(postageBatchId, reference, historyRef, grantees, re
51
49
  },
52
50
  responseType: 'json',
53
51
  });
54
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
52
+ const body = grantee_1.GranteesResultBodyResponse.parse(response.data);
55
53
  return {
56
54
  status: response.status,
57
55
  statusText: response.statusText,
58
- ref: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.ref, { name: 'ref' })),
59
- historyref: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.historyref, { name: 'historyref' })),
56
+ ref: body.ref,
57
+ historyref: body.historyref,
60
58
  };
61
59
  }
@@ -4,7 +4,8 @@ exports.pin = pin;
4
4
  exports.unpin = unpin;
5
5
  exports.getPin = getPin;
6
6
  exports.getAllPins = getAllPins;
7
- const cafe_utility_1 = require("cafe-utility");
7
+ const pinning_1 = require("../types/schema/pinning");
8
+ const upload_1 = require("../types/schema/upload");
8
9
  const http_1 = require("../utils/http");
9
10
  const typed_bytes_1 = require("../utils/typed-bytes");
10
11
  const PINNING_ENDPOINT = 'pins';
@@ -47,10 +48,7 @@ async function getPin(requestOptions, reference) {
47
48
  responseType: 'json',
48
49
  url: `${PINNING_ENDPOINT}/${reference}`,
49
50
  });
50
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
51
- return {
52
- reference: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.reference, { name: 'reference' })),
53
- };
51
+ return upload_1.UploadResultBody.parse(response.data);
54
52
  }
55
53
  /**
56
54
  * Get list of all pins
@@ -63,11 +61,7 @@ async function getAllPins(requestOptions) {
63
61
  responseType: 'json',
64
62
  url: `${PINNING_ENDPOINT}`,
65
63
  });
66
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
67
64
  // TODO: https://github.com/ethersphere/bee/issues/4964
68
- if (body.references === null) {
69
- return [];
70
- }
71
- const references = cafe_utility_1.Types.asArray(body.references, { name: 'references' }).map(x => cafe_utility_1.Types.asString(x, { name: 'reference' }));
72
- return references.map(x => new typed_bytes_1.Reference(x));
65
+ const { references } = pinning_1.GetAllPinsResponse.parse(response.data);
66
+ return (references ?? []).map(x => new typed_bytes_1.Reference(x));
73
67
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rchash = rchash;
4
- const cafe_utility_1 = require("cafe-utility");
4
+ const rchash_1 = require("../types/schema/rchash");
5
5
  const http_1 = require("../utils/http");
6
6
  const RCHASH_ENDPOINT = 'rchash';
7
7
  async function rchash(requestOptions, depth, anchor1, anchor2) {
@@ -9,6 +9,5 @@ async function rchash(requestOptions, depth, anchor1, anchor2) {
9
9
  responseType: 'json',
10
10
  url: `${RCHASH_ENDPOINT}/${depth}/${anchor1}/${anchor2}`,
11
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' });
12
+ return rchash_1.RchashResponse.parse(response.data).durationSeconds;
14
13
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.upload = upload;
4
4
  const cafe_utility_1 = require("cafe-utility");
5
+ const upload_1 = require("../types/schema/upload");
5
6
  const headers_1 = require("../utils/headers");
6
7
  const http_1 = require("../utils/http");
7
8
  const type_1 = require("../utils/type");
@@ -30,9 +31,9 @@ async function upload(requestOptions, owner, identifier, signature, data, stamp,
30
31
  responseType: 'json',
31
32
  params: { sig: signature.toHex() },
32
33
  });
33
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
34
+ const body = upload_1.UploadResultBody.parse(response.data);
34
35
  return {
35
- reference: new typed_bytes_1.Reference(cafe_utility_1.Types.asHexString(body.reference)),
36
+ reference: body.reference,
36
37
  tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
37
38
  historyAddress: response.headers['swarm-act-history-address']
38
39
  ? cafe_utility_1.Optional.of(new typed_bytes_1.Reference(response.headers['swarm-act-history-address']))
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkConnection = checkConnection;
4
4
  exports.isGateway = isGateway;
5
- const cafe_utility_1 = require("cafe-utility");
5
+ const status_1 = require("../types/schema/status");
6
6
  const http_1 = require("../utils/http");
7
7
  /**
8
8
  * Ping the base bee URL. If connection was not successful throw error
@@ -12,6 +12,7 @@ const http_1 = require("../utils/http");
12
12
  async function checkConnection(requestOptions) {
13
13
  await (0, http_1.http)(requestOptions, {
14
14
  url: '',
15
+ responseType: 'text',
15
16
  });
16
17
  }
17
18
  async function isGateway(requestOptions) {
@@ -19,8 +20,7 @@ async function isGateway(requestOptions) {
19
20
  const response = await (0, http_1.http)(requestOptions, {
20
21
  url: '/gateway',
21
22
  });
22
- const data = cafe_utility_1.Types.asObject(response.data);
23
- return cafe_utility_1.Types.asBoolean(data.gateway);
23
+ return status_1.IsGatewayResponse.parse(response.data).gateway;
24
24
  }
25
25
  catch (error) {
26
26
  return false;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reupload = reupload;
4
4
  exports.isRetrievable = isRetrievable;
5
- const cafe_utility_1 = require("cafe-utility");
5
+ const stewardship_1 = require("../types/schema/stewardship");
6
6
  const http_1 = require("../utils/http");
7
7
  const typed_bytes_1 = require("../utils/typed-bytes");
8
8
  const stewardshipEndpoint = 'stewardship';
@@ -26,6 +26,5 @@ async function isRetrievable(requestOptions, reference) {
26
26
  responseType: 'json',
27
27
  url: `${stewardshipEndpoint}/${reference}`,
28
28
  });
29
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
30
- return cafe_utility_1.Types.asBoolean(body.isRetrievable, { name: 'isRetrievable' });
29
+ return stewardship_1.IsRetrievableResponse.parse(response.data).isRetrievable;
31
30
  }
@@ -5,7 +5,7 @@ exports.retrieveTag = retrieveTag;
5
5
  exports.getAllTags = getAllTags;
6
6
  exports.deleteTag = deleteTag;
7
7
  exports.updateTag = updateTag;
8
- const cafe_utility_1 = require("cafe-utility");
8
+ const tag_1 = require("../types/schema/tag");
9
9
  const http_1 = require("../utils/http");
10
10
  const endpoint = 'tags';
11
11
  /**
@@ -19,17 +19,7 @@ async function createTag(requestOptions) {
19
19
  url: endpoint,
20
20
  responseType: 'json',
21
21
  });
22
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
23
- return {
24
- address: cafe_utility_1.Types.asEmptiableString(body.address, { name: 'address' }),
25
- seen: cafe_utility_1.Types.asNumber(body.seen, { name: 'seen' }),
26
- sent: cafe_utility_1.Types.asNumber(body.sent, { name: 'sent' }),
27
- split: cafe_utility_1.Types.asNumber(body.split, { name: 'split' }),
28
- startedAt: cafe_utility_1.Types.asString(body.startedAt, { name: 'startedAt' }),
29
- stored: cafe_utility_1.Types.asNumber(body.stored, { name: 'stored' }),
30
- synced: cafe_utility_1.Types.asNumber(body.synced, { name: 'synced' }),
31
- uid: cafe_utility_1.Types.asNumber(body.uid, { name: 'uid' }),
32
- };
22
+ return tag_1.TagSchema.parse(response.data);
33
23
  }
34
24
  /**
35
25
  * Retrieve tag information from Bee node
@@ -42,17 +32,7 @@ async function retrieveTag(requestOptions, uid) {
42
32
  url: `${endpoint}/${uid}`,
43
33
  responseType: 'json',
44
34
  });
45
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
46
- return {
47
- address: cafe_utility_1.Types.asEmptiableString(body.address, { name: 'address' }),
48
- seen: cafe_utility_1.Types.asNumber(body.seen, { name: 'seen' }),
49
- sent: cafe_utility_1.Types.asNumber(body.sent, { name: 'sent' }),
50
- split: cafe_utility_1.Types.asNumber(body.split, { name: 'split' }),
51
- startedAt: cafe_utility_1.Types.asString(body.startedAt, { name: 'startedAt' }),
52
- stored: cafe_utility_1.Types.asNumber(body.stored, { name: 'stored' }),
53
- synced: cafe_utility_1.Types.asNumber(body.synced, { name: 'synced' }),
54
- uid: cafe_utility_1.Types.asNumber(body.uid, { name: 'uid' }),
55
- };
35
+ return tag_1.TagSchema.parse(response.data);
56
36
  }
57
37
  /**
58
38
  * Get limited listing of all tags.
@@ -67,18 +47,7 @@ async function getAllTags(requestOptions, offset, limit) {
67
47
  params: { offset, limit },
68
48
  responseType: 'json',
69
49
  });
70
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
71
- const tags = cafe_utility_1.Types.asArray(body.tags, { name: 'tags' }).map(x => cafe_utility_1.Types.asObject(x, { name: 'tag' }));
72
- return tags.map(x => ({
73
- address: cafe_utility_1.Types.asEmptiableString(x.address, { name: 'address' }),
74
- seen: cafe_utility_1.Types.asNumber(x.seen, { name: 'seen' }),
75
- sent: cafe_utility_1.Types.asNumber(x.sent, { name: 'sent' }),
76
- split: cafe_utility_1.Types.asNumber(x.split, { name: 'split' }),
77
- startedAt: cafe_utility_1.Types.asString(x.startedAt, { name: 'startedAt' }),
78
- stored: cafe_utility_1.Types.asNumber(x.stored, { name: 'stored' }),
79
- synced: cafe_utility_1.Types.asNumber(x.synced, { name: 'synced' }),
80
- uid: cafe_utility_1.Types.asNumber(x.uid, { name: 'uid' }),
81
- }));
50
+ return tag_1.GetAllTagsResponse.parse(response.data).tags;
82
51
  }
83
52
  /**
84
53
  * Removes tag from the Bee node.
@@ -26,7 +26,8 @@ class Stamper {
26
26
  }
27
27
  this.buckets[bucket]++;
28
28
  const index = cafe_utility_1.Binary.concatBytes(cafe_utility_1.Binary.numberToUint32(bucket, 'BE'), cafe_utility_1.Binary.numberToUint32(height, 'BE'));
29
- const timestamp = cafe_utility_1.Binary.numberToUint64(BigInt(Date.now()), 'BE');
29
+ const currentTimeNs = BigInt(Date.now()) * 1000000n; // Bee uses unix timestamp in nanoseconds
30
+ const timestamp = cafe_utility_1.Binary.numberToUint64(currentTimeNs, 'BE');
30
31
  const signature = this.signer.sign(cafe_utility_1.Binary.concatBytes(address, this.batchId.toUint8Array(), index, timestamp));
31
32
  return {
32
33
  batchId: this.batchId,
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetPeerBalanceResponse = exports.GetAllBalancesResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const tokens_1 = require("../../utils/tokens");
6
+ const type_1 = require("../../utils/type");
7
+ const PeerBalanceSchema = zod_1.z.object({
8
+ peer: zod_1.z.string(),
9
+ balance: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'balance' }))),
10
+ });
11
+ exports.GetAllBalancesResponse = zod_1.z.object({
12
+ balances: zod_1.z.array(PeerBalanceSchema),
13
+ });
14
+ exports.GetPeerBalanceResponse = PeerBalanceSchema;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionHashResponse = exports.GetLastChequesResponse = exports.GetLastChequesForPeerResponse = exports.GetLastCashoutActionResponse = exports.GetChequebookBalanceResponse = exports.GetChequebookAddressResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const tokens_1 = require("../../utils/tokens");
6
+ const type_1 = require("../../utils/type");
7
+ const typed_bytes_1 = require("../../utils/typed-bytes");
8
+ const ChequeSchema = zod_1.z.object({
9
+ beneficiary: zod_1.z.string().transform(s => new typed_bytes_1.EthAddress(s)),
10
+ chequebook: zod_1.z.string().transform(s => new typed_bytes_1.EthAddress(s)),
11
+ payout: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'payout' }))),
12
+ });
13
+ const CashoutResultSchema = zod_1.z.object({
14
+ recipient: zod_1.z.string(),
15
+ lastPayout: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'lastPayout' }))),
16
+ bounced: zod_1.z.boolean(),
17
+ });
18
+ exports.GetChequebookAddressResponse = zod_1.z.object({
19
+ chequebookAddress: zod_1.z.string().transform(s => new typed_bytes_1.EthAddress(s)),
20
+ });
21
+ exports.GetChequebookBalanceResponse = zod_1.z.object({
22
+ availableBalance: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'availableBalance' }))),
23
+ totalBalance: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'totalBalance' }))),
24
+ });
25
+ exports.GetLastCashoutActionResponse = zod_1.z.object({
26
+ peer: zod_1.z.string(),
27
+ uncashedAmount: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'uncashedAmount' }))),
28
+ transactionHash: zod_1.z
29
+ .string()
30
+ .nullish()
31
+ .transform(v => v ?? null),
32
+ lastCashedCheque: ChequeSchema.nullish().transform(v => v ?? null),
33
+ result: CashoutResultSchema.nullish().transform(v => v ?? null),
34
+ });
35
+ exports.GetLastChequesForPeerResponse = zod_1.z.object({
36
+ peer: zod_1.z.string(),
37
+ lastreceived: ChequeSchema.nullish().transform(v => v ?? null),
38
+ lastsent: ChequeSchema.nullish().transform(v => v ?? null),
39
+ });
40
+ exports.GetLastChequesResponse = zod_1.z.object({
41
+ lastcheques: zod_1.z.array(zod_1.z.object({
42
+ peer: zod_1.z.string(),
43
+ lastreceived: ChequeSchema.nullish().transform(v => v ?? null),
44
+ lastsent: ChequeSchema.nullish().transform(v => v ?? null),
45
+ })),
46
+ });
47
+ exports.TransactionHashResponse = zod_1.z.object({
48
+ transactionHash: zod_1.z.string().transform(s => new typed_bytes_1.TransactionId(s)),
49
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetTopologyResponse = exports.GetBlocklistResponse = exports.GetPeersResponse = exports.GetNodeAddressesResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const typed_bytes_1 = require("../../utils/typed-bytes");
6
+ const PeerSchema = zod_1.z.object({
7
+ address: zod_1.z.string(),
8
+ fullNode: zod_1.z.boolean(),
9
+ });
10
+ const BinSchema = zod_1.z.object({
11
+ population: zod_1.z.number(),
12
+ connected: zod_1.z.number(),
13
+ connectedPeers: zod_1.z
14
+ .array(zod_1.z.object({ address: zod_1.z.string() }))
15
+ .nullish()
16
+ .transform(v => v ?? []),
17
+ disconnectedPeers: zod_1.z
18
+ .array(zod_1.z.object({ address: zod_1.z.string() }))
19
+ .nullish()
20
+ .transform(v => v ?? []),
21
+ });
22
+ const BinRecord = zod_1.z.record(zod_1.z.string(), BinSchema);
23
+ exports.GetNodeAddressesResponse = zod_1.z.object({
24
+ overlay: zod_1.z.string().transform(s => new typed_bytes_1.PeerAddress(s)),
25
+ underlay: zod_1.z.array(zod_1.z.string()),
26
+ ethereum: zod_1.z.string().transform(s => new typed_bytes_1.EthAddress(s)),
27
+ publicKey: zod_1.z.string().transform(s => new typed_bytes_1.PublicKey(s)),
28
+ pssPublicKey: zod_1.z.string().transform(s => new typed_bytes_1.PublicKey(s)),
29
+ });
30
+ exports.GetPeersResponse = zod_1.z.object({
31
+ peers: zod_1.z.array(PeerSchema),
32
+ });
33
+ exports.GetBlocklistResponse = zod_1.z.object({
34
+ peers: zod_1.z.array(PeerSchema),
35
+ });
36
+ exports.GetTopologyResponse = zod_1.z.object({
37
+ baseAddr: zod_1.z.string(),
38
+ population: zod_1.z.number(),
39
+ connected: zod_1.z.number(),
40
+ timestamp: zod_1.z.string(),
41
+ nnLowWatermark: zod_1.z.number(),
42
+ depth: zod_1.z.number(),
43
+ reachability: zod_1.z.string(),
44
+ networkAvailability: zod_1.z.string(),
45
+ bins: BinRecord,
46
+ });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostEnvelopeBodyResponse = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
5
+ const zod_1 = require("zod");
6
+ exports.PostEnvelopeBodyResponse = zod_1.z.object({
7
+ issuer: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
8
+ index: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
9
+ timestamp: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
10
+ signature: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
11
+ });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GranteesResultBodyResponse = exports.GetGranteesBodyResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const typed_bytes_1 = require("../../utils/typed-bytes");
6
+ exports.GetGranteesBodyResponse = zod_1.z.array(zod_1.z.string().transform(s => new typed_bytes_1.PublicKey(s)));
7
+ exports.GranteesResultBodyResponse = zod_1.z.object({
8
+ ref: zod_1.z.string().transform(s => new typed_bytes_1.Reference(s)),
9
+ historyref: zod_1.z.string().transform(s => new typed_bytes_1.Reference(s)),
10
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAllPinsResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.GetAllPinsResponse = zod_1.z.object({
6
+ references: zod_1.z.array(zod_1.z.string()).nullable(),
7
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RchashResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.RchashResponse = zod_1.z.object({
6
+ durationSeconds: zod_1.z.number(),
7
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAllSettlementsResponse = exports.GetSettlementsResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const tokens_1 = require("../../utils/tokens");
6
+ const type_1 = require("../../utils/type");
7
+ const SettlementSchema = zod_1.z.object({
8
+ peer: zod_1.z.string(),
9
+ sent: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'sent' }))),
10
+ received: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'received' }))),
11
+ });
12
+ exports.GetSettlementsResponse = SettlementSchema;
13
+ exports.GetAllSettlementsResponse = zod_1.z.object({
14
+ totalSent: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'totalSent' }))),
15
+ totalReceived: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'totalReceived' }))),
16
+ settlements: zod_1.z.array(SettlementSchema),
17
+ });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetRedistributionStateResponse = exports.TxHashResponse = exports.GetWithdrawableStakeResponse = exports.GetStakeResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const tokens_1 = require("../../utils/tokens");
6
+ const type_1 = require("../../utils/type");
7
+ const typed_bytes_1 = require("../../utils/typed-bytes");
8
+ exports.GetStakeResponse = zod_1.z.object({
9
+ stakedAmount: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'stakedAmount' }))),
10
+ });
11
+ exports.GetWithdrawableStakeResponse = zod_1.z.object({
12
+ withdrawableAmount: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'withdrawableAmount' }))),
13
+ });
14
+ exports.TxHashResponse = zod_1.z.object({
15
+ txHash: zod_1.z.string().transform(s => new typed_bytes_1.TransactionId(s)),
16
+ });
17
+ exports.GetRedistributionStateResponse = zod_1.z.object({
18
+ minimumGasFunds: zod_1.z.string().transform(s => tokens_1.DAI.fromWei((0, type_1.asNumberString)(s, { name: 'minimumGasFunds' }))),
19
+ hasSufficientFunds: zod_1.z.boolean(),
20
+ isFrozen: zod_1.z.boolean(),
21
+ isFullySynced: zod_1.z.boolean(),
22
+ phase: zod_1.z.string(),
23
+ round: zod_1.z.number(),
24
+ lastWonRound: zod_1.z.number(),
25
+ lastPlayedRound: zod_1.z.number(),
26
+ lastFrozenRound: zod_1.z.number(),
27
+ lastSelectedRound: zod_1.z.number(),
28
+ lastSampleDurationSeconds: zod_1.z.number(),
29
+ block: zod_1.z.number(),
30
+ reward: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'reward' }))),
31
+ fees: zod_1.z.string().transform(s => tokens_1.DAI.fromWei((0, type_1.asNumberString)(s, { name: 'fees' }))),
32
+ isHealthy: zod_1.z.boolean(),
33
+ });
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatchIdResponse = exports.GetPostageBatchBucketsResponse = exports.GetPostageBatchResponse = exports.GetAllPostageBatchesResponse = exports.GetGlobalPostageBatchesResponse = exports.GetGlobalPostageBatchResponse = exports.RawPostageBatchSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const type_1 = require("../../utils/type");
6
+ const typed_bytes_1 = require("../../utils/typed-bytes");
7
+ exports.RawPostageBatchSchema = zod_1.z.object({
8
+ batchID: zod_1.z.string(),
9
+ utilization: zod_1.z.number(),
10
+ utilizationRatio: zod_1.z.number().optional(),
11
+ usable: zod_1.z.boolean(),
12
+ label: zod_1.z.string(),
13
+ depth: zod_1.z.number(),
14
+ amount: zod_1.z.string(),
15
+ bucketDepth: zod_1.z.number(),
16
+ blockNumber: zod_1.z.number(),
17
+ immutableFlag: zod_1.z.boolean(),
18
+ batchTTL: zod_1.z.number(),
19
+ });
20
+ exports.GetGlobalPostageBatchResponse = zod_1.z.object({
21
+ batchID: zod_1.z.string().transform(s => new typed_bytes_1.BatchId(s)),
22
+ batchTTL: zod_1.z.number(),
23
+ bucketDepth: zod_1.z.number(),
24
+ depth: zod_1.z.number(),
25
+ immutable: zod_1.z.boolean(),
26
+ owner: zod_1.z.string().transform(s => new typed_bytes_1.EthAddress(s)),
27
+ start: zod_1.z.number(),
28
+ value: zod_1.z.string().transform(s => (0, type_1.asNumberString)(s, { name: 'value' })),
29
+ });
30
+ exports.GetGlobalPostageBatchesResponse = zod_1.z.object({
31
+ batches: zod_1.z.array(exports.GetGlobalPostageBatchResponse),
32
+ });
33
+ exports.GetAllPostageBatchesResponse = zod_1.z.object({
34
+ stamps: zod_1.z.array(exports.RawPostageBatchSchema),
35
+ });
36
+ exports.GetPostageBatchResponse = exports.RawPostageBatchSchema;
37
+ exports.GetPostageBatchBucketsResponse = zod_1.z.object({
38
+ depth: zod_1.z.number(),
39
+ bucketDepth: zod_1.z.number(),
40
+ bucketUpperBound: zod_1.z.number(),
41
+ buckets: zod_1.z.array(zod_1.z.object({
42
+ bucketID: zod_1.z.number(),
43
+ collisions: zod_1.z.number(),
44
+ })),
45
+ });
46
+ exports.BatchIdResponse = zod_1.z.object({
47
+ batchID: zod_1.z.string().transform(s => new typed_bytes_1.BatchId(s)),
48
+ });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WithdrawResponse = exports.GetWalletBalanceResponse = exports.GetChainStateResponse = exports.GetReserveStateResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const tokens_1 = require("../../utils/tokens");
6
+ const type_1 = require("../../utils/type");
7
+ const typed_bytes_1 = require("../../utils/typed-bytes");
8
+ const workaround_1 = require("../../utils/workaround");
9
+ exports.GetReserveStateResponse = zod_1.z.object({
10
+ commitment: zod_1.z.number(),
11
+ radius: zod_1.z.number(),
12
+ storageRadius: zod_1.z.number(),
13
+ reserveCapacityDoubling: zod_1.z.number(),
14
+ });
15
+ exports.GetChainStateResponse = zod_1.z.object({
16
+ block: zod_1.z.number(),
17
+ chainTip: zod_1.z.number(),
18
+ totalAmount: zod_1.z.string().transform(s => (0, type_1.asNumberString)(s, { name: 'totalAmount' })),
19
+ currentPrice: zod_1.z
20
+ .string()
21
+ .transform(Number)
22
+ .transform(s => (0, workaround_1.normalizeCurrentPrice)(s)),
23
+ minimumValidityBlocks: zod_1.z.number().optional(),
24
+ });
25
+ exports.GetWalletBalanceResponse = zod_1.z.object({
26
+ bzzBalance: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'bzzBalance' }))),
27
+ nativeTokenBalance: zod_1.z.string().transform(s => tokens_1.DAI.fromWei((0, type_1.asNumberString)(s, { name: 'nativeTokenBalance' }))),
28
+ chainID: zod_1.z.number(),
29
+ chequebookContractAddress: zod_1.z.string(),
30
+ walletAddress: zod_1.z.string(),
31
+ });
32
+ exports.WithdrawResponse = zod_1.z.object({
33
+ transactionHash: zod_1.z.string().transform(s => new typed_bytes_1.TransactionId(s)),
34
+ });
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsGatewayResponse = exports.GetNodeInfoResponse = exports.GetReadinessResponse = exports.GetHealthResponse = exports.GetDebugStatusResponse = void 0;
4
+ const zod_1 = require("zod");
5
+ const debug_1 = require("../debug");
6
+ exports.GetDebugStatusResponse = zod_1.z.object({
7
+ overlay: zod_1.z.string(),
8
+ proximity: zod_1.z.number(),
9
+ beeMode: zod_1.z.string().transform(debug_1.toBeeMode),
10
+ reserveSize: zod_1.z.number(),
11
+ reserveSizeWithinRadius: zod_1.z.number(),
12
+ pullsyncRate: zod_1.z.number(),
13
+ storageRadius: zod_1.z.number(),
14
+ connectedPeers: zod_1.z.number(),
15
+ neighborhoodSize: zod_1.z.number(),
16
+ batchCommitment: zod_1.z.number(),
17
+ isReachable: zod_1.z.boolean(),
18
+ lastSyncedBlock: zod_1.z.number(),
19
+ committedDepth: zod_1.z.number(),
20
+ isWarmingUp: zod_1.z.boolean(),
21
+ });
22
+ exports.GetHealthResponse = zod_1.z.object({
23
+ apiVersion: zod_1.z.string(),
24
+ version: zod_1.z.string(),
25
+ status: zod_1.z.literal('ok'),
26
+ });
27
+ exports.GetReadinessResponse = zod_1.z.object({
28
+ apiVersion: zod_1.z.string(),
29
+ version: zod_1.z.string(),
30
+ status: zod_1.z.enum(['ready', 'notReady']),
31
+ });
32
+ exports.GetNodeInfoResponse = zod_1.z.object({
33
+ beeMode: zod_1.z.string().transform(debug_1.toBeeMode),
34
+ chequebookEnabled: zod_1.z.boolean(),
35
+ swapEnabled: zod_1.z.boolean(),
36
+ });
37
+ exports.IsGatewayResponse = zod_1.z.object({
38
+ gateway: zod_1.z.boolean(),
39
+ });