@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/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/tar-uploader.browser.d.ts +1 -1
- package/dist/types/utils/tar-uploader.d.ts +1 -1
- package/dist/types/utils/tokens.d.ts +4 -0
- package/package.json +3 -3
package/dist/cjs/bee.js
CHANGED
|
@@ -1760,16 +1760,15 @@ class Bee {
|
|
|
1760
1760
|
/**
|
|
1761
1761
|
* Calculates the `amount` and expected duration extension for topping up a postage batch with a given BZZ value.
|
|
1762
1762
|
*
|
|
1763
|
-
* @param
|
|
1763
|
+
* @param depth Depth of the postage batch to top up.
|
|
1764
1764
|
* @param bzz The amount of BZZ to spend on the top-up.
|
|
1765
1765
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
1766
1766
|
* @returns An object with `amount` (to pass to {@link topUpBatch}) and `duration` (the expected TTL extension).
|
|
1767
1767
|
*/
|
|
1768
|
-
async calculateTopUpForBzz(
|
|
1769
|
-
const batch = await this.getPostageBatch(postageBatchId, requestOptions);
|
|
1768
|
+
async calculateTopUpForBzz(depth, bzz, requestOptions) {
|
|
1770
1769
|
const chainState = await this.getChainState(requestOptions);
|
|
1771
1770
|
const blockTime = this.network === 'gnosis' ? 5 : 15;
|
|
1772
|
-
const amount = bzz.toPLURBigInt() / 2n ** BigInt(
|
|
1771
|
+
const amount = bzz.toPLURBigInt() / 2n ** BigInt(depth);
|
|
1773
1772
|
const duration = (0, stamps_1.getStampDuration)(amount, chainState.currentPrice, blockTime);
|
|
1774
1773
|
return { amount, duration };
|
|
1775
1774
|
}
|
package/dist/cjs/utils/tokens.js
CHANGED
|
@@ -12,6 +12,9 @@ class BZZ {
|
|
|
12
12
|
static fromPLUR(plur) {
|
|
13
13
|
return new BZZ(new cafe_utility_1.FixedPointNumber(plur, BZZ.DIGITS));
|
|
14
14
|
}
|
|
15
|
+
static fromFloat(float) {
|
|
16
|
+
return new BZZ(cafe_utility_1.FixedPointNumber.fromFloat(float, BZZ.DIGITS));
|
|
17
|
+
}
|
|
15
18
|
toPLURString() {
|
|
16
19
|
return this.state.toString();
|
|
17
20
|
}
|
|
@@ -21,6 +24,9 @@ class BZZ {
|
|
|
21
24
|
toDecimalString() {
|
|
22
25
|
return this.state.toDecimalString();
|
|
23
26
|
}
|
|
27
|
+
toFloat() {
|
|
28
|
+
return this.state.toFloat();
|
|
29
|
+
}
|
|
24
30
|
toSignificantDigits(digits) {
|
|
25
31
|
return this.toDecimalString().slice(0, this.toDecimalString().indexOf('.') + digits + 1);
|
|
26
32
|
}
|
|
@@ -82,6 +88,9 @@ class DAI {
|
|
|
82
88
|
static fromWei(wei) {
|
|
83
89
|
return new DAI(new cafe_utility_1.FixedPointNumber(wei, DAI.DIGITS));
|
|
84
90
|
}
|
|
91
|
+
static fromFloat(float) {
|
|
92
|
+
return new DAI(cafe_utility_1.FixedPointNumber.fromFloat(float, DAI.DIGITS));
|
|
93
|
+
}
|
|
85
94
|
toWeiString() {
|
|
86
95
|
return this.state.toString();
|
|
87
96
|
}
|
|
@@ -94,6 +103,9 @@ class DAI {
|
|
|
94
103
|
toSignificantDigits(digits) {
|
|
95
104
|
return this.toDecimalString().slice(0, this.toDecimalString().indexOf('.') + digits + 1);
|
|
96
105
|
}
|
|
106
|
+
toFloat() {
|
|
107
|
+
return this.state.toFloat();
|
|
108
|
+
}
|
|
97
109
|
/**
|
|
98
110
|
* Does not mutate the current DAI instance.
|
|
99
111
|
*
|