@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,97 +1,53 @@
|
|
|
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 balancesEndpoint = 'balances';
|
|
35
3
|
const consumedEndpoint = 'consumed';
|
|
36
4
|
/**
|
|
37
5
|
* Get the balances with all known peers including prepaid services
|
|
38
6
|
*
|
|
39
|
-
* @param
|
|
7
|
+
* @param kyOptions Ky Options for making requests
|
|
40
8
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
path: balancesEndpoint,
|
|
46
|
-
responseType: 'json'
|
|
47
|
-
});
|
|
48
|
-
return response.data;
|
|
9
|
+
export async function getAllBalances(kyOptions) {
|
|
10
|
+
const response = await http(kyOptions, {
|
|
11
|
+
path: balancesEndpoint,
|
|
12
|
+
responseType: 'json'
|
|
49
13
|
});
|
|
14
|
+
return response.parsedData;
|
|
50
15
|
}
|
|
51
16
|
/**
|
|
52
17
|
* Get the balances with a specific peer including prepaid services
|
|
53
18
|
*
|
|
54
|
-
* @param
|
|
19
|
+
* @param kyOptions Ky Options for making requests
|
|
55
20
|
* @param address Swarm address of peer
|
|
56
21
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
path: `${balancesEndpoint}/${address}`,
|
|
62
|
-
responseType: 'json'
|
|
63
|
-
});
|
|
64
|
-
return response.data;
|
|
22
|
+
export async function getPeerBalance(kyOptions, address) {
|
|
23
|
+
const response = await http(kyOptions, {
|
|
24
|
+
path: `${balancesEndpoint}/${address}`,
|
|
25
|
+
responseType: 'json'
|
|
65
26
|
});
|
|
27
|
+
return response.parsedData;
|
|
66
28
|
}
|
|
67
29
|
/**
|
|
68
30
|
* Get the past due consumption balances with all known peers
|
|
69
31
|
*
|
|
70
|
-
* @param
|
|
32
|
+
* @param kyOptions Ky Options for making requests
|
|
71
33
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
path: consumedEndpoint,
|
|
77
|
-
responseType: 'json'
|
|
78
|
-
});
|
|
79
|
-
return response.data;
|
|
34
|
+
export async function getPastDueConsumptionBalances(kyOptions) {
|
|
35
|
+
const response = await http(kyOptions, {
|
|
36
|
+
path: consumedEndpoint,
|
|
37
|
+
responseType: 'json'
|
|
80
38
|
});
|
|
39
|
+
return response.parsedData;
|
|
81
40
|
}
|
|
82
41
|
/**
|
|
83
42
|
* Get the past due consumption balance with a specific peer
|
|
84
43
|
*
|
|
85
|
-
* @param
|
|
44
|
+
* @param kyOptions Ky Options for making requests
|
|
86
45
|
* @param address Swarm address of peer
|
|
87
46
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
path: `${consumedEndpoint}/${address}`,
|
|
93
|
-
responseType: 'json'
|
|
94
|
-
});
|
|
95
|
-
return response.data;
|
|
47
|
+
export async function getPastDueConsumptionPeerBalance(kyOptions, address) {
|
|
48
|
+
const response = await http(kyOptions, {
|
|
49
|
+
path: `${consumedEndpoint}/${address}`,
|
|
50
|
+
responseType: 'json'
|
|
96
51
|
});
|
|
52
|
+
return response.parsedData;
|
|
97
53
|
}
|
|
@@ -1,198 +1,135 @@
|
|
|
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 chequebookEndpoint = 'chequebook';
|
|
35
3
|
/**
|
|
36
4
|
* Get the address of the chequebook contract used
|
|
37
5
|
*
|
|
38
|
-
* @param
|
|
6
|
+
* @param kyOptions Ky Options for making requests
|
|
39
7
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
path: chequebookEndpoint + '/address',
|
|
45
|
-
responseType: 'json'
|
|
46
|
-
});
|
|
47
|
-
return response.data;
|
|
8
|
+
export async function getChequebookAddress(kyOptions) {
|
|
9
|
+
const response = await http(kyOptions, {
|
|
10
|
+
path: chequebookEndpoint + '/address',
|
|
11
|
+
responseType: 'json'
|
|
48
12
|
});
|
|
13
|
+
return response.parsedData;
|
|
49
14
|
}
|
|
50
15
|
/**
|
|
51
16
|
* Get the balance of the chequebook
|
|
52
17
|
*
|
|
53
|
-
* @param
|
|
18
|
+
* @param kyOptions Ky Options for making requests
|
|
54
19
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
path: chequebookEndpoint + '/balance',
|
|
60
|
-
responseType: 'json'
|
|
61
|
-
});
|
|
62
|
-
return response.data;
|
|
20
|
+
export async function getChequebookBalance(kyOptions) {
|
|
21
|
+
const response = await http(kyOptions, {
|
|
22
|
+
path: chequebookEndpoint + '/balance',
|
|
23
|
+
responseType: 'json'
|
|
63
24
|
});
|
|
25
|
+
return response.parsedData;
|
|
64
26
|
}
|
|
65
27
|
/**
|
|
66
28
|
* Get last cashout action for the peer
|
|
67
29
|
*
|
|
68
|
-
* @param
|
|
30
|
+
* @param kyOptions Ky Options for making requests
|
|
69
31
|
* @param peer Swarm address of peer
|
|
70
32
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
path: chequebookEndpoint + `/cashout/${peer}`,
|
|
76
|
-
responseType: 'json'
|
|
77
|
-
});
|
|
78
|
-
return response.data;
|
|
33
|
+
export async function getLastCashoutAction(kyOptions, peer) {
|
|
34
|
+
const response = await http(kyOptions, {
|
|
35
|
+
path: chequebookEndpoint + `/cashout/${peer}`,
|
|
36
|
+
responseType: 'json'
|
|
79
37
|
});
|
|
38
|
+
return response.parsedData;
|
|
80
39
|
}
|
|
81
40
|
/**
|
|
82
41
|
* Cashout the last cheque for the peer
|
|
83
42
|
*
|
|
84
|
-
* @param
|
|
43
|
+
* @param kyOptions Ky Options for making requests
|
|
85
44
|
* @param peer Swarm address of peer
|
|
86
45
|
* @param options
|
|
87
46
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const response = yield http(ky, {
|
|
102
|
-
method: 'post',
|
|
103
|
-
path: chequebookEndpoint + `/cashout/${peer}`,
|
|
104
|
-
responseType: 'json',
|
|
105
|
-
headers
|
|
106
|
-
});
|
|
107
|
-
return response.data.transactionHash;
|
|
47
|
+
export async function cashoutLastCheque(kyOptions, peer, options) {
|
|
48
|
+
const headers = {};
|
|
49
|
+
if (options?.gasPrice) {
|
|
50
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
51
|
+
}
|
|
52
|
+
if (options?.gasLimit) {
|
|
53
|
+
headers['gas-limit'] = options.gasLimit.toString();
|
|
54
|
+
}
|
|
55
|
+
const response = await http(kyOptions, {
|
|
56
|
+
method: 'post',
|
|
57
|
+
path: chequebookEndpoint + `/cashout/${peer}`,
|
|
58
|
+
responseType: 'json',
|
|
59
|
+
headers
|
|
108
60
|
});
|
|
61
|
+
return response.parsedData.transactionHash;
|
|
109
62
|
}
|
|
110
63
|
/**
|
|
111
64
|
* Get last cheques for the peer
|
|
112
65
|
*
|
|
113
|
-
* @param
|
|
66
|
+
* @param kyOptions Ky Options for making requests
|
|
114
67
|
* @param peer Swarm address of peer
|
|
115
68
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
path: chequebookEndpoint + `/cheque/${peer}`,
|
|
121
|
-
responseType: 'json'
|
|
122
|
-
});
|
|
123
|
-
return response.data;
|
|
69
|
+
export async function getLastChequesForPeer(kyOptions, peer) {
|
|
70
|
+
const response = await http(kyOptions, {
|
|
71
|
+
path: chequebookEndpoint + `/cheque/${peer}`,
|
|
72
|
+
responseType: 'json'
|
|
124
73
|
});
|
|
74
|
+
return response.parsedData;
|
|
125
75
|
}
|
|
126
76
|
/**
|
|
127
77
|
* Get last cheques for all peers
|
|
128
78
|
*
|
|
129
|
-
* @param
|
|
79
|
+
* @param kyOptions Ky Options for making requests
|
|
130
80
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
path: chequebookEndpoint + '/cheque',
|
|
136
|
-
responseType: 'json'
|
|
137
|
-
});
|
|
138
|
-
return response.data;
|
|
81
|
+
export async function getLastCheques(kyOptions) {
|
|
82
|
+
const response = await http(kyOptions, {
|
|
83
|
+
path: chequebookEndpoint + '/cheque',
|
|
84
|
+
responseType: 'json'
|
|
139
85
|
});
|
|
86
|
+
return response.parsedData;
|
|
140
87
|
}
|
|
141
88
|
/**
|
|
142
89
|
* Deposit tokens from overlay address into chequebook
|
|
143
90
|
*
|
|
144
|
-
* @param
|
|
91
|
+
* @param kyOptions Ky Options for making requests
|
|
145
92
|
* @param amount Amount of tokens to deposit
|
|
146
93
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
147
94
|
* @return string Hash of the transaction
|
|
148
95
|
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
searchParams: {
|
|
163
|
-
amount: amount.toString(10)
|
|
164
|
-
},
|
|
165
|
-
headers
|
|
166
|
-
});
|
|
167
|
-
return response.data.transactionHash;
|
|
96
|
+
export async function depositTokens(kyOptions, amount, gasPrice) {
|
|
97
|
+
const headers = {};
|
|
98
|
+
if (gasPrice) {
|
|
99
|
+
headers['gas-price'] = gasPrice.toString();
|
|
100
|
+
}
|
|
101
|
+
const response = await http(kyOptions, {
|
|
102
|
+
method: 'post',
|
|
103
|
+
path: chequebookEndpoint + '/deposit',
|
|
104
|
+
responseType: 'json',
|
|
105
|
+
searchParams: {
|
|
106
|
+
amount: amount.toString(10)
|
|
107
|
+
},
|
|
108
|
+
headers
|
|
168
109
|
});
|
|
110
|
+
return response.parsedData.transactionHash;
|
|
169
111
|
}
|
|
170
112
|
/**
|
|
171
113
|
* Withdraw tokens from the chequebook to the overlay address
|
|
172
114
|
*
|
|
173
|
-
* @param
|
|
115
|
+
* @param kyOptions Ky Options for making requests
|
|
174
116
|
* @param amount Amount of tokens to withdraw
|
|
175
117
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
176
118
|
* @return string Hash of the transaction
|
|
177
119
|
*/
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
searchParams: {
|
|
192
|
-
amount: amount.toString(10)
|
|
193
|
-
},
|
|
194
|
-
headers
|
|
195
|
-
});
|
|
196
|
-
return response.data.transactionHash;
|
|
120
|
+
export async function withdrawTokens(kyOptions, amount, gasPrice) {
|
|
121
|
+
const headers = {};
|
|
122
|
+
if (gasPrice) {
|
|
123
|
+
headers['gas-price'] = gasPrice.toString();
|
|
124
|
+
}
|
|
125
|
+
const response = await http(kyOptions, {
|
|
126
|
+
method: 'post',
|
|
127
|
+
path: chequebookEndpoint + '/withdraw',
|
|
128
|
+
responseType: 'json',
|
|
129
|
+
searchParams: {
|
|
130
|
+
amount: amount.toString(10)
|
|
131
|
+
},
|
|
132
|
+
headers
|
|
197
133
|
});
|
|
134
|
+
return response.parsedData.transactionHash;
|
|
198
135
|
}
|
|
@@ -1,71 +1,33 @@
|
|
|
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 endpoint = 'chunks';
|
|
35
3
|
/**
|
|
36
4
|
* Check if chunk at address exists locally
|
|
37
5
|
*
|
|
38
|
-
* @param
|
|
6
|
+
* @param kyOptions Ky Options for making requests
|
|
39
7
|
* @param address Swarm address of chunk
|
|
40
8
|
*
|
|
41
9
|
* @returns BeeGenericResponse if chunk is found or throws an exception
|
|
42
10
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
path: endpoint + `/${address}`,
|
|
48
|
-
responseType: 'json'
|
|
49
|
-
});
|
|
50
|
-
return response.data;
|
|
11
|
+
export async function checkIfChunkExistsLocally(kyOptions, address) {
|
|
12
|
+
const response = await http(kyOptions, {
|
|
13
|
+
path: endpoint + `/${address}`,
|
|
14
|
+
responseType: 'json'
|
|
51
15
|
});
|
|
16
|
+
return response.parsedData;
|
|
52
17
|
}
|
|
53
18
|
/**
|
|
54
19
|
* Delete a chunk from local storage
|
|
55
20
|
*
|
|
56
|
-
* @param
|
|
21
|
+
* @param kyOptions Ky Options for making requests
|
|
57
22
|
* @param address Swarm address of chunk
|
|
58
23
|
*
|
|
59
24
|
* @returns BeeGenericResponse if chunk was deleted or throws an exception
|
|
60
25
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
path: endpoint + `/${address}`,
|
|
67
|
-
responseType: 'json'
|
|
68
|
-
});
|
|
69
|
-
return response.data;
|
|
26
|
+
export async function deleteChunkFromLocalStorage(kyOptions, address) {
|
|
27
|
+
const response = await http(kyOptions, {
|
|
28
|
+
method: 'delete',
|
|
29
|
+
path: endpoint + `/${address}`,
|
|
30
|
+
responseType: 'json'
|
|
70
31
|
});
|
|
32
|
+
return response.parsedData;
|
|
71
33
|
}
|
|
@@ -1,89 +1,45 @@
|
|
|
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
|
-
export function getNodeAddresses(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
responseType: 'json'
|
|
39
|
-
});
|
|
40
|
-
return response.data;
|
|
2
|
+
export async function getNodeAddresses(kyOptions) {
|
|
3
|
+
const response = await http(kyOptions, {
|
|
4
|
+
path: 'addresses',
|
|
5
|
+
responseType: 'json'
|
|
41
6
|
});
|
|
7
|
+
return response.parsedData;
|
|
42
8
|
}
|
|
43
|
-
export function getPeers(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
responseType: 'json'
|
|
48
|
-
});
|
|
49
|
-
return response.data.peers;
|
|
9
|
+
export async function getPeers(kyOptions) {
|
|
10
|
+
const response = await http(kyOptions, {
|
|
11
|
+
path: 'peers',
|
|
12
|
+
responseType: 'json'
|
|
50
13
|
});
|
|
14
|
+
return response.parsedData.peers;
|
|
51
15
|
}
|
|
52
|
-
export function getBlocklist(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
responseType: 'json'
|
|
57
|
-
});
|
|
58
|
-
return response.data.peers;
|
|
16
|
+
export async function getBlocklist(kyOptions) {
|
|
17
|
+
const response = await http(kyOptions, {
|
|
18
|
+
path: 'blocklist',
|
|
19
|
+
responseType: 'json'
|
|
59
20
|
});
|
|
21
|
+
return response.parsedData.peers;
|
|
60
22
|
}
|
|
61
|
-
export function removePeer(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
method: 'DELETE'
|
|
67
|
-
});
|
|
68
|
-
return response.data;
|
|
23
|
+
export async function removePeer(kyOptions, peer) {
|
|
24
|
+
const response = await http(kyOptions, {
|
|
25
|
+
path: `peers/${peer}`,
|
|
26
|
+
responseType: 'json',
|
|
27
|
+
method: 'DELETE'
|
|
69
28
|
});
|
|
29
|
+
return response.parsedData;
|
|
70
30
|
}
|
|
71
|
-
export function getTopology(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
responseType: 'json'
|
|
76
|
-
});
|
|
77
|
-
return response.data;
|
|
31
|
+
export async function getTopology(kyOptions) {
|
|
32
|
+
const response = await http(kyOptions, {
|
|
33
|
+
path: `topology`,
|
|
34
|
+
responseType: 'json'
|
|
78
35
|
});
|
|
36
|
+
return response.parsedData;
|
|
79
37
|
}
|
|
80
|
-
export function pingPeer(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
method: 'POST'
|
|
86
|
-
});
|
|
87
|
-
return response.data;
|
|
38
|
+
export async function pingPeer(kyOptions, peer) {
|
|
39
|
+
const response = await http(kyOptions, {
|
|
40
|
+
path: `pingpong/${peer}`,
|
|
41
|
+
responseType: 'json',
|
|
42
|
+
method: 'POST'
|
|
88
43
|
});
|
|
44
|
+
return response.parsedData;
|
|
89
45
|
}
|
|
@@ -1,65 +1,27 @@
|
|
|
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 settlementsEndpoint = 'settlements';
|
|
35
3
|
/**
|
|
36
4
|
* Get amount of sent and received from settlements with a peer
|
|
37
5
|
*
|
|
38
|
-
* @param
|
|
6
|
+
* @param kyOptions Ky Options for making requests
|
|
39
7
|
* @param peer Swarm address of peer
|
|
40
8
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
path: `${settlementsEndpoint}/${peer}`,
|
|
46
|
-
responseType: 'json'
|
|
47
|
-
});
|
|
48
|
-
return response.data;
|
|
9
|
+
export async function getSettlements(kyOptions, peer) {
|
|
10
|
+
const response = await http(kyOptions, {
|
|
11
|
+
path: `${settlementsEndpoint}/${peer}`,
|
|
12
|
+
responseType: 'json'
|
|
49
13
|
});
|
|
14
|
+
return response.parsedData;
|
|
50
15
|
}
|
|
51
16
|
/**
|
|
52
17
|
* Get settlements with all known peers and total amount sent or received
|
|
53
18
|
*
|
|
54
|
-
* @param
|
|
19
|
+
* @param kyOptions Ky Options for making requests
|
|
55
20
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
path: settlementsEndpoint,
|
|
61
|
-
responseType: 'json'
|
|
62
|
-
});
|
|
63
|
-
return response.data;
|
|
21
|
+
export async function getAllSettlements(kyOptions) {
|
|
22
|
+
const response = await http(kyOptions, {
|
|
23
|
+
path: settlementsEndpoint,
|
|
24
|
+
responseType: 'json'
|
|
64
25
|
});
|
|
26
|
+
return response.parsedData;
|
|
65
27
|
}
|