From 8bd13bdb0fc5e2e102c72f401122d888b0113b16 Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Sat, 8 Aug 2020 15:34:44 -0400 Subject: [PATCH] problem: protobuf code is not included with dshackle --- README.adoc | 1 + docs/06-methods.adoc | 3 + proto/README.adoc | 7 ++ proto/blockchain.proto | 154 +++++++++++++++++++++++++++++++++++++++++ proto/common.proto | 68 ++++++++++++++++++ 5 files changed, 233 insertions(+) create mode 100644 proto/README.adoc create mode 100644 proto/blockchain.proto create mode 100644 proto/common.proto diff --git a/README.adoc b/README.adoc index d01aef97..453c2490 100644 --- a/README.adoc +++ b/README.adoc @@ -160,6 +160,7 @@ NOTE: It's not necessary to use gRPC, as Dshackle can provide standard JSON RPC Dshackle provides a custom gRPC based API, which provides additional methods and other features such as streaming responses. Please refer to the documentation: link:docs/06-methods.adoc[gRPC Methods] +The Protobuf definitions could be found in link:proto/[./proto]. .Connect and listen for new blocks on Ethereum Mainnet [source,bash] diff --git a/docs/06-methods.adoc b/docs/06-methods.adoc index 77672e53..a5936743 100644 --- a/docs/06-methods.adoc +++ b/docs/06-methods.adoc @@ -10,6 +10,9 @@ NOTE: It's not necessary to use gRPC, as Dshackle can provide standard JSON RPC === gRPC definition +The source code for the Protobuf definitions could be found in link:../proto/[/proto]. + +.Service API [source,proto] ---- service Blockchain { diff --git a/proto/README.adoc b/proto/README.adoc new file mode 100644 index 00000000..bc5ea63d --- /dev/null +++ b/proto/README.adoc @@ -0,0 +1,7 @@ += Emerald Dshackle Protobuf definitions + +Protobuf definition for the external interface (i.e. gRPC) of the Emerald Dshackle. +This gRPC definitions are part of the general Emerald API, please see the project with whole API at https://github.com/emeraldpay/emerald-grpc + +Dshakle also has some internal Protobuf schemas, for example to serialize cached values. +You can find them in link:../src/main/proto/[]. \ No newline at end of file diff --git a/proto/blockchain.proto b/proto/blockchain.proto new file mode 100644 index 00000000..691906b8 --- /dev/null +++ b/proto/blockchain.proto @@ -0,0 +1,154 @@ +syntax = "proto3"; +package emerald; +option java_package = "io.emeraldpay.api.proto"; +import "common.proto"; + +service Blockchain { + rpc SubscribeHead (Chain) returns (stream ChainHead) { + } + rpc SubscribeBalance (BalanceRequest) returns (stream AddressBalance) { + } + rpc SubscribeTxStatus (TxStatusRequest) returns (stream TxStatus) { + } + + rpc GetBalance (BalanceRequest) returns (stream AddressBalance) { + } + + rpc NativeCall (NativeCallRequest) returns (stream NativeCallReplyItem) { + } + + rpc Describe (DescribeRequest) returns (DescribeResponse) { + } + rpc SubscribeStatus (StatusRequest) returns (stream ChainStatus) { + } +} + +message NativeCallRequest { + ChainRef chain = 1; + repeated NativeCallItem items = 2; + Selector selector = 3; + int32 quorum = 4; + AvailabilityEnum min_availability = 5; +} + +message NativeCallItem { + uint32 id = 1; + string method = 3; + bytes payload = 4; +} + +message NativeCallReplyItem { + uint32 id = 1; + bool succeed = 2; + bytes payload = 3; + string errorMessage = 4; +} + +message ChainHead { + ChainRef chain = 1; + uint64 height = 2; + string block_id = 3; + uint64 timestamp = 4; + bytes weight = 5; + uint64 reorg = 6; +} + +message TxStatusRequest { + ChainRef chain = 1; + string tx_id = 2; + uint32 confirmation_limit = 3; +} + +message TxStatus { + string tx_id = 1; + bool broadcasted = 2; + bool mined = 3; + BlockInfo block = 4; + uint32 confirmations = 5; +} + +message BalanceRequest { + Asset asset = 1; + AnyAddress address = 2; +} + +message AddressBalance { + Asset asset = 1; + SingleAddress address = 2; + string balance = 3; +} + +message DescribeRequest { +} + +message DescribeResponse { + repeated DescribeChain chains = 1; +} + +message DescribeChain { + ChainRef chain = 1; + ChainStatus status = 2; + repeated NodeDetails nodes = 3; + repeated string supportedMethods = 4; + repeated string excludedMethods = 5; +} + +message StatusRequest { + repeated ChainRef chains = 1; +} + +message ChainStatus { + ChainRef chain = 1; + AvailabilityEnum availability = 2; + uint32 quorum = 3; +} + +enum AvailabilityEnum { + AVAIL_UNKNOWN = 0; + AVAIL_OK = 1; + AVAIL_LAGGING = 2; + AVAIL_IMMATURE = 3; + AVAIL_SYNCING = 4; + AVAIL_UNAVAILABLE = 5; +} + +message NodeDetails { + uint32 quorum = 1; + repeated Label labels = 2; +} + +message Label { + string name = 1; + string value = 2; +} + +message Selector { + oneof selector_type { + LabelSelector labelSelector = 1; + OrSelector orSelector = 2; + AndSelector andSelector = 3; + NotSelector notSelector = 4; + ExistsSelector existsSelector = 5; + } +} + +message LabelSelector { + string name = 1; + repeated string value = 2; +} + +message OrSelector { + repeated Selector selectors = 1; +} + +message AndSelector { + repeated Selector selectors = 1; +} + +message NotSelector { + Selector selector = 1; +} + +message ExistsSelector { + string name = 1; +} \ No newline at end of file diff --git a/proto/common.proto b/proto/common.proto new file mode 100644 index 00000000..68c2f871 --- /dev/null +++ b/proto/common.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package emerald; +option java_package = "io.emeraldpay.api.proto"; + +message Chain { + ChainRef type = 1; +} + +enum ChainRef { + CHAIN_UNSPECIFIED = 0; + + CHAIN_BITCOIN = 1; + CHAIN_GRIN = 2; + + CHAIN_ETHEREUM = 100; + CHAIN_ETHEREUM_CLASSIC = 101; + + // Sidechains and state channels + CHAIN_LIGHTNING = 1001; + + // Testnets + CHAIN_MORDEN = 10001; + CHAIN_KOVAN = 10002; + CHAIN_TESTNET_BITCOIN = 10003; + CHAIN_FLOONET = 10004; + + // Non-standard starts from 50000 +} + +message SingleAddress { + string address = 1; +} + +message XpubAddress { + bytes xpub = 1; + string path = 2; + uint64 start = 3; + uint64 limit = 4; +} + +message MultiAddress { + repeated SingleAddress addresses = 1; +} + +message ReferenceAddress { + uint64 refid = 1; +} + +message AnyAddress { + oneof addr_type { + SingleAddress address_single = 1; + MultiAddress address_multi = 2; + XpubAddress address_xpub = 3; + ReferenceAddress address_ref = 4; + } +} + +message Asset { + ChainRef chain = 1; + string code = 2; +} + +message BlockInfo { + uint64 height = 1; + string block_id = 2; + uint64 timestamp = 3; + bytes weight = 4; +} \ No newline at end of file