@ethersphere/bee-js 5.0.0 → 6.0.0-pre.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 (192) hide show
  1. package/README.md +9 -1
  2. package/dist/index.browser.js +33 -0
  3. package/dist/index.browser.js.map +7 -0
  4. package/dist/src/bee-debug.js +624 -0
  5. package/dist/{mjs → src}/bee.js +243 -340
  6. package/dist/{mjs → src}/chunk/bmt.js +0 -0
  7. package/dist/{mjs → src}/chunk/cac.js +0 -0
  8. package/dist/{mjs → src}/chunk/serialize.js +0 -0
  9. package/dist/{mjs → src}/chunk/signer.js +13 -47
  10. package/dist/{mjs → src}/chunk/soc.js +31 -71
  11. package/dist/{mjs → src}/chunk/span.js +1 -1
  12. package/dist/{mjs → src}/feed/identifier.js +0 -0
  13. package/dist/src/feed/index.js +92 -0
  14. package/dist/src/feed/json.js +27 -0
  15. package/dist/src/feed/retrievable.js +67 -0
  16. package/dist/{mjs → src}/feed/topic.js +0 -0
  17. package/dist/{mjs → src}/feed/type.js +0 -0
  18. package/dist/{mjs → src}/index.js +1 -2
  19. package/dist/src/modules/bytes.js +59 -0
  20. package/dist/src/modules/bzz.js +122 -0
  21. package/dist/src/modules/chunk.js +45 -0
  22. package/dist/src/modules/debug/balance.js +57 -0
  23. package/dist/src/modules/debug/chequebook.js +150 -0
  24. package/dist/src/modules/debug/chunk.js +35 -0
  25. package/dist/src/modules/debug/connectivity.js +45 -0
  26. package/dist/src/modules/debug/settlements.js +29 -0
  27. package/dist/src/modules/debug/stamps.js +64 -0
  28. package/dist/src/modules/debug/states.js +46 -0
  29. package/dist/src/modules/debug/status.js +134 -0
  30. package/dist/src/modules/debug/tag.js +16 -0
  31. package/dist/src/modules/debug/transactions.js +69 -0
  32. package/dist/src/modules/feed.js +67 -0
  33. package/dist/src/modules/pinning.js +60 -0
  34. package/dist/src/modules/pss.js +40 -0
  35. package/dist/src/modules/soc.js +31 -0
  36. package/dist/src/modules/status.js +12 -0
  37. package/dist/src/modules/stewardship.js +24 -0
  38. package/dist/src/modules/tag.js +77 -0
  39. package/dist/{mjs → src}/types/debug.js +0 -0
  40. package/dist/{mjs → src}/types/index.js +0 -0
  41. package/dist/{mjs → src}/utils/bytes.js +3 -2
  42. package/dist/src/utils/collection-browser.js +19 -0
  43. package/dist/src/utils/collection-node.js +74 -0
  44. package/dist/src/utils/collection.js +64 -0
  45. package/dist/src/utils/data.browser.js +72 -0
  46. package/dist/src/utils/data.js +42 -0
  47. package/dist/{mjs → src}/utils/error.js +0 -0
  48. package/dist/{mjs → src}/utils/eth.js +32 -68
  49. package/dist/{mjs → src}/utils/expose.js +1 -1
  50. package/dist/src/utils/file.js +36 -0
  51. package/dist/{mjs → src}/utils/hash.js +0 -0
  52. package/dist/{mjs → src}/utils/headers.js +4 -4
  53. package/dist/{mjs → src}/utils/hex.js +0 -0
  54. package/dist/src/utils/http.js +162 -0
  55. package/dist/{mjs → src}/utils/merge.js +2 -2
  56. package/dist/{mjs → src}/utils/pss.js +0 -0
  57. package/dist/{mjs → src}/utils/reference.js +0 -0
  58. package/dist/src/utils/sleep.js +8 -0
  59. package/dist/{mjs → src}/utils/stamps.js +0 -0
  60. package/dist/{mjs → src}/utils/stream.js +3 -3
  61. package/dist/{mjs → src}/utils/tar.js +0 -0
  62. package/dist/{mjs → src}/utils/type.js +12 -13
  63. package/dist/{mjs → src}/utils/uint64.js +0 -0
  64. package/dist/{mjs → src}/utils/url.js +0 -0
  65. package/dist/types/chunk/bmt.d.ts +1 -1
  66. package/dist/types/chunk/soc.d.ts +1 -1
  67. package/dist/types/chunk/span.d.ts +1 -1
  68. package/dist/types/feed/index.d.ts +1 -1
  69. package/dist/types/index.d.ts +0 -13
  70. package/dist/types/modules/bzz.d.ts +1 -1
  71. package/dist/types/types/index.d.ts +8 -8
  72. package/dist/types/utils/{collection.browser.d.ts → collection-browser.d.ts} +0 -0
  73. package/dist/types/utils/{collection.node.d.ts → collection-node.d.ts} +0 -0
  74. package/dist/types/utils/error.d.ts +1 -1
  75. package/dist/types/utils/eth.d.ts +3 -3
  76. package/dist/types/utils/expose.d.ts +7 -4
  77. package/dist/types/utils/hash.d.ts +1 -1
  78. package/dist/types/utils/hex.d.ts +2 -2
  79. package/dist/types/utils/http.d.ts +3 -3
  80. package/dist/types/utils/stream.d.ts +1 -1
  81. package/dist/types/utils/uint64.d.ts +1 -1
  82. package/package.json +44 -59
  83. package/dist/cjs/bee-debug.js +0 -642
  84. package/dist/cjs/bee.js +0 -983
  85. package/dist/cjs/chunk/bmt.js +0 -55
  86. package/dist/cjs/chunk/cac.js +0 -56
  87. package/dist/cjs/chunk/serialize.js +0 -19
  88. package/dist/cjs/chunk/signer.js +0 -137
  89. package/dist/cjs/chunk/soc.js +0 -176
  90. package/dist/cjs/chunk/span.js +0 -29
  91. package/dist/cjs/feed/identifier.js +0 -35
  92. package/dist/cjs/feed/index.js +0 -132
  93. package/dist/cjs/feed/json.js +0 -41
  94. package/dist/cjs/feed/retrievable.js +0 -72
  95. package/dist/cjs/feed/topic.js +0 -25
  96. package/dist/cjs/feed/type.js +0 -15
  97. package/dist/cjs/index.js +0 -39
  98. package/dist/cjs/modules/bytes.js +0 -74
  99. package/dist/cjs/modules/bzz.js +0 -131
  100. package/dist/cjs/modules/chunk.js +0 -58
  101. package/dist/cjs/modules/debug/balance.js +0 -77
  102. package/dist/cjs/modules/debug/chequebook.js +0 -167
  103. package/dist/cjs/modules/debug/chunk.js +0 -51
  104. package/dist/cjs/modules/debug/connectivity.js +0 -75
  105. package/dist/cjs/modules/debug/settlements.js +0 -45
  106. package/dist/cjs/modules/debug/stamps.js +0 -89
  107. package/dist/cjs/modules/debug/states.js +0 -64
  108. package/dist/cjs/modules/debug/status.js +0 -153
  109. package/dist/cjs/modules/debug/tag.js +0 -30
  110. package/dist/cjs/modules/debug/transactions.js +0 -81
  111. package/dist/cjs/modules/feed.js +0 -76
  112. package/dist/cjs/modules/pinning.js +0 -80
  113. package/dist/cjs/modules/pss.js +0 -55
  114. package/dist/cjs/modules/soc.js +0 -40
  115. package/dist/cjs/modules/status.js +0 -26
  116. package/dist/cjs/modules/stewardship.js +0 -41
  117. package/dist/cjs/modules/tag.js +0 -96
  118. package/dist/cjs/package.json +0 -8
  119. package/dist/cjs/types/debug.js +0 -10
  120. package/dist/cjs/types/index.js +0 -51
  121. package/dist/cjs/types/ky-options.js +0 -8
  122. package/dist/cjs/types/ky-universal/common.js +0 -8
  123. package/dist/cjs/types/ky-universal/hooks.js +0 -8
  124. package/dist/cjs/types/ky-universal/retry.js +0 -8
  125. package/dist/cjs/utils/bytes.js +0 -121
  126. package/dist/cjs/utils/collection.browser.js +0 -36
  127. package/dist/cjs/utils/collection.js +0 -70
  128. package/dist/cjs/utils/collection.node.js +0 -115
  129. package/dist/cjs/utils/data.browser.js +0 -74
  130. package/dist/cjs/utils/data.js +0 -58
  131. package/dist/cjs/utils/error.js +0 -50
  132. package/dist/cjs/utils/eth.js +0 -211
  133. package/dist/cjs/utils/expose.js +0 -44
  134. package/dist/cjs/utils/file.js +0 -49
  135. package/dist/cjs/utils/hash.js +0 -21
  136. package/dist/cjs/utils/headers.js +0 -59
  137. package/dist/cjs/utils/hex.js +0 -150
  138. package/dist/cjs/utils/http.js +0 -172
  139. package/dist/cjs/utils/merge.js +0 -34
  140. package/dist/cjs/utils/pss.js +0 -18
  141. package/dist/cjs/utils/reference.js +0 -36
  142. package/dist/cjs/utils/sleep.js +0 -23
  143. package/dist/cjs/utils/stamps.js +0 -17
  144. package/dist/cjs/utils/stream.js +0 -146
  145. package/dist/cjs/utils/tar.js +0 -25
  146. package/dist/cjs/utils/type.js +0 -426
  147. package/dist/cjs/utils/uint64.js +0 -29
  148. package/dist/cjs/utils/url.js +0 -56
  149. package/dist/index.browser.min.js +0 -3
  150. package/dist/index.browser.min.js.LICENSE.txt +0 -60
  151. package/dist/index.browser.min.js.map +0 -1
  152. package/dist/mjs/bee-debug.js +0 -744
  153. package/dist/mjs/feed/index.js +0 -134
  154. package/dist/mjs/feed/json.js +0 -63
  155. package/dist/mjs/feed/retrievable.js +0 -105
  156. package/dist/mjs/modules/bytes.js +0 -96
  157. package/dist/mjs/modules/bzz.js +0 -160
  158. package/dist/mjs/modules/chunk.js +0 -80
  159. package/dist/mjs/modules/debug/balance.js +0 -97
  160. package/dist/mjs/modules/debug/chequebook.js +0 -198
  161. package/dist/mjs/modules/debug/chunk.js +0 -71
  162. package/dist/mjs/modules/debug/connectivity.js +0 -89
  163. package/dist/mjs/modules/debug/settlements.js +0 -65
  164. package/dist/mjs/modules/debug/stamps.js +0 -108
  165. package/dist/mjs/modules/debug/states.js +0 -84
  166. package/dist/mjs/modules/debug/status.js +0 -182
  167. package/dist/mjs/modules/debug/tag.js +0 -50
  168. package/dist/mjs/modules/debug/transactions.js +0 -103
  169. package/dist/mjs/modules/feed.js +0 -101
  170. package/dist/mjs/modules/pinning.js +0 -100
  171. package/dist/mjs/modules/pss.js +0 -74
  172. package/dist/mjs/modules/soc.js +0 -64
  173. package/dist/mjs/modules/status.js +0 -46
  174. package/dist/mjs/modules/stewardship.js +0 -60
  175. package/dist/mjs/modules/tag.js +0 -119
  176. package/dist/mjs/package.json +0 -8
  177. package/dist/mjs/types/ky-options.js +0 -7
  178. package/dist/mjs/types/ky-universal/common.js +0 -7
  179. package/dist/mjs/types/ky-universal/hooks.js +0 -7
  180. package/dist/mjs/types/ky-universal/retry.js +0 -7
  181. package/dist/mjs/utils/collection.browser.js +0 -56
  182. package/dist/mjs/utils/collection.js +0 -98
  183. package/dist/mjs/utils/collection.node.js +0 -169
  184. package/dist/mjs/utils/data.browser.js +0 -108
  185. package/dist/mjs/utils/data.js +0 -78
  186. package/dist/mjs/utils/file.js +0 -70
  187. package/dist/mjs/utils/http.js +0 -208
  188. package/dist/mjs/utils/sleep.js +0 -43
  189. package/dist/types/types/ky-options.d.ts +0 -221
  190. package/dist/types/types/ky-universal/common.d.ts +0 -13
  191. package/dist/types/types/ky-universal/hooks.d.ts +0 -92
  192. package/dist/types/types/ky-universal/retry.d.ts +0 -38
