diff --git a/BUILD b/BUILD index e69de29..d242081 100644 --- a/BUILD +++ b/BUILD @@ -0,0 +1,3 @@ +load("@io_bazel_rules_go//go:def.bzl", "gazelle", "go_prefix") + +go_prefix("github.com/iotaledger/entangled") diff --git a/WORKSPACE b/WORKSPACE index fbbe893..34e907d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,7 +1,5 @@ workspace(name="org_iota_hub") -# Global config - # EXTERNAL RULES git_repository( name="org_pubref_rules_protobuf", @@ -70,18 +68,16 @@ new_git_repository( build_file="BUILD.libzmq", ) load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") -boost_deps() - load("@org_pubref_rules_protobuf//cpp:rules.bzl", "cpp_proto_repositories") -cpp_proto_repositories() - load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", - "go_register_toolchains") -go_rules_dependencies() -go_register_toolchains() - + "go_register_toolchains", "go_prefix") load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_repositories") -go_proto_repositories() load("@org_pubref_rules_protobuf//grpc_gateway:rules.bzl", "grpc_gateway_proto_repositories") + +boost_deps() +cpp_proto_repositories() +go_rules_dependencies() +go_register_toolchains() +go_proto_repositories() grpc_gateway_proto_repositories() diff --git a/proto/BUILD b/proto/BUILD index 5512108..0a3d8d5 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -1,13 +1,22 @@ package(default_visibility=["//visibility:public"]) +load("@org_pubref_rules_protobuf//protobuf:rules.bzl", "proto_language") load("@org_pubref_rules_protobuf//cpp:rules.bzl", "cc_proto_library") +load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library") +load("@org_pubref_rules_protobuf//grpc_gateway:rules.bzl", + "grpc_gateway_proto_library", "GRPC_GATEWAY_DEPS") -filegroup( - name="protos", - srcs=["hub.proto"], ) +filegroup(name="protos", srcs=["messages.proto"]) cc_proto_library( name="cpp", - protos=[":protos"], + protos=[":protos", "hub.proto"], verbose=0, with_grpc=True, ) + +# Currently broken in rules_protobuf. +#grpc_gateway_proto_library( +# name="gateway", +# verbose=1, +# protos=["gateway.proto", ":protos"], +# visibility=["//visibility:public"], ) diff --git a/proto/gateway.proto b/proto/gateway.proto new file mode 100644 index 0000000..6984fcd --- /dev/null +++ b/proto/gateway.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package iota.rpc; + +import "proto/messages.proto"; +import "google/api/annotations.proto"; + +service HubGateway { + rpc CreateUser (CreateUserRequest) returns (CreateUserReply) { + option (google.api.http) = { + post: "/v1/createUser" + body: "*" + }; + + } +} + diff --git a/proto/hub.proto b/proto/hub.proto index 2367fb7..c00cd40 100644 --- a/proto/hub.proto +++ b/proto/hub.proto @@ -1,66 +1,7 @@ syntax = "proto3"; package iota.rpc; - -enum ErrorCode { - UNKNOWN = 0; - USER_EXISTS = 1; - USER_DOES_NOT_EXIST = 2; -} -message Error { - ErrorCode code = 1; -} - -message CreateUserRequest { - string userId = 1; -} - -message CreateUserReply {} - -message GetBalanceRequest { - string userId = 1; -} - -message GetBalanceReply { - int64 available = 1; -} - -message DepositAddressRequest { - string userId = 1; -} - -message DepositAddressReply { - string address = 1; -} - -message UserWithdrawRequest { - string userId = 1; - string address = 2; - uint64 amount = 3; - string note = 4; -} - -message UserWithdrawReply { - uint32 error = 1; - string bundleHash = 2; -} - -message StatsRequest {} - -message StatsReply {} - -message GetUserHistoryRequest {} - -message GetUserHistoryReply {} - -message UserBalanceSubscriptionRequest {} - -message UserBalanceEvent {} - -message ScheduleSweepRequest {} - -message ScheduleSweepReply {} - +import "proto/messages.proto"; service Hub { rpc CreateUser (CreateUserRequest ) returns ( CreateUserReply ); diff --git a/proto/messages.proto b/proto/messages.proto new file mode 100644 index 0000000..a4d6871 --- /dev/null +++ b/proto/messages.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; + +package iota.rpc; + +enum ErrorCode { + UNKNOWN = 0; + USER_EXISTS = 1; + USER_DOES_NOT_EXIST = 2; +} +message Error { + ErrorCode code = 1; +} + +message CreateUserRequest { + string userId = 1; +} + +message CreateUserReply {} + +message GetBalanceRequest { + string userId = 1; +} + +message GetBalanceReply { + int64 available = 1; + + // TODO(th0br0): pendingSweep + +} + +message DepositAddressRequest { + string userId = 1; +} + +message DepositAddressReply { + string address = 1; +} + +message UserWithdrawRequest { + string userId = 1; + string address = 2; + uint64 amount = 3; + string note = 4; +} + +message UserWithdrawReply { + uint32 error = 1; + string bundleHash = 2; +} + +message StatsRequest {} + +message StatsReply {} + +message GetUserHistoryRequest {} + +message GetUserHistoryReply {} + +message UserBalanceSubscriptionRequest {} + +message UserBalanceEvent {} + +message ScheduleSweepRequest {} + +message ScheduleSweepReply {} \ No newline at end of file