github.com/s7techlab/cckit@v0.10.5/examples/token/service/allowance/allowance.proto (about)

     1  syntax = "proto3";
     2  
     3  option go_package = "github.com/s7techlab/cckit/examples/token/service/allowance";
     4  package examples.erc20_service.service.allowance;
     5  
     6  import "google/api/annotations.proto";
     7  import "google/protobuf/empty.proto";
     8  import "mwitkow/go-proto-validators/validator.proto";
     9  
    10  service AllowanceService {
    11    // Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transfersender.
    12    // This is zero by default.
    13    rpc GetAllowance (AllowanceRequest) returns (Allowance) {
    14      option (google.api.http) = {
    15        get: "/allowance/{owner_address}/{spender_address}/{token}"
    16      };
    17    }
    18  
    19    // Sets amount as the allowance of spender over the caller’s tokens.
    20    // Emits an ApprovalEvent
    21    rpc Approve (ApproveRequest) returns (Allowance) {
    22      option (google.api.http) = {
    23        post: "/approve"
    24      };
    25    }
    26    // Moves amount tokens from sender to recipient using the allowance mechanism.
    27    // Amount is then deducted from the caller’s allowance.
    28    // Emits TransferEvent
    29    rpc TransferFrom (TransferFromRequest) returns (TransferFromResponse) {
    30      option (google.api.http) = {
    31        post: "/transfer-from"
    32      };
    33    }
    34  }
    35  
    36  message AllowanceRequest {
    37    string owner_address = 1 [(validator.field) = {string_not_empty : true}];
    38    string spender_address = 2 [(validator.field) = {string_not_empty : true}];
    39    repeated string token = 3;
    40  }
    41  
    42  message ApproveRequest {
    43    string owner_address = 1 [(validator.field) = {string_not_empty : true}];
    44    string spender_address = 2 [(validator.field) = {string_not_empty : true}];
    45    uint64 amount = 3 [(validator.field) = {int_gt: 0}];
    46    repeated string token = 4;
    47  }
    48  
    49  message TransferFromRequest {
    50    string owner_address = 1 [(validator.field) = {string_not_empty : true}];
    51    string recipient_address = 2 [(validator.field) = {string_not_empty : true}];
    52    uint64 amount = 3 [(validator.field) = {int_gt: 0}];
    53    repeated string token = 4;
    54  }
    55  
    56  message TransferFromResponse {
    57    string owner_address = 1;
    58    string recipient_address = 2;
    59    repeated string token = 3;
    60    uint64 amount = 4;
    61  }
    62  
    63  // Allowance identifier
    64  message AllowanceId {
    65    string owner_address = 1;
    66    string spender_address = 2;
    67    repeated string token = 3;
    68  }
    69  
    70  // Allowance
    71  message Allowance {
    72    string  owner_address = 1;
    73    string  spender_address = 2;
    74    repeated string token = 3;
    75    uint64 amount = 4;
    76  }
    77  
    78  message Allowances {
    79    repeated Allowance items = 1;
    80  }
    81  
    82  // Approved event is emitted when Approve method has been invoked
    83  message Approved  {
    84    string owner_address = 1;
    85    string spender_address = 2;
    86    repeated string token = 3;
    87    uint64 amount = 4;
    88  }
    89  
    90  // TransferredFrom event is emitted when TransferFrom method has been invoked
    91  message TransferredFrom  {
    92    string owner_address = 1;
    93    string spender_address = 2;
    94    string recipient_address = 3;
    95    repeated string token = 4;
    96    uint64 amount = 5;
    97  }