@ethersphere/bee-js 6.0.0-pre.0 → 6.0.0-pre.10

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 (193) hide show
  1. package/README.md +18 -17
  2. package/dist/cjs/bee-debug.js +572 -0
  3. package/dist/cjs/bee.js +876 -0
  4. package/dist/cjs/chunk/bmt.js +55 -0
  5. package/dist/cjs/chunk/cac.js +56 -0
  6. package/dist/cjs/chunk/serialize.js +19 -0
  7. package/dist/cjs/chunk/signer.js +126 -0
  8. package/dist/cjs/chunk/soc.js +159 -0
  9. package/dist/cjs/chunk/span.js +29 -0
  10. package/dist/cjs/feed/identifier.js +35 -0
  11. package/dist/cjs/feed/index.js +116 -0
  12. package/dist/cjs/feed/json.js +28 -0
  13. package/dist/cjs/feed/retrievable.js +58 -0
  14. package/dist/cjs/feed/topic.js +25 -0
  15. package/dist/cjs/feed/type.js +15 -0
  16. package/dist/cjs/index.js +39 -0
  17. package/dist/cjs/modules/bytes.js +61 -0
  18. package/dist/cjs/modules/bzz.js +125 -0
  19. package/dist/cjs/modules/chunk.js +48 -0
  20. package/dist/cjs/modules/debug/balance.js +60 -0
  21. package/dist/cjs/modules/debug/chequebook.js +142 -0
  22. package/dist/cjs/modules/debug/chunk.js +38 -0
  23. package/dist/cjs/modules/debug/connectivity.js +54 -0
  24. package/dist/cjs/modules/debug/settlements.js +32 -0
  25. package/dist/cjs/modules/debug/stake.js +57 -0
  26. package/dist/cjs/modules/debug/stamps.js +68 -0
  27. package/dist/cjs/modules/debug/states.js +64 -0
  28. package/dist/cjs/modules/debug/status.js +148 -0
  29. package/dist/cjs/modules/debug/tag.js +19 -0
  30. package/dist/cjs/modules/debug/transactions.js +64 -0
  31. package/dist/cjs/modules/feed.js +66 -0
  32. package/dist/cjs/modules/pinning.js +63 -0
  33. package/dist/cjs/modules/pss.js +43 -0
  34. package/dist/cjs/modules/soc.js +32 -0
  35. package/dist/cjs/modules/status.js +15 -0
  36. package/dist/cjs/modules/stewardship.js +28 -0
  37. package/dist/cjs/modules/tag.js +77 -0
  38. package/dist/cjs/package.json +8 -0
  39. package/dist/cjs/types/debug.js +10 -0
  40. package/dist/cjs/types/index.js +51 -0
  41. package/dist/cjs/utils/bytes.js +121 -0
  42. package/dist/cjs/utils/collection.browser.js +23 -0
  43. package/dist/cjs/utils/collection.js +59 -0
  44. package/dist/cjs/utils/collection.node.js +71 -0
  45. package/dist/cjs/utils/data.browser.js +61 -0
  46. package/dist/cjs/utils/data.js +45 -0
  47. package/dist/cjs/utils/error.js +16 -0
  48. package/dist/cjs/utils/eth.js +199 -0
  49. package/dist/cjs/utils/expose.js +44 -0
  50. package/dist/cjs/utils/file.js +38 -0
  51. package/dist/cjs/utils/hash.js +21 -0
  52. package/dist/cjs/utils/headers.js +59 -0
  53. package/dist/cjs/utils/hex.js +150 -0
  54. package/dist/cjs/utils/http.js +40 -0
  55. package/dist/cjs/utils/pss.js +18 -0
  56. package/dist/cjs/utils/reference.js +36 -0
  57. package/dist/cjs/utils/stamps.js +17 -0
  58. package/dist/cjs/utils/stream.js +146 -0
  59. package/dist/cjs/utils/tar.js +25 -0
  60. package/dist/cjs/utils/type.js +434 -0
  61. package/dist/cjs/utils/uint64.js +29 -0
  62. package/dist/cjs/utils/url.js +56 -0
  63. package/dist/index.browser.min.js +3 -0
  64. package/dist/index.browser.min.js.LICENSE.txt +50 -0
  65. package/dist/index.browser.min.js.map +1 -0
  66. package/dist/{src → mjs}/bee-debug.js +102 -183
  67. package/dist/{src → mjs}/bee.js +82 -232
  68. package/dist/{src → mjs}/chunk/bmt.js +4 -10
  69. package/dist/{src → mjs}/chunk/cac.js +0 -3
  70. package/dist/{src → mjs}/chunk/signer.js +1 -18
  71. package/dist/{src → mjs}/chunk/soc.js +17 -29
  72. package/dist/{src → mjs}/chunk/span.js +2 -5
  73. package/dist/{src → mjs}/feed/identifier.js +0 -6
  74. package/dist/{src → mjs}/feed/index.js +24 -27
  75. package/dist/{src → mjs}/feed/json.js +2 -5
  76. package/dist/{src → mjs}/feed/retrievable.js +7 -21
  77. package/dist/{src → mjs}/feed/topic.js +0 -2
  78. package/dist/{src → mjs}/index.js +2 -2
  79. package/dist/{src → mjs}/modules/bytes.js +16 -20
  80. package/dist/{src → mjs}/modules/bzz.js +33 -40
  81. package/dist/{src → mjs}/modules/chunk.js +11 -13
  82. package/dist/mjs/modules/debug/balance.js +53 -0
  83. package/dist/mjs/modules/debug/chequebook.js +135 -0
  84. package/dist/{src → mjs}/modules/debug/chunk.js +10 -12
  85. package/dist/mjs/modules/debug/connectivity.js +45 -0
  86. package/dist/mjs/modules/debug/settlements.js +27 -0
  87. package/dist/mjs/modules/debug/stake.js +51 -0
  88. package/dist/mjs/modules/debug/stamps.js +61 -0
  89. package/dist/mjs/modules/debug/states.js +58 -0
  90. package/dist/{src → mjs}/modules/debug/status.js +46 -37
  91. package/dist/mjs/modules/debug/tag.js +15 -0
  92. package/dist/mjs/modules/debug/transactions.js +59 -0
  93. package/dist/{src → mjs}/modules/feed.js +15 -21
  94. package/dist/mjs/modules/pinning.js +56 -0
  95. package/dist/{src → mjs}/modules/pss.js +7 -10
  96. package/dist/{src → mjs}/modules/soc.js +6 -7
  97. package/dist/mjs/modules/status.js +11 -0
  98. package/dist/mjs/modules/stewardship.js +23 -0
  99. package/dist/mjs/modules/tag.js +72 -0
  100. package/dist/mjs/package.json +8 -0
  101. package/dist/{src → mjs}/types/debug.js +0 -1
  102. package/dist/{src → mjs}/types/index.js +0 -4
  103. package/dist/{src → mjs}/utils/bytes.js +8 -17
  104. package/dist/{src/utils/collection-browser.js → mjs/utils/collection.browser.js} +0 -1
  105. package/dist/{src → mjs}/utils/collection.js +0 -12
  106. package/dist/{src/utils/collection-node.js → mjs/utils/collection.node.js} +0 -13
  107. package/dist/{src → mjs}/utils/data.browser.js +2 -11
  108. package/dist/{src → mjs}/utils/data.js +0 -7
  109. package/dist/mjs/utils/error.js +11 -0
  110. package/dist/{src → mjs}/utils/eth.js +6 -28
  111. package/dist/{src → mjs}/utils/expose.js +1 -1
  112. package/dist/{src → mjs}/utils/file.js +4 -9
  113. package/dist/{src → mjs}/utils/hash.js +0 -1
  114. package/dist/{src → mjs}/utils/headers.js +5 -13
  115. package/dist/{src → mjs}/utils/hex.js +6 -25
  116. package/dist/mjs/utils/http.js +34 -0
  117. package/dist/{src → mjs}/utils/pss.js +0 -2
  118. package/dist/{src → mjs}/utils/reference.js +2 -5
  119. package/dist/{src → mjs}/utils/stream.js +3 -26
  120. package/dist/{src → mjs}/utils/tar.js +3 -6
  121. package/dist/{src → mjs}/utils/type.js +23 -80
  122. package/dist/{src → mjs}/utils/uint64.js +0 -1
  123. package/dist/{src → mjs}/utils/url.js +2 -10
  124. package/dist/types/bee-debug.d.ts +71 -46
  125. package/dist/types/bee.d.ts +34 -58
  126. package/dist/types/chunk/bmt.d.ts +1 -1
  127. package/dist/types/chunk/cac.d.ts +1 -1
  128. package/dist/types/chunk/soc.d.ts +9 -9
  129. package/dist/types/chunk/span.d.ts +1 -1
  130. package/dist/types/feed/index.d.ts +10 -10
  131. package/dist/types/feed/json.d.ts +2 -2
  132. package/dist/types/feed/retrievable.d.ts +2 -2
  133. package/dist/types/feed/type.d.ts +1 -1
  134. package/dist/types/index.d.ts +13 -2
  135. package/dist/types/modules/bytes.d.ts +5 -5
  136. package/dist/types/modules/bzz.d.ts +8 -8
  137. package/dist/types/modules/chunk.d.ts +4 -4
  138. package/dist/types/modules/debug/balance.d.ts +9 -9
  139. package/dist/types/modules/debug/chequebook.d.ts +17 -17
  140. package/dist/types/modules/debug/chunk.d.ts +5 -5
  141. package/dist/types/modules/debug/connectivity.d.ts +7 -7
  142. package/dist/types/modules/debug/settlements.d.ts +5 -5
  143. package/dist/types/modules/debug/stake.d.ts +21 -0
  144. package/dist/types/modules/debug/stamps.d.ts +7 -7
  145. package/dist/types/modules/debug/states.d.ts +7 -7
  146. package/dist/types/modules/debug/status.d.ts +21 -15
  147. package/dist/types/modules/debug/tag.d.ts +3 -3
  148. package/dist/types/modules/debug/transactions.d.ts +5 -5
  149. package/dist/types/modules/feed.d.ts +3 -3
  150. package/dist/types/modules/pinning.d.ts +7 -7
  151. package/dist/types/modules/pss.d.ts +3 -3
  152. package/dist/types/modules/soc.d.ts +2 -2
  153. package/dist/types/modules/status.d.ts +3 -3
  154. package/dist/types/modules/stewardship.d.ts +3 -3
  155. package/dist/types/modules/tag.d.ts +6 -6
  156. package/dist/types/types/debug.d.ts +35 -2
  157. package/dist/types/types/index.d.ts +48 -89
  158. package/dist/types/utils/error.d.ts +0 -26
  159. package/dist/types/utils/eth.d.ts +6 -6
  160. package/dist/types/utils/expose.d.ts +4 -7
  161. package/dist/types/utils/hash.d.ts +1 -1
  162. package/dist/types/utils/headers.d.ts +1 -1
  163. package/dist/types/utils/hex.d.ts +4 -4
  164. package/dist/types/utils/http.d.ts +11 -21
  165. package/dist/types/utils/stream.d.ts +1 -1
  166. package/dist/types/utils/type.d.ts +3 -2
  167. package/dist/types/utils/uint64.d.ts +1 -1
  168. package/package.json +59 -52
  169. package/dist/index.browser.js +0 -33
  170. package/dist/index.browser.js.map +0 -7
  171. package/dist/src/modules/debug/balance.js +0 -57
  172. package/dist/src/modules/debug/chequebook.js +0 -150
  173. package/dist/src/modules/debug/connectivity.js +0 -45
  174. package/dist/src/modules/debug/settlements.js +0 -29
  175. package/dist/src/modules/debug/stamps.js +0 -64
  176. package/dist/src/modules/debug/states.js +0 -46
  177. package/dist/src/modules/debug/tag.js +0 -16
  178. package/dist/src/modules/debug/transactions.js +0 -69
  179. package/dist/src/modules/pinning.js +0 -60
  180. package/dist/src/modules/status.js +0 -12
  181. package/dist/src/modules/stewardship.js +0 -24
  182. package/dist/src/modules/tag.js +0 -77
  183. package/dist/src/utils/error.js +0 -47
  184. package/dist/src/utils/http.js +0 -162
  185. package/dist/src/utils/merge.js +0 -36
  186. package/dist/src/utils/sleep.js +0 -8
  187. package/dist/types/utils/merge.d.ts +0 -8
  188. package/dist/types/utils/sleep.d.ts +0 -6
  189. /package/dist/{src → mjs}/chunk/serialize.js +0 -0
  190. /package/dist/{src → mjs}/feed/type.js +0 -0
  191. /package/dist/{src → mjs}/utils/stamps.js +0 -0
  192. /package/dist/types/utils/{collection-browser.d.ts → collection.browser.d.ts} +0 -0
  193. /package/dist/types/utils/{collection-node.d.ts → collection.node.d.ts} +0 -0
