syntax = "proto3";

package ethrpc.v1;
//option go_package = "protoeth";
import "google/protobuf/empty.proto";

// GetAccounts only for ganache
message GetAccountsReq {}

message TestnetReq {
    uint32 id = 1;
}

message HashStringOrNumber {
    string reqString = 1;
    uint64 reqNum = 2;
}

message InfoWithIndex {
    HashStringOrNumber req = 1;
    uint64 index = 2;
}

message CountResp {
    uint64 count = 1;
}

message ObjResp {
    string respObj = 1;
}

message GetAccountsResp {
    repeated string accounts = 1;
}

// GetBalance -> eth.getBalance -> eth_getBalance
message GetBalanceReq {
   repeated string address = 1;
}
message GetBalanceResp {
   repeated string balance = 1;
}


// GetNonce -> eth.GetNonce -> GetNonce
message GetNonceReq {
   repeated string address = 1;
}
message GetNonceResp {
   repeated string balance = 1;
}


message CreateRawTransactionReq {
    string to = 1;
    string data = 2;
    uint32 gas = 3;
    uint32 value = 4;   
}

message CreateRawTransactionResp {
    string rawTX = 1;
}

message DeploySignedTransactionReq{
    string signedTX = 1;
}

message DeploySignedTransactionResp {
    string txReciept = 1;
}

// GetTransaction -> Eth.getTransaction -> eth_getTransactionByHAsh
message TxHash {
    string txhash = 1;
}
message TransactionInfo {
    string transaction = 1;
}

message TxReceipt {
    string txReceipt = 1;
}

message RawTxRequest {
    uint32 networkid = 1;
    string tx = 2;
}

message BlockNumber {
    uint64 blocknum = 1;
}

message TxResponse {
    string txData = 1;
}

message NumResult {
    uint64 resultNum = 1;
}

message GetTxReq {
    uint32 networkid = 1;
    string txhash = 2;
}

message CallRequest {
    uint32 networkid = 1;
    string fn = 2;
    string params = 3;
    string abi = 4;
    string address = 5;
    string fromAddress = 6; // python will not allow .from so it has to be fromAddress
    uint64 value = 7;
    uint64 gasSupply = 8;
}

message CallResponse {
    string result = 1;
}

service ProtoEthService {
    rpc GetBalance(GetBalanceReq) returns (GetBalanceResp) {};
    rpc GetNonce(GetNonceReq) returns (GetNonceResp) {};
    rpc GetTransaction(GetTxReq) returns (TransactionInfo) {};
    rpc GetTransactionReceipt(TxHash) returns (TxReceipt) {};
    rpc ContractCall(CallRequest) returns (CallResponse) {};
    rpc GetHashrate(google.protobuf.Empty) returns (NumResult) {};
    rpc GetGasPrice(google.protobuf.Empty) returns (NumResult) {};
    rpc GetBlockNumber(google.protobuf.Empty) returns (BlockNumber) {};
    rpc GetBlockTransactionCount(HashStringOrNumber) returns (CountResp) {};
    rpc GetBlock(HashStringOrNumber) returns (ObjResp) {};
    rpc GetTransactionFromBlock(InfoWithIndex) returns (ObjResp) {};
    // eth_sendRawTransaction should have simple requests but stream of responses
    rpc SendRawTransactions(RawTxRequest) returns (TxResponse) {};
}

// ##############################
// ## 1. create protocol buffer for sendTransaction
// ## this protobuf should return a stream. Once the transaction is successful, stream will return confirmations
// ## 2. split functions in multiple subs exmp - eth, personal, debug
// ##############################
