@ethersphere/bee-js 5.2.0 → 6.0.0-pre.1

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 (111) hide show
  1. package/dist/cjs/bee-debug.js +58 -72
  2. package/dist/cjs/bee.js +71 -86
  3. package/dist/cjs/chunk/soc.js +14 -14
  4. package/dist/cjs/feed/index.js +20 -21
  5. package/dist/cjs/feed/json.js +2 -2
  6. package/dist/cjs/feed/retrievable.js +7 -8
  7. package/dist/cjs/index.js +7 -7
  8. package/dist/cjs/modules/bytes.js +15 -15
  9. package/dist/cjs/modules/bzz.js +24 -25
  10. package/dist/cjs/modules/chunk.js +10 -10
  11. package/dist/cjs/modules/debug/balance.js +16 -16
  12. package/dist/cjs/modules/debug/chequebook.js +34 -34
  13. package/dist/cjs/modules/debug/chunk.js +8 -8
  14. package/dist/cjs/modules/debug/connectivity.js +24 -24
  15. package/dist/cjs/modules/debug/settlements.js +8 -8
  16. package/dist/cjs/modules/debug/stake.js +11 -11
  17. package/dist/cjs/modules/debug/stamps.js +25 -25
  18. package/dist/cjs/modules/debug/states.js +12 -12
  19. package/dist/cjs/modules/debug/status.js +24 -24
  20. package/dist/cjs/modules/debug/tag.js +4 -4
  21. package/dist/cjs/modules/debug/transactions.js +16 -16
  22. package/dist/cjs/modules/feed.js +14 -14
  23. package/dist/cjs/modules/pinning.js +14 -14
  24. package/dist/cjs/modules/pss.js +6 -6
  25. package/dist/cjs/modules/soc.js +6 -6
  26. package/dist/cjs/modules/status.js +3 -3
  27. package/dist/cjs/modules/stewardship.js +7 -7
  28. package/dist/cjs/modules/tag.js +20 -20
  29. package/dist/cjs/utils/error.js +1 -35
  30. package/dist/cjs/utils/headers.js +3 -3
  31. package/dist/cjs/utils/http.js +14 -141
  32. package/dist/cjs/utils/type.js +1 -4
  33. package/dist/index.browser.min.js +1 -1
  34. package/dist/index.browser.min.js.LICENSE.txt +0 -8
  35. package/dist/index.browser.min.js.map +1 -1
  36. package/dist/mjs/bee-debug.js +59 -73
  37. package/dist/mjs/bee.js +72 -87
  38. package/dist/mjs/chunk/soc.js +14 -14
  39. package/dist/mjs/feed/index.js +20 -21
  40. package/dist/mjs/feed/json.js +2 -2
  41. package/dist/mjs/feed/retrievable.js +7 -8
  42. package/dist/mjs/index.js +2 -2
  43. package/dist/mjs/modules/bytes.js +15 -15
  44. package/dist/mjs/modules/bzz.js +24 -25
  45. package/dist/mjs/modules/chunk.js +10 -10
  46. package/dist/mjs/modules/debug/balance.js +16 -16
  47. package/dist/mjs/modules/debug/chequebook.js +34 -34
  48. package/dist/mjs/modules/debug/chunk.js +8 -8
  49. package/dist/mjs/modules/debug/connectivity.js +24 -24
  50. package/dist/mjs/modules/debug/settlements.js +8 -8
  51. package/dist/mjs/modules/debug/stake.js +11 -11
  52. package/dist/mjs/modules/debug/stamps.js +25 -25
  53. package/dist/mjs/modules/debug/states.js +12 -12
  54. package/dist/mjs/modules/debug/status.js +24 -25
  55. package/dist/mjs/modules/debug/tag.js +4 -4
  56. package/dist/mjs/modules/debug/transactions.js +16 -16
  57. package/dist/mjs/modules/feed.js +14 -14
  58. package/dist/mjs/modules/pinning.js +14 -14
  59. package/dist/mjs/modules/pss.js +6 -6
  60. package/dist/mjs/modules/soc.js +6 -6
  61. package/dist/mjs/modules/status.js +3 -3
  62. package/dist/mjs/modules/stewardship.js +7 -7
  63. package/dist/mjs/modules/tag.js +20 -20
  64. package/dist/mjs/utils/error.js +0 -31
  65. package/dist/mjs/utils/headers.js +3 -3
  66. package/dist/mjs/utils/http.js +10 -138
  67. package/dist/mjs/utils/type.js +2 -5
  68. package/dist/types/bee-debug.d.ts +50 -50
  69. package/dist/types/bee.d.ts +34 -34
  70. package/dist/types/chunk/soc.d.ts +5 -6
  71. package/dist/types/feed/index.d.ts +7 -8
  72. package/dist/types/feed/json.d.ts +2 -2
  73. package/dist/types/feed/retrievable.d.ts +2 -2
  74. package/dist/types/index.d.ts +2 -4
  75. package/dist/types/modules/bytes.d.ts +4 -5
  76. package/dist/types/modules/bzz.d.ts +5 -6
  77. package/dist/types/modules/chunk.d.ts +3 -4
  78. package/dist/types/modules/debug/balance.d.ts +5 -6
  79. package/dist/types/modules/debug/chequebook.d.ts +9 -10
  80. package/dist/types/modules/debug/chunk.d.ts +3 -4
  81. package/dist/types/modules/debug/connectivity.d.ts +7 -8
  82. package/dist/types/modules/debug/settlements.d.ts +3 -4
  83. package/dist/types/modules/debug/stake.d.ts +4 -5
  84. package/dist/types/modules/debug/stamps.d.ts +7 -8
  85. package/dist/types/modules/debug/states.d.ts +4 -5
  86. package/dist/types/modules/debug/status.d.ts +10 -10
  87. package/dist/types/modules/debug/tag.d.ts +2 -3
  88. package/dist/types/modules/debug/transactions.d.ts +5 -6
  89. package/dist/types/modules/feed.d.ts +3 -4
  90. package/dist/types/modules/pinning.d.ts +5 -6
  91. package/dist/types/modules/pss.d.ts +2 -3
  92. package/dist/types/modules/soc.d.ts +2 -3
  93. package/dist/types/modules/status.d.ts +2 -2
  94. package/dist/types/modules/stewardship.d.ts +3 -4
  95. package/dist/types/modules/tag.d.ts +6 -7
  96. package/dist/types/types/debug.d.ts +2 -2
  97. package/dist/types/types/index.d.ts +12 -51
  98. package/dist/types/utils/error.d.ts +0 -26
  99. package/dist/types/utils/headers.d.ts +1 -1
  100. package/dist/types/utils/http.d.ts +12 -21
  101. package/dist/types/utils/type.d.ts +2 -2
  102. package/package.json +4 -4
  103. package/dist/223.index.browser.min.js +0 -3
  104. package/dist/223.index.browser.min.js.LICENSE.txt +0 -1
  105. package/dist/223.index.browser.min.js.map +0 -1
  106. package/dist/cjs/utils/merge.js +0 -34
  107. package/dist/cjs/utils/sleep.js +0 -12
  108. package/dist/mjs/utils/merge.js +0 -32
  109. package/dist/mjs/utils/sleep.js +0 -8
  110. package/dist/types/utils/merge.d.ts +0 -8
  111. package/dist/types/utils/sleep.d.ts +0 -6
