@upcoming/bee-js 10.1.2 → 12.0.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.
Files changed (95) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/bee.js +105 -12
  3. package/dist/cjs/chunk/bmt.js +1 -2
  4. package/dist/cjs/chunk/cac.js +27 -32
  5. package/dist/cjs/chunk/soc.js +39 -31
  6. package/dist/cjs/feed/identifier.js +1 -2
  7. package/dist/cjs/feed/index.js +29 -19
  8. package/dist/cjs/feed/retrievable.js +1 -2
  9. package/dist/cjs/index.js +17 -7
  10. package/dist/cjs/manifest/manifest.js +19 -2
  11. package/dist/cjs/modules/bytes.js +4 -5
  12. package/dist/cjs/modules/bzz.js +4 -5
  13. package/dist/cjs/modules/chunk.js +2 -3
  14. package/dist/cjs/modules/debug/balance.js +4 -5
  15. package/dist/cjs/modules/debug/chequebook.js +8 -9
  16. package/dist/cjs/modules/debug/connectivity.js +7 -8
  17. package/dist/cjs/modules/debug/settlements.js +2 -3
  18. package/dist/cjs/modules/debug/stake.js +6 -7
  19. package/dist/cjs/modules/debug/stamps.js +23 -77
  20. package/dist/cjs/modules/debug/states.js +6 -6
  21. package/dist/cjs/modules/debug/status.js +9 -9
  22. package/dist/cjs/modules/debug/transactions.js +4 -5
  23. package/dist/cjs/modules/envelope.js +1 -2
  24. package/dist/cjs/modules/feed.js +3 -4
  25. package/dist/cjs/modules/grantee.js +3 -4
  26. package/dist/cjs/modules/gsoc.js +2 -3
  27. package/dist/cjs/modules/pinning.js +4 -5
  28. package/dist/cjs/modules/pss.js +2 -3
  29. package/dist/cjs/modules/rchash.js +1 -2
  30. package/dist/cjs/modules/soc.js +1 -2
  31. package/dist/cjs/modules/status.js +2 -3
  32. package/dist/cjs/modules/stewardship.js +2 -3
  33. package/dist/cjs/modules/tag.js +5 -6
  34. package/dist/cjs/types/debug.js +3 -3
  35. package/dist/cjs/types/index.js +2 -2
  36. package/dist/cjs/utils/bytes.js +2 -2
  37. package/dist/cjs/utils/chunk-size.js +1 -2
  38. package/dist/cjs/utils/chunk-stream.browser.js +30 -6
  39. package/dist/cjs/utils/chunk-stream.js +3 -4
  40. package/dist/cjs/utils/cid.js +3 -3
  41. package/dist/cjs/utils/collection.browser.js +2 -3
  42. package/dist/cjs/utils/collection.js +5 -6
  43. package/dist/cjs/utils/collection.node.js +2 -3
  44. package/dist/cjs/utils/data.browser.js +1 -2
  45. package/dist/cjs/utils/data.js +1 -2
  46. package/dist/cjs/utils/expose.js +4 -1
  47. package/dist/cjs/utils/file.js +2 -3
  48. package/dist/cjs/utils/headers.js +2 -3
  49. package/dist/cjs/utils/http.js +25 -5
  50. package/dist/cjs/utils/pss.js +1 -2
  51. package/dist/cjs/utils/redundancy.js +3 -4
  52. package/dist/cjs/utils/stamps.js +60 -11
  53. package/dist/cjs/utils/tar-uploader.browser.js +1 -2
  54. package/dist/cjs/utils/tar-uploader.js +1 -2
  55. package/dist/cjs/utils/tar-writer.browser.js +1 -2
  56. package/dist/cjs/utils/tar-writer.js +1 -2
  57. package/dist/cjs/utils/type.js +35 -25
  58. package/dist/cjs/utils/url.js +3 -4
  59. package/dist/cjs/utils/workaround.js +7 -5
  60. package/dist/index.browser.min.js +1 -1
  61. package/dist/index.browser.min.js.map +1 -1
  62. package/dist/mjs/bee.js +93 -9
  63. package/dist/mjs/chunk/cac.js +21 -30
  64. package/dist/mjs/chunk/soc.js +16 -17
  65. package/dist/mjs/feed/index.js +7 -6
  66. package/dist/mjs/manifest/manifest.js +19 -2
  67. package/dist/mjs/modules/debug/stamps.js +37 -110
  68. package/dist/mjs/modules/debug/states.js +3 -0
  69. package/dist/mjs/modules/debug/status.js +1 -1
  70. package/dist/mjs/utils/chunk-stream.browser.js +29 -5
  71. package/dist/mjs/utils/expose.js +1 -1
  72. package/dist/mjs/utils/http.js +25 -3
  73. package/dist/mjs/utils/stamps.js +48 -0
  74. package/dist/mjs/utils/type.js +2 -1
  75. package/dist/mjs/utils/workaround.js +5 -2
  76. package/dist/types/bee.d.ts +67 -4
  77. package/dist/types/chunk/cac.d.ts +27 -13
  78. package/dist/types/chunk/soc.d.ts +43 -11
  79. package/dist/types/index.d.ts +3 -0
  80. package/dist/types/modules/bzz.d.ts +0 -1
  81. package/dist/types/modules/debug/status.d.ts +1 -1
  82. package/dist/types/modules/gsoc.d.ts +0 -1
  83. package/dist/types/modules/pss.d.ts +0 -1
  84. package/dist/types/types/debug.d.ts +1 -0
  85. package/dist/types/types/index.d.ts +1 -0
  86. package/dist/types/utils/constants.d.ts +3 -3
  87. package/dist/types/utils/error.d.ts +2 -2
  88. package/dist/types/utils/expose.d.ts +1 -1
  89. package/dist/types/utils/stamps.d.ts +15 -1
  90. package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
  91. package/dist/types/utils/tar-uploader.d.ts +1 -1
  92. package/dist/types/utils/tar.browser.d.ts +1 -1
  93. package/dist/types/utils/tar.d.ts +0 -1
  94. package/dist/types/utils/type.d.ts +0 -1
  95. package/package.json +10 -13
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadReadable = exports.download = exports.head = exports.upload = void 0;
3
+ exports.upload = upload;
4
+ exports.head = head;
5
+ exports.download = download;
6
+ exports.downloadReadable = downloadReadable;
4
7
  const cafe_utility_1 = require("cafe-utility");
