@ethersphere/bee-js 5.1.1 → 5.1.2

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 (151) hide show
  1. package/README.md +14 -6
  2. package/dist/223.index.browser.min.js +3 -0
  3. package/dist/223.index.browser.min.js.LICENSE.txt +1 -0
  4. package/dist/223.index.browser.min.js.map +1 -0
  5. package/dist/cjs/bee-debug.js +208 -312
  6. package/dist/cjs/bee.js +258 -353
  7. package/dist/cjs/chunk/signer.js +11 -22
  8. package/dist/cjs/chunk/soc.js +33 -50
  9. package/dist/cjs/chunk/span.js +1 -1
  10. package/dist/cjs/feed/index.js +50 -65
  11. package/dist/cjs/feed/json.js +8 -21
  12. package/dist/cjs/feed/retrievable.js +14 -27
  13. package/dist/cjs/modules/bytes.js +25 -37
  14. package/dist/cjs/modules/bzz.js +63 -68
  15. package/dist/cjs/modules/chunk.js +17 -27
  16. package/dist/cjs/modules/debug/balance.js +24 -41
  17. package/dist/cjs/modules/debug/chequebook.js +71 -96
  18. package/dist/cjs/modules/debug/chunk.js +13 -26
  19. package/dist/cjs/modules/debug/connectivity.js +32 -53
  20. package/dist/cjs/modules/debug/settlements.js +12 -25
  21. package/dist/cjs/modules/debug/stake.js +20 -33
  22. package/dist/cjs/modules/debug/stamps.js +45 -66
  23. package/dist/cjs/modules/debug/states.js +27 -40
  24. package/dist/cjs/modules/debug/status.js +53 -80
  25. package/dist/cjs/modules/debug/tag.js +6 -17
  26. package/dist/cjs/modules/debug/transactions.js +23 -40
  27. package/dist/cjs/modules/feed.js +17 -27
  28. package/dist/cjs/modules/pinning.js +24 -41
  29. package/dist/cjs/modules/pss.js +9 -20
  30. package/dist/cjs/modules/soc.js +12 -20
  31. package/dist/cjs/modules/status.js +4 -15
  32. package/dist/cjs/modules/stewardship.js +10 -23
  33. package/dist/cjs/modules/tag.js +28 -47
  34. package/dist/cjs/utils/collection.browser.js +4 -17
  35. package/dist/cjs/utils/collection.js +11 -22
  36. package/dist/cjs/utils/collection.node.js +42 -86
  37. package/dist/cjs/utils/data.browser.js +46 -59
  38. package/dist/cjs/utils/data.js +22 -35
  39. package/dist/cjs/utils/eth.js +31 -43
  40. package/dist/cjs/utils/file.js +9 -20
  41. package/dist/cjs/utils/headers.js +4 -4
  42. package/dist/cjs/utils/http.js +78 -93
  43. package/dist/cjs/utils/merge.js +1 -1
  44. package/dist/cjs/utils/sleep.js +2 -13
  45. package/dist/cjs/utils/type.js +14 -12
  46. package/dist/index.browser.min.js +1 -1
  47. package/dist/index.browser.min.js.LICENSE.txt +1 -3
  48. package/dist/index.browser.min.js.map +1 -1
  49. package/dist/mjs/bee-debug.js +209 -450
  50. package/dist/mjs/bee.js +256 -491
  51. package/dist/mjs/chunk/bmt.js +4 -10
  52. package/dist/mjs/chunk/cac.js +0 -3
  53. package/dist/mjs/chunk/signer.js +12 -63
  54. package/dist/mjs/chunk/soc.js +33 -85
  55. package/dist/mjs/chunk/span.js +3 -6
  56. package/dist/mjs/feed/identifier.js +0 -6
  57. package/dist/mjs/feed/index.js +53 -97
  58. package/dist/mjs/feed/json.js +10 -49
  59. package/dist/mjs/feed/retrievable.js +13 -64
  60. package/dist/mjs/feed/topic.js +0 -2
  61. package/dist/mjs/index.js +1 -2
  62. package/dist/mjs/modules/bytes.js +25 -65
  63. package/dist/mjs/modules/bzz.js +64 -108
  64. package/dist/mjs/modules/chunk.js +17 -54
  65. package/dist/mjs/modules/debug/balance.js +24 -68
  66. package/dist/mjs/modules/debug/chequebook.js +75 -138
  67. package/dist/mjs/modules/debug/chunk.js +13 -51
  68. package/dist/mjs/modules/debug/connectivity.js +32 -76
  69. package/dist/mjs/modules/debug/settlements.js +12 -50
  70. package/dist/mjs/modules/debug/stake.js +20 -61
  71. package/dist/mjs/modules/debug/stamps.js +47 -94
  72. package/dist/mjs/modules/debug/states.js +25 -66
  73. package/dist/mjs/modules/debug/status.js +66 -125
  74. package/dist/mjs/modules/debug/tag.js +6 -41
  75. package/dist/mjs/modules/debug/transactions.js +25 -69
  76. package/dist/mjs/modules/feed.js +17 -57
  77. package/dist/mjs/modules/pinning.js +24 -68
  78. package/dist/mjs/modules/pss.js +11 -47
  79. package/dist/mjs/modules/soc.js +14 -48
  80. package/dist/mjs/modules/status.js +4 -39
  81. package/dist/mjs/modules/stewardship.js +10 -47
  82. package/dist/mjs/modules/tag.js +31 -78
  83. package/dist/mjs/types/debug.js +0 -1
  84. package/dist/mjs/types/index.js +0 -4
  85. package/dist/mjs/utils/bytes.js +6 -14
  86. package/dist/mjs/utils/collection.browser.js +4 -42
  87. package/dist/mjs/utils/collection.js +11 -57
  88. package/dist/mjs/utils/collection.node.js +42 -150
  89. package/dist/mjs/utils/data.browser.js +49 -94
  90. package/dist/mjs/utils/data.js +19 -62
  91. package/dist/mjs/utils/error.js +0 -5
  92. package/dist/mjs/utils/eth.js +37 -95
  93. package/dist/mjs/utils/file.js +11 -50
  94. package/dist/mjs/utils/hash.js +0 -1
  95. package/dist/mjs/utils/headers.js +6 -14
  96. package/dist/mjs/utils/hex.js +6 -25
  97. package/dist/mjs/utils/http.js +80 -138
  98. package/dist/mjs/utils/merge.js +3 -7
  99. package/dist/mjs/utils/pss.js +0 -2
  100. package/dist/mjs/utils/reference.js +2 -5
  101. package/dist/mjs/utils/sleep.js +2 -37
  102. package/dist/mjs/utils/stream.js +0 -23
  103. package/dist/mjs/utils/tar.js +2 -5
  104. package/dist/mjs/utils/type.js +18 -82
  105. package/dist/mjs/utils/uint64.js +0 -1
  106. package/dist/mjs/utils/url.js +2 -10
  107. package/dist/types/bee-debug.d.ts +2 -2
  108. package/dist/types/bee.d.ts +2 -26
  109. package/dist/types/chunk/cac.d.ts +1 -1
  110. package/dist/types/chunk/soc.d.ts +8 -7
  111. package/dist/types/feed/index.d.ts +9 -8
  112. package/dist/types/feed/type.d.ts +1 -1
  113. package/dist/types/modules/bytes.d.ts +6 -5
  114. package/dist/types/modules/bzz.d.ts +9 -8
  115. package/dist/types/modules/chunk.d.ts +5 -4
  116. package/dist/types/modules/debug/balance.d.ts +10 -9
  117. package/dist/types/modules/debug/chequebook.d.ts +18 -17
  118. package/dist/types/modules/debug/chunk.d.ts +6 -5
  119. package/dist/types/modules/debug/connectivity.d.ts +8 -7
  120. package/dist/types/modules/debug/settlements.d.ts +6 -5
  121. package/dist/types/modules/debug/stake.d.ts +5 -4
  122. package/dist/types/modules/debug/stamps.d.ts +8 -7
  123. package/dist/types/modules/debug/states.d.ts +8 -7
  124. package/dist/types/modules/debug/status.d.ts +15 -15
  125. package/dist/types/modules/debug/tag.d.ts +4 -3
  126. package/dist/types/modules/debug/transactions.d.ts +6 -5
  127. package/dist/types/modules/feed.d.ts +4 -3
  128. package/dist/types/modules/pinning.d.ts +8 -7
  129. package/dist/types/modules/pss.d.ts +4 -3
  130. package/dist/types/modules/soc.d.ts +3 -2
  131. package/dist/types/modules/status.d.ts +3 -3
  132. package/dist/types/modules/stewardship.d.ts +4 -3
  133. package/dist/types/modules/tag.d.ts +7 -6
  134. package/dist/types/types/debug.d.ts +1 -1
  135. package/dist/types/types/index.d.ts +30 -34
  136. package/dist/types/utils/eth.d.ts +3 -3
  137. package/dist/types/utils/hex.d.ts +2 -2
  138. package/dist/types/utils/http.d.ts +6 -6
  139. package/package.json +34 -39
  140. package/dist/cjs/types/ky-options.js +0 -8
  141. package/dist/cjs/types/ky-universal/common.js +0 -8
  142. package/dist/cjs/types/ky-universal/hooks.js +0 -8
  143. package/dist/cjs/types/ky-universal/retry.js +0 -8
  144. package/dist/mjs/types/ky-options.js +0 -7
  145. package/dist/mjs/types/ky-universal/common.js +0 -7
  146. package/dist/mjs/types/ky-universal/hooks.js +0 -7
  147. package/dist/mjs/types/ky-universal/retry.js +0 -7
  148. package/dist/types/types/ky-options.d.ts +0 -221
  149. package/dist/types/types/ky-universal/common.d.ts +0 -13
  150. package/dist/types/types/ky-universal/hooks.d.ts +0 -92
  151. package/dist/types/types/ky-universal/retry.d.ts +0 -38
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.deleteChunkFromLocalStorage = exports.checkIfChunkExistsLocally = void 0;
13
4
  const http_1 = require("../../utils/http");