@@ -1,167 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.withdrawTokens = exports.depositTokens = exports.getLastCheques = exports.getLastChequesForPeer = exports.cashoutLastCheque = exports.getLastCashoutAction = exports.getChequebookBalance = exports.getChequebookAddress = void 0;
13
- const http_1 = require("../../utils/http");
14
- const chequebookEndpoint = 'chequebook';
15
- /**
16
- * Get the address of the chequebook contract used
17
- *
18
- * @param ky Ky debug instance
19
- */
20
- function getChequebookAddress(ky) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const response = yield (0, http_1.http)(ky, {
23
- path: chequebookEndpoint + '/address',
24
- responseType: 'json',
25
- });
26
- return response.data;
27
- });
28
- }
29
- exports.getChequebookAddress = getChequebookAddress;
30
- /**
31
- * Get the balance of the chequebook
32
- *
33
- * @param ky Ky debug instance
34
- */
35
- function getChequebookBalance(ky) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const response = yield (0, http_1.http)(ky, {
38
- path: chequebookEndpoint + '/balance',
39
- responseType: 'json',
40
- });
41
- return response.data;
42
- });
43
- }
44
- exports.getChequebookBalance = getChequebookBalance;
45
- /**
46
- * Get last cashout action for the peer
47
- *
48
- * @param ky Ky debug instance
49
- * @param peer Swarm address of peer
50
- */
51
- function getLastCashoutAction(ky, peer) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const response = yield (0, http_1.http)(ky, {
54
- path: chequebookEndpoint + `/cashout/${peer}`,
55
- responseType: 'json',
56
- });
57
- return response.data;
58
- });
59
- }
60
- exports.getLastCashoutAction = getLastCashoutAction;
61
- /**
62
- * Cashout the last cheque for the peer
63
- *
64
- * @param ky Ky debug instance
65
- * @param peer Swarm address of peer
66
- * @param options
67
- */
68
- function cashoutLastCheque(ky, peer, options) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const headers = {};
71
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
72
- headers['gas-price'] = options.gasPrice.toString();
73
- }
74
- if (options === null || options === void 0 ? void 0 : options.gasLimit) {
75
- headers['gas-limit'] = options.gasLimit.toString();
76
- }
77
- const response = yield (0, http_1.http)(ky, {
78
- method: 'post',
79
- path: chequebookEndpoint + `/cashout/${peer}`,
80
- responseType: 'json',
81
- headers,
82
- });
83
- return response.data.transactionHash;
84
- });
85
- }
86
- exports.cashoutLastCheque = cashoutLastCheque;
87
- /**
88
- * Get last cheques for the peer
89
- *
90
- * @param ky Ky debug instance
91
- * @param peer Swarm address of peer
92
- */
93
- function getLastChequesForPeer(ky, peer) {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- const response = yield (0, http_1.http)(ky, {
96
- path: chequebookEndpoint + `/cheque/${peer}`,
97
- responseType: 'json',
98
- });
99
- return response.data;
100
- });
101
- }
102
- exports.getLastChequesForPeer = getLastChequesForPeer;
103
- /**
104
- * Get last cheques for all peers
105
- *
106
- * @param ky Ky debug instance
107
- */
108
- function getLastCheques(ky) {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- const response = yield (0, http_1.http)(ky, {
111
- path: chequebookEndpoint + '/cheque',
112
- responseType: 'json',
113
- });
114
- return response.data;
115
- });
116
- }
117
- exports.getLastCheques = getLastCheques;
118
- /**
119
- * Deposit tokens from overlay address into chequebook
120
- *
121
- * @param ky Ky debug instance
122
- * @param amount Amount of tokens to deposit
123
- * @param gasPrice Gas Price in WEI for the transaction call
124
- * @return string Hash of the transaction
125
- */
126
- function depositTokens(ky, amount, gasPrice) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- const headers = {};
129
- if (gasPrice) {
130
- headers['gas-price'] = gasPrice.toString();
131
- }
132
- const response = yield (0, http_1.http)(ky, {
133
- method: 'post',
134
- path: chequebookEndpoint + '/deposit',
135
- responseType: 'json',
136
- searchParams: { amount: amount.toString(10) },
137
- headers,
138
- });
139
- return response.data.transactionHash;
140
- });
141
- }
142
- exports.depositTokens = depositTokens;
143
- /**
144
- * Withdraw tokens from the chequebook to the overlay address
145
- *
146
- * @param ky Ky debug instance
147
- * @param amount Amount of tokens to withdraw
148
- * @param gasPrice Gas Price in WEI for the transaction call
149
- * @return string Hash of the transaction
150
- */
151
- function withdrawTokens(ky, amount, gasPrice) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- const headers = {};
154
- if (gasPrice) {
155
- headers['gas-price'] = gasPrice.toString();
156
- }
157
- const response = yield (0, http_1.http)(ky, {
158
- method: 'post',
159
- path: chequebookEndpoint + '/withdraw',
160
- responseType: 'json',
161
- searchParams: { amount: amount.toString(10) },
162
- headers,
163
- });
164
- return response.data.transactionHash;
165
- });
166
- }
167
- exports.withdrawTokens = withdrawTokens;
@@ -1,51 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.deleteChunkFromLocalStorage = exports.checkIfChunkExistsLocally = void 0;
13
- const http_1 = require("../../utils/http");
14
- const endpoint = 'chunks';
15
- /**
16
- * Check if chunk at address exists locally
17
- *
18
- * @param ky Ky debug instance
19
- * @param address Swarm address of chunk
20
- *
21
- * @returns BeeGenericResponse if chunk is found or throws an exception
22
- */
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;
30
- });
31
- }
32
- exports.checkIfChunkExistsLocally = checkIfChunkExistsLocally;
33
- /**
34
- * Delete a chunk from local storage
35
- *
36
- * @param ky Ky debug instance
37
- * @param address Swarm address of chunk
38
- *
39
- * @returns BeeGenericResponse if chunk was deleted or throws an exception
40
- */
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;
49
- });
50
- }
51
- exports.deleteChunkFromLocalStorage = deleteChunkFromLocalStorage;
@@ -1,75 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.pingPeer = exports.getTopology = exports.removePeer = exports.getBlocklist = exports.getPeers = exports.getNodeAddresses = void 0;
13
- 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;
21
- });
22
- }
23
- 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;
31
- });
32
- }
33
- 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;
41
- });
42
- }
43
- 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;
52
- });
53
- }
54
- 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;
62
- });
63
- }
64
- 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;
73
- });
74
- }
75
- exports.pingPeer = pingPeer;
@@ -1,45 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAllSettlements = exports.getSettlements = void 0;
13
- const http_1 = require("../../utils/http");
14
- const settlementsEndpoint = 'settlements';
15
- /**
16
- * Get amount of sent and received from settlements with a peer
17
- *
18
- * @param ky Ky debug instance
19
- * @param peer Swarm address of peer
20
- */
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;
28
- });
29
- }
30
- exports.getSettlements = getSettlements;
31
- /**
32
- * Get settlements with all known peers and total amount sent or received
33
- *
34
- * @param ky Ky debug instance
35
- */
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;
43
- });
44
- }
45
- exports.getAllSettlements = getAllSettlements;
@@ -1,89 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.diluteBatch = exports.topUpBatch = exports.createPostageBatch = exports.getPostageBatchBuckets = exports.getPostageBatch = exports.getAllPostageBatches = void 0;
13
- const http_1 = require("../../utils/http");
14
- 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;
23
- });
24
- }
25
- 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;
34
- });
35
- }
36
- 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;
45
- });
46
- }
47
- 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;
65
- });
66
- }
67
- 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;
76
- });
77
- }
78
- 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;
87
- });
88
- }
89
- exports.diluteBatch = diluteBatch;
@@ -1,64 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getWalletBalance = exports.getChainState = exports.getReserveState = void 0;
13
- const http_1 = require("../../utils/http");
14
- const RESERVE_STATE_ENDPOINT = 'reservestate';
15
- const WALLET_ENDPOINT = 'wallet';
16
- const CHAIN_STATE_ENDPOINT = 'chainstate';
17
- /**
18
- * Get state of reserve
19
- *
20
- * @param ky Ky debug instance
21
- */
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;
30
- });
31
- }
32
- exports.getReserveState = getReserveState;
33
- /**
34
- * Get state of reserve
35
- *
36
- * @param ky Ky debug instance
37
- */
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;
46
- });
47
- }
48
- exports.getChainState = getChainState;
49
- /**
50
- * Get wallet balances for xDai and BZZ of the node
51
- *
52
- * @param ky Ky debug instance
53
- */
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 response.data;
62
- });
63
- }
64
- exports.getWalletBalance = getWalletBalance;
@@ -1,153 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getHealth = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
16
- const http_1 = require("../../utils/http");
17
- const major_js_1 = __importDefault(require("semver/functions/major.js"));
18
- // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
19
- // so if you are changing anything about them change the `update_bee` action accordingly!
20
- exports.SUPPORTED_BEE_VERSION_EXACT = '1.7.0-bbf13011';
21
- exports.SUPPORTED_API_VERSION = '3.0.2';
22
- exports.SUPPORTED_DEBUG_API_VERSION = '3.0.2';
23
- exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.substring(0, exports.SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
24
- const NODE_INFO_URL = 'node';
25
- const HEALTH_URL = 'health';
26
- /**
27
- * Get health of node
28
- *
29
- * @param ky Ky debug instance
30
- */
31
- function getHealth(ky) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const response = yield (0, http_1.http)(ky, {
34
- method: 'get',
35
- path: HEALTH_URL,
36
- responseType: 'json',
37
- });
38
- return response.data;
39
- });
40
- }
41
- exports.getHealth = getHealth;
42
- /**
43
- * Get information about Bee node
44
- *
45
- * @param ky Ky debug instance
46
- */
47
- function getNodeInfo(ky) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const response = yield (0, http_1.http)(ky, {
50
- method: 'get',
51
- path: NODE_INFO_URL,
52
- responseType: 'json',
53
- });
54
- return response.data;
55
- });
56
- }
57
- exports.getNodeInfo = getNodeInfo;
58
- /**
59
- * Connects to a node and checks if it is a supported Bee version by the bee-js
60
- *
61
- * @param ky Ky debug instance
62
- *
63
- * @returns true if the Bee node version is supported
64
- * @deprecated Use `isSupportedExactVersion` instead
65
- */
66
- function isSupportedVersion(ky) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- return isSupportedExactVersion(ky);
69
- });
70
- }
71
- exports.isSupportedVersion = isSupportedVersion;
72
- /**
73
- * Connects to a node and checks if its version matches with the one that bee-js supports.
74
- *
75
- * Be aware that this is the most strict version check and most probably
76
- * you will want to use more relaxed API-versions based checks like
77
- * `isSupportedApiVersion`, `isSupportedMainApiVersion` or `isSupportedDebugApiVersion`
78
- * based on your use-case.
79
- *
80
- * @param ky
81
- */
82
- function isSupportedExactVersion(ky) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- const { version } = yield getHealth(ky);
85
- return version === exports.SUPPORTED_BEE_VERSION_EXACT;
86
- });
87
- }
88
- exports.isSupportedExactVersion = isSupportedExactVersion;
89
- /**
90
- * Connects to a node and checks if its main's API version matches with the one that bee-js supports.
91
- *
92
- * This is useful if you are not using `BeeDebug` class (for anything else then this check)
93
- * and want to make sure about compatibility.
94
- *
95
- * @param ky
96
- */
97
- function isSupportedMainApiVersion(ky) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- const { apiVersion } = yield getHealth(ky);
100
- return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
101
- });
102
- }
103
- exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
104
- /**
105
- * Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
106
- *
107
- * This is useful if you are not using `Bee` class in your application and want to make sure
108
- * about compatibility.
109
- *
110
- * @param ky
111
- */
112
- function isSupportedDebugApiVersion(ky) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- const { debugApiVersion } = yield getHealth(ky);
115
- return (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION);
116
- });
117
- }
118
- exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
119
- /**
120
- * Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
121
- *
122
- * This should be the main way how to check compatibility for your app and Bee node.
123
- *
124
- * @param ky
125
- */
126
- function isSupportedApiVersion(ky) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- const { apiVersion, debugApiVersion } = yield getHealth(ky);
129
- return ((0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION) &&
130
- (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION));
131
- });
132
- }
133
- exports.isSupportedApiVersion = isSupportedApiVersion;
134
- /**
135
- * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
136
- * and versions that bee-js supports (properties prefixed with `supported*`).
137
- *
138
- * @param ky
139
- */
140
- function getVersions(ky) {
141
- return __awaiter(this, void 0, void 0, function* () {
142
- const { version, apiVersion, debugApiVersion } = yield getHealth(ky);
143
- return {
144
- supportedBeeVersion: exports.SUPPORTED_BEE_VERSION_EXACT,
145
- supportedBeeApiVersion: exports.SUPPORTED_API_VERSION,
146
- supportedBeeDebugApiVersion: exports.SUPPORTED_DEBUG_API_VERSION,
147
- beeVersion: version,
148
- beeApiVersion: apiVersion,
149
- beeDebugApiVersion: debugApiVersion,
150
- };
151
- });
152
- }
153
- exports.getVersions = getVersions;
@@ -1,30 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.retrieveExtendedTag = void 0;
13
- const http_1 = require("../../utils/http");
14
- const endpoint = 'tags';
15
- /**
16
- * Retrieve tag with extended information from Bee node
17
- *
18
- * @param ky Ky debug instance
19
- * @param uid UID of tag to be retrieved
20
- */
21
- function retrieveExtendedTag(ky, uid) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const response = yield (0, http_1.http)(ky, {
24
- path: `${endpoint}/${uid}`,
25
- responseType: 'json',
26
- });
27
- return response.data;
28
- });
29
- }
30
- exports.retrieveExtendedTag = retrieveExtendedTag;