@upcoming/bee-js 0.13.0 → 0.15.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 +10 -1
- package/dist/cjs/utils/expose.js +2 -1
- package/dist/cjs/utils/stamps.js +17 -9
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +10 -1
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/stamps.js +8 -1
- package/dist/types/bee.d.ts +1 -0
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/stamps.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/bee.js
CHANGED
|
@@ -713,7 +713,7 @@ class Bee {
|
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
-
gsocMine(targetOverlay, identifier, proximity =
|
|
716
|
+
gsocMine(targetOverlay, identifier, proximity = 12) {
|
|
717
717
|
targetOverlay = new typed_bytes_1.PeerAddress(targetOverlay);
|
|
718
718
|
identifier = new typed_bytes_1.Identifier(identifier);
|
|
719
719
|
const start = 0xb33n;
|
|
@@ -1190,6 +1190,15 @@ class Bee {
|
|
|
1190
1190
|
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice);
|
|
1191
1191
|
return this.topUpBatch(batch.batchID, amount, options);
|
|
1192
1192
|
}
|
|
1193
|
+
async getExtensionCost(postageBatchId, gigabytes, duration, options) {
|
|
1194
|
+
const batch = await this.getPostageBatch(postageBatchId, options);
|
|
1195
|
+
const chainState = await this.getChainState(options);
|
|
1196
|
+
const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice);
|
|
1197
|
+
const depth = (0, stamps_1.getDepthForSize)(gigabytes);
|
|
1198
|
+
const currentValue = (0, stamps_1.getStampCost)(batch.depth, batch.amount);
|
|
1199
|
+
const newValue = (0, stamps_1.getStampCost)(depth, amount);
|
|
1200
|
+
return newValue.minus(currentValue);
|
|
1201
|
+
}
|
|
1193
1202
|
async getSizeExtensionCost(postageBatchId, gigabytes, options) {
|
|
1194
1203
|
const batch = await this.getPostageBatch(postageBatchId, options);
|
|
1195
1204
|
const depth = (0, stamps_1.getDepthForSize)(gigabytes);
|
package/dist/cjs/utils/expose.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStampUsage = exports.getStampTheoreticalBytes = exports.getStampEffectiveBytes = exports.getStampDuration = exports.getStampCost = exports.getDepthForSize = exports.getAmountForDuration = exports.getRedundancyStats = exports.getRedundancyStat = exports.approximateOverheadForRedundancyLevel = exports.makeMaxTarget = exports.getFolderSize = exports.makeCollectionFromFileList = exports.getCollectionSize = void 0;
|
|
3
|
+
exports.getStampUsage = exports.getStampTheoreticalBytes = exports.getStampEffectiveBytesBreakpoints = exports.getStampEffectiveBytes = exports.getStampDuration = exports.getStampCost = exports.getDepthForSize = exports.getAmountForDuration = exports.getRedundancyStats = exports.getRedundancyStat = exports.approximateOverheadForRedundancyLevel = exports.makeMaxTarget = exports.getFolderSize = exports.makeCollectionFromFileList = exports.getCollectionSize = void 0;
|
|
4
4
|
var collection_1 = require("./collection");
|
|
5
5
|
Object.defineProperty(exports, "getCollectionSize", { enumerable: true, get: function () { return collection_1.getCollectionSize; } });
|
|
6
6
|
Object.defineProperty(exports, "makeCollectionFromFileList", { enumerable: true, get: function () { return collection_1.makeCollectionFromFileList; } });
|
|
@@ -18,5 +18,6 @@ Object.defineProperty(exports, "getDepthForSize", { enumerable: true, get: funct
|
|
|
18
18
|
Object.defineProperty(exports, "getStampCost", { enumerable: true, get: function () { return stamps_1.getStampCost; } });
|
|
19
19
|
Object.defineProperty(exports, "getStampDuration", { enumerable: true, get: function () { return stamps_1.getStampDuration; } });
|
|
20
20
|
Object.defineProperty(exports, "getStampEffectiveBytes", { enumerable: true, get: function () { return stamps_1.getStampEffectiveBytes; } });
|
|
21
|
+
Object.defineProperty(exports, "getStampEffectiveBytesBreakpoints", { enumerable: true, get: function () { return stamps_1.getStampEffectiveBytesBreakpoints; } });
|
|
21
22
|
Object.defineProperty(exports, "getStampTheoreticalBytes", { enumerable: true, get: function () { return stamps_1.getStampTheoreticalBytes; } });
|
|
22
23
|
Object.defineProperty(exports, "getStampUsage", { enumerable: true, get: function () { return stamps_1.getStampUsage; } });
|
package/dist/cjs/utils/stamps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.marshalStamp = exports.convertEnvelopeToMarshaledStamp = exports.getDepthForSize = exports.getAmountForDuration = exports.getStampDuration = exports.getStampCost = exports.getStampEffectiveBytes = exports.getStampTheoreticalBytes = exports.getStampUsage = void 0;
|
|
3
|
+
exports.marshalStamp = exports.convertEnvelopeToMarshaledStamp = exports.getDepthForSize = exports.getAmountForDuration = exports.getStampDuration = exports.getStampCost = exports.getStampEffectiveBytesBreakpoints = exports.getStampEffectiveBytes = exports.getStampTheoreticalBytes = exports.getStampUsage = void 0;
|
|
4
4
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
5
|
const bytes_1 = require("./bytes");
|
|
6
6
|
const duration_1 = require("./duration");
|
|
@@ -51,14 +51,14 @@ const effectiveSizeBreakpoints = [
|
|
|
51
51
|
[23, 17.03],
|
|
52
52
|
[24, 44.21],
|
|
53
53
|
[25, 102.78],
|
|
54
|
-
[26, 225.
|
|
55
|
-
[27, 480.
|
|
56
|
-
[28,
|
|
57
|
-
[29,
|
|
58
|
-
[30,
|
|
59
|
-
[31,
|
|
60
|
-
[32,
|
|
61
|
-
[33,
|
|
54
|
+
[26, 225.87],
|
|
55
|
+
[27, 480.44],
|
|
56
|
+
[28, 1001.44],
|
|
57
|
+
[29, 2060.27],
|
|
58
|
+
[30, 4201.9],
|
|
59
|
+
[31, 8519.02],
|
|
60
|
+
[32, 17199.89],
|
|
61
|
+
[33, 34628.46],
|
|
62
62
|
];
|
|
63
63
|
/**
|
|
64
64
|
* Utility function that calculates the effective size of a postage batch based on its depth.
|
|
@@ -76,6 +76,14 @@ function getStampEffectiveBytes(depth) {
|
|
|
76
76
|
return Math.ceil(getStampTheoreticalBytes(depth) * utilRate);
|
|
77
77
|
}
|
|
78
78
|
exports.getStampEffectiveBytes = getStampEffectiveBytes;
|
|
79
|
+
function getStampEffectiveBytesBreakpoints() {
|
|
80
|
+
const map = new Map();
|
|
81
|
+
for (let i = 22; i < 35; i++) {
|
|
82
|
+
map.set(i, getStampEffectiveBytes(i));
|
|
83
|
+
}
|
|
84
|
+
return map;
|
|
85
|
+
}
|
|
86
|
+
exports.getStampEffectiveBytesBreakpoints = getStampEffectiveBytesBreakpoints;
|
|
79
87
|
/**
|
|
80
88
|
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
81
89
|
*/
|