@dashevo/dapi-grpc 2.1.0-dev.7 → 2.1.0-pr.2716.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.
@@ -427,6 +427,15 @@ type PlatformgetGroupActionSigners = {
427
427
  readonly responseType: typeof platform_pb.GetGroupActionSignersResponse;
428
428
  };
429
429
 
430
+ type PlatformSubscribePlatformEvents = {
431
+ readonly methodName: string;
432
+ readonly service: typeof Platform;
433
+ readonly requestStream: true;
434
+ readonly responseStream: true;
435
+ readonly requestType: typeof platform_pb.PlatformEventsCommand;
436
+ readonly responseType: typeof platform_pb.PlatformEventsResponse;
437
+ };
438
+
430
439
  export class Platform {
431
440
  static readonly serviceName: string;
432
441
  static readonly broadcastStateTransition: PlatformbroadcastStateTransition;
@@ -476,6 +485,7 @@ export class Platform {
476
485
  static readonly getGroupInfos: PlatformgetGroupInfos;
477
486
  static readonly getGroupActions: PlatformgetGroupActions;
478
487
  static readonly getGroupActionSigners: PlatformgetGroupActionSigners;
488
+ static readonly SubscribePlatformEvents: PlatformSubscribePlatformEvents;
479
489
  }
480
490
 
481
491
  export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
@@ -933,5 +943,6 @@ export class PlatformClient {
933
943
  requestMessage: platform_pb.GetGroupActionSignersRequest,
934
944
  callback: (error: ServiceError|null, responseMessage: platform_pb.GetGroupActionSignersResponse|null) => void
935
945
  ): UnaryResponse;
946
+ subscribePlatformEvents(metadata?: grpc.Metadata): BidirectionalStream<platform_pb.PlatformEventsCommand, platform_pb.PlatformEventsResponse>;
936
947
  }
937
948
 
@@ -433,6 +433,15 @@ Platform.getGroupActionSigners = {
433
433
  responseType: platform_pb.GetGroupActionSignersResponse
434
434
  };
435
435
 
436
+ Platform.SubscribePlatformEvents = {
437
+ methodName: "SubscribePlatformEvents",
438
+ service: Platform,
439
+ requestStream: true,
440
+ responseStream: true,
441
+ requestType: platform_pb.PlatformEventsCommand,
442
+ responseType: platform_pb.PlatformEventsResponse
443
+ };
444
+
436
445
  exports.Platform = Platform;
437
446
 
438
447
  function PlatformClient(serviceHost, options) {
@@ -1897,5 +1906,50 @@ PlatformClient.prototype.getGroupActionSigners = function getGroupActionSigners(
1897
1906
  };
1898
1907
  };
1899
1908
 
1909
+ PlatformClient.prototype.subscribePlatformEvents = function subscribePlatformEvents(metadata) {
1910
+ var listeners = {
1911
+ data: [],
1912
+ end: [],
1913
+ status: []
1914
+ };
1915
+ var client = grpc.client(Platform.SubscribePlatformEvents, {
1916
+ host: this.serviceHost,
1917
+ metadata: metadata,
1918
+ transport: this.options.transport
1919
+ });
1920
+ client.onEnd(function (status, statusMessage, trailers) {
1921
+ listeners.status.forEach(function (handler) {
1922
+ handler({ code: status, details: statusMessage, metadata: trailers });
1923
+ });
1924
+ listeners.end.forEach(function (handler) {
1925
+ handler({ code: status, details: statusMessage, metadata: trailers });
1926
+ });
1927
+ listeners = null;
1928
+ });
1929
+ client.onMessage(function (message) {
1930
+ listeners.data.forEach(function (handler) {
1931
+ handler(message);
1932
+ })
1933
+ });
1934
+ client.start(metadata);
1935
+ return {
1936
+ on: function (type, handler) {
1937
+ listeners[type].push(handler);
1938
+ return this;
1939
+ },
1940
+ write: function (requestMessage) {
1941
+ client.send(requestMessage);
1942
+ return this;
1943
+ },
1944
+ end: function () {
1945
+ client.finishSend();
1946
+ },
1947
+ cancel: function () {
1948
+ listeners = null;
1949
+ client.close();
1950
+ }
1951
+ };
1952
+ };
1953
+
1900
1954
  exports.PlatformClient = PlatformClient;
