@upcoming/bee-js 9.4.2 → 9.8.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 (36) hide show
  1. package/dist/cjs/bee.js +110 -22
  2. package/dist/cjs/manifest/manifest.js +3 -3
  3. package/dist/cjs/modules/debug/stake.js +37 -3
  4. package/dist/cjs/modules/debug/states.js +24 -1
  5. package/dist/cjs/modules/debug/status.js +3 -2
  6. package/dist/cjs/modules/status.js +15 -1
  7. package/dist/cjs/types/index.js +277 -1
  8. package/dist/cjs/utils/bytes.js +19 -1
  9. package/dist/cjs/utils/chunk-stream.js +15 -3
  10. package/dist/cjs/utils/http.js +1 -1
  11. package/dist/cjs/utils/stamps.js +36 -13
  12. package/dist/index.browser.min.js +1 -1
  13. package/dist/index.browser.min.js.map +1 -1
  14. package/dist/mjs/bee.js +109 -23
  15. package/dist/mjs/manifest/manifest.js +3 -3
  16. package/dist/mjs/modules/debug/stake.js +45 -2
  17. package/dist/mjs/modules/debug/states.js +35 -0
  18. package/dist/mjs/modules/debug/status.js +5 -2
  19. package/dist/mjs/modules/status.js +12 -0
  20. package/dist/mjs/types/index.js +1267 -1
  21. package/dist/mjs/utils/bytes.js +17 -0
  22. package/dist/mjs/utils/chunk-stream.js +14 -3
  23. package/dist/mjs/utils/http.js +1 -1
  24. package/dist/mjs/utils/stamps.js +35 -14
  25. package/dist/types/bee.d.ts +71 -19
  26. package/dist/types/manifest/manifest.d.ts +1 -1
  27. package/dist/types/modules/debug/stake.d.ts +9 -2
  28. package/dist/types/modules/debug/states.d.ts +4 -0
  29. package/dist/types/modules/debug/status.d.ts +2 -2
  30. package/dist/types/modules/status.d.ts +1 -0
  31. package/dist/types/types/debug.d.ts +1 -0
  32. package/dist/types/types/index.d.ts +66 -0
  33. package/dist/types/utils/bytes.d.ts +1 -0
  34. package/dist/types/utils/chunk-stream.d.ts +2 -2
  35. package/dist/types/utils/stamps.d.ts +4 -4
  36. package/package.json +3 -3
