@ethersphere/bee-js 3.3.0 → 3.3.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 (85) hide show
  1. package/dist/cjs/chunk/bmt.js +7 -2
  2. package/dist/cjs/chunk/signer.js +9 -4
  3. package/dist/cjs/modules/debug/status.js +5 -5
  4. package/dist/cjs/package.json +1 -0
  5. package/dist/cjs/types/ky-options.js +8 -0
  6. package/dist/cjs/types/ky-universal/common.js +8 -0
  7. package/dist/cjs/types/ky-universal/hooks.js +8 -0
  8. package/dist/cjs/types/ky-universal/retry.js +8 -0
  9. package/dist/cjs/utils/eth.js +8 -3
  10. package/dist/cjs/utils/hash.js +7 -2
  11. package/dist/cjs/utils/stream.js +14 -5
  12. package/dist/index.browser.min.js +3 -0
  13. package/dist/index.browser.min.js.LICENSE.txt +52 -0
  14. package/dist/index.browser.min.js.map +1 -0
  15. package/dist/mjs/bee-debug.js +608 -508
  16. package/dist/mjs/bee.js +935 -836
  17. package/dist/mjs/chunk/bmt.js +34 -24
  18. package/dist/mjs/chunk/cac.js +24 -22
  19. package/dist/mjs/chunk/serialize.js +9 -9
  20. package/dist/mjs/chunk/signer.js +92 -73
  21. package/dist/mjs/chunk/soc.js +78 -66
  22. package/dist/mjs/chunk/span.js +19 -16
  23. package/dist/mjs/feed/index.js +110 -101
  24. package/dist/mjs/feed/json.js +21 -17
  25. package/dist/mjs/feed/topic.js +18 -17
  26. package/dist/mjs/feed/type.js +5 -5
  27. package/dist/mjs/index.js +7 -7
  28. package/dist/mjs/modules/bytes.js +33 -30
  29. package/dist/mjs/modules/bzz.js +80 -77
  30. package/dist/mjs/modules/chunk.js +22 -20
  31. package/dist/mjs/modules/debug/balance.js +26 -22
  32. package/dist/mjs/modules/debug/chequebook.js +84 -65
  33. package/dist/mjs/modules/debug/chunk.js +15 -13
  34. package/dist/mjs/modules/debug/connectivity.js +34 -34
  35. package/dist/mjs/modules/debug/settlements.js +14 -12
  36. package/dist/mjs/modules/debug/stamps.js +52 -47
  37. package/dist/mjs/modules/debug/states.js +16 -14
  38. package/dist/mjs/modules/debug/status.js +55 -35
  39. package/dist/mjs/modules/debug/tag.js +8 -7
  40. package/dist/mjs/modules/debug/transactions.js +31 -25
  41. package/dist/mjs/modules/feed.js +39 -33
  42. package/dist/mjs/modules/pinning.js +34 -28
  43. package/dist/mjs/modules/pss.js +18 -14
  44. package/dist/mjs/modules/soc.js +18 -15
  45. package/dist/mjs/modules/status.js +6 -5
  46. package/dist/mjs/modules/stewardship.js +13 -12
  47. package/dist/mjs/modules/tag.js +38 -30
  48. package/dist/mjs/package.json +1 -0
  49. package/dist/mjs/types/debug.js +5 -4
  50. package/dist/mjs/types/index.js +6 -2
  51. package/dist/mjs/types/ky-options.js +7 -0
  52. package/dist/mjs/types/ky-universal/common.js +7 -0
  53. package/dist/mjs/types/ky-universal/hooks.js +7 -0
  54. package/dist/mjs/types/ky-universal/retry.js +7 -0
  55. package/dist/mjs/utils/bytes.js +32 -26
  56. package/dist/mjs/utils/collection.browser.js +4 -3
  57. package/dist/mjs/utils/collection.js +47 -35
  58. package/dist/mjs/utils/collection.node.js +53 -42
  59. package/dist/mjs/utils/data.browser.js +64 -48
  60. package/dist/mjs/utils/data.js +29 -25
  61. package/dist/mjs/utils/error.js +47 -39
  62. package/dist/mjs/utils/eth.js +119 -104
  63. package/dist/mjs/utils/expose.js +9 -9
  64. package/dist/mjs/utils/file.js +22 -19
  65. package/dist/mjs/utils/hash.js +10 -5
  66. package/dist/mjs/utils/headers.js +43 -39
  67. package/dist/mjs/utils/hex.js +78 -63
  68. package/dist/mjs/utils/http.js +119 -100
  69. package/dist/mjs/utils/merge.js +26 -20
  70. package/dist/mjs/utils/pss.js +8 -6
  71. package/dist/mjs/utils/stamps.js +7 -3
  72. package/dist/mjs/utils/stream.js +107 -82
  73. package/dist/mjs/utils/tar.js +17 -14
  74. package/dist/mjs/utils/type.js +249 -209
  75. package/dist/mjs/utils/uint64.js +16 -16
  76. package/dist/mjs/utils/url.js +32 -25
  77. package/dist/types/types/index.d.ts +1 -1
  78. package/dist/types/types/ky-options.d.ts +221 -0
  79. package/dist/types/types/ky-universal/common.d.ts +13 -0
  80. package/dist/types/types/ky-universal/hooks.d.ts +92 -0
  81. package/dist/types/types/ky-universal/retry.d.ts +38 -0
  82. package/dist/types/utils/stream.d.ts +11 -8
  83. package/package.json +9 -6
  84. package/dist/index.js +0 -28326
  85. package/dist/index.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { extractUploadHeaders } from '../utils/headers';
