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

import "gogoproto/gogo.proto";
import "iov/starname/v1beta1/types.proto";

option go_package="github.com/iov-one/starnamed/x/starname/types";

// Msg defines the starname Msg service.
service Msg {
    // AddAccountCertificate adds a certificate to an Account
    rpc AddAccountCertificate(MsgAddAccountCertificate) returns (MsgAddAccountCertificateResponse);
    // DeleteAccount registers a Domain
    rpc DeleteAccount(MsgDeleteAccount) returns (MsgDeleteAccountResponse);
    // DeleteAccountCertificate deletes a certificate from an account
    rpc DeleteAccountCertificate(MsgDeleteAccountCertificate) returns (MsgDeleteAccountCertificateResponse);
    // DeleteDomain registers a Domain
    rpc DeleteDomain(MsgDeleteDomain) returns (MsgDeleteDomainResponse);
    // RegisterAccount registers an Account
    rpc RegisterAccount(MsgRegisterAccount) returns (MsgRegisterAccountResponse);
    // RegisterDomain registers a Domain
    rpc RegisterDomain(MsgRegisterDomain) returns (MsgRegisterDomainResponse);
    // RenewAccount registers a Domain
    rpc RenewAccount(MsgRenewAccount) returns (MsgRenewAccountResponse);
    // RenewDomain registers a Domain
    rpc RenewDomain(MsgRenewDomain) returns (MsgRenewDomainResponse);
    // ReplaceAccountMetadata registers a Domain
    rpc ReplaceAccountMetadata(MsgReplaceAccountMetadata) returns (MsgReplaceAccountMetadataResponse);
    // ReplaceAccountResources registers a Domain
    rpc ReplaceAccountResources(MsgReplaceAccountResources) returns (MsgReplaceAccountResourcesResponse);
    // TransferAccount registers a Domain
    rpc TransferAccount(MsgTransferAccount) returns (MsgTransferAccountResponse);
    // TransferDomain registers a Domain
    rpc TransferDomain(MsgTransferDomain) returns (MsgTransferDomainResponse);
}

