@ethersphere/bee-js 12.0.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/cjs/bee.js +3 -4
- package/dist/cjs/utils/tokens.js +12 -0
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +3 -4
- package/dist/mjs/utils/tokens.js +12 -0
- package/dist/types/bee.d.ts +2 -2
- package/dist/types/utils/tokens.d.ts +4 -0
- package/package.json +2 -2
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
|
|
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(
|
|
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(
|
|
1744
|
+
const amount = bzz.toPLURBigInt() / 2n ** BigInt(depth);
|
|
1746
1745
|
const duration = getStampDuration(amount, chainState.currentPrice, blockTime);
|
|
1747
1746
|
return {
|
|
1748
1747
|
amount,
|
package/dist/mjs/utils/tokens.js
CHANGED
|
@@ -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
|
*
|
package/dist/types/bee.d.ts
CHANGED
|
@@ -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
|
|
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(
|
|
1165
|
+
calculateTopUpForBzz(depth: number, bzz: BZZ, requestOptions?: BeeRequestOptions): Promise<{
|
|
1166
1166
|
amount: bigint;
|
|
1167
1167
|
duration: Duration;
|
|
1168
1168
|
}>;
|
|
@@ -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": "12.
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"axios": "^1.15.1",
|
|
65
|
-
"cafe-utility": "^33.
|
|
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",
|