@ethersphere/bee-js 10.1.1 → 10.2.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 CHANGED
@@ -1623,7 +1623,7 @@ class Bee {
1623
1623
  const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1624
1624
  const currentAmount = (0, stamps_1.getAmountForDuration)(batch.duration, chainState.currentPrice, blockTime);
1625
1625
  const currentCost = (0, stamps_1.getStampCost)(batch.depth, currentAmount);
1626
- const newCost = (0, stamps_1.getStampCost)(depth, currentAmount + amount);
1626
+ const newCost = (0, stamps_1.getStampCost)(Math.max(batch.depth, depth), currentAmount + amount);
1627
1627
  return newCost.minus(currentCost);
1628
1628
  }
1629
1629
  /**
@@ -316,7 +316,17 @@ class MantarayNode {
316
316
  */
317
317
  async saveRecursively(bee, postageBatchId, options, requestOptions) {
318
318
  for (const fork of this.forks.values()) {
319
- await fork.node.saveRecursively(bee, postageBatchId, options, requestOptions);
319
+ const uploadResult = await fork.node.saveRecursively(bee, postageBatchId, options, requestOptions);
320
+ if (options?.act) {
321
+ let historyAddress;
322
+ uploadResult.historyAddress.ifPresent(ref => (historyAddress = ref));
323
+ if (historyAddress) {
324
+ if (!fork.node.metadata) {
325
+ fork.node.metadata = {};
326
+ }
327
+ fork.node.metadata['swarm-act-history-address'] = historyAddress.toHex();
328
+ }
329
+ }
320
330
  }
321
331
  const result = await bee.uploadData(postageBatchId, await this.marshal(), options, requestOptions);
322
332
  this.selfAddress = result.reference.toUint8Array();
@@ -330,7 +340,14 @@ class MantarayNode {
330
340
  if (!fork.node.selfAddress) {
331
341
  throw Error('MantarayNode#loadRecursively fork.node.selfAddress is not set');
332
342
  }
333
- const node = await MantarayNode.unmarshal(bee, fork.node.selfAddress, options, requestOptions);
343
+ let downloadOptions = options;
344
+ if (fork.node.metadata && fork.node.metadata['swarm-act-history-address']) {
345
+ downloadOptions = {
346
+ ...options,
347
+ actHistoryAddress: fork.node.metadata['swarm-act-history-address'],
348
+ };
349
+ }
350
+ const node = await MantarayNode.unmarshal(bee, fork.node.selfAddress, downloadOptions, requestOptions);
334
351
  fork.node.targetAddress = node.targetAddress;
335
352
  fork.node.forks = node.forks;
336
353
  fork.node.path = fork.prefix;