@ethersphere/bee-js 13.0.0-upcoming.gcfb9756 → 13.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 (201) hide show
  1. package/README.md +104 -103
  2. package/dist/cjs/api/bytes.js +3 -4
  3. package/dist/cjs/api/bzz.js +5 -6
  4. package/dist/cjs/api/chunk.js +3 -3
  5. package/dist/cjs/api/envelope.js +3 -2
  6. package/dist/cjs/api/feed.js +4 -5
  7. package/dist/cjs/api/pin.js +2 -2
  8. package/dist/cjs/api/soc.js +2 -2
  9. package/dist/cjs/bee.js +18 -19
  10. package/dist/cjs/chunk/soc.js +21 -63
  11. package/dist/cjs/feed/identifier.js +3 -4
  12. package/dist/cjs/feed/index.js +17 -19
  13. package/dist/cjs/feed/retrievable.js +2 -2
  14. package/dist/cjs/index.js +18 -8
  15. package/dist/cjs/manifest/manifest.js +97 -333
  16. package/dist/cjs/modules/balance.js +3 -3
  17. package/dist/cjs/modules/cheque.js +4 -4
  18. package/dist/cjs/modules/chunk.js +8 -8
  19. package/dist/cjs/modules/collection.js +6 -6
  20. package/dist/cjs/modules/connectivity.js +3 -3
  21. package/dist/cjs/modules/data.js +6 -6
  22. package/dist/cjs/modules/feed.js +10 -10
  23. package/dist/cjs/modules/file.js +3 -3
  24. package/dist/cjs/modules/grantee.js +9 -9
  25. package/dist/cjs/modules/messaging.js +15 -17
  26. package/dist/cjs/modules/pin.js +6 -6
  27. package/dist/cjs/modules/settlement.js +2 -2
  28. package/dist/cjs/modules/soc.js +3 -3
  29. package/dist/cjs/modules/stamp.js +7 -7
  30. package/dist/cjs/modules/tag.js +2 -2
  31. package/dist/cjs/modules/transaction.js +4 -4
  32. package/dist/cjs/modules/wallet.js +3 -3
  33. package/dist/cjs/types/schema/chequebook.js +5 -5
  34. package/dist/cjs/types/schema/connectivity.js +5 -5
  35. package/dist/cjs/types/schema/envelope.js +5 -5
  36. package/dist/cjs/types/schema/grantee.js +4 -4
  37. package/dist/cjs/types/schema/stake.js +2 -2
  38. package/dist/cjs/types/schema/stamps.js +4 -4
  39. package/dist/cjs/types/schema/states.js +2 -2
  40. package/dist/cjs/types/schema/transactions.js +3 -3
  41. package/dist/cjs/types/schema/upload.js +2 -2
  42. package/dist/cjs/utils/chunk-stream.browser.js +24 -16
  43. package/dist/cjs/utils/chunk-stream.js +17 -9
  44. package/dist/cjs/utils/constants.js +3 -3
  45. package/dist/cjs/utils/expose.js +4 -4
  46. package/dist/cjs/utils/headers.js +4 -4
  47. package/dist/cjs/utils/http.js +3 -1
  48. package/dist/cjs/utils/pss.js +2 -2
  49. package/dist/cjs/utils/resource-locator.js +2 -2
  50. package/dist/cjs/utils/schema.js +4 -4
  51. package/dist/cjs/utils/stamps.js +15 -130
  52. package/dist/cjs/utils/type.js +2 -2
  53. package/dist/codemod/index.js +141 -0
  54. package/dist/codemod/transforms/v13.js +524 -0
  55. package/dist/index.browser.min.js +2 -1
  56. package/dist/index.browser.min.js.LICENSE.txt +3 -0
  57. package/dist/index.browser.min.js.map +1 -1
  58. package/dist/mjs/api/bytes.js +1 -2
  59. package/dist/mjs/api/bzz.js +1 -2
  60. package/dist/mjs/api/chunk.js +1 -1
  61. package/dist/mjs/api/envelope.js +3 -2
  62. package/dist/mjs/api/feed.js +1 -2
  63. package/dist/mjs/api/pin.js +1 -1
  64. package/dist/mjs/api/soc.js +1 -1
  65. package/dist/mjs/bee.js +13 -14
  66. package/dist/mjs/chunk/soc.js +11 -49
  67. package/dist/mjs/feed/identifier.js +2 -3
  68. package/dist/mjs/feed/index.js +6 -8
  69. package/dist/mjs/feed/retrievable.js +1 -1
  70. package/dist/mjs/index.js +2 -5
  71. package/dist/mjs/manifest/manifest.js +95 -339
  72. package/dist/mjs/modules/balance.js +1 -1
  73. package/dist/mjs/modules/cheque.js +1 -1
  74. package/dist/mjs/modules/chunk.js +1 -1
  75. package/dist/mjs/modules/collection.js +1 -1
  76. package/dist/mjs/modules/connectivity.js +1 -1
  77. package/dist/mjs/modules/data.js +3 -3
  78. package/dist/mjs/modules/feed.js +1 -1
  79. package/dist/mjs/modules/file.js +1 -1
  80. package/dist/mjs/modules/grantee.js +1 -1
  81. package/dist/mjs/modules/messaging.js +3 -5
  82. package/dist/mjs/modules/pin.js +1 -1
  83. package/dist/mjs/modules/settlement.js +1 -1
  84. package/dist/mjs/modules/soc.js +1 -1
  85. package/dist/mjs/modules/stamp.js +1 -1
  86. package/dist/mjs/modules/tag.js +1 -1
  87. package/dist/mjs/modules/transaction.js +1 -1
  88. package/dist/mjs/modules/wallet.js +1 -1
  89. package/dist/mjs/types/schema/chequebook.js +1 -1
  90. package/dist/mjs/types/schema/connectivity.js +1 -1
  91. package/dist/mjs/types/schema/envelope.js +5 -5
  92. package/dist/mjs/types/schema/grantee.js +1 -1
  93. package/dist/mjs/types/schema/stake.js +1 -1
  94. package/dist/mjs/types/schema/stamps.js +1 -1
  95. package/dist/mjs/types/schema/states.js +1 -1
  96. package/dist/mjs/types/schema/transactions.js +1 -1
  97. package/dist/mjs/types/schema/upload.js +1 -1
  98. package/dist/mjs/utils/chunk-stream.browser.js +28 -18
  99. package/dist/mjs/utils/chunk-stream.js +21 -11
  100. package/dist/mjs/utils/constants.js +1 -1
  101. package/dist/mjs/utils/expose.js +1 -1
  102. package/dist/mjs/utils/headers.js +1 -1
  103. package/dist/mjs/utils/http.js +6 -1
  104. package/dist/mjs/utils/pss.js +1 -1
  105. package/dist/mjs/utils/resource-locator.js +1 -1
  106. package/dist/mjs/utils/schema.js +1 -1
  107. package/dist/mjs/utils/stamps.js +5 -99
  108. package/dist/mjs/utils/type.js +2 -2
  109. package/dist/types/api/balance.d.ts +1 -1
  110. package/dist/types/api/batches.d.ts +1 -1
  111. package/dist/types/api/bytes.d.ts +3 -3
  112. package/dist/types/api/bzz.d.ts +1 -2
  113. package/dist/types/api/chequebook.d.ts +1 -1
  114. package/dist/types/api/chunk.d.ts +1 -1
  115. package/dist/types/api/connectivity.d.ts +1 -1
  116. package/dist/types/api/consumed.d.ts +1 -1
  117. package/dist/types/api/envelope.d.ts +1 -1
  118. package/dist/types/api/feed.d.ts +1 -2
  119. package/dist/types/api/grantee.d.ts +1 -1
  120. package/dist/types/api/pin.d.ts +1 -1
  121. package/dist/types/api/pss.d.ts +1 -1
  122. package/dist/types/api/settlement.d.ts +1 -1
  123. package/dist/types/api/soc.d.ts +1 -1
  124. package/dist/types/api/stake.d.ts +1 -1
  125. package/dist/types/api/stamp.d.ts +1 -1
  126. package/dist/types/api/stewardship.d.ts +1 -1
  127. package/dist/types/api/tag.d.ts +1 -1
  128. package/dist/types/api/transaction.d.ts +1 -1
  129. package/dist/types/api/wallet.d.ts +1 -1
  130. package/dist/types/bee.d.ts +11 -13
  131. package/dist/types/chunk/soc.d.ts +3 -48
  132. package/dist/types/feed/identifier.d.ts +1 -1
  133. package/dist/types/feed/index.d.ts +1 -3
  134. package/dist/types/feed/retrievable.d.ts +1 -1
  135. package/dist/types/index.d.ts +17 -20
  136. package/dist/types/manifest/manifest.d.ts +24 -33
  137. package/dist/types/modules/balance.d.ts +1 -1
  138. package/dist/types/modules/cheque.d.ts +1 -1
  139. package/dist/types/modules/chequebook.d.ts +1 -1
  140. package/dist/types/modules/chunk.d.ts +1 -2
  141. package/dist/types/modules/collection.d.ts +2 -2
  142. package/dist/types/modules/connectivity.d.ts +1 -1
  143. package/dist/types/modules/context.d.ts +1 -1
  144. package/dist/types/modules/data.d.ts +3 -3
  145. package/dist/types/modules/feed.d.ts +1 -1
  146. package/dist/types/modules/file.d.ts +1 -2
  147. package/dist/types/modules/grantee.d.ts +1 -1
  148. package/dist/types/modules/messaging.d.ts +1 -2
  149. package/dist/types/modules/pin.d.ts +1 -1
  150. package/dist/types/modules/settlement.d.ts +1 -1
  151. package/dist/types/modules/soc.d.ts +1 -1
  152. package/dist/types/modules/stake.d.ts +1 -1
  153. package/dist/types/modules/stamp.d.ts +1 -1
  154. package/dist/types/modules/storage.d.ts +1 -1
  155. package/dist/types/modules/tag.d.ts +1 -1
  156. package/dist/types/modules/transaction.d.ts +1 -1
  157. package/dist/types/modules/wallet.d.ts +1 -1
  158. package/dist/types/types/debug.d.ts +1 -1
  159. package/dist/types/types/index.d.ts +2 -11
  160. package/dist/types/types/schema/chequebook.d.ts +1 -1
  161. package/dist/types/types/schema/connectivity.d.ts +1 -1
  162. package/dist/types/types/schema/grantee.d.ts +1 -1
  163. package/dist/types/types/schema/stake.d.ts +1 -1
  164. package/dist/types/types/schema/stamps.d.ts +1 -1
  165. package/dist/types/types/schema/states.d.ts +1 -1
  166. package/dist/types/types/schema/transactions.d.ts +1 -1
  167. package/dist/types/types/schema/upload.d.ts +1 -1
  168. package/dist/types/utils/chunk-stream.browser.d.ts +1 -1
  169. package/dist/types/utils/chunk-stream.d.ts +2 -2
  170. package/dist/types/utils/constants.d.ts +1 -1
  171. package/dist/types/utils/expose.d.ts +1 -1
  172. package/dist/types/utils/headers.d.ts +1 -1
  173. package/dist/types/utils/pss.d.ts +1 -1
  174. package/dist/types/utils/resource-locator.d.ts +1 -1
  175. package/dist/types/utils/schema.d.ts +1 -1
  176. package/dist/types/utils/stamps.d.ts +2 -27
  177. package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
  178. package/dist/types/utils/tar-uploader.d.ts +1 -1
  179. package/dist/types/utils/type.d.ts +1 -1
  180. package/package.json +7 -2
  181. package/dist/cjs/chunk/bmt.js +0 -37
  182. package/dist/cjs/chunk/cac.js +0 -43
  183. package/dist/cjs/stamper/stamper.js +0 -44
  184. package/dist/cjs/utils/bytes.js +0 -116
  185. package/dist/cjs/utils/cid.js +0 -37
  186. package/dist/cjs/utils/redundancy.js +0 -133
  187. package/dist/cjs/utils/typed-bytes.js +0 -186
  188. package/dist/mjs/chunk/bmt.js +0 -34
  189. package/dist/mjs/chunk/cac.js +0 -34
  190. package/dist/mjs/stamper/stamper.js +0 -40
  191. package/dist/mjs/utils/bytes.js +0 -102
  192. package/dist/mjs/utils/cid.js +0 -32
  193. package/dist/mjs/utils/redundancy.js +0 -98
  194. package/dist/mjs/utils/typed-bytes.js +0 -167
  195. package/dist/types/chunk/bmt.d.ts +0 -16
  196. package/dist/types/chunk/cac.d.ts +0 -40
  197. package/dist/types/stamper/stamper.d.ts +0 -15
  198. package/dist/types/utils/bytes.d.ts +0 -19
  199. package/dist/types/utils/cid.d.ts +0 -10
  200. package/dist/types/utils/redundancy.d.ts +0 -21
  201. package/dist/types/utils/typed-bytes.d.ts +0 -69
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetTopologyResponse = exports.GetBlocklistResponse = exports.GetPeersResponse = exports.GetNodeAddressesResponse = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
- const typed_bytes_1 = require("../../utils/typed-bytes");
6
6
  const PeerSchema = zod_1.z.object({
7
7
  address: zod_1.z.string(),
8
8
  fullNode: zod_1.z.boolean(),
@@ -21,11 +21,11 @@ const BinSchema = zod_1.z.object({
21
21
  });
22
22
  const BinRecord = zod_1.z.record(zod_1.z.string(), BinSchema);
23
23
  exports.GetNodeAddressesResponse = zod_1.z.object({
24
- overlay: zod_1.z.string().transform(s => new typed_bytes_1.PeerAddress(s)),
24
+ overlay: zod_1.z.string().transform(s => new core_sdk_1.PeerAddress(s)),
25
25
  underlay: zod_1.z.array(zod_1.z.string()),
26
- ethereum: zod_1.z.string().transform(s => new typed_bytes_1.EthAddress(s)),
27
- publicKey: zod_1.z.string().transform(s => new typed_bytes_1.PublicKey(s)),
28
- pssPublicKey: zod_1.z.string().transform(s => new typed_bytes_1.PublicKey(s)),
26
+ ethereum: zod_1.z.string().transform(s => new core_sdk_1.EthAddress(s)),
27
+ publicKey: zod_1.z.string().transform(s => new core_sdk_1.PublicKey(s)),
28
+ pssPublicKey: zod_1.z.string().transform(s => new core_sdk_1.PublicKey(s)),
29
29
  });
30
30
  exports.GetPeersResponse = zod_1.z.object({
31
31
  peers: zod_1.z.array(PeerSchema),
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PostEnvelopeBodyResponse = void 0;
4
- const cafe_utility_1 = require("cafe-utility");
5
4
  const zod_1 = require("zod");
5
+ const core_sdk_1 = require("@ethersphere/core-sdk");
6
6
  exports.PostEnvelopeBodyResponse = zod_1.z.object({
7
- issuer: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
8
- index: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
9
- timestamp: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
10
- signature: zod_1.z.string().transform(s => cafe_utility_1.Binary.hexToUint8Array(s)),
7
+ issuer: zod_1.z.string().transform(s => (0, core_sdk_1.hexToUint8Array)(s)),
8
+ index: zod_1.z.string().transform(s => (0, core_sdk_1.hexToUint8Array)(s)),
9
+ timestamp: zod_1.z.string().transform(s => (0, core_sdk_1.hexToUint8Array)(s)),
10
+ signature: zod_1.z.string().transform(s => (0, core_sdk_1.hexToUint8Array)(s)),
11
11
  });
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GranteesResultBodyResponse = exports.GetGranteesBodyResponse = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
- const typed_bytes_1 = require("../../utils/typed-bytes");
6
- exports.GetGranteesBodyResponse = zod_1.z.array(zod_1.z.string().transform(s => new typed_bytes_1.PublicKey(s)));
6
+ exports.GetGranteesBodyResponse = zod_1.z.array(zod_1.z.string().transform(s => new core_sdk_1.PublicKey(s)));
7
7
  exports.GranteesResultBodyResponse = zod_1.z.object({
8
- ref: zod_1.z.string().transform(s => new typed_bytes_1.Reference(s)),
9
- historyref: zod_1.z.string().transform(s => new typed_bytes_1.Reference(s)),
8
+ ref: zod_1.z.string().transform(s => new core_sdk_1.Reference(s)),
9
+ historyref: zod_1.z.string().transform(s => new core_sdk_1.Reference(s)),
10
10
  });
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetRedistributionStateResponse = exports.TxHashResponse = exports.GetWithdrawableStakeResponse = exports.GetStakeResponse = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
6
  const tokens_1 = require("../../utils/tokens");
6
7
  const type_1 = require("../../utils/type");
7
- const typed_bytes_1 = require("../../utils/typed-bytes");
8
8
  exports.GetStakeResponse = zod_1.z.object({
9
9
  stakedAmount: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'stakedAmount' }))),
10
10
  });
