keeper

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const RegexMatchAll = "^(.*?)?"
View Source
const RegexMatchNothing = "$^"

Variables

View Source
var (
	// DomainStorePrefix is the prefix used to define the prefixed store containing domain data
	DomainStorePrefix = []byte{0x00}
	// AccountPrefixStore is the prefix used to define the prefixed store containing account data
	AccountStorePrefix = []byte{0x01}
	// IndexStorePrefix is the prefix used to defines the prefixed store containing indexing data
	IndexStorePrefix = []byte{0x02}
)
View Source
var AliceKey types.AccAddress = addrs[0]
View Source
var BobKey types.AccAddress = addrs[1]
View Source
var CharlieKey types.AccAddress = addrs[2]

Functions

func AvailableQueries

func AvailableQueries() []iovns.QueryHandler

AvailableQueries returns the list of available queries in the module

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

NewQuerier builds the query handler for the module

func NewTestCodec

func NewTestCodec() *codec.Codec

NewTestCodec generates aliceAddr mock codec for keeper module

func NewTestKeeper

func NewTestKeeper(t testing.TB, isCheckTx bool) (Keeper, sdk.Context, *Mocks)

NewTestKeeper generates aliceAddr keeper and aliceAddr context from it

func RunTests added in v0.3.0

func RunTests(t *testing.T, tests map[string]SubTest)

runTests run tests cases after generating a new keeper and context for each test case

Types

type ConfigurationKeeper

type ConfigurationKeeper interface {
	// GetFees gets the fees
	GetFees(ctx sdk.Context) *configuration.Fees
	// GetConfiguration returns the configuration
	GetConfiguration(ctx sdk.Context) configuration.Config
	// IsOwner returns if the provided address is an owner or not
	IsOwner(ctx sdk.Context, addr sdk.AccAddress) bool
	// GetValidDomainNameRegexp returns the regular expression that aliceAddr domain name must match
	// in order to be valid
	GetValidDomainNameRegexp(ctx sdk.Context) string
	// GetDomainRenewDuration returns the default duration of aliceAddr domain renewal
	GetDomainRenewDuration(ctx sdk.Context) time.Duration
	// GetDomainGracePeriod returns the grace period duration
	GetDomainGracePeriod(ctx sdk.Context) time.Duration
}

ConfigurationKeeper defines the behaviour of the configuration state checks

type ConfigurationSetter added in v0.3.0

type ConfigurationSetter interface {
	SetConfig(ctx types.Context, config configuration.Config)
	SetFees(ctx types.Context, fees *configuration.Fees)
}

since the exposed interface for configuration keeper does not include set config as the domain module should not be able to change configuration state, then only in test cases we expose this method

func GetConfigSetter added in v0.3.0

func GetConfigSetter(keeper ConfigurationKeeper) ConfigurationSetter

getConfigSetter exposes the configurationSetter interface allowing the module to set configuration state, this should only be used for tests and will panic if the keeper provided can not be cast to configurationSetter

type Keeper

type Keeper struct {
	// external keepers
	ConfigurationKeeper ConfigurationKeeper
	SupplyKeeper        SupplyKeeper
	// contains filtered or unexported fields
}

Keeper of the domain store TODO split this keeper in sub-struct in order to avoid possible mistakes with keys and not clutter the exposed methods

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, configKeeper ConfigurationKeeper, supply SupplyKeeper, paramspace ParamSubspace) Keeper

NewKeeper creates aliceAddr domain keeper

func (Keeper) AddAccountCertificate

func (k Keeper) AddAccountCertificate(ctx sdk.Context, account types.Account, newCert []byte)

AddAccountCertificate adds aliceAddr new certificate to the account

func (Keeper) CollectFees added in v0.2.0

func (k Keeper) CollectFees(ctx sdk.Context, msg types.MsgWithFeePayer, domain types.Domain) error

CollectFees collects the fees of a msg and sends them to the distribution module to validators and stakers

func (Keeper) CreateAccount

func (k Keeper) CreateAccount(ctx sdk.Context, account types.Account)

CreateAccount creates an account

func (Keeper) CreateDomain

func (k Keeper) CreateDomain(ctx sdk.Context, domain types.Domain)

CreateDomain creates the domain inside the KVStore with its name as key

func (Keeper) DeleteAccount

func (k Keeper) DeleteAccount(ctx sdk.Context, domainName, accountName string)

DeleteAccount deletes an account based on it full account name -> domain + iovns.Separator + account