@@ -15,37 +6,33 @@ const endpoint = 'chunks';
15
6
  /**
16
7
  * Check if chunk at address exists locally
17
8
  *
18
- * @param ky Ky debug instance
9
+ * @param kyOptions Ky Options for making requests
19
10
  * @param address Swarm address of chunk
20
11
  *
21
12
  * @returns BeeGenericResponse if chunk is found or throws an exception
22
13
  */
23
- function checkIfChunkExistsLocally(ky, address) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const response = yield (0, http_1.http)(ky, {
26
- path: endpoint + `/${address}`,
27
- responseType: 'json',
28
- });
29
- return response.data;
14
+ async function checkIfChunkExistsLocally(kyOptions, address) {
15
+ const response = await (0, http_1.http)(kyOptions, {
16
+ path: endpoint + `/${address}`,
17
+ responseType: 'json',
30
18
  });
19
+ return response.parsedData;
31
20
  }
32
21
  exports.checkIfChunkExistsLocally = checkIfChunkExistsLocally;
33
22
  /**
34
23
  * Delete a chunk from local storage
35
24
  *
36
- * @param ky Ky debug instance
25
+ * @param kyOptions Ky Options for making requests
37
26
  * @param address Swarm address of chunk
38
27
  *
39
28
  * @returns BeeGenericResponse if chunk was deleted or throws an exception
40
29
  */