package/dist/mjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Bee } from "./bee.js";
2
2
  import { BeeDebug } from "./bee-debug.js";
3
- export * as Utils from "./utils/expose.js";
3
+ export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./modules/debug/status.js";
4
4
  export * from "./types/index.js";
5
5
  export * from "./utils/error.js";
6
- export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./modules/debug/status.js";
6
+ export * as Utils from "./utils/expose.js";
7
7
  export { Bee, BeeDebug };
@@ -1,7 +1,7 @@
1
+ import { wrapBytesWithHelpers } from "../utils/bytes.js";
1
2
  import { prepareData } from "../utils/data.js";
2
3
  import { extractUploadHeaders } from "../utils/headers.js";
3
4
  import { http } from "../utils/http.js";
4
- import { wrapBytesWithHelpers } from "../utils/bytes.js";
5
5
  import { makeTagUid } from "../utils/type.js";
6
6
  const endpoint = 'bytes';
7
7
  /**
@@ -12,20 +12,20 @@ const endpoint = 'bytes';
12
12
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
13
13
  * @param options Additional options like tag, encryption, pinning
14
14
  */
15
- export async function upload(kyOptions, data, postageBatchId, options) {
16
- const response = await http(kyOptions, {
17
- path: endpoint,
15
+ export async function upload(requestOptions, data, postageBatchId, options) {
16
+ const response = await http(requestOptions, {
17
+ url: endpoint,
18
18
  method: 'post',
19
19
  responseType: 'json',
20
- body: await prepareData(data),
20
+ data: await prepareData(data),
21
21
  headers: {
22
22
  'content-type': 'application/octet-stream',
23
23
  ...extractUploadHeaders(postageBatchId, options)
24
24
  }
25
25
  });
26
26
  return {
27
- reference: response.parsedData.reference,
28
- tagUid: makeTagUid(response.headers.get('swarm-tag'))
27
+ reference: response.data.reference,
28
+ tagUid: makeTagUid(response.headers['swarm-tag'])
29
29
  };
30
30
  }
31
31
  /**
@@ -34,12 +34,12 @@ export async function upload(kyOptions, data, postageBatchId, options) {
34
34
  * @param ky
35
35
  * @param hash Bee content reference
36
36
  */
37
- export async function download(kyOptions, hash) {
38
- const response = await http(kyOptions, {
37
+ export async function download(requestOptions, hash) {
38
+ const response = await http(requestOptions, {
39
39
  responseType: 'arraybuffer',
40
- path: `${endpoint}/${hash}`
40
+ url: `${endpoint}/${hash}`
41
41
  });
42
- return wrapBytesWithHelpers(new Uint8Array(response.parsedData));
42
+ return wrapBytesWithHelpers(new Uint8Array(response.data));
43
43
  }
44
44
  /**
45
45
  * Download data as a readable stream
@@ -47,10 +47,10 @@ export async function download(kyOptions, hash) {
47
47
  * @param ky
48
48
  * @param hash Bee content reference
49
49
  */
50
- export async function downloadReadable(kyOptions, hash) {
51
- const response = await http(kyOptions, {
50
+ export async function downloadReadable(requestOptions, hash) {
51
+ const response = await http(requestOptions, {
52
52
  responseType: 'stream',
53
- path: `${endpoint}/${hash}`
53
+ url: `${endpoint}/${hash}`
54
54
  });
55
- return response.parsedData;
55
+ return response.data;
56
56
  }
@@ -1,10 +1,9 @@
1
+ import { wrapBytesWithHelpers } from "../utils/bytes.js";
2
+ import { assertCollection } from "../utils/collection.js";
1
3
  import { extractUploadHeaders, readFileHeaders } from "../utils/headers.js";
2
4
  import { http } from "../utils/http.js";
3
- import { prepareData } from "../utils/data.js";
4
- import { makeTar } from "../utils/tar.js";
5
- import { assertCollection } from "../utils/collection.js";
6
- import { wrapBytesWithHelpers } from "../utils/bytes.js";
7
5
  import { isReadable } from "../utils/stream.js";
6
+ import { makeTar } from "../utils/tar.js";
8
7
  import { makeTagUid } from "../utils/type.js";
9
8
  const bzzEndpoint = 'bzz';
10
9
  function extractFileUploadHeaders(postageBatchId, options) {
@@ -22,26 +21,26 @@ function extractFileUploadHeaders(postageBatchId, options) {
22
21
  * @param name Name that will be attached to the uploaded file. Wraps the data into manifest with set index document.
23
22
  * @param options
24
23
  */
25
- export async function uploadFile(kyOptions, data, postageBatchId, name, options) {
24
+ export async function uploadFile(requestOptions, data, postageBatchId, name, options) {
26
25
  if (isReadable(data) && !options?.contentType) {
27
26
  if (!options) options = {};
28
27
  options.contentType = 'application/octet-stream';
29
28
  }
30
- const response = await http(kyOptions, {
29
+ const response = await http(requestOptions, {
31
30
  method: 'post',
32
- path: bzzEndpoint,
33
- body: await prepareData(data),
31
+ url: bzzEndpoint,
32
+ data,
34
33
  headers: {
35
34
  ...extractFileUploadHeaders(postageBatchId, options)
36
35
  },
37
- searchParams: {
36
+ params: {
38
37
  name
39
38
  },
40
39
  responseType: 'json'
41
40
  });
42
41
  return {
43
- reference: response.parsedData.reference,
44
- tagUid: makeTagUid(response.headers.get('swarm-tag'))
42
+ reference: response.data.reference,
43
+ tagUid: makeTagUid(response.headers['swarm-tag'])
45
44
  };
46
45
  }
47
46
  /**
@@ -51,15 +50,15 @@ export async function uploadFile(kyOptions, data, postageBatchId, name, options)
51
50
  * @param hash Bee file or collection hash
52
51
  * @param path If hash is collection then this defines path to a single file in the collection
53
52
  */
54
- export async function downloadFile(kyOptions, hash, path = '') {
55
- const response = await http(kyOptions, {
53
+ export async function downloadFile(requestOptions, hash, path = '') {
54
+ const response = await http(requestOptions, {
56
55
  method: 'GET',
57
56
  responseType: 'arraybuffer',
58
- path: `${bzzEndpoint}/${hash}/${path}`
57
+ url: `${bzzEndpoint}/${hash}/${path}`
59
58
  });
60
59
  const file = {
61
60
  ...readFileHeaders(response.headers),
62
- data: wrapBytesWithHelpers(new Uint8Array(response.parsedData))
61
+ data: wrapBytesWithHelpers(new Uint8Array(response.data))
63
62
  };
64
63
  return file;
65
64
  }
@@ -70,15 +69,15 @@ export async function downloadFile(kyOptions, hash, path = '') {
70
69
  * @param hash Bee file or collection hash
71
70
  * @param path If hash is collection then this defines path to a single file in the collection
72
71
  */
73
- export async function downloadFileReadable(kyOptions, hash, path = '') {
74
- const response = await http(kyOptions, {
72
+ export async function downloadFileReadable(requestOptions, hash, path = '') {
73
+ const response = await http(requestOptions, {
75
74
  method: 'GET',
76
75
  responseType: 'stream',
77
- path: `${bzzEndpoint}/${hash}/${path}`
76
+ url: `${bzzEndpoint}/${hash}/${path}`
78
77
  });
79
78
  const file = {
80
79
  ...readFileHeaders(response.headers),
81
- data: response.parsedData
80
+ data: response.data
82
81
  };
83
82
  return file;
84
83
  }
@@ -95,13 +94,13 @@ function extractCollectionUploadHeaders(postageBatchId, options) {
95
94
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
96
95
  * @param options
97
96
  */
98
- export async function uploadCollection(kyOptions, collection, postageBatchId, options) {
97
+ export async function uploadCollection(requestOptions, collection, postageBatchId, options) {
99
98
  assertCollection(collection);
100
99
  const tarData = makeTar(collection);
101
- const response = await http(kyOptions, {
100
+ const response = await http(requestOptions, {
102
101
  method: 'post',
103
- path: bzzEndpoint,
104
- body: tarData,
102
+ url: bzzEndpoint,
103
+ data: tarData,
105
104
  responseType: 'json',
106
105
  headers: {
107
106
  'content-type': 'application/x-tar',
@@ -110,7 +109,7 @@ export async function uploadCollection(kyOptions, collection, postageBatchId, op
110
109
  }
111
110
  });
112
111
  return {
113
- reference: response.parsedData.reference,
114
- tagUid: makeTagUid(response.headers.get('swarm-tag'))
112
+ reference: response.data.reference,
113
+ tagUid: makeTagUid(response.headers['swarm-tag'])
115
114
  };
116
115
  }
@@ -1,6 +1,6 @@
1
+ import { wrapBytesWithHelpers } from "../utils/bytes.js";
1
2
  import { extractUploadHeaders } from "../utils/headers.js";
2
3
  import { http } from "../utils/http.js";
3
- import { wrapBytesWithHelpers } from "../utils/bytes.js";
4
4
  const endpoint = 'chunks';
5
5
  /**
6
6
  * Upload chunk to a Bee node
@@ -14,18 +14,18 @@ const endpoint = 'chunks';
14
14
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
15
15
  * @param options Additional options like tag, encryption, pinning
16
16
  */
17
- export async function upload(kyOptions, data, postageBatchId, options) {
18
- const response = await http(kyOptions, {
17
+ export async function upload(requestOptions, data, postageBatchId, options) {
18
+ const response = await http(requestOptions, {
19
19
  method: 'post',
20
- path: `${endpoint}`,
21
- body: data,
20
+ url: `${endpoint}`,
21
+ data,
22
22
  headers: {
23
23
  'content-type': 'application/octet-stream',
24
24
  ...extractUploadHeaders(postageBatchId, options)
25
25
  },
26
26
  responseType: 'json'
27
27
  });
28
- return response.parsedData.reference;
28
+ return response.data.reference;
29
29
  }
30
30
  /**
31
31
  * Download chunk data as a byte array
@@ -34,10 +34,10 @@ export async function upload(kyOptions, data, postageBatchId, options) {
34
34
  * @param hash Bee content reference
35
35
  *
36
36
  */
37
- export async function download(kyOptions, hash) {
38
- const response = await http(kyOptions, {
37
+ export async function download(requestOptions, hash) {
38
+ const response = await http(requestOptions, {
39
39
  responseType: 'arraybuffer',
40
- path: `${endpoint}/${hash}`
40
+ url: `${endpoint}/${hash}`
41
41
  });
42
- return wrapBytesWithHelpers(new Uint8Array(response.parsedData));
42
+ return wrapBytesWithHelpers(new Uint8Array(response.data));
43
43
  }
@@ -6,12 +6,12 @@ const consumedEndpoint = 'consumed';
6
6
  *
7
7
  * @param kyOptions Ky Options for making requests
8
8
  */
9
- export async function getAllBalances(kyOptions) {
10
- const response = await http(kyOptions, {
11
- path: balancesEndpoint,
9
+ export async function getAllBalances(requestOptions) {
10
+ const response = await http(requestOptions, {
11
+ url: balancesEndpoint,
12
12
  responseType: 'json'
13
13
  });
14
- return response.parsedData;
14
+ return response.data;
15
15
  }
16
16
  /**
17
17
  * Get the balances with a specific peer including prepaid services
@@ -19,24 +19,24 @@ export async function getAllBalances(kyOptions) {
19
19
  * @param kyOptions Ky Options for making requests
20
20
  * @param address Swarm address of peer
21
21
  */
22
- export async function getPeerBalance(kyOptions, address) {
23
- const response = await http(kyOptions, {
24
- path: `${balancesEndpoint}/${address}`,
22
+ export async function getPeerBalance(requestOptions, address) {
23
+ const response = await http(requestOptions, {
24
+ url: `${balancesEndpoint}/${address}`,
25
25
  responseType: 'json'
26
26
  });
27
- return response.parsedData;
27
+ return response.data;
28
28
  }
29
29
  /**
30
30
  * Get the past due consumption balances with all known peers
31
31
  *
32
32
  * @param kyOptions Ky Options for making requests
33
33
  */
34
- export async function getPastDueConsumptionBalances(kyOptions) {
35
- const response = await http(kyOptions, {
36
- path: consumedEndpoint,
34
+ export async function getPastDueConsumptionBalances(requestOptions) {
35
+ const response = await http(requestOptions, {
36
+ url: consumedEndpoint,
37
37
  responseType: 'json'
38
38
  });
39
- return response.parsedData;
39
+ return response.data;
40
40
  }
41
41
  /**
42
42
  * Get the past due consumption balance with a specific peer
@@ -44,10 +44,10 @@ export async function getPastDueConsumptionBalances(kyOptions) {
44
44
  * @param kyOptions Ky Options for making requests
45
45
  * @param address Swarm address of peer
46
46
  */
47
- export async function getPastDueConsumptionPeerBalance(kyOptions, address) {
48
- const response = await http(kyOptions, {
49
- path: `${consumedEndpoint}/${address}`,
47
+ export async function getPastDueConsumptionPeerBalance(requestOptions, address) {
48
+ const response = await http(requestOptions, {
49
+ url: `${consumedEndpoint}/${address}`,
50
50
  responseType: 'json'
51
51
  });
52
- return response.parsedData;
52
+ return response.data;
53
53
  }
@@ -5,24 +5,24 @@ const chequebookEndpoint = 'chequebook';
5
5
  *
6
6
  * @param kyOptions Ky Options for making requests
7
7
  */
8
- export async function getChequebookAddress(kyOptions) {
9
- const response = await http(kyOptions, {
10
- path: chequebookEndpoint + '/address',
8
+ export async function getChequebookAddress(requestOptions) {
9
+ const response = await http(requestOptions, {
10
+ url: chequebookEndpoint + '/address',
11
11
  responseType: 'json'
12
12
  });
13
- return response.parsedData;
13
+ return response.data;
14
14
  }
15
15
  /**
16
16
  * Get the balance of the chequebook
17
17
  *
18
18
  * @param kyOptions Ky Options for making requests
19
19
  */
20
- export async function getChequebookBalance(kyOptions) {
21
- const response = await http(kyOptions, {
22
- path: chequebookEndpoint + '/balance',
20
+ export async function getChequebookBalance(requestOptions) {
21
+ const response = await http(requestOptions, {
22
+ url: chequebookEndpoint + '/balance',
23
23
  responseType: 'json'
24
24
  });
25
- return response.parsedData;
25
+ return response.data;
26
26
  }
27
27
  /**
28
28
  * Get last cashout action for the peer
@@ -30,12 +30,12 @@ export async function getChequebookBalance(kyOptions) {
30
30
  * @param kyOptions Ky Options for making requests
31
31
  * @param peer Swarm address of peer
32
32
  */
33
- export async function getLastCashoutAction(kyOptions, peer) {
34
- const response = await http(kyOptions, {
35
- path: chequebookEndpoint + `/cashout/${peer}`,
33
+ export async function getLastCashoutAction(requestOptions, peer) {
34
+ const response = await http(requestOptions, {
35
+ url: chequebookEndpoint + `/cashout/${peer}`,
36
36
  responseType: 'json'
37
37
  });
38
- return response.parsedData;
38
+ return response.data;
39
39
  }
40
40
  /**
41
41
  * Cashout the last cheque for the peer
@@ -44,7 +44,7 @@ export async function getLastCashoutAction(kyOptions, peer) {
44
44
  * @param peer Swarm address of peer
45
45
  * @param options
46
46
  */
47
- export async function cashoutLastCheque(kyOptions, peer, options) {
47
+ export async function cashoutLastCheque(requestOptions, peer, options) {
48
48
  const headers = {};
49
49
  if (options?.gasPrice) {
50
50
  headers['gas-price'] = options.gasPrice.toString();
@@ -52,13 +52,13 @@ export async function cashoutLastCheque(kyOptions, peer, options) {
52
52
  if (options?.gasLimit) {
53
53
  headers['gas-limit'] = options.gasLimit.toString();
54
54
  }
55
- const response = await http(kyOptions, {
55
+ const response = await http(requestOptions, {
56
56
  method: 'post',
57
- path: chequebookEndpoint + `/cashout/${peer}`,
57
+ url: chequebookEndpoint + `/cashout/${peer}`,
58
58
  responseType: 'json',
59
59
  headers
60
60
  });
61
- return response.parsedData.transactionHash;
61
+ return response.data.transactionHash;
62
62
  }
63
63
  /**
64
64
  * Get last cheques for the peer
@@ -66,24 +66,24 @@ export async function cashoutLastCheque(kyOptions, peer, options) {
66
66
  * @param kyOptions Ky Options for making requests
67
67
  * @param peer Swarm address of peer
68
68
  */
69
- export async function getLastChequesForPeer(kyOptions, peer) {
70
- const response = await http(kyOptions, {
71
- path: chequebookEndpoint + `/cheque/${peer}`,
69
+ export async function getLastChequesForPeer(requestOptions, peer) {
70
+ const response = await http(requestOptions, {
71
+ url: chequebookEndpoint + `/cheque/${peer}`,
72
72
  responseType: 'json'
73
73
  });
74
- return response.parsedData;
74
+ return response.data;
75
75
  }
76
76
  /**
77
77
  * Get last cheques for all peers
78
78
  *
79
79
  * @param kyOptions Ky Options for making requests
80
80
  */
81
- export async function getLastCheques(kyOptions) {
82
- const response = await http(kyOptions, {
83
- path: chequebookEndpoint + '/cheque',
81
+ export async function getLastCheques(requestOptions) {
82
+ const response = await http(requestOptions, {
83
+ url: chequebookEndpoint + '/cheque',
84
84
  responseType: 'json'
85
85
  });
86
- return response.parsedData;
86
+ return response.data;
87
87
  }
88
88
  /**
89
89
  * Deposit tokens from overlay address into chequebook
@@ -93,21 +93,21 @@ export async function getLastCheques(kyOptions) {
93
93
  * @param gasPrice Gas Price in WEI for the transaction call
94
94
  * @return string Hash of the transaction
95
95
  */
96
- export async function depositTokens(kyOptions, amount, gasPrice) {
96
+ export async function depositTokens(requestOptions, amount, gasPrice) {
97
97
  const headers = {};
98
98
  if (gasPrice) {
99
99
  headers['gas-price'] = gasPrice.toString();
100
100
  }
101
- const response = await http(kyOptions, {
101
+ const response = await http(requestOptions, {
102
102
  method: 'post',
103
- path: chequebookEndpoint + '/deposit',
103
+ url: chequebookEndpoint + '/deposit',
104
104
  responseType: 'json',
105
- searchParams: {
105
+ params: {
106
106
  amount: amount.toString(10)
107
107
  },
108
108
  headers
109
109
  });
110
- return response.parsedData.transactionHash;
110
+ return response.data.transactionHash;
111
111
  }
112
112
  /**
113
113
  * Withdraw tokens from the chequebook to the overlay address
@@ -117,19 +117,19 @@ export async function depositTokens(kyOptions, amount, gasPrice) {
117
117
  * @param gasPrice Gas Price in WEI for the transaction call
118
118
  * @return string Hash of the transaction
119
119
  */
120
- export async function withdrawTokens(kyOptions, amount, gasPrice) {
120
+ export async function withdrawTokens(requestOptions, amount, gasPrice) {
121
121
  const headers = {};
122
122
  if (gasPrice) {
123
123
  headers['gas-price'] = gasPrice.toString();
124
124
  }
125
- const response = await http(kyOptions, {
125
+ const response = await http(requestOptions, {
126
126
  method: 'post',
127
- path: chequebookEndpoint + '/withdraw',
127
+ url: chequebookEndpoint + '/withdraw',
128
128
  responseType: 'json',
129
- searchParams: {
129
+ params: {
130
130
  amount: amount.toString(10)
131
131
  },
132
132
  headers
133
133
  });
134
- return response.parsedData.transactionHash;
134
+ return response.data.transactionHash;
135
135
  }
@@ -8,12 +8,12 @@ const endpoint = 'chunks';
8
8
  *
9
9
  * @returns BeeGenericResponse if chunk is found or throws an exception
10
10
  */
11
- export async function checkIfChunkExistsLocally(kyOptions, address) {
12
- const response = await http(kyOptions, {
13
- path: endpoint + `/${address}`,
11
+ export async function checkIfChunkExistsLocally(requestOptions, address) {
12
+ const response = await http(requestOptions, {
13
+ url: `${endpoint}/${address}`,
14
14
  responseType: 'json'
15
15
  });
16
- return response.parsedData;
16
+ return response.data;
17
17
  }
18
18
  /**
19
19
  * Delete a chunk from local storage
@@ -23,11 +23,11 @@ export async function checkIfChunkExistsLocally(kyOptions, address) {
23
23
  *
24
24
  * @returns BeeGenericResponse if chunk was deleted or throws an exception
25
25
  */
26
- export async function deleteChunkFromLocalStorage(kyOptions, address) {
27
- const response = await http(kyOptions, {
26
+ export async function deleteChunkFromLocalStorage(requestOptions, address) {
27
+ const response = await http(requestOptions, {
28
28
  method: 'delete',
29
- path: endpoint + `/${address}`,
29
+ url: `${endpoint}/${address}`,
30
30
  responseType: 'json'
31
31
  });
32
- return response.parsedData;
32
+ return response.data;
33
33
  }
@@ -1,45 +1,45 @@
1
1
  import { http } from "../../utils/http.js";
2
- export async function getNodeAddresses(kyOptions) {
3
- const response = await http(kyOptions, {
4
- path: 'addresses',
2
+ export async function getNodeAddresses(requestOptions) {
3
+ const response = await http(requestOptions, {
4
+ url: 'addresses',
5
5
  responseType: 'json'
6
6
  });
7
- return response.parsedData;
7
+ return response.data;
8
8
  }
9
- export async function getPeers(kyOptions) {
10
- const response = await http(kyOptions, {
11
- path: 'peers',
9
+ export async function getPeers(requestOptions) {
10
+ const response = await http(requestOptions, {
11
+ url: 'peers',
12
12
  responseType: 'json'
13
13
  });
14
- return response.parsedData.peers;
14
+ return response.data.peers;
15
15
  }
16
- export async function getBlocklist(kyOptions) {
17
- const response = await http(kyOptions, {
18
- path: 'blocklist',
16
+ export async function getBlocklist(requestOptions) {
17
+ const response = await http(requestOptions, {
18
+ url: 'blocklist',
19
19
  responseType: 'json'
20
20
  });
21
- return response.parsedData.peers;
21
+ return response.data.peers;
22
22
  }
23
- export async function removePeer(kyOptions, peer) {
24
- const response = await http(kyOptions, {
25
- path: `peers/${peer}`,
23
+ export async function removePeer(requestOptions, peer) {
24
+ const response = await http(requestOptions, {
25
+ url: `peers/${peer}`,
26
26
  responseType: 'json',
27
27
  method: 'DELETE'
28
28
  });
29
- return response.parsedData;
29
+ return response.data;
30
30
  }
31
- export async function getTopology(kyOptions) {
32
- const response = await http(kyOptions, {
33
- path: `topology`,
31
+ export async function getTopology(requestOptions) {
32
+ const response = await http(requestOptions, {
33
+ url: `topology`,
34
34
  responseType: 'json'
35
35
  });
36
- return response.parsedData;
36
+ return response.data;
37
37
  }
38
- export async function pingPeer(kyOptions, peer) {
39
- const response = await http(kyOptions, {
40
- path: `pingpong/${peer}`,
38
+ export async function pingPeer(requestOptions, peer) {
39
+ const response = await http(requestOptions, {
40
+ url: `pingpong/${peer}`,
41
41
  responseType: 'json',
42
42
  method: 'POST'
43
43
  });
44
- return response.parsedData;
44
+ return response.data;
45
45
  }
@@ -6,22 +6,22 @@ const settlementsEndpoint = 'settlements';
6
6
  * @param kyOptions Ky Options for making requests
7
7
  * @param peer Swarm address of peer
8
8
  */
9
- export async function getSettlements(kyOptions, peer) {
10
- const response = await http(kyOptions, {
11
- path: `${settlementsEndpoint}/${peer}`,
9
+ export async function getSettlements(requestOptions, peer) {
10
+ const response = await http(requestOptions, {
11
+ url: `${settlementsEndpoint}/${peer}`,
12
12
  responseType: 'json'
13
13
  });
14
- return response.parsedData;
14
+ return response.data;
15
15
  }
16
16
  /**
17
17
  * Get settlements with all known peers and total amount sent or received
18
18
  *
19
19
  * @param kyOptions Ky Options for making requests
20
20
  */
21
- export async function getAllSettlements(kyOptions) {
22
- const response = await http(kyOptions, {
23
- path: settlementsEndpoint,
21
+ export async function getAllSettlements(requestOptions) {
22
+ const response = await http(requestOptions, {
23
+ url: settlementsEndpoint,
24
24
  responseType: 'json'
25
25
  });
26
- return response.parsedData;
26
+ return response.data;
27
27
  }
@@ -6,13 +6,13 @@ const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
6
6
  *
7
7
  * @param kyOptions Ky Options for making requests
8
8
  */
9
- export async function getStake(kyOptions) {
10
- const response = await http(kyOptions, {
9
+ export async function getStake(requestOptions) {
10
+ const response = await http(requestOptions, {
11
11
  method: 'get',
12
12
  responseType: 'json',
13
- path: `${STAKE_ENDPOINT}`
13
+ url: `${STAKE_ENDPOINT}`
14
14
  });
15
- return response.parsedData.stakedAmount.toString();
15
+ return response.data.stakedAmount.toString();
16
16
  }
17
17
  /**
18
18
  * Stake given amount of tokens.
@@ -21,7 +21,7 @@ export async function getStake(kyOptions) {
21
21
  * @param amount
22
22
  * @param options
23
23
  */
24
- export async function stake(kyOptions, amount, options) {
24
+ export async function stake(requestOptions, amount, options) {
25
25
  const headers = {};
26
26
  if (options?.gasPrice) {
27
27
  headers['gas-price'] = options.gasPrice.toString();
@@ -29,10 +29,10 @@ export async function stake(kyOptions, amount, options) {
29
29
  if (options?.gasLimit) {
30
30
  headers['gas-limit'] = options.gasLimit.toString();
31
31
  }
32
- await http(kyOptions, {
32
+ await http(requestOptions, {
33
33
  method: 'post',
34
34
  responseType: 'json',
35
- path: `${STAKE_ENDPOINT}/${amount}`,
35
+ url: `${STAKE_ENDPOINT}/${amount}`,
36
36
  headers
37
37
  });
38
38
  }
@@ -41,11 +41,11 @@ export async function stake(kyOptions, amount, options) {
41
41
  *
42
42
  * @param kyOptions Ky Options for making requests
43
43
  */
44
- export async function getRedistributionState(kyOptions) {
45
- const response = await http(kyOptions, {
44
+ export async function getRedistributionState(requestOptions) {
45
+ const response = await http(requestOptions, {
46
46
  method: 'get',
47
47
  responseType: 'json',
48
- path: REDISTRIBUTION_ENDPOINT
48
+ url: REDISTRIBUTION_ENDPOINT
49
49
  });
50
- return response.parsedData;
50
+ return response.data;
51
51
  }