func (Keeper) DeleteAccountCertificate

func (k Keeper) DeleteAccountCertificate(ctx sdk.Context, account types.Account, certificateIndex int)

DeleteAccountCertificate deletes aliceAddr certificate at given index, it will panic if the index is wrong

func (Keeper) DeleteDomain

func (k Keeper) DeleteDomain(ctx sdk.Context, domainName string) (exists bool)

DeleteDomain deletes the domain and the accounts in it this operation can only fail in case the domain does not exist

func (Keeper) FlushDomain

func (k Keeper) FlushDomain(ctx sdk.Context, domain types.Domain)

FlushDomain clears all the accounts in a domain, empty account excluded

func (Keeper) GetAccount

func (k Keeper) GetAccount(ctx sdk.Context, domainName, accountName string) (account types.Account, exists bool)

GetAccount finds an account based on its key name, if not found it will return a zeroed account and false.

func (Keeper) GetAccountsInDomain

func (k Keeper) GetAccountsInDomain(ctx sdk.Context, domainName string, do func(key []byte) bool)

GetAccountsInDomain provides all the account keys related to the given domain name

func (Keeper) GetDomain

func (k Keeper) GetDomain(ctx sdk.Context, domainName string) (domain types.Domain, ok bool)

GetDomain returns the domain based on its name, if domain is not found ok will be false

func (Keeper) IterateAllAccounts added in v0.2.1

func (k Keeper) IterateAllAccounts(ctx sdk.Context) []types.Account

IterateAllAccounts returns all the accounts inside the store

func (Keeper) IterateAllDomains

func (k Keeper) IterateAllDomains(ctx sdk.Context) []types.Domain

IterateAllDomains will return an iterator for all the domain keys present in the KVStore, it's callers duty to close the iterator.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns aliceAddr module-specific logger.

func (Keeper) RenewAccount added in v0.3.0

func (k Keeper) RenewAccount(ctx sdk.Context, account *types.Account, accountRenew time.Duration)

RenewAccount updates an account expiration time

func (*Keeper) RenewDomain added in v0.3.0

func (k *Keeper) RenewDomain(ctx sdk.Context, domain types.Domain)

RenewDomain takes care of renewing the domain expiration time based on the configuration

func (Keeper) ReplaceAccountTargets

func (k Keeper) ReplaceAccountTargets(ctx sdk.Context, account types.Account, targets []types.BlockchainAddress)

ReplaceAccountTargets updates an account targets

func (Keeper) SetAccount

func (k Keeper) SetAccount(ctx sdk.Context, account types.Account)

SetAccount upserts account data

func (Keeper) SetDomain

func (k Keeper) SetDomain(ctx sdk.Context, domain types.Domain)

SetDomain updates or creates a new domain in the store

func (Keeper) TransferAccount

func (k Keeper) TransferAccount(ctx sdk.Context, account types.Account, newOwner sdk.AccAddress)

TransferAccount transfers the account to aliceAddr new owner after resetting certificates and targets

func (Keeper) TransferAccountWithReset added in v0.3.0

func (k Keeper) TransferAccountWithReset(ctx sdk.Context, account types.Account, newOwner sdk.AccAddress, reset bool)

TransferAccountWithReset transfers the account to aliceAddr new owner after modifying account contents

func (Keeper) TransferDomainAccountsOwnedByAddr added in v0.3.0

func (k Keeper) TransferDomainAccountsOwnedByAddr(ctx sdk.Context, domain types.Domain, currentOwner, newOwner sdk.AccAddress)

TransferDomainAccountsOwnedByAddr transfers all the accounts in the domain owned by an address to a new address

func (Keeper) TransferDomainAll added in v0.3.0

func (k Keeper) TransferDomainAll(ctx sdk.Context, newOwner sdk.AccAddress, domain types.Domain)

TransferDomainAll transfers the domain and the related accounts TODO deprecate

func (Keeper) TransferDomainOwnership added in v0.3.0

func (k Keeper) TransferDomainOwnership(ctx sdk.Context, domain types.Domain, newOwner sdk.AccAddress)

TransferDomainOwnership transfers the domain owner to newOwner

func (Keeper) UpdateMetadataAccount added in v0.3.0

func (k Keeper) UpdateMetadataAccount(ctx sdk.Context, account types.Account, newMetadata string)

UpdateMetadataAccount updates accounts metadata

type Mocks added in v0.2.0

type Mocks struct {
	Supply *mock.SupplyKeeperMock
}

type ParamSubspace

