@upcoming/bee-js 9.7.0 → 9.8.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 +16 -0
- package/dist/cjs/utils/chunk-stream.js +15 -3
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +14 -0
- package/dist/mjs/utils/chunk-stream.js +14 -3
- package/dist/types/bee.d.ts +2 -1
- package/dist/types/utils/chunk-stream.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/bee.js
CHANGED
|
@@ -1226,6 +1226,22 @@ class Bee {
|
|
|
1226
1226
|
const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
|
|
1227
1227
|
return (0, stamps_1.getStampCost)(depth, amount);
|
|
1228
1228
|
}
|
|
1229
|
+
async extendStorage(postageBatchId, size, duration, options, encryption, erasureCodeLevel) {
|
|
1230
|
+
const batch = await this.getPostageBatch(postageBatchId, options);
|
|
1231
|
+
const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
|
|
1232
|
+
const chainState = await this.getChainState(options);
|
|
1233
|
+
const depthDelta = depth - batch.depth;
|
|
1234
|
+
const multiplier = depthDelta === 0 ? 1n : 2n ** BigInt(depthDelta);
|
|
1235
|
+
const targetAmount = (BigInt(batch.amount) +
|
|
1236
|
+
(0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15)) *
|
|
1237
|
+
multiplier;
|
|
1238
|
+
const amountDelta = targetAmount - BigInt(batch.amount);
|
|
1239
|
+
const transactionId = await this.topUpBatch(batch.batchID, amountDelta, options);
|
|
1240
|
+
if (depthDelta) {
|
|
1241
|
+
return this.diluteBatch(batch.batchID, depth, options);
|
|
1242
|
+
}
|
|
1243
|
+
return transactionId;
|
|
1244
|
+
}
|
|
1229
1245
|
async extendStorageSize(postageBatchId, size, options, encryption, erasureCodeLevel) {
|
|
1230
1246
|
const batch = await this.getPostageBatch(postageBatchId, options);
|
|
1231
1247
|
const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
|
|
@@ -40,6 +40,7 @@ async function streamDirectory(bee, dir, postageBatchId, onUploadProgress, optio
|
|
|
40
40
|
for (const file of files) {
|
|
41
41
|
total += (0, chunk_size_1.totalChunks)(file.size);
|
|
42
42
|
}
|
|
43
|
+
let hasIndexHtml = false;
|
|
43
44
|
async function onChunk(chunk) {
|
|
44
45
|
await queue.enqueue(async () => {
|
|
45
46
|
await bee.uploadChunk(postageBatchId, chunk.build(), options, requestOptions);
|
|
@@ -64,11 +65,22 @@ async function streamDirectory(bee, dir, postageBatchId, onUploadProgress, optio
|
|
|
64
65
|
Filename: filename,
|
|
65
66
|
});
|
|
66
67
|
if (file.path === 'index.html') {
|
|
67
|
-
|
|
68
|
-
'website-index-document': 'index.html',
|
|
69
|
-
});
|
|
68
|
+
hasIndexHtml = true;
|
|
70
69
|
}
|
|
71
70
|
}
|
|
71
|
+
if (hasIndexHtml || options?.indexDocument || options?.errorDocument) {
|
|
72
|
+
const metadata = {};
|
|
73
|
+
if (options?.indexDocument) {
|
|
74
|
+
metadata['website-index-document'] = options.indexDocument;
|
|
75
|
+
}
|
|
76
|
+
else if (hasIndexHtml) {
|
|
77
|
+
metadata['website-index-document'] = 'index.html';
|
|
78
|
+
}
|
|
79
|
+
if (options?.errorDocument) {
|
|
80
|
+
metadata['website-error-document'] = options.errorDocument;
|
|
81
|
+
}
|
|
82
|
+
mantaray.addFork('/', __1.NULL_ADDRESS, metadata);
|
|
83
|
+
}
|
|
72
84
|
return mantaray.saveRecursively(bee, postageBatchId, options, requestOptions);
|
|
73
85
|
}
|
|
74
86
|
exports.streamDirectory = streamDirectory;
|