@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,97 +1,53 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
2
  const balancesEndpoint = 'balances';
35
3
  const consumedEndpoint = 'consumed';
36
4
  /**
37
5
  * Get the balances with all known peers including prepaid services
38
6
  *
39
- * @param ky Ky debug instance
7
+ * @param kyOptions Ky Options for making requests
40
8
  */
41
-
42
- export function getAllBalances(ky) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const response = yield http(ky, {
45
- path: balancesEndpoint,
46
- responseType: 'json'
47
- });
48
- return response.data;
9
+ export async function getAllBalances(kyOptions) {
10
+ const response = await http(kyOptions, {
11
+ path: balancesEndpoint,
12
+ responseType: 'json'
49
13
  });
14
+ return response.parsedData;
50
15
  }
51
16
  /**
52
17
  * Get the balances with a specific peer including prepaid services
53
18
  *
54
- * @param ky Ky debug instance
19
+ * @param kyOptions Ky Options for making requests
55
20
  * @param address Swarm address of peer
56
21
  */
57
-
58
- export function getPeerBalance(ky, address) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- const response = yield http(ky, {
61
- path: `${balancesEndpoint}/${address}`,
62
- responseType: 'json'
63
- });
64
- return response.data;
22
+ export async function getPeerBalance(kyOptions, address) {
23
+ const response = await http(kyOptions, {
24
+ path: `${balancesEndpoint}/${address}`,
25
+ responseType: 'json'
65
26
  });
27
+ return response.parsedData;
66
28
  }
67
29
  /**
68
30
  * Get the past due consumption balances with all known peers
69
31
  *
70
- * @param ky Ky debug instance
32
+ * @param kyOptions Ky Options for making requests
71
33
  */
72
-
73
- export function getPastDueConsumptionBalances(ky) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const response = yield http(ky, {
76
- path: consumedEndpoint,
77
- responseType: 'json'
78
- });
79
- return response.data;
34
+ export async function getPastDueConsumptionBalances(kyOptions) {
35
+ const response = await http(kyOptions, {
36
+ path: consumedEndpoint,
37
+ responseType: 'json'
80
38
  });
39
+ return response.parsedData;
81
40
  }
82
41
  /**
83
42
  * Get the past due consumption balance with a specific peer
84
43
  *
85
- * @param ky Ky debug instance
44
+ * @param kyOptions Ky Options for making requests
86
45
  * @param address Swarm address of peer
87
46
  */
88
-
89
- export function getPastDueConsumptionPeerBalance(ky, address) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const response = yield http(ky, {
92
- path: `${consumedEndpoint}/${address}`,
93
- responseType: 'json'
94
- });
95
- return response.data;
47
+ export async function getPastDueConsumptionPeerBalance(kyOptions, address) {
48
+ const response = await http(kyOptions, {
49
+ path: `${consumedEndpoint}/${address}`,
50
+ responseType: 'json'
96
51
  });
52
+ return response.parsedData;
97
53
  }
@@ -1,198 +1,135 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
2
  const chequebookEndpoint = 'chequebook';
35
3
  /**
36
4
  * Get the address of the chequebook contract used
37
5
  *
38
- * @param ky Ky debug instance
6
+ * @param kyOptions Ky Options for making requests
39
7
  */
40
-
41
- export function getChequebookAddress(ky) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const response = yield http(ky, {
44
- path: chequebookEndpoint + '/address',
45
- responseType: 'json'
46
- });
47
- return response.data;
8
+ export async function getChequebookAddress(kyOptions) {
9
+ const response = await http(kyOptions, {
10
+ path: chequebookEndpoint + '/address',
11
+ responseType: 'json'
48
12
  });
13
+ return response.parsedData;
49
14
  }
50
15
  /**
51
16
  * Get the balance of the chequebook
52
17
  *
53
- * @param ky Ky debug instance
18
+ * @param kyOptions Ky Options for making requests
54
19
  */
55
-
56
- export function getChequebookBalance(ky) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const response = yield http(ky, {
59
- path: chequebookEndpoint + '/balance',
60
- responseType: 'json'
61
- });
62
- return response.data;
20
+ export async function getChequebookBalance(kyOptions) {
21
+ const response = await http(kyOptions, {
22
+ path: chequebookEndpoint + '/balance',
23
+ responseType: 'json'
63
24
  });
25
+ return response.parsedData;
64
26
  }
