Skip to content

Commit

Permalink
chore: update docs (#352)
Browse files Browse the repository at this point in the history
* chore: update docs

* chore: update CHANGELOG.md

* chore: update docs (2)
  • Loading branch information
fdymylja authored Sep 16, 2020
1 parent a0048b4 commit cc21950
Show file tree
Hide file tree
Showing 29 changed files with 210 additions and 80 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

## HEAD
- update docs
## 0.9.1
- upgrade to cosmos sdk 0.39.1
- fix empty account renewal
Expand Down
10 changes: 7 additions & 3 deletions x/configuration/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
2 changes: 2 additions & 0 deletions x/configuration/client/cli/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package cli contains the cobra commands used to interact with the configuration module via CLI
package cli
2 changes: 2 additions & 0 deletions x/configuration/client/rest/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package rest contains the handlers used to interact with the configuration module via REST
package rest
10 changes: 5 additions & 5 deletions x/configuration/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion x/configuration/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions x/configuration/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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"`
}
2 changes: 2 additions & 0 deletions x/configuration/types/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package types contains all the types used by the configuration module
package types
51 changes: 35 additions & 16 deletions x/configuration/types/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 14 additions & 2 deletions x/configuration/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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} }
1 change: 1 addition & 0 deletions x/configuration/types/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
5 changes: 4 additions & 1 deletion x/starname/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 2 additions & 0 deletions x/starname/client/cli/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package cli contains the cobra commands used to interact with the starname module via CLI
package cli
7 changes: 5 additions & 2 deletions x/starname/client/cli/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
2 changes: 2 additions & 0 deletions x/starname/client/rest/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package rest contains the http handlers used to interact with the starname module via RESt
package rest
11 changes: 7 additions & 4 deletions x/starname/controllers/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,31 @@ 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()
})
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()
})
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()
})
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)
Expand All @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit cc21950

Please sign in to comment.