@upcoming/bee-js 0.5.1 → 0.5.2

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withdrawTokens = exports.depositTokens = exports.getLastCheques = exports.getLastChequesForPeer = exports.cashoutLastCheque = exports.getLastCashoutAction = exports.getChequebookBalance = exports.getChequebookAddress = void 0;
4
4
  const cafe_utility_1 = require("cafe-utility");
5
+ const headers_1 = require("../../utils/headers");
5
6
  const http_1 = require("../../utils/http");
6
7
  const tokens_1 = require("../../utils/tokens");
7
8
  const type_1 = require("../../utils/type");
@@ -69,18 +70,11 @@ exports.getLastCashoutAction = getLastCashoutAction;
69
70
  * @param options
70
71
  */
71
72
  async function cashoutLastCheque(requestOptions, peer, options) {
72
- const headers = {};
73
- if (options?.gasPrice) {
74
- headers['gas-price'] = options.gasPrice.toString();
75
- }
76
- if (options?.gasLimit) {
77
- headers['gas-limit'] = options.gasLimit.toString();
78
- }
79
73
  const response = await (0, http_1.http)(requestOptions, {
80
74
  method: 'post',
81
75
  url: chequebookEndpoint + `/cashout/${peer}`,
82
76
  responseType: 'json',
83
- headers,
77
+ headers: (0, headers_1.prepareRequestHeaders)(null, options),
84
78
  });
85
79
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
86
80
  return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRedistributionState = exports.stake = exports.getStake = void 0;
4
4
  const cafe_utility_1 = require("cafe-utility");
5
+ const headers_1 = require("../../utils/headers");
5
6
  const http_1 = require("../../utils/http");
6
7
  const tokens_1 = require("../../utils/tokens");
7
8
  const type_1 = require("../../utils/type");
@@ -30,18 +31,11 @@ exports.getStake = getStake;
30
31
  * @param options
31
32
  */
32
33
  async function stake(requestOptions, amount, options) {
33
- const headers = {};
34
- if (options?.gasPrice) {
35
- headers['gas-price'] = options.gasPrice.toString();
36
- }
37
- if (options?.gasLimit) {
38
- headers['gas-limit'] = options.gasLimit.toString();
39
- }
40
34
  await (0, http_1.http)(requestOptions, {
41
35
  method: 'post',
42
36
  responseType: 'json',
43
37
  url: `${STAKE_ENDPOINT}/${amount}`,
44
- headers,
38
+ headers: (0, headers_1.prepareRequestHeaders)(null, options),
45
39
  });
46
40
  }
47
41
  exports.stake = stake;
@@ -76,7 +76,7 @@ exports.rebroadcastTransaction = rebroadcastTransaction;
76
76
  async function cancelTransaction(requestOptions, transactionHash, gasPrice) {
77
77
  const headers = {};
78
78
  if (gasPrice) {
79
- headers['gas-price'] = gasPrice;
79
+ headers['gas-price'] = gasPrice.toString();
80
80
  }
81
81
  const response = await (0, http_1.http)(requestOptions, {
82
82
  method: 'delete',
@@ -98,6 +98,12 @@ function prepareRequestHeaders(stamp, nullableOptions) {
98
98
  if (options.actPublisher || options.actHistoryAddress || options.actTimestamp) {
99
99
  headers['swarm-act'] = 'true';
100
100
  }
101
+ if (options.gasPrice) {
102
+ headers['gas-price'] = String(options.gasPrice);
103
+ }
104
+ if (options.gasLimit) {
105
+ headers['gas-limit'] = String(options.gasLimit);
106
+ }
101
107
  return headers;
102
108
  }
103
109
  exports.prepareRequestHeaders = prepareRequestHeaders;
@@ -29,8 +29,8 @@ const stream = __importStar(require("stream"));
29
29
  const types_1 = require("../types");
30
30
  const file_1 = require("./file");
31
31
  const typed_bytes_1 = require("./typed-bytes");
32
- function isReadable(obj) {
33
- return typeof stream.Readable !== 'undefined' && obj instanceof stream.Readable;
32
+ function isReadable(value) {
33
+ return typeof stream.Readable !== 'undefined' && value instanceof stream.Readable;
34
34
  }
35
35
  exports.isReadable = isReadable;
36
36
  function asNumberString(value, options) {