41
- function deleteChunkFromLocalStorage(ky, address) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const response = yield (0, http_1.http)(ky, {
44
- method: 'delete',
45
- path: endpoint + `/${address}`,
46
- responseType: 'json',
47
- });
48
- return response.data;
30
+ async function deleteChunkFromLocalStorage(kyOptions, address) {
31
+ const response = await (0, http_1.http)(kyOptions, {
32
+ method: 'delete',
33
+ path: endpoint + `/${address}`,
34
+ responseType: 'json',
49
35
  });
36
+ return response.parsedData;
50
37
  }
51
38
  exports.deleteChunkFromLocalStorage = deleteChunkFromLocalStorage;
@@ -1,75 +1,54 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.pingPeer = exports.getTopology = exports.removePeer = exports.getBlocklist = exports.getPeers = exports.getNodeAddresses = void 0;
13
4
  const http_1 = require("../../utils/http");
14
- function getNodeAddresses(ky) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const response = yield (0, http_1.http)(ky, {
17
- path: 'addresses',
18
- responseType: 'json',
19
- });
20
- return response.data;
5
+ async function getNodeAddresses(kyOptions) {
6
+ const response = await (0, http_1.http)(kyOptions, {
7
+ path: 'addresses',
8
+ responseType: 'json',
21
9
  });
10
+ return response.parsedData;
22
11
  }