type ParamSubspace interface {
}

ParamSubspace is a placeholder

type QueryAccountsFromOwner

type QueryAccountsFromOwner struct {
	// Owner is the owner of the accounts
	Owner sdk.AccAddress `json:"owner"`
	// ResultsPerPage is the number of results returned in each page
	ResultsPerPage int `json:"results_per_page"`
	// Offset is the page number
	Offset int `json:"offset"`
}

QueryAccountsFromOwner queries all the accounts owned by a certain sdk.AccAddress

func (*QueryAccountsFromOwner) Description

func (q *QueryAccountsFromOwner) Description() string

Description is a placeholder

func (*QueryAccountsFromOwner) Handler

Handler implements local queryHandler

func (*QueryAccountsFromOwner) QueryPath

func (q *QueryAccountsFromOwner) QueryPath() string

QueryPath implements iovns.QueryHandler

func (*QueryAccountsFromOwner) Use

func (q *QueryAccountsFromOwner) Use() string

Use is a placeholder

func (*QueryAccountsFromOwner) Validate

func (q *QueryAccountsFromOwner) Validate() error

Validate implements iovns.QueryHandler

type QueryAccountsFromOwnerResponse

type QueryAccountsFromOwnerResponse struct {
	// Accounts is a slice containing the accounts
	// returned by the query
	Accounts []types.Account `json:"accounts"`
}

QueryAccountsFromOwnerResponse is the response model returned by QueryAccountsFromOwner

type QueryAccountsInDomain

type QueryAccountsInDomain struct {
	// Domain is the domain name
	Domain string `json:"domain" arg:"positional"`
	// ResultsPerPage is the results that each page should contain
	ResultsPerPage int `json:"results_per_page" arg:"positional"`
	// Offset is the page number
	Offset int `json:"offset" arg:"positional"`
}

QueryAccountsInDomain is the request model used to query accounts contained in a domain

func (*QueryAccountsInDomain) Description

func (q *QueryAccountsInDomain) Description() string

Description is a placeholder

func (*QueryAccountsInDomain) Handler

Handler implements queryHandler

func (*QueryAccountsInDomain) QueryPath

func (q *QueryAccountsInDomain) QueryPath() string

QueryPath implements iovns.QueryHandler

func (*QueryAccountsInDomain) Use

func (q *QueryAccountsInDomain) Use() string

Use is a placeholder

func (*QueryAccountsInDomain) Validate

func (q *QueryAccountsInDomain) Validate() error

Validate implements iovns.QueryHandler

type QueryAccountsInDomainResponse

type QueryAccountsInDomainResponse struct {
	// Accounts is a slice of the accounts found
	Accounts []types.Account `json:"accounts"`
}

QueryAccountsInDomainResponse is the response model returned after a QueryAccountsInDomain query

type QueryDomainsFromOwner

type QueryDomainsFromOwner struct {
	// Owner is the address of the owner of the domains
	Owner sdk.AccAddress `json:"owner"`
	// ResultsPerPage is the number of results displayed in a page
	ResultsPerPage int `json:"results_per_page"`
	// Offset is the page number
	Offset int `json:"offset"`
}

QueryDomainsFromOwner is the request model used to query domains owned by a sdk.AccAddress

func (*QueryDomainsFromOwner) Description

func (q *QueryDomainsFromOwner) Description() string

Description is a placeholder

func (*QueryDomainsFromOwner) Handler

Handler implements the local queryHandler

func (*QueryDomainsFromOwner) QueryPath

func (q *QueryDomainsFromOwner) QueryPath() string

QueryPath implements iovns.QueryHandler

func (*QueryDomainsFromOwner) Use

func (q *QueryDomainsFromOwner) Use() string

Use is a placeholder

func (*QueryDomainsFromOwner) Validate

func (q *QueryDomainsFromOwner) Validate() error

Validate implements iovns.QueryHandler

type QueryDomainsFromOwnerResponse

type QueryDomainsFromOwnerResponse struct {
	// Domains is a slice of the domains
	// found by the query
	Domains []types.Domain
}

QueryDomainsFromOwnerResponse is the response returned by the QueryDomainsFromOwner query

type QueryHandlerFunc

type QueryHandlerFunc func(ctx sdk.Context, path []string, query abci.RequestQuery, k Keeper) ([]byte, error)

QueryHandlerFunc defines the query handler for this module

type QueryResolveAccount

type QueryResolveAccount struct {
	// Domain is the name of the domain of the account
	Domain string `json:"domain"`
	// Name is the name of the account
	Name string `json:"name"`
}

