@ethersphere/bee-js 10.1.2 → 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.
@@ -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;