23
12
  exports.getNodeAddresses = getNodeAddresses;
24
- function getPeers(ky) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const response = yield (0, http_1.http)(ky, {
27
- path: 'peers',
28
- responseType: 'json',
29
- });
30
- return response.data.peers;
13
+ async function getPeers(kyOptions) {
14
+ const response = await (0, http_1.http)(kyOptions, {
15
+ path: 'peers',
16
+ responseType: 'json',
31
17
  });
18
+ return response.parsedData.peers;
32
19
  }
33
20
  exports.getPeers = getPeers;
34
- function getBlocklist(ky) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const response = yield (0, http_1.http)(ky, {
37
- path: 'blocklist',
38
- responseType: 'json',
39
- });
40
- return response.data.peers;
21
+ async function getBlocklist(kyOptions) {
22
+ const response = await (0, http_1.http)(kyOptions, {
23
+ path: 'blocklist',
24
+ responseType: 'json',
41
25
  });
26
+ return response.parsedData.peers;
42
27
  }
43
28
  exports.getBlocklist = getBlocklist;
44
- function removePeer(ky, peer) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const response = yield (0, http_1.http)(ky, {
47
- path: `peers/${peer}`,
48
- responseType: 'json',
49
- method: 'DELETE',
50
- });
51
- return response.data;
29
+ async function removePeer(kyOptions, peer) {
30
+ const response = await (0, http_1.http)(kyOptions, {
31
+ path: `peers/${peer}`,
32
+ responseType: 'json',
33
+ method: 'DELETE',
52
34
  });
35
+ return response.parsedData;
53
36
  }
54
37
  exports.removePeer = removePeer;
55
- function getTopology(ky) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const response = yield (0, http_1.http)(ky, {
58
- path: `topology`,
59
- responseType: 'json',
60
- });
61
- return response.data;
38
+ async function getTopology(kyOptions) {
39
+ const response = await (0, http_1.http)(kyOptions, {
40
+ path: `topology`,
41
+ responseType: 'json',
62
42
  });
43
+ return response.parsedData;
63
44
  }
64
45
  exports.getTopology = getTopology;
65
- function pingPeer(ky, peer) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const response = yield (0, http_1.http)(ky, {
68
- path: `pingpong/${peer}`,
69
- responseType: 'json',
70
- method: 'POST',
71
- });
72
- return response.data;
46
+ async function pingPeer(kyOptions, peer) {
47
+ const response = await (0, http_1.http)(kyOptions, {
48
+ path: `pingpong/${peer}`,
49
+ responseType: 'json',
50
+ method: 'POST',
73
51
  });
52
+ return response.parsedData;
74
53
  }
75
54
  exports.pingPeer = pingPeer;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getAllSettlements = exports.getSettlements = void 0;
13
4
  const http_1 = require("../../utils/http");
