@ethersphere/bee-js 5.2.0 → 6.0.0-pre.1
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/bee-debug.js +58 -72
- package/dist/cjs/bee.js +71 -86
- package/dist/cjs/chunk/soc.js +14 -14
- package/dist/cjs/feed/index.js +20 -21
- package/dist/cjs/feed/json.js +2 -2
- package/dist/cjs/feed/retrievable.js +7 -8
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/modules/bytes.js +15 -15
- package/dist/cjs/modules/bzz.js +24 -25
- package/dist/cjs/modules/chunk.js +10 -10
- package/dist/cjs/modules/debug/balance.js +16 -16
- package/dist/cjs/modules/debug/chequebook.js +34 -34
- package/dist/cjs/modules/debug/chunk.js +8 -8
- package/dist/cjs/modules/debug/connectivity.js +24 -24
- package/dist/cjs/modules/debug/settlements.js +8 -8
- package/dist/cjs/modules/debug/stake.js +11 -11
- package/dist/cjs/modules/debug/stamps.js +25 -25
- package/dist/cjs/modules/debug/states.js +12 -12
- package/dist/cjs/modules/debug/status.js +24 -24
- package/dist/cjs/modules/debug/tag.js +4 -4
- package/dist/cjs/modules/debug/transactions.js +16 -16
- package/dist/cjs/modules/feed.js +14 -14
- package/dist/cjs/modules/pinning.js +14 -14
- package/dist/cjs/modules/pss.js +6 -6
- package/dist/cjs/modules/soc.js +6 -6
- package/dist/cjs/modules/status.js +3 -3
- package/dist/cjs/modules/stewardship.js +7 -7
- package/dist/cjs/modules/tag.js +20 -20
- package/dist/cjs/utils/error.js +1 -35
- package/dist/cjs/utils/headers.js +3 -3
- package/dist/cjs/utils/http.js +14 -141
- package/dist/cjs/utils/type.js +1 -4
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +0 -8
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +59 -73
- package/dist/mjs/bee.js +72 -87
- package/dist/mjs/chunk/soc.js +14 -14
- package/dist/mjs/feed/index.js +20 -21
- package/dist/mjs/feed/json.js +2 -2
- package/dist/mjs/feed/retrievable.js +7 -8
- package/dist/mjs/index.js +2 -2
- package/dist/mjs/modules/bytes.js +15 -15
- package/dist/mjs/modules/bzz.js +24 -25
- package/dist/mjs/modules/chunk.js +10 -10
- package/dist/mjs/modules/debug/balance.js +16 -16
- package/dist/mjs/modules/debug/chequebook.js +34 -34
- package/dist/mjs/modules/debug/chunk.js +8 -8
- package/dist/mjs/modules/debug/connectivity.js +24 -24
- package/dist/mjs/modules/debug/settlements.js +8 -8
- package/dist/mjs/modules/debug/stake.js +11 -11
- package/dist/mjs/modules/debug/stamps.js +25 -25
- package/dist/mjs/modules/debug/states.js +12 -12
- package/dist/mjs/modules/debug/status.js +24 -25
- package/dist/mjs/modules/debug/tag.js +4 -4
- package/dist/mjs/modules/debug/transactions.js +16 -16
- package/dist/mjs/modules/feed.js +14 -14
- package/dist/mjs/modules/pinning.js +14 -14
- package/dist/mjs/modules/pss.js +6 -6
- package/dist/mjs/modules/soc.js +6 -6
- package/dist/mjs/modules/status.js +3 -3
- package/dist/mjs/modules/stewardship.js +7 -7
- package/dist/mjs/modules/tag.js +20 -20
- package/dist/mjs/utils/error.js +0 -31
- package/dist/mjs/utils/headers.js +3 -3
- package/dist/mjs/utils/http.js +10 -138
- package/dist/mjs/utils/type.js +2 -5
- package/dist/types/bee-debug.d.ts +50 -50
- package/dist/types/bee.d.ts +34 -34
- package/dist/types/chunk/soc.d.ts +5 -6
- package/dist/types/feed/index.d.ts +7 -8
- package/dist/types/feed/json.d.ts +2 -2
- package/dist/types/feed/retrievable.d.ts +2 -2
- package/dist/types/index.d.ts +2 -4
- package/dist/types/modules/bytes.d.ts +4 -5
- package/dist/types/modules/bzz.d.ts +5 -6
- package/dist/types/modules/chunk.d.ts +3 -4
- package/dist/types/modules/debug/balance.d.ts +5 -6
- package/dist/types/modules/debug/chequebook.d.ts +9 -10
- package/dist/types/modules/debug/chunk.d.ts +3 -4
- package/dist/types/modules/debug/connectivity.d.ts +7 -8
- package/dist/types/modules/debug/settlements.d.ts +3 -4
- package/dist/types/modules/debug/stake.d.ts +4 -5
- package/dist/types/modules/debug/stamps.d.ts +7 -8
- package/dist/types/modules/debug/states.d.ts +4 -5
- package/dist/types/modules/debug/status.d.ts +10 -10
- package/dist/types/modules/debug/tag.d.ts +2 -3
- package/dist/types/modules/debug/transactions.d.ts +5 -6
- package/dist/types/modules/feed.d.ts +3 -4
- package/dist/types/modules/pinning.d.ts +5 -6
- package/dist/types/modules/pss.d.ts +2 -3
- package/dist/types/modules/soc.d.ts +2 -3
- package/dist/types/modules/status.d.ts +2 -2
- package/dist/types/modules/stewardship.d.ts +3 -4
- package/dist/types/modules/tag.d.ts +6 -7
- package/dist/types/types/debug.d.ts +2 -2
- package/dist/types/types/index.d.ts +12 -51
- package/dist/types/utils/error.d.ts +0 -26
- package/dist/types/utils/headers.d.ts +1 -1
- package/dist/types/utils/http.d.ts +12 -21
- package/dist/types/utils/type.d.ts +2 -2
- package/package.json +4 -4
- package/dist/223.index.browser.min.js +0 -3
- package/dist/223.index.browser.min.js.LICENSE.txt +0 -1
- package/dist/223.index.browser.min.js.map +0 -1
- package/dist/cjs/utils/merge.js +0 -34
- package/dist/cjs/utils/sleep.js +0 -12
- package/dist/mjs/utils/merge.js +0 -32
- package/dist/mjs/utils/sleep.js +0 -8
- package/dist/types/utils/merge.d.ts +0 -8
- package/dist/types/utils/sleep.d.ts +0 -6
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { http } from "../../utils/http.js";
|
|
2
2
|
const STAMPS_ENDPOINT = 'stamps';
|
|
3
|
-
export async function getAllPostageBatches(
|
|
4
|
-
const response = await http(
|
|
3
|
+
export async function getAllPostageBatches(requestOptions) {
|
|
4
|
+
const response = await http(requestOptions, {
|
|
5
5
|
method: 'get',
|
|
6
|
-
|
|
6
|
+
url: `${STAMPS_ENDPOINT}`,
|
|
7
7
|
responseType: 'json'
|
|
8
8
|
});
|
|
9
|
-
return response.
|
|
9
|
+
return response.data.stamps;
|
|
10
10
|
}
|
|
11
|
-
export async function getPostageBatch(
|
|
12
|
-
const response = await http(
|
|
11
|
+
export async function getPostageBatch(requestOptions, postageBatchId) {
|
|
12
|
+
const response = await http(requestOptions, {
|
|
13
13
|
method: 'get',
|
|
14
|
-
|
|
14
|
+
url: `${STAMPS_ENDPOINT}/${postageBatchId}`,
|
|
15
15
|
responseType: 'json'
|
|
16
16
|
});
|
|
17
|
-
return response.
|
|
17
|
+
return response.data;
|
|
18
18
|
}
|
|
19
|
-
export async function getPostageBatchBuckets(
|
|
20
|
-
const response = await http(
|
|
19
|
+
export async function getPostageBatchBuckets(requestOptions, postageBatchId) {
|
|
20
|
+
const response = await http(requestOptions, {
|
|
21
21
|
method: 'get',
|
|
22
|
-
|
|
22
|
+
url: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
|
|
23
23
|
responseType: 'json'
|
|
24
24
|
});
|
|
25
|
-
return response.
|
|
25
|
+
return response.data;
|
|
26
26
|
}
|
|
27
|
-
export async function createPostageBatch(
|
|
27
|
+
export async function createPostageBatch(requestOptions, amount, depth, options) {
|
|
28
28
|
const headers = {};
|
|
29
29
|
if (options?.gasPrice) {
|
|
30
30
|
headers['gas-price'] = options.gasPrice.toString();
|
|
@@ -32,30 +32,30 @@ export async function createPostageBatch(kyOptions, amount, depth, options) {
|
|
|
32
32
|
if (options?.immutableFlag !== undefined) {
|
|
33
33
|
headers.immutable = String(options.immutableFlag);
|
|
34
34
|
}
|
|
35
|
-
const response = await http(
|
|
35
|
+
const response = await http(requestOptions, {
|
|
36
36
|
method: 'post',
|
|
37
|
-
|
|
37
|
+
url: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
|
|
38
38
|
responseType: 'json',
|
|
39
|
-
|
|
39
|
+
params: {
|
|
40
40
|
label: options?.label
|
|
41
41
|
},
|
|
42
42
|
headers
|
|
43
43
|
});
|
|
44
|
-
return response.
|
|
44
|
+
return response.data.batchID;
|
|
45
45
|
}
|
|
46
|
-
export async function topUpBatch(
|
|
47
|
-
const response = await http(
|
|
46
|
+
export async function topUpBatch(requestOptions, id, amount) {
|
|
47
|
+
const response = await http(requestOptions, {
|
|
48
48
|
method: 'patch',
|
|
49
|
-
|
|
49
|
+
url: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
|
|
50
50
|
responseType: 'json'
|
|
51
51
|
});
|
|
52
|
-
return response.
|
|
52
|
+
return response.data.batchID;
|
|
53
53
|
}
|
|
54
|
-
export async function diluteBatch(
|
|
55
|
-
const response = await http(
|
|
54
|
+
export async function diluteBatch(requestOptions, id, depth) {
|
|
55
|
+
const response = await http(requestOptions, {
|
|
56
56
|
method: 'patch',
|
|
57
|
-
|
|
57
|
+
url: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
|
|
58
58
|
responseType: 'json'
|
|
59
59
|
});
|
|
60
|
-
return response.
|
|
60
|
+
return response.data.batchID;
|
|
61
61
|
}
|
|
@@ -7,39 +7,39 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
|
|
|
7
7
|
*
|
|
8
8
|
* @param kyOptions Ky Options for making requests
|
|
9
9
|
*/
|
|
10
|
-
export async function getReserveState(
|
|
11
|
-
const response = await http(
|
|
10
|
+
export async function getReserveState(requestOptions) {
|
|
11
|
+
const response = await http(requestOptions, {
|
|
12
12
|
method: 'get',
|
|
13
|
-
|
|
13
|
+
url: `${RESERVE_STATE_ENDPOINT}`,
|
|
14
14
|
responseType: 'json'
|
|
15
15
|
});
|
|
16
|
-
return response.
|
|
16
|
+
return response.data;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Get state of reserve
|
|
20
20
|
*
|
|
21
21
|
* @param kyOptions Ky Options for making requests
|
|
22
22
|
*/
|
|
23
|
-
export async function getChainState(
|
|
24
|
-
const response = await http(
|
|
23
|
+
export async function getChainState(requestOptions) {
|
|
24
|
+
const response = await http(requestOptions, {
|
|
25
25
|
method: 'get',
|
|
26
|
-
|
|
26
|
+
url: `${CHAIN_STATE_ENDPOINT}`,
|
|
27
27
|
responseType: 'json'
|
|
28
28
|
});
|
|
29
|
-
return response.
|
|
29
|
+
return response.data;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Get wallet balances for xDai and BZZ of the node
|
|
33
33
|
*
|
|
34
34
|
* @param kyOptions Ky Options for making requests
|
|
35
35
|
*/
|
|
36
|
-
export async function getWalletBalance(
|
|
37
|
-
const response = await http(
|
|
36
|
+
export async function getWalletBalance(requestOptions) {
|
|
37
|
+
const response = await http(requestOptions, {
|
|
38
38
|
method: 'get',
|
|
39
|
-
|
|
39
|
+
url: `${WALLET_ENDPOINT}`,
|
|
40
40
|
responseType: 'json'
|
|
41
41
|
});
|
|
42
|
-
return mapWalletProperties(response.
|
|
42
|
+
return mapWalletProperties(response.data);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* TODO: Remove on next break
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { http } from "../../utils/http.js";
|
|
2
1
|
import getMajorSemver from 'semver/functions/major.js';
|
|
3
|
-
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
2
|
+
import { http } from "../../utils/http.js"; // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
4
3
|
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
5
4
|
export const SUPPORTED_BEE_VERSION_EXACT = '1.12.0-88c1d236';
|
|
6
5
|
export const SUPPORTED_API_VERSION = '4.0.0';
|
|
@@ -14,24 +13,24 @@ const READINESS_URL = 'readiness';
|
|
|
14
13
|
*
|
|
15
14
|
* @param kyOptions Ky Options for making requests
|
|
16
15
|
*/
|
|
17
|
-
export async function getHealth(
|
|
18
|
-
const response = await http(
|
|
16
|
+
export async function getHealth(requestOptions) {
|
|
17
|
+
const response = await http(requestOptions, {
|
|
19
18
|
method: 'get',
|
|
20
|
-
|
|
19
|
+
url: HEALTH_URL,
|
|
21
20
|
responseType: 'json'
|
|
22
21
|
});
|
|
23
|
-
return response.
|
|
22
|
+
return response.data;
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
25
|
* Get readiness of node
|
|
27
26
|
*
|
|
28
27
|
* @param kyOptions Ky Options for making requests
|
|
29
28
|
*/
|
|
30
|
-
export async function getReadiness(
|
|
29
|
+
export async function getReadiness(requestOptions) {
|
|
31
30
|
try {
|
|
32
|
-
const response = await http(
|
|
31
|
+
const response = await http(requestOptions, {
|
|
33
32
|
method: 'get',
|
|
34
|
-
|
|
33
|
+
url: READINESS_URL
|
|
35
34
|
});
|
|
36
35
|
return response.status === 200;
|
|
37
36
|
} catch {
|
|
@@ -43,13 +42,13 @@ export async function getReadiness(kyOptions) {
|
|
|
43
42
|
*
|
|
44
43
|
* @param kyOptions Ky Options for making requests
|
|
45
44
|
*/
|
|
46
|
-
export async function getNodeInfo(
|
|
47
|
-
const response = await http(
|
|
45
|
+
export async function getNodeInfo(requestOptions) {
|
|
46
|
+
const response = await http(requestOptions, {
|
|
48
47
|
method: 'get',
|
|
49
|
-
|
|
48
|
+
url: NODE_INFO_URL,
|
|
50
49
|
responseType: 'json'
|
|
51
50
|
});
|
|
52
|
-
return response.
|
|
51
|
+
return response.data;
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
54
|
* Connects to a node and checks if it is a supported Bee version by the bee-js
|
|
@@ -60,8 +59,8 @@ export async function getNodeInfo(kyOptions) {
|
|
|
60
59
|
* @deprecated Use `isSupportedExactVersion` instead
|
|
61
60
|
*/
|
|
62
61
|
// TODO: Remove on break
|
|
63
|
-
export async function isSupportedVersion(
|
|
64
|
-
return isSupportedExactVersion(
|
|
62
|
+
export async function isSupportedVersion(requestOptions) {
|
|
63
|
+
return isSupportedExactVersion(requestOptions);
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
66
|
* Connects to a node and checks if its version matches with the one that bee-js supports.
|
|
@@ -73,10 +72,10 @@ export async function isSupportedVersion(kyOptions) {
|
|
|
73
72
|
*
|
|
74
73
|
* @param ky
|
|
75
74
|
*/
|
|
76
|
-
export async function isSupportedExactVersion(
|
|
75
|
+
export async function isSupportedExactVersion(requestOptions) {
|
|
77
76
|
const {
|
|
78
77
|
version
|
|
79
|
-
} = await getHealth(
|
|
78
|
+
} = await getHealth(requestOptions);
|
|
80
79
|
return version === SUPPORTED_BEE_VERSION_EXACT;
|
|
81
80
|
}
|
|
82
81
|
/**
|
|
@@ -87,10 +86,10 @@ export async function isSupportedExactVersion(kyOptions) {
|
|
|
87
86
|
*
|
|
88
87
|
* @param ky
|
|
89
88
|
*/
|
|
90
|
-
export async function isSupportedMainApiVersion(
|
|
89
|
+
export async function isSupportedMainApiVersion(requestOptions) {
|
|
91
90
|
const {
|
|
92
91
|
apiVersion
|
|
93
|
-
} = await getHealth(
|
|
92
|
+
} = await getHealth(requestOptions);
|
|
94
93
|
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
|
|
95
94
|
}
|
|
96
95
|
/**
|
|
@@ -101,10 +100,10 @@ export async function isSupportedMainApiVersion(kyOptions) {
|
|
|
101
100
|
*
|
|
102
101
|
* @param ky
|
|
103
102
|
*/
|
|
104
|
-
export async function isSupportedDebugApiVersion(
|
|
103
|
+
export async function isSupportedDebugApiVersion(requestOptions) {
|
|
105
104
|
const {
|
|
106
105
|
debugApiVersion
|
|
107
|
-
} = await getHealth(
|
|
106
|
+
} = await getHealth(requestOptions);
|
|
108
107
|
return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
109
108
|
}
|
|
110
109
|
/**
|
|
@@ -114,11 +113,11 @@ export async function isSupportedDebugApiVersion(kyOptions) {
|
|
|
114
113
|
*
|
|
115
114
|
* @param ky
|
|
116
115
|
*/
|
|
117
|
-
export async function isSupportedApiVersion(
|
|
116
|
+
export async function isSupportedApiVersion(requestOptions) {
|
|
118
117
|
const {
|
|
119
118
|
apiVersion,
|
|
120
119
|
debugApiVersion
|
|
121
|
-
} = await getHealth(
|
|
120
|
+
} = await getHealth(requestOptions);
|
|
122
121
|
return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) && getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
|
|
123
122
|
}
|
|
124
123
|
/**
|
|
@@ -127,12 +126,12 @@ export async function isSupportedApiVersion(kyOptions) {
|
|
|
127
126
|
*
|
|
128
127
|
* @param ky
|
|
129
128
|
*/
|
|
130
|
-
export async function getVersions(
|
|
129
|
+
export async function getVersions(requestOptions) {
|
|
131
130
|
const {
|
|
132
131
|
version,
|
|
133
132
|
apiVersion,
|
|
134
133
|
debugApiVersion
|
|
135
|
-
} = await getHealth(
|
|
134
|
+
} = await getHealth(requestOptions);
|
|
136
135
|
return {
|
|
137
136
|
supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
|
|
138
137
|
supportedBeeApiVersion: SUPPORTED_API_VERSION,
|
|
@@ -6,10 +6,10 @@ const endpoint = 'tags';
|
|
|
6
6
|
* @param kyOptions Ky Options for making requests
|
|
7
7
|
* @param uid UID of tag to be retrieved
|
|
8
8
|
*/
|
|
9
|
-
export async function retrieveExtendedTag(
|
|
10
|
-
const response = await http(
|
|
11
|
-
|
|
9
|
+
export async function retrieveExtendedTag(requestOptions, uid) {
|
|
10
|
+
const response = await http(requestOptions, {
|
|
11
|
+
url: `${endpoint}/${uid}`,
|
|
12
12
|
responseType: 'json'
|
|
13
13
|
});
|
|
14
|
-
return response.
|
|
14
|
+
return response.data;
|
|
15
15
|
}
|
|
@@ -5,12 +5,12 @@ const transactionsEndpoint = 'transactions';
|
|
|
5
5
|
*
|
|
6
6
|
* @param ky Debug Ky instance
|
|
7
7
|
*/
|
|
8
|
-
export async function getAllTransactions(
|
|
9
|
-
const response = await http(
|
|
10
|
-
|
|
8
|
+
export async function getAllTransactions(requestOptions) {
|
|
9
|
+
const response = await http(requestOptions, {
|
|
10
|
+
url: transactionsEndpoint,
|
|
11
11
|
responseType: 'json'
|
|
12
12
|
});
|
|
13
|
-
return response.
|
|
13
|
+
return response.data.pendingTransactions;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Get information for specific pending transactions
|
|
@@ -18,12 +18,12 @@ export async function getAllTransactions(kyOptions) {
|
|
|
18
18
|
* @param ky Debug Ky instance
|
|
19
19
|
* @param transactionHash Hash of the transaction
|
|
20
20
|
*/
|
|
21
|
-
export async function getTransaction(
|
|
22
|
-
const response = await http(
|
|
23
|
-
|
|
21
|
+
export async function getTransaction(requestOptions, transactionHash) {
|
|
22
|
+
const response = await http(requestOptions, {
|
|
23
|
+
url: `${transactionsEndpoint}/${transactionHash}`,
|
|
24
24
|
responseType: 'json'
|
|
25
25
|
});
|
|
26
|
-
return response.
|
|
26
|
+
return response.data;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Rebroadcast existing transaction
|
|
@@ -31,13 +31,13 @@ export async function getTransaction(kyOptions, transactionHash) {
|
|
|
31
31
|
* @param ky Debug Ky instance
|
|
32
32
|
* @param transactionHash Hash of the transaction
|
|
33
33
|
*/
|
|
34
|
-
export async function rebroadcastTransaction(
|
|
35
|
-
const response = await http(
|
|
34
|
+
export async function rebroadcastTransaction(requestOptions, transactionHash) {
|
|
35
|
+
const response = await http(requestOptions, {
|
|
36
36
|
method: 'post',
|
|
37
|
-
|
|
37
|
+
url: `${transactionsEndpoint}/${transactionHash}`,
|
|
38
38
|
responseType: 'json'
|
|
39
39
|
});
|
|
40
|
-
return response.
|
|
40
|
+
return response.data.transactionHash;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Cancel existing transaction
|
|
@@ -46,14 +46,14 @@ export async function rebroadcastTransaction(kyOptions, transactionHash) {
|
|
|
46
46
|
* @param transactionHash Hash of the transaction
|
|
47
47
|
* @param gasPrice Optional gas price
|
|
48
48
|
*/
|
|
49
|
-
export async function cancelTransaction(
|
|
50
|
-
const response = await http(
|
|
49
|
+
export async function cancelTransaction(requestOptions, transactionHash, gasPrice) {
|
|
50
|
+
const response = await http(requestOptions, {
|
|
51
51
|
method: 'delete',
|
|
52
52
|
headers: {
|
|
53
53
|
'gas-price': gasPrice
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
url: `${transactionsEndpoint}/${transactionHash}`,
|
|
56
56
|
responseType: 'json'
|
|
57
57
|
});
|
|
58
|
-
return response.
|
|
58
|
+
return response.data.transactionHash;
|
|
59
59
|
}
|
package/dist/mjs/modules/feed.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { filterHeaders, http } from "../utils/http.js";
|
|
2
|
-
import { extractUploadHeaders } from "../utils/headers.js";
|
|
3
1
|
import { BeeError } from "../utils/error.js";
|
|
2
|
+
import { extractUploadHeaders } from "../utils/headers.js";
|
|
3
|
+
import { http } from "../utils/http.js";
|
|
4
4
|
const feedEndpoint = 'feeds';
|
|
5
5
|
/**
|
|
6
6
|
* Create an initial feed root manifest
|
|
@@ -11,19 +11,19 @@ const feedEndpoint = 'feeds';
|
|
|
11
11
|
* @param postageBatchId Postage BatchId to be used to create the Feed Manifest
|
|
12
12
|
* @param options Additional options, like type (default: 'sequence')
|
|
13
13
|
*/
|
|
14
|
-
export async function createFeedManifest(
|
|
15
|
-
const response = await http(
|
|
14
|
+
export async function createFeedManifest(requestOptions, owner, topic, postageBatchId, options) {
|
|
15
|
+
const response = await http(requestOptions, {
|
|
16
16
|
method: 'post',
|
|
17
17
|
responseType: 'json',
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
url: `${feedEndpoint}/${owner}/${topic}`,
|
|
19
|
+
params: options,
|
|
20
20
|
headers: extractUploadHeaders(postageBatchId)
|
|
21
21
|
});
|
|
22
|
-
return response.
|
|
22
|
+
return response.data.reference;
|
|
23
23
|
}
|
|
24
24
|
function readFeedUpdateHeaders(headers) {
|
|
25
|
-
const feedIndex = headers
|
|
26
|
-
const feedIndexNext = headers
|
|
25
|
+
const feedIndex = headers['swarm-feed-index'];
|
|
26
|
+
const feedIndexNext = headers['swarm-feed-index-next'];
|
|
27
27
|
if (!feedIndex) {
|
|
28
28
|
throw new BeeError('Response did not contain expected swarm-feed-index!');
|
|
29
29
|
}
|
|
@@ -48,14 +48,14 @@ function readFeedUpdateHeaders(headers) {
|
|
|
48
48
|
* @param topic Topic in hex
|
|
49
49
|
* @param options Additional options, like index, at, type
|
|
50
50
|
*/
|
|
51
|
-
export async function fetchLatestFeedUpdate(
|
|
52
|
-
const response = await http(
|
|
51
|
+
export async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
|
|
52
|
+
const response = await http(requestOptions, {
|
|
53
53
|
responseType: 'json',
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
url: `${feedEndpoint}/${owner}/${topic}`,
|
|
55
|
+
params: options
|
|
56
56
|
});
|
|
57
57
|
return {
|
|
58
|
-
...response.
|
|
58
|
+
...response.data,
|
|
59
59
|
...readFeedUpdateHeaders(response.headers)
|
|
60
60
|
};
|
|
61
61
|
}
|
|
@@ -6,11 +6,11 @@ const PINNING_ENDPOINT = 'pins';
|
|
|
6
6
|
* @param kyOptions Ky Options for making requests
|
|
7
7
|
* @param reference Bee data reference
|
|
8
8
|
*/
|
|
9
|
-
export async function pin(
|
|
10
|
-
await http(
|
|
9
|
+
export async function pin(requestOptions, reference) {
|
|
10
|
+
await http(requestOptions, {
|
|
11
11
|
method: 'post',
|
|
12
12
|
responseType: 'json',
|
|
13
|
-
|
|
13
|
+
url: `${PINNING_ENDPOINT}/${reference}`
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -19,11 +19,11 @@ export async function pin(kyOptions, reference) {
|
|
|
19
19
|
* @param kyOptions Ky Options for making requests
|
|
20
20
|
* @param reference Bee data reference
|
|
21
21
|
*/
|
|
22
|
-
export async function unpin(
|
|
23
|
-
await http(
|
|
22
|
+
export async function unpin(requestOptions, reference) {
|
|
23
|
+
await http(requestOptions, {
|
|
24
24
|
method: 'delete',
|
|
25
25
|
responseType: 'json',
|
|
26
|
-
|
|
26
|
+
url: `${PINNING_ENDPOINT}/${reference}`
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
@@ -33,24 +33,24 @@ export async function unpin(kyOptions, reference) {
|
|
|
33
33
|
* @param reference
|
|
34
34
|
* @throws Error if given address is not pinned
|
|
35
35
|
*/
|
|
36
|
-
export async function getPin(
|
|
37
|
-
const response = await http(
|
|
36
|
+
export async function getPin(requestOptions, reference) {
|
|
37
|
+
const response = await http(requestOptions, {
|
|
38
38
|
method: 'get',
|
|
39
39
|
responseType: 'json',
|
|
40
|
-
|
|
40
|
+
url: `${PINNING_ENDPOINT}/${reference}`
|
|
41
41
|
});
|
|
42
|
-
return response.
|
|
42
|
+
return response.data;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Get list of all pins
|
|
46
46
|
*
|
|
47
47
|
* @param ky Ky instance
|
|
48
48
|
*/
|
|
49
|
-
export async function getAllPins(
|
|
50
|
-
const response = await http(
|
|
49
|
+
export async function getAllPins(requestOptions) {
|
|
50
|
+
const response = await http(requestOptions, {
|
|
51
51
|
method: 'get',
|
|
52
52
|
responseType: 'json',
|
|
53
|
-
|
|
53
|
+
url: `${PINNING_ENDPOINT}`
|
|
54
54
|
});
|
|
55
|
-
return response.
|
|
55
|
+
return response.data.references;
|
|
56
56
|
}
|
package/dist/mjs/modules/pss.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
2
|
import { prepareData } from "../utils/data.js";
|
|
3
|
-
import { http } from "../utils/http.js";
|
|
4
3
|
import { extractUploadHeaders } from "../utils/headers.js";
|
|
4
|
+
import { http } from "../utils/http.js";
|
|
5
5
|
const endpoint = 'pss';
|
|
6
6
|
/**
|
|
7
7
|
* Send to recipient or target with Postal Service for Swarm
|
|
@@ -14,13 +14,13 @@ const endpoint = 'pss';
|
|
|
14
14
|
* @param recipient Recipient public key
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
export async function send(
|
|
18
|
-
await http(
|
|
17
|
+
export async function send(requestOptions, topic, target, data, postageBatchId, recipient) {
|
|
18
|
+
await http(requestOptions, {
|
|
19
19
|
method: 'post',
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
url: `${endpoint}/send/${topic}/${target}`,
|
|
21
|
+
data: await prepareData(data),
|
|
22
22
|
responseType: 'json',
|
|
23
|
-
|
|
23
|
+
params: {
|
|
24
24
|
recipient
|
|
25
25
|
},
|
|
26
26
|
headers: extractUploadHeaders(postageBatchId)
|
package/dist/mjs/modules/soc.js
CHANGED
|
@@ -12,19 +12,19 @@ const socEndpoint = 'soc';
|
|
|
12
12
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
13
13
|
* @param options Additional options like tag, encryption, pinning
|
|
14
14
|
*/
|
|
15
|
-
export async function upload(
|
|
16
|
-
const response = await http(
|
|
15
|
+
export async function upload(requestOptions, owner, identifier, signature, data, postageBatchId, options) {
|
|
16
|
+
const response = await http(requestOptions, {
|
|
17
17
|
method: 'post',
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
url: `${socEndpoint}/${owner}/${identifier}`,
|
|
19
|
+
data,
|
|
20
20
|
headers: {
|
|
21
21
|
'content-type': 'application/octet-stream',
|
|
22
22
|
...extractUploadHeaders(postageBatchId, options)
|
|
23
23
|
},
|
|
24
24
|
responseType: 'json',
|
|
25
|
-
|
|
25
|
+
params: {
|
|
26
26
|
sig: signature
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
return response.
|
|
29
|
+
return response.data.reference;
|
|
30
30
|
}
|
|
@@ -4,8 +4,8 @@ import { http } from "../utils/http.js";
|
|
|
4
4
|
*
|
|
5
5
|
* @param kyOptions Ky instance for given Bee class instance
|
|
6
6
|
*/
|
|
7
|
-
export async function checkConnection(
|
|
8
|
-
await http(
|
|
9
|
-
|
|
7
|
+
export async function checkConnection(requestOptions) {
|
|
8
|
+
await http(requestOptions, {
|
|
9
|
+
url: ''
|
|
10
10
|
});
|
|
11
11
|
}
|
|
@@ -7,17 +7,17 @@ const stewardshipEndpoint = 'stewardship';
|
|
|
7
7
|
* @param options
|
|
8
8
|
* @throws BeeResponseError if not locally pinned or invalid data
|
|
9
9
|
*/
|
|
10
|
-
export async function reupload(
|
|
11
|
-
await http(
|
|
10
|
+
export async function reupload(requestOptions, reference) {
|
|
11
|
+
await http(requestOptions, {
|
|
12
12
|
method: 'put',
|
|
13
|
-
|
|
13
|
+
url: `${stewardshipEndpoint}/${reference}`
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
export async function isRetrievable(
|
|
17
|
-
const response = await http(
|
|
16
|
+
export async function isRetrievable(requestOptions, reference) {
|
|
17
|
+
const response = await http(requestOptions, {
|
|
18
18
|
method: 'get',
|
|
19
19
|
responseType: 'json',
|
|
20
|
-
|
|
20
|
+
url: `${stewardshipEndpoint}/${reference}`
|
|
21
21
|
});
|
|
22
|
-
return response.
|
|
22
|
+
return response.data.isRetrievable;
|
|
23
23
|
}
|
package/dist/mjs/modules/tag.js
CHANGED
|
@@ -5,13 +5,13 @@ const endpoint = 'tags';
|
|
|
5
5
|
*
|
|
6
6
|
* @param url Bee tag URL
|
|
7
7
|
*/
|
|
8
|
-
export async function createTag(
|
|
9
|
-
const response = await http(
|
|
8
|
+
export async function createTag(requestOptions) {
|
|
9
|
+
const response = await http(requestOptions, {
|
|
10
10
|
method: 'post',
|
|
11
|
-
|
|
11
|
+
url: endpoint,
|
|
12
12
|
responseType: 'json'
|
|
13
13
|
});
|
|
14
|
-
return response.
|
|
14
|
+
return response.data;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Retrieve tag information from Bee node
|
|
@@ -19,12 +19,12 @@ export async function createTag(kyOptions) {
|
|
|
19
19
|
* @param url Bee tag URL
|
|
20
20
|
* @param uid UID of tag to be retrieved
|
|
21
21
|
*/
|
|
22
|
-
export async function retrieveTag(
|
|
23
|
-
const response = await http(
|
|
24
|
-
|
|
22
|
+
export async function retrieveTag(requestOptions, uid) {
|
|
23
|
+
const response = await http(requestOptions, {
|
|
24
|
+
url: `${endpoint}/${uid}`,
|
|
25
25
|
responseType: 'json'
|
|
26
26
|
});
|
|
27
|
-
return response.
|
|
27
|
+
return response.data;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Get limited listing of all tags.
|
|
@@ -33,26 +33,26 @@ export async function retrieveTag(kyOptions, uid) {
|
|
|
33
33
|
* @param offset
|
|
34
34
|
* @param limit
|
|
35
35
|
*/
|
|
36
|
-
export async function getAllTags(
|
|
37
|
-
const response = await http(
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
export async function getAllTags(requestOptions, offset, limit) {
|
|
37
|
+
const response = await http(requestOptions, {
|
|
38
|
+
url: endpoint,
|
|
39
|
+
params: {
|
|
40
40
|
offset,
|
|
41
41
|
limit
|
|
42
42
|
},
|
|
43
43
|
responseType: 'json'
|
|
44
44
|
});
|
|
45
|
-
return response.
|
|
45
|
+
return response.data.tags;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Removes tag from the Bee node.
|
|
49
49
|
* @param url
|
|
50
50
|
* @param uid
|
|
51
51
|
*/
|
|
52
|
-
export async function deleteTag(
|
|
53
|
-
await http(
|
|
52
|
+
export async function deleteTag(requestOptions, uid) {
|
|
53
|
+
await http(requestOptions, {
|
|
54
54
|
method: 'delete',
|
|
55
|
-
|
|
55
|
+
url: `${endpoint}/${uid}`
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -61,11 +61,11 @@ export async function deleteTag(kyOptions, uid) {
|
|
|
61
61
|
* @param uid
|
|
62
62
|
* @param reference
|
|
63
63
|
*/
|
|
64
|
-
export async function updateTag(
|
|
65
|
-
await http(
|
|
64
|
+
export async function updateTag(requestOptions, uid, reference) {
|
|
65
|
+
await http(requestOptions, {
|
|
66
66
|
method: 'patch',
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
url: `${endpoint}/${uid}`,
|
|
68
|
+
data: {
|
|
69
69
|
reference
|
|
70
70
|
}
|
|
71
71
|
});
|