2
- import { http } from '../utils/http';
3
- import { wrapBytesWithHelpers } from '../utils/bytes';
1
+ import { extractUploadHeaders } from "../utils/headers.js";
2
+ 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,19 @@ 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
+
17
18
  export async function upload(ky, data, postageBatchId, options) {
18
- const response = await http(ky, {
19
- method: 'post',
20
- path: `${endpoint}`,
21
- body: data,
22
- headers: {
23
- 'content-type': 'application/octet-stream',
24
- ...extractUploadHeaders(postageBatchId, options),
25
- },
26
- responseType: 'json',
27
- });
28
- return response.data.reference;
19
+ const response = await http(ky, {
20
+ method: 'post',
21
+ path: `${endpoint}`,
22
+ body: data,
23
+ headers: {
24
+ 'content-type': 'application/octet-stream',
25
+ ...extractUploadHeaders(postageBatchId, options)
26
+ },
27
+ responseType: 'json'
28
+ });
29
+ return response.data.reference;
29
30
  }
30
31
  /**
31
32
  * Download chunk data as a byte array
@@ -34,10 +35,11 @@ export async function upload(ky, data, postageBatchId, options) {
34
35
  * @param hash Bee content reference
35
36
  *
36
37
  */
38
+
37
39
  export async function download(ky, hash) {
38
- const response = await http(ky, {
39
- responseType: 'arraybuffer',
40
- path: `${endpoint}/${hash}`,
41
- });
42
- return wrapBytesWithHelpers(new Uint8Array(response.data));
43
- }
40
+ const response = await http(ky, {
41
+ responseType: 'arraybuffer',
42
+ path: `${endpoint}/${hash}`
43
+ });
44
+ return wrapBytesWithHelpers(new Uint8Array(response.data));
45
+ }
@@ -1,4 +1,4 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const balancesEndpoint = 'balances';
3
3
  const consumedEndpoint = 'consumed';
4
4
  /**
@@ -6,12 +6,13 @@ const consumedEndpoint = 'consumed';
6
6
  *
7
7
  * @param ky Ky debug instance
8
8
  */
9
+
9
10
  export async function getAllBalances(ky) {
10
- const response = await http(ky, {
11
- path: balancesEndpoint,
12
- responseType: 'json',
13
- });
14
- return response.data;
11
+ const response = await http(ky, {
12
+ path: balancesEndpoint,
13
+ responseType: 'json'
14
+ });
15
+ return response.data;
15
16
  }
16
17
  /**
17
18
  * Get the balances with a specific peer including prepaid services
@@ -19,24 +20,26 @@ export async function getAllBalances(ky) {
19
20
  * @param ky Ky debug instance
20
21
  * @param address Swarm address of peer
21
22
  */
23
+
22
24
  export async function getPeerBalance(ky, address) {
23
- const response = await http(ky, {
24
- path: `${balancesEndpoint}/${address}`,
25
- responseType: 'json',
26
- });
27
- return response.data;
25
+ const response = await http(ky, {
26
+ path: `${balancesEndpoint}/${address}`,
27
+ responseType: 'json'
28
+ });
29
+ return response.data;
28
30
  }
29
31
  /**
30
32
  * Get the past due consumption balances with all known peers
31
33
  *
32
34
  * @param ky Ky debug instance
33
35
  */
