github.com/s7techlab/cckit@v0.10.5/examples/token/service/balance/balance.proto (about) 1 syntax = "proto3"; 2 3 option go_package = "github.com/s7techlab/cckit/examples/token/service/balance"; 4 package examples.erc20_service.service.balance; 5 6 import "google/api/annotations.proto"; 7 import "google/protobuf/empty.proto"; 8 import "mwitkow/go-proto-validators/validator.proto"; 9 10 // Balance 11 service BalanceService { 12 // Returns the amount of tokens owned by account. 13 rpc GetBalance (GetBalanceRequest) returns (Balance) { 14 option (google.api.http) = { 15 get: "/token/balances/{address}/{token}" 16 }; 17 } 18 19 rpc ListBalances (google.protobuf.Empty) returns (Balances) { 20 option (google.api.http) = { 21 get: "/token/balances" 22 }; 23 } 24 25 rpc ListAddressBalances (ListAddressBalancesRequest) returns (Balances) { 26 option (google.api.http) = { 27 get: "/token/balances/{address}" 28 }; 29 } 30 31 // Moves amount tokens from the caller’s account to recipient. 32 // Returns transfer details 33 rpc Transfer (TransferRequest) returns (TransferResponse) { 34 option (google.api.http) = { 35 post: "/token/transfer" 36 body: "*" 37 }; 38 } 39 } 40 41 message GetBalanceRequest { 42 string address = 1 [(validator.field) = {string_not_empty : true}]; 43 repeated string token = 2; 44 } 45 46 message ListAddressBalancesRequest { 47 string address = 1 [(validator.field) = {string_not_empty : true}]; 48 } 49 50 message TransferRequest { 51 string recipient_address = 1 [(validator.field) = {string_not_empty : true}]; 52 repeated string token = 2; 53 uint64 amount = 3 [(validator.field) = {int_gt: 0}]; 54 repeated AddMetaRequest meta = 4; 55 } 56 57 message TransferResponse { 58 string sender_address = 1; 59 string recipient_address = 2; 60 repeated string token = 3; 61 uint64 amount = 4; 62 repeated Meta meta = 5; 63 } 64 65 // Balance identifier 66 message BalanceId { 67 string address = 1; 68 repeated string token = 2; 69 } 70 71 // Balance 72 message Balance { 73 string address = 1; 74 repeated string token = 2; 75 uint64 amount = 3; 76 } 77 78 // List 79 message Balances { 80 repeated Balance items = 1; 81 } 82 83 enum BalanceOperationType { 84 BALANCE_OPERATION_UNKNOWN = 0; 85 BALANCE_OPERATION_SET = 1; 86 BALANCE_OPERATION_ADD = 2; 87 BALANCE_OPERATION_SUB = 3; 88 BALANCE_OPERATION_TRANSFER = 4; 89 } 90 91 message BalanceOperation { 92 string sender_address = 1; 93 string recipient_address = 2; 94 repeated string token = 3; 95 uint64 amount = 4; 96 } 97 98 // Transferred event is emitted when Transfer method has been invoked 99 message Transferred { 100 string sender_address = 1; 101 string recipient_address = 2; 102 repeated string token = 3; 103 uint64 amount = 4; 104 repeated Meta meta = 5; 105 } 106 107 message AddMetaRequest { 108 string key = 1 [(validator.field) = {string_not_empty : true}]; 109 string value = 2 [(validator.field) = {string_not_empty : true}]; 110 } 111 112 message Meta { 113 string key = 1; 114 string value = 2; 115 }