65
27
  /**
66
28
  * Get last cashout action for the peer
67
29
  *
68
- * @param ky Ky debug instance
30
+ * @param kyOptions Ky Options for making requests
69
31
  * @param peer Swarm address of peer
70
32
  */
71
-
72
- export function getLastCashoutAction(ky, peer) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- const response = yield http(ky, {
75
- path: chequebookEndpoint + `/cashout/${peer}`,
76
- responseType: 'json'
77
- });
78
- return response.data;
33
+ export async function getLastCashoutAction(kyOptions, peer) {
34
+ const response = await http(kyOptions, {
35
+ path: chequebookEndpoint + `/cashout/${peer}`,
36
+ responseType: 'json'
79
37
  });
38
+ return response.parsedData;
80
39
  }
81
40
  /**
82
41
  * Cashout the last cheque for the peer
83
42
  *
84
- * @param ky Ky debug instance
43
+ * @param kyOptions Ky Options for making requests
85
44
  * @param peer Swarm address of peer
86
45
  * @param options
87
46
  */
88
-
89
- export function cashoutLastCheque(ky, peer, options) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const headers = {};
92
-
93
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
94
- headers['gas-price'] = options.gasPrice.toString();
95
- }
96
-
97
- if (options === null || options === void 0 ? void 0 : options.gasLimit) {
98
- headers['gas-limit'] = options.gasLimit.toString();
99
- }
100
-
101
- const response = yield http(ky, {
102
- method: 'post',
103
- path: chequebookEndpoint + `/cashout/${peer}`,
104
- responseType: 'json',
105
- headers
106
- });
107
- return response.data.transactionHash;
47
+ export async function cashoutLastCheque(kyOptions, peer, options) {
48
+ const headers = {};
49
+ if (options?.gasPrice) {
50
+ headers['gas-price'] = options.gasPrice.toString();
51
+ }
52
+ if (options?.gasLimit) {
53
+ headers['gas-limit'] = options.gasLimit.toString();
54
+ }
55
+ const response = await http(kyOptions, {
56
+ method: 'post',
57
+ path: chequebookEndpoint + `/cashout/${peer}`,
58
+ responseType: 'json',
59
+ headers
108
60
  });
61
+ return response.parsedData.transactionHash;
109
62
  }
110
63
  /**
111
64
  * Get last cheques for the peer
112
65
  *
113
- * @param ky Ky debug instance
66
+ * @param kyOptions Ky Options for making requests
114
67
  * @param peer Swarm address of peer
115
68
  */
116
-
117
- export function getLastChequesForPeer(ky, peer) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- const response = yield http(ky, {
120
- path: chequebookEndpoint + `/cheque/${peer}`,
121
- responseType: 'json'
122
- });
123
- return response.data;
69
+ export async function getLastChequesForPeer(kyOptions, peer) {
70
+ const response = await http(kyOptions, {
71
+ path: chequebookEndpoint + `/cheque/${peer}`,
72
+ responseType: 'json'
124
73
  });
74
+ return response.parsedData;
125
75
  }
126
76
  /**
127
77
  * Get last cheques for all peers
128
78
  *
129
- * @param ky Ky debug instance
79
+ * @param kyOptions Ky Options for making requests
130
80
  */