@@ -1,57 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- const balancesEndpoint = 'balances';
3
- const consumedEndpoint = 'consumed';
4
- /**
5
- * Get the balances with all known peers including prepaid services
6
- *
7
- * @param ky Ky debug instance
8
- */
9
-
10
- export async function getAllBalances(ky) {
11
- const response = await http(ky, {
12
- path: balancesEndpoint,
13
- responseType: 'json'
14
- });
15
- return response.parsedData;
16
- }
17
- /**
18
- * Get the balances with a specific peer including prepaid services
19
- *
20
- * @param ky Ky debug instance
21
- * @param address Swarm address of peer
22
- */
23
-
24
- export async function getPeerBalance(ky, address) {
25
- const response = await http(ky, {
26
- path: `${balancesEndpoint}/${address}`,
27
- responseType: 'json'
28
- });
29
- return response.parsedData;
30
- }
31
- /**
32
- * Get the past due consumption balances with all known peers
33
- *
34
- * @param ky Ky debug instance
35
- */
36
-
37
- export async function getPastDueConsumptionBalances(ky) {
38
- const response = await http(ky, {
39
- path: consumedEndpoint,
40
- responseType: 'json'
41
- });
42
- return response.parsedData;
43
- }
44
- /**
45
- * Get the past due consumption balance with a specific peer
46
- *
47
- * @param ky Ky debug instance
48
- * @param address Swarm address of peer
49
- */
50
-
51
- export async function getPastDueConsumptionPeerBalance(ky, address) {
52
- const response = await http(ky, {
53
- path: `${consumedEndpoint}/${address}`,
54
- responseType: 'json'
55
- });
56
- return response.parsedData;
57
- }
@@ -1,150 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- const chequebookEndpoint = 'chequebook';
3
- /**
4
- * Get the address of the chequebook contract used
5
- *
6
- * @param ky Ky debug instance
7
- */
8
-
9
- export async function getChequebookAddress(ky) {
10
- const response = await http(ky, {
11
- path: chequebookEndpoint + '/address',
12
- responseType: 'json'
13
- });
14
- return response.parsedData;
15
- }
16
- /**
17
- * Get the balance of the chequebook
18
- *
19
- * @param ky Ky debug instance
20
- */
21
-
22
- export async function getChequebookBalance(ky) {
23
- const response = await http(ky, {
24
- path: chequebookEndpoint + '/balance',
25
- responseType: 'json'
26
- });
27
- return response.parsedData;
28
- }
29
- /**
30
- * Get last cashout action for the peer
31
- *
32
- * @param ky Ky debug instance
33
- * @param peer Swarm address of peer
34
- */
35
-
36
- export async function getLastCashoutAction(ky, peer) {
37
- const response = await http(ky, {
38
- path: chequebookEndpoint + `/cashout/${peer}`,
39
- responseType: 'json'
40
- });
41
- return response.parsedData;
42
- }
43
- /**
44
- * Cashout the last cheque for the peer
45
- *
46
- * @param ky Ky debug instance
47
- * @param peer Swarm address of peer
48
- * @param options
49
- */
50
-
51
- export async function cashoutLastCheque(ky, peer, options) {
52
- const headers = {};
53
-
54
- if (options?.gasPrice) {
55
- headers['gas-price'] = options.gasPrice.toString();
56
- }
57
-
58
- if (options?.gasLimit) {
59
- headers['gas-limit'] = options.gasLimit.toString();
60
- }
61
-
62
- const response = await http(ky, {
63
- method: 'post',
64
- path: chequebookEndpoint + `/cashout/${peer}`,
65
- responseType: 'json',
66
- headers
67
- });
68
- return response.parsedData.transactionHash;
69
- }
70
- /**
71
- * Get last cheques for the peer
72
- *
73
- * @param ky Ky debug instance
74
- * @param peer Swarm address of peer
75
- */
76
-
77
- export async function getLastChequesForPeer(ky, peer) {
78
- const response = await http(ky, {
79
- path: chequebookEndpoint + `/cheque/${peer}`,
80
- responseType: 'json'
81
- });
82
- return response.parsedData;
83
- }
84
- /**
85
- * Get last cheques for all peers
86
- *
87
- * @param ky Ky debug instance
88
- */
89
-
90
- export async function getLastCheques(ky) {
91
- const response = await http(ky, {
92
- path: chequebookEndpoint + '/cheque',
93
- responseType: 'json'
94
- });
95
- return response.parsedData;
96
- }
97
- /**
98
- * Deposit tokens from overlay address into chequebook
99
- *
100
- * @param ky Ky debug instance
101
- * @param amount Amount of tokens to deposit
102
- * @param gasPrice Gas Price in WEI for the transaction call
103
- * @return string Hash of the transaction
104
- */
105
-
106
- export async function depositTokens(ky, amount, gasPrice) {
107
- const headers = {};
108
-
109
- if (gasPrice) {
110
- headers['gas-price'] = gasPrice.toString();
111
- }
112
-
113
- const response = await http(ky, {
114
- method: 'post',
115
- path: chequebookEndpoint + '/deposit',
116
- responseType: 'json',
117
- searchParams: {
118
- amount: amount.toString(10)
119
- },
120
- headers
121
- });
122
- return response.parsedData.transactionHash;
123
- }
124
- /**
125
- * Withdraw tokens from the chequebook to the overlay address
126
- *
127
- * @param ky Ky debug instance
128
- * @param amount Amount of tokens to withdraw
129
- * @param gasPrice Gas Price in WEI for the transaction call
130
- * @return string Hash of the transaction
131
- */
132
-
133
- export async function withdrawTokens(ky, amount, gasPrice) {
134
- const headers = {};
135
-
136
- if (gasPrice) {
137
- headers['gas-price'] = gasPrice.toString();
138
- }
139
-
140
- const response = await http(ky, {
141
- method: 'post',
142
- path: chequebookEndpoint + '/withdraw',
143
- responseType: 'json',
144
- searchParams: {
145
- amount: amount.toString(10)
146
- },
147
- headers
148
- });
149
- return response.parsedData.transactionHash;
150
- }
@@ -1,45 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- export async function getNodeAddresses(ky) {
3
- const response = await http(ky, {
4
- path: 'addresses',
5
- responseType: 'json'
6
- });
7
- return response.parsedData;
8
- }
9
- export async function getPeers(ky) {
10
- const response = await http(ky, {
11
- path: 'peers',
12
- responseType: 'json'
13
- });
14
- return response.parsedData.peers;
15
- }
16
- export async function getBlocklist(ky) {
17
- const response = await http(ky, {
18
- path: 'blocklist',
19
- responseType: 'json'
20
- });
21
- return response.parsedData.peers;
22
- }
23
- export async function removePeer(ky, peer) {
24
- const response = await http(ky, {
25
- path: `peers/${peer}`,
26
- responseType: 'json',
27
- method: 'DELETE'
28
- });
29
- return response.parsedData;
30
- }
31
- export async function getTopology(ky) {
32
- const response = await http(ky, {
33
- path: `topology`,
34
- responseType: 'json'
35
- });
36
- return response.parsedData;
37
- }
38
- export async function pingPeer(ky, peer) {
39
- const response = await http(ky, {
40
- path: `pingpong/${peer}`,
41
- responseType: 'json',
42
- method: 'POST'
43
- });
44
- return response.parsedData;
45
- }
@@ -1,29 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- const settlementsEndpoint = 'settlements';
3
- /**
4
- * Get amount of sent and received from settlements with a peer
5
- *
6
- * @param ky Ky debug instance
7
- * @param peer Swarm address of peer
8
- */
9
-
10
- export async function getSettlements(ky, peer) {
11
- const response = await http(ky, {
12
- path: `${settlementsEndpoint}/${peer}`,
13
- responseType: 'json'
14
- });
15
- return response.parsedData;
16
- }
17
- /**
18
- * Get settlements with all known peers and total amount sent or received
19
- *
20
- * @param ky Ky debug instance
21
- */
22
-
23
- export async function getAllSettlements(ky) {
24
- const response = await http(ky, {
25
- path: settlementsEndpoint,
26
- responseType: 'json'
27
- });
28
- return response.parsedData;
29
- }
@@ -1,64 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- const STAMPS_ENDPOINT = 'stamps';
3
- export async function getAllPostageBatches(ky) {
4
- const response = await http(ky, {
5
- method: 'get',
6
- path: `${STAMPS_ENDPOINT}`,
7
- responseType: 'json'
8
- });
9
- return response.parsedData.stamps;
10
- }
11
- export async function getPostageBatch(ky, postageBatchId) {
12
- const response = await http(ky, {
13
- method: 'get',
14
- path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
15
- responseType: 'json'
16
- });
17
- return response.parsedData;
18
- }
19
- export async function getPostageBatchBuckets(ky, postageBatchId) {
20
- const response = await http(ky, {
21
- method: 'get',
22
- path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
23
- responseType: 'json'
24
- });
25
- return response.parsedData;
26
- }
27
- export async function createPostageBatch(ky, amount, depth, options) {
28
- const headers = {};
29
-
30
- if (options?.gasPrice) {
31
- headers['gas-price'] = options.gasPrice.toString();
32
- }
33
-
34
- if (options?.immutableFlag !== undefined) {
35
- headers.immutable = String(options.immutableFlag);
36
- }
37
-
38
- const response = await http(ky, {
39
- method: 'post',
40
- path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
41
- responseType: 'json',
42
- searchParams: {
43
- label: options?.label
44
- },
45
- headers
46
- });
47
- return response.parsedData.batchID;
48
- }
49
- export async function topUpBatch(ky, id, amount) {
50
- const response = await http(ky, {
51
- method: 'patch',
52
- path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
53
- responseType: 'json'
54
- });
55
- return response.parsedData.batchID;
56
- }
57
- export async function diluteBatch(ky, id, depth) {
58
- const response = await http(ky, {
59
- method: 'patch',
60
- path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
61
- responseType: 'json'
62
- });
63
- return response.parsedData.batchID;
64
- }
@@ -1,46 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- const RESERVE_STATE_ENDPOINT = 'reservestate';
3
- const WALLET_ENDPOINT = 'wallet';
4
- const CHAIN_STATE_ENDPOINT = 'chainstate';
5
- /**
6
- * Get state of reserve
7
- *
8
- * @param ky Ky debug instance
9
- */
10
-
11
- export async function getReserveState(ky) {
12
- const response = await http(ky, {
13
- method: 'get',
14
- path: `${RESERVE_STATE_ENDPOINT}`,
15
- responseType: 'json'
16
- });
17
- return response.parsedData;
18
- }
19
- /**
20
- * Get state of reserve
21
- *
22
- * @param ky Ky debug instance
23
- */
24
-
25
- export async function getChainState(ky) {
26
- const response = await http(ky, {
27
- method: 'get',
28
- path: `${CHAIN_STATE_ENDPOINT}`,
29
- responseType: 'json'
30
- });
31
- return response.parsedData;
32
- }
33
- /**
34
- * Get wallet balances for xDai and BZZ of the node
35
- *
36
- * @param ky Ky debug instance
37
- */
38
-
39
- export async function getWalletBalance(ky) {
40
- const response = await http(ky, {
41
- method: 'get',
42
- path: `${WALLET_ENDPOINT}`,
43
- responseType: 'json'
44
- });
45
- return response.parsedData;
46
- }
@@ -1,16 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- const endpoint = 'tags';
3
- /**
4
- * Retrieve tag with extended information from Bee node
5
- *
6
- * @param ky Ky debug instance
7
- * @param uid UID of tag to be retrieved
8
- */
9
-
10
- export async function retrieveExtendedTag(ky, uid) {
11
- const response = await http(ky, {
12
- path: `${endpoint}/${uid}`,
13
- responseType: 'json'
14
- });
15
- return response.parsedData;
16
- }
@@ -1,69 +0,0 @@
1
- import { http } from "../../utils/http.js";
2
- const transactionsEndpoint = 'transactions';
3
- /**
4
- * Get list of all pending transactions
5
- *
6
- * @param ky Debug Ky instance
7
- */
8
-
9
- export async function getAllTransactions(ky) {
10
- const response = await http(ky, {
11
- path: transactionsEndpoint,
12
- responseType: 'json'
13
- });
14
- return response.parsedData.pendingTransactions;
15
- }
16
- /**
17
- * Get information for specific pending transactions
18
- *
19
- * @param ky Debug Ky instance
20
- * @param transactionHash Hash of the transaction
21
- */
22
-
23
- export async function getTransaction(ky, transactionHash) {
24
- const response = await http(ky, {
25
- path: `${transactionsEndpoint}/${transactionHash}`,
26
- responseType: 'json'
27
- });
28
- return response.parsedData;
29
- }
30
- /**
31
- * Rebroadcast existing transaction
32
- *
33
- * @param ky Debug Ky instance
34
- * @param transactionHash Hash of the transaction
35
- */
36
-
37
- export async function rebroadcastTransaction(ky, transactionHash) {
38
- const response = await http(ky, {
39
- method: 'post',
40
- path: `${transactionsEndpoint}/${transactionHash}`,
41
- responseType: 'json'
42
- });
43
- return response.parsedData.transactionHash;
44
- }
45
- /**
46
- * Cancel existing transaction
47
- *
48
- * @param ky Debug Ky instance
49
- * @param transactionHash Hash of the transaction
50
- * @param gasPrice Optional gas price
51
- */
52
-
53
- export async function cancelTransaction(ky, transactionHash, gasPrice) {
54
- let headers;
55
-
56
- if (gasPrice) {
57
- headers = {
58
- 'gas-price': gasPrice
59
- };
60
- }
61
-
62
- const response = await http(ky, {
63
- method: 'delete',
64
- headers,
65
- path: `${transactionsEndpoint}/${transactionHash}`,
66
- responseType: 'json'
67
- });
68
- return response.parsedData.transactionHash;
69
- }
@@ -1,60 +0,0 @@
1
- import { http } from "../utils/http.js";
2
- const PINNING_ENDPOINT = 'pins';
3
- /**
4
- * Pin data with given reference
5
- *
6
- * @param ky Ky instance for given Bee class instance
7
- * @param reference Bee data reference
8
- */
9
-
10
- export async function pin(ky, reference) {
11
- await http(ky, {
12
- method: 'post',
13
- responseType: 'json',
14
- path: `${PINNING_ENDPOINT}/${reference}`
15
- });
16
- }
17
- /**
18
- * Unpin data with given reference
19
- *
20
- * @param ky Ky instance for given Bee class instance
21
- * @param reference Bee data reference
22
- */
23
-
24
- export async function unpin(ky, reference) {
25
- await http(ky, {
26
- method: 'delete',
27
- responseType: 'json',
28
- path: `${PINNING_ENDPOINT}/${reference}`
29
- });
30
- }
31
- /**
32
- * Get pin status for specific address.
33
- *
34
- * @param ky Ky instance
35
- * @param reference
36
- * @throws Error if given address is not pinned
37
- */
38
-
39
- export async function getPin(ky, reference) {
40
- const response = await http(ky, {
41
- method: 'get',
42
- responseType: 'json',
43
- path: `${PINNING_ENDPOINT}/${reference}`
44
- });
45
- return response.parsedData;
46
- }
47
- /**
48
- * Get list of all pins
49
- *
50
- * @param ky Ky instance
51
- */
52
-
53
- export async function getAllPins(ky) {
54
- const response = await http(ky, {
55
- method: 'get',
56
- responseType: 'json',
57
- path: `${PINNING_ENDPOINT}`
58
- });
59
- return response.parsedData.references;
60
- }
@@ -1,12 +0,0 @@
1
- import { http } from "../utils/http.js";
2
- /**
3
- * Ping the base bee URL. If connection was not successful throw error
4
- *
5
- * @param ky Ky instance for given Bee class instance
6
- */
7
-
8
- export async function checkConnection(ky) {
9
- await http(ky, {
10
- path: ''
11
- });
12
- }
@@ -1,24 +0,0 @@
1
- import { http } from "../utils/http.js";
2
- const stewardshipEndpoint = 'stewardship';
3
- /**
4
- * Reupload locally pinned data
5
- * @param ky Ky instance
6
- * @param reference
7
- * @param options
8
- * @throws BeeResponseError if not locally pinned or invalid data
9
- */
10
-
11
- export async function reupload(ky, reference) {
12
- await http(ky, {
13
- method: 'put',
14
- path: `${stewardshipEndpoint}/${reference}`
15
- });
16
- }
17
- export async function isRetrievable(ky, reference) {
18
- const response = await http(ky, {
19
- method: 'get',
20
- responseType: 'json',
21
- path: `${stewardshipEndpoint}/${reference}`
22
- });
23
- return response.parsedData.isRetrievable;
24
- }
@@ -1,77 +0,0 @@
1
- import { http } from "../utils/http.js";
2
- const endpoint = 'tags';
3
- /**
4
- * Create new tag on the Bee node
5
- *
6
- * @param url Bee tag URL
7
- */
8
-
9
- export async function createTag(ky) {
10
- const response = await http(ky, {
11
- method: 'post',
12
- path: endpoint,
13
- responseType: 'json'
14
- });
15
- return response.parsedData;
16
- }
17
- /**
18
- * Retrieve tag information from Bee node
19
- *
20
- * @param url Bee tag URL
21
- * @param uid UID of tag to be retrieved
22
- */
23
-
24
- export async function retrieveTag(ky, uid) {
25
- const response = await http(ky, {
26
- path: `${endpoint}/${uid}`,
27
- responseType: 'json'
28
- });
29
- return response.parsedData;
30
- }
31
- /**
32
- * Get limited listing of all tags.
33
- *
34
- * @param url
35
- * @param offset
36
- * @param limit
37
- */
38
-
39
- export async function getAllTags(ky, offset, limit) {
40
- const response = await http(ky, {
41
- path: `${endpoint}`,
42
- searchParams: {
43
- offset,
44
- limit
45
- },
46
- responseType: 'json'
47
- });
48
- return response.parsedData.tags;
49
- }
50
- /**
51
- * Removes tag from the Bee node.
52
- * @param url
53
- * @param uid
54
- */
55
-
56
- export async function deleteTag(ky, uid) {
57
- await http(ky, {
58
- method: 'delete',
59
- path: `${endpoint}/${uid}`
60
- });
61
- }
62
- /**
63
- * Updates tag
64
- * @param url
65
- * @param uid
66
- * @param reference
67
- */
68
-
69
- export async function updateTag(ky, uid, reference) {
70
- await http(ky, {
71
- method: 'patch',
72
- path: `${endpoint}/${uid}`,
73
- json: {
74
- reference
75
- }
76
- });
77
- }
@@ -1,47 +0,0 @@
1
- export class BeeError extends Error {
2
- constructor(message) {
3
- super(message);
4
- }
5
-
6
- }
7
- export class BeeArgumentError extends BeeError {
8
- constructor(message, value) {
9
- super(message);
10
- this.value = value;
11
- }
12
-
13
- }
14
- export class BeeRequestError extends BeeError {
15
- /**
16
- * @param message
17
- * @param requestOptions KyOptions that were used to assemble the request. THIS MIGHT NOT BE COMPLETE! If custom Ky instance was used that has set defaults then these defaults are not visible in this object!
18
- */
19
- constructor(message, requestOptions) {
20
- super(message);
21
- this.requestOptions = requestOptions;
22
- }
23
-
24
- }
25
- export class BeeResponseError extends BeeError {
26
- /**
27
- * @param status HTTP status code number
28
- * @param response Response returned from the server
29
- * @param responseBody Response body as string which is returned from response.text() call
30
- * @param requestOptions KyOptions that were used to assemble the request. THIS MIGHT NOT BE COMPLETE! If custom Ky instance was used that has set defaults then these defaults are not visible in this object!
31
- * @param message
32
- */
33
- constructor(status, response, responseBody, requestOptions, message) {
34
- super(message);
35
- this.status = status;
36
- this.response = response;
37
- this.responseBody = responseBody;
38
- this.requestOptions = requestOptions;
39
- }
40
-
41
- }
42
- export class BeeNotAJsonError extends BeeError {
43
- constructor() {
44
- super(`Received response is not valid JSON.`);
45
- }
46
-
47
- }