@@ -15,31 +6,27 @@ const settlementsEndpoint = 'settlements';
15
6
  /**
16
7
  * Get amount of sent and received from settlements with a peer
17
8
  *
18
- * @param ky Ky debug instance
9
+ * @param kyOptions Ky Options for making requests
19
10
  * @param peer Swarm address of peer
20
11
  */
21
- function getSettlements(ky, peer) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const response = yield (0, http_1.http)(ky, {
24
- path: `${settlementsEndpoint}/${peer}`,
25
- responseType: 'json',
26
- });
27
- return response.data;
12
+ async function getSettlements(kyOptions, peer) {
13
+ const response = await (0, http_1.http)(kyOptions, {
14
+ path: `${settlementsEndpoint}/${peer}`,
15
+ responseType: 'json',
28
16
  });
17
+ return response.parsedData;
29
18
  }
30
19
  exports.getSettlements = getSettlements;
31
20
  /**
32
21
  * Get settlements with all known peers and total amount sent or received
33
22
  *
34
- * @param ky Ky debug instance
23
+ * @param kyOptions Ky Options for making requests
35
24
  */
36
- function getAllSettlements(ky) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const response = yield (0, http_1.http)(ky, {
39
- path: settlementsEndpoint,
40
- responseType: 'json',
41
- });
42
- return response.data;
25
+ async function getAllSettlements(kyOptions) {
26
+ const response = await (0, http_1.http)(kyOptions, {
27
+ path: settlementsEndpoint,
28
+ responseType: 'json',
43
29
  });
30
+ return response.parsedData;
44
31
  }
45
32
  exports.getAllSettlements = getAllSettlements;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.stake = exports.getStake = void 0;
13
4
  const http_1 = require("../../utils/http");
@@ -15,17 +6,15 @@ const STAKE_ENDPOINT = 'stake';
15
6
  /**
16
7
  * Gets the staked amount
17
8
  *
18
- * @param ky Ky instance for given Bee class instance
9
+ * @param kyOptions Ky Options for making requests
19
10
  */
20
- function getStake(ky) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const response = yield (0, http_1.http)(ky, {
23
- method: 'get',
24
- responseType: 'json',
25
- path: `${STAKE_ENDPOINT}`,
26
- });
27
- return response.data.stakedAmount.toString();
11
+ async function getStake(kyOptions) {
12
+ const response = await (0, http_1.http)(kyOptions, {
13
+ method: 'get',
14
+ responseType: 'json',
15
+ path: `${STAKE_ENDPOINT}`,
28
16
  });
17
+ return response.parsedData.stakedAmount.toString();
29
18
  }
30
19
  exports.getStake = getStake;
31
20
  /**
@@ -35,21 +24,19 @@ exports.getStake = getStake;
35
24
  * @param amount
36
25
  * @param options
37
26
  */
38
- function stake(ky, amount, options) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const headers = {};
41
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
42
- headers['gas-price'] = options.gasPrice.toString();
43
- }
44
- if (options === null || options === void 0 ? void 0 : options.gasLimit) {
45
- headers['gas-limit'] = options.gasLimit.toString();
46
- }
47
- yield (0, http_1.http)(ky, {
48
- method: 'post',
49
- responseType: 'json',
50
- path: `${STAKE_ENDPOINT}/${amount}`,
51
- headers,
52
- });
27
+ async function stake(kyOptions, amount, options) {
28
+ const headers = {};
29
+ if (options?.gasPrice) {
30
+ headers['gas-price'] = options.gasPrice.toString();
31
+ }
32
+ if (options?.gasLimit) {
33
+ headers['gas-limit'] = options.gasLimit.toString();
34
+ }
35
+ await (0, http_1.http)(kyOptions, {
36
+ method: 'post',
37
+ responseType: 'json',
38
+ path: `${STAKE_ENDPOINT}/${amount}`,
39
+ headers,
53
40
  });
54
41
  }
55
42
  exports.stake = stake;
