Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.

Commit

Permalink
proto: restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
th0br0 committed Apr 19, 2018
1 parent 3fcda59 commit 7e89e61
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 75 deletions.
3 changes: 3 additions & 0 deletions BUILD
@@ -0,0 +1,3 @@
load("@io_bazel_rules_go//go:def.bzl", "gazelle", "go_prefix")

go_prefix("github.com/iotaledger/entangled")
18 changes: 7 additions & 11 deletions WORKSPACE
@@ -1,7 +1,5 @@
workspace(name="org_iota_hub")

# Global config

# EXTERNAL RULES
git_repository(
name="org_pubref_rules_protobuf",
Expand Down Expand Up @@ -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()
17 changes: 13 additions & 4 deletions 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"], )
17 changes: 17 additions & 0 deletions 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: "*"
};

}
}

61 changes: 1 addition & 60 deletions 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 );
Expand Down
65 changes: 65 additions & 0 deletions 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 {}

0 comments on commit 7e89e61

Please sign in to comment.