-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP][Session] Adding the Relay type (#53)
Scaffolding and customizing the first version of the `Relay` type.
- Loading branch information
Showing
2 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
syntax = "proto3"; | ||
package pocket.service; | ||
|
||
option go_package = "pocket/x/service/types"; | ||
|
||
import "cosmos_proto/cosmos.proto"; | ||
// TODO(@Olshansk): Uncomment the line below once the `service.proto` is added. | ||
// import "pocket/service/service.proto"; | ||
import "pocket/application/application.proto"; | ||
import "pocket/supplier/supplier.proto"; | ||
|
||
// Relay contains both the RelayRequest (signed by the Application) and the RelayResponse (signed by the Supplier). | ||
// The serialized tuple is inserted into the SMST leaves as values in the Claim/Proof lifecycle. | ||
message Relay { | ||
RelayRequest req = 1; | ||
RelayResponse res = 2; | ||
} | ||
|
||
// RelayRequestMetadata contains the metadata for a RelayRequest. | ||
message RelayRequestMetadata { | ||
// TODO(@Olshansk): Uncomment the line below once the `service.proto` is added. | ||
// session.SessionHeader session_header = 1; // Session header associated with the relay. | ||
// TODO_COMMENT(@h5law): Add link or more details to how this is related to ring signatures once implemented. | ||
bytes signature = 2; // The request signature. This may be the application signature, or any gateway it delegated to. | ||
} | ||
|
||
// RelayRequest holds the request details for a relay. | ||
message RelayRequest { | ||
RelayRequestMetadata meta = 1; | ||
oneof payload { | ||
JSONRPCRequestPayload json_rpc_payload = 2; | ||
RESTRequestPayload rest_payload = 3; | ||
// Future possible relay types: | ||
// WebSocketsRequestPayload websockets_payload = 4; | ||
// GRPCRequestPayload grpc_payload = 5; | ||
// GraphQLRequestPayload graphql_payload = 6; | ||
} | ||
} | ||
|
||
// JSONRPCRequestPayload contains the payload for a JSON-RPC request. | ||
// See https://www.jsonrpc.org/specification#request_object for more details. | ||
message JSONRPCRequestPayload { | ||
bytes id = 1; // Identifier established by the Client to create context for the request. | ||
string jsonrpc = 2; // Version of JSON-RPC. Must be exactly "2.0". | ||
string method = 3; // Method being invoked on the server. | ||
map<string, string> parameters = 4; // Parameters for the method. https://www.jsonrpc.org/specification#parameter_structures | ||
} | ||
|
||
// RESTRequestType represents the type of REST request. | ||
enum RESTRequestType { | ||
REST_REQUEST_TYPE_UNKNOWN = 0; // Default uninitialized value. | ||
REST_REQUEST_TYPE_GET = 1; | ||
REST_REQUEST_TYPE_PUT = 2; | ||
REST_REQUEST_TYPE_POST = 3; | ||
REST_REQUEST_TYPE_DELETE = 4; | ||
} | ||
|
||
// RESTRequestPayload contains the payload and metadata for a REST request. | ||
message RESTRequestPayload { | ||
RESTRequestType request_type = 1; | ||
string http_path = 2; // Path for the REST endpoint. | ||
string contents = 3; // Request contents. | ||
map<string, string> headers = 4; // Request headers. | ||
} | ||
|
||
// RelayResponse contains the response details for a RelayRequest. | ||
message RelayResponse { | ||
RelayResponseMetadata meta = 1; | ||
oneof payload { | ||
JSONRPCResponsePayload json_rpc_payload = 2; | ||
RESTResponsePayload rest_payload = 3; | ||
// Future possible relay types: | ||
// WebSocketsResponsePayload websockets_payload = 4; | ||
// GRPCResponsePayload grpc_payload = 5; | ||
// GraphQLResponsePayload graphql_payload = 6; | ||
} | ||
} | ||
|
||
// RelayResponseMetadata contains the metadata for a RelayResponse. | ||
message RelayResponseMetadata { | ||
// TODO(@Olshansk): Uncomment the line below once the `service.proto` is added. | ||
// session.SessionHeader session_header = 1; // Session header associated with the relay. | ||
bytes supplier_signature = 2; // Signature of the supplier on the response. | ||
} | ||
|
||
// JSONRPCResponsePayload contains the response details for a JSON-RPC relay. | ||
// See www.jsonrpc.org/specification for more details. | ||
message JSONRPCResponsePayload { | ||
bytes id = 1; // Identifier established by the Client to link the response back to the request. | ||
string jsonrpc = 2; // Version of JSON-RPC. Must be exactly "2.0". | ||
bytes result = 3; // Response result payload. | ||
JSONRPCResponseError error = 4; // Error message, if any. Can be nil. | ||
} | ||
|
||
message JSONRPCResponseError { | ||
int32 code = 1; // Error code. | ||
string message = 2; // Error message. | ||
bytes data = 3; // Error data. | ||
} | ||
|
||
// RESTResponsePayload contains the response details for a REST relay. | ||
message RESTResponsePayload { | ||
uint32 status_code = 1; // Response status code. | ||
string err = 2; // Error message, if any. | ||
bytes payload = 3; // Response payload. | ||
} |