// MsgAddAccountCertificate is the message used when a user wants to add new certificates to his account
message MsgAddAccountCertificate {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Owner is the owner of the account
    string owner = 3 [
        (gogoproto.moretags) = "yaml:\"owner\""
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // NewCertificate is the new certificate to add
    bytes new_certificate = 5 [(gogoproto.moretags) = "yaml:\"new_certificate\""];
}
// MsgAddAccountCertificateResponse returns an empty response.
message MsgAddAccountCertificateResponse{
}

// MsgDeleteAccountCertificate is the request model used to remove certificates from an account
message MsgDeleteAccountCertificate {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Owner is the owner of the account
    string owner = 3 [
        (gogoproto.moretags) = "yaml:\"owner\""
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // DeleteCertificate is the certificate to delete
    bytes delete_certificate = 5 [(gogoproto.moretags) = "yaml:\"delete_certificate\""];
}
// MsgDeleteAccountCertificateResponse returns an empty response.
message MsgDeleteAccountCertificateResponse {
}

// MsgDeleteAccount is the request model used to delete an account
message MsgDeleteAccount {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Owner is the owner of the account
    string owner = 3 [
        (gogoproto.moretags) = "yaml:\"owner\""
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
}
// MsgDeleteAccountResponse returns an empty response.
message MsgDeleteAccountResponse {
}

// MsgDeleteDomain is the request model to delete a domain
message MsgDeleteDomain {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Owner is the owner of the account
    string owner = 2 [
        (gogoproto.moretags) = "yaml:\"owner\""
   ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 3 [
        (gogoproto.moretags) = "yaml:\"payer\""
   ];
}
// MsgDeleteDomainResponse returns an empty response.
message MsgDeleteDomainResponse {
}

// MsgRegisterAccount is the request model used to register new accounts
message MsgRegisterAccount {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Owner is the owner of the account
    string owner = 3 [
        (gogoproto.moretags) = "yaml:\"owner\""
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // Broker is the account that facilitated the transaction
    string broker = 5 [
        (gogoproto.moretags) = "yaml:\"broker\""
    ];
    // Registerer is the user who registers this account
    string registerer = 6 [
         (gogoproto.moretags) = "yaml:\"registerer\""
    ];
    // Resources are the blockchain addresses of the account
    repeated Resource resources = 7 [(gogoproto.moretags) = "yaml:\"resources\""];
}
// MsgRegisterAccountResponse returns an empty response.
message MsgRegisterAccountResponse {
}

// MsgRegisterDomain is the request used to register new domains
message MsgRegisterDomain {
    string name = 1 [(gogoproto.moretags) = "yaml:\"name\""];
    string admin = 2 [
        (gogoproto.moretags) = "yaml:\"admin\""
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 3 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // Broker is the account that facilitated the transaction
    string broker = 4 [
        (gogoproto.moretags) = "yaml:\"broker\""
    ];
    // DomainType defines the type of the domain
    string domain_type = 5 [
        (gogoproto.casttype) = "DomainType",
        (gogoproto.moretags) = "yaml:\"domain_type"
    ];
}
// MsgRegisterDomainResponse returns an empty response.
message MsgRegisterDomainResponse{
}

// MsgRenewAccount is the request model used to renew accounts
message MsgRenewAccount {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Signer is the signer of the request
    string signer = 3 [
        (gogoproto.moretags) = "yaml:\"signer\""
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
}
// MsgRenewAccountResponse returns an empty response.
message MsgRenewAccountResponse {
}

// MsgRenewDomain is the request model used to renew a domain
message MsgRenewDomain {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Signer is the signer of the request
    string signer = 2 [
        (gogoproto.moretags) = "yaml:\"signer\""
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 3 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
}
// MsgRegisterDomain returns an empty response.
message MsgRenewDomainResponse {
}

// MsgReplaceAccountResources is the request model used to renew resources associated with an account
message MsgReplaceAccountResources {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Owner is the owner of the account
    string owner = 3 [
        (gogoproto.moretags) = "yaml:\"owner"
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // NewResources are the new resources
    repeated Resource new_resources = 5 [
        (gogoproto.moretags) = "yaml:\"new_resources"
    ];
}
// MsgReplaceAccountResourcesResponse
message MsgReplaceAccountResourcesResponse {
}

// MsgReplaceAccountMetadata is the function used to set accounts metadata
message MsgReplaceAccountMetadata {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Owner is the owner of the account
    string owner = 3 [
        (gogoproto.moretags) = "yaml:\"owner"
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // NewMetadataURI is the metadata URI of the account
    // we want to update or insert
    string new_metadata_uri = 5 [
       (gogoproto.moretags) = "yaml:\"new_metadata_uri\"",
       (gogoproto.customname) = "NewMetadataURI"
    ];
}
// MsgReplaceAccountMetadataResponse returns an empty response.
message MsgReplaceAccountMetadataResponse {
}

// MsgTransferAccount is the request model used to transfer accounts
message MsgTransferAccount {
    // Domain is the domain of the account
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Name is the name of the account
    string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
    // Owner is the owner of the account
    string owner = 3 [
        (gogoproto.moretags) = "yaml:\"owner"
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 4 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // NewOwner is the new owner of the account
    string new_owner = 5 [
        (gogoproto.moretags) = "yaml:\"new_owner"
    ];
    // ToReset if true, removes all old data from account
    bool reset = 6 [
        (gogoproto.moretags) = "yaml:\"reset",
        (gogoproto.customname) = "ToReset"
    ];
}
// MsgTransferAccountResponse returns an empty response.
message MsgTransferAccountResponse {
}

// MsgTransferDomain is the request model used to transfer a domain
message MsgTransferDomain {
    // Domain is the name of the domain
    string domain = 1 [(gogoproto.moretags) = "yaml:\"domain\""];
    // Owner is the owner of the domain
    string owner = 2 [
        (gogoproto.moretags) = "yaml:\"owner"
    ];
    // Payer is the address of the entity that pays the product and transaction fees
    string payer = 3 [
        (gogoproto.moretags) = "yaml:\"payer\""
    ];
    // NewAdmin is the  new owner of the domain
    string new_admin = 4 [
        (gogoproto.moretags) = "yaml:\"new_admin"
    ];
    // TransferFlag controls the operations that occurs on a domain's accounts
    int64 transfer_flag = 5 [
        (gogoproto.casttype) = "TransferFlag",
        (gogoproto.moretags) = "yaml:\"transfer_flag"
    ];
}
// MsgTransferDomainResponse returns an empty response.
message MsgTransferDomainResponse {
}

message MsgSignText {
    string message = 1;
    string signer = 2;
}