QueryResolveAccount is the query model used to resolve an account

func (*QueryResolveAccount) Description

func (q *QueryResolveAccount) Description() string

Description is a placeholder

func (*QueryResolveAccount) Handler

Handler implements local queryHandler

func (*QueryResolveAccount) QueryPath

func (q *QueryResolveAccount) QueryPath() string

QueryPath implements iovns.QueryHandler

func (*QueryResolveAccount) Use

func (q *QueryResolveAccount) Use() string

Use is a placeholder

func (*QueryResolveAccount) Validate

func (q *QueryResolveAccount) Validate() error

Validate implements iovns.QueryHandler

type QueryResolveAccountResponse

type QueryResolveAccountResponse struct {
	// Account contains the resolved account
	Account types.Account `json:"account"`
}

QueryResolveAccountResponse is the response returned by the QueryResolveAccount query

type QueryResolveDomain

type QueryResolveDomain struct {
	// Name is the domain name
	Name string `json:"name" arg:"positional"`
}

QueryResolveDomain is the request model used to resolve a domain

func (*QueryResolveDomain) Description

func (q *QueryResolveDomain) Description() string

Description is a placeholder

func (*QueryResolveDomain) Handler

func (q *QueryResolveDomain) Handler() QueryHandlerFunc

Handler implements the local queryHandler

func (*QueryResolveDomain) QueryPath

func (q *QueryResolveDomain) QueryPath() string

QueryPath implements iovns.QueryHandler

func (*QueryResolveDomain) Use

func (q *QueryResolveDomain) Use() string

Use is a placeholder

func (*QueryResolveDomain) Validate

func (q *QueryResolveDomain) Validate() error

Validate implements iovns.QueryHandler

type QueryResolveDomainResponse

type QueryResolveDomainResponse struct {
	// Domain contains the queried domain information
	Domain types.Domain `json:"domain"`
}

QueryResolveDomainResponse is response returned by the QueryResolveDomain query

type QueryTargetAccounts added in v0.2.3

type QueryTargetAccounts struct {
	// Target is the blockchain target we want to query
	Target types.BlockchainAddress `json:"target"`
	// ResultsPerPage is the number of results displayed in a page
	ResultsPerPage int `json:"results_per_page"`
	// Offset is the page number
	Offset int `json:"offset"`
}

QueryTargetAccounts gets accounts from a target

func (*QueryTargetAccounts) Handler added in v0.2.3

func (*QueryTargetAccounts) QueryPath added in v0.2.3

func (q *QueryTargetAccounts) QueryPath() string

QueryPath implements iovns.QueryHandler

func (*QueryTargetAccounts) Validate added in v0.2.3

func (q *QueryTargetAccounts) Validate() error

type QueryTargetAccountsResponse added in v0.2.3

type QueryTargetAccountsResponse struct {
	Accounts []types.Account `json:"accounts"`
}

QueryTargetAccountsResponse is the response returned by query target

type SubTest added in v0.3.0

type SubTest struct {
	// BeforeTestBlockTime is the block time during before test in unix seconds
	// WARNING: if block time is given 0, it will be accepted as time.Now()
	BeforeTestBlockTime int64
	// BeforeTest is the function run before doing the test,
	// used for example to store state, like configurations etc.
	// Ignored if nil
	BeforeTest func(t *testing.T, k Keeper, ctx types.Context, mocks *Mocks)
	// TestBlockTime is the block time during test in unix seconds
	// WARNING: if block time is given 0, it will be accepted as time.Now()
	TestBlockTime int64
	// Test is the function that runs the actual test
	Test func(t *testing.T, k Keeper, ctx types.Context, mocks *Mocks)
	// AfterTestBlockTime is the block time during after test in unix seconds
	// WARNING: if block time is given 0, it will be accepted as time.Now()
	AfterTestBlockTime int64
	// AfterTest performs actions after the test is run, it can
	// be used to check if the state after Test is run matches
	// the result we expect.
	// Ignored if nil
	AfterTest func(t *testing.T, k Keeper, ctx types.Context, mocks *Mocks)
}

subTest defines a test runner

type SupplyKeeper added in v0.2.0

type SupplyKeeper interface {
	SendCoinsFromAccountToModule(ctx sdk.Context, addr sdk.AccAddress, moduleName string, coins sdk.Coins) error
}

SupplyKeeper defines the behaviour of the supply keeper used to collect and then distribute the fees

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL