@upcoming/bee-js 0.5.0 → 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.
- package/dist/cjs/modules/debug/chequebook.js +2 -8
- package/dist/cjs/modules/debug/stake.js +2 -8
- package/dist/cjs/modules/debug/transactions.js +1 -1
- package/dist/cjs/utils/headers.js +6 -0
- package/dist/cjs/utils/http.js +5 -24
- package/dist/cjs/utils/type.js +2 -2
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/modules/debug/chequebook.js +2 -8
- package/dist/mjs/modules/debug/stake.js +2 -8
- package/dist/mjs/modules/debug/transactions.js +1 -1
- package/dist/mjs/utils/headers.js +6 -0
- package/dist/mjs/utils/http.js +4 -1
- package/dist/mjs/utils/type.js +2 -2
- package/dist/types/modules/debug/chequebook.d.ts +2 -2
- package/dist/types/modules/debug/transactions.d.ts +1 -1
- package/dist/types/types/debug.d.ts +2 -2
- package/dist/types/types/index.d.ts +4 -1
- package/dist/types/utils/type.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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;
|
package/dist/cjs/utils/http.js
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.http = exports.DEFAULT_HTTP_CONFIG = void 0;
|
|
27
|
-
const axios_1 =
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
28
8
|
const cafe_utility_1 = require("cafe-utility");
|
|
29
9
|
const index_1 = require("../index");
|
|
10
|
+
const { AxiosError } = axios_1.default;
|
|
30
11
|
const MAX_FAILED_ATTEMPTS = 100000;
|
|
31
12
|
const DELAY_FAST = 200;
|
|
32
13
|
const DELAY_SLOW = 1000;
|
|
@@ -62,7 +43,7 @@ async function http(options, config) {
|
|
|
62
43
|
return response;
|
|
63
44
|
}
|
|
64
45
|
catch (e) {
|
|
65
|
-
if (e instanceof
|
|
46
|
+
if (e instanceof AxiosError) {
|
|
66
47
|
if (e.code === 'ECONNABORTED' && options.endlesslyRetry) {
|
|
67
48
|
failedAttempts++;
|
|
68
49
|
await cafe_utility_1.System.sleepMillis(failedAttempts < DELAY_THRESHOLD ? DELAY_FAST : DELAY_SLOW);
|
package/dist/cjs/utils/type.js
CHANGED
|
@@ -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(
|
|
33
|
-
return typeof stream.Readable !== 'undefined' &&
|
|
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) {
|