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

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

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

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

// Params defines the set of params for the name module.
message Params {
  // maximum length of name segment to allow
  uint32 max_segment_length = 1;
  // minimum length of name segment to allow
  uint32 min_segment_length = 2;
  // maximum number of name segments to allow.  Example: `foo.bar.baz` would be 3
  uint32 max_name_levels = 3;
  // determines if unrestricted name keys are allowed or not
  bool allow_unrestricted_names = 4;
}

// NameRecord is a structure used to bind ownership of a name hierarchy to a collection of addresses
message NameRecord {
  option (cosmos.msg.v1.signer) = "address";

  option (gogoproto.goproto_stringer) = false;

  // the bound name
  string name = 1;
  // the address the name resolved to
  string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
  // whether owner signature is required to add sub-names
  bool restricted = 3;
}

// CreateRootNameProposal details a proposal 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.
// Deprecated: This legacy proposal is deprecated in favor of Msg-based gov
// proposals, see MsgCreateRootNameRequest.
message CreateRootNameProposal {
  option deprecated                   = true;
  option (gogoproto.equal)            = false;
  option (gogoproto.goproto_getters)  = false;
  option (gogoproto.goproto_stringer) = false;

  // proposal title
  string title = 1;
  // proposal description
  string description = 2;
  // the bound name
  string name = 3;
  // the address the name will resolve to
  string owner = 4;
  // a flag that indicates if an owner signature is required to add sub-names
  bool restricted = 5;
}

// Event emitted when name is bound.
message EventNameBound {
  string address    = 1;
  string name       = 2;
  bool   restricted = 3;
}

// Event emitted when name is unbound.
message EventNameUnbound {
  string address    = 1;
  string name       = 2;
  bool   restricted = 3;
}

// Event emitted when name is updated.
message EventNameUpdate {
  string address    = 1;
  string name       = 2;
  bool   restricted = 3;
}

// EventNameParamsUpdated event emitted when name params are updated.
message EventNameParamsUpdated {
  string allow_unrestricted_names = 1;
  string max_name_levels          = 2;
  string min_segment_length       = 3;
  string max_segment_length       = 4;
}