5
8
  const bytes_1 = require("../utils/bytes");
6
9
  const headers_1 = require("../utils/headers");
@@ -36,7 +39,6 @@ async function upload(requestOptions, data, postageBatchId, options) {
36
39
  : cafe_utility_1.Optional.empty(),
37
40
  };
38
41
  }
39
- exports.upload = upload;
40
42
  /**
41
43
  * Requests content length for a reference
42
44
  *
@@ -54,7 +56,6 @@ async function head(requestOptions, reference) {
54
56
  contentLength: parseInt(response.headers['content-length']),
55
57
  };
56
58
  }
57
- exports.head = head;
58
59
  /**
59
60
  * Download data as a byte array
60
61
  *
@@ -72,7 +73,6 @@ async function download(requestOptions, resource, options) {
72
73
  });
73
74
  return new bytes_1.Bytes(response.data);
74
75
  }
75
- exports.download = download;
76
76
  /**
77
77
  * Download data as a readable stream
78
78
  *
@@ -90,4 +90,3 @@ async function downloadReadable(requestOptions, resource, options) {
90
90
  });
91
91
  return response.data;
92
92
  }
93
- exports.downloadReadable = downloadReadable;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadCollection = exports.downloadFileReadable = exports.downloadFile = exports.uploadFile = void 0;
3
+ exports.uploadFile = uploadFile;
4
+ exports.downloadFile = downloadFile;
5
+ exports.downloadFileReadable = downloadFileReadable;
6
+ exports.uploadCollection = uploadCollection;
4
7
  const cafe_utility_1 = require("cafe-utility");
5
8
  const bytes_1 = require("../utils/bytes");
6
9
  const collection_1 = require("../utils/collection");
@@ -43,7 +46,6 @@ async function uploadFile(requestOptions, data, postageBatchId, name, options) {
43
46
  : cafe_utility_1.Optional.empty(),
44
47
  };
45
48
  }
46
- exports.uploadFile = uploadFile;
47
49
  /**
48
50
  * Download single file as a buffer
49
51
  *
@@ -64,7 +66,6 @@ async function downloadFile(requestOptions, resource, path = '', options) {
64
66
  };
65
67
  return file;
66
68
  }
67
- exports.downloadFile = downloadFile;
68
69
  /**
69
70
  * Download single file as a readable stream
70
71
  *
@@ -86,7 +87,6 @@ async function downloadFileReadable(requestOptions, reference, path = '', option
86
87
  };
87
88
  return file;
88
89
  }
89
- exports.downloadFileReadable = downloadFileReadable;
90
90
  /*******************************************************************************************************************/
91
91
  // Collections
92
92
  /**
@@ -108,4 +108,3 @@ async function uploadCollection(requestOptions, collection, postageBatchId, opti
108
108
  : cafe_utility_1.Optional.empty(),
109
109
  };
110
110
  }
111
- exports.uploadCollection = uploadCollection;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.download = exports.upload = void 0;
3
+ exports.upload = upload;
4
+ exports.download = download;
4
5
  const cafe_utility_1 = require("cafe-utility");
5
6
  const headers_1 = require("../utils/headers");
6
7
  const http_1 = require("../utils/http");
@@ -39,7 +40,6 @@ async function upload(requestOptions, data, stamp, options) {
39
40
  : cafe_utility_1.Optional.empty(),
40
41
  };
41
42
  }
42
- exports.upload = upload;
43
43
  /**
44
44
  * Download chunk data as a byte array
45
45
  *
@@ -56,4 +56,3 @@ async function download(requestOptions, reference, options) {
56
56
  });
57
57
  return new Uint8Array(response.data);
58
58
  }
59
- exports.download = download;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPastDueConsumptionPeerBalance = exports.getPastDueConsumptionBalances = exports.getPeerBalance = exports.getAllBalances = void 0;
3
+ exports.getAllBalances = getAllBalances;
4
+ exports.getPeerBalance = getPeerBalance;
5
+ exports.getPastDueConsumptionBalances = getPastDueConsumptionBalances;
6
+ exports.getPastDueConsumptionPeerBalance = getPastDueConsumptionPeerBalance;
4
7
  const cafe_utility_1 = require("cafe-utility");
5
8
  const http_1 = require("../../utils/http");
6
9
  const tokens_1 = require("../../utils/tokens");
@@ -26,7 +29,6 @@ async function getAllBalances(requestOptions) {
26
29
  })),
27
30
  };
28
31
  }
29
- exports.getAllBalances = getAllBalances;
30
32
  /**
31
33
  * Get the balances with a specific peer including prepaid services
32
34
  *
@@ -44,7 +46,6 @@ async function getPeerBalance(requestOptions, address) {
44
46
  balance: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.balance, { name: 'balance' })),
45
47
  };
46
48
  }
47
- exports.getPeerBalance = getPeerBalance;
48
49
  /**
49
50
  * Get the past due consumption balances with all known peers
50
51
  *
@@ -64,7 +65,6 @@ async function getPastDueConsumptionBalances(requestOptions) {
64
65
  })),
65
66
  };
66
67
  }
67
- exports.getPastDueConsumptionBalances = getPastDueConsumptionBalances;
68
68
  /**
69
69
  * Get the past due consumption balance with a specific peer
70
70
  *
@@ -82,4 +82,3 @@ async function getPastDueConsumptionPeerBalance(requestOptions, address) {
82
82
  balance: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.balance, { name: 'balance' })),
83
83
  };
84
84
  }
85
- exports.getPastDueConsumptionPeerBalance = getPastDueConsumptionPeerBalance;
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withdrawTokens = exports.depositTokens = exports.getLastCheques = exports.getLastChequesForPeer = exports.cashoutLastCheque = exports.getLastCashoutAction = exports.getChequebookBalance = exports.getChequebookAddress = void 0;
3
+ exports.getChequebookAddress = getChequebookAddress;
4
+ exports.getChequebookBalance = getChequebookBalance;
5
+ exports.getLastCashoutAction = getLastCashoutAction;
6
+ exports.cashoutLastCheque = cashoutLastCheque;
7
+ exports.getLastChequesForPeer = getLastChequesForPeer;
8
+ exports.getLastCheques = getLastCheques;
9
+ exports.depositTokens = depositTokens;
10
+ exports.withdrawTokens = withdrawTokens;
4
11
  const cafe_utility_1 = require("cafe-utility");
5
12
  const headers_1 = require("../../utils/headers");
6
13
  const http_1 = require("../../utils/http");
@@ -23,7 +30,6 @@ async function getChequebookAddress(requestOptions) {
23
30
  chequebookAddress: new typed_bytes_1.EthAddress(cafe_utility_1.Types.asString(body.chequebookAddress, { name: 'chequebookAddress' })),
24
31
  };
25
32
  }
26
- exports.getChequebookAddress = getChequebookAddress;
27
33
  /**
28
34
  * Get the balance of the chequebook
29
35
  *
@@ -40,7 +46,6 @@ async function getChequebookBalance(requestOptions) {
40
46
  totalBalance: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.totalBalance, { name: 'totalBalance' })),
41
47
  };
42
48
  }
43
- exports.getChequebookBalance = getChequebookBalance;
44
49
  /**
45
50
  * Get last cashout action for the peer
46
51
  *
@@ -61,7 +66,6 @@ async function getLastCashoutAction(requestOptions, peer) {
61
66
  result: cafe_utility_1.Types.asNullable(x => asCashoutResult(x), body.result),
62
67
  };
63
68
  }
64
- exports.getLastCashoutAction = getLastCashoutAction;
65
69
  /**
66
70
  * Cashout the last cheque for the peer
67
71
  *
@@ -79,7 +83,6 @@ async function cashoutLastCheque(requestOptions, peer, options) {
79
83
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
80
84
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
81
85
  }
82
- exports.cashoutLastCheque = cashoutLastCheque;
83
86
  /**
84
87
  * Get last cheques for the peer
85
88
  *
@@ -98,7 +101,6 @@ async function getLastChequesForPeer(requestOptions, peer) {
98
101
  lastsent: cafe_utility_1.Types.asNullable(x => asCheque(x), body.lastsent),
99
102
  };
100
103
  }
101
- exports.getLastChequesForPeer = getLastChequesForPeer;
102
104
  /**
103
105
  * Get last cheques for all peers
104
106
  *
@@ -119,7 +121,6 @@ async function getLastCheques(requestOptions) {
119
121
  })),
120
122
  };
121
123
  }
122
- exports.getLastCheques = getLastCheques;
123
124
  function asCheque(x) {
124
125
  const object = cafe_utility_1.Types.asObject(x, { name: 'cheque' });
125
126
  return {
@@ -159,7 +160,6 @@ async function depositTokens(requestOptions, amount, gasPrice) {
159
160
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
160
161
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
161
162
  }
162
- exports.depositTokens = depositTokens;
163
163
  /**
164
164
  * Withdraw tokens from the chequebook to the overlay address
165
165
  *
@@ -183,4 +183,3 @@ async function withdrawTokens(requestOptions, amount, gasPrice) {
183
183
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
184
184
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
185
185
  }
186
- exports.withdrawTokens = withdrawTokens;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asBin = exports.pingPeer = exports.getTopology = exports.removePeer = exports.getBlocklist = exports.getPeers = exports.getNodeAddresses = void 0;
3
+ exports.getNodeAddresses = getNodeAddresses;
4
+ exports.getPeers = getPeers;
5
+ exports.getBlocklist = getBlocklist;
6
+ exports.removePeer = removePeer;
7
+ exports.getTopology = getTopology;
8
+ exports.pingPeer = pingPeer;
9
+ exports.asBin = asBin;
4
10
  const cafe_utility_1 = require("cafe-utility");
5
11
  const http_1 = require("../../utils/http");
6
12
  const typed_bytes_1 = require("../../utils/typed-bytes");
@@ -18,7 +24,6 @@ async function getNodeAddresses(requestOptions) {
18
24
  pssPublicKey: new typed_bytes_1.PublicKey(cafe_utility_1.Types.asString(body.pssPublicKey, { name: 'pssPublicKey' })),
19
25
  };
20
26
  }
21
- exports.getNodeAddresses = getNodeAddresses;
22
27
  async function getPeers(requestOptions) {
23
28
  const response = await (0, http_1.http)(requestOptions, {
24
29
  url: 'peers',
@@ -30,7 +35,6 @@ async function getPeers(requestOptions) {
30
35
  fullNode: cafe_utility_1.Types.asBoolean(cafe_utility_1.Types.asObject(x, { name: 'peer' }).fullNode, { name: 'fullNode' }),
31
36
  }));
32
37
  }
33
- exports.getPeers = getPeers;
34
38
  async function getBlocklist(requestOptions) {
35
39
  const response = await (0, http_1.http)(requestOptions, {
36
40
  url: 'blocklist',
@@ -38,7 +42,6 @@ async function getBlocklist(requestOptions) {
38
42
  });
39
43
  return response.data.peers;
40
44
  }
41
- exports.getBlocklist = getBlocklist;
42
45
  async function removePeer(requestOptions, peer) {
43
46
  const response = await (0, http_1.http)(requestOptions, {
44
47
  url: `peers/${peer}`,
@@ -47,7 +50,6 @@ async function removePeer(requestOptions, peer) {
47
50
  });
48
51
  return response.data;
49
52
  }
50
- exports.removePeer = removePeer;
51
53
  async function getTopology(requestOptions) {
52
54
  const response = await (0, http_1.http)(requestOptions, {
53
55
  url: `topology`,
@@ -100,7 +102,6 @@ async function getTopology(requestOptions) {
100
102
  },
101
103
  };
102
104
  }
103
- exports.getTopology = getTopology;
104
105
  async function pingPeer(requestOptions, peer) {
105
106
  const response = await (0, http_1.http)(requestOptions, {
106
107
  url: `pingpong/${peer}`,
@@ -109,7 +110,6 @@ async function pingPeer(requestOptions, peer) {
109
110
  });
110
111
  return response.data;
111
112
  }
112
- exports.pingPeer = pingPeer;
113
113
  function asBin(value, name) {
114
114
  const bin = cafe_utility_1.Types.asObject(value, { name });
115
115
  if (!bin.disconnectedPeers) {
@@ -129,4 +129,3 @@ function asBin(value, name) {
129
129
  })),
130
130
  };
131
131
  }
132
- exports.asBin = asBin;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAllSettlements = exports.getSettlements = void 0;
3
+ exports.getSettlements = getSettlements;
4
+ exports.getAllSettlements = getAllSettlements;
4
5
  const cafe_utility_1 = require("cafe-utility");
5
6
  const http_1 = require("../../utils/http");
6
7
  const tokens_1 = require("../../utils/tokens");
@@ -24,7 +25,6 @@ async function getSettlements(requestOptions, peer) {
24
25
  received: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.received, { name: 'received' })),
25
26
  };
26
27
  }
27
- exports.getSettlements = getSettlements;
28
28
  /**
29
29
  * Get settlements with all known peers and total amount sent or received
30
30
  *
@@ -49,4 +49,3 @@ async function getAllSettlements(requestOptions) {
49
49
  })),
50
50
  };
51
51
  }
52
- exports.getAllSettlements = getAllSettlements;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRedistributionState = exports.stake = exports.migrateStake = exports.withdrawSurplusStake = exports.getWithdrawableStake = exports.getStake = void 0;
3
+ exports.getStake = getStake;
4
+ exports.getWithdrawableStake = getWithdrawableStake;
5
+ exports.withdrawSurplusStake = withdrawSurplusStake;
6
+ exports.migrateStake = migrateStake;
7
+ exports.stake = stake;
8
+ exports.getRedistributionState = getRedistributionState;
4
9
  const cafe_utility_1 = require("cafe-utility");
5
10
  const headers_1 = require("../../utils/headers");
6
11
  const http_1 = require("../../utils/http");
@@ -23,7 +28,6 @@ async function getStake(requestOptions) {
23
28
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
24
29
  return tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.stakedAmount, { name: 'stakedAmount' }));
25
30
  }
26
- exports.getStake = getStake;
27
31
  /**
28
32
  * Gets the amount of withdrawable staked BZZ
29
33
  *
@@ -38,7 +42,6 @@ async function getWithdrawableStake(requestOptions) {
38
42
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
39
43
  return tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.withdrawableAmount, { name: 'withdrawableAmount' }));
40
44
  }
41
- exports.getWithdrawableStake = getWithdrawableStake;
42
45
  async function withdrawSurplusStake(requestOptions) {
43
46
  const response = await (0, http_1.http)(requestOptions, {
44
47
  method: 'delete',
@@ -48,7 +51,6 @@ async function withdrawSurplusStake(requestOptions) {
48
51
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
49
52
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
50
53
  }
51
- exports.withdrawSurplusStake = withdrawSurplusStake;
52
54
  async function migrateStake(requestOptions) {
53
55
  const response = await (0, http_1.http)(requestOptions, {
54
56
  method: 'delete',
@@ -58,7 +60,6 @@ async function migrateStake(requestOptions) {
58
60
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
59
61
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
60
62
  }
61
- exports.migrateStake = migrateStake;
62
63
  /**
63
64
  * Stake given amount of tokens.
64
65
  *
@@ -75,7 +76,6 @@ async function stake(requestOptions, amount, options) {
75
76
  const body = cafe_utility_1.Types.asObject(repsonse.data, { name: 'response.data' });
76
77
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
77
78
  }
78
- exports.stake = stake;
79
79
  /**
80
80
  * Get current status of node in redistribution game
81
81
  *
@@ -106,4 +106,3 @@ async function getRedistributionState(requestOptions) {
106
106
  isHealthy: cafe_utility_1.Types.asBoolean(body.isHealthy, { name: 'isHealthy' }),
107
107
  };
108
108
  }
109
- exports.getRedistributionState = getRedistributionState;
@@ -1,14 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.diluteBatch = exports.topUpBatch = exports.createPostageBatch = exports.getPostageBatchBuckets = exports.getPostageBatch = exports.getAllPostageBatches = exports.getGlobalPostageBatches = void 0;
3
+ exports.getGlobalPostageBatches = getGlobalPostageBatches;
4
+ exports.getAllPostageBatches = getAllPostageBatches;
5
+ exports.getPostageBatch = getPostageBatch;
6
+ exports.getPostageBatchBuckets = getPostageBatchBuckets;
7
+ exports.createPostageBatch = createPostageBatch;
8
+ exports.topUpBatch = topUpBatch;
9
+ exports.diluteBatch = diluteBatch;
4
10
  const cafe_utility_1 = require("cafe-utility");
5
- const duration_1 = require("../../utils/duration");
6
11
  const http_1 = require("../../utils/http");
7
- const size_1 = require("../../utils/size");
8
12
  const stamps_1 = require("../../utils/stamps");
9
13
  const type_1 = require("../../utils/type");
10
14
  const typed_bytes_1 = require("../../utils/typed-bytes");
11
- const workaround_1 = require("../../utils/workaround");
12
15
  const STAMPS_ENDPOINT = 'stamps';
13
16
  const BATCHES_ENDPOINT = 'batches';
14
17
  async function getGlobalPostageBatches(requestOptions) {
@@ -30,7 +33,6 @@ async function getGlobalPostageBatches(requestOptions) {
30
33
  value: (0, type_1.asNumberString)(x.value, { name: 'value' }),
31
34
  }));
32
35
  }
33
- exports.getGlobalPostageBatches = getGlobalPostageBatches;
34
36
  async function getAllPostageBatches(requestOptions) {
35
37
  const response = await (0, http_1.http)(requestOptions, {
36
38
  method: 'get',
@@ -39,42 +41,8 @@ async function getAllPostageBatches(requestOptions) {
39
41
  });
40
42
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
41
43
  const stamps = cafe_utility_1.Types.asArray(body.stamps, { name: 'stamps' }).map(x => cafe_utility_1.Types.asObject(x, { name: 'stamp' }));
42
- return stamps.map(x => {
43
- const utilization = cafe_utility_1.Types.asNumber(x.utilization, { name: 'utilization' });
44
- const depth = cafe_utility_1.Types.asNumber(x.depth, { name: 'depth' });
45
- const bucketDepth = cafe_utility_1.Types.asNumber(x.bucketDepth, { name: 'bucketDepth' });
46
- const usage = (0, stamps_1.getStampUsage)(utilization, depth, bucketDepth);
47
- const batchTTL = (0, workaround_1.normalizeBatchTTL)(cafe_utility_1.Types.asNumber(x.batchTTL, { name: 'batchTTL' }));
48
- const duration = duration_1.Duration.fromSeconds(batchTTL);
49
- const effectiveBytes = (0, stamps_1.getStampEffectiveBytes)(depth);
50
- return {
51
- batchID: new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(x.batchID, { name: 'batchID' })),
52
- utilization,
53
- usable: cafe_utility_1.Types.asBoolean(x.usable, { name: 'usable' }),
54
- label: cafe_utility_1.Types.asEmptiableString(x.label, { name: 'label' }),
55
- depth,
56
- amount: (0, type_1.asNumberString)(x.amount, { name: 'amount' }),
57
- bucketDepth,
58
- blockNumber: cafe_utility_1.Types.asNumber(x.blockNumber, { name: 'blockNumber' }),
59
- immutableFlag: cafe_utility_1.Types.asBoolean(x.immutableFlag, { name: 'immutableFlag' }),
60
- usage,
61
- usageText: `${Math.round(usage * 100)}%`,
62
- size: size_1.Size.fromBytes(effectiveBytes),
63
- remainingSize: size_1.Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage))),
64
- theoreticalSize: size_1.Size.fromBytes((0, stamps_1.getStampTheoreticalBytes)(depth)),
65
- duration,
66
- calculateSize(encryption, redundancyLevel) {
67
- const effectiveBytes = (0, stamps_1.getStampEffectiveBytes)(this.depth, encryption, redundancyLevel);
68
- return size_1.Size.fromBytes(effectiveBytes);
69
- },
70
- calculateRemainingSize(encryption, redundancyLevel) {
71
- const effectiveBytes = (0, stamps_1.getStampEffectiveBytes)(this.depth, encryption, redundancyLevel);
72
- return size_1.Size.fromBytes(Math.ceil(effectiveBytes * (1 - this.usage)));
73
- },
74
- };
75
- });
44
+ return stamps.map(x => (0, stamps_1.mapPostageBatch)(validateRawPostageBatch(x)));
76
45
  }
77
- exports.getAllPostageBatches = getAllPostageBatches;
78
46
  async function getPostageBatch(requestOptions, postageBatchId, encryption, erasureCodeLevel) {
79
47
  const response = await (0, http_1.http)(requestOptions, {
80
48
  method: 'get',
@@ -82,40 +50,8 @@ async function getPostageBatch(requestOptions, postageBatchId, encryption, erasu
82
50
  responseType: 'json',
83
51
  });
84
52
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
85
- const utilization = cafe_utility_1.Types.asNumber(body.utilization, { name: 'utilization' });
86
- const depth = cafe_utility_1.Types.asNumber(body.depth, { name: 'depth' });
87
- const bucketDepth = cafe_utility_1.Types.asNumber(body.bucketDepth, { name: 'bucketDepth' });
88
- const usage = (0, stamps_1.getStampUsage)(utilization, depth, bucketDepth);
89
- const batchTTL = (0, workaround_1.normalizeBatchTTL)(cafe_utility_1.Types.asNumber(body.batchTTL, { name: 'batchTTL' }));
90
- const duration = duration_1.Duration.fromSeconds(batchTTL);
91
- const effectiveBytes = (0, stamps_1.getStampEffectiveBytes)(depth, encryption, erasureCodeLevel);
92
- return {
93
- batchID: new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(body.batchID, { name: 'batchID' })),
94
- utilization,
95
- usable: cafe_utility_1.Types.asBoolean(body.usable, { name: 'usable' }),
96
- label: cafe_utility_1.Types.asEmptiableString(body.label, { name: 'label' }),
97
- depth,
98
- amount: (0, type_1.asNumberString)(body.amount, { name: 'amount' }),
99
- bucketDepth,
100
- blockNumber: cafe_utility_1.Types.asNumber(body.blockNumber, { name: 'blockNumber' }),
101
- immutableFlag: cafe_utility_1.Types.asBoolean(body.immutableFlag, { name: 'immutableFlag' }),
102
- usage,
103
- usageText: `${Math.round(usage * 100)}%`,
104
- size: size_1.Size.fromBytes(effectiveBytes),
105
- remainingSize: size_1.Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage))),
106
- theoreticalSize: size_1.Size.fromBytes((0, stamps_1.getStampTheoreticalBytes)(depth)),
107
- duration,
108
- calculateSize(encryption, redundancyLevel) {
109
- const effectiveBytes = (0, stamps_1.getStampEffectiveBytes)(depth, encryption, redundancyLevel);
110
- return size_1.Size.fromBytes(effectiveBytes);
111
- },
112
- calculateRemainingSize(encryption, redundancyLevel) {
113
- const effectiveBytes = (0, stamps_1.getStampEffectiveBytes)(depth, encryption, redundancyLevel);
114
- return size_1.Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage)));
115
- },
116
- };
53
+ return (0, stamps_1.mapPostageBatch)(validateRawPostageBatch(body), encryption, erasureCodeLevel);
117
54
  }
118
- exports.getPostageBatch = getPostageBatch;
119
55
  async function getPostageBatchBuckets(requestOptions, postageBatchId) {
120
56
  const response = await (0, http_1.http)(requestOptions, {
121
57
  method: 'get',
@@ -135,7 +71,6 @@ async function getPostageBatchBuckets(requestOptions, postageBatchId) {
135
71
  })),
136
72
  };
137
73
  }
138
- exports.getPostageBatchBuckets = getPostageBatchBuckets;
139
74
  async function createPostageBatch(requestOptions, amount, depth, options) {
140
75
  const headers = {};
141
76
  if (options?.gasPrice) {
@@ -154,7 +89,6 @@ async function createPostageBatch(requestOptions, amount, depth, options) {
154
89
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
155
90
  return new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(body.batchID, { name: 'batchID' }));
156
91
  }
157
- exports.createPostageBatch = createPostageBatch;
158
92
  async function topUpBatch(requestOptions, id, amount) {
159
93
  const response = await (0, http_1.http)(requestOptions, {
160
94
  method: 'patch',
@@ -164,7 +98,6 @@ async function topUpBatch(requestOptions, id, amount) {
164
98
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
165
99
  return new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(body.batchID, { name: 'batchID' }));
166
100
  }
167
- exports.topUpBatch = topUpBatch;
168
101
  async function diluteBatch(requestOptions, id, depth) {
169
102
  const response = await (0, http_1.http)(requestOptions, {
170
103
  method: 'patch',
@@ -174,4 +107,17 @@ async function diluteBatch(requestOptions, id, depth) {
174
107
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
175
108
  return new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(body.batchID, { name: 'batchID' }));
176
109
  }
177
- exports.diluteBatch = diluteBatch;
110
+ function validateRawPostageBatch(raw) {
111
+ return {
112
+ amount: (0, type_1.asNumberString)(raw.amount, { name: 'amount' }),
113
+ batchID: cafe_utility_1.Types.asString(raw.batchID, { name: 'batchID' }),
114
+ batchTTL: cafe_utility_1.Types.asNumber(raw.batchTTL, { name: 'batchTTL' }),
115
+ bucketDepth: cafe_utility_1.Types.asNumber(raw.bucketDepth, { name: 'bucketDepth' }),
116
+ blockNumber: cafe_utility_1.Types.asNumber(raw.blockNumber, { name: 'blockNumber' }),
117
+ depth: cafe_utility_1.Types.asNumber(raw.depth, { name: 'depth' }),
118
+ immutableFlag: cafe_utility_1.Types.asBoolean(raw.immutableFlag, { name: 'immutableFlag' }),
119
+ label: cafe_utility_1.Types.asEmptiableString(raw.label, { name: 'label' }),
120
+ usable: cafe_utility_1.Types.asBoolean(raw.usable, { name: 'usable' }),
121
+ utilization: cafe_utility_1.Types.asNumber(raw.utilization, { name: 'utilization' }),
122
+ };
123
+ }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withdrawDAI = exports.withdrawBZZ = exports.getWalletBalance = exports.getChainState = exports.getReserveState = void 0;
3
+ exports.getReserveState = getReserveState;
4
+ exports.getChainState = getChainState;
5
+ exports.getWalletBalance = getWalletBalance;
6
+ exports.withdrawBZZ = withdrawBZZ;
7
+ exports.withdrawDAI = withdrawDAI;
4
8
  const cafe_utility_1 = require("cafe-utility");
5
9
  const http_1 = require("../../utils/http");
6
10
  const tokens_1 = require("../../utils/tokens");
@@ -26,9 +30,9 @@ async function getReserveState(requestOptions) {
26
30
  commitment: cafe_utility_1.Types.asNumber(body.commitment, { name: 'commitment' }),
27
31
  radius: cafe_utility_1.Types.asNumber(body.radius, { name: 'radius' }),
28
32
  storageRadius: cafe_utility_1.Types.asNumber(body.storageRadius, { name: 'storageRadius' }),
33
+ reserveCapacityDoubling: cafe_utility_1.Types.asNumber(body.reserveCapacityDoubling, { name: 'reserveCapacityDoubling' }),
29
34
  };
30
35
  }
31
- exports.getReserveState = getReserveState;
32
36
  /**
33
37
  * Get state of reserve
34
38
  *
@@ -48,7 +52,6 @@ async function getChainState(requestOptions) {
48
52
  currentPrice: (0, workaround_1.normalizeCurrentPrice)(cafe_utility_1.Types.asNumber(body.currentPrice, { name: 'currentPrice' })),
49
53
  };
50
54
  }
51
- exports.getChainState = getChainState;
52
55
  /**
53
56
  * Get wallet balances for xDai and BZZ of the node
54
57
  *
@@ -69,7 +72,6 @@ async function getWalletBalance(requestOptions) {
69
72
  walletAddress: cafe_utility_1.Types.asString(body.walletAddress, { name: 'walletAddress' }),
70
73
  };
71
74
  }
72
- exports.getWalletBalance = getWalletBalance;
73
75
  async function withdrawBZZ(requestOptions, amount, address) {
74
76
  const response = await (0, http_1.http)(requestOptions, {
75
77
  method: 'post',
@@ -80,7 +82,6 @@ async function withdrawBZZ(requestOptions, amount, address) {
80
82
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
81
83
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
82
84
  }
83
- exports.withdrawBZZ = withdrawBZZ;
84
85
  async function withdrawDAI(requestOptions, amount, address) {
85
86
  const response = await (0, http_1.http)(requestOptions, {
86
87
  method: 'post',
@@ -91,4 +92,3 @@ async function withdrawDAI(requestOptions, amount, address) {
91
92
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
92
93
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
93
94
  }
94
- exports.withdrawDAI = withdrawDAI;
@@ -3,12 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedExactVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.getDebugStatus = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
6
+ exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
7
+ exports.getDebugStatus = getDebugStatus;
8
+ exports.getHealth = getHealth;
9
+ exports.getReadiness = getReadiness;
10
+ exports.getNodeInfo = getNodeInfo;
11
+ exports.isSupportedExactVersion = isSupportedExactVersion;
12
+ exports.isSupportedApiVersion = isSupportedApiVersion;
13
+ exports.getVersions = getVersions;
7
14
  const cafe_utility_1 = require("cafe-utility");
8
15
  const major_js_1 = __importDefault(require("semver/functions/major.js"));
9
16
  const debug_1 = require("../../types/debug");
10
17
  const http_1 = require("../../utils/http");
11
- exports.SUPPORTED_BEE_VERSION_EXACT = '2.6.0-d0aa8b93';
18
+ exports.SUPPORTED_BEE_VERSION_EXACT = '2.7.0-6ddf9b45';
12
19
  exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
13
20
  exports.SUPPORTED_API_VERSION = '7.3.0';
14
21
  const NODE_INFO_URL = 'node';
@@ -39,7 +46,6 @@ async function getDebugStatus(requestOptions) {
39
46
  isWarmingUp: cafe_utility_1.Types.asBoolean(body.isWarmingUp, { name: 'isWarmingUp' }),
40
47
  };
41
48
  }
42
- exports.getDebugStatus = getDebugStatus;
43
49
  /**
44
50
  * Get health of node
45
51
  *
@@ -58,7 +64,6 @@ async function getHealth(requestOptions) {
58
64
  status: cafe_utility_1.Types.asString(body.status, { name: 'status' }),
59
65
  };
60
66
  }
61
- exports.getHealth = getHealth;
62
67
  /**
63
68
  * Get readiness of node
64
69
  *
@@ -76,7 +81,6 @@ async function getReadiness(requestOptions) {
76
81
  status: cafe_utility_1.Types.asString(body.status, { name: 'status' }),
77
82
  };
78
83
  }
79
- exports.getReadiness = getReadiness;
80
84
  /**
81
85
  * Get information about Bee node
82
86
  *
@@ -95,7 +99,6 @@ async function getNodeInfo(requestOptions) {
95
99
  swapEnabled: cafe_utility_1.Types.asBoolean(body.swapEnabled, { name: 'swapEnabled' }),
96
100
  };
97
101
  }
98
- exports.getNodeInfo = getNodeInfo;
99
102
  /**
100
103
  * Connects to a node and checks if its version matches with the one that bee-js supports.
101
104
  *
@@ -108,7 +111,6 @@ async function isSupportedExactVersion(requestOptions) {
108
111
  const { version } = await getHealth(requestOptions);
109
112
  return version === exports.SUPPORTED_BEE_VERSION_EXACT;
110
113
  }
111
- exports.isSupportedExactVersion = isSupportedExactVersion;
112
114
  /**
113
115
  * Connects to a node and checks if its Main API versions matches with the one that bee-js supports.
114
116
  *
@@ -120,7 +122,6 @@ async function isSupportedApiVersion(requestOptions) {
120
122
  const { apiVersion } = await getHealth(requestOptions);
121
123
  return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
122
124
  }
123
- exports.isSupportedApiVersion = isSupportedApiVersion;
124
125
  /**
125
126
  * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
126
127
  * and versions that bee-js supports (properties prefixed with `supported*`).
@@ -136,4 +137,3 @@ async function getVersions(requestOptions) {
136
137
  beeApiVersion: apiVersion,
137
138
  };
138
139
  }
139
- exports.getVersions = getVersions;