syntax = "proto3";
package starnamed.x.escrow.v1beta1;

import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/iov-one/starnamed/x/escrow/types";
option (gogoproto.goproto_getters_all) = false;

// Msg defines the escrow Msg service
service Msg {
    // CreateEscrow defines a method for creating an escrow
    rpc CreateEscrow(MsgCreateEscrow) returns (MsgCreateEscrowResponse);

    // UpdateEscrow defines a method for updating an escrow
    rpc UpdateEscrow(MsgUpdateEscrow) returns (MsgUpdateEscrowResponse);

    // TransferToEscrow defines a method for a buyer to transfer funds to the escrow
    rpc TransferToEscrow(MsgTransferToEscrow) returns (MsgTransferToEscrowResponse);

    // RefundEscrow defines a method for the seller to return the assets locked in the escrow
    rpc RefundEscrow(MsgRefundEscrow) returns (MsgRefundEscrowResponse);
}

// MsgCreateEscrow defines a message to create an escrow
message MsgCreateEscrow {
    string seller = 1;
    string fee_payer = 2;
    google.protobuf.Any object = 3 [ (cosmos_proto.accepts_interface) = "TransferableObject" ];
    repeated cosmos.base.v1beta1.Coin price = 4 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ];
    uint64 deadline = 5;
}

// MsgCreateEscrowResponse defines the Msg/CreateEscrow response type
message MsgCreateEscrowResponse {
    string id = 1;
}

// MsgUpdateEscrow defines a message to update an escrow
message MsgUpdateEscrow {
    string id = 1;
    string updater = 2;
    string fee_payer = 3;
    string seller = 4;
    repeated cosmos.base.v1beta1.Coin price = 5[ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ];
    uint64 deadline = 6;
}

// MsgUpdateEscrowResponse defines the Msg/UpdateEscrow response type
message MsgUpdateEscrowResponse {}

message MsgTransferToEscrow {
    string id = 1;
    string sender = 2;
    string fee_payer = 3;
    repeated cosmos.base.v1beta1.Coin amount = 4 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ];
}

message MsgTransferToEscrowResponse {
}

message MsgRefundEscrow {
    string id = 1;
    string sender = 2;
    string fee_payer = 3;
}

message MsgRefundEscrowResponse {}