1901
1955
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dapi-grpc",
3
- "version": "2.1.0-dev.7",
3
+ "version": "2.1.0-pr.2716.1",
4
4
  "description": "DAPI GRPC definition file and generated clients",
5
5
  "browser": "browser.js",
6
6
  "main": "node.js",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "homepage": "https://github.com/dashevo/dapi-grpc#readme",
47
47
  "dependencies": {
48
- "@dashevo/grpc-common": "2.1.0-dev.7",
48
+ "@dashevo/grpc-common": "2.1.0-pr.2716.1",
49
49
  "@dashevo/protobufjs": "6.10.5",
50
50
  "@grpc/grpc-js": "1.4.4",
51
51
  "@improbable-eng/grpc-web": "^0.15.0",
@@ -6,6 +6,91 @@ package org.dash.platform.dapi.v0;
6
6
 
7
7
  import "google/protobuf/timestamp.proto";
8
8
 
9
+ // Platform events streaming (v0)
10
+ message PlatformEventsCommand {
11
+ message PlatformEventsCommandV0 {
12
+ oneof command {
13
+ AddSubscriptionV0 add = 1;
14
+ RemoveSubscriptionV0 remove = 2;
15
+ }
16
+ }
17
+ oneof version { PlatformEventsCommandV0 v0 = 1; }
18
+ }
19
+
20
+ message PlatformEventsResponse {
21
+ message PlatformEventsResponseV0 {
22
+ oneof response {
23
+ PlatformEventMessageV0 event = 1;
24
+ AckV0 ack = 2;
25
+ PlatformErrorV0 error = 3;
26
+ }
27
+ }
28
+ oneof version { PlatformEventsResponseV0 v0 = 1; }
29
+ }
30
+
31
+ message AddSubscriptionV0 {
32
+ string client_subscription_id = 1;
33
+ PlatformFilterV0 filter = 2;
34
+ }
35
+
36
+ message RemoveSubscriptionV0 {
37
+ string client_subscription_id = 1;
38
+ }
39
+
40
+ message AckV0 {
41
+ string client_subscription_id = 1;
42
+ string op = 2; // "add" | "remove"
43
+ }
44
+
45
+ message PlatformErrorV0 {
46
+ string client_subscription_id = 1;
47
+ uint32 code = 2;
48
+ string message = 3;
49
+ }
50
+
51
+ message PlatformEventMessageV0 {
52
+ string client_subscription_id = 1;
53
+ PlatformEventV0 event = 2;
54
+ }
55
+
56
+ // Initial placeholder filter and event to be refined during integration
57
+ // Filter for StateTransitionResult events
58
+ message StateTransitionResultFilter {
59
+ // When set, only match StateTransitionResult events for this tx hash.
60
+ optional bytes tx_hash = 1;
61
+ }
62
+
63
+ message PlatformFilterV0 {
64
+ oneof kind {
65
+ bool all = 1; // subscribe to all platform events
66
+ bool block_committed = 2; // subscribe to BlockCommitted events only
67
+ StateTransitionResultFilter state_transition_result = 3; // subscribe to StateTransitionResult events (optionally filtered by tx_hash)
68
+ }
69
+ }
70
+
71
+ message PlatformEventV0 {
72
+ message BlockMetadata {
73
+ uint64 height = 1 [ jstype = JS_STRING ];
74
+ uint64 time_ms = 2 [ jstype = JS_STRING ];
75
+ bytes block_id_hash = 3;
76
+ }
77
+
78
+ message BlockCommitted {
79
+ BlockMetadata meta = 1;
80
+ uint32 tx_count = 2;
81
+ }
82
+
83
+ message StateTransitionFinalized {
84
+ BlockMetadata meta = 1;
85
+ bytes tx_hash = 2;
86
+ }
87
+
88
+ oneof event {
89
+ BlockCommitted block_committed = 1;
90
+ StateTransitionFinalized state_transition_finalized = 2;
91
+ }
92
+ }
93
+
9
94
  service Platform {
10
95
  rpc broadcastStateTransition(BroadcastStateTransitionRequest)
11
96
  returns (BroadcastStateTransitionResponse);
@@ -102,6 +187,10 @@ service Platform {
102
187
  rpc getGroupActions(GetGroupActionsRequest) returns (GetGroupActionsResponse);
103
188
  rpc getGroupActionSigners(GetGroupActionSignersRequest)
104
189
  returns (GetGroupActionSignersResponse);
190
+
191
+ // Bi-directional stream for multiplexed platform events subscriptions
192
+ rpc SubscribePlatformEvents(stream PlatformEventsCommand)
193
+ returns (stream PlatformEventsResponse);
105
194
  }
106
195
 
107
196
  // Proof message includes cryptographic proofs for validating responses
@@ -1,4 +1,222 @@
1
1
  // This file is @generated by prost-build.
2
+ /// Platform events streaming (v0)
3
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
4
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
5
+ #[derive(::dapi_grpc_macros::Mockable)]
6
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
7
+ pub struct PlatformEventsCommand {
8
+ #[prost(oneof = "platform_events_command::Version", tags = "1")]
9
+ pub version: ::core::option::Option<platform_events_command::Version>,
10
+ }
11
+ /// Nested message and enum types in `PlatformEventsCommand`.
12
+ pub mod platform_events_command {
13
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
14
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
15
+ #[derive(::dapi_grpc_macros::Mockable)]
16
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
17
+ pub struct PlatformEventsCommandV0 {
18
+ #[prost(oneof = "platform_events_command_v0::Command", tags = "1, 2")]
19
+ pub command: ::core::option::Option<platform_events_command_v0::Command>,
20
+ }
21
+ /// Nested message and enum types in `PlatformEventsCommandV0`.
22
+ pub mod platform_events_command_v0 {
23
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
24
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
25
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
26
+ pub enum Command {
27
+ #[prost(message, tag = "1")]
28
+ Add(super::super::AddSubscriptionV0),
29
+ #[prost(message, tag = "2")]
30
+ Remove(super::super::RemoveSubscriptionV0),
31
+ }
32
+ }
33
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
34
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
35
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
36
+ pub enum Version {
37
+ #[prost(message, tag = "1")]
38
+ V0(PlatformEventsCommandV0),
39
+ }
40
+ }
41
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
42
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
43
+ #[derive(::dapi_grpc_macros::Mockable)]
44
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
45
+ pub struct PlatformEventsResponse {
46
+ #[prost(oneof = "platform_events_response::Version", tags = "1")]
47
+ pub version: ::core::option::Option<platform_events_response::Version>,
48
+ }
49
+ /// Nested message and enum types in `PlatformEventsResponse`.
50
+ pub mod platform_events_response {
51
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
52
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
53
+ #[derive(::dapi_grpc_macros::Mockable)]
54
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
55
+ pub struct PlatformEventsResponseV0 {
56
+ #[prost(oneof = "platform_events_response_v0::Response", tags = "1, 2, 3")]
57
+ pub response: ::core::option::Option<platform_events_response_v0::Response>,
58
+ }
59
+ /// Nested message and enum types in `PlatformEventsResponseV0`.
60
+ pub mod platform_events_response_v0 {
61
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
62
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
63
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
64
+ pub enum Response {
65
+ #[prost(message, tag = "1")]
66
+ Event(super::super::PlatformEventMessageV0),
67
+ #[prost(message, tag = "2")]
68
+ Ack(super::super::AckV0),
69
+ #[prost(message, tag = "3")]
70
+ Error(super::super::PlatformErrorV0),
71
+ }
72
+ }
73
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
74
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
75
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
76
+ pub enum Version {
77
+ #[prost(message, tag = "1")]
78
+ V0(PlatformEventsResponseV0),
79
+ }
80
+ }
81
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
82
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
83
+ #[derive(::dapi_grpc_macros::Mockable)]
84
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
85
+ pub struct AddSubscriptionV0 {
86
+ #[prost(string, tag = "1")]
87
+ pub client_subscription_id: ::prost::alloc::string::String,
88
+ #[prost(message, optional, tag = "2")]
89
+ pub filter: ::core::option::Option<PlatformFilterV0>,
90
+ }
91
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
92
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
93
+ #[derive(::dapi_grpc_macros::Mockable)]
94
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
95
+ pub struct RemoveSubscriptionV0 {
96
+ #[prost(string, tag = "1")]
97
+ pub client_subscription_id: ::prost::alloc::string::String,
98
+ }
99
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
100
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
101
+ #[derive(::dapi_grpc_macros::Mockable)]
102
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
103
+ pub struct AckV0 {
104
+ #[prost(string, tag = "1")]
105
+ pub client_subscription_id: ::prost::alloc::string::String,
106
+ /// "add" | "remove"
107
+ #[prost(string, tag = "2")]
108
+ pub op: ::prost::alloc::string::String,
109
+ }
110
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
111
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
112
+ #[derive(::dapi_grpc_macros::Mockable)]
113
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
114
+ pub struct PlatformErrorV0 {
115
+ #[prost(string, tag = "1")]
116
+ pub client_subscription_id: ::prost::alloc::string::String,
117
+ #[prost(uint32, tag = "2")]
118
+ pub code: u32,
119
+ #[prost(string, tag = "3")]
120
+ pub message: ::prost::alloc::string::String,
121
+ }
122
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
123
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
124
+ #[derive(::dapi_grpc_macros::Mockable)]
125
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
126
+ pub struct PlatformEventMessageV0 {
127
+ #[prost(string, tag = "1")]
128
+ pub client_subscription_id: ::prost::alloc::string::String,
129
+ #[prost(message, optional, tag = "2")]
130
+ pub event: ::core::option::Option<PlatformEventV0>,
131
+ }
132
+ /// Initial placeholder filter and event to be refined during integration
133
+ /// Filter for StateTransitionResult events
134
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
135
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
136
+ #[derive(::dapi_grpc_macros::Mockable)]
137
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
138
+ pub struct StateTransitionResultFilter {
139
+ /// When set, only match StateTransitionResult events for this tx hash.
140
+ #[prost(bytes = "vec", optional, tag = "1")]
141
+ pub tx_hash: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
142
+ }
143
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
144
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
145
+ #[derive(::dapi_grpc_macros::Mockable)]
146
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
147
+ pub struct PlatformFilterV0 {
148
+ #[prost(oneof = "platform_filter_v0::Kind", tags = "1, 2, 3")]
149
+ pub kind: ::core::option::Option<platform_filter_v0::Kind>,
150
+ }
151
+ /// Nested message and enum types in `PlatformFilterV0`.
152
+ pub mod platform_filter_v0 {
153
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
154
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
155
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
156
+ pub enum Kind {
157
+ /// subscribe to all platform events
158
+ #[prost(bool, tag = "1")]
159
+ All(bool),
160
+ /// subscribe to BlockCommitted events only
161
+ #[prost(bool, tag = "2")]
162
+ BlockCommitted(bool),
163
+ /// subscribe to StateTransitionResult events (optionally filtered by tx_hash)
164
+ #[prost(message, tag = "3")]
165
+ StateTransitionResult(super::StateTransitionResultFilter),
166
+ }
167
+ }
168
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
169
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
170
+ #[derive(::dapi_grpc_macros::Mockable)]
171
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
172
+ pub struct PlatformEventV0 {
173
+ #[prost(oneof = "platform_event_v0::Event", tags = "1, 2")]
174
+ pub event: ::core::option::Option<platform_event_v0::Event>,
175
+ }
176
+ /// Nested message and enum types in `PlatformEventV0`.
177
+ pub mod platform_event_v0 {
178
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
179
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
180
+ #[derive(::dapi_grpc_macros::Mockable)]
181
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
182
+ pub struct BlockMetadata {
183
+ #[prost(uint64, tag = "1")]
184
+ pub height: u64,
185
+ #[prost(uint64, tag = "2")]
186
+ pub time_ms: u64,
187
+ #[prost(bytes = "vec", tag = "3")]
188
+ pub block_id_hash: ::prost::alloc::vec::Vec<u8>,
189
+ }
190
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
191
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
192
+ #[derive(::dapi_grpc_macros::Mockable)]
193
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
194
+ pub struct BlockCommitted {
195
+ #[prost(message, optional, tag = "1")]
196
+ pub meta: ::core::option::Option<BlockMetadata>,
197
+ #[prost(uint32, tag = "2")]
198
+ pub tx_count: u32,
199
+ }
200
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
201
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
202
+ #[derive(::dapi_grpc_macros::Mockable)]
203
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
204
+ pub struct StateTransitionFinalized {
205
+ #[prost(message, optional, tag = "1")]
206
+ pub meta: ::core::option::Option<BlockMetadata>,
207
+ #[prost(bytes = "vec", tag = "2")]
208
+ pub tx_hash: ::prost::alloc::vec::Vec<u8>,
209
+ }
210
+ #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
211
+ #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
212
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
213
+ pub enum Event {
214
+ #[prost(message, tag = "1")]
215
+ BlockCommitted(BlockCommitted),
216
+ #[prost(message, tag = "2")]
217
+ StateTransitionFinalized(StateTransitionFinalized),
218
+ }
219
+ }
2
220
  /// Proof message includes cryptographic proofs for validating responses
3
221
  #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
4
222
  #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
@@ -7024,5 +7242,37 @@ pub mod platform_client {
7024
7242
  );
7025
7243
  self.inner.unary(req, path, codec).await
7026
7244
  }
7245
+ /// Bi-directional stream for multiplexed platform events subscriptions
7246
+ pub async fn subscribe_platform_events(
7247
+ &mut self,
7248
+ request: impl tonic::IntoStreamingRequest<
7249
+ Message = super::PlatformEventsCommand,
7250
+ >,
7251
+ ) -> std::result::Result<
7252
+ tonic::Response<tonic::codec::Streaming<super::PlatformEventsResponse>>,
7253
+ tonic::Status,
7254
+ > {
7255
+ self.inner
7256
+ .ready()
7257
+ .await
7258
+ .map_err(|e| {
7259
+ tonic::Status::unknown(
7260
+ format!("Service was not ready: {}", e.into()),
7261
+ )
7262
+ })?;
7263
+ let codec = tonic_prost::ProstCodec::default();
7264
+ let path = http::uri::PathAndQuery::from_static(
7265
+ "/org.dash.platform.dapi.v0.Platform/SubscribePlatformEvents",
7266
+ );
7267
+ let mut req = request.into_streaming_request();
7268
+ req.extensions_mut()
7269
+ .insert(
7270
+ GrpcMethod::new(
7271
+ "org.dash.platform.dapi.v0.Platform",
7272
+ "SubscribePlatformEvents",
7273
+ ),
7274
+ );
7275
+ self.inner.streaming(req, path, codec).await
7276
+ }
7027
7277
  }
7028
7278
  }