53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package exported
|
|
|
|
import (
|
|
"github.com/tendermint/tendermint/crypto"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// Account is an interface used to store coins at a given address within state.
|
|
// It presumes a notion of sequence numbers for replay protection,
|
|
// a notion of account numbers for replay protection for previously pruned accounts,
|
|
// and a pubkey for authentication purposes.
|
|
//
|
|
// Many complex conditions can be used in the concrete struct which implements Account.
|
|
type Account interface {
|
|
GetAddress() sdk.AccAddress
|
|
SetAddress(sdk.AccAddress) error // errors if already set.
|
|
|
|
GetPubKey() crypto.PubKey // can return nil.
|
|
SetPubKey(crypto.PubKey) error
|
|
|
|
GetAccountNumber() uint64
|
|
SetAccountNumber(uint64) error
|
|
|
|
GetSequence() uint64
|
|
SetSequence(uint64) error
|
|
|
|
// Ensure that account implements stringer
|
|
String() string
|
|
}
|
|
|
|
// GenesisAccounts defines a slice of GenesisAccount objects
|
|
type GenesisAccounts []GenesisAccount
|
|
|
|
// Contains returns true if the given address exists in a slice of GenesisAccount
|
|
// objects.
|
|
func (ga GenesisAccounts) Contains(addr sdk.Address) bool {
|
|
for _, acc := range ga {
|
|
if acc.GetAddress().Equals(addr) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// GenesisAccount defines a genesis account that embeds an Account with validation capabilities.
|
|
type GenesisAccount interface {
|
|
Account
|
|
|
|
Validate() error
|
|
}
|