36
+
34
37
  export async function getPastDueConsumptionBalances(ky) {
35
- const response = await http(ky, {
36
- path: consumedEndpoint,
37
- responseType: 'json',
38
- });
39
- return response.data;
38
+ const response = await http(ky, {
39
+ path: consumedEndpoint,
40
+ responseType: 'json'
41
+ });
42
+ return response.data;
40
43
  }
41
44
  /**
42
45
  * Get the past due consumption balance with a specific peer
@@ -44,10 +47,11 @@ export async function getPastDueConsumptionBalances(ky) {
44
47
  * @param ky Ky debug instance
45
48
  * @param address Swarm address of peer
46
49
  */
50
+
47
51
  export async function getPastDueConsumptionPeerBalance(ky, address) {
48
- const response = await http(ky, {
49
- path: `${consumedEndpoint}/${address}`,
50
- responseType: 'json',
51
- });
52
- return response.data;
53
- }
52
+ const response = await http(ky, {
53
+ path: `${consumedEndpoint}/${address}`,
54
+ responseType: 'json'
55
+ });
56
+ return response.data;
57
+ }
@@ -1,28 +1,30 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const chequebookEndpoint = 'chequebook';
3
3
  /**
4
4
  * Get the address of the chequebook contract used
5
5
  *
6
6
  * @param ky Ky debug instance
7
7
  */
8
+
8
9
  export async function getChequebookAddress(ky) {
9
- const response = await http(ky, {
10
- path: chequebookEndpoint + '/address',
11
- responseType: 'json',
12
- });
13
- return response.data;
10
+ const response = await http(ky, {
11
+ path: chequebookEndpoint + '/address',
12
+ responseType: 'json'
13
+ });
14
+ return response.data;
14
15
  }
15
16
  /**
16
17
  * Get the balance of the chequebook
17
18
  *
18
19
  * @param ky Ky debug instance
19
20
  */
21
+
20
22
  export async function getChequebookBalance(ky) {
21
- const response = await http(ky, {
22
- path: chequebookEndpoint + '/balance',
23
- responseType: 'json',
24
- });
25
- return response.data;
23
+ const response = await http(ky, {
24
+ path: chequebookEndpoint + '/balance',
25
+ responseType: 'json'
26
+ });
27
+ return response.data;
26
28
  }
27
29
  /**
28
30
  * Get last cashout action for the peer
@@ -30,12 +32,13 @@ export async function getChequebookBalance(ky) {
30
32
  * @param ky Ky debug instance
31
33
  * @param peer Swarm address of peer
32
34
  */
35
+
33
36
  export async function getLastCashoutAction(ky, peer) {
34
- const response = await http(ky, {
35
- path: chequebookEndpoint + `/cashout/${peer}`,
36
- responseType: 'json',
37
- });
38
- return response.data;
37
+ const response = await http(ky, {
38
+ path: chequebookEndpoint + `/cashout/${peer}`,
39
+ responseType: 'json'
40
+ });
41
+ return response.data;
39
42
  }
40
43
  /**
41
44
  * Cashout the last cheque for the peer
@@ -44,21 +47,25 @@ export async function getLastCashoutAction(ky, peer) {
44
47
  * @param peer Swarm address of peer
45
48
  * @param options
46
49
  */
50
+
47
51
  export async function cashoutLastCheque(ky, 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(ky, {
56
- method: 'post',
57
- path: chequebookEndpoint + `/cashout/${peer}`,
58
- responseType: 'json',
59
- headers,
60
- });
61
- return response.data.transactionHash;
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.data.transactionHash;
62
69
  }
63
70
  /**
64
71
  * Get last cheques for the peer
@@ -66,24 +73,26 @@ export async function cashoutLastCheque(ky, peer, options) {
66
73
  * @param ky Ky debug instance
67
74
  * @param peer Swarm address of peer
68
75
  */
76
+
69
77
  export async function getLastChequesForPeer(ky, peer) {
70
- const response = await http(ky, {
71
- path: chequebookEndpoint + `/cheque/${peer}`,
72
- responseType: 'json',
73
- });
74
- return response.data;
78
+ const response = await http(ky, {
79
+ path: chequebookEndpoint + `/cheque/${peer}`,
80
+ responseType: 'json'
81
+ });
82
+ return response.data;
75
83
  }
76
84
  /**
77
85
  * Get last cheques for all peers
78
86
  *
79
87
  * @param ky Ky debug instance
80
88
  */
