@ethersphere/bee-js 9.0.3 → 9.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 +6 -5
- package/dist/cjs/utils/stamps.js +2 -2
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +6 -5
- package/dist/mjs/utils/stamps.js +2 -2
- package/dist/types/bee.d.ts +4 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/utils/stamps.d.ts +2 -2
- package/package.json +4 -5
package/dist/cjs/bee.js
CHANGED
|
@@ -84,6 +84,7 @@ class Bee {
|
|
|
84
84
|
if (options?.signer) {
|
|
85
85
|
this.signer = new typed_bytes_1.PrivateKey(options.signer);
|
|
86
86
|
}
|
|
87
|
+
this.network = options?.network ?? 'gnosis';
|
|
87
88
|
this.requestOptions = {
|
|
88
89
|
baseURL: this.url,
|
|
89
90
|
timeout: options?.timeout ?? 0,
|
|
@@ -1161,7 +1162,7 @@ class Bee {
|
|
|
1161
1162
|
}
|
|
1162
1163
|
async buyStorage(size, duration, options, requestOptions) {
|
|
1163
1164
|
const chainState = await this.getChainState(requestOptions);
|
|
1164
|
-
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice);
|
|
1165
|
+
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
|
|
1165
1166
|
const depth = (0, stamps_1.getDepthForSize)(size);
|
|
1166
1167
|
if (options) {
|
|
1167
1168
|
options = (0, type_1.preparePostageBatchOptions)(options);
|
|
@@ -1170,7 +1171,7 @@ class Bee {
|
|
|
1170
1171
|
}
|
|
1171
1172
|
async getStorageCost(size, duration, options) {
|
|
1172
1173
|
const chainState = await this.getChainState(options);
|
|
1173
|
-
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice);
|
|
1174
|
+
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
|
|
1174
1175
|
const depth = (0, stamps_1.getDepthForSize)(size);
|
|
1175
1176
|
return (0, stamps_1.getStampCost)(depth, amount);
|
|
1176
1177
|
}
|
|
@@ -1187,13 +1188,13 @@ class Bee {
|
|
|
1187
1188
|
async extendStorageDuration(postageBatchId, duration, options) {
|
|
1188
1189
|
const batch = await this.getPostageBatch(postageBatchId, options);
|
|
1189
1190
|
const chainState = await this.getChainState(options);
|
|
1190
|
-
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice);
|
|
1191
|
+
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
|
|
1191
1192
|
return this.topUpBatch(batch.batchID, amount, options);
|
|
1192
1193
|
}
|
|
1193
1194
|
async getExtensionCost(postageBatchId, size, duration, options) {
|
|
1194
1195
|
const batch = await this.getPostageBatch(postageBatchId, options);
|
|
1195
1196
|
const chainState = await this.getChainState(options);
|
|
1196
|
-
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice);
|
|
1197
|
+
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
|
|
1197
1198
|
const depth = (0, stamps_1.getDepthForSize)(size);
|
|
1198
1199
|
const currentValue = (0, stamps_1.getStampCost)(batch.depth, batch.amount);
|
|
1199
1200
|
const newValue = (0, stamps_1.getStampCost)(depth, amount);
|
|
@@ -1213,7 +1214,7 @@ class Bee {
|
|
|
1213
1214
|
async getDurationExtensionCost(postageBatchId, duration, options) {
|
|
1214
1215
|
const batch = await this.getPostageBatch(postageBatchId, options);
|
|
1215
1216
|
const chainState = await this.getChainState(options);
|
|
1216
|
-
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice);
|
|
1217
|
+
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
|
|
1217
1218
|
return (0, stamps_1.getStampCost)(batch.depth, amount);
|
|
1218
1219
|
}
|
|
1219
1220
|
/**
|
package/dist/cjs/utils/stamps.js
CHANGED
|
@@ -98,7 +98,7 @@ exports.getStampCost = getStampCost;
|
|
|
98
98
|
*
|
|
99
99
|
* @returns {number} The TTL of the postage batch.
|
|
100
100
|
*/
|
|
101
|
-
function getStampDuration(amount, pricePerBlock, blockTime
|
|
101
|
+
function getStampDuration(amount, pricePerBlock, blockTime) {
|
|
102
102
|
const amountBigInt = BigInt((0, type_1.asNumberString)(amount));
|
|
103
103
|
return duration_1.Duration.fromSeconds(Number((amountBigInt * BigInt(blockTime)) / BigInt(pricePerBlock)));
|
|
104
104
|
}
|
|
@@ -110,7 +110,7 @@ exports.getStampDuration = getStampDuration;
|
|
|
110
110
|
* @param pricePerBlock The price per block in PLUR.
|
|
111
111
|
* @param blockTime The block time in seconds.
|
|
112
112
|
*/
|
|
113
|
-
function getAmountForDuration(duration, pricePerBlock, blockTime
|
|
113
|
+
function getAmountForDuration(duration, pricePerBlock, blockTime) {
|
|
114
114
|
return (BigInt(duration.toSeconds()) / BigInt(blockTime)) * BigInt(pricePerBlock);
|
|
115
115
|
}
|
|
116
116
|
exports.getAmountForDuration = getAmountForDuration;
|