@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/mjs/bee.js CHANGED
@@ -686,7 +686,7 @@ export class Bee {
686
686
  }
687
687
  });
688
688
  }
689
- gsocMine(targetOverlay, identifier, proximity = 16) {
689
+ gsocMine(targetOverlay, identifier, proximity = 12) {
690
690
  targetOverlay = new PeerAddress(targetOverlay);
691
691
  identifier = new Identifier(identifier);
692
692
  const start = 0xb33n;
@@ -1176,6 +1176,15 @@ export class Bee {
1176
1176
  const amount = getAmountForDuration(duration, chainState.currentPrice);
1177
1177
  return this.topUpBatch(batch.batchID, amount, options);
1178
1178
  }
1179
+ async getExtensionCost(postageBatchId, gigabytes, duration, options) {
1180
+ const batch = await this.getPostageBatch(postageBatchId, options);
1181
+ const chainState = await this.getChainState(options);
1182
+ const amount = getAmountForDuration(duration, chainState.currentPrice);
1183
+ const depth = getDepthForSize(gigabytes);
1184
+ const currentValue = getStampCost(batch.depth, batch.amount);
1185
+ const newValue = getStampCost(depth, amount);
1186
+ return newValue.minus(currentValue);
1187
+ }
1179
1188
  async getSizeExtensionCost(postageBatchId, gigabytes, options) {
1180
1189
  const batch = await this.getPostageBatch(postageBatchId, options);
1181
1190
  const depth = getDepthForSize(gigabytes);
@@ -2,4 +2,4 @@ export { getCollectionSize, makeCollectionFromFileList } from "./collection.js";
2
2
  export { getFolderSize } from "./collection.node.js";
3
3
  export { makeMaxTarget } from "./pss.js";
4
4
  export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from "./redundancy.js";
5
- export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampTheoreticalBytes, getStampUsage } from "./stamps.js";
5
+ export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage } from "./stamps.js";
@@ -41,7 +41,7 @@ const utilisationRateMap = {
41
41
  33: 0.9842,
42
42
  34: 0.9889
43
43
  };
44
- const effectiveSizeBreakpoints = [[22, 4.93], [23, 17.03], [24, 44.21], [25, 102.78], [26, 225.86], [27, 480.43], [28, 1.0], [29, 2.06], [30, 4.2], [31, 8.52], [32, 17.2], [33, 34.63]];
44
+ const effectiveSizeBreakpoints = [[22, 4.93], [23, 17.03], [24, 44.21], [25, 102.78], [26, 225.87], [27, 480.44], [28, 1001.44], [29, 2060.27], [30, 4201.9], [31, 8519.02], [32, 17199.89], [33, 34628.46]];
45
45
  /**
46
46
  * Utility function that calculates the effective size of a postage batch based on its depth.
47
47
  *
@@ -57,6 +57,13 @@ export function getStampEffectiveBytes(depth) {
57
57
  const utilRate = utilisationRateMap[depth] ?? 0.99;
58
58
  return Math.ceil(getStampTheoreticalBytes(depth) * utilRate);
59
59
  }
60
+ export function getStampEffectiveBytesBreakpoints() {
61
+ const map = new Map();
62
+ for (let i = 22; i < 35; i++) {
63
+ map.set(i, getStampEffectiveBytes(i));
64
+ }
65
+ return map;
66
+ }
60
67
  /**
61
68
  * Utility function that calculates the cost of a postage batch based on its depth and amount.
62
69
  */
@@ -653,6 +653,7 @@ export declare class Bee {
653
653
  getStorageCost(gigabytes: number, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>;
654
654
  extendStorageSize(postageBatchId: BatchId | Uint8Array | string, gigabytes: number, options?: BeeRequestOptions): Promise<BatchId>;
655
655
  extendStorageDuration(postageBatchId: BatchId | Uint8Array | string, duration: Duration, options?: BeeRequestOptions): Promise<BatchId>;
656
+ getExtensionCost(postageBatchId: BatchId | Uint8Array | string, gigabytes: number, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>;
656
657
  getSizeExtensionCost(postageBatchId: BatchId | Uint8Array | string, gigabytes: number, options?: BeeRequestOptions): Promise<BZZ>;
657
658
  getDurationExtensionCost(postageBatchId: BatchId | Uint8Array | string, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>;
658
659
  /**
@@ -2,4 +2,4 @@ export { getCollectionSize, makeCollectionFromFileList } from './collection';
2
2
  export { getFolderSize } from './collection.node';
3
3
  export { makeMaxTarget } from './pss';
4
4
  export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy';
5
- export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampTheoreticalBytes, getStampUsage, } from './stamps';
5
+ export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage, } from './stamps';
@@ -27,6 +27,7 @@ export declare function getStampTheoreticalBytes(depth: number): number;
27
27
  * @returns {number} The effective size of the postage batch in bytes.
28
28
  */
29
29
  export declare function getStampEffectiveBytes(depth: number): number;
30
+ export declare function getStampEffectiveBytesBreakpoints(): Map<number, number>;
30
31
  /**
31
32
  * Utility function that calculates the cost of a postage batch based on its depth and amount.
32
33
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upcoming/bee-js",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",