package/dist/cjs/bee.js CHANGED
@@ -722,7 +722,8 @@ class Bee {
722
722
  for (let i = 0n; i < 0xffffn; i++) {
723
723
  const signer = new typed_bytes_1.PrivateKey(cafe_utility_1.Binary.numberToUint256(start + i, 'BE'));
724
724
  const socAddress = (0, soc_1.makeSOCAddress)(identifier, signer.publicKey().address());
725
- const actualProximity = 256 - cafe_utility_1.Binary.proximity(socAddress.toUint8Array(), targetOverlay.toUint8Array(), 256);
725
+ // TODO: test the significance of the hardcoded 256
726
+ const actualProximity = 256 - cafe_utility_1.Binary.proximity(socAddress.toUint8Array(), targetOverlay.toUint8Array());
726
727
  if (actualProximity <= 256 - proximity) {
727
728
  return signer;
728
729
  }
@@ -896,6 +897,17 @@ class Bee {
896
897
  }
897
898
  return true;
898
899
  }
900
+ /**
901
+ * Checks the `/gateway` endpoint to see if the remote API is a gateway.
902
+ *
903
+ * Do note that this is not a standard way to check for gateway nodes,
904
+ * but some of the gateway tooling expose this endpoint.
905
+ *
906
+ * @param options
907
+ */
908
+ async isGateway(options) {
909
+ return status.isGateway(this.getRequestOptionsForCall(options));
910
+ }
899
911
  // Legacy debug API
900
912
  async getNodeAddresses(options) {
901
913
  return connectivity.getNodeAddresses(this.getRequestOptionsForCall(options));
@@ -1011,13 +1023,24 @@ class Bee {
1011
1023
  return chequebook.cashoutLastCheque(this.getRequestOptionsForCall(requestOptions), address, options);
1012
1024
  }
1013
1025
  /**
1014
- * Deposit tokens from overlay address into chequebook
1026
+ * Deposit tokens from node wallet into chequebook
1015
1027
  *
1016
1028
  * @param amount Amount of tokens to deposit (must be positive integer)
1017
1029
  * @param gasPrice Gas Price in WEI for the transaction call
1018
1030
  * @return string Hash of the transaction
1031
+ * @deprecated Use `depositBZZToChequebook` instead.
1019
1032
  */
1020
1033
  async depositTokens(amount, gasPrice, options) {
1034
+ return this.depositBZZToChequebook(amount, gasPrice, options);
1035
+ }
1036
+ /**
1037
+ * Deposit tokens from node wallet into chequebook
1038
+ *
1039
+ * @param amount Amount of tokens to deposit (must be positive integer)
1040
+ * @param gasPrice Gas Price in WEI for the transaction call
1041
+ * @return string Hash of the transaction
1042
+ */
1043
+ async depositBZZToChequebook(amount, gasPrice, options) {
1021
1044
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
1022
1045
  let gasPriceString;
1023
1046
  if (gasPrice) {
@@ -1026,13 +1049,24 @@ class Bee {
1026
1049
  return chequebook.depositTokens(this.getRequestOptionsForCall(options), amountString, gasPriceString);
1027
1050
  }
1028
1051
  /**
1029
- * Withdraw tokens from the chequebook to the overlay address
1052
+ * Withdraw tokens from the chequebook to the node wallet
1030
1053
  *
1031
1054
  * @param amount Amount of tokens to withdraw (must be positive integer)
1032
1055
  * @param gasPrice Gas Price in WEI for the transaction call
1033
1056
  * @return string Hash of the transaction
1057
+ * @deprecated Use `withdrawBZZFromChequebook` instead.
1034
1058
  */
1035
1059
  async withdrawTokens(amount, gasPrice, options) {
1060
+ return this.withdrawBZZFromChequebook(amount, gasPrice, options);
1061
+ }
1062
+ /**
1063
+ * Withdraw tokens from the chequebook to the node wallet
1064
+ *
1065
+ * @param amount Amount of tokens to withdraw (must be positive integer)
1066
+ * @param gasPrice Gas Price in WEI for the transaction call
1067
+ * @return string Hash of the transaction
1068
+ */
1069
+ async withdrawBZZFromChequebook(amount, gasPrice, options) {
1036
1070
  // TODO: check BZZ in tests
1037
1071
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
1038
1072
  let gasPriceString;
@@ -1041,6 +1075,16 @@ class Bee {
1041
1075
  }
1042
1076
  return chequebook.withdrawTokens(this.getRequestOptionsForCall(options), amountString, gasPriceString);
1043
1077
  }
1078
+ async withdrawBZZToExternalWallet(amount, address, options) {
1079
+ amount = amount instanceof tokens_1.BZZ ? amount : tokens_1.BZZ.fromPLUR(amount);
1080
+ address = new typed_bytes_1.EthAddress(address);
1081
+ return states.withdrawBZZ(this.getRequestOptionsForCall(options), amount, address);
1082
+ }
1083
+ async withdrawDAIToExternalWallet(amount, address, options) {
1084
+ amount = amount instanceof tokens_1.DAI ? amount : tokens_1.DAI.fromWei(amount);
1085
+ address = new typed_bytes_1.EthAddress(address);
1086
+ return states.withdrawDAI(this.getRequestOptionsForCall(options), amount, address);
1087
+ }
1044
1088
  /*
1045
1089
  * Settlements endpoint
1046
1090
  */
@@ -1124,7 +1168,7 @@ class Bee {
1124
1168
  return states.getChainState(this.getRequestOptionsForCall(options));
1125
1169
  }
1126
1170
  /**
1127
- * Get wallet balances for xDai and BZZ of the Bee node
1171
+ * Get wallet balances for DAI and BZZ of the Bee node
1128
1172
  *
1129
1173
  * @param options
1130
1174
  */
@@ -1167,24 +1211,40 @@ class Bee {
1167
1211
  }
1168
1212
  return stamp;
1169
1213
  }
1170
- async buyStorage(size, duration, options, requestOptions) {
1214
+ async buyStorage(size, duration, options, requestOptions, encryption, erasureCodeLevel) {
1171
1215
  const chainState = await this.getChainState(requestOptions);
1172
1216
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1173
- const depth = (0, stamps_1.getDepthForSize)(size);
1217
+ const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1174
1218
  if (options) {
1175
1219
  options = (0, type_1.preparePostageBatchOptions)(options);
1176
1220
  }
1177
1221
  return this.createPostageBatch(amount, depth, options, requestOptions);
1178
1222
  }
1179
- async getStorageCost(size, duration, options) {
1223
+ async getStorageCost(size, duration, options, encryption, erasureCodeLevel) {
1180
1224
  const chainState = await this.getChainState(options);
1181
1225
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1182
- const depth = (0, stamps_1.getDepthForSize)(size);
1226
+ const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1183
1227
  return (0, stamps_1.getStampCost)(depth, amount);
1184
1228
  }
1185
- async extendStorageSize(postageBatchId, size, options) {
1229
+ async extendStorage(postageBatchId, size, duration, options, encryption, erasureCodeLevel) {
1230
+ const batch = await this.getPostageBatch(postageBatchId, options);
1231
+ const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1232
+ const chainState = await this.getChainState(options);
1233
+ const depthDelta = depth - batch.depth;
1234
+ const multiplier = depthDelta === 0 ? 1n : 2n ** BigInt(depthDelta);
1235
+ const targetAmount = (BigInt(batch.amount) +
1236
+ (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15)) *
1237
+ multiplier;
1238
+ const amountDelta = targetAmount - BigInt(batch.amount);
1239
+ const transactionId = await this.topUpBatch(batch.batchID, amountDelta, options);
1240
+ if (depthDelta) {
1241
+ return this.diluteBatch(batch.batchID, depth, options);
1242
+ }
1243
+ return transactionId;
1244
+ }
1245
+ async extendStorageSize(postageBatchId, size, options, encryption, erasureCodeLevel) {
1186
1246
  const batch = await this.getPostageBatch(postageBatchId, options);
1187
- const depth = (0, stamps_1.getDepthForSize)(size);
1247
+ const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1188
1248
  const delta = depth - batch.depth;
1189
1249
  if (delta <= 0) {
1190
1250
  throw new error_1.BeeArgumentError('New depth has to be greater than the original depth', depth);
@@ -1198,18 +1258,18 @@ class Bee {
1198
1258
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1199
1259
  return this.topUpBatch(batch.batchID, amount, options);
1200
1260
  }
1201
- async getExtensionCost(postageBatchId, size, duration, options) {
1261
+ async getExtensionCost(postageBatchId, size, duration, options, encryption, erasureCodeLevel) {
1202
1262
  const batch = await this.getPostageBatch(postageBatchId, options);
1203
1263
  const chainState = await this.getChainState(options);
1204
1264
  const amount = (0, stamps_1.getAmountForDuration)(duration, chainState.currentPrice, this.network === 'gnosis' ? 5 : 15);
1205
- const depth = (0, stamps_1.getDepthForSize)(size);
1265
+ const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1206
1266
  const currentValue = (0, stamps_1.getStampCost)(batch.depth, batch.amount);
1207
1267
  const newValue = (0, stamps_1.getStampCost)(depth, amount);
1208
1268
  return newValue.minus(currentValue);
1209
1269
  }
1210
- async getSizeExtensionCost(postageBatchId, size, options) {
1270
+ async getSizeExtensionCost(postageBatchId, size, options, encryption, erasureCodeLevel) {
1211
1271
  const batch = await this.getPostageBatch(postageBatchId, options);
1212
- const depth = (0, stamps_1.getDepthForSize)(size);
1272
+ const depth = (0, stamps_1.getDepthForSize)(size, encryption, erasureCodeLevel);
1213
1273
  const delta = depth - batch.depth;
1214
1274
  if (delta <= 0) {
1215
1275
  throw new error_1.BeeArgumentError('New depth has to be greater than the original depth', depth);
@@ -1342,7 +1402,7 @@ class Bee {
1342
1402
  return transactions.rebroadcastTransaction(this.getRequestOptionsForCall(options), transactionHash);
1343
1403
  }
1344
1404
  /**
1345
- * Cancel currently pending transaction
1405
+ * Cancels a currently pending transaction
1346
1406
  * @param transactionHash
1347
1407
  * @param gasPrice
1348
1408
  */
@@ -1355,20 +1415,48 @@ class Bee {
1355
1415
  return transactions.cancelTransaction(this.getRequestOptionsForCall(options), transactionHash, gasPriceString);
1356
1416
  }
1357
1417
  /**
1358
- * Gets the staked amount of BZZ (in PLUR unit) as number string.
1418
+ * Gets the amount of staked BZZ
1359
1419
  *
1360
- * @param options
1420
+ * @param options HTTP request options, such as `headers` or `timeout`
1361
1421
  */
1362
1422
  async getStake(options) {
1363
1423
  return stake.getStake(this.getRequestOptionsForCall(options));
1364
1424
  }
1365
1425
  /**
1366
- * Deposits given amount of BZZ token (in PLUR unit).
1426
+ * Gets the amount of withdrawable staked BZZ.
1427
+ *
1428
+ * @param options HTTP request options, such as `headers` or `timeout`
1429
+ */
1430
+ async getWithdrawableStake(options) {
1431
+ return stake.getWithdrawableStake(this.getRequestOptionsForCall(options));
1432
+ }
1433
+ /**
1434
+ * Withdraws ALL surplus staked BZZ to the node wallet.
1435
+ *
1436
+ * Use the `getWithdrawableStake` method to check how much surplus stake is available.
1437
+ *
1438
+ * @param options HTTP request options, such as `headers` or `timeout`
1439
+ */
1440
+ async withdrawSurplusStake(options) {
1441
+ return stake.withdrawSurplusStake(this.getRequestOptionsForCall(options));
1442
+ }
1443
+ /**
1444
+ * Withdraws all staked BZZ to the node wallet.
1445
+ *
1446
+ * **Only available when the staking contract is paused and is in the process of being migrated to a new contract!**
1447
+ *
1448
+ * @param options HTTP request options, such as `headers` or `timeout`
1449
+ */
1450
+ async migrateStake(options) {
1451
+ return stake.migrateStake(this.getRequestOptionsForCall(options));
1452
+ }
1453
+ /**
1454
+ * Stakes the given amount of BZZ. Initial deposit must be at least 10 BZZ.
1367
1455
  *
1368
1456
  * Be aware that staked BZZ tokens can **not** be withdrawn.
1369
1457
  *
1370
- * @param amount Amount of BZZ token (in PLUR unit) to be staked. Minimum is 100_000_000_000_000_000 PLUR (10 BZZ).
1371
- * @param options
1458
+ * @param amount Amount of BZZ tokens to be staked. If not providing a `BZZ` instance, the amount is denoted in PLUR.
1459
+ * @param options HTTP request options, such as `headers` or `timeout`
1372
1460
  */
1373
1461
  async depositStake(amount, options, requestOptions) {
1374
1462
  const amountString = amount instanceof tokens_1.BZZ ? amount.toPLURString() : (0, type_1.asNumberString)(amount, { min: 1n, name: 'amount' });
@@ -1378,9 +1466,9 @@ class Bee {
1378
1466
  return stake.stake(this.getRequestOptionsForCall(requestOptions), amountString, options);
1379
1467
  }
1380
1468
  /**
1381
- * Get current status of node in redistribution game
1469
+ * Gets current status of node in redistribution game
1382
1470
  *
1383
- * @param options
1471
+ * @param options HTTP request options, such as `headers` or `timeout`
1384
1472
  */
1385
1473
  async getRedistributionState(options) {
1386
1474
  return stake.getRedistributionState(this.getRequestOptionsForCall(options));
@@ -69,12 +69,12 @@ class Fork {
69
69
  }
70
70
  return cafe_utility_1.Binary.concatBytes(...data);
71
71
  }
72
- static unmarshal(reader) {
72
+ static unmarshal(reader, addressLength) {
73
73
  const type = cafe_utility_1.Binary.uint8ToNumber(reader.read(1));
74
74
  const prefixLength = cafe_utility_1.Binary.uint8ToNumber(reader.read(1));
75
75
  const prefix = reader.read(prefixLength);
76
76
  reader.read(30 - prefixLength);
77
- const selfAddress = reader.read(32);
77
+ const selfAddress = reader.read(addressLength);
78
78
  let metadata = undefined;
79
79
  if (isType(type, TYPE_WITH_METADATA)) {
80
80
  const metadataLength = cafe_utility_1.Binary.uint16ToNumber(reader.read(2), 'BE');
@@ -214,7 +214,7 @@ class MantarayNode {
214
214
  const forkBitmap = reader.read(32);
215
215
  for (let i = 0; i < 256; i++) {
216
216
  if (cafe_utility_1.Binary.getBit(forkBitmap, i, 'LE')) {
217
- const newFork = Fork.unmarshal(reader);
217
+ const newFork = Fork.unmarshal(reader, targetAddressLength);
218
218
  node.forks.set(i, newFork);
219
219
  newFork.node.parent = node;
220
220
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRedistributionState = exports.stake = exports.getStake = void 0;
3
+ exports.getRedistributionState = exports.stake = exports.migrateStake = exports.withdrawSurplusStake = exports.getWithdrawableStake = exports.getStake = void 0;
4
4
  const cafe_utility_1 = require("cafe-utility");
5
5
  const headers_1 = require("../../utils/headers");
6
6
  const http_1 = require("../../utils/http");
@@ -10,7 +10,7 @@ const typed_bytes_1 = require("../../utils/typed-bytes");
10
10
  const STAKE_ENDPOINT = 'stake';
11
11
  const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
12
12
  /**
13
- * Gets the staked amount
13
+ * Gets the amount of staked BZZ
14
14
  *
15
15
  * @param requestOptions Options for making requests
16
16
  */
@@ -24,12 +24,46 @@ async function getStake(requestOptions) {
24
24
  return tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.stakedAmount, { name: 'stakedAmount' }));
25
25
  }
26
26
  exports.getStake = getStake;
27
+ /**
28
+ * Gets the amount of withdrawable staked BZZ
29
+ *
30
+ * @param requestOptions Options for making requests
31
+ */
32
+ async function getWithdrawableStake(requestOptions) {
33
+ const response = await (0, http_1.http)(requestOptions, {
34
+ method: 'get',
35
+ responseType: 'json',
36
+ url: `${STAKE_ENDPOINT}/withdrawable`,
37
+ });
38
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
39
+ return tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.withdrawableAmount, { name: 'withdrawableAmount' }));
40
+ }
41
+ exports.getWithdrawableStake = getWithdrawableStake;
42
+ async function withdrawSurplusStake(requestOptions) {
43
+ const response = await (0, http_1.http)(requestOptions, {
44
+ method: 'delete',
45
+ responseType: 'json',
46
+ url: `${STAKE_ENDPOINT}/withdrawable`,
47
+ });
48
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
49
+ return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
50
+ }
51
+ exports.withdrawSurplusStake = withdrawSurplusStake;
52
+ async function migrateStake(requestOptions) {
53
+ const response = await (0, http_1.http)(requestOptions, {
54
+ method: 'delete',
55
+ responseType: 'json',
56
+ url: STAKE_ENDPOINT,
57
+ });
58
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
59
+ return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
60
+ }
61
+ exports.migrateStake = migrateStake;
27
62
  /**
28
63
  * Stake given amount of tokens.
29
64
  *
30
65
  * @param requestOptions Options for making requests
31
66
  * @param amount
32
- * @param options
33
67
  */
34
68
  async function stake(requestOptions, amount, options) {
35
69
  const repsonse = await (0, http_1.http)(requestOptions, {
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWalletBalance = exports.getChainState = exports.getReserveState = void 0;
3
+ exports.withdrawDAI = exports.withdrawBZZ = exports.getWalletBalance = exports.getChainState = exports.getReserveState = void 0;
4
4
  const cafe_utility_1 = require("cafe-utility");
5
5
  const http_1 = require("../../utils/http");
6
6
  const tokens_1 = require("../../utils/tokens");
7
7
  const type_1 = require("../../utils/type");
8
+ const typed_bytes_1 = require("../../utils/typed-bytes");
8
9
  const workaround_1 = require("../../utils/workaround");
9
10
  const RESERVE_STATE_ENDPOINT = 'reservestate';
10
11
  const WALLET_ENDPOINT = 'wallet';
@@ -69,3 +70,25 @@ async function getWalletBalance(requestOptions) {
69
70
  };
70
71
  }
71
72
  exports.getWalletBalance = getWalletBalance;
73
+ async function withdrawBZZ(requestOptions, amount, address) {
74
+ const response = await (0, http_1.http)(requestOptions, {
75
+ method: 'post',
76
+ url: `${WALLET_ENDPOINT}/withdraw/bzz`,
77
+ responseType: 'json',
78
+ params: { amount: amount.toPLURString(), address: address.toHex() },
79
+ });
80
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
81
+ return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
82
+ }
83
+ exports.withdrawBZZ = withdrawBZZ;
84
+ async function withdrawDAI(requestOptions, amount, address) {
85
+ const response = await (0, http_1.http)(requestOptions, {
86
+ method: 'post',
87
+ url: `${WALLET_ENDPOINT}/withdraw/nativetoken`,
88
+ responseType: 'json',
89
+ params: { amount: amount.toWeiString(), address: address.toHex() },
90
+ });
91
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
92
+ return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
93
+ }
94
+ exports.withdrawDAI = withdrawDAI;
@@ -8,9 +8,9 @@ const cafe_utility_1 = require("cafe-utility");
8
8
  const major_js_1 = __importDefault(require("semver/functions/major.js"));
9
9
  const debug_1 = require("../../types/debug");
10
10
  const http_1 = require("../../utils/http");
11
- exports.SUPPORTED_BEE_VERSION_EXACT = '2.4.0-390a402e';
11
+ exports.SUPPORTED_BEE_VERSION_EXACT = '2.6.0-d0aa8b93';
12
12
  exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
13
- exports.SUPPORTED_API_VERSION = '7.2.0';
13
+ exports.SUPPORTED_API_VERSION = '7.3.0';
14
14
  const NODE_INFO_URL = 'node';
15
15
  const STATUS_URL = 'status';
16
16
  const HEALTH_URL = 'health';
@@ -36,6 +36,7 @@ async function getDebugStatus(requestOptions) {
36
36
  isReachable: cafe_utility_1.Types.asBoolean(body.isReachable, { name: 'isReachable' }),
37
37
  lastSyncedBlock: cafe_utility_1.Types.asNumber(body.lastSyncedBlock, { name: 'lastSyncedBlock' }),
38
38
  committedDepth: cafe_utility_1.Types.asNumber(body.committedDepth, { name: 'committedDepth' }),
39
+ isWarmingUp: cafe_utility_1.Types.asBoolean(body.isWarmingUp, { name: 'isWarmingUp' }),
39
40
  };
40
41
  }
41
42
  exports.getDebugStatus = getDebugStatus;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkConnection = void 0;
3
+ exports.isGateway = exports.checkConnection = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
4
5
  const http_1 = require("../utils/http");
5
6
  /**
6
7
  * Ping the base bee URL. If connection was not successful throw error
@@ -13,3 +14,16 @@ async function checkConnection(requestOptions) {
13
14
  });
14
15
  }
15
16
  exports.checkConnection = checkConnection;
17
+ async function isGateway(requestOptions) {
18
+ try {
19
+ const response = await (0, http_1.http)(requestOptions, {
20
+ url: '/gateway',
21
+ });
22
+ const data = cafe_utility_1.Types.asObject(response.data);
23
+ return cafe_utility_1.Types.asBoolean(data.gateway);
24
+ }
25
+ catch (error) {
26
+ return false;
27
+ }
28
+ }
29
+ exports.isGateway = isGateway;