@ethersphere/bee-js 12.2.2 → 12.3.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.js +56 -23
- package/dist/cjs/chunk/cac.js +4 -2
- package/dist/cjs/feed/index.js +3 -1
- package/dist/cjs/modules/bytes.js +6 -4
- package/dist/cjs/modules/bzz.js +5 -4
- package/dist/cjs/modules/chunk.js +3 -2
- package/dist/cjs/modules/debug/balance.js +5 -29
- package/dist/cjs/modules/debug/chequebook.js +9 -58
- package/dist/cjs/modules/debug/connectivity.js +5 -82
- package/dist/cjs/modules/debug/settlements.js +3 -22
- package/dist/cjs/modules/debug/stake.js +8 -33
- package/dist/cjs/modules/debug/stamps.js +27 -53
- package/dist/cjs/modules/debug/states.js +6 -31
- package/dist/cjs/modules/debug/status.js +7 -39
- package/dist/cjs/modules/debug/transactions.js +5 -26
- package/dist/cjs/modules/envelope.js +6 -6
- package/dist/cjs/modules/feed.js +3 -4
- package/dist/cjs/modules/grantee.js +8 -10
- package/dist/cjs/modules/pinning.js +5 -11
- package/dist/cjs/modules/rchash.js +2 -3
- package/dist/cjs/modules/soc.js +3 -2
- package/dist/cjs/modules/status.js +3 -3
- package/dist/cjs/modules/stewardship.js +2 -3
- package/dist/cjs/modules/tag.js +4 -35
- package/dist/cjs/stamper/stamper.js +2 -1
- package/dist/cjs/types/schema/balance.js +14 -0
- package/dist/cjs/types/schema/chequebook.js +49 -0
- package/dist/cjs/types/schema/connectivity.js +46 -0
- package/dist/cjs/types/schema/envelope.js +11 -0
- package/dist/cjs/types/schema/grantee.js +10 -0
- package/dist/cjs/types/schema/pinning.js +7 -0
- package/dist/cjs/types/schema/rchash.js +7 -0
- package/dist/cjs/types/schema/settlements.js +17 -0
- package/dist/cjs/types/schema/stake.js +33 -0
- package/dist/cjs/types/schema/stamps.js +48 -0
- package/dist/cjs/types/schema/states.js +34 -0
- package/dist/cjs/types/schema/status.js +39 -0
- package/dist/cjs/types/schema/stewardship.js +7 -0
- package/dist/cjs/types/schema/tag.js +20 -0
- package/dist/cjs/types/schema/transactions.js +24 -0
- package/dist/cjs/types/schema/upload.js +8 -0
- package/dist/cjs/utils/bad-ports.js +92 -0
- package/dist/cjs/utils/bytes.js +5 -3
- package/dist/cjs/utils/error.js +1 -0
- package/dist/cjs/utils/headers.js +19 -13
- package/dist/cjs/utils/hex-schema.js +8 -0
- package/dist/cjs/utils/http.js +92 -52
- package/dist/cjs/utils/resource-locator.js +4 -3
- package/dist/cjs/utils/schema.js +88 -0
- package/dist/cjs/utils/stamps.js +2 -1
- package/dist/cjs/utils/type.js +12 -130
- package/dist/cjs/utils/url.js +24 -0
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +59 -30
- package/dist/mjs/chunk/cac.js +5 -3
- package/dist/mjs/feed/index.js +4 -2
- package/dist/mjs/modules/bytes.js +8 -8
- package/dist/mjs/modules/bzz.js +6 -9
- package/dist/mjs/modules/chunk.js +4 -7
- package/dist/mjs/modules/debug/balance.js +5 -61
- package/dist/mjs/modules/debug/chequebook.js +9 -114
- package/dist/mjs/modules/debug/connectivity.js +5 -145
- package/dist/mjs/modules/debug/settlements.js +3 -46
- package/dist/mjs/modules/debug/stake.js +8 -85
- package/dist/mjs/modules/debug/stamps.js +24 -126
- package/dist/mjs/modules/debug/states.js +6 -71
- package/dist/mjs/modules/debug/status.js +7 -93
- package/dist/mjs/modules/debug/transactions.js +5 -60
- package/dist/mjs/modules/envelope.js +6 -20
- package/dist/mjs/modules/feed.js +6 -7
- package/dist/mjs/modules/grantee.js +8 -26
- package/dist/mjs/modules/pinning.js +7 -21
- package/dist/mjs/modules/rchash.js +2 -7
- package/dist/mjs/modules/soc.js +4 -5
- package/dist/mjs/modules/status.js +4 -4
- package/dist/mjs/modules/stewardship.js +2 -7
- package/dist/mjs/modules/tag.js +4 -93
- package/dist/mjs/stamper/stamper.js +2 -1
- package/dist/mjs/types/schema/balance.js +13 -0
- package/dist/mjs/types/schema/chequebook.js +53 -0
- package/dist/mjs/types/schema/connectivity.js +41 -0
- package/dist/mjs/types/schema/envelope.js +8 -0
- package/dist/mjs/types/schema/grantee.js +7 -0
- package/dist/mjs/types/schema/pinning.js +4 -0
- package/dist/mjs/types/schema/rchash.js +4 -0
- package/dist/mjs/types/schema/settlements.js +22 -0
- package/dist/mjs/types/schema/stake.js +40 -0
- package/dist/mjs/types/schema/stamps.js +47 -0
- package/dist/mjs/types/schema/states.js +34 -0
- package/dist/mjs/types/schema/status.js +36 -0
- package/dist/mjs/types/schema/stewardship.js +4 -0
- package/dist/mjs/types/schema/tag.js +14 -0
- package/dist/mjs/types/schema/transactions.js +25 -0
- package/dist/mjs/types/schema/upload.js +5 -0
- package/dist/mjs/utils/bad-ports.js +6 -0
- package/dist/mjs/utils/bytes.js +6 -8
- package/dist/mjs/utils/error.js +5 -0
- package/dist/mjs/utils/headers.js +19 -13
- package/dist/mjs/utils/hex-schema.js +2 -0
- package/dist/mjs/utils/http.js +97 -59
- package/dist/mjs/utils/resource-locator.js +4 -3
- package/dist/mjs/utils/schema.js +81 -0
- package/dist/mjs/utils/stamps.js +2 -1
- package/dist/mjs/utils/type.js +13 -233
- package/dist/mjs/utils/url.js +23 -0
- package/dist/types/bee.d.ts +23 -0
- package/dist/types/modules/debug/connectivity.d.ts +2 -2
- package/dist/types/modules/debug/stamps.d.ts +2 -0
- package/dist/types/modules/debug/status.d.ts +2 -2
- package/dist/types/types/debug.d.ts +1 -0
- package/dist/types/types/schema/balance.d.ts +12 -0
- package/dist/types/types/schema/chequebook.d.ts +104 -0
- package/dist/types/types/schema/connectivity.d.ts +49 -0
- package/dist/types/types/schema/envelope.d.ts +7 -0
- package/dist/types/types/schema/grantee.d.ts +7 -0
- package/dist/types/types/schema/pinning.d.ts +4 -0
- package/dist/types/types/schema/rchash.d.ts +4 -0
- package/dist/types/types/schema/settlements.d.ts +16 -0
- package/dist/types/types/schema/stake.d.ts +29 -0
- package/dist/types/types/schema/stamps.d.ts +77 -0
- package/dist/types/types/schema/states.d.ts +26 -0
- package/dist/types/types/schema/status.d.ts +38 -0
- package/dist/types/types/schema/stewardship.d.ts +4 -0
- package/dist/types/types/schema/tag.d.ts +23 -0
- package/dist/types/types/schema/transactions.d.ts +29 -0
- package/dist/types/types/schema/upload.d.ts +5 -0
- package/dist/types/utils/bad-ports.d.ts +6 -0
- package/dist/types/utils/error.d.ts +5 -0
- package/dist/types/utils/hex-schema.d.ts +2 -0
- package/dist/types/utils/http.d.ts +18 -3
- package/dist/types/utils/schema.d.ts +90 -0
- package/dist/types/utils/stamps.d.ts +1 -0
- package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
- package/dist/types/utils/tar-uploader.d.ts +1 -1
- package/dist/types/utils/type.d.ts +1 -16
- package/dist/types/utils/url.d.ts +9 -0
- package/package.json +11 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetAllPinsResponse } from "../types/schema/pinning.js";
|
|
2
|
+
import { UploadResultBody } from "../types/schema/upload.js";
|
|
2
3
|
import { http } from "../utils/http.js";
|
|
3
4
|
import { Reference } from "../utils/typed-bytes.js";
|
|
4
5
|
const PINNING_ENDPOINT = 'pins';
|
|
@@ -41,14 +42,7 @@ export async function getPin(requestOptions, reference) {
|
|
|
41
42
|
responseType: 'json',
|
|
42
43
|
url: `${PINNING_ENDPOINT}/${reference}`
|
|
43
44
|
});
|
|
44
|
-
|
|
45
|
-
name: 'response.data'
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
reference: new Reference(Types.asString(body.reference, {
|
|
49
|
-
name: 'reference'
|
|
50
|
-
}))
|
|
51
|
-
};
|
|
45
|
+
return UploadResultBody.parse(response.data);
|
|
52
46
|
}
|
|
53
47
|
/**
|
|
54
48
|
* Get list of all pins
|
|
@@ -61,17 +55,9 @@ export async function getAllPins(requestOptions) {
|
|
|
61
55
|
responseType: 'json',
|
|
62
56
|
url: `${PINNING_ENDPOINT}`
|
|
63
57
|
});
|
|
64
|
-
const body = Types.asObject(response.data, {
|
|
65
|
-
name: 'response.data'
|
|
66
|
-
});
|
|
67
58
|
// TODO: https://github.com/ethersphere/bee/issues/4964
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
name: 'references'
|
|
73
|
-
}).map(x => Types.asString(x, {
|
|
74
|
-
name: 'reference'
|
|
75
|
-
}));
|
|
76
|
-
return references.map(x => new Reference(x));
|
|
59
|
+
const {
|
|
60
|
+
references
|
|
61
|
+
} = GetAllPinsResponse.parse(response.data);
|
|
62
|
+
return (references ?? []).map(x => new Reference(x));
|
|
77
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RchashResponse } from "../types/schema/rchash.js";
|
|
2
2
|
import { http } from "../utils/http.js";
|
|
3
3
|
const RCHASH_ENDPOINT = 'rchash';
|
|
4
4
|
export async function rchash(requestOptions, depth, anchor1, anchor2) {
|
|
@@ -6,10 +6,5 @@ export async function rchash(requestOptions, depth, anchor1, anchor2) {
|
|
|
6
6
|
responseType: 'json',
|
|
7
7
|
url: `${RCHASH_ENDPOINT}/${depth}/${anchor1}/${anchor2}`
|
|
8
8
|
});
|
|
9
|
-
|
|
10
|
-
name: 'response.data'
|
|
11
|
-
});
|
|
12
|
-
return Types.asNumber(body.durationSeconds, {
|
|
13
|
-
name: 'durationSeconds'
|
|
14
|
-
});
|
|
9
|
+
return RchashResponse.parse(response.data).durationSeconds;
|
|
15
10
|
}
|
package/dist/mjs/modules/soc.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Optional
|
|
1
|
+
import { Optional } from 'cafe-utility';
|
|
2
|
+
import { UploadResultBody } from "../types/schema/upload.js";
|
|
2
3
|
import { prepareRequestHeaders } from "../utils/headers.js";
|
|
3
4
|
import { http } from "../utils/http.js";
|
|
4
5
|
import { makeTagUid } from "../utils/type.js";
|
|
@@ -29,11 +30,9 @@ export async function upload(requestOptions, owner, identifier, signature, data,
|
|
|
29
30
|
sig: signature.toHex()
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
|
-
const body =
|
|
33
|
-
name: 'response.data'
|
|
34
|
-
});
|
|
33
|
+
const body = UploadResultBody.parse(response.data);
|
|
35
34
|
return {
|
|
36
|
-
reference:
|
|
35
|
+
reference: body.reference,
|
|
37
36
|
tagUid: response.headers['swarm-tag'] ? makeTagUid(response.headers['swarm-tag']) : undefined,
|
|
38
37
|
historyAddress: response.headers['swarm-act-history-address'] ? Optional.of(new Reference(response.headers['swarm-act-history-address'])) : Optional.empty()
|
|
39
38
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IsGatewayResponse } from "../types/schema/status.js";
|
|
2
2
|
import { http } from "../utils/http.js";
|
|
3
3
|
/**
|
|
4
4
|
* Ping the base bee URL. If connection was not successful throw error
|
|
@@ -7,7 +7,8 @@ import { http } from "../utils/http.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export async function checkConnection(requestOptions) {
|
|
9
9
|
await http(requestOptions, {
|
|
10
|
-
url: ''
|
|
10
|
+
url: '',
|
|
11
|
+
responseType: 'text'
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
14
|
export async function isGateway(requestOptions) {
|
|
@@ -15,8 +16,7 @@ export async function isGateway(requestOptions) {
|
|
|
15
16
|
const response = await http(requestOptions, {
|
|
16
17
|
url: '/gateway'
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
return Types.asBoolean(data.gateway);
|
|
19
|
+
return IsGatewayResponse.parse(response.data).gateway;
|
|
20
20
|
} catch (error) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IsRetrievableResponse } from "../types/schema/stewardship.js";
|
|
2
2
|
import { http } from "../utils/http.js";
|
|
3
3
|
import { Reference } from "../utils/typed-bytes.js";
|
|
4
4
|
const stewardshipEndpoint = 'stewardship';
|
|
@@ -24,10 +24,5 @@ export async function isRetrievable(requestOptions, reference) {
|
|
|
24
24
|
responseType: 'json',
|
|
25
25
|
url: `${stewardshipEndpoint}/${reference}`
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
name: 'response.data'
|
|
29
|
-
});
|
|
30
|
-
return Types.asBoolean(body.isRetrievable, {
|
|
31
|
-
name: 'isRetrievable'
|
|
32
|
-
});
|
|
27
|
+
return IsRetrievableResponse.parse(response.data).isRetrievable;
|
|
33
28
|
}
|
package/dist/mjs/modules/tag.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetAllTagsResponse, TagSchema } from "../types/schema/tag.js";
|
|
2
2
|
import { http } from "../utils/http.js";
|
|
3
3
|
const endpoint = 'tags';
|
|
4
4
|
/**
|
|
@@ -12,35 +12,7 @@ export async function createTag(requestOptions) {
|
|
|
12
12
|
url: endpoint,
|
|
13
13
|
responseType: 'json'
|
|
14
14
|
});
|
|
15
|
-
|
|
16
|
-
name: 'response.data'
|
|
17
|
-
});
|
|
18
|
-
return {
|
|
19
|
-
address: Types.asEmptiableString(body.address, {
|
|
20
|
-
name: 'address'
|
|
21
|
-
}),
|
|
22
|
-
seen: Types.asNumber(body.seen, {
|
|
23
|
-
name: 'seen'
|
|
24
|
-
}),
|
|
25
|
-
sent: Types.asNumber(body.sent, {
|
|
26
|
-
name: 'sent'
|
|
27
|
-
}),
|
|
28
|
-
split: Types.asNumber(body.split, {
|
|
29
|
-
name: 'split'
|
|
30
|
-
}),
|
|
31
|
-
startedAt: Types.asString(body.startedAt, {
|
|
32
|
-
name: 'startedAt'
|
|
33
|
-
}),
|
|
34
|
-
stored: Types.asNumber(body.stored, {
|
|
35
|
-
name: 'stored'
|
|
36
|
-
}),
|
|
37
|
-
synced: Types.asNumber(body.synced, {
|
|
38
|
-
name: 'synced'
|
|
39
|
-
}),
|
|
40
|
-
uid: Types.asNumber(body.uid, {
|
|
41
|
-
name: 'uid'
|
|
42
|
-
})
|
|
43
|
-
};
|
|
15
|
+
return TagSchema.parse(response.data);
|
|
44
16
|
}
|
|
45
17
|
/**
|
|
46
18
|
* Retrieve tag information from Bee node
|
|
@@ -53,35 +25,7 @@ export async function retrieveTag(requestOptions, uid) {
|
|
|
53
25
|
url: `${endpoint}/${uid}`,
|
|
54
26
|
responseType: 'json'
|
|
55
27
|
});
|
|
56
|
-
|
|
57
|
-
name: 'response.data'
|
|
58
|
-
});
|
|
59
|
-
return {
|
|
60
|
-
address: Types.asEmptiableString(body.address, {
|
|
61
|
-
name: 'address'
|
|
62
|
-
}),
|
|
63
|
-
seen: Types.asNumber(body.seen, {
|
|
64
|
-
name: 'seen'
|
|
65
|
-
}),
|
|
66
|
-
sent: Types.asNumber(body.sent, {
|
|
67
|
-
name: 'sent'
|
|
68
|
-
}),
|
|
69
|
-
split: Types.asNumber(body.split, {
|
|
70
|
-
name: 'split'
|
|
71
|
-
}),
|
|
72
|
-
startedAt: Types.asString(body.startedAt, {
|
|
73
|
-
name: 'startedAt'
|
|
74
|
-
}),
|
|
75
|
-
stored: Types.asNumber(body.stored, {
|
|
76
|
-
name: 'stored'
|
|
77
|
-
}),
|
|
78
|
-
synced: Types.asNumber(body.synced, {
|
|
79
|
-
name: 'synced'
|
|
80
|
-
}),
|
|
81
|
-
uid: Types.asNumber(body.uid, {
|
|
82
|
-
name: 'uid'
|
|
83
|
-
})
|
|
84
|
-
};
|
|
28
|
+
return TagSchema.parse(response.data);
|
|
85
29
|
}
|
|
86
30
|
/**
|
|
87
31
|
* Get limited listing of all tags.
|
|
@@ -99,40 +43,7 @@ export async function getAllTags(requestOptions, offset, limit) {
|
|
|
99
43
|
},
|
|
100
44
|
responseType: 'json'
|
|
101
45
|
});
|
|
102
|
-
|
|
103
|
-
name: 'response.data'
|
|
104
|
-
});
|
|
105
|
-
const tags = Types.asArray(body.tags, {
|
|
106
|
-
name: 'tags'
|
|
107
|
-
}).map(x => Types.asObject(x, {
|
|
108
|
-
name: 'tag'
|
|
109
|
-
}));
|
|
110
|
-
return tags.map(x => ({
|
|
111
|
-
address: Types.asEmptiableString(x.address, {
|
|
112
|
-
name: 'address'
|
|
113
|
-
}),
|
|
114
|
-
seen: Types.asNumber(x.seen, {
|
|
115
|
-
name: 'seen'
|
|
116
|
-
}),
|
|
117
|
-
sent: Types.asNumber(x.sent, {
|
|
118
|
-
name: 'sent'
|
|
119
|
-
}),
|
|
120
|
-
split: Types.asNumber(x.split, {
|
|
121
|
-
name: 'split'
|
|
122
|
-
}),
|
|
123
|
-
startedAt: Types.asString(x.startedAt, {
|
|
124
|
-
name: 'startedAt'
|
|
125
|
-
}),
|
|
126
|
-
stored: Types.asNumber(x.stored, {
|
|
127
|
-
name: 'stored'
|
|
128
|
-
}),
|
|
129
|
-
synced: Types.asNumber(x.synced, {
|
|
130
|
-
name: 'synced'
|
|
131
|
-
}),
|
|
132
|
-
uid: Types.asNumber(x.uid, {
|
|
133
|
-
name: 'uid'
|
|
134
|
-
})
|
|
135
|
-
}));
|
|
46
|
+
return GetAllTagsResponse.parse(response.data).tags;
|
|
136
47
|
}
|
|
137
48
|
/**
|
|
138
49
|
* Removes tag from the Bee node.
|
|
@@ -23,7 +23,8 @@ export class Stamper {
|
|
|
23
23
|
}
|
|
24
24
|
this.buckets[bucket]++;
|
|
25
25
|
const index = Binary.concatBytes(Binary.numberToUint32(bucket, 'BE'), Binary.numberToUint32(height, 'BE'));
|
|
26
|
-
const
|
|
26
|
+
const currentTimeNs = BigInt(Date.now()) * 1000000n; // Bee uses unix timestamp in nanoseconds
|
|
27
|
+
const timestamp = Binary.numberToUint64(currentTimeNs, 'BE');
|
|
27
28
|
const signature = this.signer.sign(Binary.concatBytes(address, this.batchId.toUint8Array(), index, timestamp));
|
|
28
29
|
return {
|
|
29
30
|
batchId: this.batchId,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BZZ } from "../../utils/tokens.js";
|
|
3
|
+
import { asNumberString } from "../../utils/type.js";
|
|
4
|
+
const PeerBalanceSchema = z.object({
|
|
5
|
+
peer: z.string(),
|
|
6
|
+
balance: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
7
|
+
name: 'balance'
|
|
8
|
+
})))
|
|
9
|
+
});
|
|
10
|
+
export const GetAllBalancesResponse = z.object({
|
|
11
|
+
balances: z.array(PeerBalanceSchema)
|
|
12
|
+
});
|
|
13
|
+
export const GetPeerBalanceResponse = PeerBalanceSchema;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BZZ } from "../../utils/tokens.js";
|
|
3
|
+
import { asNumberString } from "../../utils/type.js";
|
|
4
|
+
import { EthAddress, TransactionId } from "../../utils/typed-bytes.js";
|
|
5
|
+
const ChequeSchema = z.object({
|
|
6
|
+
beneficiary: z.string().transform(s => new EthAddress(s)),
|
|
7
|
+
chequebook: z.string().transform(s => new EthAddress(s)),
|
|
8
|
+
payout: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
9
|
+
name: 'payout'
|
|
10
|
+
})))
|
|
11
|
+
});
|
|
12
|
+
const CashoutResultSchema = z.object({
|
|
13
|
+
recipient: z.string(),
|
|
14
|
+
lastPayout: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
15
|
+
name: 'lastPayout'
|
|
16
|
+
}))),
|
|
17
|
+
bounced: z.boolean()
|
|
18
|
+
});
|
|
19
|
+
export const GetChequebookAddressResponse = z.object({
|
|
20
|
+
chequebookAddress: z.string().transform(s => new EthAddress(s))
|
|
21
|
+
});
|
|
22
|
+
export const GetChequebookBalanceResponse = z.object({
|
|
23
|
+
availableBalance: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
24
|
+
name: 'availableBalance'
|
|
25
|
+
}))),
|
|
26
|
+
totalBalance: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
27
|
+
name: 'totalBalance'
|
|
28
|
+
})))
|
|
29
|
+
});
|
|
30
|
+
export const GetLastCashoutActionResponse = z.object({
|
|
31
|
+
peer: z.string(),
|
|
32
|
+
uncashedAmount: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
33
|
+
name: 'uncashedAmount'
|
|
34
|
+
}))),
|
|
35
|
+
transactionHash: z.string().nullish().transform(v => v ?? null),
|
|
36
|
+
lastCashedCheque: ChequeSchema.nullish().transform(v => v ?? null),
|
|
37
|
+
result: CashoutResultSchema.nullish().transform(v => v ?? null)
|
|
38
|
+
});
|
|
39
|
+
export const GetLastChequesForPeerResponse = z.object({
|
|
40
|
+
peer: z.string(),
|
|
41
|
+
lastreceived: ChequeSchema.nullish().transform(v => v ?? null),
|
|
42
|
+
lastsent: ChequeSchema.nullish().transform(v => v ?? null)
|
|
43
|
+
});
|
|
44
|
+
export const GetLastChequesResponse = z.object({
|
|
45
|
+
lastcheques: z.array(z.object({
|
|
46
|
+
peer: z.string(),
|
|
47
|
+
lastreceived: ChequeSchema.nullish().transform(v => v ?? null),
|
|
48
|
+
lastsent: ChequeSchema.nullish().transform(v => v ?? null)
|
|
49
|
+
}))
|
|
50
|
+
});
|
|
51
|
+
export const TransactionHashResponse = z.object({
|
|
52
|
+
transactionHash: z.string().transform(s => new TransactionId(s))
|
|
53
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EthAddress, PeerAddress, PublicKey } from "../../utils/typed-bytes.js";
|
|
3
|
+
const PeerSchema = z.object({
|
|
4
|
+
address: z.string(),
|
|
5
|
+
fullNode: z.boolean()
|
|
6
|
+
});
|
|
7
|
+
const BinSchema = z.object({
|
|
8
|
+
population: z.number(),
|
|
9
|
+
connected: z.number(),
|
|
10
|
+
connectedPeers: z.array(z.object({
|
|
11
|
+
address: z.string()
|
|
12
|
+
})).nullish().transform(v => v ?? []),
|
|
13
|
+
disconnectedPeers: z.array(z.object({
|
|
14
|
+
address: z.string()
|
|
15
|
+
})).nullish().transform(v => v ?? [])
|
|
16
|
+
});
|
|
17
|
+
const BinRecord = z.record(z.string(), BinSchema);
|
|
18
|
+
export const GetNodeAddressesResponse = z.object({
|
|
19
|
+
overlay: z.string().transform(s => new PeerAddress(s)),
|
|
20
|
+
underlay: z.array(z.string()),
|
|
21
|
+
ethereum: z.string().transform(s => new EthAddress(s)),
|
|
22
|
+
publicKey: z.string().transform(s => new PublicKey(s)),
|
|
23
|
+
pssPublicKey: z.string().transform(s => new PublicKey(s))
|
|
24
|
+
});
|
|
25
|
+
export const GetPeersResponse = z.object({
|
|
26
|
+
peers: z.array(PeerSchema)
|
|
27
|
+
});
|
|
28
|
+
export const GetBlocklistResponse = z.object({
|
|
29
|
+
peers: z.array(PeerSchema)
|
|
30
|
+
});
|
|
31
|
+
export const GetTopologyResponse = z.object({
|
|
32
|
+
baseAddr: z.string(),
|
|
33
|
+
population: z.number(),
|
|
34
|
+
connected: z.number(),
|
|
35
|
+
timestamp: z.string(),
|
|
36
|
+
nnLowWatermark: z.number(),
|
|
37
|
+
depth: z.number(),
|
|
38
|
+
reachability: z.string(),
|
|
39
|
+
networkAvailability: z.string(),
|
|
40
|
+
bins: BinRecord
|
|
41
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Binary } from 'cafe-utility';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const PostEnvelopeBodyResponse = z.object({
|
|
4
|
+
issuer: z.string().transform(s => Binary.hexToUint8Array(s)),
|
|
5
|
+
index: z.string().transform(s => Binary.hexToUint8Array(s)),
|
|
6
|
+
timestamp: z.string().transform(s => Binary.hexToUint8Array(s)),
|
|
7
|
+
signature: z.string().transform(s => Binary.hexToUint8Array(s))
|
|
8
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PublicKey, Reference } from "../../utils/typed-bytes.js";
|
|
3
|
+
export const GetGranteesBodyResponse = z.array(z.string().transform(s => new PublicKey(s)));
|
|
4
|
+
export const GranteesResultBodyResponse = z.object({
|
|
5
|
+
ref: z.string().transform(s => new Reference(s)),
|
|
6
|
+
historyref: z.string().transform(s => new Reference(s))
|
|
7
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BZZ } from "../../utils/tokens.js";
|
|
3
|
+
import { asNumberString } from "../../utils/type.js";
|
|
4
|
+
const SettlementSchema = z.object({
|
|
5
|
+
peer: z.string(),
|
|
6
|
+
sent: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
7
|
+
name: 'sent'
|
|
8
|
+
}))),
|
|
9
|
+
received: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
10
|
+
name: 'received'
|
|
11
|
+
})))
|
|
12
|
+
});
|
|
13
|
+
export const GetSettlementsResponse = SettlementSchema;
|
|
14
|
+
export const GetAllSettlementsResponse = z.object({
|
|
15
|
+
totalSent: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
16
|
+
name: 'totalSent'
|
|
17
|
+
}))),
|
|
18
|
+
totalReceived: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
19
|
+
name: 'totalReceived'
|
|
20
|
+
}))),
|
|
21
|
+
settlements: z.array(SettlementSchema)
|
|
22
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BZZ, DAI } from "../../utils/tokens.js";
|
|
3
|
+
import { asNumberString } from "../../utils/type.js";
|
|
4
|
+
import { TransactionId } from "../../utils/typed-bytes.js";
|
|
5
|
+
export const GetStakeResponse = z.object({
|
|
6
|
+
stakedAmount: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
7
|
+
name: 'stakedAmount'
|
|
8
|
+
})))
|
|
9
|
+
});
|
|
10
|
+
export const GetWithdrawableStakeResponse = z.object({
|
|
11
|
+
withdrawableAmount: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
12
|
+
name: 'withdrawableAmount'
|
|
13
|
+
})))
|
|
14
|
+
});
|
|
15
|
+
export const TxHashResponse = z.object({
|
|
16
|
+
txHash: z.string().transform(s => new TransactionId(s))
|
|
17
|
+
});
|
|
18
|
+
export const GetRedistributionStateResponse = z.object({
|
|
19
|
+
minimumGasFunds: z.string().transform(s => DAI.fromWei(asNumberString(s, {
|
|
20
|
+
name: 'minimumGasFunds'
|
|
21
|
+
}))),
|
|
22
|
+
hasSufficientFunds: z.boolean(),
|
|
23
|
+
isFrozen: z.boolean(),
|
|
24
|
+
isFullySynced: z.boolean(),
|
|
25
|
+
phase: z.string(),
|
|
26
|
+
round: z.number(),
|
|
27
|
+
lastWonRound: z.number(),
|
|
28
|
+
lastPlayedRound: z.number(),
|
|
29
|
+
lastFrozenRound: z.number(),
|
|
30
|
+
lastSelectedRound: z.number(),
|
|
31
|
+
lastSampleDurationSeconds: z.number(),
|
|
32
|
+
block: z.number(),
|
|
33
|
+
reward: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
34
|
+
name: 'reward'
|
|
35
|
+
}))),
|
|
36
|
+
fees: z.string().transform(s => DAI.fromWei(asNumberString(s, {
|
|
37
|
+
name: 'fees'
|
|
38
|
+
}))),
|
|
39
|
+
isHealthy: z.boolean()
|
|
40
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { asNumberString } from "../../utils/type.js";
|
|
3
|
+
import { BatchId, EthAddress } from "../../utils/typed-bytes.js";
|
|
4
|
+
export const RawPostageBatchSchema = z.object({
|
|
5
|
+
batchID: z.string(),
|
|
6
|
+
utilization: z.number(),
|
|
7
|
+
utilizationRatio: z.number().optional(),
|
|
8
|
+
usable: z.boolean(),
|
|
9
|
+
label: z.string(),
|
|
10
|
+
depth: z.number(),
|
|
11
|
+
amount: z.string(),
|
|
12
|
+
bucketDepth: z.number(),
|
|
13
|
+
blockNumber: z.number(),
|
|
14
|
+
immutableFlag: z.boolean(),
|
|
15
|
+
batchTTL: z.number()
|
|
16
|
+
});
|
|
17
|
+
export const GetGlobalPostageBatchResponse = z.object({
|
|
18
|
+
batchID: z.string().transform(s => new BatchId(s)),
|
|
19
|
+
batchTTL: z.number(),
|
|
20
|
+
bucketDepth: z.number(),
|
|
21
|
+
depth: z.number(),
|
|
22
|
+
immutable: z.boolean(),
|
|
23
|
+
owner: z.string().transform(s => new EthAddress(s)),
|
|
24
|
+
start: z.number(),
|
|
25
|
+
value: z.string().transform(s => asNumberString(s, {
|
|
26
|
+
name: 'value'
|
|
27
|
+
}))
|
|
28
|
+
});
|
|
29
|
+
export const GetGlobalPostageBatchesResponse = z.object({
|
|
30
|
+
batches: z.array(GetGlobalPostageBatchResponse)
|
|
31
|
+
});
|
|
32
|
+
export const GetAllPostageBatchesResponse = z.object({
|
|
33
|
+
stamps: z.array(RawPostageBatchSchema)
|
|
34
|
+
});
|
|
35
|
+
export const GetPostageBatchResponse = RawPostageBatchSchema;
|
|
36
|
+
export const GetPostageBatchBucketsResponse = z.object({
|
|
37
|
+
depth: z.number(),
|
|
38
|
+
bucketDepth: z.number(),
|
|
39
|
+
bucketUpperBound: z.number(),
|
|
40
|
+
buckets: z.array(z.object({
|
|
41
|
+
bucketID: z.number(),
|
|
42
|
+
collisions: z.number()
|
|
43
|
+
}))
|
|
44
|
+
});
|
|
45
|
+
export const BatchIdResponse = z.object({
|
|
46
|
+
batchID: z.string().transform(s => new BatchId(s))
|
|
47
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BZZ, DAI } from "../../utils/tokens.js";
|
|
3
|
+
import { asNumberString } from "../../utils/type.js";
|
|
4
|
+
import { TransactionId } from "../../utils/typed-bytes.js";
|
|
5
|
+
import { normalizeCurrentPrice } from "../../utils/workaround.js";
|
|
6
|
+
export const GetReserveStateResponse = z.object({
|
|
7
|
+
commitment: z.number(),
|
|
8
|
+
radius: z.number(),
|
|
9
|
+
storageRadius: z.number(),
|
|
10
|
+
reserveCapacityDoubling: z.number()
|
|
11
|
+
});
|
|
12
|
+
export const GetChainStateResponse = z.object({
|
|
13
|
+
block: z.number(),
|
|
14
|
+
chainTip: z.number(),
|
|
15
|
+
totalAmount: z.string().transform(s => asNumberString(s, {
|
|
16
|
+
name: 'totalAmount'
|
|
17
|
+
})),
|
|
18
|
+
currentPrice: z.string().transform(Number).transform(s => normalizeCurrentPrice(s)),
|
|
19
|
+
minimumValidityBlocks: z.number().optional()
|
|
20
|
+
});
|
|
21
|
+
export const GetWalletBalanceResponse = z.object({
|
|
22
|
+
bzzBalance: z.string().transform(s => BZZ.fromPLUR(asNumberString(s, {
|
|
23
|
+
name: 'bzzBalance'
|
|
24
|
+
}))),
|
|
25
|
+
nativeTokenBalance: z.string().transform(s => DAI.fromWei(asNumberString(s, {
|
|
26
|
+
name: 'nativeTokenBalance'
|
|
27
|
+
}))),
|
|
28
|
+
chainID: z.number(),
|
|
29
|
+
chequebookContractAddress: z.string(),
|
|
30
|
+
walletAddress: z.string()
|
|
31
|
+
});
|
|
32
|
+
export const WithdrawResponse = z.object({
|
|
33
|
+
transactionHash: z.string().transform(s => new TransactionId(s))
|
|
34
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toBeeMode } from "../debug.js";
|
|
3
|
+
export const GetDebugStatusResponse = z.object({
|
|
4
|
+
overlay: z.string(),
|
|
5
|
+
proximity: z.number(),
|
|
6
|
+
beeMode: z.string().transform(toBeeMode),
|
|
7
|
+
reserveSize: z.number(),
|
|
8
|
+
reserveSizeWithinRadius: z.number(),
|
|
9
|
+
pullsyncRate: z.number(),
|
|
10
|
+
storageRadius: z.number(),
|
|
11
|
+
connectedPeers: z.number(),
|
|
12
|
+
neighborhoodSize: z.number(),
|
|
13
|
+
batchCommitment: z.number(),
|
|
14
|
+
isReachable: z.boolean(),
|
|
15
|
+
lastSyncedBlock: z.number(),
|
|
16
|
+
committedDepth: z.number(),
|
|
17
|
+
isWarmingUp: z.boolean()
|
|
18
|
+
});
|
|
19
|
+
export const GetHealthResponse = z.object({
|
|
20
|
+
apiVersion: z.string(),
|
|
21
|
+
version: z.string(),
|
|
22
|
+
status: z.literal('ok')
|
|
23
|
+
});
|
|
24
|
+
export const GetReadinessResponse = z.object({
|
|
25
|
+
apiVersion: z.string(),
|
|
26
|
+
version: z.string(),
|
|
27
|
+
status: z.enum(['ready', 'notReady'])
|
|
28
|
+
});
|
|
29
|
+
export const GetNodeInfoResponse = z.object({
|
|
30
|
+
beeMode: z.string().transform(toBeeMode),
|
|
31
|
+
chequebookEnabled: z.boolean(),
|
|
32
|
+
swapEnabled: z.boolean()
|
|
33
|
+
});
|
|
34
|
+
export const IsGatewayResponse = z.object({
|
|
35
|
+
gateway: z.boolean()
|
|
36
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const TagSchema = z.object({
|
|
3
|
+
address: z.string().nullish().transform(v => v ?? ''),
|
|
4
|
+
seen: z.number(),
|
|
5
|
+
sent: z.number(),
|
|
6
|
+
split: z.number(),
|
|
7
|
+
startedAt: z.string(),
|
|
8
|
+
stored: z.number(),
|
|
9
|
+
synced: z.number(),
|
|
10
|
+
uid: z.number()
|
|
11
|
+
});
|
|
12
|
+
export const GetAllTagsResponse = z.object({
|
|
13
|
+
tags: z.array(TagSchema)
|
|
14
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { asNumberString } from "../../utils/type.js";
|
|
3
|
+
import { TransactionId } from "../../utils/typed-bytes.js";
|
|
4
|
+
const TransactionInfoSchema = z.object({
|
|
5
|
+
transactionHash: z.string().transform(s => new TransactionId(s)),
|
|
6
|
+
to: z.string(),
|
|
7
|
+
nonce: z.number(),
|
|
8
|
+
gasPrice: z.string().transform(s => asNumberString(s, {
|
|
9
|
+
name: 'gasPrice'
|
|
10
|
+
})),
|
|
11
|
+
gasLimit: z.number(),
|
|
12
|
+
data: z.string(),
|
|
13
|
+
created: z.string(),
|
|
14
|
+
description: z.string(),
|
|
15
|
+
value: z.string().transform(s => asNumberString(s, {
|
|
16
|
+
name: 'value'
|
|
17
|
+
}))
|
|
18
|
+
});
|
|
19
|
+
export const GetAllTransactionsResponse = z.object({
|
|
20
|
+
pendingTransactions: z.array(TransactionInfoSchema)
|
|
21
|
+
});
|
|
22
|
+
export const GetTransactionResponse = TransactionInfoSchema;
|
|
23
|
+
export const TransactionHashResponse = z.object({
|
|
24
|
+
transactionHash: z.string().transform(s => new TransactionId(s))
|
|
25
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ports blocked by the WHATWG Fetch spec for HTTP/HTTPS requests.
|
|
3
|
+
*
|
|
4
|
+
* See: https://fetch.spec.whatwg.org/#port-blocking
|
|
5
|
+
*/
|
|
6
|
+
export const BAD_PORTS = ['1', '7', '9', '11', '13', '15', '17', '19', '20', '21', '22', '23', '25', '37', '42', '43', '53', '69', '77', '79', '87', '95', '101', '102', '103', '104', '109', '110', '111', '113', '115', '117', '119', '123', '135', '137', '139', '143', '161', '179', '389', '427', '465', '512', '513', '514', '515', '526', '530', '531', '532', '540', '548', '554', '556', '563', '587', '601', '636', '989', '990', '993', '995', '1719', '1720', '1723', '2049', '3659', '4045', '4190', '5060', '5061', '6000', '6566', '6665', '6666', '6667', '6668', '6669', '6679', '6697', '10080'];
|