@upcoming/bee-js 0.5.1 → 0.5.3
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/manifest/manifest.js +6 -5
- 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/type.js +2 -2
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/manifest/manifest.js +6 -5
- 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/type.js +2 -2
- package/dist/types/manifest/manifest.d.ts +3 -3
- 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
|
@@ -128,8 +128,8 @@ class MantarayNode {
|
|
|
128
128
|
: this.targetAddress, forkBitmap, ...forks), this.obfuscationKey);
|
|
129
129
|
return cafe_utility_1.Binary.concatBytes(this.obfuscationKey, data);
|
|
130
130
|
}
|
|
131
|
-
static async unmarshal(bee, reference) {
|
|
132
|
-
const data = (await bee.downloadData(reference)).toUint8Array();
|
|
131
|
+
static async unmarshal(bee, reference, options, requestOptions) {
|
|
132
|
+
const data = (await bee.downloadData(reference, options, requestOptions)).toUint8Array();
|
|
133
133
|
const obfuscationKey = data.subarray(0, 32);
|
|
134
134
|
const decrypted = cafe_utility_1.Binary.xorCypher(data.subarray(32), obfuscationKey);
|
|
135
135
|
const reader = new cafe_utility_1.Uint8ArrayReader(decrypted);
|
|
@@ -219,13 +219,14 @@ class MantarayNode {
|
|
|
219
219
|
this.selfAddress = result.reference.toUint8Array();
|
|
220
220
|
return new typed_bytes_1.Reference(this.selfAddress);
|
|
221
221
|
}
|
|
222
|
-
async loadRecursively(bee) {
|
|
222
|
+
async loadRecursively(bee, options, requestOptions) {
|
|
223
223
|
for (const fork of this.forks.values()) {
|
|
224
|
-
const node = await MantarayNode.unmarshal(bee, fork.node.targetAddress);
|
|
224
|
+
const node = await MantarayNode.unmarshal(bee, fork.node.targetAddress, options, requestOptions);
|
|
225
225
|
fork.node.targetAddress = node.targetAddress;
|
|
226
226
|
fork.node.forks = node.forks;
|
|
227
227
|
fork.node.path = fork.prefix;
|
|
228
|
-
|
|
228
|
+
fork.node.parent = this;
|
|
229
|
+
await fork.node.loadRecursively(bee, options, requestOptions);
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
232
|
find(path) {
|
|
@@ -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/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) {
|