@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,52 +1,17 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
1
|
import { http } from "../../utils/http.js";
|
|
34
2
|
const STAKE_ENDPOINT = 'stake';
|
|
35
3
|
/**
|
|
36
4
|
* Gets the staked amount
|
|
37
5
|
*
|
|
38
|
-
* @param
|
|
6
|
+
* @param kyOptions Ky Options for making requests
|
|
39
7
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
responseType: 'json',
|
|
46
|
-
path: `${STAKE_ENDPOINT}`
|
|
47
|
-
});
|
|
48
|
-
return response.data.stakedAmount.toString();
|
|
8
|
+
export async function getStake(kyOptions) {
|
|
9
|
+
const response = await http(kyOptions, {
|
|
10
|
+
method: 'get',
|
|
11
|
+
responseType: 'json',
|
|
12
|
+
path: `${STAKE_ENDPOINT}`
|
|
49
13
|
});
|
|
14
|
+
return response.parsedData.stakedAmount.toString();
|
|
50
15
|
}
|
|
51
16
|
/**
|
|
52
17
|
* Stake given amount of tokens.
|
|
@@ -55,24 +20,18 @@ export function getStake(ky) {
|
|
|
55
20
|
* @param amount
|
|
56
21
|
* @param options
|
|
57
22
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
yield http(ky, {
|
|
72
|
-
method: 'post',
|
|
73
|
-
responseType: 'json',
|
|
74
|
-
path: `${STAKE_ENDPOINT}/${amount}`,
|
|
75
|
-
headers
|
|
76
|
-
});
|
|
23
|
+
export async function stake(kyOptions, amount, options) {
|
|
24
|
+
const headers = {};
|
|
25
|
+
if (options?.gasPrice) {
|
|
26
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
27
|
+
}
|
|
28
|
+
if (options?.gasLimit) {
|
|
29
|
+
headers['gas-limit'] = options.gasLimit.toString();
|
|
30
|
+
}
|
|
31
|
+
await http(kyOptions, {
|
|
32
|
+
method: 'post',
|
|
33
|
+
responseType: 'json',
|
|
34
|
+
path: `${STAKE_ENDPOINT}/${amount}`,
|
|
35
|
+
headers
|
|
77
36
|
});
|
|
78
37
|
}
|
|
@@ -1,108 +1,61 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
1
|
import { http } from "../../utils/http.js";
|
|
34
2
|
const STAMPS_ENDPOINT = 'stamps';
|
|
35
|
-
export function getAllPostageBatches(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
responseType: 'json'
|
|
41
|
-
});
|
|
42
|
-
return response.data.stamps;
|
|
3
|
+
export async function getAllPostageBatches(kyOptions) {
|
|
4
|
+
const response = await http(kyOptions, {
|
|
5
|
+
method: 'get',
|
|
6
|
+
path: `${STAMPS_ENDPOINT}`,
|
|
7
|
+
responseType: 'json'
|
|
43
8
|
});
|
|
9
|
+
return response.parsedData.stamps;
|
|
44
10
|
}
|
|
45
|
-
export function getPostageBatch(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
responseType: 'json'
|
|
51
|
-
});
|
|
52
|
-
return response.data;
|
|
11
|
+
export async function getPostageBatch(kyOptions, postageBatchId) {
|
|
12
|
+
const response = await http(kyOptions, {
|
|
13
|
+
method: 'get',
|
|
14
|
+
path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
|
|
15
|
+
responseType: 'json'
|
|
53
16
|
});
|
|
17
|
+
return response.parsedData;
|
|
54
18
|
}
|
|
55
|
-
export function getPostageBatchBuckets(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
responseType: 'json'
|
|
61
|
-
});
|
|
62
|
-
return response.data;
|
|
19
|
+
export async function getPostageBatchBuckets(kyOptions, postageBatchId) {
|
|
20
|
+
const response = await http(kyOptions, {
|
|
21
|
+
method: 'get',
|
|
22
|
+
path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
|
|
23
|
+
responseType: 'json'
|
|
63
24
|
});
|
|
25
|
+
return response.parsedData;
|
|
64
26
|
}
|
|
65
|
-
export function createPostageBatch(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
searchParams: {
|
|
82
|
-
label: options === null || options === void 0 ? void 0 : options.label
|
|
83
|
-
},
|
|
84
|
-
headers
|
|
85
|
-
});
|
|
86
|
-
return response.data.batchID;
|
|
27
|
+
export async function createPostageBatch(kyOptions, amount, depth, options) {
|
|
28
|
+
const headers = {};
|
|
29
|
+
if (options?.gasPrice) {
|
|
30
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
31
|
+
}
|
|
32
|
+
if (options?.immutableFlag !== undefined) {
|
|
33
|
+
headers.immutable = String(options.immutableFlag);
|
|
34
|
+
}
|
|
35
|
+
const response = await http(kyOptions, {
|
|
36
|
+
method: 'post',
|
|
37
|
+
path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
|
|
38
|
+
responseType: 'json',
|
|
39
|
+
searchParams: {
|
|
40
|
+
label: options?.label
|
|
41
|
+
},
|
|
42
|
+
headers
|
|
87
43
|
});
|
|
44
|
+
return response.parsedData.batchID;
|
|
88
45
|
}
|
|
89
|
-
export function topUpBatch(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
responseType: 'json'
|
|
95
|
-
});
|
|
96
|
-
return response.data.batchID;
|
|
46
|
+
export async function topUpBatch(kyOptions, id, amount) {
|
|
47
|
+
const response = await http(kyOptions, {
|
|
48
|
+
method: 'patch',
|
|
49
|
+
path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
|
|
50
|
+
responseType: 'json'
|
|
97
51
|
});
|
|
52
|
+
return response.parsedData.batchID;
|
|
98
53
|
}
|
|
99
|
-
export function diluteBatch(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
responseType: 'json'
|
|
105
|
-
});
|
|
106
|
-
return response.data.batchID;
|
|
54
|
+
export async function diluteBatch(kyOptions, id, depth) {
|
|
55
|
+
const response = await http(kyOptions, {
|
|
56
|
+
method: 'patch',
|
|
57
|
+
path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
|
|
58
|
+
responseType: 'json'
|
|
107
59
|
});
|
|
60
|
+
return response.parsedData.batchID;
|
|
108
61
|
}
|
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
1
|
import { http } from "../../utils/http.js";
|
|
34
2
|
const RESERVE_STATE_ENDPOINT = 'reservestate';
|
|
35
3
|
const WALLET_ENDPOINT = 'wallet';
|
|
@@ -37,63 +5,54 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
|
|
|
37
5
|
/**
|
|
38
6
|
* Get state of reserve
|
|
39
7
|
*
|
|
40
|
-
* @param
|
|
8
|
+
* @param kyOptions Ky Options for making requests
|
|
41
9
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
path: `${RESERVE_STATE_ENDPOINT}`,
|
|
48
|
-
responseType: 'json'
|
|
49
|
-
});
|
|
50
|
-
return response.data;
|
|
10
|
+
export async function getReserveState(kyOptions) {
|
|
11
|
+
const response = await http(kyOptions, {
|
|
12
|
+
method: 'get',
|
|
13
|
+
path: `${RESERVE_STATE_ENDPOINT}`,
|
|
14
|
+
responseType: 'json'
|
|
51
15
|
});
|
|
16
|
+
return response.parsedData;
|
|
52
17
|
}
|
|
53
18
|
/**
|
|
54
19
|
* Get state of reserve
|
|
55
20
|
*
|
|
56
|
-
* @param
|
|
21
|
+
* @param kyOptions Ky Options for making requests
|
|
57
22
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
path: `${CHAIN_STATE_ENDPOINT}`,
|
|
64
|
-
responseType: 'json'
|
|
65
|
-
});
|
|
66
|
-
return response.data;
|
|
23
|
+
export async function getChainState(kyOptions) {
|
|
24
|
+
const response = await http(kyOptions, {
|
|
25
|
+
method: 'get',
|
|
26
|
+
path: `${CHAIN_STATE_ENDPOINT}`,
|
|
27
|
+
responseType: 'json'
|
|
67
28
|
});
|
|
29
|
+
return response.parsedData;
|
|
68
30
|
}
|
|
69
31
|
/**
|
|
70
32
|
* Get wallet balances for xDai and BZZ of the node
|
|
71
33
|
*
|
|
72
|
-
* @param
|
|
34
|
+
* @param kyOptions Ky Options for making requests
|
|
73
35
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
path: `${WALLET_ENDPOINT}`,
|
|
80
|
-
responseType: 'json'
|
|
81
|
-
});
|
|
82
|
-
return mapWalletProperties(response.data);
|
|
36
|
+
export async function getWalletBalance(kyOptions) {
|
|
37
|
+
const response = await http(kyOptions, {
|
|
38
|
+
method: 'get',
|
|
39
|
+
path: `${WALLET_ENDPOINT}`,
|
|
40
|
+
responseType: 'json'
|
|
83
41
|
});
|
|
42
|
+
return mapWalletProperties(response.parsedData);
|
|
84
43
|
}
|
|
85
44
|
/**
|
|
86
45
|
* TODO: Remove on next break
|
|
87
46
|
* @param data
|
|
88
47
|
*/
|
|
89
|
-
|
|
90
48
|
function mapWalletProperties(data) {
|
|
91
|
-
return
|
|
49
|
+
return {
|
|
92
50
|
// @ts-ignore: Needed for backward compatibility mapping
|
|
93
51
|
bzz: data.bzzBalance,
|
|
94
52
|
// @ts-ignore: Needed for backward compatibility mapping
|
|
95
53
|
xDai: data.nativeTokenBalance,
|
|
96
54
|
// @ts-ignore: Needed for backward compatibility mapping
|
|
97
|
-
contractAddress: data.chequebookContractAddress
|
|
98
|
-
|
|
55
|
+
contractAddress: data.chequebookContractAddress,
|
|
56
|
+
...data
|
|
57
|
+
};
|
|
99
58
|
}
|
|
@@ -1,40 +1,8 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
1
|
import { http } from "../../utils/http.js";
|
|
34
|
-
import getMajorSemver from 'semver/functions/major.js';
|
|
2
|
+
import getMajorSemver from 'semver/functions/major.js';
|
|
3
|
+
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
35
4
|
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
36
|
-
|
|
37
|
-
export const SUPPORTED_BEE_VERSION_EXACT = '1.10.0-904cbb08';
|
|
5
|
+
export const SUPPORTED_BEE_VERSION_EXACT = '1.11.1-1992b846';
|
|
38
6
|
export const SUPPORTED_API_VERSION = '4.0.0';
|
|
39
7
|
export const SUPPORTED_DEBUG_API_VERSION = '4.0.0';
|
|
40
8
|
export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.substring(0, SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
|
|
@@ -44,68 +12,56 @@ const READINESS_URL = 'readiness';
|
|
|
44
12
|
/**
|
|
45
13
|
* Get health of node
|
|
46
14
|
*
|
|
47
|
-
* @param
|
|
15
|
+
* @param kyOptions Ky Options for making requests
|
|
48
16
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
path: HEALTH_URL,
|
|
55
|
-
responseType: 'json'
|
|
56
|
-
});
|
|
57
|
-
return response.data;
|
|
17
|
+
export async function getHealth(kyOptions) {
|
|
18
|
+
const response = await http(kyOptions, {
|
|
19
|
+
method: 'get',
|
|
20
|
+
path: HEALTH_URL,
|
|
21
|
+
responseType: 'json'
|
|
58
22
|
});
|
|
23
|
+
return response.parsedData;
|
|
59
24
|
}
|
|
60
25
|
/**
|
|
61
26
|
* Get readiness of node
|
|
62
27
|
*
|
|
63
|
-
* @param
|
|
28
|
+
* @param kyOptions Ky Options for making requests
|
|
64
29
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
30
|
+
export async function getReadiness(kyOptions) {
|
|
31
|
+
try {
|
|
32
|
+
const response = await http(kyOptions, {
|
|
33
|
+
method: 'get',
|
|
34
|
+
path: READINESS_URL
|
|
35
|
+
});
|
|
36
|
+
return response.status === 200;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
78
40
|
}
|
|
79
41
|
/**
|
|
80
42
|
* Get information about Bee node
|
|
81
43
|
*
|
|
82
|
-
* @param
|
|
44
|
+
* @param kyOptions Ky Options for making requests
|
|
83
45
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
path: NODE_INFO_URL,
|
|
90
|
-
responseType: 'json'
|
|
91
|
-
});
|
|
92
|
-
return response.data;
|
|
46
|
+
export async function getNodeInfo(kyOptions) {
|
|
47
|
+
const response = await http(kyOptions, {
|
|
48
|
+
method: 'get',
|
|
49
|
+
path: NODE_INFO_URL,
|
|
50
|
+
responseType: 'json'
|
|
93
51
|
});
|
|
52
|
+
return response.parsedData;
|
|
94
53
|
}
|
|
95
54
|
/**
|
|
96
55
|
* Connects to a node and checks if it is a supported Bee version by the bee-js
|
|
97
56
|
*
|
|
98
|
-
* @param
|
|
57
|
+
* @param kyOptions Ky Options for making requests
|
|
99
58
|
*
|
|
100
59
|
* @returns true if the Bee node version is supported
|
|
101
60
|
* @deprecated Use `isSupportedExactVersion` instead
|
|
102
61
|
*/
|
|
103
62
|
// TODO: Remove on break
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
return isSupportedExactVersion(ky);
|
|
108
|
-
});
|
|
63
|
+
export async function isSupportedVersion(kyOptions) {
|
|
64
|
+
return isSupportedExactVersion(kyOptions);
|
|
109
65
|
}
|
|
110
66
|
/**
|
|
111
67
|
* Connects to a node and checks if its version matches with the one that bee-js supports.
|
|
@@ -117,14 +73,11 @@ export function isSupportedVersion(ky) {
|
|
|
117
73
|
*
|
|
118
74
|
* @param ky
|
|
119
75
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
} = yield getHealth(ky);
|
|
126
|
-
return version === SUPPORTED_BEE_VERSION_EXACT;
|
|
127
|
-
});
|
|
76
|
+
export async function isSupportedExactVersion(kyOptions) {
|
|
77
|
+
const {
|
|
78
|
+
version
|
|
79
|
+
} = await getHealth(kyOptions);
|
|
80
|
+
return version === SUPPORTED_BEE_VERSION_EXACT;
|
|
128
81
|
}
|
|
129
82
|
/**
|
|
130
83
|
* Connects to a node and checks if its main's API version matches with the one that bee-js supports.
|
|
@@ -134,14 +87,11 @@ export function isSupportedExactVersion(ky) {
|
|
|
134
87
|
*
|
|
135
88
|
* @param ky
|
|
136
89
|
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} = yield getHealth(ky);
|
|
143
|
-
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
|
|
144
|
-
});
|
|
90
|
+
export async function isSupportedMainApiVersion(kyOptions) {
|
|
91
|
+
const {
|
|
92
|
+
apiVersion
|
|
93
|
+
} = await getHealth(kyOptions);
|
|
94
|
+
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
|
|
145
95
|
}
|
|
146
96
|
/**
|
|
147
97
|
* Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
|
|
@@ -151,14 +101,11 @@ export function isSupportedMainApiVersion(ky) {
|
|
|
151
101
|
*
|
|
152
102
|
* @param ky
|
|
153
103
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
} = yield getHealth(ky);
|
|
160
|
-
return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
161
|
-
});
|
|
104
|
+
export async function isSupportedDebugApiVersion(kyOptions) {
|
|
105
|
+
const {
|
|
106
|
+
debugApiVersion
|
|
107
|
+
} = await getHealth(kyOptions);
|
|
108
|
+
return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
162
109
|
}
|
|
163
110
|
/**
|
|
164
111
|
* Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
|
|
@@ -167,15 +114,12 @@ export function isSupportedDebugApiVersion(ky) {
|
|
|
167
114
|
*
|
|
168
115
|
* @param ky
|
|
169
116
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} = yield getHealth(ky);
|
|
177
|
-
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) && getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
178
|
-
});
|
|
117
|
+
export async function isSupportedApiVersion(kyOptions) {
|
|
118
|
+
const {
|
|
119
|
+
apiVersion,
|
|
120
|
+
debugApiVersion
|
|
121
|
+
} = await getHealth(kyOptions);
|
|
122
|
+
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) && getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
179
123
|
}
|
|
180
124
|
/**
|
|
181
125
|
* Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
|
|
@@ -183,21 +127,18 @@ export function isSupportedApiVersion(ky) {
|
|
|
183
127
|
*
|
|
184
128
|
* @param ky
|
|
185
129
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
beeDebugApiVersion: debugApiVersion
|
|
201
|
-
};
|
|
202
|
-
});
|
|
130
|
+
export async function getVersions(kyOptions) {
|
|
131
|
+
const {
|
|
132
|
+
version,
|
|
133
|
+
apiVersion,
|
|
134
|
+
debugApiVersion
|
|
135
|
+
} = await getHealth(kyOptions);
|
|
136
|
+
return {
|
|
137
|
+
supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
|
|
138
|
+
supportedBeeApiVersion: SUPPORTED_API_VERSION,
|
|
139
|
+
supportedBeeDebugApiVersion: SUPPORTED_DEBUG_API_VERSION,
|
|
140
|
+
beeVersion: version,
|
|
141
|
+
beeApiVersion: apiVersion,
|
|
142
|
+
beeDebugApiVersion: debugApiVersion
|
|
143
|
+
};
|
|
203
144
|
}
|