@ethersphere/bee-js 12.2.1 → 12.3.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 (143) hide show
  1. package/dist/cjs/bee.js +56 -23
  2. package/dist/cjs/chunk/cac.js +4 -2
  3. package/dist/cjs/feed/index.js +3 -1
  4. package/dist/cjs/index.js +1 -3
  5. package/dist/cjs/modules/bytes.js +6 -4
  6. package/dist/cjs/modules/bzz.js +5 -4
  7. package/dist/cjs/modules/chunk.js +3 -2
  8. package/dist/cjs/modules/debug/balance.js +5 -29
  9. package/dist/cjs/modules/debug/chequebook.js +9 -58
  10. package/dist/cjs/modules/debug/connectivity.js +5 -82
  11. package/dist/cjs/modules/debug/settlements.js +3 -22
  12. package/dist/cjs/modules/debug/stake.js +8 -33
  13. package/dist/cjs/modules/debug/stamps.js +27 -53
  14. package/dist/cjs/modules/debug/states.js +6 -31
  15. package/dist/cjs/modules/debug/status.js +5 -37
  16. package/dist/cjs/modules/debug/transactions.js +5 -26
  17. package/dist/cjs/modules/envelope.js +6 -6
  18. package/dist/cjs/modules/feed.js +3 -4
  19. package/dist/cjs/modules/grantee.js +8 -10
  20. package/dist/cjs/modules/pinning.js +5 -11
  21. package/dist/cjs/modules/rchash.js +2 -3
  22. package/dist/cjs/modules/soc.js +3 -2
  23. package/dist/cjs/modules/status.js +3 -3
  24. package/dist/cjs/modules/stewardship.js +2 -3
  25. package/dist/cjs/modules/tag.js +4 -35
  26. package/dist/cjs/stamper/stamper.js +2 -1
  27. package/dist/cjs/types/schema/balance.js +14 -0
  28. package/dist/cjs/types/schema/chequebook.js +49 -0
  29. package/dist/cjs/types/schema/connectivity.js +46 -0
  30. package/dist/cjs/types/schema/envelope.js +11 -0
  31. package/dist/cjs/types/schema/grantee.js +10 -0
  32. package/dist/cjs/types/schema/pinning.js +7 -0
  33. package/dist/cjs/types/schema/rchash.js +7 -0
  34. package/dist/cjs/types/schema/settlements.js +17 -0
  35. package/dist/cjs/types/schema/stake.js +33 -0
  36. package/dist/cjs/types/schema/stamps.js +48 -0
  37. package/dist/cjs/types/schema/states.js +34 -0
  38. package/dist/cjs/types/schema/status.js +39 -0
  39. package/dist/cjs/types/schema/stewardship.js +7 -0
  40. package/dist/cjs/types/schema/tag.js +20 -0
  41. package/dist/cjs/types/schema/transactions.js +24 -0
  42. package/dist/cjs/types/schema/upload.js +8 -0
  43. package/dist/cjs/utils/bad-ports.js +92 -0
  44. package/dist/cjs/utils/bytes.js +5 -3
  45. package/dist/cjs/utils/error.js +1 -0
  46. package/dist/cjs/utils/headers.js +19 -13
  47. package/dist/cjs/utils/hex-schema.js +8 -0
  48. package/dist/cjs/utils/http.js +92 -52
  49. package/dist/cjs/utils/resource-locator.js +4 -3
  50. package/dist/cjs/utils/schema.js +88 -0
  51. package/dist/cjs/utils/stamps.js +2 -1
  52. package/dist/cjs/utils/type.js +12 -130
  53. package/dist/cjs/utils/url.js +24 -0
  54. package/dist/index.browser.min.js +1 -1
  55. package/dist/index.browser.min.js.map +1 -1
  56. package/dist/mjs/bee.js +59 -30
  57. package/dist/mjs/chunk/cac.js +5 -3
  58. package/dist/mjs/feed/index.js +4 -2
  59. package/dist/mjs/index.js +1 -2
  60. package/dist/mjs/modules/bytes.js +8 -8
  61. package/dist/mjs/modules/bzz.js +6 -9
  62. package/dist/mjs/modules/chunk.js +4 -7
  63. package/dist/mjs/modules/debug/balance.js +5 -61
  64. package/dist/mjs/modules/debug/chequebook.js +9 -114
  65. package/dist/mjs/modules/debug/connectivity.js +5 -145
  66. package/dist/mjs/modules/debug/settlements.js +3 -46
  67. package/dist/mjs/modules/debug/stake.js +8 -85
  68. package/dist/mjs/modules/debug/stamps.js +24 -126
  69. package/dist/mjs/modules/debug/states.js +6 -71
  70. package/dist/mjs/modules/debug/status.js +5 -91
  71. package/dist/mjs/modules/debug/transactions.js +5 -60
  72. package/dist/mjs/modules/envelope.js +6 -20
  73. package/dist/mjs/modules/feed.js +6 -7
  74. package/dist/mjs/modules/grantee.js +8 -26
  75. package/dist/mjs/modules/pinning.js +7 -21
  76. package/dist/mjs/modules/rchash.js +2 -7
  77. package/dist/mjs/modules/soc.js +4 -5
  78. package/dist/mjs/modules/status.js +4 -4
  79. package/dist/mjs/modules/stewardship.js +2 -7
  80. package/dist/mjs/modules/tag.js +4 -93
  81. package/dist/mjs/stamper/stamper.js +2 -1
  82. package/dist/mjs/types/schema/balance.js +13 -0
  83. package/dist/mjs/types/schema/chequebook.js +53 -0
  84. package/dist/mjs/types/schema/connectivity.js +41 -0
  85. package/dist/mjs/types/schema/envelope.js +8 -0
  86. package/dist/mjs/types/schema/grantee.js +7 -0
  87. package/dist/mjs/types/schema/pinning.js +4 -0
  88. package/dist/mjs/types/schema/rchash.js +4 -0
  89. package/dist/mjs/types/schema/settlements.js +22 -0
  90. package/dist/mjs/types/schema/stake.js +40 -0
  91. package/dist/mjs/types/schema/stamps.js +47 -0
  92. package/dist/mjs/types/schema/states.js +34 -0
  93. package/dist/mjs/types/schema/status.js +36 -0
  94. package/dist/mjs/types/schema/stewardship.js +4 -0
  95. package/dist/mjs/types/schema/tag.js +14 -0
  96. package/dist/mjs/types/schema/transactions.js +25 -0
  97. package/dist/mjs/types/schema/upload.js +5 -0
  98. package/dist/mjs/utils/bad-ports.js +6 -0
  99. package/dist/mjs/utils/bytes.js +6 -8
  100. package/dist/mjs/utils/error.js +5 -0
  101. package/dist/mjs/utils/headers.js +19 -13
  102. package/dist/mjs/utils/hex-schema.js +2 -0
  103. package/dist/mjs/utils/http.js +97 -59
  104. package/dist/mjs/utils/resource-locator.js +4 -3
  105. package/dist/mjs/utils/schema.js +81 -0
  106. package/dist/mjs/utils/stamps.js +2 -1
  107. package/dist/mjs/utils/type.js +13 -233
  108. package/dist/mjs/utils/url.js +23 -0
  109. package/dist/types/bee.d.ts +23 -0
  110. package/dist/types/index.d.ts +1 -3
  111. package/dist/types/modules/debug/connectivity.d.ts +2 -2
  112. package/dist/types/modules/debug/stamps.d.ts +2 -0
  113. package/dist/types/types/debug.d.ts +1 -0
  114. package/dist/types/types/schema/balance.d.ts +12 -0
  115. package/dist/types/types/schema/chequebook.d.ts +104 -0
  116. package/dist/types/types/schema/connectivity.d.ts +49 -0
  117. package/dist/types/types/schema/envelope.d.ts +7 -0
  118. package/dist/types/types/schema/grantee.d.ts +7 -0
  119. package/dist/types/types/schema/pinning.d.ts +4 -0
  120. package/dist/types/types/schema/rchash.d.ts +4 -0
  121. package/dist/types/types/schema/settlements.d.ts +16 -0
  122. package/dist/types/types/schema/stake.d.ts +29 -0
  123. package/dist/types/types/schema/stamps.d.ts +77 -0
  124. package/dist/types/types/schema/states.d.ts +26 -0
  125. package/dist/types/types/schema/status.d.ts +38 -0
  126. package/dist/types/types/schema/stewardship.d.ts +4 -0
  127. package/dist/types/types/schema/tag.d.ts +23 -0
  128. package/dist/types/types/schema/transactions.d.ts +29 -0
  129. package/dist/types/types/schema/upload.d.ts +5 -0
  130. package/dist/types/utils/bad-ports.d.ts +6 -0
  131. package/dist/types/utils/error.d.ts +5 -0
  132. package/dist/types/utils/hex-schema.d.ts +2 -0
  133. package/dist/types/utils/http.d.ts +18 -3
  134. package/dist/types/utils/schema.d.ts +90 -0
  135. package/dist/types/utils/stamps.d.ts +1 -0
  136. package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
  137. package/dist/types/utils/tar-uploader.d.ts +1 -1
  138. package/dist/types/utils/type.d.ts +1 -16
  139. package/dist/types/utils/url.d.ts +9 -0
  140. package/package.json +10 -10
  141. package/dist/cjs/bee-dev.js +0 -78
  142. package/dist/mjs/bee-dev.js +0 -98
  143. package/dist/types/bee-dev.d.ts +0 -5
@@ -6,41 +6,28 @@ exports.getBlocklist = getBlocklist;
6
6
  exports.removePeer = removePeer;
7
7
  exports.getTopology = getTopology;
8
8
  exports.pingPeer = pingPeer;
9
- exports.asBin = asBin;
10
- const cafe_utility_1 = require("cafe-utility");
9
+ const connectivity_1 = require("../../types/schema/connectivity");
11
10
  const http_1 = require("../../utils/http");
12
- const typed_bytes_1 = require("../../utils/typed-bytes");
13
11
  async function getNodeAddresses(requestOptions) {
14
12
  const response = await (0, http_1.http)(requestOptions, {
15
13
  url: 'addresses',
16
14
  responseType: 'json',
17
15
  });
18
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
19
- return {
20
- overlay: new typed_bytes_1.PeerAddress(cafe_utility_1.Types.asString(body.overlay, { name: 'overlay' })),
21
- underlay: cafe_utility_1.Types.asArray(body.underlay, { name: 'underlay' }).map(x => cafe_utility_1.Types.asString(x, { name: 'underlay' })),
22
- ethereum: new typed_bytes_1.EthAddress(cafe_utility_1.Types.asString(body.ethereum, { name: 'ethereum' })),
23
- publicKey: new typed_bytes_1.PublicKey(cafe_utility_1.Types.asString(body.publicKey, { name: 'publicKey' })),
24
- pssPublicKey: new typed_bytes_1.PublicKey(cafe_utility_1.Types.asString(body.pssPublicKey, { name: 'pssPublicKey' })),
25
- };
16
+ return connectivity_1.GetNodeAddressesResponse.parse(response.data);
26
17
  }
