syntax = "proto3";
package provenance.name.v1;

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

option go_package = "github.com/provenance-io/provenance/x/name/types";

option java_package        = "io.provenance.name.v1";
option java_multiple_files = true;

// Msg defines the bank Msg service.
service Msg {
  option (cosmos.msg.v1.service) = true;

  // BindName binds a name to an address under a root name.
  rpc BindName(MsgBindNameRequest) returns (MsgBindNameResponse);

  // DeleteName defines a method to verify a particular invariance.
  rpc DeleteName(MsgDeleteNameRequest) returns (MsgDeleteNameResponse);

  // ModifyName defines a method to modify the attributes of an existing name.
  rpc ModifyName(MsgModifyNameRequest) returns (MsgModifyNameResponse);

  // CreateRootName defines a governance method for creating a root name.
  rpc CreateRootName(MsgCreateRootNameRequest) returns (MsgCreateRootNameResponse);

  // UpdateParams is a governance proposal endpoint for updating the name module's params.
  rpc UpdateParams(MsgUpdateParamsRequest) returns (MsgUpdateParamsResponse);
}

// MsgBindNameRequest defines an sdk.Msg type that is used to add an address/name binding under an optional parent name.
// The record may optionally be restricted to prevent additional names from being added under this one without the
// owner signing the request.
message MsgBindNameRequest {
  option (cosmos.msg.v1.signer) = "parent";

  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // The parent record to bind this name under.
  NameRecord parent = 1 [(gogoproto.nullable) = false];
  // The name record to bind under the parent
  NameRecord record = 2 [(gogoproto.nullable) = false];
}

// MsgBindNameResponse defines the Msg/BindName response type.
message MsgBindNameResponse {}

// MsgDeleteNameRequest defines an sdk.Msg type that is used to remove an existing address/name binding.  The binding
// may not have any child names currently bound for this request to be successful. All associated attributes on account
// addresses will be deleted.
message MsgDeleteNameRequest {
  option (cosmos.msg.v1.signer) = "record";

  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // The record being removed
  NameRecord record = 1 [(gogoproto.nullable) = false];
}

// MsgDeleteNameResponse defines the Msg/DeleteName response type.
message MsgDeleteNameResponse {}

// MsgCreateRootNameRequest defines an sdk.Msg type to create a new root name
// that is controlled by a given owner and optionally restricted to the owner
// for the sole creation of sub names.
message MsgCreateRootNameRequest {
  option (cosmos.msg.v1.signer) = "authority";

  // The signing authority for the request
  string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
  // NameRecord is a structure used to bind ownership of a name hierarchy to a collection of addresses
  NameRecord record = 2;
}

// MsgCreateRootNameResponse defines Msg/CreateRootName response type.
message MsgCreateRootNameResponse {}

// MsgModifyNameRequest defines a governance method that is used to update an existing address/name binding.
message MsgModifyNameRequest {
  option (cosmos.msg.v1.signer) = "authority";

  // The address signing the message
  string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
  // The record being updated
  NameRecord record = 2 [(gogoproto.nullable) = false];
}

// MsgModifyNameResponse defines the Msg/ModifyName response type.
message MsgModifyNameResponse {}

// MsgUpdateParamsRequest is a request message for the UpdateParams endpoint.
message MsgUpdateParamsRequest {
  option (cosmos.msg.v1.signer) = "authority";

  // authority should be the governance module account address.
  string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

  // params are the new param values to set.
  Params params = 2 [(gogoproto.nullable) = false];
}

// MsgUpdateParamsResponse is a response message for the UpdateParams endpoint.
message MsgUpdateParamsResponse {}