@ethersphere/bee-js 11.2.0 → 12.1.0

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
@@ -1733,16 +1733,15 @@ export class Bee {
1733
1733
  /**
1734
1734
  * Calculates the `amount` and expected duration extension for topping up a postage batch with a given BZZ value.
1735
1735
  *
1736
- * @param postageBatchId
1736
+ * @param depth Depth of the postage batch to top up.
1737
1737
  * @param bzz The amount of BZZ to spend on the top-up.
1738
1738
  * @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
1739
1739
  * @returns An object with `amount` (to pass to {@link topUpBatch}) and `duration` (the expected TTL extension).
1740
1740
  */
1741
- async calculateTopUpForBzz(postageBatchId, bzz, requestOptions) {
1742
- const batch = await this.getPostageBatch(postageBatchId, requestOptions);
1741
+ async calculateTopUpForBzz(depth, bzz, requestOptions) {
1743
1742
  const chainState = await this.getChainState(requestOptions);
1744
1743
  const blockTime = this.network === 'gnosis' ? 5 : 15;
1745
- const amount = bzz.toPLURBigInt() / 2n ** BigInt(batch.depth);
1744
+ const amount = bzz.toPLURBigInt() / 2n ** BigInt(depth);
1746
1745
  const duration = getStampDuration(amount, chainState.currentPrice, blockTime);
1747
1746
  return {
1748
1747
  amount,
@@ -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
  *
@@ -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,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("axios").AxiosResponse<unknown, any, {}>>;
@@ -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("axios").AxiosResponse<unknown, any, {}>>;
@@ -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
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "11.2.0",
3
+ "version": "12.1.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",
@@ -61,8 +61,8 @@
61
61
  "depcheck": "depcheck ."
62
62
  },
63
63
  "dependencies": {
64
- "axios": "^0.30.2",
65
- "cafe-utility": "^33.6.1",
64
+ "axios": "^1.15.1",
65
+ "cafe-utility": "^33.9.0",
66
66
  "debug": "^4.4.1",
67
67
  "isomorphic-ws": "^4.0.1",
68
68
  "semver": "^7.3.5",