27
18
  async function getPeers(requestOptions) {
28
19
  const response = await (0, http_1.http)(requestOptions, {
29
20
  url: 'peers',
30
21
  responseType: 'json',
31
22
  });
32
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
33
- return cafe_utility_1.Types.asArray(body.peers, { name: 'peers' }).map(x => ({
34
- address: cafe_utility_1.Types.asString(cafe_utility_1.Types.asObject(x, { name: 'peer' }).address, { name: 'address' }),
35
- fullNode: cafe_utility_1.Types.asBoolean(cafe_utility_1.Types.asObject(x, { name: 'peer' }).fullNode, { name: 'fullNode' }),
36
- }));
23
+ return connectivity_1.GetPeersResponse.parse(response.data).peers;
37
24
  }
38
25
  async function getBlocklist(requestOptions) {
39
26
  const response = await (0, http_1.http)(requestOptions, {
40
27
  url: 'blocklist',
41
28
  responseType: 'json',
42
29
  });
43
- return response.data.peers;
30
+ return connectivity_1.GetBlocklistResponse.parse(response.data).peers;
44
31
  }
45
32
  async function removePeer(requestOptions, peer) {
46
33
  const response = await (0, http_1.http)(requestOptions, {
@@ -55,52 +42,7 @@ async function getTopology(requestOptions) {
55
42
  url: `topology`,
56
43
  responseType: 'json',
57
44
  });
58
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
59
- const bins = cafe_utility_1.Types.asObject(body.bins, { name: 'bins' });
60
- return {
61
- baseAddr: cafe_utility_1.Types.asString(body.baseAddr, { name: 'baseAddr' }),
62
- population: cafe_utility_1.Types.asNumber(body.population, { name: 'population' }),
63
- connected: cafe_utility_1.Types.asNumber(body.connected, { name: 'connected' }),
64
- timestamp: cafe_utility_1.Types.asString(body.timestamp, { name: 'timestamp' }),
65
- nnLowWatermark: cafe_utility_1.Types.asNumber(body.nnLowWatermark, { name: 'nnLowWatermark' }),
66
- depth: cafe_utility_1.Types.asNumber(body.depth, { name: 'depth' }),
67
- reachability: cafe_utility_1.Types.asString(body.reachability, { name: 'reachability' }),
68
- networkAvailability: cafe_utility_1.Types.asString(body.networkAvailability, { name: 'networkAvailability' }),
69
- bins: {
70
- bin_0: asBin(bins.bin_0, 'bin_0'),
71
- bin_1: asBin(bins.bin_1, 'bin_1'),
72
- bin_2: asBin(bins.bin_2, 'bin_2'),
73
- bin_3: asBin(bins.bin_3, 'bin_3'),
74
- bin_4: asBin(bins.bin_4, 'bin_4'),
75
- bin_5: asBin(bins.bin_5, 'bin_5'),
76
- bin_6: asBin(bins.bin_6, 'bin_6'),
77
- bin_7: asBin(bins.bin_7, 'bin_7'),
78
- bin_8: asBin(bins.bin_8, 'bin_8'),
79
- bin_9: asBin(bins.bin_9, 'bin_9'),
80
- bin_10: asBin(bins.bin_10, 'bin_10'),
81
- bin_11: asBin(bins.bin_11, 'bin_11'),
82
- bin_12: asBin(bins.bin_12, 'bin_12'),
83
- bin_13: asBin(bins.bin_13, 'bin_13'),
84
- bin_14: asBin(bins.bin_14, 'bin_14'),
85
- bin_15: asBin(bins.bin_15, 'bin_15'),
86
- bin_16: asBin(bins.bin_16, 'bin_16'),
87
- bin_17: asBin(bins.bin_17, 'bin_17'),
88
- bin_18: asBin(bins.bin_18, 'bin_18'),
89
- bin_19: asBin(bins.bin_19, 'bin_19'),
90
- bin_20: asBin(bins.bin_20, 'bin_20'),
91
- bin_21: asBin(bins.bin_21, 'bin_21'),
92
- bin_22: asBin(bins.bin_22, 'bin_22'),
93
- bin_23: asBin(bins.bin_23, 'bin_23'),
94
- bin_24: asBin(bins.bin_24, 'bin_24'),
95
- bin_25: asBin(bins.bin_25, 'bin_25'),
96
- bin_26: asBin(bins.bin_26, 'bin_26'),
97
- bin_27: asBin(bins.bin_27, 'bin_27'),
98
- bin_28: asBin(bins.bin_28, 'bin_28'),
99
- bin_29: asBin(bins.bin_29, 'bin_29'),
100
- bin_30: asBin(bins.bin_30, 'bin_30'),
101
- bin_31: asBin(bins.bin_31, 'bin_31'),
102
- },
103
- };
45
+ return connectivity_1.GetTopologyResponse.parse(response.data);
104
46
  }
105
47
  async function pingPeer(requestOptions, peer) {
106
48
  const response = await (0, http_1.http)(requestOptions, {
@@ -110,22 +52,3 @@ async function pingPeer(requestOptions, peer) {
110
52
  });
111
53
  return response.data;
112
54
  }
113
- function asBin(value, name) {
114
- const bin = cafe_utility_1.Types.asObject(value, { name });
115
- if (!bin.disconnectedPeers) {
116
- bin.disconnectedPeers = [];
117
- }
118
- if (!bin.connectedPeers) {
119
- bin.connectedPeers = [];
120
- }
121
- return {
122
- population: cafe_utility_1.Types.asNumber(bin.population, { name: 'population' }),
123
- connected: cafe_utility_1.Types.asNumber(bin.connected, { name: 'connected' }),
124
- connectedPeers: cafe_utility_1.Types.asArray(bin.connectedPeers, { name: 'connectedPeers' }).map(x => ({
125
- address: cafe_utility_1.Types.asString(cafe_utility_1.Types.asObject(x, { name: 'connectedPeer' }).address, { name: 'address' }),
126
- })),
127
- disconnectedPeers: cafe_utility_1.Types.asArray(bin.disconnectedPeers, { name: 'disconnectedPeers' }).map(x => ({
128
- address: cafe_utility_1.Types.asString(cafe_utility_1.Types.asObject(x, { name: 'disconnectedPeer' }).address, { name: 'address' }),
129
- })),
130
- };
131
- }
@@ -2,10 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSettlements = getSettlements;
4
4
  exports.getAllSettlements = getAllSettlements;
5
- const cafe_utility_1 = require("cafe-utility");
5
+ const settlements_1 = require("../../types/schema/settlements");
6
6
  const http_1 = require("../../utils/http");
7
- const tokens_1 = require("../../utils/tokens");
8
- const type_1 = require("../../utils/type");
9
7
  const settlementsEndpoint = 'settlements';
10
8
  /**
11
9
  * Get amount of sent and received from settlements with a peer
@@ -18,12 +16,7 @@ async function getSettlements(requestOptions, peer) {
18
16
  url: `${settlementsEndpoint}/${peer}`,
19
17
  responseType: 'json',
20
18
  });
21
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
22
- return {
23
- peer: cafe_utility_1.Types.asString(body.peer, { name: 'peer' }),
24
- sent: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.sent, { name: 'sent' })),
25
- received: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.received, { name: 'received' })),
26
- };
19
+ return settlements_1.GetSettlementsResponse.parse(response.data);
27
20
  }
28
21
  /**
29
22
  * Get settlements with all known peers and total amount sent or received
@@ -35,17 +28,5 @@ async function getAllSettlements(requestOptions) {
35
28
  url: settlementsEndpoint,
36
29
  responseType: 'json',
37
30
  });
38
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
39
- const totalSent = tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.totalSent, { name: 'totalSent' }));
40
- const totalReceived = tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.totalReceived, { name: 'totalReceived' }));
41
- const settlements = cafe_utility_1.Types.asArray(body.settlements, { name: 'settlements' }).map(x => cafe_utility_1.Types.asObject(x, { name: 'settlement' }));
42
- return {
43
- totalSent,
44
- totalReceived,
45
- settlements: settlements.map(x => ({
46
- peer: cafe_utility_1.Types.asString(x.peer, { name: 'peer' }),
47
- sent: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(x.sent, { name: 'sent' })),
48
- received: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(x.received, { name: 'received' })),
49
- })),
50
- };
31
+ return settlements_1.GetAllSettlementsResponse.parse(response.data);
51
32
  }
@@ -6,12 +6,9 @@ exports.withdrawSurplusStake = withdrawSurplusStake;
6
6
  exports.migrateStake = migrateStake;
7
7
  exports.stake = stake;
8
8
  exports.getRedistributionState = getRedistributionState;
9
- const cafe_utility_1 = require("cafe-utility");
9
+ const stake_1 = require("../../types/schema/stake");
10
10
  const headers_1 = require("../../utils/headers");
11
11
  const http_1 = require("../../utils/http");
12
- const tokens_1 = require("../../utils/tokens");
13
- const type_1 = require("../../utils/type");
14
- const typed_bytes_1 = require("../../utils/typed-bytes");
15
12
  const STAKE_ENDPOINT = 'stake';
16
13
  const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
17
14
  /**
@@ -25,8 +22,7 @@ async function getStake(requestOptions) {
25
22
  responseType: 'json',
26
23
  url: `${STAKE_ENDPOINT}`,
27
24
  });
28
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
29
- return tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.stakedAmount, { name: 'stakedAmount' }));
25
+ return stake_1.GetStakeResponse.parse(response.data).stakedAmount;
30
26
  }
31
27
  /**
32
28
  * Gets the amount of withdrawable staked BZZ
@@ -39,8 +35,7 @@ async function getWithdrawableStake(requestOptions) {
39
35
  responseType: 'json',
40
36
  url: `${STAKE_ENDPOINT}/withdrawable`,
41
37
  });
42
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
43
- return tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.withdrawableAmount, { name: 'withdrawableAmount' }));
38
+ return stake_1.GetWithdrawableStakeResponse.parse(response.data).withdrawableAmount;
44
39
  }
45
40
  async function withdrawSurplusStake(requestOptions) {
46
41
  const response = await (0, http_1.http)(requestOptions, {
@@ -48,8 +43,7 @@ async function withdrawSurplusStake(requestOptions) {
48
43
  responseType: 'json',
49
44
  url: `${STAKE_ENDPOINT}/withdrawable`,
50
45
  });
51
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
52
- return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
46
+ return stake_1.TxHashResponse.parse(response.data).txHash;
53
47
  }
54
48
  async function migrateStake(requestOptions) {
55
49
  const response = await (0, http_1.http)(requestOptions, {
@@ -57,8 +51,7 @@ async function migrateStake(requestOptions) {
57
51
  responseType: 'json',
58
52
  url: STAKE_ENDPOINT,
59
53
  });
60
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
61
- return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
54
+ return stake_1.TxHashResponse.parse(response.data).txHash;
62
55
  }
63
56
  /**
64
57
  * Stake given amount of tokens.
@@ -67,14 +60,13 @@ async function migrateStake(requestOptions) {
67
60
  * @param amount
68
61
  */
69
62
  async function stake(requestOptions, amount, options) {
70
- const repsonse = await (0, http_1.http)(requestOptions, {
63
+ const response = await (0, http_1.http)(requestOptions, {
71
64
  method: 'post',
72
65
  responseType: 'json',
73
66
  url: `${STAKE_ENDPOINT}/${amount}`,
74
67
  headers: (0, headers_1.prepareRequestHeaders)(null, options),
75
68
  });
76
- const body = cafe_utility_1.Types.asObject(repsonse.data, { name: 'response.data' });
77
- return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asHexString(body.txHash, { name: 'txHash' }));
69
+ return stake_1.TxHashResponse.parse(response.data).txHash;
78
70
  }
79
71
  /**
80
72
  * Get current status of node in redistribution game
@@ -87,22 +79,5 @@ async function getRedistributionState(requestOptions) {
87
79
  responseType: 'json',
88
80
  url: REDISTRIBUTION_ENDPOINT,
89
81
  });
90
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
91
- return {
92
- minimumGasFunds: tokens_1.DAI.fromWei((0, type_1.asNumberString)(body.minimumGasFunds, { name: 'minimumGasFunds' })),
93
- hasSufficientFunds: cafe_utility_1.Types.asBoolean(body.hasSufficientFunds, { name: 'hasSufficientFunds' }),
94
- isFrozen: cafe_utility_1.Types.asBoolean(body.isFrozen, { name: 'isFrozen' }),
95
- isFullySynced: cafe_utility_1.Types.asBoolean(body.isFullySynced, { name: 'isFullySynced' }),
96
- phase: cafe_utility_1.Types.asString(body.phase, { name: 'phase' }),
97
- round: cafe_utility_1.Types.asNumber(body.round, { name: 'round' }),
98
- lastWonRound: cafe_utility_1.Types.asNumber(body.lastWonRound, { name: 'lastWonRound' }),
99
- lastPlayedRound: cafe_utility_1.Types.asNumber(body.lastPlayedRound, { name: 'lastPlayedRound' }),
100
- lastFrozenRound: cafe_utility_1.Types.asNumber(body.lastFrozenRound, { name: 'lastFrozenRound' }),
101
- lastSelectedRound: cafe_utility_1.Types.asNumber(body.lastSelectedRound, { name: 'lastSelectedRound' }),
102
- lastSampleDurationSeconds: cafe_utility_1.Types.asNumber(body.lastSampleDurationSeconds, { name: 'lastSampleDurationSeconds' }),
103
- block: cafe_utility_1.Types.asNumber(body.block, { name: 'block' }),
104
- reward: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.reward, { name: 'reward' })),
105
- fees: tokens_1.DAI.fromWei((0, type_1.asNumberString)(body.fees, { name: 'fees' })),
106
- isHealthy: cafe_utility_1.Types.asBoolean(body.isHealthy, { name: 'isHealthy' }),
107
- };
82
+ return stake_1.GetRedistributionStateResponse.parse(response.data);
108
83
  }
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGlobalPostageBatches = getGlobalPostageBatches;
4
+ exports.getGlobalPostageBatch = getGlobalPostageBatch;
4
5
  exports.getAllPostageBatches = getAllPostageBatches;
5
6
  exports.getPostageBatch = getPostageBatch;
6
7
  exports.getPostageBatchBuckets = getPostageBatchBuckets;
7
8
  exports.createPostageBatch = createPostageBatch;
9
+ exports.updatePostageBatchLabel = updatePostageBatchLabel;
8
10
  exports.topUpBatch = topUpBatch;
9
11
  exports.diluteBatch = diluteBatch;
10
- const cafe_utility_1 = require("cafe-utility");
12
+ const stamps_1 = require("../../types/schema/stamps");
11
13
  const http_1 = require("../../utils/http");
12
- const stamps_1 = require("../../utils/stamps");
13
- const type_1 = require("../../utils/type");
14
- const typed_bytes_1 = require("../../utils/typed-bytes");
14
+ const stamps_2 = require("../../utils/stamps");
15
15
  const STAMPS_ENDPOINT = 'stamps';
16
16
  const BATCHES_ENDPOINT = 'batches';
17
17
  async function getGlobalPostageBatches(requestOptions) {
@@ -20,18 +20,15 @@ async function getGlobalPostageBatches(requestOptions) {
20
20
  url: `${BATCHES_ENDPOINT}`,
21
21
  responseType: 'json',
22
22
  });
23
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
24
- const batches = cafe_utility_1.Types.asArray(body.batches, { name: 'batches' }).map(x => cafe_utility_1.Types.asObject(x, { name: 'batch' }));
25
- return batches.map(x => ({
26
- batchID: new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(x.batchID, { name: 'batchID' })),
27
- batchTTL: cafe_utility_1.Types.asNumber(x.batchTTL, { name: 'batchTTL' }),
28
- bucketDepth: cafe_utility_1.Types.asNumber(x.bucketDepth, { name: 'bucketDepth' }),
29
- depth: cafe_utility_1.Types.asNumber(x.depth, { name: 'depth' }),
30
- immutable: cafe_utility_1.Types.asBoolean(x.immutable, { name: 'immutable' }),
31
- owner: new typed_bytes_1.EthAddress(cafe_utility_1.Types.asString(x.owner, { name: 'owner' })),
32
- start: cafe_utility_1.Types.asNumber(x.start, { name: 'start' }),
33
- value: (0, type_1.asNumberString)(x.value, { name: 'value' }),
34
- }));
23
+ return stamps_1.GetGlobalPostageBatchesResponse.parse(response.data).batches;
24
+ }
25
+ async function getGlobalPostageBatch(requestOptions, postageBatchId) {
26
+ const response = await (0, http_1.http)(requestOptions, {
27
+ method: 'get',
28
+ url: `${BATCHES_ENDPOINT}/${postageBatchId}`,
29
+ responseType: 'json',
30
+ });
31
+ return stamps_1.GetGlobalPostageBatchResponse.parse(response.data);
35
32
  }
36
33
  async function getAllPostageBatches(requestOptions) {
37
34
  const response = await (0, http_1.http)(requestOptions, {
@@ -39,9 +36,7 @@ async function getAllPostageBatches(requestOptions) {
39
36
  url: `${STAMPS_ENDPOINT}`,
40
37
  responseType: 'json',
41
38
  });
42
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
43
- const stamps = cafe_utility_1.Types.asArray(body.stamps, { name: 'stamps' }).map(x => cafe_utility_1.Types.asObject(x, { name: 'stamp' }));
44
- return stamps.map(x => (0, stamps_1.mapPostageBatch)(validateRawPostageBatch(x)));
39
+ return stamps_1.GetAllPostageBatchesResponse.parse(response.data).stamps.map(x => (0, stamps_2.mapPostageBatch)(x));
45
40
  }
46
41
  async function getPostageBatch(requestOptions, postageBatchId, encryption, erasureCodeLevel) {
47
42
  const response = await (0, http_1.http)(requestOptions, {
@@ -49,8 +44,7 @@ async function getPostageBatch(requestOptions, postageBatchId, encryption, erasu
49
44
  url: `${STAMPS_ENDPOINT}/${postageBatchId}`,
50
45
  responseType: 'json',
51
46
  });
52
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
53
- return (0, stamps_1.mapPostageBatch)(validateRawPostageBatch(body), encryption, erasureCodeLevel);
47
+ return (0, stamps_2.mapPostageBatch)(stamps_1.GetPostageBatchResponse.parse(response.data), encryption, erasureCodeLevel);
54
48
  }
55
49
  async function getPostageBatchBuckets(requestOptions, postageBatchId) {
56
50
  const response = await (0, http_1.http)(requestOptions, {
@@ -58,18 +52,7 @@ async function getPostageBatchBuckets(requestOptions, postageBatchId) {
58
52
  url: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
59
53
  responseType: 'json',
60
54
  });
61
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
62
- return {
63
- depth: cafe_utility_1.Types.asNumber(body.depth, { name: 'depth' }),
64
- bucketDepth: cafe_utility_1.Types.asNumber(body.bucketDepth, { name: 'bucketDepth' }),
65
- bucketUpperBound: cafe_utility_1.Types.asNumber(body.bucketUpperBound, { name: 'bucketUpperBound' }),
66
- buckets: cafe_utility_1.Types.asArray(body.buckets, { name: 'buckets' })
67
- .map(x => cafe_utility_1.Types.asObject(x, { name: 'bucket' }))
68
- .map(x => ({
69
- bucketID: cafe_utility_1.Types.asNumber(x.bucketID, { name: 'bucketID' }),
70
- collisions: cafe_utility_1.Types.asNumber(x.collisions, { name: 'collisions' }),
71
- })),
72
- };
55
+ return stamps_1.GetPostageBatchBucketsResponse.parse(response.data);
73
56
  }
74
57
  async function createPostageBatch(requestOptions, amount, depth, options) {
75
58
  const headers = {};
@@ -86,8 +69,15 @@ async function createPostageBatch(requestOptions, amount, depth, options) {
86
69
  params: { label: options?.label },
87
70
  headers,
88
71
  });
89
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
90
- return new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(body.batchID, { name: 'batchID' }));
72
+ return stamps_1.BatchIdResponse.parse(response.data).batchID;
73
+ }
74
+ async function updatePostageBatchLabel(requestOptions, id, label) {
75
+ await (0, http_1.http)(requestOptions, {
76
+ method: 'patch',
77
+ url: `${STAMPS_ENDPOINT}/${id}`,
78
+ responseType: 'json',
79
+ data: { label },
80
+ });
91
81
  }
92
82
  async function topUpBatch(requestOptions, id, amount) {
93
83
  const response = await (0, http_1.http)(requestOptions, {
@@ -95,8 +85,7 @@ async function topUpBatch(requestOptions, id, amount) {
95
85
  url: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
96
86
  responseType: 'json',
97
87
  });
98
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
99
- return new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(body.batchID, { name: 'batchID' }));
88
+ return stamps_1.BatchIdResponse.parse(response.data).batchID;
100
89
  }
101
90
  async function diluteBatch(requestOptions, id, depth) {
102
91
  const response = await (0, http_1.http)(requestOptions, {
@@ -104,20 +93,5 @@ async function diluteBatch(requestOptions, id, depth) {
104
93
  url: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
105
94
  responseType: 'json',
106
95
  });
107
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
108
- return new typed_bytes_1.BatchId(cafe_utility_1.Types.asString(body.batchID, { name: 'batchID' }));
109
- }
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
- };
96
+ return stamps_1.BatchIdResponse.parse(response.data).batchID;
123
97
  }
@@ -5,12 +5,8 @@ exports.getChainState = getChainState;
5
5
  exports.getWalletBalance = getWalletBalance;
6
6
  exports.withdrawBZZ = withdrawBZZ;
7
7
  exports.withdrawDAI = withdrawDAI;
8
- const cafe_utility_1 = require("cafe-utility");
8
+ const states_1 = require("../../types/schema/states");
9
9
  const http_1 = require("../../utils/http");
10
- const tokens_1 = require("../../utils/tokens");
11
- const type_1 = require("../../utils/type");
12
- const typed_bytes_1 = require("../../utils/typed-bytes");
13
- const workaround_1 = require("../../utils/workaround");
14
10
  const RESERVE_STATE_ENDPOINT = 'reservestate';
15
11
  const WALLET_ENDPOINT = 'wallet';
16
12
  const CHAIN_STATE_ENDPOINT = 'chainstate';
@@ -25,13 +21,7 @@ async function getReserveState(requestOptions) {
25
21
  url: `${RESERVE_STATE_ENDPOINT}`,
26
22
  responseType: 'json',
27
23
  });
28
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
29
- return {
30
- commitment: cafe_utility_1.Types.asNumber(body.commitment, { name: 'commitment' }),
31
- radius: cafe_utility_1.Types.asNumber(body.radius, { name: 'radius' }),
32
- storageRadius: cafe_utility_1.Types.asNumber(body.storageRadius, { name: 'storageRadius' }),
33
- reserveCapacityDoubling: cafe_utility_1.Types.asNumber(body.reserveCapacityDoubling, { name: 'reserveCapacityDoubling' }),
34
- };
24
+ return states_1.GetReserveStateResponse.parse(response.data);
35
25
  }
36
26
  /**
37
27
  * Get state of reserve
@@ -44,13 +34,7 @@ async function getChainState(requestOptions) {
44
34
  url: `${CHAIN_STATE_ENDPOINT}`,
45
35
  responseType: 'json',
46
36
  });
47
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
48
- return {
49
- block: cafe_utility_1.Types.asNumber(body.block, { name: 'block' }),
50
- chainTip: cafe_utility_1.Types.asNumber(body.chainTip, { name: 'chainTip' }),
51
- totalAmount: (0, type_1.asNumberString)(body.totalAmount, { name: 'totalAmount' }),
52
- currentPrice: (0, workaround_1.normalizeCurrentPrice)(cafe_utility_1.Types.asNumber(body.currentPrice, { name: 'currentPrice' })),
53
- };
37
+ return states_1.GetChainStateResponse.parse(response.data);
54
38
  }
55
39
  /**
56
40
  * Get wallet balances for xDai and BZZ of the node
@@ -63,14 +47,7 @@ async function getWalletBalance(requestOptions) {
63
47
  url: `${WALLET_ENDPOINT}`,
64
48
  responseType: 'json',
65
49
  });
66
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
67
- return {
68
- bzzBalance: tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(body.bzzBalance, { name: 'bzzBalance' })),
69
- nativeTokenBalance: tokens_1.DAI.fromWei((0, type_1.asNumberString)(body.nativeTokenBalance, { name: 'nativeTokenBalance' })),
70
- chainID: cafe_utility_1.Types.asNumber(body.chainID, { name: 'chainID' }),
71
- chequebookContractAddress: cafe_utility_1.Types.asString(body.chequebookContractAddress, { name: 'chequebookContractAddress' }),
72
- walletAddress: cafe_utility_1.Types.asString(body.walletAddress, { name: 'walletAddress' }),
73
- };
50
+ return states_1.GetWalletBalanceResponse.parse(response.data);
74
51
  }
75
52
  async function withdrawBZZ(requestOptions, amount, address) {
76
53
  const response = await (0, http_1.http)(requestOptions, {
@@ -79,8 +56,7 @@ async function withdrawBZZ(requestOptions, amount, address) {
79
56
  responseType: 'json',
80
57
  params: { amount: amount.toPLURString(), address: address.toHex() },
81
58
  });
82
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
83
- return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
59
+ return states_1.WithdrawResponse.parse(response.data).transactionHash;
84
60
  }
85
61
  async function withdrawDAI(requestOptions, amount, address) {
86
62
  const response = await (0, http_1.http)(requestOptions, {
@@ -89,6 +65,5 @@ async function withdrawDAI(requestOptions, amount, address) {
89
65
  responseType: 'json',
90
66
  params: { amount: amount.toWeiString(), address: address.toHex() },
91
67
  });
92
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
93
- return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
68
+ return states_1.WithdrawResponse.parse(response.data).transactionHash;
94
69
  }
@@ -11,9 +11,8 @@ exports.getNodeInfo = getNodeInfo;
11
11
  exports.isSupportedExactVersion = isSupportedExactVersion;
12
12
  exports.isSupportedApiVersion = isSupportedApiVersion;
13
13
  exports.getVersions = getVersions;
14
- const cafe_utility_1 = require("cafe-utility");
15
14
  const major_js_1 = __importDefault(require("semver/functions/major.js"));
16
- const debug_1 = require("../../types/debug");
15
+ const status_1 = require("../../types/schema/status");
17
16
  const http_1 = require("../../utils/http");
18
17
  exports.SUPPORTED_BEE_VERSION_EXACT = '2.7.0-6ddf9b45';
19
18
  exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
@@ -28,23 +27,7 @@ async function getDebugStatus(requestOptions) {
28
27
  url: STATUS_URL,
29
28
  responseType: 'json',
30
29
  });
31
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
32
- return {
33
- overlay: cafe_utility_1.Types.asString(body.overlay, { name: 'overlay' }),
34
- proximity: cafe_utility_1.Types.asNumber(body.proximity, { name: 'proximity' }),
35
- beeMode: (0, debug_1.toBeeMode)(cafe_utility_1.Types.asString(body.beeMode, { name: 'beeMode' })),
36
- reserveSize: cafe_utility_1.Types.asNumber(body.reserveSize, { name: 'reserveSize' }),
37
- reserveSizeWithinRadius: cafe_utility_1.Types.asNumber(body.reserveSizeWithinRadius, { name: 'reserveSizeWithinRadius' }),
38
- pullsyncRate: cafe_utility_1.Types.asNumber(body.pullsyncRate, { name: 'pullsyncRate' }),
39
- storageRadius: cafe_utility_1.Types.asNumber(body.storageRadius, { name: 'storageRadius' }),
40
- connectedPeers: cafe_utility_1.Types.asNumber(body.connectedPeers, { name: 'connectedPeers' }),
41
- neighborhoodSize: cafe_utility_1.Types.asNumber(body.neighborhoodSize, { name: 'neighborhoodSize' }),
42
- batchCommitment: cafe_utility_1.Types.asNumber(body.batchCommitment, { name: 'batchCommitment' }),
43
- isReachable: cafe_utility_1.Types.asBoolean(body.isReachable, { name: 'isReachable' }),
44
- lastSyncedBlock: cafe_utility_1.Types.asNumber(body.lastSyncedBlock, { name: 'lastSyncedBlock' }),
45
- committedDepth: cafe_utility_1.Types.asNumber(body.committedDepth, { name: 'committedDepth' }),
46
- isWarmingUp: cafe_utility_1.Types.asBoolean(body.isWarmingUp, { name: 'isWarmingUp' }),
47
- };
30
+ return status_1.GetDebugStatusResponse.parse(response.data);
48
31
  }
49
32
  /**
50
33
  * Get health of node
@@ -57,12 +40,7 @@ async function getHealth(requestOptions) {
57
40
  url: HEALTH_URL,
58
41
  responseType: 'json',
59
42
  });
60
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
61
- return {
62
- apiVersion: cafe_utility_1.Types.asString(body.apiVersion, { name: 'apiVersion' }),
63
- version: cafe_utility_1.Types.asString(body.version, { name: 'version' }),
64
- status: cafe_utility_1.Types.asString(body.status, { name: 'status' }),
65
- };
43
+ return status_1.GetHealthResponse.parse(response.data);
66
44
  }
67
45
  /**
68
46
  * Get readiness of node
@@ -74,12 +52,7 @@ async function getReadiness(requestOptions) {
74
52
  method: 'get',
75
53
  url: READINESS_URL,
76
54
  });
77
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
78
- return {
79
- apiVersion: cafe_utility_1.Types.asString(body.apiVersion, { name: 'apiVersion' }),
80
- version: cafe_utility_1.Types.asString(body.version, { name: 'version' }),
81
- status: cafe_utility_1.Types.asString(body.status, { name: 'status' }),
82
- };
55
+ return status_1.GetReadinessResponse.parse(response.data);
83
56
  }
84
57
  /**
85
58
  * Get information about Bee node
@@ -92,12 +65,7 @@ async function getNodeInfo(requestOptions) {
92
65
  url: NODE_INFO_URL,
93
66
  responseType: 'json',
94
67
  });
95
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
96
- return {
97
- beeMode: (0, debug_1.toBeeMode)(cafe_utility_1.Types.asString(body.beeMode, { name: 'beeMode' })),
98
- chequebookEnabled: cafe_utility_1.Types.asBoolean(body.chequebookEnabled, { name: 'chequebookEnabled' }),
99
- swapEnabled: cafe_utility_1.Types.asBoolean(body.swapEnabled, { name: 'swapEnabled' }),
100
- };
68
+ return status_1.GetNodeInfoResponse.parse(response.data);
101
69
  }
102
70
  /**
103
71
  * Connects to a node and checks if its version matches with the one that bee-js supports.
@@ -4,10 +4,8 @@ exports.getAllTransactions = getAllTransactions;
4
4
  exports.getTransaction = getTransaction;
5
5
  exports.rebroadcastTransaction = rebroadcastTransaction;
6
6
  exports.cancelTransaction = cancelTransaction;
7
- const cafe_utility_1 = require("cafe-utility");
7
+ const transactions_1 = require("../../types/schema/transactions");
8
8
  const http_1 = require("../../utils/http");
9
- const type_1 = require("../../utils/type");
10
- const typed_bytes_1 = require("../../utils/typed-bytes");
11
9
  const transactionsEndpoint = 'transactions';
12
10
  /**
13
11
  * Get list of all pending transactions
@@ -19,9 +17,7 @@ async function getAllTransactions(requestOptions) {
19
17
  url: transactionsEndpoint,
20
18
  responseType: 'json',
21
19
  });
22
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
23
- const pendingTransactions = cafe_utility_1.Types.asArray(body.pendingTransactions, { name: 'pendingTransactions' });
24
- return pendingTransactions.map(toTransaction);
20
+ return transactions_1.GetAllTransactionsResponse.parse(response.data).pendingTransactions;
25
21
  }
26
22
  /**
27
23
  * Get information for specific pending transactions
@@ -34,22 +30,7 @@ async function getTransaction(requestOptions, transactionHash) {
34
30
  url: `${transactionsEndpoint}/${transactionHash}`,
35
31
  responseType: 'json',
36
32
  });
37
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
38
- return toTransaction(body);
39
- }
40
- function toTransaction(value) {
41
- const object = cafe_utility_1.Types.asObject(value, { name: 'transaction' });
42
- return {
43
- transactionHash: new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(object.transactionHash, { name: 'transactionHash' })),
44
- to: cafe_utility_1.Types.asString(object.to, { name: 'to' }),
45
- nonce: cafe_utility_1.Types.asNumber(object.nonce, { name: 'nonce' }),
46
- gasPrice: (0, type_1.asNumberString)(object.gasPrice, { name: 'gasPrice' }),
47
- gasLimit: cafe_utility_1.Types.asNumber(object.gasLimit, { name: 'gasLimit' }),
48
- data: cafe_utility_1.Types.asString(object.data, { name: 'data' }),
49
- created: cafe_utility_1.Types.asString(object.created, { name: 'created' }),
50
- description: cafe_utility_1.Types.asString(object.description, { name: 'description' }),
51
- value: (0, type_1.asNumberString)(object.value, { name: 'value' }),
52
- };
33
+ return transactions_1.GetTransactionResponse.parse(response.data);
53
34
  }
54
35
  /**
55
36
  * Rebroadcast existing transaction
@@ -63,8 +44,7 @@ async function rebroadcastTransaction(requestOptions, transactionHash) {
63
44
  url: `${transactionsEndpoint}/${transactionHash}`,
64
45
  responseType: 'json',
65
46
  });
66
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
67
- return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
47
+ return transactions_1.TransactionHashResponse.parse(response.data).transactionHash;
68
48
  }
69
49
  /**
70
50
  * Cancel existing transaction
@@ -84,6 +64,5 @@ async function cancelTransaction(requestOptions, transactionHash, gasPrice) {
84
64
  url: `${transactionsEndpoint}/${transactionHash}`,
85
65
  responseType: 'json',
86
66
  });
87
- const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
88
- return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
67
+ return transactions_1.TransactionHashResponse.parse(response.data).transactionHash;
89
68
  }