github.com/igggame/nebulas-go@v2.1.0+incompatible/nebtestkit/cases/rpc/rpc_client/rpc.proto (about)

     1  
     2  syntax = "proto3";
     3  
     4  //import "google/api/annotations.proto";
     5  
     6  import "../../../..//consensus/pb/state.proto";
     7  //import "../../../../core/pb/block.proto";
     8  import "./block.proto";
     9  import "../../../../neblet/pb/config.proto";
    10  package rpcpb;
    11  
    12  // RPC API interface.
    13  service ApiService {
    14      // Return the state of the neb.
    15      rpc GetNebState (NonParamsRequest) returns (GetNebStateResponse) { 
    16          option (google.api.http) = {
    17              get: "/v1/user/nebstate"
    18          };
    19      }
    20  
    21      // Return the latest irreversible block.
    22      rpc LatestIrreversibleBlock (NonParamsRequest) returns (BlockResponse) {
    23          option (google.api.http) = {
    24              get: "/v1/user/lib"
    25          };
    26      }
    27  
    28      // Return the state of the account.
    29      rpc GetAccountState (GetAccountStateRequest) returns (GetAccountStateResponse) {
    30          option (google.api.http) = {
    31              post: "/v1/user/accountstate"
    32              body: "*"
    33          };
    34      }
    35  
    36      // Call transaction
    37      rpc Call (TransactionRequest) returns (CallResponse) {
    38          option (google.api.http) = {
    39              post: "/v1/user/call"
    40              body: "*"
    41          };
    42      }
    43  
    44  	// Submit the signed transaction.
    45  	rpc SendRawTransaction (SendRawTransactionRequest) returns (SendTransactionResponse) {
    46  		option (google.api.http) = {
    47              post: "/v1/user/rawtransaction"
    48              body: "*"
    49          };
    50      }
    51  
    52      // Get block info by the block hash.
    53      rpc GetBlockByHash (GetBlockByHashRequest) returns (BlockResponse) {
    54          option (google.api.http) = {
    55              post: "/v1/user/getBlockByHash"
    56              body: "*"
    57          };
    58      }
    59  
    60      // Get block info by the block height.
    61      rpc GetBlockByHeight (GetBlockByHeightRequest) returns (BlockResponse) {
    62          option (google.api.http) = {
    63              post: "/v1/user/getBlockByHeight"
    64              body: "*"
    65          };
    66      }
    67  
    68      // Get transactionReceipt info by tansaction hash.
    69      rpc GetTransactionReceipt (GetTransactionByHashRequest) returns (TransactionResponse) {
    70          option (google.api.http) = {
    71              post: "/v1/user/getTransactionReceipt"
    72              body: "*"
    73          };
    74      }
    75  
    76      // Subscribe message
    77      rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {
    78          option (google.api.http) = {
    79              post: "/v1/user/subscribe"
    80              body: "*"
    81          };
    82      }
    83  
    84      // Get GasPrice
    85      rpc GetGasPrice(NonParamsRequest) returns (GasPriceResponse) {
    86          option (google.api.http) = {
    87              get: "/v1/user/getGasPrice"
    88          };
    89      }
    90  
    91      // EstimateGas
    92      rpc EstimateGas(TransactionRequest) returns (GasResponse) {
    93          option (google.api.http) = {
    94              post: "/v1/user/estimateGas"
    95              body: "*"
    96          };
    97      }
    98  
    99      rpc GetEventsByHash(HashRequest) returns (EventsResponse) {
   100          option (google.api.http) = {
   101              post: "/v1/user/getEventsByHash"
   102              body: "*"
   103          };
   104      }
   105  
   106      rpc GetDynasty (ByBlockHeightRequest) returns (GetDynastyResponse) {
   107  		option (google.api.http) = {
   108              post: "/v1/user/dynasty"
   109              body: "*"
   110  		};
   111      }
   112  
   113      // Verify Signature.
   114      rpc VerifySignature (VerifySignatureRequest) returns (VerifySignatureResponse) {
   115          option (google.api.http) = {
   116              post: "/v1/user/verifySignature"
   117              body: "*"
   118          };
   119      }
   120  }
   121  
   122  service AdminService {
   123      // Accounts return account list.
   124      rpc Accounts (NonParamsRequest) returns (AccountsResponse) {
   125          option (google.api.http) = {
   126              get: "/v1/admin/accounts"
   127          };
   128      }
   129      
   130      // NewAccount create a new account with passphrase
   131      rpc NewAccount(NewAccountRequest) returns (NewAccountResponse) {
   132          option (google.api.http) = {
   133              post: "/v1/admin/account/new"
   134              body: "*"
   135          };
   136      }
   137  
   138      // UnlockAccount unlock account with passphrase
   139      rpc UnlockAccount(UnlockAccountRequest) returns (UnlockAccountResponse) {
   140          option (google.api.http) = {
   141              post: "/v1/admin/account/unlock"
   142              body: "*"
   143          };
   144      }
   145  
   146      // LockAccount lock account
   147      rpc LockAccount(LockAccountRequest) returns (LockAccountResponse) {
   148          option (google.api.http) = {
   149              post: "/v1/admin/account/lock"
   150              body: "*"
   151          };
   152      }
   153  
   154      // Verify, sign, and send the transaction.
   155  	rpc SendTransaction (TransactionRequest) returns (SendTransactionResponse) {
   156  		option (google.api.http) = {
   157              post: "/v1/admin/transaction"
   158              body: "*"
   159          };
   160      }
   161  
   162      // Sign sign msg
   163      rpc SignHash(SignHashRequest) returns (SignHashResponse) {
   164          option (google.api.http) = {
   165              post: "/v1/admin/sign/hash"
   166              body: "*"
   167          };
   168      }
   169  
   170      // Sign sign transaction
   171      rpc SignTransactionWithPassphrase(SignTransactionPassphraseRequest) returns (SignTransactionPassphraseResponse) {
   172          option (google.api.http) = {
   173              post: "/v1/admin/sign"
   174              body: "*"
   175          };
   176      }
   177  
   178      // SendTransactionWithPassphrase send transaction with passphrase
   179      rpc SendTransactionWithPassphrase(SendTransactionPassphraseRequest) returns (SendTransactionResponse) {
   180          option (google.api.http) = {
   181              post: "/v1/admin/transactionWithPassphrase"
   182              body: "*"
   183          };
   184      }
   185  
   186      rpc StartPprof (PprofRequest) returns (PprofResponse) {
   187          option (google.api.http) = {
   188  			post: "/v1/admin/pprof"
   189  			body: "*"
   190  		};
   191      }
   192  
   193      //Get Config
   194      rpc GetConfig (NonParamsRequest) returns (GetConfigResponse) {
   195          option (google.api.http) = {
   196              get: "/v1/admin/getConfig"
   197  		};
   198  
   199      }
   200  
   201      // Return the p2p node info.
   202      rpc NodeInfo (NonParamsRequest) returns (NodeInfoResponse) {
   203          option (google.api.http) = {
   204              get: "/v1/admin/nodeinfo"
   205          };
   206      }
   207  }
   208  
   209  // Request message of Subscribe rpc
   210  message SubscribeRequest {
   211      repeated string topics = 1;
   212  }
   213  
   214  // Request message of Subscribe rpc
   215  message SubscribeResponse {
   216      string topic = 1;
   217      string data = 2;
   218  }
   219  
   220  // Request message of non params.
   221  message NonParamsRequest {
   222  }
   223  
   224  // Response message of node info.
   225  message NodeInfoResponse {
   226      // the node ID.
   227      string id = 1;
   228  
   229      // the block chainID.
   230      uint32 chain_id  = 2;
   231  
   232      // coinbase
   233      string coinbase = 3;
   234  
   235      // Number of peers currenly connected.
   236      uint32 peer_count = 4;
   237  
   238      // the node synchronized status.
   239      bool synchronized = 5;
   240  
   241      // the node route table bucket size.
   242      int32 bucket_size = 6;
   243  
   244      // the network protocol version.
   245      string protocol_version = 10;
   246  
   247      repeated RouteTable route_table = 11;
   248  }
   249  
   250  
   251  message RouteTable {
   252      string id = 1;
   253      repeated string address = 2;
   254  }
   255  
   256  // Response message of GetNebState rpc.
   257  message GetNebStateResponse {
   258  
   259      // Block chain id
   260      uint32 chain_id = 1;
   261  
   262      // Current neb tail hash
   263      string tail = 2;
   264  
   265      // Current neb lib hash
   266      string lib = 3;
   267  
   268      // Current neb tail block height
   269      uint64 height = 4;
   270  
   271      // The current neb protocol version.
   272      string protocol_version = 6;
   273  
   274      // The peer sync status.
   275      bool synchronized = 7;
   276  
   277      // neb version
   278      string version = 8;
   279  }
   280  
   281  // Response message of Accounts rpc.
   282  message AccountsResponse {
   283      // Account list
   284      repeated string addresses = 1;
   285  }
   286  
   287  // Request message of GetAccountState rpc.
   288  message GetAccountStateRequest {
   289      // Hex string of the account addresss.
   290      string address = 1;
   291  
   292      // block account state with height. If not specified, use 0 as tail height.
   293      uint64 height = 2;
   294  }
   295  
   296  // Response message of GetAccountState rpc.
   297  message GetAccountStateResponse {
   298      // Current balance in unit of 1/(10^18) nas.
   299      string balance = 1; // uint128, len=16
   300  
   301      // Current transaction count.
   302      uint64 nonce = 2;
   303  
   304      // Account type
   305      uint32 type = 3;
   306  }
   307  
   308  // Response message of Call rpc.
   309  message CallResponse {
   310      // result of smart contract method call.
   311      string result = 1;
   312  
   313      //execute error
   314      string execute_err = 2;
   315  
   316      //estimate gas used
   317      string estimate_gas = 3;
   318  }
   319  
   320  // ByBlockHeightRequest message
   321  message ByBlockHeightRequest {
   322      uint64 height = 1;
   323  }
   324  
   325  // Response message of GetDynastyRequest rpc
   326  message GetDynastyResponse {
   327  	repeated string miners = 1;
   328  }
   329  
   330  // Request message of SendTransaction rpc.
   331  message TransactionRequest {
   332  	// Hex string of the sender account addresss.
   333  	string from = 1;
   334  
   335      // Hex string of the receiver account addresss.
   336      string to = 2;
   337  
   338      // Amount of value sending with this transaction.
   339      string value = 3; // uint128, len=16
   340  
   341      // Transaction nonce.
   342      uint64 nonce = 4;
   343  
   344  	// gasPrice sending with this transaction.
   345  	string gas_price = 5; // uint128, len=16
   346  
   347  	// gasLimit sending with this transaction.
   348  	string gas_limit = 6; // uint128, len=16
   349  
   350  	// contract sending with this transaction
   351  	ContractRequest contract = 7;
   352  
   353      // binary data for transaction
   354      bytes binary = 10;
   355  
   356      // transaction payload type, enum:binary, deploy, call
   357      string type = 20;
   358  }
   359  
   360  message ContractRequest {
   361  	// contract source code.
   362  	string source = 1;
   363  
   364  	// contract source type, support javascript and typescript
   365  	string source_type = 2;
   366  
   367  	// call contract function name
   368  	string function = 3;
   369  
   370  	// the params of contract.
   371  	string args = 4;
   372  }
   373  
   374  // Request message of SendRawTransactionRequest rpc.
   375  message SendRawTransactionRequest {
   376  
   377      // Signed data of transaction
   378      bytes data = 1;
   379  }
   380  
   381  // Response message of SendTransaction rpc.
   382  message SendTransactionResponse {
   383      // Hex string of transaction hash.
   384      string txhash = 1;
   385  
   386      // Hex string of contract address if transaction is deploy type
   387      string contract_address = 2;
   388  }
   389  
   390  // Request message of GetBlockByHash rpc.
   391  message GetBlockByHashRequest {
   392      // Hex string of block hash.
   393      string hash = 1;
   394  
   395      // If true it returns the full transaction objects, if false only the hashes of the transactions.
   396      bool full_fill_transaction = 2;
   397  }
   398  
   399  // Request message of GetBlockByHeight rpc.
   400  message GetBlockByHeightRequest {
   401      // block height.
   402      uint64 height = 1;
   403  
   404      // If true it returns the full transaction objects, if false only the hashes of the transactions.
   405      bool full_fill_transaction = 2;
   406  }
   407  
   408  // Request message of GetTransactionByHash rpc.
   409  message GetTransactionByHashRequest {
   410      // Hex string of transaction hash.
   411      string hash = 1;
   412  }
   413  
   414  // Response message of Block.
   415  message BlockResponse {
   416  
   417      // Hex string of block hash.
   418      string hash = 1;
   419  
   420      // Hex string of block parent hash.
   421      string parent_hash = 2;
   422  
   423      // block height
   424      uint64 height = 3;
   425  
   426      // block nonce
   427      uint64 nonce = 4;
   428  
   429      // Hex string of coinbase address.
   430      string coinbase = 5;
   431  
   432      // block timestamp.
   433      int64 timestamp = 6;
   434  
   435      // block chain id
   436      uint32 chain_id = 7;
   437  
   438      // Hex string of state root.
   439      string state_root = 8;
   440  
   441      // Hex string of txs root.
   442      string txs_root = 9;
   443  
   444      // Hex string of event root.
   445      string events_root = 10;
   446  
   447      // Hex string of consensus root.
   448      consensuspb.ConsensusRoot consensus_root = 11;
   449  
   450      // Miner
   451      string miner = 12;
   452  
   453      //Random seed
   454      string randomSeed = 13;
   455  
   456      //vrf proof
   457      string randomProof = 14;
   458  
   459      // is finaliy
   460      bool is_finality = 15;
   461  
   462      // transaction slice
   463      repeated TransactionResponse transactions = 100;
   464  }
   465  
   466  // Response message of TransactionReceipt.
   467  message TransactionResponse {
   468  
   469      // Hex string of tx hash.
   470      string hash = 1;
   471  
   472      uint32 chainId = 2;
   473  
   474      // Hex string of the sender account addresss.
   475      string from = 3;
   476  
   477      // Hex string of the receiver account addresss.
   478      string to = 4;
   479  
   480      string value = 5;
   481  
   482      // Transaction nonce.
   483      uint64 nonce = 6;
   484  
   485      int64 timestamp = 7;
   486  
   487      string type = 8;
   488  
   489      bytes data = 9;
   490  
   491      string gas_price = 10;
   492  
   493      string gas_limit = 11;
   494  
   495      string contract_address = 12;
   496  
   497      // transaction status 0 failed, 1 success, 2 pending
   498      int32 status = 13;
   499  
   500      // transaction gas used
   501      string gas_used = 14;
   502  }
   503  
   504  message NewAccountRequest {
   505      string passphrase = 1;
   506  }
   507  
   508  message NewAccountResponse {
   509      string address = 1;
   510  }
   511  
   512  message UnlockAccountRequest {
   513      string address = 1;
   514      string passphrase = 2;
   515      uint64 duration = 3;
   516  }
   517  
   518  message UnlockAccountResponse {
   519      bool result = 1;
   520  }
   521  
   522  message LockAccountRequest {
   523      string address = 1;
   524  }
   525  
   526  message LockAccountResponse {
   527      bool result = 1;
   528  }
   529  
   530  message SignHashRequest {
   531  
   532      // sign address
   533      string address = 1;
   534  
   535      // sign msg
   536      bytes hash = 2;
   537  
   538      // sign algorithm
   539      uint32 alg = 3;
   540  }
   541  
   542  message SignHashResponse {
   543      bytes data = 1;
   544  }
   545  
   546  message SignTransactionPassphraseRequest {
   547  	// transaction struct
   548  	TransactionRequest transaction = 1;
   549  
   550      // from account passphrase
   551      string passphrase = 2;
   552  }
   553  
   554  message SignTransactionPassphraseResponse {
   555      bytes data = 1;
   556  }
   557  
   558  message SendTransactionPassphraseRequest {
   559  	// transaction struct
   560  	TransactionRequest transaction = 1;
   561  
   562      // from account passphrase
   563      string passphrase = 2;
   564  }
   565  
   566  message GasPriceResponse {
   567      string gas_price = 1;
   568  }
   569  
   570  // Request message of GetTransactionByHash rpc.
   571  message HashRequest {
   572      // Hex string of block/transaction hash.
   573      string hash = 1;
   574  }
   575  
   576  message GasResponse {
   577      string gas = 1;
   578      string err = 2;
   579  }
   580  
   581  message EventsResponse {
   582     repeated Event events = 1;
   583  }
   584  
   585  message Event {
   586      string topic = 1;
   587      string data = 2;
   588  }
   589  
   590  message PprofRequest {
   591      string listen = 1;
   592  }
   593  
   594  message PprofResponse {
   595      bool result = 1;
   596  }
   597  
   598  message GetConfigResponse {
   599      // Config
   600      nebletpb.Config config = 1;
   601  }
   602  
   603  message VerifySignatureRequest {
   604      string msg = 1;
   605      string signature = 2;
   606      string address = 3;
   607      uint32 alg = 4;
   608  }
   609  
   610  message VerifySignatureResponse {
   611      bool result = 1;
   612      string address = 2;
   613  }