131
-
132
- export function getLastCheques(ky) {
133
- return __awaiter(this, void 0, void 0, function* () {
134
- const response = yield http(ky, {
135
- path: chequebookEndpoint + '/cheque',
136
- responseType: 'json'
137
- });
138
- return response.data;
81
+ export async function getLastCheques(kyOptions) {
82
+ const response = await http(kyOptions, {
83
+ path: chequebookEndpoint + '/cheque',
84
+ responseType: 'json'
139
85
  });
86
+ return response.parsedData;
140
87
  }
141
88
  /**
142
89
  * Deposit tokens from overlay address into chequebook
143
90
  *
144
- * @param ky Ky debug instance
91
+ * @param kyOptions Ky Options for making requests
145
92
  * @param amount Amount of tokens to deposit
146
93
  * @param gasPrice Gas Price in WEI for the transaction call
147
94
  * @return string Hash of the transaction
148
95
  */
149
-
150
- export function depositTokens(ky, amount, gasPrice) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- const headers = {};
153
-
154
- if (gasPrice) {
155
- headers['gas-price'] = gasPrice.toString();
156
- }
157
-
158
- const response = yield http(ky, {
159
- method: 'post',
160
- path: chequebookEndpoint + '/deposit',
161
- responseType: 'json',
162
- searchParams: {
163
- amount: amount.toString(10)
164
- },
165
- headers
166
- });
167
- return response.data.transactionHash;
96
+ export async function depositTokens(kyOptions, amount, gasPrice) {
97
+ const headers = {};
98
+ if (gasPrice) {
99
+ headers['gas-price'] = gasPrice.toString();
100
+ }
101
+ const response = await http(kyOptions, {
102
+ method: 'post',
103
+ path: chequebookEndpoint + '/deposit',
104
+ responseType: 'json',
105
+ searchParams: {
106
+ amount: amount.toString(10)
107
+ },
108
+ headers
168
109
  });
110
+ return response.parsedData.transactionHash;
169
111
  }
170
112
  /**
171
113
  * Withdraw tokens from the chequebook to the overlay address
172
114
  *
173
- * @param ky Ky debug instance
115
+ * @param kyOptions Ky Options for making requests
174
116
  * @param amount Amount of tokens to withdraw
175
117
  * @param gasPrice Gas Price in WEI for the transaction call
176
118
  * @return string Hash of the transaction
177
119
  */
178
-
179
- export function withdrawTokens(ky, amount, gasPrice) {
180
- return __awaiter(this, void 0, void 0, function* () {
181
- const headers = {};
182
-
183
- if (gasPrice) {
184
- headers['gas-price'] = gasPrice.toString();
185
- }
186
-
187
- const response = yield http(ky, {
188
- method: 'post',
189
- path: chequebookEndpoint + '/withdraw',
190
- responseType: 'json',
191
- searchParams: {
192
- amount: amount.toString(10)
193
- },
194
- headers
195
- });
196
- return response.data.transactionHash;
120
+ export async function withdrawTokens(kyOptions, amount, gasPrice) {
121
+ const headers = {};
122
+ if (gasPrice) {
123
+ headers['gas-price'] = gasPrice.toString();
124
+ }
125
+ const response = await http(kyOptions, {
126
+ method: 'post',
127
+ path: chequebookEndpoint + '/withdraw',
128
+ responseType: 'json',
129
+ searchParams: {
130
+ amount: amount.toString(10)
131
+ },
132
+ headers
197
133
  });
134
+ return response.parsedData.transactionHash;
198
135
  }
@@ -1,71 +1,33 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
2
  const endpoint = 'chunks';
35
3
  /**
36
4
  * Check if chunk at address exists locally
37
5
  *
38
- * @param ky Ky debug instance
6
+ * @param kyOptions Ky Options for making requests
39
7
  * @param address Swarm address of chunk
40
8
  *
41
9
  * @returns BeeGenericResponse if chunk is found or throws an exception
42
10
  */
43
-
44
- export function checkIfChunkExistsLocally(ky, address) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const response = yield http(ky, {
47
- path: endpoint + `/${address}`,
48
- responseType: 'json'
49
- });
50
- return response.data;
11
+ export async function checkIfChunkExistsLocally(kyOptions, address) {
12
+ const response = await http(kyOptions, {
13
+ path: endpoint + `/${address}`,
14
+ responseType: 'json'
51
15
  });
16
+ return response.parsedData;
52
17
  }
53
18
  /**
54
19
  * Delete a chunk from local storage
55
20
  *
56
- * @param ky Ky debug instance
21
+ * @param kyOptions Ky Options for making requests
57
22
  * @param address Swarm address of chunk
58
23
  *
59
24
  * @returns BeeGenericResponse if chunk was deleted or throws an exception
60
25
  */
61
-
62
- export function deleteChunkFromLocalStorage(ky, address) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const response = yield http(ky, {
65
- method: 'delete',
66
- path: endpoint + `/${address}`,
67
- responseType: 'json'
68
- });
69
- return response.data;
26
+ export async function deleteChunkFromLocalStorage(kyOptions, address) {
27
+ const response = await http(kyOptions, {
28
+ method: 'delete',
29
+ path: endpoint + `/${address}`,
30
+ responseType: 'json'
70
31
  });
32
+ return response.parsedData;
71
33
  }
@@ -1,89 +1,45 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
- export function getNodeAddresses(ky) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const response = yield http(ky, {
37
- path: 'addresses',
38
- responseType: 'json'
39
- });
40
- return response.data;
2
+ export async function getNodeAddresses(kyOptions) {
3
+ const response = await http(kyOptions, {
4
+ path: 'addresses',
5
+ responseType: 'json'
41
6
  });
7
+ return response.parsedData;
42
8
  }
43
- export function getPeers(ky) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const response = yield http(ky, {
46
- path: 'peers',
47
- responseType: 'json'
48
- });
49
- return response.data.peers;
9
+ export async function getPeers(kyOptions) {
10
+ const response = await http(kyOptions, {
11
+ path: 'peers',
12
+ responseType: 'json'
50
13
  });
14
+ return response.parsedData.peers;
51
15
  }
52
- export function getBlocklist(ky) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const response = yield http(ky, {
55
- path: 'blocklist',
56
- responseType: 'json'
57
- });
58
- return response.data.peers;
16
+ export async function getBlocklist(kyOptions) {
17
+ const response = await http(kyOptions, {
18
+ path: 'blocklist',
19
+ responseType: 'json'
59
20
  });
21
+ return response.parsedData.peers;
60
22
  }
61
- export function removePeer(ky, peer) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const response = yield http(ky, {
64
- path: `peers/${peer}`,
65
- responseType: 'json',
66
- method: 'DELETE'
67
- });
68
- return response.data;
23
+ export async function removePeer(kyOptions, peer) {
24
+ const response = await http(kyOptions, {
25
+ path: `peers/${peer}`,
26
+ responseType: 'json',
27
+ method: 'DELETE'
69
28
  });
29
+ return response.parsedData;
70
30
  }
71
- export function getTopology(ky) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const response = yield http(ky, {
74
- path: `topology`,
75
- responseType: 'json'
76
- });
77
- return response.data;
31
+ export async function getTopology(kyOptions) {
32
+ const response = await http(kyOptions, {
33
+ path: `topology`,
34
+ responseType: 'json'
78
35
  });
36
+ return response.parsedData;
79
37
  }
80
- export function pingPeer(ky, peer) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- const response = yield http(ky, {
83
- path: `pingpong/${peer}`,
84
- responseType: 'json',
85
- method: 'POST'
86
- });
87
- return response.data;
38
+ export async function pingPeer(kyOptions, peer) {
39
+ const response = await http(kyOptions, {
40
+ path: `pingpong/${peer}`,
41
+ responseType: 'json',
42
+ method: 'POST'
88
43
  });
44
+ return response.parsedData;
89
45
  }
@@ -1,65 +1,27 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
2
  const settlementsEndpoint = 'settlements';
35
3
  /**
36
4
  * Get amount of sent and received from settlements with a peer
37
5
  *
38
- * @param ky Ky debug instance
6
+ * @param kyOptions Ky Options for making requests
39
7
  * @param peer Swarm address of peer
40
8
  */
41
-
42
- export function getSettlements(ky, peer) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const response = yield http(ky, {
45
- path: `${settlementsEndpoint}/${peer}`,
46
- responseType: 'json'
47
- });
48
- return response.data;
9
+ export async function getSettlements(kyOptions, peer) {
10
+ const response = await http(kyOptions, {
11
+ path: `${settlementsEndpoint}/${peer}`,
12
+ responseType: 'json'
49
13
  });
14
+ return response.parsedData;
50
15
  }
51
16
  /**
52
17
  * Get settlements with all known peers and total amount sent or received
53
18
  *
54
- * @param ky Ky debug instance
19
+ * @param kyOptions Ky Options for making requests
55
20
  */
56
-
57
- export function getAllSettlements(ky) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const response = yield http(ky, {
60
- path: settlementsEndpoint,
61
- responseType: 'json'
62
- });
63
- return response.data;
21
+ export async function getAllSettlements(kyOptions) {
22
+ const response = await http(kyOptions, {
23
+ path: settlementsEndpoint,
24
+ responseType: 'json'
64
25
  });
26
+ return response.parsedData;
65
27
  }