@@ -12,7 +12,7 @@ exports.GetWithdrawableStakeResponse = zod_1.z.object({
12
12
  withdrawableAmount: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'withdrawableAmount' }))),
13
13
  });
14
14
  exports.TxHashResponse = zod_1.z.object({
15
- txHash: zod_1.z.string().transform(s => new typed_bytes_1.TransactionId(s)),
15
+ txHash: zod_1.z.string().transform(s => new core_sdk_1.TransactionId(s)),
16
16
  });
17
17
  exports.GetRedistributionStateResponse = zod_1.z.object({
18
18
  minimumGasFunds: zod_1.z.string().transform(s => tokens_1.DAI.fromWei((0, type_1.asNumberString)(s, { name: 'minimumGasFunds' }))),
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BatchIdResponse = exports.GetPostageBatchBucketsResponse = exports.GetPostageBatchResponse = exports.GetAllPostageBatchesResponse = exports.GetGlobalPostageBatchesResponse = exports.GetGlobalPostageBatchResponse = exports.RawPostageBatchSchema = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
6
  const type_1 = require("../../utils/type");
6
- const typed_bytes_1 = require("../../utils/typed-bytes");
7
7
  exports.RawPostageBatchSchema = zod_1.z.object({
8
8
  batchID: zod_1.z.string(),
9
9
  utilization: zod_1.z.number(),
@@ -18,12 +18,12 @@ exports.RawPostageBatchSchema = zod_1.z.object({
18
18
  batchTTL: zod_1.z.number(),
19
19
  });
20
20
  exports.GetGlobalPostageBatchResponse = zod_1.z.object({
21
- batchID: zod_1.z.string().transform(s => new typed_bytes_1.BatchId(s)),
21
+ batchID: zod_1.z.string().transform(s => new core_sdk_1.BatchId(s)),
22
22
  batchTTL: zod_1.z.number(),
23
23
  bucketDepth: zod_1.z.number(),
24
24
  depth: zod_1.z.number(),
25
25
  immutable: zod_1.z.boolean(),
26
- owner: zod_1.z.string().transform(s => new typed_bytes_1.EthAddress(s)),
26
+ owner: zod_1.z.string().transform(s => new core_sdk_1.EthAddress(s)),
27
27
  start: zod_1.z.number(),
28
28
  value: zod_1.z.string().transform(s => (0, type_1.asNumberString)(s, { name: 'value' })),
29
29
  });
@@ -44,5 +44,5 @@ exports.GetPostageBatchBucketsResponse = zod_1.z.object({
44
44
  })),
45
45
  });
46
46
  exports.BatchIdResponse = zod_1.z.object({
47
- batchID: zod_1.z.string().transform(s => new typed_bytes_1.BatchId(s)),
47
+ batchID: zod_1.z.string().transform(s => new core_sdk_1.BatchId(s)),
48
48
  });
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WithdrawResponse = exports.GetWalletBalanceResponse = exports.GetChainStateResponse = exports.GetReserveStateResponse = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
6
  const tokens_1 = require("../../utils/tokens");
6
7
  const type_1 = require("../../utils/type");
7
- const typed_bytes_1 = require("../../utils/typed-bytes");
8
8
  const workaround_1 = require("../../utils/workaround");
9
9
  exports.GetReserveStateResponse = zod_1.z.object({
10
10
  commitment: zod_1.z.number(),
@@ -30,5 +30,5 @@ exports.GetWalletBalanceResponse = zod_1.z.object({
30
30
  walletAddress: zod_1.z.string(),
31
31
  });
32
32
  exports.WithdrawResponse = zod_1.z.object({
33
- transactionHash: zod_1.z.string().transform(s => new typed_bytes_1.TransactionId(s)),
33
+ transactionHash: zod_1.z.string().transform(s => new core_sdk_1.TransactionId(s)),
34
34
  });
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransactionHashResponse = exports.GetTransactionResponse = exports.GetAllTransactionsResponse = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
6
  const type_1 = require("../../utils/type");
6
- const typed_bytes_1 = require("../../utils/typed-bytes");
7
7
  const TransactionInfoSchema = zod_1.z.object({
8
- transactionHash: zod_1.z.string().transform(s => new typed_bytes_1.TransactionId(s)),
8
+ transactionHash: zod_1.z.string().transform(s => new core_sdk_1.TransactionId(s)),
9
9
  to: zod_1.z.string(),
10
10
  nonce: zod_1.z.number(),
11
11
  gasPrice: zod_1.z.string().transform(s => (0, type_1.asNumberString)(s, { name: 'gasPrice' })),
@@ -20,5 +20,5 @@ exports.GetAllTransactionsResponse = zod_1.z.object({
20
20
  });
21
21
  exports.GetTransactionResponse = TransactionInfoSchema;
22
22
  exports.TransactionHashResponse = zod_1.z.object({
23
- transactionHash: zod_1.z.string().transform(s => new typed_bytes_1.TransactionId(s)),
23
+ transactionHash: zod_1.z.string().transform(s => new core_sdk_1.TransactionId(s)),
24
24
  });
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UploadResultBody = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
- const typed_bytes_1 = require("../../utils/typed-bytes");
6
6
  exports.UploadResultBody = zod_1.z.object({
7
- reference: zod_1.z.string().transform(s => new typed_bytes_1.Reference(s)),
7
+ reference: zod_1.z.string().transform(s => new core_sdk_1.Reference(s)),
8
8
  });
@@ -9,7 +9,7 @@ const manifest_1 = require("../manifest/manifest");
9
9
  const chunk_size_1 = require("./chunk-size");
10
10
  const collection_1 = require("./collection");
11
11
  const mime_1 = require("./mime");
12
- const typed_bytes_1 = require("./typed-bytes");
12
+ const core_sdk_1 = require("@ethersphere/core-sdk");
13
13
  async function hashDirectory(_dir) {
14
14
  throw new Error('Hashing directories is not supported in browsers!');
15
15
  }
@@ -27,23 +27,27 @@ async function streamFiles(bee, files, postageBatchId, onUploadProgress, options
27
27
  for (const file of files) {
28
28
  total += (0, chunk_size_1.totalChunks)(file.size);
29
29
  }
30
- postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
31
- async function onChunk(chunk) {
32
- await queue.enqueue(async () => {
30
+ postageBatchId = new core_sdk_1.BatchId(postageBatchId);
31
+ async function uploadAndTrack(chunk) {
32
+ if (signal?.aborted) {
33
+ return;
34
+ }
35
+ try {
36
+ await bee.chunk.upload(postageBatchId, chunk.build(), options, requestOptions);
37
+ onUploadProgress?.({ total, processed: ++processed });
38
+ }
39
+ catch (err) {
33
40
  if (signal?.aborted) {
34
41
  return;
35
42
  }
36
- try {
37
- await bee.chunk.upload(postageBatchId, chunk.build(), options, requestOptions);
38
- onUploadProgress?.({ total, processed: ++processed });
39
- }
40
- catch (err) {
41
- if (signal?.aborted) {
42
- return;
43
- }
44
- throw err;
45
- }
46
- });
43
+ throw err;
44
+ }
45
+ }
46
+ async function onBatch(batch) {
47
+ for (const { chunk } of batch) {
48
+ await queue.enqueue(async () => uploadAndTrack(chunk));
49
+ }
50
+ return [];
47
51
  }
48
52
  const mantaray = new manifest_1.MantarayNode();
49
53
  for (const file of files) {
@@ -51,7 +55,7 @@ async function streamFiles(bee, files, postageBatchId, onUploadProgress, options
51
55
  throw new Error('Request aborted');
52
56
  }
53
57
  const rootChunk = await new Promise((resolve, reject) => {
54
- const tree = new cafe_utility_1.MerkleTree(onChunk);
58
+ const tree = new core_sdk_1.ChunkSplitter(onBatch);
55
59
  let offset = 0;
56
60
  const reader = new FileReader();
57
61
  reader.onerror = () => {
@@ -63,7 +67,11 @@ async function streamFiles(bee, files, postageBatchId, onUploadProgress, options
63
67
  return;
64
68
  }
65
69
  if (offset >= file.size) {
70
+ // ChunkSplitter's onBatch only sees chunks once they're referenced
71
+ // by a parent - the root chunk returned by finalize() is never
72
+ // passed to it, so it has to be uploaded here explicitly.
66
73
  const rootChunk = await tree.finalize();
74
+ await queue.enqueue(async () => uploadAndTrack(rootChunk));
67
75
  resolve(rootChunk);
68
76
  return;
69
77
  }
@@ -10,12 +10,12 @@ const manifest_1 = require("../manifest/manifest");
10
10
  const chunk_size_1 = require("./chunk-size");
11
11
  const collection_node_1 = require("./collection.node");
12
12
  const mime_1 = require("./mime");
13
- const typed_bytes_1 = require("./typed-bytes");
13
+ const core_sdk_1 = require("@ethersphere/core-sdk");
14
14
  async function hashDirectory(dir) {
15
15
  const files = await (0, collection_node_1.makeCollectionFromFS)(dir);
16
16
  const mantaray = new manifest_1.MantarayNode();
17
17
  for (const file of files) {
18
- const tree = new cafe_utility_1.MerkleTree(cafe_utility_1.MerkleTree.NOOP);
18
+ const tree = new core_sdk_1.ChunkSplitter(core_sdk_1.ChunkSplitter.NOOP);
19
19
  if (!file.fsPath) {
20
20
  throw Error('File does not have fsPath, which should never happen in node. Please report this issue.');
21
21
  }
@@ -36,17 +36,21 @@ async function streamDirectory(bee, dir, postageBatchId, onUploadProgress, optio
36
36
  const queue = new cafe_utility_1.AsyncQueue(64, 64);
37
37
  let total = 0;
38
38
  let processed = 0;
39
- postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
39
+ postageBatchId = new core_sdk_1.BatchId(postageBatchId);
40
40
  const files = await (0, collection_node_1.makeCollectionFromFS)(dir);
41
41
  for (const file of files) {
42
42
  total += (0, chunk_size_1.totalChunks)(file.size);
43
43
  }
44
44
  let hasIndexHtml = false;
45
- async function onChunk(chunk) {
46
- await queue.enqueue(async () => {
47
- await bee.chunk.upload(postageBatchId, chunk.build(), options, requestOptions);
48
- onUploadProgress?.({ total, processed: ++processed });
49
- });
45
+ async function uploadAndTrack(chunk) {
46
+ await bee.chunk.upload(postageBatchId, chunk.build(), options, requestOptions);
47
+ onUploadProgress?.({ total, processed: ++processed });
48
+ }
49
+ async function onBatch(batch) {
50
+ for (const { chunk } of batch) {
51
+ await queue.enqueue(async () => uploadAndTrack(chunk));
52
+ }
53
+ return [];
50
54
  }
51
55
  const mantaray = new manifest_1.MantarayNode();
52
56
  for (const file of files) {
@@ -54,11 +58,15 @@ async function streamDirectory(bee, dir, postageBatchId, onUploadProgress, optio
54
58
  throw Error('File does not have fsPath, which should never happen in node. Please report this issue.');
55
59
  }
56
60
  const readStream = (0, fs_1.createReadStream)(file.fsPath);
57
- const tree = new cafe_utility_1.MerkleTree(onChunk);
61
+ const tree = new core_sdk_1.ChunkSplitter(onBatch);
58
62
  for await (const data of readStream) {
59
63
  await tree.append(data);
60
64
  }
65
+ // ChunkSplitter's onBatch only sees chunks once they're referenced by a
66
+ // parent - the root chunk returned by finalize() is never passed to it,
67
+ // so it has to be uploaded here explicitly.
61
68
  const rootChunk = await tree.finalize();
69
+ await queue.enqueue(async () => uploadAndTrack(rootChunk));
62
70
  await queue.drain();
63
71
  const { filename, extension } = cafe_utility_1.Strings.parseFilename(file.path);
64
72
  mantaray.addFork(file.path, rootChunk.hash(), {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NULL_OWNER = exports.NULL_IDENTIFIER = exports.NULL_ADDRESS = exports.NULL_TOPIC = exports.NULL_STAMP = exports.SWARM_GATEWAY_URL = void 0;
4
- const typed_bytes_1 = require("./typed-bytes");
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
5
5
  exports.SWARM_GATEWAY_URL = 'https://api.gateway.ethswarm.org';
6
- exports.NULL_STAMP = new typed_bytes_1.BatchId('0000000000000000000000000000000000000000000000000000000000000000');
7
- exports.NULL_TOPIC = new typed_bytes_1.Topic('0000000000000000000000000000000000000000000000000000000000000000');
6
+ exports.NULL_STAMP = new core_sdk_1.BatchId('0000000000000000000000000000000000000000000000000000000000000000');
7
+ exports.NULL_TOPIC = new core_sdk_1.Topic('0000000000000000000000000000000000000000000000000000000000000000');
8
8
  exports.NULL_ADDRESS = new Uint8Array(32);
9
9
  exports.NULL_IDENTIFIER = new Uint8Array(32);
10
10
  exports.NULL_OWNER = new Uint8Array(20);
@@ -8,10 +8,10 @@ var collection_node_1 = require("./collection.node");
8
8
  Object.defineProperty(exports, "getFolderSize", { enumerable: true, get: function () { return collection_node_1.getFolderSize; } });
9
9
  var pss_1 = require("./pss");
10
10
  Object.defineProperty(exports, "makeMaxTarget", { enumerable: true, get: function () { return pss_1.makeMaxTarget; } });
11
- var redundancy_1 = require("./redundancy");
12
- Object.defineProperty(exports, "approximateOverheadForRedundancyLevel", { enumerable: true, get: function () { return redundancy_1.approximateOverheadForRedundancyLevel; } });
13
- Object.defineProperty(exports, "getRedundancyStat", { enumerable: true, get: function () { return redundancy_1.getRedundancyStat; } });
14
- Object.defineProperty(exports, "getRedundancyStats", { enumerable: true, get: function () { return redundancy_1.getRedundancyStats; } });
11
+ var core_sdk_1 = require("@ethersphere/core-sdk");
12
+ Object.defineProperty(exports, "approximateOverheadForRedundancyLevel", { enumerable: true, get: function () { return core_sdk_1.approximateOverheadForRedundancyLevel; } });
13
+ Object.defineProperty(exports, "getRedundancyStat", { enumerable: true, get: function () { return core_sdk_1.getRedundancyStat; } });
14
+ Object.defineProperty(exports, "getRedundancyStats", { enumerable: true, get: function () { return core_sdk_1.getRedundancyStats; } });
15
15
  var stamps_1 = require("./stamps");
16
16
  Object.defineProperty(exports, "convertEnvelopeToMarshaledStamp", { enumerable: true, get: function () { return stamps_1.convertEnvelopeToMarshaledStamp; } });
17
17
  Object.defineProperty(exports, "getAmountForDuration", { enumerable: true, get: function () { return stamps_1.getAmountForDuration; } });
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readFileHeaders = readFileHeaders;
4
4
  exports.prepareRequestHeaders = prepareRequestHeaders;
5
+ const core_sdk_1 = require("@ethersphere/core-sdk");
5
6
  const zod_1 = require("zod");
6
7
  const error_1 = require("./error");
7
8
  const stamps_1 = require("./stamps");
8
- const typed_bytes_1 = require("./typed-bytes");
9
9
  function readFileHeaders(headers) {
10
10
  const name = readContentDispositionFilename(headers['content-disposition']);
11
11
  const tagUid = readTagUid(headers['swarm-tag-uid']);
@@ -40,7 +40,7 @@ function prepareRequestHeaders(stamp, nullableOptions) {
40
40
  headers['swarm-postage-stamp'] = (0, stamps_1.convertEnvelopeToMarshaledStamp)(stamp).toHex();
41
41
  }
42
42
  else if (stamp) {
43
- stamp = new typed_bytes_1.BatchId(stamp);
43
+ stamp = new core_sdk_1.BatchId(stamp);
44
44
  headers['swarm-postage-batch-id'] = stamp.toHex();
45
45
  }
46
46
  if (!nullableOptions) {
@@ -92,10 +92,10 @@ function prepareRequestHeaders(stamp, nullableOptions) {
92
92
  headers['swarm-error-document'] = String(options.errorDocument);
93
93
  }
94
94
  if (options.actPublisher) {
95
- headers['swarm-act-publisher'] = new typed_bytes_1.PublicKey(options.actPublisher).toCompressedHex();
95
+ headers['swarm-act-publisher'] = new core_sdk_1.PublicKey(options.actPublisher).toCompressedHex();
96
96
  }
97
97
  if (options.actHistoryAddress) {
98
- headers['swarm-act-history-address'] = new typed_bytes_1.Reference(options.actHistoryAddress).toHex();
98
+ headers['swarm-act-history-address'] = new core_sdk_1.Reference(options.actHistoryAddress).toHex();
99
99
  }
100
100
  if (options.actTimestamp) {
101
101
  headers['swarm-act-timestamp'] = String(options.actTimestamp);
@@ -25,7 +25,9 @@ exports.DEFAULT_HTTP_CONFIG = {
25
25
  * @param config Internal settings and/or Bee settings
26
26
  */
27
27
  async function http(options, config) {
28
- const requestConfig = cafe_utility_1.Objects.deepMerge3(exports.DEFAULT_HTTP_CONFIG, config, options);
28
+ const rawData = config.data;
29
+ const requestConfig = cafe_utility_1.Objects.deepMerge3(exports.DEFAULT_HTTP_CONFIG, { ...config, data: undefined }, options);
30
+ requestConfig.data = rawData;
29
31
  if (options.signal) {
30
32
  requestConfig.signal = options.signal;
31
33
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeMaxTarget = makeMaxTarget;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const types_1 = require("../types");
5
- const typed_bytes_1 = require("./typed-bytes");
6
6
  /**
7
7
  * Utility function that for given strings/reference takes the most specific
8
8
  * target that Bee node will except.
@@ -11,6 +11,6 @@ const typed_bytes_1 = require("./typed-bytes");
11
11
  * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
12
12
  */
13
13
  function makeMaxTarget(target) {
14
- target = new typed_bytes_1.PeerAddress(target);
14
+ target = new core_sdk_1.PeerAddress(target);
15
15
  return target.toHex().slice(0, types_1.PSS_TARGET_HEX_LENGTH_MAX);
16
16
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ResourceLocator = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
- const typed_bytes_1 = require("./typed-bytes");
6
6
  class ResourceLocator {
7
7
  constructor(raw) {
8
8
  this.raw = raw;
@@ -12,7 +12,7 @@ class ResourceLocator {
12
12
  if (asString.success && asString.data.includes('.eth')) {
13
13
  return asString.data;
14
14
  }
15
- return new typed_bytes_1.Reference(this.raw).toHex();
15
+ return new core_sdk_1.Reference(this.raw).toHex();
16
16
  }
17
17
  }
18
18
  exports.ResourceLocator = ResourceLocator;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AllTagsOptionsSchema = exports.TransactionOptionsSchema = exports.PostageBatchOptionsSchema = exports.GsocMessageHandlerSchema = exports.PssMessageHandlerSchema = exports.TagUidSchema = exports.TagInputSchema = exports.CollectionUploadOptionsSchema = exports.FileUploadOptionsSchema = exports.RedundantUploadOptionsSchema = exports.UploadOptionsSchema = exports.DownloadOptionsSchema = exports.BeeRequestOptionsSchema = exports.HexStringSchema = void 0;
4
+ const core_sdk_1 = require("@ethersphere/core-sdk");
4
5
  const zod_1 = require("zod");
5
6
  const types_1 = require("../types");
6
- const typed_bytes_1 = require("./typed-bytes");
7
7
  var hex_schema_1 = require("./hex-schema");
8
8
  Object.defineProperty(exports, "HexStringSchema", { enumerable: true, get: function () { return hex_schema_1.HexStringSchema; } });
9
9
  const fnField = zod_1.z.any().refine(v => zod_1.z.function().safeParse(v).success, 'expected a function');
@@ -34,13 +34,13 @@ exports.DownloadOptionsSchema = zod_1.z.object({
34
34
  redundancyStrategy: zod_1.z.number().int().optional(),
35
35
  fallback: zod_1.z.boolean().optional(),
36
36
  timeoutMs: zod_1.z.number().int().min(0).optional(),
37
- actPublisher: zod_1.z.optional(zod_1.z.any().transform((v) => new typed_bytes_1.PublicKey(v))),
38
- actHistoryAddress: zod_1.z.optional(zod_1.z.any().transform((v) => new typed_bytes_1.Reference(v))),
37
+ actPublisher: zod_1.z.optional(zod_1.z.any().transform((v) => new core_sdk_1.PublicKey(v))),
38
+ actHistoryAddress: zod_1.z.optional(zod_1.z.any().transform((v) => new core_sdk_1.Reference(v))),
39
39
  actTimestamp: zod_1.z.coerce.number().optional(),
40
40
  });
41
41
  exports.UploadOptionsSchema = zod_1.z.object({
42
42
  act: zod_1.z.boolean().optional(),
43
- actHistoryAddress: zod_1.z.optional(zod_1.z.any().transform((v) => new typed_bytes_1.Reference(v))),
43
+ actHistoryAddress: zod_1.z.optional(zod_1.z.any().transform((v) => new core_sdk_1.Reference(v))),
44
44
  deferred: zod_1.z.boolean().optional(),
45
45
  encrypt: zod_1.z.boolean().optional(),
46
46
  pin: zod_1.z.boolean().optional(),
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStampUsage = getStampUsage;
4
- exports.getStampTheoreticalBytes = getStampTheoreticalBytes;
5
- exports.getStampEffectiveBytes = getStampEffectiveBytes;
6
- exports.getStampEffectiveBytesBreakpoints = getStampEffectiveBytesBreakpoints;
3
+ exports.getStampUsage = exports.getStampTheoreticalBytes = exports.getStampEffectiveBytesBreakpoints = exports.getStampEffectiveBytes = void 0;
7
4
  exports.getStampCost = getStampCost;
8
5
  exports.getStampDuration = getStampDuration;
9
6
  exports.getAmountForDuration = getAmountForDuration;
@@ -12,99 +9,16 @@ exports.convertEnvelopeToMarshaledStamp = convertEnvelopeToMarshaledStamp;
12
9
  exports.marshalStamp = marshalStamp;
13
10
  exports.mapPostageBatch = mapPostageBatch;
14
11
  exports.unmapPostageBatch = unmapPostageBatch;
15
- const cafe_utility_1 = require("cafe-utility");
16
- const types_1 = require("../types");
17
- const bytes_1 = require("./bytes");
18
12
  const duration_1 = require("./duration");
19
13
  const size_1 = require("./size");
20
14
  const tokens_1 = require("./tokens");
21
15
  const type_1 = require("./type");
22
- const typed_bytes_1 = require("./typed-bytes");
23
16
  const workaround_1 = require("./workaround");
24
- const MAX_UTILIZATION = 0.9;
25
- /**
26
- * Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
27
- *
28
- * For smaller depths (up to 20), this may provide less accurate results.
29
- *
30
- * @returns {number} A number between 0 and 1 representing the usage of the postage batch.
31
- */
32
- function getStampUsage(utilization, depth, bucketDepth) {
33
- return utilization / Math.pow(2, depth - bucketDepth);
34
- }
35
- /**
36
- * Utility function that calculates the theoritical maximum size of a postage batch based on its depth.
37
- *
38
- * For smaller depths (up to 22), this may provide less accurate results.
39
- *
40
- * @returns {number} The maximum theoretical size of the postage batch in bytes.
41
- */
42
- function getStampTheoreticalBytes(depth) {
43
- return 4096 * 2 ** depth;
44
- }
45
- /**
46
- * Based on https://docs.ethswarm.org/docs/learn/technology/contracts/postage-stamp/#effective-utilisation-table
47
- * Optimised for encrypted, medium erasure coding
48
- */
49
- const effectiveSizeBreakpoints = [
50
- [17, 0.00004089],
51
- [18, 0.00609],
52
- [19, 0.10249],
53
- [20, 0.62891],
54
- [21, 2.38],
55
- [22, 7.07],
56
- [23, 18.24],
57
- [24, 43.04],
58
- [25, 96.5],
59
- [26, 208.52],
60
- [27, 435.98],
61
- [28, 908.81],
62
- [29, 1870],
63
- [30, 3810],
64
- [31, 7730],
65
- [32, 15610],
66
- [33, 31430],
67
- [34, 63150],
68
- ];
69
- /**
70
- * Utility function that calculates the effective size of a postage batch based on its depth.
71
- *
72
- * Below 22 depth the effective size is 0
73
- * Above 34 it's always > 99%
74
- *
75
- * @returns {number} The effective size of the postage batch in bytes.
76
- */
77
- function getStampEffectiveBytes(depth, encryption, erasureCodeLevel) {
78
- if (depth < 17) {
79
- return 0;
80
- }
81
- if (encryption !== undefined && erasureCodeLevel !== undefined) {
82
- const encryptionKey = encryption ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF';
83
- const breakpoints = types_1.capacityBreakpoints[encryptionKey][erasureCodeLevel];
84
- const entry = breakpoints.find(item => item.batchDepth === depth);
85
- if (entry?.effectiveVolume) {
86
- return (0, bytes_1.parseSizeToBytes)(entry.effectiveVolume);
87
- }
88
- }
89
- else {
90
- const breakpoint = effectiveSizeBreakpoints.find(([d, size]) => {
91
- if (depth === d) {
92
- return size;
93
- }
94
- });
95
- if (breakpoint) {
96
- return breakpoint[1] * 1000 * 1000 * 1000;
97
- }
98
- }
99
- return Math.ceil(getStampTheoreticalBytes(depth) * MAX_UTILIZATION);
100
- }
101
- function getStampEffectiveBytesBreakpoints(encryption, erasureCodeLevel) {
102
- const map = new Map();
103
- for (let i = 17; i < 35; i++) {
104
- map.set(i, getStampEffectiveBytes(i, encryption, erasureCodeLevel));
105
- }
106
- return map;
107
- }
17
+ const core_sdk_1 = require("@ethersphere/core-sdk");
18
+ Object.defineProperty(exports, "getStampEffectiveBytes", { enumerable: true, get: function () { return core_sdk_1.getStampEffectiveBytes; } });
19
+ Object.defineProperty(exports, "getStampEffectiveBytesBreakpoints", { enumerable: true, get: function () { return core_sdk_1.getStampEffectiveBytesBreakpoints; } });
20
+ Object.defineProperty(exports, "getStampTheoreticalBytes", { enumerable: true, get: function () { return core_sdk_1.getStampTheoreticalBytes; } });
21
+ Object.defineProperty(exports, "getStampUsage", { enumerable: true, get: function () { return core_sdk_1.getStampUsage; } });
108
22
  /**
109
23
  * Utility function that calculates the cost of a postage batch based on its depth and amount.
110
24
  */
@@ -139,50 +53,21 @@ function getAmountForDuration(duration, pricePerBlock, blockTime) {
139
53
  * @returns
140
54
  */
141
55
  function getDepthForSize(size, encryption, erasureCodeLevel) {
142
- if (encryption !== undefined && erasureCodeLevel !== undefined) {
143
- const encryptionKey = encryption ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF';
144
- const breakpoints = types_1.capacityBreakpoints[encryptionKey][erasureCodeLevel];
145
- const entry = breakpoints.find(item => {
146
- return size.toBytes() <= (0, bytes_1.parseSizeToBytes)(item.effectiveVolume);
147
- });
148
- if (entry?.effectiveVolume) {
149
- return entry.batchDepth;
150
- }
151
- }
152
- else {
153
- for (const [depth, sizeBreakpoint] of effectiveSizeBreakpoints) {
154
- if (size.toBytes() <= sizeBreakpoint * 1000 * 1000 * 1000) {
155
- return depth;
156
- }
157
- }
158
- }
159
- return 35;
56
+ return (0, core_sdk_1.getDepthForSize)(size.toBytes(), encryption, erasureCodeLevel);
160
57
  }
161
58
  function convertEnvelopeToMarshaledStamp(envelope) {
162
- return marshalStamp(envelope.signature, envelope.batchId.toUint8Array(), envelope.timestamp, envelope.index);
59
+ return (0, core_sdk_1.convertEnvelopeToMarshaledStamp)(envelope);
163
60
  }
164
61
  function marshalStamp(signature, batchId, timestamp, index) {
165
- if (signature.length !== 65) {
166
- throw Error('invalid signature length');
167
- }
168
- if (batchId.length !== 32) {
169
- throw Error('invalid batch ID length');
170
- }
171
- if (timestamp.length !== 8) {
172
- throw Error('invalid timestamp length');
173
- }
174
- if (index.length !== 8) {
175
- throw Error('invalid index length');
176
- }
177
- return new bytes_1.Bytes(cafe_utility_1.Binary.concatBytes(batchId, index, timestamp, signature));
62
+ return (0, core_sdk_1.marshalStamp)(signature, batchId, timestamp, index);
178
63
  }
179
64
  function mapPostageBatch(raw, encryption, erasureCodeLevel) {
180
65
  const batchTTL = (0, workaround_1.normalizeBatchTTL)(raw.batchTTL);
181
66
  const duration = duration_1.Duration.fromSeconds(batchTTL);
182
- const effectiveBytes = getStampEffectiveBytes(raw.depth, encryption, erasureCodeLevel);
183
- const usage = raw.utilizationRatio ?? getStampUsage(raw.utilization, raw.depth, raw.bucketDepth);
67
+ const effectiveBytes = (0, core_sdk_1.getStampEffectiveBytes)(raw.depth, encryption, erasureCodeLevel);
68
+ const usage = raw.utilizationRatio ?? (0, core_sdk_1.getStampUsage)(raw.utilization, raw.depth, raw.bucketDepth);
184
69
  return {
185
- batchID: new typed_bytes_1.BatchId(raw.batchID),
70
+ batchID: new core_sdk_1.BatchId(raw.batchID),
186
71
  utilization: raw.utilization,
187
72
  usable: raw.usable,
188
73
  label: raw.label,
@@ -195,14 +80,14 @@ function mapPostageBatch(raw, encryption, erasureCodeLevel) {
195
80
  usageText: `${Math.round(usage * 100)}%`,
196
81
  size: size_1.Size.fromBytes(effectiveBytes),
197
82
  remainingSize: size_1.Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage))),
198
- theoreticalSize: size_1.Size.fromBytes(getStampTheoreticalBytes(raw.depth)),
83
+ theoreticalSize: size_1.Size.fromBytes((0, core_sdk_1.getStampTheoreticalBytes)(raw.depth)),
199
84
  duration,
200
85
  calculateSize(encryption, redundancyLevel) {
201
- const effectiveBytes = getStampEffectiveBytes(raw.depth, encryption, redundancyLevel);
86
+ const effectiveBytes = (0, core_sdk_1.getStampEffectiveBytes)(raw.depth, encryption, redundancyLevel);
202
87
  return size_1.Size.fromBytes(effectiveBytes);
203
88
  },
204
89
  calculateRemainingSize(encryption, redundancyLevel) {
205
- const effectiveBytes = getStampEffectiveBytes(raw.depth, encryption, redundancyLevel);
90
+ const effectiveBytes = (0, core_sdk_1.getStampEffectiveBytes)(raw.depth, encryption, redundancyLevel);
206
91
  return size_1.Size.fromBytes(Math.ceil(effectiveBytes * (1 - this.usage)));
207
92
  },
208
93
  };