@@ -1,89 +1,68 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.diluteBatch = exports.topUpBatch = exports.createPostageBatch = exports.getPostageBatchBuckets = exports.getPostageBatch = exports.getAllPostageBatches = void 0;
13
4
  const http_1 = require("../../utils/http");
14
5
  const STAMPS_ENDPOINT = 'stamps';
15
- function getAllPostageBatches(ky) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const response = yield (0, http_1.http)(ky, {
18
- method: 'get',
19
- path: `${STAMPS_ENDPOINT}`,
20
- responseType: 'json',
21
- });
22
- return response.data.stamps;
6
+ async function getAllPostageBatches(kyOptions) {
7
+ const response = await (0, http_1.http)(kyOptions, {
8
+ method: 'get',
9
+ path: `${STAMPS_ENDPOINT}`,
10
+ responseType: 'json',
23
11
  });
12
+ return response.parsedData.stamps;
24
13
  }
25
14
  exports.getAllPostageBatches = getAllPostageBatches;
26
- function getPostageBatch(ky, postageBatchId) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const response = yield (0, http_1.http)(ky, {
29
- method: 'get',
30
- path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
31
- responseType: 'json',
32
- });
33
- return response.data;
15
+ async function getPostageBatch(kyOptions, postageBatchId) {
16
+ const response = await (0, http_1.http)(kyOptions, {
17
+ method: 'get',
18
+ path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
19
+ responseType: 'json',
34
20
  });
21
+ return response.parsedData;
35
22
  }
36
23
  exports.getPostageBatch = getPostageBatch;
37
- function getPostageBatchBuckets(ky, postageBatchId) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const response = yield (0, http_1.http)(ky, {
40
- method: 'get',
41
- path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
42
- responseType: 'json',
43
- });
44
- return response.data;
24
+ async function getPostageBatchBuckets(kyOptions, postageBatchId) {
25
+ const response = await (0, http_1.http)(kyOptions, {
26
+ method: 'get',
27
+ path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
28
+ responseType: 'json',
45
29
  });
30
+ return response.parsedData;
46
31
  }
47
32
  exports.getPostageBatchBuckets = getPostageBatchBuckets;
48
- function createPostageBatch(ky, amount, depth, options) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const headers = {};
51
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
52
- headers['gas-price'] = options.gasPrice.toString();
53
- }
54
- if ((options === null || options === void 0 ? void 0 : options.immutableFlag) !== undefined) {
55
- headers.immutable = String(options.immutableFlag);
56
- }
57
- const response = yield (0, http_1.http)(ky, {
58
- method: 'post',
59
- path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
60
- responseType: 'json',
61
- searchParams: { label: options === null || options === void 0 ? void 0 : options.label },
62
- headers,
63
- });
64
- return response.data.batchID;
33
+ async function createPostageBatch(kyOptions, amount, depth, options) {
34
+ const headers = {};
35
+ if (options?.gasPrice) {
36
+ headers['gas-price'] = options.gasPrice.toString();
37
+ }
38
+ if (options?.immutableFlag !== undefined) {
39
+ headers.immutable = String(options.immutableFlag);
40
+ }
41
+ const response = await (0, http_1.http)(kyOptions, {
42
+ method: 'post',
43
+ path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
44
+ responseType: 'json',
45
+ searchParams: { label: options?.label },
46
+ headers,
65
47
  });
48
+ return response.parsedData.batchID;
66
49
  }
67
50
  exports.createPostageBatch = createPostageBatch;
68
- function topUpBatch(ky, id, amount) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const response = yield (0, http_1.http)(ky, {
71
- method: 'patch',
72
- path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
73
- responseType: 'json',
74
- });
75
- return response.data.batchID;
51
+ async function topUpBatch(kyOptions, id, amount) {
52
+ const response = await (0, http_1.http)(kyOptions, {
53
+ method: 'patch',
54
+ path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
55
+ responseType: 'json',
76
56
  });
57
+ return response.parsedData.batchID;
77
58
  }
78
59
  exports.topUpBatch = topUpBatch;
