syntax = "proto3";
package band.tss.v1beta1;

import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";

import "band/tss/v1beta1/tss.proto";
import "band/tss/v1beta1/genesis.proto";

option go_package = "github.com/bandprotocol/chain/v3/x/tss/types";

// Msg defines the tss Msg service.
service Msg {
  option (cosmos.msg.v1.service) = true;
  // SubmitDKGRound1 submits dkg for computing round 1.
  rpc SubmitDKGRound1(MsgSubmitDKGRound1) returns (MsgSubmitDKGRound1Response);

  // SubmitDKGRound2 submits dkg for computing round 2.
  rpc SubmitDKGRound2(MsgSubmitDKGRound2) returns (MsgSubmitDKGRound2Response);

  // Complain submits proof for complaining malicious.
  rpc Complain(MsgComplain) returns (MsgComplainResponse);

  // Confirm submits own signature for proof that it can derive the secret.
  rpc Confirm(MsgConfirm) returns (MsgConfirmResponse);

  // SubmitDEs submits list of pre-commits DE for signing process.
  rpc SubmitDEs(MsgSubmitDEs) returns (MsgSubmitDEsResponse);

  // ResetDE resets the submitted DEs that being stored on chain.
  rpc ResetDE(MsgResetDE) returns (MsgResetDEResponse);

  // SubmitSignature submits signature on task participant need to do.
  rpc SubmitSignature(MsgSubmitSignature) returns (MsgSubmitSignatureResponse);

  // UpdateParams defines a governance operation for updating the x/tss module
  // parameters.
  rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgSubmitDKGRound1 is the Msg/MsgSubmitDKGRound1 request type.
message MsgSubmitDKGRound1 {
  option (cosmos.msg.v1.signer) = "sender";
  option (amino.name)           = "tss/MsgSubmitDKGRound1";

  // group_id is ID of the group.
  uint64 group_id = 1
      [(gogoproto.customname) = "GroupID", (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.GroupID"];
  // round1_info is all data that require to handle round 1.
  Round1Info round1_info = 2 [(gogoproto.nullable) = false];
  // sender is the user address that submits the group creation information;
  // must be a member of this group.
  string sender = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgSubmitDKGRound1Response is the Msg/SubmitDKGRound1 response type.
message MsgSubmitDKGRound1Response {}

// MsgSubmitDKGRound2 is the Msg/SubmitDKGRound2 request type.
message MsgSubmitDKGRound2 {
  option (cosmos.msg.v1.signer) = "sender";
  option (amino.name)           = "tss/MsgSubmitDKGRound2";

  // group_id is ID of the group.
  uint64 group_id = 1
      [(gogoproto.customname) = "GroupID", (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.GroupID"];
  // round2_info is all data that is required to handle round 2.
  Round2Info round2_info = 2 [(gogoproto.nullable) = false];
  // sender is the user address that submits the group creation information;
  // must be a member of this group.
  string sender = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgSubmitDKGRound2Response is response data for MsgSubmitDKGRound2 message
message MsgSubmitDKGRound2Response {}

// MsgComplain is a message used to complain about malicious actors in the group.
message MsgComplain {
  option (cosmos.msg.v1.signer) = "sender";
  option (amino.name)           = "tss/MsgComplaint";

  // group_id is ID of the group.
  uint64 group_id = 1
      [(gogoproto.customname) = "GroupID", (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.GroupID"];
  // complaints is a list of complaints.
  repeated Complaint complaints = 2 [(gogoproto.nullable) = false];
  // sender is the user address that submits the group creation information;
  // must be a member of this group.
  string sender = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgComplainResponse is response data for MsgComplain message
message MsgComplainResponse {}

// MsgConfirm is a message used to confirm own public key.
message MsgConfirm {
  option (cosmos.msg.v1.signer) = "sender";
  option (amino.name)           = "tss/MsgConfirm";

  // group_id is ID of the group.
  uint64 group_id = 1
      [(gogoproto.customname) = "GroupID", (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.GroupID"];
  // member_id is ID of the sender.
  uint64 member_id = 2
      [(gogoproto.customname) = "MemberID", (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.MemberID"];
  // own_pub_key_sig is a signature of the member_i on its own PubKey to confirm
  // that the address is able to derive the PubKey.
  bytes own_pub_key_sig = 3 [(gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.Signature"];
  // sender is the user address that submits the group creation information;
  // must be a member of this group.
  string sender = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgConfirmResponse is response data for MsgConfirm message
message MsgConfirmResponse {}

// MsgSubmitDEs is a message used to submit a list of DEs.
message MsgSubmitDEs {
  option (cosmos.msg.v1.signer) = "sender";
  option (amino.name)           = "tss/MsgSubmitDEs";

  // des is a list of DE objects.
  repeated DE des = 1 [(gogoproto.customname) = "DEs", (gogoproto.nullable) = false];
  // sender is the user address that submits DE objects.
  string sender = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgSubmitDEsResponse is response data for MsgSubmitDEs message
message MsgSubmitDEsResponse {}

// MsgResetDE is a message used to reset the DEs that being stored on chain.
message MsgResetDE {
  option (cosmos.msg.v1.signer) = "sender";
  option (amino.name)           = "tss/MsgResetDE";

  // sender is the user address that request for resetting DEs.
  string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgResetDEResponse is response data for MsgResetDE message
message MsgResetDEResponse {}

// MsgSubmitSignature is a message used to submitting signature data.
message MsgSubmitSignature {
  option (cosmos.msg.v1.signer) = "signer";
  option (amino.name)           = "tss/MsgSubmitSignature";

  // signing_id is the unique identifier of the signing process.
  uint64 signing_id = 1 [
    (gogoproto.customname) = "SigningID",
    (gogoproto.casttype)   = "github.com/bandprotocol/chain/v3/pkg/tss.SigningID"
  ];
  // member_id is the unique identifier of the signer in the group.
  uint64 member_id = 2
      [(gogoproto.customname) = "MemberID", (gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.MemberID"];
  // signature is the signature produced by the signer.
  bytes signature = 3 [(gogoproto.casttype) = "github.com/bandprotocol/chain/v3/pkg/tss.Signature"];
  // signer is the address who signs a message; must be a member of the group.
  string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgSubmitSignatureResponse is response data for MsgSubmitSignature message
message MsgSubmitSignatureResponse {}

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
  option (cosmos.msg.v1.signer) = "authority";
  option (amino.name)           = "tss/MsgUpdateParams";

  // params defines the x/tss parameters to update.
  Params params = 1 [(gogoproto.nullable) = false];
  // authority is the address of the governance account.
  string authority = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}