89
+
81
90
  export async function getLastCheques(ky) {
82
- const response = await http(ky, {
83
- path: chequebookEndpoint + '/cheque',
84
- responseType: 'json',
85
- });
86
- return response.data;
91
+ const response = await http(ky, {
92
+ path: chequebookEndpoint + '/cheque',
93
+ responseType: 'json'
94
+ });
95
+ return response.data;
87
96
  }
88
97
  /**
89
98
  * Deposit tokens from overlay address into chequebook
@@ -93,19 +102,24 @@ export async function getLastCheques(ky) {
93
102
  * @param gasPrice Gas Price in WEI for the transaction call
94
103
  * @return string Hash of the transaction
95
104
  */
105
+
96
106
  export async function depositTokens(ky, amount, gasPrice) {
97
- const headers = {};
98
- if (gasPrice) {
99
- headers['gas-price'] = gasPrice.toString();
100
- }
101
- const response = await http(ky, {
102
- method: 'post',
103
- path: chequebookEndpoint + '/deposit',
104
- responseType: 'json',
105
- searchParams: { amount: amount.toString(10) },
106
- headers,
107
- });
108
- return response.data.transactionHash;
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.data.transactionHash;
109
123
  }
110
124
  /**
111
125
  * Withdraw tokens from the chequebook to the overlay address
@@ -115,17 +129,22 @@ export async function depositTokens(ky, amount, gasPrice) {
115
129
  * @param gasPrice Gas Price in WEI for the transaction call
116
130
  * @return string Hash of the transaction
117
131
  */
132
+
118
133
  export async function withdrawTokens(ky, amount, gasPrice) {
119
- const headers = {};
120
- if (gasPrice) {
121
- headers['gas-price'] = gasPrice.toString();
122
- }
123
- const response = await http(ky, {
124
- method: 'post',
125
- path: chequebookEndpoint + '/withdraw',
126
- responseType: 'json',
127
- searchParams: { amount: amount.toString(10) },
128
- headers,
129
- });
130
- return response.data.transactionHash;
131
- }
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.data.transactionHash;
150
+ }
@@ -1,4 +1,4 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const endpoint = 'chunks';
3
3
  /**
4
4
  * Check if chunk at address exists locally
@@ -8,12 +8,13 @@ const endpoint = 'chunks';
8
8
  *
9
9
  * @returns BeeGenericResponse if chunk is found or throws an exception
10
10
  */
11
+
11
12
  export async function checkIfChunkExistsLocally(ky, address) {
12
- const response = await http(ky, {
13
- path: endpoint + `/${address}`,
14
- responseType: 'json',
15
- });
16
- return response.data;
13
+ const response = await http(ky, {
14
+ path: endpoint + `/${address}`,
15
+ responseType: 'json'
16
+ });
17
+ return response.data;
17
18
  }
18
19
  /**
19
20
  * Delete a chunk from local storage
@@ -23,11 +24,12 @@ export async function checkIfChunkExistsLocally(ky, address) {
23
24
  *
24
25
  * @returns BeeGenericResponse if chunk was deleted or throws an exception
25
26
  */
27
+
26
28
  export async function deleteChunkFromLocalStorage(ky, address) {
27
- const response = await http(ky, {
28
- method: 'delete',
29
- path: endpoint + `/${address}`,
30
- responseType: 'json',
31
- });
32
- return response.data;
33
- }
29
+ const response = await http(ky, {
30
+ method: 'delete',
31
+ path: endpoint + `/${address}`,
32
+ responseType: 'json'
33
+ });
34
+ return response.data;
35
+ }
@@ -1,45 +1,45 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  export async function getNodeAddresses(ky) {
3
- const response = await http(ky, {
4
- path: 'addresses',
5
- responseType: 'json',
6
- });
7
- return response.data;
3
+ const response = await http(ky, {
4
+ path: 'addresses',
5
+ responseType: 'json'
6
+ });
7
+ return response.data;
8
8
  }
9
9
  export async function getPeers(ky) {
10
- const response = await http(ky, {
11
- path: 'peers',
12
- responseType: 'json',
13
- });
14
- return response.data.peers || [];
10
+ const response = await http(ky, {
11
+ path: 'peers',
12
+ responseType: 'json'
13
+ });
14
+ return response.data.peers || [];
15
15
  }
