@dashevo/dapi-grpc 3.0.1 → 3.1.0-dev.3
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/CHANGELOG.md +0 -2
- package/Cargo.toml +2 -2
- package/README.md +0 -1
- package/build.rs +104 -16
- package/clients/drive/v0/nodejs/drive_pbjs.js +53499 -36752
- package/clients/platform/v0/nodejs/platform_pbjs.js +53499 -36752
- package/clients/platform/v0/nodejs/platform_protoc.js +44924 -28778
- package/clients/platform/v0/web/platform_pb.d.ts +2626 -444
- package/clients/platform/v0/web/platform_pb.js +44924 -28778
- package/clients/platform/v0/web/platform_pb_service.d.ts +171 -0
- package/clients/platform/v0/web/platform_pb_service.js +360 -0
- package/eslint.config.mjs +11 -0
- package/package.json +5 -7
- package/protos/platform/v0/platform.proto +924 -2
- package/src/lib.rs +32 -8
- package/src/mock/serde_mockable.rs +1 -1
- package/.eslintignore +0 -3
- package/.eslintrc +0 -19
- package/lib/test/.eslintrc +0 -9
- package/src/core/client/org.dash.platform.dapi.v0.rs +0 -808
- package/src/core/wasm/org.dash.platform.dapi.v0.rs +0 -797
- package/src/drive/client/org.dash.platform.dapi.v0.rs +0 -7757
- package/src/drive/client/org.dash.platform.drive.v0.rs +0 -143
- package/src/drive/wasm/org.dash.platform.dapi.v0.rs +0 -7746
- package/src/drive/wasm/org.dash.platform.drive.v0.rs +0 -132
- package/src/platform/client/org.dash.platform.dapi.v0.rs +0 -8135
- package/src/platform/wasm/org.dash.platform.dapi.v0.rs +0 -8124
- package/test/.eslintrc +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -167,5 +167,3 @@
|
|
|
167
167
|
* add more methods to Core service ([41f3ad0](https://github.com/dashevo/dapi-grpc/commit/41f3ad0ad6aee3acf4b1760949cde36d8df7d6f2))
|
|
168
168
|
* fetchIdentity endpoint ([75d32d8](https://github.com/dashevo/dapi-grpc/commit/75d32d883be4d7a113fe34f1d008e1d9bcc3c7e1))
|
|
169
169
|
* introduce Platform service ([c88b891](https://github.com/dashevo/dapi-grpc/commit/c88b891ecfac8987cd76c773b2f783ad7a155540))
|
|
170
|
-
|
|
171
|
-
|
package/Cargo.toml
CHANGED
|
@@ -39,7 +39,7 @@ serde = ["dep:serde", "dep:serde_bytes", "tenderdash-proto/serde"]
|
|
|
39
39
|
mocks = ["serde", "dep:serde_json"]
|
|
40
40
|
|
|
41
41
|
[dependencies]
|
|
42
|
-
tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v1.5.
|
|
42
|
+
tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v1.5.1", default-features = false }
|
|
43
43
|
|
|
44
44
|
prost = { version = "0.14" }
|
|
45
45
|
futures-core = "0.3.30"
|
|
@@ -83,6 +83,6 @@ ignored = [
|
|
|
83
83
|
"platform-version",
|
|
84
84
|
"futures-core",
|
|
85
85
|
"tonic-prost-build",
|
|
86
|
-
"getrandom",
|
|
86
|
+
"getrandom", # Ignore getrandom as we need it to enable `js` feature
|
|
87
87
|
"dash-platform-macros", # used in build.rs
|
|
88
88
|
]
|
package/README.md
CHANGED
package/build.rs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
use std::{
|
|
2
2
|
collections::HashSet,
|
|
3
|
+
env,
|
|
3
4
|
fs::{create_dir_all, remove_dir_all},
|
|
4
|
-
path::PathBuf,
|
|
5
|
+
path::{Path, PathBuf},
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
use tonic_prost_build::Builder;
|
|
@@ -13,23 +14,32 @@ const SERDE_WITH_STRING: &str =
|
|
|
13
14
|
r#"#[cfg_attr(feature = "serde", serde(with = "crate::deserialization::from_to_string"))]"#;
|
|
14
15
|
|
|
15
16
|
fn main() {
|
|
17
|
+
let output_base = resolve_output_base().unwrap_or_else(|e| {
|
|
18
|
+
eprintln!("[error] => resolve output base failed: {e}");
|
|
19
|
+
std::process::exit(1);
|
|
20
|
+
});
|
|
21
|
+
println!(
|
|
22
|
+
"cargo:rustc-env=DAPI_GRPC_OUT_DIR={}",
|
|
23
|
+
output_base.display()
|
|
24
|
+
);
|
|
25
|
+
|
|
16
26
|
#[cfg(feature = "server")]
|
|
17
|
-
generate_code(ImplType::Server);
|
|
27
|
+
generate_code(ImplType::Server, &output_base);
|
|
18
28
|
#[cfg(feature = "client")]
|
|
19
|
-
generate_code(ImplType::Client);
|
|
29
|
+
generate_code(ImplType::Client, &output_base);
|
|
20
30
|
|
|
21
31
|
if std::env::var("CARGO_CFG_TARGET_ARCH")
|
|
22
32
|
.unwrap_or_default()
|
|
23
33
|
.eq("wasm32")
|
|
24
34
|
{
|
|
25
|
-
generate_code(ImplType::Wasm);
|
|
35
|
+
generate_code(ImplType::Wasm, &output_base);
|
|
26
36
|
}
|
|
27
37
|
}
|
|
28
38
|
|
|
29
|
-
fn generate_code(typ: ImplType) {
|
|
39
|
+
fn generate_code(typ: ImplType, output_base: &Path) {
|
|
30
40
|
let core = MappingConfig::new(
|
|
31
41
|
PathBuf::from("protos/core/v0/core.proto"),
|
|
32
|
-
|
|
42
|
+
output_base.join("core"),
|
|
33
43
|
&typ,
|
|
34
44
|
);
|
|
35
45
|
|
|
@@ -39,7 +49,7 @@ fn generate_code(typ: ImplType) {
|
|
|
39
49
|
|
|
40
50
|
let platform = MappingConfig::new(
|
|
41
51
|
PathBuf::from("protos/platform/v0/platform.proto"),
|
|
42
|
-
|
|
52
|
+
output_base.join("platform"),
|
|
43
53
|
&typ,
|
|
44
54
|
);
|
|
45
55
|
|
|
@@ -49,7 +59,7 @@ fn generate_code(typ: ImplType) {
|
|
|
49
59
|
|
|
50
60
|
let drive = MappingConfig::new(
|
|
51
61
|
PathBuf::from("protos/drive/v0/drive.proto"),
|
|
52
|
-
|
|
62
|
+
output_base.join("drive"),
|
|
53
63
|
&typ,
|
|
54
64
|
);
|
|
55
65
|
|
|
@@ -60,6 +70,7 @@ fn generate_code(typ: ImplType) {
|
|
|
60
70
|
println!("cargo:rerun-if-changed=./protos");
|
|
61
71
|
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_SERDE");
|
|
62
72
|
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH");
|
|
73
|
+
println!("cargo:rerun-if-env-changed=DAPI_GRPC_OUT_DIR");
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
struct MappingConfig {
|
|
@@ -73,7 +84,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
73
84
|
// Derive features for versioned messages
|
|
74
85
|
//
|
|
75
86
|
// "GetConsensusParamsRequest" is excluded as this message does not support proofs
|
|
76
|
-
const VERSIONED_REQUESTS: [&str;
|
|
87
|
+
const VERSIONED_REQUESTS: [&str; 56] = [
|
|
77
88
|
"GetDataContractHistoryRequest",
|
|
78
89
|
"GetDataContractRequest",
|
|
79
90
|
"GetDataContractsRequest",
|
|
@@ -112,6 +123,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
112
123
|
"GetTokenDirectPurchasePricesRequest",
|
|
113
124
|
"GetTokenContractInfoRequest",
|
|
114
125
|
"GetTokenStatusesRequest",
|
|
126
|
+
"GetTokenPreProgrammedDistributionsRequest",
|
|
115
127
|
"GetTokenTotalSupplyRequest",
|
|
116
128
|
"GetGroupInfoRequest",
|
|
117
129
|
"GetGroupInfosRequest",
|
|
@@ -122,11 +134,24 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
122
134
|
"GetAddressesInfosRequest",
|
|
123
135
|
"GetRecentAddressBalanceChangesRequest",
|
|
124
136
|
"GetRecentCompactedAddressBalanceChangesRequest",
|
|
137
|
+
"GetShieldedEncryptedNotesRequest",
|
|
138
|
+
"GetShieldedAnchorsRequest",
|
|
139
|
+
"GetMostRecentShieldedAnchorRequest",
|
|
140
|
+
"GetShieldedPoolStateRequest",
|
|
141
|
+
"GetShieldedNullifiersRequest",
|
|
142
|
+
"GetRecentNullifierChangesRequest",
|
|
143
|
+
"GetRecentCompactedNullifierChangesRequest",
|
|
125
144
|
];
|
|
126
145
|
|
|
127
|
-
const PROOF_ONLY_VERSIONED_REQUESTS: [&str;
|
|
146
|
+
const PROOF_ONLY_VERSIONED_REQUESTS: [&str; 2] = [
|
|
147
|
+
"GetAddressesTrunkStateRequest",
|
|
148
|
+
"GetNullifiersTrunkStateRequest",
|
|
149
|
+
];
|
|
128
150
|
|
|
129
|
-
const MERK_PROOF_VERSIONED_REQUESTS: [&str;
|
|
151
|
+
const MERK_PROOF_VERSIONED_REQUESTS: [&str; 2] = [
|
|
152
|
+
"GetAddressesBranchStateRequest",
|
|
153
|
+
"GetNullifiersBranchStateRequest",
|
|
154
|
+
];
|
|
130
155
|
|
|
131
156
|
// The following responses are excluded as they don't support proofs:
|
|
132
157
|
// - "GetConsensusParamsResponse"
|
|
@@ -136,7 +161,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
136
161
|
// - "GetIdentityByNonUniquePublicKeyHashResponse"
|
|
137
162
|
//
|
|
138
163
|
// "GetEvonodesProposedEpochBlocksResponse" is used for 2 Requests
|
|
139
|
-
const VERSIONED_RESPONSES: [&str;
|
|
164
|
+
const VERSIONED_RESPONSES: [&str; 54] = [
|
|
140
165
|
"GetDataContractHistoryResponse",
|
|
141
166
|
"GetDataContractResponse",
|
|
142
167
|
"GetDataContractsResponse",
|
|
@@ -173,6 +198,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
173
198
|
"GetTokenDirectPurchasePricesResponse",
|
|
174
199
|
"GetTokenContractInfoResponse",
|
|
175
200
|
"GetTokenStatusesResponse",
|
|
201
|
+
"GetTokenPreProgrammedDistributionsResponse",
|
|
176
202
|
"GetTokenTotalSupplyResponse",
|
|
177
203
|
"GetGroupInfoResponse",
|
|
178
204
|
"GetGroupInfosResponse",
|
|
@@ -183,11 +209,24 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
183
209
|
"GetAddressesInfosResponse",
|
|
184
210
|
"GetRecentAddressBalanceChangesResponse",
|
|
185
211
|
"GetRecentCompactedAddressBalanceChangesResponse",
|
|
212
|
+
"GetShieldedEncryptedNotesResponse",
|
|
213
|
+
"GetShieldedAnchorsResponse",
|
|
214
|
+
"GetMostRecentShieldedAnchorResponse",
|
|
215
|
+
"GetShieldedPoolStateResponse",
|
|
216
|
+
"GetShieldedNullifiersResponse",
|
|
217
|
+
"GetRecentNullifierChangesResponse",
|
|
218
|
+
"GetRecentCompactedNullifierChangesResponse",
|
|
186
219
|
];
|
|
187
220
|
|
|
188
|
-
const PROOF_ONLY_VERSIONED_RESPONSES: [&str;
|
|
221
|
+
const PROOF_ONLY_VERSIONED_RESPONSES: [&str; 2] = [
|
|
222
|
+
"GetAddressesTrunkStateResponse",
|
|
223
|
+
"GetNullifiersTrunkStateResponse",
|
|
224
|
+
];
|
|
189
225
|
|
|
190
|
-
const MERK_PROOF_VERSIONED_RESPONSES: [&str;
|
|
226
|
+
const MERK_PROOF_VERSIONED_RESPONSES: [&str; 2] = [
|
|
227
|
+
"GetAddressesBranchStateResponse",
|
|
228
|
+
"GetNullifiersBranchStateResponse",
|
|
229
|
+
];
|
|
191
230
|
|
|
192
231
|
check_unique(&VERSIONED_REQUESTS).expect("VERSIONED_REQUESTS");
|
|
193
232
|
check_unique(&VERSIONED_RESPONSES).expect("VERSIONED_RESPONSES");
|
|
@@ -196,8 +235,24 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
196
235
|
check_unique(&MERK_PROOF_VERSIONED_REQUESTS).expect("MERK_PROOF_VERSIONED_REQUESTS");
|
|
197
236
|
check_unique(&MERK_PROOF_VERSIONED_RESPONSES).expect("MERK_PROOF_VERSIONED_RESPONSES");
|
|
198
237
|
|
|
238
|
+
// Messages whose latest version is v1 — the macro needs to know
|
|
239
|
+
// to generate match arms for both V0 and V1. Listed separately
|
|
240
|
+
// so the default `grpc_versions(0)` loop below skips them.
|
|
241
|
+
//
|
|
242
|
+
// Adding a message here is the proto-side companion of:
|
|
243
|
+
// - Adding a `GetXxxRequestV1` / `GetXxxResponseV1` to the
|
|
244
|
+
// oneof in `platform.proto`.
|
|
245
|
+
// - Bumping the matching `FeatureVersionBounds.max_version`
|
|
246
|
+
// to 1 in `rs-platform-version`.
|
|
247
|
+
// - Implementing the v1 dispatch arm in `drive-abci`.
|
|
248
|
+
const VERSIONED_AT_V1_REQUESTS: [&str; 1] = ["GetDocumentsRequest"];
|
|
249
|
+
const VERSIONED_AT_V1_RESPONSES: [&str; 1] = ["GetDocumentsResponse"];
|
|
250
|
+
|
|
199
251
|
// Derive VersionedGrpcMessage on requests
|
|
200
252
|
for msg in VERSIONED_REQUESTS {
|
|
253
|
+
if VERSIONED_AT_V1_REQUESTS.contains(&msg) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
201
256
|
platform = platform
|
|
202
257
|
.message_attribute(
|
|
203
258
|
msg,
|
|
@@ -205,6 +260,14 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
205
260
|
)
|
|
206
261
|
.message_attribute(msg, r#"#[grpc_versions(0)]"#);
|
|
207
262
|
}
|
|
263
|
+
for msg in VERSIONED_AT_V1_REQUESTS {
|
|
264
|
+
platform = platform
|
|
265
|
+
.message_attribute(
|
|
266
|
+
msg,
|
|
267
|
+
r#"#[derive(::dash_platform_macros::VersionedGrpcMessage)]"#,
|
|
268
|
+
)
|
|
269
|
+
.message_attribute(msg, r#"#[grpc_versions(1)]"#);
|
|
270
|
+
}
|
|
208
271
|
|
|
209
272
|
// Derive ProofOnlyVersionedGrpcMessage on requests
|
|
210
273
|
for msg in PROOF_ONLY_VERSIONED_REQUESTS {
|
|
@@ -218,6 +281,9 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
218
281
|
|
|
219
282
|
// Derive VersionedGrpcMessage and VersionedGrpcResponse on responses
|
|
220
283
|
for msg in VERSIONED_RESPONSES {
|
|
284
|
+
if VERSIONED_AT_V1_RESPONSES.contains(&msg) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
221
287
|
platform = platform
|
|
222
288
|
.message_attribute(
|
|
223
289
|
msg,
|
|
@@ -225,6 +291,14 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
225
291
|
)
|
|
226
292
|
.message_attribute(msg, r#"#[grpc_versions(0)]"#);
|
|
227
293
|
}
|
|
294
|
+
for msg in VERSIONED_AT_V1_RESPONSES {
|
|
295
|
+
platform = platform
|
|
296
|
+
.message_attribute(
|
|
297
|
+
msg,
|
|
298
|
+
r#"#[derive(::dash_platform_macros::VersionedGrpcMessage,::dash_platform_macros::VersionedGrpcResponse)]"#,
|
|
299
|
+
)
|
|
300
|
+
.message_attribute(msg, r#"#[grpc_versions(1)]"#);
|
|
301
|
+
}
|
|
228
302
|
|
|
229
303
|
// Derive VersionedGrpcMessage and ProofOnlyVersionedGrpcResponse on responses
|
|
230
304
|
for msg in PROOF_ONLY_VERSIONED_RESPONSES {
|
|
@@ -277,10 +351,14 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
|
|
|
277
351
|
.field_attribute("start_at_ms", SERDE_WITH_STRING)
|
|
278
352
|
.field_attribute("public_key_hash", SERDE_WITH_BYTES)
|
|
279
353
|
.field_attribute("public_key_hashes", SERDE_WITH_BASE64)
|
|
354
|
+
.field_attribute("nullifiers", SERDE_WITH_BASE64)
|
|
280
355
|
// Get documents fields
|
|
281
356
|
.field_attribute("data_contract_id", SERDE_WITH_BYTES)
|
|
282
|
-
|
|
283
|
-
|
|
357
|
+
// V0 still ships CBOR for `where` / `order_by`; V1 ships
|
|
358
|
+
// typed `repeated WhereClause` / `repeated OrderClause`
|
|
359
|
+
// and doesn't need the `bytes`-shaped serde shim.
|
|
360
|
+
.field_attribute("GetDocumentsRequestV0.where", SERDE_WITH_BYTES)
|
|
361
|
+
.field_attribute("GetDocumentsRequestV0.order_by", SERDE_WITH_BYTES)
|
|
284
362
|
// Proof fields
|
|
285
363
|
.field_attribute("Proof.grovedb_proof", SERDE_WITH_BYTES)
|
|
286
364
|
.field_attribute("Proof.quorum_hash", SERDE_WITH_BYTES)
|
|
@@ -462,3 +540,13 @@ fn abs_path(path: &PathBuf) -> PathBuf {
|
|
|
462
540
|
|
|
463
541
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(path)
|
|
464
542
|
}
|
|
543
|
+
|
|
544
|
+
/// Resolve output base directory for generated files.
|
|
545
|
+
fn resolve_output_base() -> Result<PathBuf, String> {
|
|
546
|
+
env::var("DAPI_GRPC_OUT_DIR")
|
|
547
|
+
.map(PathBuf::from)
|
|
548
|
+
.or_else(|_| env::var("OUT_DIR").map(|out_dir| PathBuf::from(out_dir).join("dapi_grpc")))
|
|
549
|
+
.map_err(|_| {
|
|
550
|
+
"OUT_DIR should be provided by Cargo; set DAPI_GRPC_OUT_DIR to override it".to_string()
|
|
551
|
+
})
|
|
552
|
+
}
|