syntax = "proto3";
package accounting;
option go_package = "github.com/nspcc-dev/neofs-api/accounting";

import "service/meta.proto";
import "service/verify.proto";
import "decimal/decimal.proto";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";

option (gogoproto.stable_marshaler_all) = true;

// Withdraw is a service that provides withdraw assets operations from the NeoFS
service Withdraw {
    // Get returns cheque if it was signed by inner ring nodes
    rpc Get(GetRequest) returns (GetResponse);
    // Put ask inner ring nodes to sign a cheque for withdraw invoke
    rpc Put(PutRequest) returns (PutResponse);
    // List shows all user's checks
    rpc List(ListRequest) returns (ListResponse);
    // Delete allows user to remove unused cheque
    rpc Delete(DeleteRequest) returns (DeleteResponse);
}

message Item {
    // ID is a cheque identifier
    bytes ID               = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false];
    // OwnerID is a wallet address
    bytes OwnerID          = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false];
    // Amount of funds
    decimal.Decimal Amount = 3;
    // Height is the neo blockchain height until the cheque is valid
    uint64 Height          = 4;
    // Payload contains cheque representation in bytes
    bytes Payload          = 5;
}

message GetRequest {
    // ID is cheque identifier
    bytes ID                                 = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false];
    // OwnerID is a wallet address
    bytes OwnerID                            = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false];
    // RequestMetaHeader contains information about request meta headers (should be embedded into message)
    service.RequestMetaHeader Meta           = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
    // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message)
    service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
}

message GetResponse {
    // Withdraw is cheque with meta information
    Item Withdraw = 1;
}

message PutRequest {
    // OwnerID is a wallet address
    bytes OwnerID                            = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false];
    // Amount of funds
    decimal.Decimal Amount                   = 2;
    // Height is the neo blockchain height until the cheque is valid
    uint64 Height                            = 3;
    // MessageID is a nonce for uniq request (UUIDv4)
    bytes MessageID                          = 4 [(gogoproto.customtype) = "MessageID", (gogoproto.nullable) = false];
    // RequestMetaHeader contains information about request meta headers (should be embedded into message)
    service.RequestMetaHeader Meta           = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
    // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message)
    service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
}
message PutResponse {
    // ID is cheque identifier
    bytes ID = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false];
}

message ListRequest {
    // OwnerID is a wallet address
    bytes OwnerID                            = 1 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false];
    // RequestMetaHeader contains information about request meta headers (should be embedded into message)
    service.RequestMetaHeader Meta           = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
    // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message)
    service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
}

message ListResponse {
    // Items is a set of cheques with meta information
    repeated Item Items = 1;
}

message DeleteRequest {
    // ID is cheque identifier
    bytes ID                                 = 1 [(gogoproto.customtype) = "ChequeID", (gogoproto.nullable) = false];
    // OwnerID is a wallet address
    bytes OwnerID                            = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false];
    // MessageID is a nonce for uniq request (UUIDv4)
    bytes MessageID                          = 3 [(gogoproto.customtype) = "MessageID", (gogoproto.nullable) = false];
    // RequestMetaHeader contains information about request meta headers (should be embedded into message)
    service.RequestMetaHeader Meta           = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
    // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message)
    service.RequestVerificationHeader Verify = 99 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
}

// DeleteResponse is empty
message DeleteResponse {}