16
16
  export async function getBlocklist(ky) {
17
- const response = await http(ky, {
18
- path: 'blocklist',
19
- responseType: 'json',
20
- });
21
- return response.data.peers || [];
17
+ const response = await http(ky, {
18
+ path: 'blocklist',
19
+ responseType: 'json'
20
+ });
21
+ return response.data.peers || [];
22
22
  }
23
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.data;
24
+ const response = await http(ky, {
25
+ path: `peers/${peer}`,
26
+ responseType: 'json',
27
+ method: 'DELETE'
28
+ });
29
+ return response.data;
30
30
  }
31
31
  export async function getTopology(ky) {
32
- const response = await http(ky, {
33
- path: `topology`,
34
- responseType: 'json',
35
- });
36
- return response.data;
32
+ const response = await http(ky, {
33
+ path: `topology`,
34
+ responseType: 'json'
35
+ });
36
+ return response.data;
37
37
  }
38
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.data;
45
- }
39
+ const response = await http(ky, {
40
+ path: `pingpong/${peer}`,
41
+ responseType: 'json',
42
+ method: 'POST'
43
+ });
44
+ return response.data;
45
+ }
@@ -1,4 +1,4 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const settlementsEndpoint = 'settlements';
3
3
  /**
4
4
  * Get amount of sent and received from settlements with a peer
@@ -6,22 +6,24 @@ const settlementsEndpoint = 'settlements';
6
6
  * @param ky Ky debug instance
7
7
  * @param peer Swarm address of peer
8
8
  */
9
+
9
10
  export async function getSettlements(ky, peer) {
10
- const response = await http(ky, {
11
- path: `${settlementsEndpoint}/${peer}`,
12
- responseType: 'json',
13
- });
14
- return response.data;
11
+ const response = await http(ky, {
12
+ path: `${settlementsEndpoint}/${peer}`,
13
+ responseType: 'json'
14
+ });
15
+ return response.data;
15
16
  }
16
17
  /**
17
18
  * Get settlements with all known peers and total amount sent or received
18
19
  *
19
20
  * @param ky Ky debug instance
20
21
  */
22
+
21
23
  export async function getAllSettlements(ky) {
22
- const response = await http(ky, {
23
- path: settlementsEndpoint,
24
- responseType: 'json',
25
- });
26
- return response.data;
27
- }
24
+ const response = await http(ky, {
25
+ path: settlementsEndpoint,
26
+ responseType: 'json'
27
+ });
28
+ return response.data;
29
+ }
@@ -1,59 +1,64 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const STAMPS_ENDPOINT = 'stamps';
3
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.data.stamps || [];
4
+ const response = await http(ky, {
5
+ method: 'get',
6
+ path: `${STAMPS_ENDPOINT}`,
7
+ responseType: 'json'
8
+ });
9
+ return response.data.stamps || [];
10
10
  }
11
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.data;
12
+ const response = await http(ky, {
13
+ method: 'get',
14
+ path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
15
+ responseType: 'json'
16
+ });
17
+ return response.data;
18
18
  }
19
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.data;
20
+ const response = await http(ky, {
21
+ method: 'get',
22
+ path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
23
+ responseType: 'json'
24
+ });
25
+ return response.data;
26
26
  }
27
27
  export async function createPostageBatch(ky, amount, depth, options) {
28
- const headers = {};
29
- if (options?.gasPrice) {
30
- headers['gas-price'] = options.gasPrice.toString();
31
- }
32
- if (options?.immutableFlag !== undefined) {
33
- headers.immutable = String(options.immutableFlag);
34
- }
35
- const response = await http(ky, {
36
- method: 'post',
37
- path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
38
- responseType: 'json',
39
- searchParams: { label: options?.label },
40
- headers,
41
- });
42
- return response.data.batchID;
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.data.batchID;
43
48
  }
44
49
  export async function topUpBatch(ky, id, amount) {
45
- const response = await http(ky, {
46
- method: 'patch',
47
- path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
48
- responseType: 'json',
49
- });
50
- return response.data.batchID;
50
+ const response = await http(ky, {
51
+ method: 'patch',
52
+ path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
53
+ responseType: 'json'
54
+ });
55
+ return response.data.batchID;
51
56
  }
52
57
  export async function diluteBatch(ky, id, depth) {
53
- const response = await http(ky, {
54
- method: 'patch',
55
- path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
56
- responseType: 'json',
57
- });
58
- return response.data.batchID;
59
- }
58
+ const response = await http(ky, {
59
+ method: 'patch',
60
+ path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
61
+ responseType: 'json'
62
+ });
63
+ return response.data.batchID;
64
+ }