@upcoming/bee-js 12.0.0 → 12.2.3

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.
package/dist/mjs/bee.js CHANGED
@@ -284,8 +284,8 @@ export class Bee {
284
284
  const fileName = name ?? data.name;
285
285
  const contentType = data.type;
286
286
  const fileOptions = {
287
- contentType,
288
- ...options
287
+ ...options,
288
+ contentType
289
289
  };
290
290
  return bzz.uploadFile(this.getRequestOptionsForCall(requestOptions), fileData, postageBatchId, fileName, fileOptions);
291
291
  } else {
@@ -1602,10 +1602,16 @@ export class Bee {
1602
1602
  const currentAmount = getAmountForDuration(batch.duration, chainState.currentPrice, blockTime);
1603
1603
  const targetAmount = duration.isZero() ? currentAmount * multiplier : (currentAmount + additionalAmount) * multiplier;
1604
1604
  const amountDelta = targetAmount - currentAmount;
1605
- const transactionId = await this.topUpBatch(batch.batchID, amountDelta, requestOptions);
1605
+ let transactionId;
1606
+ if (amountDelta > 0n) {
1607
+ transactionId = await this.topUpBatch(batch.batchID, amountDelta, requestOptions);
1608
+ }
1606
1609
  if (depthDelta > 0) {
1607
1610
  return this.diluteBatch(batch.batchID, depth, requestOptions);
1608
1611
  }
1612
+ if (!transactionId) {
1613
+ throw new Error('Nothing to extend, both size and duration are already sufficient');
1614
+ }
1609
1615
  return transactionId;
1610
1616
  }
1611
1617
  /**
@@ -1733,16 +1739,15 @@ export class Bee {
1733
1739
  /**
1734
1740
  * Calculates the `amount` and expected duration extension for topping up a postage batch with a given BZZ value.
1735
1741
  *
1736
- * @param postageBatchId
1742
+ * @param depth Depth of the postage batch to top up.
1737
1743
  * @param bzz The amount of BZZ to spend on the top-up.
1738
1744
  * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1739
1745
  * @returns An object with `amount` (to pass to {@link topUpBatch}) and `duration` (the expected TTL extension).
1740
1746
  */
1741
- async calculateTopUpForBzz(postageBatchId, bzz, requestOptions) {
1742
- const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1747
+ async calculateTopUpForBzz(depth, bzz, requestOptions) {
1743
1748
  const chainState = await this.getChainState(requestOptions);
1744
1749
  const blockTime = this.network === 'gnosis' ? 5 : 15;
1745
- const amount = bzz.toPLURBigInt() / 2n ** BigInt(batch.depth);
1750
+ const amount = bzz.toPLURBigInt() / 2n ** BigInt(depth);
1746
1751
  const duration = getStampDuration(amount, chainState.currentPrice, blockTime);
1747
1752
  return {
1748
1753
  amount,
package/dist/mjs/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Bee } from "./bee.js";
2
- import { BeeDev } from "./bee-dev.js";
3
2
  import { Stamper } from "./stamper/stamper.js";
4
3
  export { MerkleTree } from 'cafe-utility';
5
4
  export { MantarayNode } from "./manifest/manifest.js";
@@ -13,4 +12,4 @@ export * as Utils from "./utils/expose.js";
13
12
  export { Size } from "./utils/size.js";
14
13
  export * from "./utils/tokens.js";
15
14
  export * from "./utils/typed-bytes.js";
16
- export { Bee, BeeDev, Stamper };
15
+ export { Bee, Stamper };
@@ -57,7 +57,9 @@ export async function fetchLatestFeedUpdate(requestOptions, owner, topic, option
57
57
  const response = await http(requestOptions, {
58
58
  responseType: 'arraybuffer',
59
59
  url: `${feedEndpoint}/${owner}/${topic}`,
60
- params: options
60
+ params: {
61
+ ...options
62
+ }
61
63
  });
62
64
  return {
63
65
  payload: new Bytes(response.data),
@@ -7,7 +7,8 @@ import { http } from "../utils/http.js";
7
7
  */
8
8
  export async function checkConnection(requestOptions) {
9
9
  await http(requestOptions, {
10
- url: ''
10
+ url: '',
11
+ responseType: 'text'
11
12
  });
12
13
  }
13
14
  export async function isGateway(requestOptions) {
@@ -1,28 +1,16 @@
1
- import axios from 'axios';
2
- import { Dates, Objects, Strings, System } from 'cafe-utility';
1
+ import { Objects, Strings, System } from 'cafe-utility';
3
2
  import _debug from 'debug';
4
3
  import { BeeResponseError } from "../index.js";
5
4
  const debug = _debug('bee-js:http');
6
- const {
7
- AxiosError
8
- } = axios;
9
5
  const MAX_FAILED_ATTEMPTS = 100000;
10
6
  const DELAY_FAST = 200;
11
7
  const DELAY_SLOW = 1000;
12
- const DELAY_THRESHOLD = Dates.minutes(1) / DELAY_FAST;
13
- const ABORT_ERROR_MESSAGE = 'Request aborted';
8
+ const FAST_RETRY_COUNT = 300;
14
9
  export const DEFAULT_HTTP_CONFIG = {
15
10
  headers: {
16
11
  accept: 'application/json, text/plain, */*'
17
- },
18
- maxBodyLength: Infinity,
19
- maxContentLength: Infinity
20
- };
21
- function throwIfAborted(signal, config, responseData, responseStatus) {
22
- if (signal?.aborted) {
23
- throw new BeeResponseError(config.method || 'get', config.url || '<unknown>', ABORT_ERROR_MESSAGE, responseData, responseStatus, 'ERR_CANCELED');
24
12
  }
25
- }
13
+ };
26
14
  /**
27
15
  * Main function to make HTTP requests.
28
16
  * @param options User defined settings
@@ -32,68 +20,118 @@ export async function http(options, config) {
32
20
  const requestConfig = Objects.deepMerge3(DEFAULT_HTTP_CONFIG, config, options);
33
21
  if (options.signal) {
34
22
  requestConfig.signal = options.signal;
35
- throwIfAborted(options.signal, config);
36
23
  }
37
- maybeReplaceBodyBuffers(requestConfig);
24
+ attachBody(requestConfig);
38
25
  if (requestConfig.params) {
39
- const keys = Object.keys(requestConfig.params);
40
- for (const key of keys) {
41
- const value = requestConfig.params[key];
42
- if (value === undefined) {
43
- delete requestConfig.params[key];
44
- }
26
+ for (const k of Object.keys(requestConfig.params)) {
27
+ if (requestConfig.params[k] === undefined) delete requestConfig.params[k];
45
28
  }
46
29
  }
30
+ const url = buildUrl(requestConfig);
31
+ const method = (requestConfig.method || 'GET').toUpperCase();
32
+ requestConfig.method = method;
33
+ options.onRequest?.({
34
+ method,
35
+ url,
36
+ headers: {
37
+ ...requestConfig.headers
38
+ },
39
+ params: requestConfig.params
40
+ });
47
41
  let failedAttempts = 0;
48
42
  while (failedAttempts < MAX_FAILED_ATTEMPTS) {
49
- throwIfAborted(options.signal, config);
50
43
  try {
51
- debug(`${requestConfig.method || 'get'} ${Strings.joinUrl([requestConfig.baseURL, requestConfig.url])}`, {
52
- headers: {
53
- ...requestConfig.headers
54
- },
44
+ debug(`${method} ${url}`, {
45
+ headers: requestConfig.headers,
55
46
  params: requestConfig.params
56
47
  });
57
- maybeRunOnRequestHook(options, requestConfig);
58
- const response = await axios(requestConfig);
59
- return response;
48
+ const res = await fetch(url, requestConfig);
49
+ if (!res.ok) await throwHttpError(method, url, res, requestConfig.responseType);
50
+ return toBeeResponse(res, requestConfig.responseType);
60
51
  } catch (e) {
61
- if (e instanceof AxiosError) {
62
- if (e.code === 'ERR_CANCELED') {
63
- throwIfAborted({
64
- aborted: true
65
- }, config, e.response?.data, e.response?.status);
66
- }
67
- if (e.code === 'ECONNABORTED' && options.endlesslyRetry) {
68
- failedAttempts++;
69
- await System.sleepMillis(failedAttempts < DELAY_THRESHOLD ? DELAY_FAST : DELAY_SLOW);
70
- } else {
71
- throw new BeeResponseError(config.method || 'get', config.url || '<unknown>', e.message, e.response?.data, e.response?.status, e.response?.statusText);
72
- }
52
+ if (e instanceof BeeResponseError) throw e;
53
+ const err = e;
54
+ if (err.name === 'TimeoutError' && options.endlesslyRetry) {
55
+ failedAttempts++;
56
+ await System.sleepMillis(failedAttempts < FAST_RETRY_COUNT ? DELAY_FAST : DELAY_SLOW);
73
57
  } else {
74
- throw e;
58
+ throw toBeeError(err, method, url);
75
59
  }
76
60
  }
77
61
  }
78
62
  throw Error('Max number of failed attempts reached');
79
63
  }
80
- function maybeRunOnRequestHook(options, requestConfig) {
81
- if (options.onRequest) {
82
- options.onRequest({
83
- method: requestConfig.method || 'GET',
84
- url: Strings.joinUrl([requestConfig.baseURL, requestConfig.url]),
85
- headers: {
86
- ...requestConfig.headers
87
- },
88
- params: requestConfig.params
89
- });
64
+ function attachBody(config) {
65
+ if (config.data === undefined) return;
66
+ const data = config.data;
67
+ const isJsonShape = data !== null && typeof data === 'object' && data.constructor === Object || Array.isArray(data);
68
+ if (isJsonShape) {
69
+ config.body = JSON.stringify(data);
70
+ config.headers = {
71
+ 'content-type': 'application/json',
72
+ ...config.headers
73
+ };
74
+ } else {
75
+ config.body = data;
76
+ config.duplex = 'half';
77
+ const ct = data instanceof Blob && data.type ? data.type : 'application/octet-stream';
78
+ config.headers = {
79
+ 'content-type': ct,
80
+ ...config.headers
81
+ };
90
82
  }
91
83
  }
92
- function maybeReplaceBodyBuffers(config) {
93
- if (config.data && config.data instanceof Uint8Array) {
94
- config.data = config.data.buffer.slice(config.data.byteOffset, config.data.byteOffset + config.data.byteLength);
84
+ async function throwHttpError(method, url, res, responseType) {
85
+ const errBody = await toBeeResponse(res, responseType).catch(() => ({
86
+ data: undefined
87
+ }));
88
+ const bodyMsg = typeof errBody.data === 'string' ? errBody.data : JSON.stringify(errBody.data);
89
+ const message = bodyMsg && bodyMsg !== 'undefined' ? `${res.statusText}: ${bodyMsg}` : res.statusText;
90
+ throw new BeeResponseError(method, url, message, errBody.data, res.status, res.statusText);
91
+ }
92
+ function toBeeError(err, method, url) {
93
+ if (err.name === 'AbortError') {
94
+ return new BeeResponseError(method, url, 'Request aborted', undefined, undefined, 'ERR_CANCELED');
95
95
  }
96
- if (config.data && typeof Buffer !== 'undefined' && Buffer.isBuffer(config.data)) {
97
- config.data = config.data.buffer.slice(config.data.byteOffset, config.data.byteOffset + config.data.byteLength);
96
+ const cause = err.cause;
97
+ const message = cause?.message ? `${err.message}: ${cause.message}` : err.message;
98
+ return new BeeResponseError(method, url, message);
99
+ }
100
+ export async function toBeeResponse(res, responseType = 'json') {
101
+ let data;
102
+ switch (responseType) {
103
+ case 'arraybuffer':
104
+ data = await res.arrayBuffer();
105
+ break;
106
+ case 'text':
107
+ data = await res.text();
108
+ break;
109
+ case 'blob':
110
+ data = await res.blob();
111
+ break;
112
+ case 'stream':
113
+ data = res.body;
114
+ break;
115
+ case 'json':
116
+ default:
117
+ {
118
+ const text = await res.text();
119
+ data = text ? JSON.parse(text) : null;
120
+ }
121
+ }
122
+ return {
123
+ data: data,
124
+ status: res.status,
125
+ statusText: res.statusText,
126
+ headers: Object.fromEntries(res.headers.entries()),
127
+ raw: res
128
+ };
129
+ }
130
+ function buildUrl(config) {
131
+ let url = Strings.joinUrl([config.baseURL ?? '', config.url ?? '']);
132
+ if (config.params) {
133
+ const qs = new URLSearchParams(Object.entries(config.params).filter(([, v]) => v !== undefined).map(([k, v]) => [k, String(v)])).toString();
134
+ if (qs) url += `?${qs}`;
98
135
  }
136
+ return url;
99
137
  }
@@ -12,10 +12,20 @@ export class TarStream {
12
12
  });
13
13
  }
14
14
  beginFile(path, size) {
15
- if (path.length > 100) {
16
- throw new Error(`File name too long: ${path}`);
15
+ const {
16
+ name,
17
+ prefix,
18
+ longLink
19
+ } = splitPath(path);
20
+ if (longLink) {
21
+ const encoder = new TextEncoder();
22
+ const pathData = encoder.encode(path + '\0');
23
+ this.pieces.push(createLongLinkHeader(pathData.length));
24
+ this.pieces.push(pathData);
25
+ const padding = pathData.length % 512 === 0 ? 0 : 512 - pathData.length % 512;
26
+ if (padding > 0) this.pieces.push(new Uint8Array(padding));
17
27
  }
18
- const header = createHeader(path, size);
28
+ const header = createHeader(name, prefix, size);
19
29
  this.pieces.push(header);
20
30
  this.currentFileSize = 0;
21
31
  }
@@ -33,7 +43,55 @@ export class TarStream {
33
43
  this.pieces.push(createEndOfArchive());
34
44
  }
35
45
  }
36
- function createHeader(path, size) {
46
+ function splitPath(path) {
47
+ if (path.length <= 100) return {
48
+ name: path,
49
+ prefix: '',
50
+ longLink: false
51
+ };
52
+ for (let i = path.length - 1; i >= 0; i--) {
53
+ if (path[i] === '/') {
54
+ const name = path.substring(i + 1);
55
+ const prefix = path.substring(0, i);
56
+ if (name.length <= 100 && prefix.length <= 155) return {
57
+ name,
58
+ prefix,
59
+ longLink: false
60
+ };
61
+ }
62
+ }
63
+ // Filename itself is > 100 chars or path > 255 chars — use GNU LongLink
64
+ const lastSlash = path.lastIndexOf('/');
65
+ const truncatedName = (lastSlash >= 0 ? path.substring(lastSlash + 1) : path).slice(0, 100);
66
+ return {
67
+ name: truncatedName,
68
+ prefix: '',
69
+ longLink: true
70
+ };
71
+ }
72
+ function createLongLinkHeader(size) {
73
+ const encoder = new TextEncoder();
74
+ function writeToBuffer(str, offset, length) {
75
+ const bytes = encoder.encode(str);
76
+ header.set(bytes.slice(0, length), offset);
77
+ }
78
+ const header = new Uint8Array(512);
79
+ header.fill(0);
80
+ writeToBuffer('././@LongLink', 0, 100);
81
+ writeToBuffer('0000644\0', 100, 8);
82
+ writeToBuffer('0000000\0', 108, 8);
83
+ writeToBuffer('0000000\0', 116, 8);
84
+ writeToBuffer(size.toString(8).padStart(11, '0') + '\0', 124, 12);
85
+ writeToBuffer('00000000000\0', 136, 12);
86
+ writeToBuffer(' ', 148, 8);
87
+ writeToBuffer('L', 156, 1);
88
+ writeToBuffer('ustar\0\0', 257, 8);
89
+ let checksum = 0;
90
+ for (let i = 0; i < 512; i++) checksum += header[i];
91
+ writeToBuffer(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
92
+ return header;
93
+ }
94
+ function createHeader(name, prefix, size) {
37
95
  const encoder = new TextEncoder();
38
96
  function writeToBuffer(str, offset, length) {
39
97
  const bytes = encoder.encode(str);
@@ -43,7 +101,7 @@ function createHeader(path, size) {
43
101
  const header = new Uint8Array(512);
44
102
  header.fill(0, 0, 512);
45
103
  // File name, truncated to 100 characters if necessary
46
- writeToBuffer(path.slice(0, 100).padEnd(100, '\0'), 0, 100);
104
+ writeToBuffer(name.slice(0, 100).padEnd(100, '\0'), 0, 100);
47
105
  // File mode (octal) and null-terminated
48
106
  writeToBuffer('0000777\0', 100, 8);
49
107
  // UID and GID (octal) and null-terminated
@@ -60,11 +118,11 @@ function createHeader(path, size) {
60
118
  writeToBuffer('0', 156, 1);
61
119
  // USTAR magic and version
62
120
  writeToBuffer('ustar\0\0', 257, 8);
121
+ // UStar prefix field (offset 345, 155 bytes) — used when path > 100 but fits split
122
+ if (prefix) writeToBuffer(prefix.slice(0, 155).padEnd(155, '\0'), 345, 155);
63
123
  // Calculate checksum
64
124
  let checksum = 0;
65
- for (let i = 0; i < 512; i++) {
66
- checksum += header[i];
67
- }
125
+ for (let i = 0; i < 512; i++) checksum += header[i];
68
126
  writeToBuffer(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
69
127
  return header;
70
128
  }
@@ -5,10 +5,19 @@ export class TarStream {
5
5
  this.currentFileSize = 0;
6
6
  }
7
7
  beginFile(path, size) {
8
- if (path.length > 100) {
9
- throw new Error(`File name too long: ${path}`);
8
+ const {
9
+ name,
10
+ prefix,
11
+ longLink
12
+ } = splitPath(path);
13
+ if (longLink) {
14
+ const pathData = Buffer.from(path + '\0');
15
+ this.output.write(createLongLinkHeader(pathData.length));
16
+ this.output.write(pathData);
17
+ const padding = pathData.length % 512 === 0 ? 0 : 512 - pathData.length % 512;
18
+ if (padding > 0) this.output.write(Buffer.alloc(padding, 0));
10
19
  }
11
- const header = createHeader(path, size);
20
+ const header = createHeader(name, prefix, size);
12
21
  this.output.write(header);
13
22
  this.currentFileSize = 0;
14
23
  }
@@ -39,11 +48,53 @@ export class TarStream {
39
48
  });
40
49
  }
41
50
  }
42
- function createHeader(path, size) {
51
+ function splitPath(path) {
52
+ if (path.length <= 100) return {
53
+ name: path,
54
+ prefix: '',
55
+ longLink: false
56
+ };
57
+ for (let i = path.length - 1; i >= 0; i--) {
58
+ if (path[i] === '/') {
59
+ const name = path.substring(i + 1);
60
+ const prefix = path.substring(0, i);
61
+ if (name.length <= 100 && prefix.length <= 155) return {
62
+ name,
63
+ prefix,
64
+ longLink: false
65
+ };
66
+ }
67
+ }
68
+ // Filename itself is > 100 chars or path > 255 chars — use GNU LongLink
69
+ const lastSlash = path.lastIndexOf('/');
70
+ const truncatedName = (lastSlash >= 0 ? path.substring(lastSlash + 1) : path).slice(0, 100);
71
+ return {
72
+ name: truncatedName,
73
+ prefix: '',
74
+ longLink: true
75
+ };
76
+ }
77
+ function createLongLinkHeader(size) {
78
+ const header = Buffer.alloc(512, 0);
79
+ header.write('././@LongLink', 0, 100);
80
+ header.write('0000644\0', 100, 8);
81
+ header.write('0000000\0', 108, 8);
82
+ header.write('0000000\0', 116, 8);
83
+ header.write(size.toString(8).padStart(11, '0') + '\0', 124, 12);
84
+ header.write('00000000000\0', 136, 12);
85
+ header.write(' ', 148, 8);
86
+ header.write('L', 156, 1);
87
+ header.write('ustar\0\0', 257, 8);
88
+ let checksum = 0;
89
+ for (let i = 0; i < 512; i++) checksum += header[i];
90
+ header.write(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
91
+ return header;
92
+ }
93
+ function createHeader(name, prefix, size) {
43
94
  // Initialize header with zeros
44
95
  const header = Buffer.alloc(512, 0);
45
96
  // File name, truncated to 100 characters if necessary
46
- header.write(path.slice(0, 100).padEnd(100, '\0'), 0, 100);
97
+ header.write(name.slice(0, 100).padEnd(100, '\0'), 0, 100);
47
98
  // File mode (octal) and null-terminated
48
99
  header.write('0000777\0', 100, 8);
49
100
  // UID and GID (octal) and null-terminated
@@ -60,11 +111,11 @@ function createHeader(path, size) {
60
111
  header.write('0', 156, 1);
61
112
  // USTAR magic and version
62
113
  header.write('ustar\0\0', 257, 8);
114
+ // UStar prefix field (offset 345, 155 bytes) — used when path > 100 but fits split
115
+ if (prefix) header.write(prefix.slice(0, 155).padEnd(155, '\0'), 345, 155);
63
116
  // Calculate checksum
64
117
  let checksum = 0;
65
- for (let i = 0; i < 512; i++) {
66
- checksum += header[i];
67
- }
118
+ for (let i = 0; i < 512; i++) checksum += header[i];
68
119
  header.write(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
69
120
  return header;
70
121
  }
@@ -9,6 +9,9 @@ export class BZZ {
9
9
  static fromPLUR(plur) {
10
10
  return new BZZ(new FixedPointNumber(plur, BZZ.DIGITS));
11
11
  }
12
+ static fromFloat(float) {
13
+ return new BZZ(FixedPointNumber.fromFloat(float, BZZ.DIGITS));
14
+ }
12
15
  toPLURString() {
13
16
  return this.state.toString();
14
17
  }
@@ -18,6 +21,9 @@ export class BZZ {
18
21
  toDecimalString() {
19
22
  return this.state.toDecimalString();
20
23
  }
24
+ toFloat() {
25
+ return this.state.toFloat();
26
+ }
21
27
  toSignificantDigits(digits) {
22
28
  return this.toDecimalString().slice(0, this.toDecimalString().indexOf('.') + digits + 1);
23
29
  }
@@ -78,6 +84,9 @@ export class DAI {
78
84
  static fromWei(wei) {
79
85
  return new DAI(new FixedPointNumber(wei, DAI.DIGITS));
80
86
  }
87
+ static fromFloat(float) {
88
+ return new DAI(FixedPointNumber.fromFloat(float, DAI.DIGITS));
89
+ }
81
90
  toWeiString() {
82
91
  return this.state.toString();
83
92
  }
@@ -90,6 +99,9 @@ export class DAI {
90
99
  toSignificantDigits(digits) {
91
100
  return this.toDecimalString().slice(0, this.toDecimalString().indexOf('.') + digits + 1);
92
101
  }
102
+ toFloat() {
103
+ return this.state.toFloat();
104
+ }
93
105
  /**
94
106
  * Does not mutate the current DAI instance.
95
107
  *
@@ -1074,7 +1074,7 @@ export declare class Bee {
1074
1074
  * @param erasureCodeLevel Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.
1075
1075
  * @returns
1076
1076
  */
1077
- extendStorage(postageBatchId: BatchId | Uint8Array | string, size: Size, duration: Duration, requestOptions?: BeeRequestOptions, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<BatchId>;
1077
+ extendStorage(postageBatchId: BatchId | Uint8Array | string, size: Size, duration: Duration, requestOptions?: BeeRequestOptions, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): Promise<TransactionId | BatchId>;
1078
1078
  /**
1079
1079
  * Extends the storage size of a postage batch by increasing its depth.
1080
1080
  *
@@ -1157,12 +1157,12 @@ export declare class Bee {
1157
1157
  /**
1158
1158
  * Calculates the `amount` and expected duration extension for topping up a postage batch with a given BZZ value.
1159
1159
  *
1160
- * @param postageBatchId
1160
+ * @param depth Depth of the postage batch to top up.
1161
1161
  * @param bzz The amount of BZZ to spend on the top-up.
1162
1162
  * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1163
1163
  * @returns An object with `amount` (to pass to {@link topUpBatch}) and `duration` (the expected TTL extension).
1164
1164
  */
1165
- calculateTopUpForBzz(postageBatchId: BatchId | Uint8Array | string, bzz: BZZ, requestOptions?: BeeRequestOptions): Promise<{
1165
+ calculateTopUpForBzz(depth: number, bzz: BZZ, requestOptions?: BeeRequestOptions): Promise<{
1166
1166
  amount: bigint;
1167
1167
  duration: Duration;
1168
1168
  }>;
@@ -1,5 +1,4 @@
1
1
  import { Bee } from './bee';
2
- import { BeeDev } from './bee-dev';
3
2
  import { Stamper } from './stamper/stamper';
4
3
  export { MerkleTree } from 'cafe-utility';
5
4
  export type { Chunk } from './chunk/cac';
@@ -16,12 +15,11 @@ export { Size } from './utils/size';
16
15
  export * from './utils/tokens';
17
16
  export * from './utils/typed-bytes';
18
17
  export type { UploadProgress } from './utils/upload-progress';
19
- export { Bee, BeeDev, Stamper };
18
+ export { Bee, Stamper };
20
19
  declare global {
21
20
  interface Window {
22
21
  BeeJs: {
23
22
  Bee: typeof import('./bee').Bee;
24
- BeeDev: typeof import('./bee-dev').BeeDev;
25
23
  Stamper: typeof import('./stamper/stamper').Stamper;
26
24
  Utils: typeof import('./utils/expose');
27
25
  Duration: typeof import('./utils/duration').Duration;
@@ -1,9 +1,24 @@
1
- import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
1
  import { BeeRequestOptions } from '../index';
3
- export declare const DEFAULT_HTTP_CONFIG: AxiosRequestConfig;
2
+ export declare const DEFAULT_HTTP_CONFIG: BeeRequestConfig;
3
+ export type BeeResponseType = 'json' | 'arraybuffer' | 'text' | 'blob' | 'stream';
4
+ export interface BeeResponse<T> {
5
+ data: T;
6
+ status: number;
7
+ statusText: string;
8
+ headers: Record<string, string>;
9
+ raw: Response;
10
+ }
11
+ export interface BeeRequestConfig extends RequestInit {
12
+ url?: string;
13
+ baseURL?: string;
14
+ params?: Record<string, unknown>;
15
+ data?: unknown;
16
+ responseType?: BeeResponseType;
17
+ }
4
18
  /**
5
19
  * Main function to make HTTP requests.
6
20
  * @param options User defined settings
7
21
  * @param config Internal settings and/or Bee settings
8
22
  */
9
- export declare function http<T>(options: BeeRequestOptions, config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
23
+ export declare function http<T>(options: BeeRequestOptions, config: BeeRequestConfig): Promise<BeeResponse<T>>;
24
+ export declare function toBeeResponse<T>(res: Response, responseType?: BeeResponseType): Promise<BeeResponse<T>>;
@@ -1,3 +1,3 @@
1
1
  import { BeeRequestOptions, Collection, CollectionUploadOptions } from '..';
2
2
  import { BatchId } from './typed-bytes';
3
- export declare function uploadTar(requestOptions: BeeRequestOptions, collection: Collection, postageBatchId: BatchId, options?: CollectionUploadOptions): Promise<import("axios").AxiosResponse<unknown, any, {}>>;
3
+ export declare function uploadTar(requestOptions: BeeRequestOptions, collection: Collection, postageBatchId: BatchId, options?: CollectionUploadOptions): Promise<import("./http").BeeResponse<unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { BeeRequestOptions, Collection, CollectionUploadOptions } from '..';
2
2
  import { BatchId } from './typed-bytes';
3
- export declare function uploadTar(requestOptions: BeeRequestOptions, collection: Collection, postageBatchId: BatchId, options?: CollectionUploadOptions): Promise<import("axios").AxiosResponse<unknown, any, {}>>;
3
+ export declare function uploadTar(requestOptions: BeeRequestOptions, collection: Collection, postageBatchId: BatchId, options?: CollectionUploadOptions): Promise<import("./http").BeeResponse<unknown>>;
@@ -5,9 +5,11 @@ export declare class BZZ {
5
5
  private constructor();
6
6
  static fromDecimalString(string: string): BZZ;
7
7
  static fromPLUR(plur: NumberString | string | bigint): BZZ;
8
+ static fromFloat(float: number): BZZ;
8
9
  toPLURString(): string;
9
10
  toPLURBigInt(): bigint;
10
11
  toDecimalString(): string;
12
+ toFloat(): number;
11
13
  toSignificantDigits(digits: number): string;
12
14
  /**
13
15
  * Does not mutate the current BZZ instance.
@@ -43,10 +45,12 @@ export declare class DAI {
43
45
  private constructor();
44
46
  static fromDecimalString(string: string): DAI;
45
47
  static fromWei(wei: NumberString | string | bigint): DAI;
48
+ static fromFloat(float: number): DAI;
46
49
  toWeiString(): string;
47
50
  toWeiBigInt(): bigint;
48
51
  toDecimalString(): string;
49
52
  toSignificantDigits(digits: number): string;
53
+ toFloat(): number;
50
54
  /**
51
55
  * Does not mutate the current DAI instance.
52
56
  *