@ethersphere/bee-js 5.1.1 → 5.1.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/README.md +14 -6
- package/dist/223.index.browser.min.js +3 -0
- package/dist/223.index.browser.min.js.LICENSE.txt +1 -0
- package/dist/223.index.browser.min.js.map +1 -0
- package/dist/cjs/bee-debug.js +208 -312
- package/dist/cjs/bee.js +258 -353
- package/dist/cjs/chunk/signer.js +11 -22
- package/dist/cjs/chunk/soc.js +33 -50
- package/dist/cjs/chunk/span.js +1 -1
- package/dist/cjs/feed/index.js +50 -65
- package/dist/cjs/feed/json.js +8 -21
- package/dist/cjs/feed/retrievable.js +14 -27
- package/dist/cjs/modules/bytes.js +25 -37
- package/dist/cjs/modules/bzz.js +63 -68
- package/dist/cjs/modules/chunk.js +17 -27
- package/dist/cjs/modules/debug/balance.js +24 -41
- package/dist/cjs/modules/debug/chequebook.js +71 -96
- package/dist/cjs/modules/debug/chunk.js +13 -26
- package/dist/cjs/modules/debug/connectivity.js +32 -53
- package/dist/cjs/modules/debug/settlements.js +12 -25
- package/dist/cjs/modules/debug/stake.js +20 -33
- package/dist/cjs/modules/debug/stamps.js +45 -66
- package/dist/cjs/modules/debug/states.js +27 -40
- package/dist/cjs/modules/debug/status.js +53 -80
- package/dist/cjs/modules/debug/tag.js +6 -17
- package/dist/cjs/modules/debug/transactions.js +23 -40
- package/dist/cjs/modules/feed.js +17 -27
- package/dist/cjs/modules/pinning.js +24 -41
- package/dist/cjs/modules/pss.js +9 -20
- package/dist/cjs/modules/soc.js +12 -20
- package/dist/cjs/modules/status.js +4 -15
- package/dist/cjs/modules/stewardship.js +10 -23
- package/dist/cjs/modules/tag.js +28 -47
- package/dist/cjs/utils/collection.browser.js +4 -17
- package/dist/cjs/utils/collection.js +11 -22
- package/dist/cjs/utils/collection.node.js +42 -86
- package/dist/cjs/utils/data.browser.js +46 -59
- package/dist/cjs/utils/data.js +22 -35
- package/dist/cjs/utils/eth.js +31 -43
- package/dist/cjs/utils/file.js +9 -20
- package/dist/cjs/utils/headers.js +4 -4
- package/dist/cjs/utils/http.js +78 -93
- package/dist/cjs/utils/merge.js +1 -1
- package/dist/cjs/utils/sleep.js +2 -13
- package/dist/cjs/utils/type.js +14 -12
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +1 -3
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +209 -450
- package/dist/mjs/bee.js +256 -491
- package/dist/mjs/chunk/bmt.js +4 -10
- package/dist/mjs/chunk/cac.js +0 -3
- package/dist/mjs/chunk/signer.js +12 -63
- package/dist/mjs/chunk/soc.js +33 -85
- package/dist/mjs/chunk/span.js +3 -6
- package/dist/mjs/feed/identifier.js +0 -6
- package/dist/mjs/feed/index.js +53 -97
- package/dist/mjs/feed/json.js +10 -49
- package/dist/mjs/feed/retrievable.js +13 -64
- package/dist/mjs/feed/topic.js +0 -2
- package/dist/mjs/index.js +1 -2
- package/dist/mjs/modules/bytes.js +25 -65
- package/dist/mjs/modules/bzz.js +64 -108
- package/dist/mjs/modules/chunk.js +17 -54
- package/dist/mjs/modules/debug/balance.js +24 -68
- package/dist/mjs/modules/debug/chequebook.js +75 -138
- package/dist/mjs/modules/debug/chunk.js +13 -51
- package/dist/mjs/modules/debug/connectivity.js +32 -76
- package/dist/mjs/modules/debug/settlements.js +12 -50
- package/dist/mjs/modules/debug/stake.js +20 -61
- package/dist/mjs/modules/debug/stamps.js +47 -94
- package/dist/mjs/modules/debug/states.js +25 -66
- package/dist/mjs/modules/debug/status.js +66 -125
- package/dist/mjs/modules/debug/tag.js +6 -41
- package/dist/mjs/modules/debug/transactions.js +25 -69
- package/dist/mjs/modules/feed.js +17 -57
- package/dist/mjs/modules/pinning.js +24 -68
- package/dist/mjs/modules/pss.js +11 -47
- package/dist/mjs/modules/soc.js +14 -48
- package/dist/mjs/modules/status.js +4 -39
- package/dist/mjs/modules/stewardship.js +10 -47
- package/dist/mjs/modules/tag.js +31 -78
- package/dist/mjs/types/debug.js +0 -1
- package/dist/mjs/types/index.js +0 -4
- package/dist/mjs/utils/bytes.js +6 -14
- package/dist/mjs/utils/collection.browser.js +4 -42
- package/dist/mjs/utils/collection.js +11 -57
- package/dist/mjs/utils/collection.node.js +42 -150
- package/dist/mjs/utils/data.browser.js +49 -94
- package/dist/mjs/utils/data.js +19 -62
- package/dist/mjs/utils/error.js +0 -5
- package/dist/mjs/utils/eth.js +37 -95
- package/dist/mjs/utils/file.js +11 -50
- package/dist/mjs/utils/hash.js +0 -1
- package/dist/mjs/utils/headers.js +6 -14
- package/dist/mjs/utils/hex.js +6 -25
- package/dist/mjs/utils/http.js +80 -138
- package/dist/mjs/utils/merge.js +3 -7
- package/dist/mjs/utils/pss.js +0 -2
- package/dist/mjs/utils/reference.js +2 -5
- package/dist/mjs/utils/sleep.js +2 -37
- package/dist/mjs/utils/stream.js +0 -23
- package/dist/mjs/utils/tar.js +2 -5
- package/dist/mjs/utils/type.js +18 -82
- package/dist/mjs/utils/uint64.js +0 -1
- package/dist/mjs/utils/url.js +2 -10
- package/dist/types/bee-debug.d.ts +2 -2
- package/dist/types/bee.d.ts +2 -26
- package/dist/types/chunk/cac.d.ts +1 -1
- package/dist/types/chunk/soc.d.ts +8 -7
- package/dist/types/feed/index.d.ts +9 -8
- package/dist/types/feed/type.d.ts +1 -1
- package/dist/types/modules/bytes.d.ts +6 -5
- package/dist/types/modules/bzz.d.ts +9 -8
- package/dist/types/modules/chunk.d.ts +5 -4
- package/dist/types/modules/debug/balance.d.ts +10 -9
- package/dist/types/modules/debug/chequebook.d.ts +18 -17
- package/dist/types/modules/debug/chunk.d.ts +6 -5
- package/dist/types/modules/debug/connectivity.d.ts +8 -7
- package/dist/types/modules/debug/settlements.d.ts +6 -5
- package/dist/types/modules/debug/stake.d.ts +5 -4
- package/dist/types/modules/debug/stamps.d.ts +8 -7
- package/dist/types/modules/debug/states.d.ts +8 -7
- package/dist/types/modules/debug/status.d.ts +15 -15
- package/dist/types/modules/debug/tag.d.ts +4 -3
- package/dist/types/modules/debug/transactions.d.ts +6 -5
- package/dist/types/modules/feed.d.ts +4 -3
- package/dist/types/modules/pinning.d.ts +8 -7
- package/dist/types/modules/pss.d.ts +4 -3
- package/dist/types/modules/soc.d.ts +3 -2
- package/dist/types/modules/status.d.ts +3 -3
- package/dist/types/modules/stewardship.d.ts +4 -3
- package/dist/types/modules/tag.d.ts +7 -6
- package/dist/types/types/debug.d.ts +1 -1
- package/dist/types/types/index.d.ts +30 -34
- package/dist/types/utils/eth.d.ts +3 -3
- package/dist/types/utils/hex.d.ts +2 -2
- package/dist/types/utils/http.d.ts +6 -6
- package/package.json +34 -39
- package/dist/cjs/types/ky-options.js +0 -8
- package/dist/cjs/types/ky-universal/common.js +0 -8
- package/dist/cjs/types/ky-universal/hooks.js +0 -8
- package/dist/cjs/types/ky-universal/retry.js +0 -8
- package/dist/mjs/types/ky-options.js +0 -7
- package/dist/mjs/types/ky-universal/common.js +0 -7
- package/dist/mjs/types/ky-universal/hooks.js +0 -7
- package/dist/mjs/types/ky-universal/retry.js +0 -7
- package/dist/types/types/ky-options.d.ts +0 -221
- package/dist/types/types/ky-universal/common.d.ts +0 -13
- package/dist/types/types/ky-universal/hooks.d.ts +0 -92
- package/dist/types/types/ky-universal/retry.d.ts +0 -38
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.deleteChunkFromLocalStorage = exports.checkIfChunkExistsLocally = void 0;
|
|
13
4
|
const http_1 = require("../../utils/http");
|
|
@@ -15,37 +6,33 @@ const endpoint = 'chunks';
|
|
|
15
6
|
/**
|
|
16
7
|
* Check if chunk at address exists locally
|
|
17
8
|
*
|
|
18
|
-
* @param
|
|
9
|
+
* @param kyOptions Ky Options for making requests
|
|
19
10
|
* @param address Swarm address of chunk
|
|
20
11
|
*
|
|
21
12
|
* @returns BeeGenericResponse if chunk is found or throws an exception
|
|
22
13
|
*/
|
|
23
|
-
function checkIfChunkExistsLocally(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
responseType: 'json',
|
|
28
|
-
});
|
|
29
|
-
return response.data;
|
|
14
|
+
async function checkIfChunkExistsLocally(kyOptions, address) {
|
|
15
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
16
|
+
path: endpoint + `/${address}`,
|
|
17
|
+
responseType: 'json',
|
|
30
18
|
});
|
|
19
|
+
return response.parsedData;
|
|
31
20
|
}
|
|
32
21
|
exports.checkIfChunkExistsLocally = checkIfChunkExistsLocally;
|
|
33
22
|
/**
|
|
34
23
|
* Delete a chunk from local storage
|
|
35
24
|
*
|
|
36
|
-
* @param
|
|
25
|
+
* @param kyOptions Ky Options for making requests
|
|
37
26
|
* @param address Swarm address of chunk
|
|
38
27
|
*
|
|
39
28
|
* @returns BeeGenericResponse if chunk was deleted or throws an exception
|
|
40
29
|
*/
|
|
41
|
-
function deleteChunkFromLocalStorage(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
responseType: 'json',
|
|
47
|
-
});
|
|
48
|
-
return response.data;
|
|
30
|
+
async function deleteChunkFromLocalStorage(kyOptions, address) {
|
|
31
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
32
|
+
method: 'delete',
|
|
33
|
+
path: endpoint + `/${address}`,
|
|
34
|
+
responseType: 'json',
|
|
49
35
|
});
|
|
36
|
+
return response.parsedData;
|
|
50
37
|
}
|
|
51
38
|
exports.deleteChunkFromLocalStorage = deleteChunkFromLocalStorage;
|
|
@@ -1,75 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.pingPeer = exports.getTopology = exports.removePeer = exports.getBlocklist = exports.getPeers = exports.getNodeAddresses = void 0;
|
|
13
4
|
const http_1 = require("../../utils/http");
|
|
14
|
-
function getNodeAddresses(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
responseType: 'json',
|
|
19
|
-
});
|
|
20
|
-
return response.data;
|
|
5
|
+
async function getNodeAddresses(kyOptions) {
|
|
6
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
7
|
+
path: 'addresses',
|
|
8
|
+
responseType: 'json',
|
|
21
9
|
});
|
|
10
|
+
return response.parsedData;
|
|
22
11
|
}
|
|
23
12
|
exports.getNodeAddresses = getNodeAddresses;
|
|
24
|
-
function getPeers(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
responseType: 'json',
|
|
29
|
-
});
|
|
30
|
-
return response.data.peers;
|
|
13
|
+
async function getPeers(kyOptions) {
|
|
14
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
15
|
+
path: 'peers',
|
|
16
|
+
responseType: 'json',
|
|
31
17
|
});
|
|
18
|
+
return response.parsedData.peers;
|
|
32
19
|
}
|
|
33
20
|
exports.getPeers = getPeers;
|
|
34
|
-
function getBlocklist(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
responseType: 'json',
|
|
39
|
-
});
|
|
40
|
-
return response.data.peers;
|
|
21
|
+
async function getBlocklist(kyOptions) {
|
|
22
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
23
|
+
path: 'blocklist',
|
|
24
|
+
responseType: 'json',
|
|
41
25
|
});
|
|
26
|
+
return response.parsedData.peers;
|
|
42
27
|
}
|
|
43
28
|
exports.getBlocklist = getBlocklist;
|
|
44
|
-
function removePeer(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
method: 'DELETE',
|
|
50
|
-
});
|
|
51
|
-
return response.data;
|
|
29
|
+
async function removePeer(kyOptions, peer) {
|
|
30
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
31
|
+
path: `peers/${peer}`,
|
|
32
|
+
responseType: 'json',
|
|
33
|
+
method: 'DELETE',
|
|
52
34
|
});
|
|
35
|
+
return response.parsedData;
|
|
53
36
|
}
|
|
54
37
|
exports.removePeer = removePeer;
|
|
55
|
-
function getTopology(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
responseType: 'json',
|
|
60
|
-
});
|
|
61
|
-
return response.data;
|
|
38
|
+
async function getTopology(kyOptions) {
|
|
39
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
40
|
+
path: `topology`,
|
|
41
|
+
responseType: 'json',
|
|
62
42
|
});
|
|
43
|
+
return response.parsedData;
|
|
63
44
|
}
|
|
64
45
|
exports.getTopology = getTopology;
|
|
65
|
-
function pingPeer(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
method: 'POST',
|
|
71
|
-
});
|
|
72
|
-
return response.data;
|
|
46
|
+
async function pingPeer(kyOptions, peer) {
|
|
47
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
48
|
+
path: `pingpong/${peer}`,
|
|
49
|
+
responseType: 'json',
|
|
50
|
+
method: 'POST',
|
|
73
51
|
});
|
|
52
|
+
return response.parsedData;
|
|
74
53
|
}
|
|
75
54
|
exports.pingPeer = pingPeer;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getAllSettlements = exports.getSettlements = void 0;
|
|
13
4
|
const http_1 = require("../../utils/http");
|
|
@@ -15,31 +6,27 @@ const settlementsEndpoint = 'settlements';
|
|
|
15
6
|
/**
|
|
16
7
|
* Get amount of sent and received from settlements with a peer
|
|
17
8
|
*
|
|
18
|
-
* @param
|
|
9
|
+
* @param kyOptions Ky Options for making requests
|
|
19
10
|
* @param peer Swarm address of peer
|
|
20
11
|
*/
|
|
21
|
-
function getSettlements(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
responseType: 'json',
|
|
26
|
-
});
|
|
27
|
-
return response.data;
|
|
12
|
+
async function getSettlements(kyOptions, peer) {
|
|
13
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
14
|
+
path: `${settlementsEndpoint}/${peer}`,
|
|
15
|
+
responseType: 'json',
|
|
28
16
|
});
|
|
17
|
+
return response.parsedData;
|
|
29
18
|
}
|
|
30
19
|
exports.getSettlements = getSettlements;
|
|
31
20
|
/**
|
|
32
21
|
* Get settlements with all known peers and total amount sent or received
|
|
33
22
|
*
|
|
34
|
-
* @param
|
|
23
|
+
* @param kyOptions Ky Options for making requests
|
|
35
24
|
*/
|
|
36
|
-
function getAllSettlements(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
responseType: 'json',
|
|
41
|
-
});
|
|
42
|
-
return response.data;
|
|
25
|
+
async function getAllSettlements(kyOptions) {
|
|
26
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
27
|
+
path: settlementsEndpoint,
|
|
28
|
+
responseType: 'json',
|
|
43
29
|
});
|
|
30
|
+
return response.parsedData;
|
|
44
31
|
}
|
|
45
32
|
exports.getAllSettlements = getAllSettlements;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.stake = exports.getStake = void 0;
|
|
13
4
|
const http_1 = require("../../utils/http");
|
|
@@ -15,17 +6,15 @@ const STAKE_ENDPOINT = 'stake';
|
|
|
15
6
|
/**
|
|
16
7
|
* Gets the staked amount
|
|
17
8
|
*
|
|
18
|
-
* @param
|
|
9
|
+
* @param kyOptions Ky Options for making requests
|
|
19
10
|
*/
|
|
20
|
-
function getStake(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
path: `${STAKE_ENDPOINT}`,
|
|
26
|
-
});
|
|
27
|
-
return response.data.stakedAmount.toString();
|
|
11
|
+
async function getStake(kyOptions) {
|
|
12
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
13
|
+
method: 'get',
|
|
14
|
+
responseType: 'json',
|
|
15
|
+
path: `${STAKE_ENDPOINT}`,
|
|
28
16
|
});
|
|
17
|
+
return response.parsedData.stakedAmount.toString();
|
|
29
18
|
}
|
|
30
19
|
exports.getStake = getStake;
|
|
31
20
|
/**
|
|
@@ -35,21 +24,19 @@ exports.getStake = getStake;
|
|
|
35
24
|
* @param amount
|
|
36
25
|
* @param options
|
|
37
26
|
*/
|
|
38
|
-
function stake(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
headers,
|
|
52
|
-
});
|
|
27
|
+
async function stake(kyOptions, amount, options) {
|
|
28
|
+
const headers = {};
|
|
29
|
+
if (options?.gasPrice) {
|
|
30
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
31
|
+
}
|
|
32
|
+
if (options?.gasLimit) {
|
|
33
|
+
headers['gas-limit'] = options.gasLimit.toString();
|
|
34
|
+
}
|
|
35
|
+
await (0, http_1.http)(kyOptions, {
|
|
36
|
+
method: 'post',
|
|
37
|
+
responseType: 'json',
|
|
38
|
+
path: `${STAKE_ENDPOINT}/${amount}`,
|
|
39
|
+
headers,
|
|
53
40
|
});
|
|
54
41
|
}
|
|
55
42
|
exports.stake = stake;
|
|
@@ -1,89 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.diluteBatch = exports.topUpBatch = exports.createPostageBatch = exports.getPostageBatchBuckets = exports.getPostageBatch = exports.getAllPostageBatches = void 0;
|
|
13
4
|
const http_1 = require("../../utils/http");
|
|
14
5
|
const STAMPS_ENDPOINT = 'stamps';
|
|
15
|
-
function getAllPostageBatches(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
responseType: 'json',
|
|
21
|
-
});
|
|
22
|
-
return response.data.stamps;
|
|
6
|
+
async function getAllPostageBatches(kyOptions) {
|
|
7
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
8
|
+
method: 'get',
|
|
9
|
+
path: `${STAMPS_ENDPOINT}`,
|
|
10
|
+
responseType: 'json',
|
|
23
11
|
});
|
|
12
|
+
return response.parsedData.stamps;
|
|
24
13
|
}
|
|
25
14
|
exports.getAllPostageBatches = getAllPostageBatches;
|
|
26
|
-
function getPostageBatch(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
responseType: 'json',
|
|
32
|
-
});
|
|
33
|
-
return response.data;
|
|
15
|
+
async function getPostageBatch(kyOptions, postageBatchId) {
|
|
16
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
17
|
+
method: 'get',
|
|
18
|
+
path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
|
|
19
|
+
responseType: 'json',
|
|
34
20
|
});
|
|
21
|
+
return response.parsedData;
|
|
35
22
|
}
|
|
36
23
|
exports.getPostageBatch = getPostageBatch;
|
|
37
|
-
function getPostageBatchBuckets(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
responseType: 'json',
|
|
43
|
-
});
|
|
44
|
-
return response.data;
|
|
24
|
+
async function getPostageBatchBuckets(kyOptions, postageBatchId) {
|
|
25
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
26
|
+
method: 'get',
|
|
27
|
+
path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
|
|
28
|
+
responseType: 'json',
|
|
45
29
|
});
|
|
30
|
+
return response.parsedData;
|
|
46
31
|
}
|
|
47
32
|
exports.getPostageBatchBuckets = getPostageBatchBuckets;
|
|
48
|
-
function createPostageBatch(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
headers,
|
|
63
|
-
});
|
|
64
|
-
return response.data.batchID;
|
|
33
|
+
async function createPostageBatch(kyOptions, amount, depth, options) {
|
|
34
|
+
const headers = {};
|
|
35
|
+
if (options?.gasPrice) {
|
|
36
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
37
|
+
}
|
|
38
|
+
if (options?.immutableFlag !== undefined) {
|
|
39
|
+
headers.immutable = String(options.immutableFlag);
|
|
40
|
+
}
|
|
41
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
42
|
+
method: 'post',
|
|
43
|
+
path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
|
|
44
|
+
responseType: 'json',
|
|
45
|
+
searchParams: { label: options?.label },
|
|
46
|
+
headers,
|
|
65
47
|
});
|
|
48
|
+
return response.parsedData.batchID;
|
|
66
49
|
}
|
|
67
50
|
exports.createPostageBatch = createPostageBatch;
|
|
68
|
-
function topUpBatch(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
responseType: 'json',
|
|
74
|
-
});
|
|
75
|
-
return response.data.batchID;
|
|
51
|
+
async function topUpBatch(kyOptions, id, amount) {
|
|
52
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
53
|
+
method: 'patch',
|
|
54
|
+
path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
|
|
55
|
+
responseType: 'json',
|
|
76
56
|
});
|
|
57
|
+
return response.parsedData.batchID;
|
|
77
58
|
}
|
|
78
59
|
exports.topUpBatch = topUpBatch;
|
|
79
|
-
function diluteBatch(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
responseType: 'json',
|
|
85
|
-
});
|
|
86
|
-
return response.data.batchID;
|
|
60
|
+
async function diluteBatch(kyOptions, id, depth) {
|
|
61
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
62
|
+
method: 'patch',
|
|
63
|
+
path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
|
|
64
|
+
responseType: 'json',
|
|
87
65
|
});
|
|
66
|
+
return response.parsedData.batchID;
|
|
88
67
|
}
|
|
89
68
|
exports.diluteBatch = diluteBatch;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getWalletBalance = exports.getChainState = exports.getReserveState = void 0;
|
|
13
4
|
const http_1 = require("../../utils/http");
|
|
@@ -17,49 +8,43 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
|
|
|
17
8
|
/**
|
|
18
9
|
* Get state of reserve
|
|
19
10
|
*
|
|
20
|
-
* @param
|
|
11
|
+
* @param kyOptions Ky Options for making requests
|
|
21
12
|
*/
|
|
22
|
-
function getReserveState(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
responseType: 'json',
|
|
28
|
-
});
|
|
29
|
-
return response.data;
|
|
13
|
+
async function getReserveState(kyOptions) {
|
|
14
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
15
|
+
method: 'get',
|
|
16
|
+
path: `${RESERVE_STATE_ENDPOINT}`,
|
|
17
|
+
responseType: 'json',
|
|
30
18
|
});
|
|
19
|
+
return response.parsedData;
|
|
31
20
|
}
|
|
32
21
|
exports.getReserveState = getReserveState;
|
|
33
22
|
/**
|
|
34
23
|
* Get state of reserve
|
|
35
24
|
*
|
|
36
|
-
* @param
|
|
25
|
+
* @param kyOptions Ky Options for making requests
|
|
37
26
|
*/
|
|
38
|
-
function getChainState(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
responseType: 'json',
|
|
44
|
-
});
|
|
45
|
-
return response.data;
|
|
27
|
+
async function getChainState(kyOptions) {
|
|
28
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
29
|
+
method: 'get',
|
|
30
|
+
path: `${CHAIN_STATE_ENDPOINT}`,
|
|
31
|
+
responseType: 'json',
|
|
46
32
|
});
|
|
33
|
+
return response.parsedData;
|
|
47
34
|
}
|
|
48
35
|
exports.getChainState = getChainState;
|
|
49
36
|
/**
|
|
50
37
|
* Get wallet balances for xDai and BZZ of the node
|
|
51
38
|
*
|
|
52
|
-
* @param
|
|
39
|
+
* @param kyOptions Ky Options for making requests
|
|
53
40
|
*/
|
|
54
|
-
function getWalletBalance(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
responseType: 'json',
|
|
60
|
-
});
|
|
61
|
-
return mapWalletProperties(response.data);
|
|
41
|
+
async function getWalletBalance(kyOptions) {
|
|
42
|
+
const response = await (0, http_1.http)(kyOptions, {
|
|
43
|
+
method: 'get',
|
|
44
|
+
path: `${WALLET_ENDPOINT}`,
|
|
45
|
+
responseType: 'json',
|
|
62
46
|
});
|
|
47
|
+
return mapWalletProperties(response.parsedData);
|
|
63
48
|
}
|
|
64
49
|
exports.getWalletBalance = getWalletBalance;
|
|
65
50
|
/**
|
|
@@ -67,11 +52,13 @@ exports.getWalletBalance = getWalletBalance;
|
|
|
67
52
|
* @param data
|
|
68
53
|
*/
|
|
69
54
|
function mapWalletProperties(data) {
|
|
70
|
-
return
|
|
55
|
+
return {
|
|
71
56
|
// @ts-ignore: Needed for backward compatibility mapping
|
|
72
|
-
bzz: data.bzzBalance,
|
|
57
|
+
bzz: data.bzzBalance,
|
|
73
58
|
// @ts-ignore: Needed for backward compatibility mapping
|
|
74
|
-
xDai: data.nativeTokenBalance,
|
|
59
|
+
xDai: data.nativeTokenBalance,
|
|
75
60
|
// @ts-ignore: Needed for backward compatibility mapping
|
|
76
|
-
contractAddress: data.chequebookContractAddress
|
|
61
|
+
contractAddress: data.chequebookContractAddress,
|
|
62
|
+
...data,
|
|
63
|
+
};
|
|
77
64
|
}
|