diff --git a/CHANGELOG.md b/CHANGELOG.md index 51fe5b75..2bd78fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog - +## HEAD +- update docs ## 0.9.1 - upgrade to cosmos sdk 0.39.1 - fix empty account renewal diff --git a/x/configuration/alias.go b/x/configuration/alias.go index ff650d74..27ffe5ce 100644 --- a/x/configuration/alias.go +++ b/x/configuration/alias.go @@ -4,8 +4,10 @@ import "github.com/iov-one/iovns/x/configuration/types" // alias for types type ( - Config = types.Config // Config aliases types.Config - Fees = types.Fees // Fees aliases types.Fees + // Config aliases types.Config + Config = types.Config + // Fees aliases types.Fees + Fees = types.Fees ) // alias for consts @@ -21,6 +23,8 @@ const ( // function aliases var ( - NewFees = types.NewFees // NewFees aliases types.NewFees + // NewFees aliases types.NewFees + NewFees = types.NewFees + // RegisterCodec aliases types.RegisterCodec RegisterCodec = types.RegisterCodec ) diff --git a/x/configuration/client/cli/doc.go b/x/configuration/client/cli/doc.go new file mode 100644 index 00000000..dce217a9 --- /dev/null +++ b/x/configuration/client/cli/doc.go @@ -0,0 +1,2 @@ +// Package cli contains the cobra commands used to interact with the configuration module via CLI +package cli diff --git a/x/configuration/client/rest/doc.go b/x/configuration/client/rest/doc.go new file mode 100644 index 00000000..503ed71a --- /dev/null +++ b/x/configuration/client/rest/doc.go @@ -0,0 +1,2 @@ +// Package rest contains the handlers used to interact with the configuration module via REST +package rest diff --git a/x/configuration/client/rest/tx.go b/x/configuration/client/rest/tx.go index 434212c2..5d81cbd8 100644 --- a/x/configuration/client/rest/tx.go +++ b/x/configuration/client/rest/tx.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/x/auth/client/utils" - . "github.com/iov-one/iovns/x/configuration/types" + "github.com/iov-one/iovns/x/configuration/types" ) // handleTxRequest is a helper function that takes care of checking base requests, sdk messages, after verifying @@ -27,8 +27,8 @@ func handleTxRequest(cliCtx context.CLIContext, baseReq rest.BaseReq, msg sdk.Ms } type updateConfig struct { - BaseReq rest.BaseReq `json:"base_req"` - Message *MsgUpdateConfig `json:"message"` + BaseReq rest.BaseReq `json:"base_req"` + Message *types.MsgUpdateConfig `json:"message"` } func updateConfigHandler(cliCtx context.CLIContext) http.HandlerFunc { @@ -42,8 +42,8 @@ func updateConfigHandler(cliCtx context.CLIContext) http.HandlerFunc { } type updateFees struct { - BaseReq rest.BaseReq `json:"base_req"` - Message *MsgUpdateFees `json:"message"` + BaseReq rest.BaseReq `json:"base_req"` + Message *types.MsgUpdateFees `json:"message"` } func updateFeesHandler(cliCtx context.CLIContext) http.HandlerFunc { diff --git a/x/configuration/genesis.go b/x/configuration/genesis.go index ba462d24..9690dc4f 100644 --- a/x/configuration/genesis.go +++ b/x/configuration/genesis.go @@ -9,8 +9,10 @@ import ( // when the app is initialized, and it is used to marshal // the state when it needs to be exported. type GenesisState struct { + // Config contains the configuration Config types.Config `json:"config"` - Fees *types.Fees `json:"fees"` + // Fees contains the fees + Fees *types.Fees `json:"fees"` } // NewGenesisState is GenesisState constructor diff --git a/x/configuration/query.go b/x/configuration/query.go index cf1c4557..2d239c63 100644 --- a/x/configuration/query.go +++ b/x/configuration/query.go @@ -63,24 +63,30 @@ func NewQuerier(k Keeper) sdk.Querier { } } +// QueryConfiguration is the request model used to get the configuration type QueryConfiguration struct{} +// Use is a placeholder func (q *QueryConfiguration) Use() string { return "query-config" } +// Description is a placeholder func (q *QueryConfiguration) Description() string { return "return the current configuration" } +// Handler implements QueryHandler func (q *QueryConfiguration) Handler() QueryHandlerFunc { return queryConfigurationHandler } +// Validate implements QueryHandler func (q *QueryConfiguration) Validate() error { return nil } +// QueryPath implements QueryHandler func (q *QueryConfiguration) QueryPath() string { return "configuration" } @@ -96,28 +102,36 @@ func queryConfigurationHandler(ctx sdk.Context, _ []string, req abci.RequestQuer return respBytes, nil } +// QueryConfigurationResponse is the response returned after querying the configuration type QueryConfigurationResponse struct { + // Config represents the current configurations Config Config `json:"configuration"` } +// QueryFees is the request model used to get the current fees type QueryFees struct{} +// Use is a placeholder func (q *QueryFees) Use() string { return "query-fees" } +// Description is a placeholder func (q *QueryFees) Description() string { return "return the current fees" } +// Handler implements QueryHandler func (q *QueryFees) Handler() QueryHandlerFunc { return queryFeesHandler } +// Validate implements QueryHandler func (q *QueryFees) Validate() error { return nil } +// QueryPath implements QueryHandler func (q *QueryFees) QueryPath() string { return "fees" } @@ -132,6 +146,8 @@ func queryFeesHandler(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keep return respBytes, nil } +// QueryFeesResponse is returned after querying fees type QueryFeesResponse struct { + // Fees represents the current fees of the network Fees Fees `json:"fees"` } diff --git a/x/configuration/types/doc.go b/x/configuration/types/doc.go new file mode 100644 index 00000000..70bf41d2 --- /dev/null +++ b/x/configuration/types/doc.go @@ -0,0 +1,2 @@ +// Package types contains all the types used by the configuration module +package types diff --git a/x/configuration/types/fees.go b/x/configuration/types/fees.go index d11847df..0cf3b96a 100644 --- a/x/configuration/types/fees.go +++ b/x/configuration/types/fees.go @@ -16,35 +16,54 @@ func NewFees() *Fees { // processing different messages type Fees struct { // FeeCoinDenom defines the denominator of the coin used to process fees - FeeCoinDenom string `json:"fee_coin_denom"` + FeeCoinDenom string `json:"fee_coin_denom"` + // FeeCoinPrice defines the price of the coin FeeCoinPrice sdk.Dec `json:"fee_coin_price"` // FeeDefault is the parameter defining the default fee FeeDefault sdk.Dec `json:"fee_default"` // account fees - RegisterAccountClosed sdk.Dec `json:"register_account_closed"` - RegisterAccountOpen sdk.Dec `json:"register_account_open"` - TransferAccountClosed sdk.Dec `json:"transfer_account_closed"` - TransferAccountOpen sdk.Dec `json:"transfer_account_open"` + // RegisterAccountClosed is the fee to be paid to register an account in a closed domain + RegisterAccountClosed sdk.Dec `json:"register_account_closed"` + // RegisterAccountOpen is the fee to be paid to register an account in an open domain + RegisterAccountOpen sdk.Dec `json:"register_account_open"` + // TransferAccountClosed is the fee to be paid to register an account in a closed domain + TransferAccountClosed sdk.Dec `json:"transfer_account_closed"` + // TransferAccountOpen is the fee to be paid to register an account in an open domain + TransferAccountOpen sdk.Dec `json:"transfer_account_open"` + // ReplaceAccountResources is the fee to be paid to replace account's resources ReplaceAccountResources sdk.Dec `json:"replace_account_resources"` - AddAccountCertificate sdk.Dec `json:"add_account_certificate"` - DelAccountCertificate sdk.Dec `json:"del_account_certificate"` - SetAccountMetadata sdk.Dec `json:"set_account_metadata"` + // AddAccountCertificate is the fee to be paid to add a certificate to an account + AddAccountCertificate sdk.Dec `json:"add_account_certificate"` + // DelAccountCertificate is the feed to be paid to delete a certificate in an account + DelAccountCertificate sdk.Dec `json:"del_account_certificate"` + // SetAccountMetadata is the fee to be paid to set account's metadata + SetAccountMetadata sdk.Dec `json:"set_account_metadata"` // domain fees // Register domain - RegisterDomain1 sdk.Dec `json:"register_domain_1"` - RegisterDomain2 sdk.Dec `json:"register_domain_2"` - RegisterDomain3 sdk.Dec `json:"register_domain_3"` - RegisterDomain4 sdk.Dec `json:"register_domain_4"` - RegisterDomain5 sdk.Dec `json:"register_domain_5"` - RegisterDomainDefault sdk.Dec `json:"register_domain_default"` + // RegisterDomain1 is the fee to be paid to register a domain with one character + RegisterDomain1 sdk.Dec `json:"register_domain_1"` + // RegisterDomain2 is the fee to be paid to register a domain with two characters + RegisterDomain2 sdk.Dec `json:"register_domain_2"` + // RegisterDomain3 is the fee to be paid to register a domain with three characters + RegisterDomain3 sdk.Dec `json:"register_domain_3"` + // RegisterDomain4 is the fee to be paid to register a domain with four characters + RegisterDomain4 sdk.Dec `json:"register_domain_4"` + // RegisterDomain5 is the fee to be paid to register a domain with five characters + RegisterDomain5 sdk.Dec `json:"register_domain_5"` + // RegisterDomainDefault is the fee to be paid to register a domain with more than five characters + RegisterDomainDefault sdk.Dec `json:"register_domain_default"` + // RegisterDomainMultiplier is the multiplication applied to fees in register domain operations if they're of open type RegisterOpenDomainMultiplier sdk.Dec `json:"register_open_domain_multiplier"` // TransferDomain + // TransferDomainClosed is the fee to be paid to transfer a closed domain TransferDomainClosed sdk.Dec `json:"transfer_domain_closed"` - TransferDomainOpen sdk.Dec `json:"transfer_domain_open"` - // RenewDomain + // TransferDomainOpen is the fee to be paid to transfer open domains + TransferDomainOpen sdk.Dec `json:"transfer_domain_open"` + // RenewDomainOpen is the fee to be paid to renew an open domain RenewDomainOpen sdk.Dec `json:"renew_domain_open"` } +// Validate validates the fee object func (f *Fees) Validate() error { if f == nil { return fmt.Errorf("fees is nil") diff --git a/x/configuration/types/msgs.go b/x/configuration/types/msgs.go index 87fe3c82..37ea3c31 100644 --- a/x/configuration/types/msgs.go +++ b/x/configuration/types/msgs.go @@ -8,16 +8,21 @@ import ( // MsgUpdateConfig is used to update // configuration using a multisig strategy type MsgUpdateConfig struct { - Signer sdk.AccAddress + // Signer is the address of the entity who is doing the transaction + Signer sdk.AccAddress + // NewConfiguration contains the new configuration data NewConfiguration Config } var _ sdk.Msg = (*MsgUpdateConfig)(nil) +// Route implements sdk.Msg func (m MsgUpdateConfig) Route() string { return RouterKey } +// Type implements sdk.Msg func (m MsgUpdateConfig) Type() string { return "update_config" } +// ValidateBasic implements sdk.Msg func (m MsgUpdateConfig) ValidateBasic() error { if m.Signer.Empty() { return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "no signer specified") @@ -32,18 +37,23 @@ func (m MsgUpdateConfig) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleC func (m MsgUpdateConfig) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{m.Signer} } type MsgUpdateFees struct { - Fees *Fees + // Fees represent the new fees to apply + Fees *Fees + // Configurer is the address that is singing the message Configurer sdk.AccAddress } +// Route implements sdk.Msg func (m MsgUpdateFees) Route() string { return RouterKey } +// Type implements sdk.Msg func (m MsgUpdateFees) Type() string { return "update_fees" } +// ValidateBasic implements sdk.Msg func (m MsgUpdateFees) ValidateBasic() error { if m.Configurer.Empty() { return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "signer is missing") @@ -55,6 +65,8 @@ func (m MsgUpdateFees) ValidateBasic() error { return nil } +// GetSignBytes implements sdk.Msg func (m MsgUpdateFees) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) } +// GetSigners implements sdk.Msg func (m MsgUpdateFees) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{m.Configurer} } diff --git a/x/configuration/types/queries.go b/x/configuration/types/queries.go index bbc2ada7..7cd174fa 100644 --- a/x/configuration/types/queries.go +++ b/x/configuration/types/queries.go @@ -5,6 +5,7 @@ type QueryConfigResponse struct { Configuration Config `json:"configuration"` } +// QueryFeesResponse is the result returned after a query to the product fees type QueryFeesResponse struct { Fees *Fees `json:"fees"` } diff --git a/x/starname/alias.go b/x/starname/alias.go index 38fafdc1..3e44e0d8 100644 --- a/x/starname/alias.go +++ b/x/starname/alias.go @@ -21,11 +21,14 @@ const ( // aliasing for types type ( + // Keeper aliases the Keeper type Keeper = keeper.Keeper ) // aliasing for funcs var ( - NewKeeper = keeper.NewKeeper + // NewKeeper aliases keeper.NewKeeper + NewKeeper = keeper.NewKeeper + // RegisterCodec aliases types.RegisterCodec RegisterCodec = types.RegisterCodec ) diff --git a/x/starname/client/cli/doc.go b/x/starname/client/cli/doc.go new file mode 100644 index 00000000..cdcee71d --- /dev/null +++ b/x/starname/client/cli/doc.go @@ -0,0 +1,2 @@ +// Package cli contains the cobra commands used to interact with the starname module via CLI +package cli diff --git a/x/starname/client/cli/errors.go b/x/starname/client/cli/errors.go index e292d150..ef36bb68 100644 --- a/x/starname/client/cli/errors.go +++ b/x/starname/client/cli/errors.go @@ -7,7 +7,10 @@ import ( var ( // CLI module error codes being with 4xx - ErrCertificateNotProvided = sdkerrors.Register(types.ModuleName, 400, "provide certificate") + // ErrCertificateNotProvided is returned by the CLI when certificates are not provided + ErrCertificateNotProvided = sdkerrors.Register(types.ModuleName, 400, "provide certificate") + // ErrCertificatedProvidedOnlyOne is returned when multiple certs + key value certs are provided via CLI ErrCertificateProvideOnlyOne = sdkerrors.Register(types.ModuleName, 401, "provide either cert or cert-file") - ErrInvalidCertificate = sdkerrors.Register(types.ModuleName, 402, "invalid certificate") + // ErrInvalidCertificate is returned when the provided certificate is deemed to be invalid + ErrInvalidCertificate = sdkerrors.Register(types.ModuleName, 402, "invalid certificate") ) diff --git a/x/starname/client/rest/doc.go b/x/starname/client/rest/doc.go new file mode 100644 index 00000000..deb7a42b --- /dev/null +++ b/x/starname/client/rest/doc.go @@ -0,0 +1,2 @@ +// Package rest contains the http handlers used to interact with the starname module via RESt +package rest diff --git a/x/starname/controllers/account/account.go b/x/starname/controllers/account/account.go index 94c4b6fd..435be475 100644 --- a/x/starname/controllers/account/account.go +++ b/x/starname/controllers/account/account.go @@ -64,6 +64,7 @@ func (a *Account) MustNotExist() *Account { return a } +// ValidName asserts the account name is valid func (a *Account) ValidName() *Account { a.validators = append(a.validators, func(ctrl *Account) error { return a.validName() @@ -71,6 +72,7 @@ func (a *Account) ValidName() *Account { return a } +// NotExpired asserts the account is not expired func (a *Account) NotExpired() *Account { a.validators = append(a.validators, func(ctrl *Account) error { return ctrl.notExpired() @@ -78,6 +80,7 @@ func (a *Account) NotExpired() *Account { return a } +// Renewable asserts that the account is renewable func (a *Account) Renewable() *Account { a.validators = append(a.validators, func(ctrl *Account) error { return ctrl.renewable() @@ -85,6 +88,7 @@ func (a *Account) Renewable() *Account { return a } +// OwnedBy asserts that the account is owned by the provided address func (a *Account) OwnedBy(addr sdk.AccAddress) *Account { f := func(ctrl *Account) error { return ctrl.ownedBy(addr) @@ -93,6 +97,7 @@ func (a *Account) OwnedBy(addr sdk.AccAddress) *Account { return a } +// CertificateSizeNotExceeded asserts that the size of a cert is not beyond the limits func (a *Account) CertificateSizeNotExceeded(cert []byte) *Account { f := func(ctrl *Account) error { return ctrl.certSizeNotExceeded(cert) @@ -101,6 +106,7 @@ func (a *Account) CertificateSizeNotExceeded(cert []byte) *Account { return a } +// CertificateLimitNotExceeded asserts that the numbers of certificates in an account was not exceeded func (a *Account) CertificateLimitNotExceeded() *Account { a.validators = append(a.validators, func(ctrl *Account) error { return ctrl.certLimitNotExceeded() @@ -163,6 +169,7 @@ func (a *Account) ResourceLimitNotExceeded(resources []types.Resource) *Account return a } +// MetadataSizeNotExceeded asserts that the metadata size of an account was not exceeded func (a *Account) MetadataSizeNotExceeded(metadata string) *Account { a.validators = append(a.validators, func(ctrl *Account) error { return ctrl.metadataSizeNotExceeded(metadata) @@ -469,10 +476,6 @@ func (a *Account) resettableBy(addr sdk.AccAddress, reset bool) error { return nil } -func GracePeriodFinished(controller *Account) error { - return controller.gracePeriodFinished() -} - // gracePeriodFinished is the condition that checks if given account's grace period has finished func (a *Account) gracePeriodFinished() error { // require configuration diff --git a/x/starname/controllers/account/doc.go b/x/starname/controllers/account/doc.go new file mode 100644 index 00000000..0f40ed88 --- /dev/null +++ b/x/starname/controllers/account/doc.go @@ -0,0 +1,2 @@ +// Package account contains request verifiers used to interact with accounts in the starname module +package account diff --git a/x/starname/controllers/domain/doc.go b/x/starname/controllers/domain/doc.go new file mode 100644 index 00000000..29c7e2ba --- /dev/null +++ b/x/starname/controllers/domain/doc.go @@ -0,0 +1,2 @@ +// Package domain contains request verifiers used to interact with domain in the starname module +package domain diff --git a/x/starname/controllers/domain/domain.go b/x/starname/controllers/domain/domain.go index 52d48a55..d6874160 100644 --- a/x/starname/controllers/domain/domain.go +++ b/x/starname/controllers/domain/domain.go @@ -65,6 +65,7 @@ func (c *Domain) Validate() error { return nil } +// Admin asserts that the domain owner is the provided address func (c *Domain) Admin(addr sdk.AccAddress) *Domain { c.validators = append(c.validators, func(controller *Domain) error { return controller.isAdmin(addr) @@ -72,6 +73,7 @@ func (c *Domain) Admin(addr sdk.AccAddress) *Domain { return c } +// NotExpired asserts that the domain has not expired func (c *Domain) NotExpired() *Domain { c.validators = append(c.validators, func(controller *Domain) error { return controller.notExpired() @@ -119,6 +121,7 @@ func (c *Domain) DeletableBy(addr sdk.AccAddress) *Domain { return c } +// Transferable asserts the domain is transferable with the given flag func (c *Domain) Transferable(flag types.TransferFlag) *Domain { c.validators = append(c.validators, func(controller *Domain) error { return controller.transferable(flag) diff --git a/x/starname/doc.go b/x/starname/doc.go new file mode 100644 index 00000000..34f9f0b0 --- /dev/null +++ b/x/starname/doc.go @@ -0,0 +1,7 @@ +// Package starname contains all the handlers, types and state keepers of the starname module +// The starname module is the implementation of a blockchainized domain name system +// based on the concepts of domains, domains have owners and can be transferred +// Domains hold an entity called Account, which can be owned by another address +// transferred, and serves the purpose of mapping resources that can be associated +// with another entity +package starname diff --git a/x/starname/keeper/doc.go b/x/starname/keeper/doc.go new file mode 100644 index 00000000..c7a45253 --- /dev/null +++ b/x/starname/keeper/doc.go @@ -0,0 +1,3 @@ +// Package keeper contains the definition of the queries used to interact with the starname module +// and also the keeper object that takes care of modifying and reading the state of the module. +package keeper diff --git a/x/starname/keeper/executor/account.go b/x/starname/keeper/executor/account.go index 1cdecaf9..dba0e51d 100644 --- a/x/starname/keeper/executor/account.go +++ b/x/starname/keeper/executor/account.go @@ -25,6 +25,7 @@ type Account struct { k keeper.Keeper } +// Transfer transfers the account to the provided owner with information reset if reset is true func (a *Account) Transfer(newOwner sdk.AccAddress, reset bool) { if a.account == nil { panic("cannot transfer non specified account") @@ -42,6 +43,7 @@ func (a *Account) Transfer(newOwner sdk.AccAddress, reset bool) { a.store.Update(a.account) } +// UpdateMetadata updates account's metadata func (a *Account) UpdateMetadata(newMetadata string) { if a.account == nil { panic("cannot update metadata on non specified account") @@ -50,6 +52,7 @@ func (a *Account) UpdateMetadata(newMetadata string) { a.store.Update(a.account) } +// ReplaceResources replaces account's resources func (a *Account) ReplaceResources(newTargets []types.Resource) { if a.account == nil { panic("cannot replace targets on non specified account") @@ -58,6 +61,7 @@ func (a *Account) ReplaceResources(newTargets []types.Resource) { a.store.Update(a.account) } +// Renew renews an account func (a *Account) Renew() { if a.account == nil { panic("cannot renew a non specified account") @@ -70,6 +74,7 @@ func (a *Account) Renew() { a.store.Update(a.account) } +// Create creates an account func (a *Account) Create() { if a.account == nil { panic("cannot create a non specified account") @@ -77,6 +82,7 @@ func (a *Account) Create() { a.store.Create(a.account) } +// Delete deletes the account func (a *Account) Delete() { if a.account == nil { panic("cannot delete a non specified account") @@ -84,6 +90,7 @@ func (a *Account) Delete() { a.store.Delete(a.account.PrimaryKey()) } +// DeleteCertificate deletes the certificate of the account at the provided index func (a *Account) DeleteCertificate(index int) { if a.account == nil { panic("cannot delete certificate on a non specified account") @@ -92,6 +99,7 @@ func (a *Account) DeleteCertificate(index int) { a.store.Update(a.account) } +// AddCertificate adds a certificate to the account func (a *Account) AddCertificate(cert []byte) { if a.account == nil { panic("cannot add certificate on a non specified account") diff --git a/x/starname/keeper/executor/doc.go b/x/starname/keeper/executor/doc.go index d13d5ada..db7a7df0 100644 --- a/x/starname/keeper/executor/doc.go +++ b/x/starname/keeper/executor/doc.go @@ -1,2 +1,3 @@ -// Package executor implements wrappers around domain module keeper +// Package executor implements wrappers around starname module keeper +// that are used to perform actions on objects stored inside the crud.Store package executor diff --git a/x/starname/keeper/keeper.go b/x/starname/keeper/keeper.go index 7527055d..955ab5ca 100644 --- a/x/starname/keeper/keeper.go +++ b/x/starname/keeper/keeper.go @@ -66,11 +66,13 @@ func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, configKeeper Configurati return keeper } +// AccountStore returns the crud.Store used to interact with account objects func (k Keeper) AccountStore(ctx sdk.Context) crud.Store { store := crud.NewStore(ctx, k.StoreKey, k.Cdc, []byte{0x1}) return store } +// DomainStore returns the crud.Store used to interact with domain objects func (k Keeper) DomainStore(ctx sdk.Context) crud.Store { return crud.NewStore(ctx, k.StoreKey, k.Cdc, []byte{0x2}) } diff --git a/x/starname/keeper/queries.go b/x/starname/keeper/queries.go index 39228534..e5ed47c2 100644 --- a/x/starname/keeper/queries.go +++ b/x/starname/keeper/queries.go @@ -97,7 +97,7 @@ func (q *QueryAccountsInDomain) Handler() QueryHandlerFunc { return queryAccountsInDomainHandler } -// Validate implements iovns.QueryHandler +// Validate implements queries.QueryHandler func (q *QueryAccountsInDomain) Validate() error { if q.Domain == "" { return sdkerrors.Wrapf(types.ErrInvalidDomainName, "empty") @@ -113,7 +113,7 @@ func (q *QueryAccountsInDomain) Validate() error { return nil } -// QueryPath implements iovns.QueryHandler +// QueryPath implements queries.QueryHandler func (q *QueryAccountsInDomain) QueryPath() string { return "accountsInDomain" } @@ -194,12 +194,12 @@ func (q *QueryAccountsWithOwner) Handler() QueryHandlerFunc { return queryAccountsWithOwnerHandler } -// QueryPath implements iovns.QueryHandler +// QueryPath implements queries.QueryHandler func (q *QueryAccountsWithOwner) QueryPath() string { return "accountsWithOwner" } -// Validate implements iovns.QueryHandler +// Validate implements queries.QueryHandler func (q *QueryAccountsWithOwner) Validate() error { if q.Owner == nil { return sdkerrors.Wrapf(types.ErrInvalidOwner, "empty") @@ -292,12 +292,12 @@ func (q *QueryDomainsWithOwner) Handler() QueryHandlerFunc { return queryDomainsWithOwnerHandler } -// QueryPath implements iovns.QueryHandler +// QueryPath implements queries.QueryHandler func (q *QueryDomainsWithOwner) QueryPath() string { return "domainsWithOwner" } -// Validate implements iovns.QueryHandler +// Validate implements queries.QueryHandler func (q *QueryDomainsWithOwner) Validate() error { if q.Owner == nil { return sdkerrors.Wrapf(types.ErrInvalidOwner, "empty") @@ -391,7 +391,7 @@ func (q *QueryResolveAccount) Handler() QueryHandlerFunc { return queryResolveAccountHandler } -// Validate implements iovns.QueryHandler +// Validate implements queries.QueryHandler func (q *QueryResolveAccount) Validate() error { if q.Starname != "" && (q.Domain != "" || q.Name != "") { return types.ErrProvideStarnameOrDomainName @@ -416,7 +416,7 @@ func (q *QueryResolveAccount) Validate() error { return nil } -// QueryPath implements iovns.QueryHandler +// QueryPath implements queries.QueryHandler func (q *QueryResolveAccount) QueryPath() string { return "resolve" } @@ -476,12 +476,12 @@ func (q *QueryResolveDomain) Handler() QueryHandlerFunc { return queryResolveDomainHandler } -// QueryPath implements iovns.QueryHandler +// QueryPath implements queries.QueryHandler func (q *QueryResolveDomain) QueryPath() string { return "domainInfo" } -// Validate implements iovns.QueryHandler +// Validate implements queries.QueryHandler func (q *QueryResolveDomain) Validate() error { if q.Name == "" { return sdkerrors.Wrapf(types.ErrInvalidDomainName, "empty") @@ -530,11 +530,12 @@ type QueryResolveResource struct { Offset int `json:"offset"` } -// QueryPath implements iovns.QueryHandler +// QueryPath implements queries.QueryHandler func (q *QueryResolveResource) QueryPath() string { return "resourceAccounts" } +// Validate implements queries.QueryHandler func (q *QueryResolveResource) Validate() error { if q.Resource.Resource == "" { return sdkerrors.Wrapf(types.ErrInvalidResource, "empty resource") @@ -552,6 +553,7 @@ func (q *QueryResolveResource) Validate() error { return nil } +// Handler implements queries.QueryHandler func (q *QueryResolveResource) Handler() QueryHandlerFunc { return queryResourceAccountHandler } diff --git a/x/starname/types/doc.go b/x/starname/types/doc.go new file mode 100644 index 00000000..0edb09a2 --- /dev/null +++ b/x/starname/types/doc.go @@ -0,0 +1,2 @@ +// Package types contains the models, errors, names used by the starname module +package types diff --git a/x/starname/types/errors.go b/x/starname/types/errors.go index c0f40c0b..e8b2890d 100644 --- a/x/starname/types/errors.go +++ b/x/starname/types/errors.go @@ -40,7 +40,7 @@ var ErrInvalidResource = sdkerrors.Register(ModuleName, 10, "resource provided i // ErrDomainExpired is returned when actions are performed on expired domains var ErrDomainExpired = sdkerrors.Register(ModuleName, 11, "domain has expired") -// ErrDomainExpired is returned when actions are performed on not expired domains +// ErrDomainNotExpired is returned when actions are performed on not expired domains var ErrDomainNotExpired = sdkerrors.Register(ModuleName, 12, "domain has not expired") // ErrAccountExists is returned when a create action is done on an account that already exists @@ -88,6 +88,7 @@ var ErrClosedDomainAccExpire = sdkerrors.Register(ModuleName, 26, "accounts in c // ErrMaxRenewExceeded is returned when max renew time exceeded var ErrMaxRenewExceeded = sdkerrors.Register(ModuleName, 27, "max renew exceeded") +// ErrRenewalDeadlineExceeded is returned when the renewal deadline was surpassed var ErrRenewalDeadlineExceeded = sdkerrors.Register(ModuleName, 31, "renewal deadline was exceeded") // ----------- QUERY ---------- diff --git a/x/starname/types/msgs.go b/x/starname/types/msgs.go index 25e4ef27..7ec4a0d4 100644 --- a/x/starname/types/msgs.go +++ b/x/starname/types/msgs.go @@ -5,6 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/errors" ) +// MsgWithFeePayer abstracts the Msg type to support a fee payer +// which takes care of handling product fees type MsgWithFeePayer interface { sdk.Msg FeePayer() sdk.AccAddress @@ -21,13 +23,14 @@ type MsgAddAccountCertificates struct { // Owner is the owner of the account Owner sdk.AccAddress `json:"owner"` // NewCertificate is the new certificate to add - NewCertificate []byte `json:"new_certificate"` - FeePayerAddr sdk.AccAddress `json:"fee_payer"` + NewCertificate []byte `json:"new_certificate"` + // FeePayerAddr is the address of the entity that has to pay product fees + FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgAddAccountCertificates)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgAddAccountCertificates) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -84,13 +87,14 @@ type MsgDeleteAccountCertificate struct { // DeleteCertificate is the certificate to delete DeleteCertificate []byte `json:"delete_certificate"` // Owner is the owner of the account - Owner sdk.AccAddress `json:"owner"` + Owner sdk.AccAddress `json:"owner"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgDeleteAccountCertificate)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgDeleteAccountCertificate) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -144,13 +148,14 @@ type MsgDeleteAccount struct { // Name is the name of the account Name string `json:"name"` // Owner is the owner of the account - Owner sdk.AccAddress `json:"owner"` + Owner sdk.AccAddress `json:"owner"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgDeleteAccount)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgDeleteAccount) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -200,14 +205,17 @@ func (m *MsgDeleteAccount) GetSigners() []sdk.AccAddress { // MsgDeleteDomain is the request // model to delete a domain type MsgDeleteDomain struct { - Domain string `json:"domain"` - Owner sdk.AccAddress `json:"owner"` + // Domain is the domain to delete + Domain string `json:"domain"` + // Owner is the owner of the domain + Owner sdk.AccAddress `json:"owner"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgDeleteDomain)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgDeleteDomain) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -265,13 +273,14 @@ type MsgRegisterAccount struct { // Resources are the blockchain addresses of the account Resources []Resource `json:"resources"` // Broker is the account that facilitated the transaction - Broker sdk.AccAddress `json:"broker"` + Broker sdk.AccAddress `json:"broker"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgRegisterAccount)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgRegisterAccount) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -326,13 +335,14 @@ type MsgRegisterDomain struct { // DomainType defines the type of the domain DomainType DomainType `json:"type"` // Broker TODO document - Broker sdk.AccAddress `json:"broker" arg:"--broker" helper:"the broker"` + Broker sdk.AccAddress `json:"broker" arg:"--broker" helper:"the broker"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgRegisterDomain)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgRegisterDomain) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -384,13 +394,14 @@ type MsgRenewAccount struct { // Name is the name of the account Name string `json:"name"` // Signer is the signer of the request - Signer sdk.AccAddress `json:"signer"` + Signer sdk.AccAddress `json:"signer"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgRenewAccount)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgRenewAccount) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -436,13 +447,14 @@ type MsgRenewDomain struct { // Domain is the domain name to renew Domain string `json:"domain"` // Signer is the request signer - Signer sdk.AccAddress `json:"signer"` + Signer sdk.AccAddress `json:"signer"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgRenewDomain)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgRenewDomain) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -493,13 +505,14 @@ type MsgReplaceAccountResources struct { // NewResources are the new resources NewResources []Resource `json:"new_resources"` // Owner is the owner of the account - Owner sdk.AccAddress `json:"owner"` + Owner sdk.AccAddress `json:"owner"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgReplaceAccountResources)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgReplaceAccountResources) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -556,13 +569,14 @@ type MsgReplaceAccountMetadata struct { // we want to update or insert NewMetadataURI string `json:"new_metadata_uri"` // Owner is the owner of the account - Owner sdk.AccAddress `json:"owner"` + Owner sdk.AccAddress `json:"owner"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgReplaceAccountMetadata)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgReplaceAccountMetadata) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -619,14 +633,15 @@ type MsgTransferAccount struct { Owner sdk.AccAddress `json:"owner"` // NewOwner is the new owner of the account NewOwner sdk.AccAddress `json:"new_owner"` - // Reset indicates if the accounts content will be resetted - Reset bool `json:"reset"` + // Reset indicates if the accounts content will be reset + Reset bool `json:"reset"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgTransferAccount)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgTransferAccount) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr @@ -693,16 +708,21 @@ const ( // MsgTransferDomain is the request model // used to transfer a domain type MsgTransferDomain struct { - Domain string `json:"domain"` - Owner sdk.AccAddress `json:"owner"` - NewAdmin sdk.AccAddress `json:"new_admin"` - TransferFlag TransferFlag `json:"transfer_flag"` + // Domain is the name of the domain + Domain string `json:"domain"` + // Owner is the address of the owner of the domain + Owner sdk.AccAddress `json:"owner"` + // NewAdmin is the address of the entity that will own the domain + NewAdmin sdk.AccAddress `json:"new_admin"` + // TransferFlag is the flag used to determine how to transfer the domain and the related accounts + TransferFlag TransferFlag `json:"transfer_flag"` + // FeePayerAddr is the address of the entity that has to pay product fees FeePayerAddr sdk.AccAddress `json:"fee_payer"` } var _ MsgWithFeePayer = (*MsgTransferDomain)(nil) -// Route implements sdk.Msg +// FeePayer implements FeePayer interface func (m *MsgTransferDomain) FeePayer() sdk.AccAddress { if !m.FeePayerAddr.Empty() { return m.FeePayerAddr diff --git a/x/starname/types/types.go b/x/starname/types/types.go index e0f0ca68..0cb4addc 100644 --- a/x/starname/types/types.go +++ b/x/starname/types/types.go @@ -48,11 +48,14 @@ func (d *Domain) SecondaryKeys() []crud.SecondaryKey { return []crud.SecondaryKey{crud.NewSecondaryKey(DomainAdminIndex, d.Admin)} } +// DomainType defines the type of the domain type DomainType string const ( - OpenDomain DomainType = "open" - ClosedDomain = "closed" + // OpenDomain is the domain type in which an account owner is the only entity that can perform actions on the account + OpenDomain DomainType = "open" + // ClosedDomain is the domain type in which the domain owner has control over accounts too + ClosedDomain = "closed" ) func ValidateDomainType(typ DomainType) error {