79
- function diluteBatch(ky, id, depth) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const response = yield (0, http_1.http)(ky, {
82
- method: 'patch',
83
- path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
84
- responseType: 'json',
85
- });
86
- return response.data.batchID;
60
+ async function diluteBatch(kyOptions, id, depth) {
61
+ const response = await (0, http_1.http)(kyOptions, {
62
+ method: 'patch',
63
+ path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
64
+ responseType: 'json',
87
65
  });
66
+ return response.parsedData.batchID;
88
67
  }
89
68
  exports.diluteBatch = diluteBatch;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getWalletBalance = exports.getChainState = exports.getReserveState = void 0;
13
4
  const http_1 = require("../../utils/http");
@@ -17,49 +8,43 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
17
8
  /**
18
9
  * Get state of reserve
19
10
  *
20
- * @param ky Ky debug instance
11
+ * @param kyOptions Ky Options for making requests
21
12
  */
22
- function getReserveState(ky) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const response = yield (0, http_1.http)(ky, {
25
- method: 'get',
26
- path: `${RESERVE_STATE_ENDPOINT}`,
27
- responseType: 'json',
28
- });
29
- return response.data;
13
+ async function getReserveState(kyOptions) {
14
+ const response = await (0, http_1.http)(kyOptions, {
15
+ method: 'get',
16
+ path: `${RESERVE_STATE_ENDPOINT}`,
17
+ responseType: 'json',
30
18
  });
19
+ return response.parsedData;
31
20
  }
32
21
  exports.getReserveState = getReserveState;
33
22
  /**
34
23
  * Get state of reserve
35
24
  *
36
- * @param ky Ky debug instance
25
+ * @param kyOptions Ky Options for making requests
37
26
  */
38
- function getChainState(ky) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const response = yield (0, http_1.http)(ky, {
41
- method: 'get',
42
- path: `${CHAIN_STATE_ENDPOINT}`,
43
- responseType: 'json',
44
- });
45
- return response.data;
27
+ async function getChainState(kyOptions) {
28
+ const response = await (0, http_1.http)(kyOptions, {
29
+ method: 'get',
30
+ path: `${CHAIN_STATE_ENDPOINT}`,
31
+ responseType: 'json',
46
32
  });
33
+ return response.parsedData;
47
34
  }
48
35
  exports.getChainState = getChainState;
49
36
  /**
50
37
  * Get wallet balances for xDai and BZZ of the node
51
38
  *
52
- * @param ky Ky debug instance
39
+ * @param kyOptions Ky Options for making requests
53
40
  */
54
- function getWalletBalance(ky) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const response = yield (0, http_1.http)(ky, {
57
- method: 'get',
58
- path: `${WALLET_ENDPOINT}`,
59
- responseType: 'json',
60
- });
61
- return mapWalletProperties(response.data);
41
+ async function getWalletBalance(kyOptions) {
42
+ const response = await (0, http_1.http)(kyOptions, {
43
+ method: 'get',
44
+ path: `${WALLET_ENDPOINT}`,
45
+ responseType: 'json',
62
46
  });
47
+ return mapWalletProperties(response.parsedData);
63
48
  }
64
49
  exports.getWalletBalance = getWalletBalance;
65
50
  /**
@@ -67,11 +52,13 @@ exports.getWalletBalance = getWalletBalance;
67
52
  * @param data
68
53
  */
69
54
  function mapWalletProperties(data) {
70
- return Object.assign({
55
+ return {
71
56
  // @ts-ignore: Needed for backward compatibility mapping
72
- bzz: data.bzzBalance,
57
+ bzz: data.bzzBalance,
73
58
  // @ts-ignore: Needed for backward compatibility mapping
74
- xDai: data.nativeTokenBalance,
59
+ xDai: data.nativeTokenBalance,
75
60
  // @ts-ignore: Needed for backward compatibility mapping
76
- contractAddress: data.chequebookContractAddress }, data);
61
+ contractAddress: data.chequebookContractAddress,
62
+ ...data,
63
+ };
77
64
  }