types

package
v0.0.0-...-8551cdf Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeValueCategory = ModuleName

	EventTypeCreateAccount     = "account.create"
	EventTypeUpdateAccountAuth = "account.authupdate"

	AttributeKeyCreator = "creator"
	AttributeKeyAccount = "account"
	AttributeKeyAuth    = "auth"
)
View Source
const (
	// module name
	ModuleName = "account"

	// StoreKey is string representation of the store key for auth
	StoreKey = "kuacc"

	// QuerierRoute is the querier route for acc
	QuerierRoute = ModuleName
)
View Source
const (
	Minter  = "minter"
	Burner  = "burner"
	Staking = "staking"
)

permissions

View Source
const (
	QueryAccount        = "account"
	QueryAuthByAddress  = "authByAddress"
	QueryAccountsByAuth = "accountsByAuth"
	QueryParams         = "params"
)

query endpoints supported by the auth Querier

View Source
const (
	// DefaultParamspace for params keeper
	DefaultParamspace = ModuleName
)
View Source
const RouterKey = ModuleName

RouterKey is they name of the bank module

Variables

View Source
var (
	ErrAccountHasCreated             = sdkerrors.Register(ModuleName, 1, "account has created")
	ErrAccountNoFound                = sdkerrors.Register(ModuleName, 2, "account no found")
	ErrAccountCannotCreateSysAccount = sdkerrors.Register(ModuleName, 3, "cannot create system account by create")
	ErrAccountNameInvalid            = sdkerrors.Register(ModuleName, 4, "account name is invalid")
	ErrAccountNameLenInvalid         = sdkerrors.Register(ModuleName, 5, "account name length is invalid")
)
View Source
var (
	// AddressStoreKeyPrefix prefix for account-by-address store
	AddressStoreKeyPrefix = []byte{0x01}

	// AuthSeqStoreKeyPerfix seq num store prefix
	AuthSeqStoreKeyPerfix = []byte{0x02}

	// Auth - Accounts store prefix
	AuthAccountsStoreKeyPerfix = []byte{0x03}

	// GlobalAccountNumberKey param key for global account number
	GlobalAccountNumberKey = types.MustName("g.account.number").Value
)
View Source
var (
	ErrInvalidLengthTypes        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTypes          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)
View Source
var ModuleCdc = codec.New()

ModuleCdc auth module wide codec

View Source
var (
	NewAccountIDFromName = types.NewAccountIDFromName
)
View Source
var (
	RootAuthName = types.MustName("root")
)

Functions

func AccountIDStoreKey

func AccountIDStoreKey(addr types.AccountID) []byte

AccountIDStoreKey turn an address to key used to get it from the account store

func AuthAccountsStoreKey

func AuthAccountsStoreKey(auth types.AccAddress) []byte

Auth - Accounts key for store

func AuthSeqStoreKey

func AuthSeqStoreKey(addr types.AccAddress) []byte

AuthSeqStoreKey seq key for store

func Cdc

func Cdc() *codec.Codec

Cdc get codec for types

func NameStoreKey

func NameStoreKey(name types.Name) []byte

NameStoreKey turn an name to key used to get it from the account store

func NewModuleAddress

func NewModuleAddress(name string) sdk.AccAddress

NewModuleAddress creates an AccAddress from the hash of the module's name

func NewProtoKuAccount

func NewProtoKuAccount() exported.Account

NewProtoKuAccount - a prototype function for KuAccount

func RegisterAccountTypeCodec

func RegisterAccountTypeCodec(o interface{}, name string)

RegisterAccountTypeCodec registers an external account type defined in another module for the internal ModuleCdc.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the codec

Types

type AccountAuth

type AccountAuth struct {
	Name    types.Name                                    `protobuf:"bytes,1,opt,name=name,proto3" json:"name" yaml:"name"`
	Address github_com_cosmos_cosmos_sdk_types.AccAddress `` /* 137-byte string literal not displayed */
}

func (*AccountAuth) Descriptor

func (*AccountAuth) Descriptor() ([]byte, []int)

func (*AccountAuth) Marshal

func (m *AccountAuth) Marshal() (dAtA []byte, err error)

func (*AccountAuth) MarshalTo

func (m *AccountAuth) MarshalTo(dAtA []byte) (int, error)

func (*AccountAuth) MarshalToSizedBuffer

func (m *AccountAuth) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (AccountAuth) MarshalYAML

func (m AccountAuth) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of an account.

func (*AccountAuth) ProtoMessage

func (*AccountAuth) ProtoMessage()

func (*AccountAuth) Reset

func (m *AccountAuth) Reset()

func (*AccountAuth) Size

func (m *AccountAuth) Size() (n int)

func (AccountAuth) String

func (m AccountAuth) String() string

String - implements exported.Account

func (*AccountAuth) Unmarshal

func (m *AccountAuth) Unmarshal(dAtA []byte) error

func (*AccountAuth) XXX_DiscardUnknown

func (m *AccountAuth) XXX_DiscardUnknown()

func (*AccountAuth) XXX_Marshal

func (m *AccountAuth) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AccountAuth) XXX_Merge

func (m *AccountAuth) XXX_Merge(src proto.Message)

func (*AccountAuth) XXX_Size

func (m *AccountAuth) XXX_Size() int

func (*AccountAuth) XXX_Unmarshal

func (m *AccountAuth) XXX_Unmarshal(b []byte) error

type AccountRetriever

type AccountRetriever struct {
	// contains filtered or unexported fields
}

AccountRetriever defines the properties of a type that can be used to retrieve accounts.

func NewAccountRetriever

func NewAccountRetriever(querier NodeQuerier) AccountRetriever

NewAccountRetriever initialises a new AccountRetriever instance.

func (AccountRetriever) EnsureExists

func (ar AccountRetriever) EnsureExists(id types.AccountID) error

EnsureExists returns an error if no account exists for the given address else nil.

func (AccountRetriever) GetAccount

func (ar AccountRetriever) GetAccount(id types.AccountID) (exported.Account, error)

GetAccount queries for an account given an address and a block height. An error is returned if the query or decoding fails.

func (AccountRetriever) GetAccountWithHeight

func (ar AccountRetriever) GetAccountWithHeight(id types.AccountID) (exported.Account, int64, error)

GetAccountWithHeight queries for an account given an address. Returns the height of the query with the account. An error is returned if the query or decoding fails.

func (AccountRetriever) GetAddAuth

func (ar AccountRetriever) GetAddAuth(add types.AccAddress) (Auth, error)

GetAddAuth queries for an auth state given an address and a block height.

func (AccountRetriever) GetAddAuthWithHeight

func (ar AccountRetriever) GetAddAuthWithHeight(add types.AccAddress) (Auth, int64, error)

GetAddAuthWithHeight queries for an auth state given an address.

func (AccountRetriever) GetAuthNumberSequence

func (ar AccountRetriever) GetAuthNumberSequence(id types.AccountID) (uint64, uint64, error)

GetAccountNumberSequence returns sequence and account number for the given address. It returns an error if the account couldn't be retrieved from the state.

type Accounts

type Accounts []string

type Auth

type Auth struct {
	Name      types.Name                                    `protobuf:"bytes,1,opt,name=name,proto3" json:"name" yaml:"name"`
	Address   github_com_cosmos_cosmos_sdk_types.AccAddress `` /* 137-byte string literal not displayed */
	PublicKey []byte                                        `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty" yaml:"public_key"`
	Number    uint64                                        `protobuf:"varint,4,opt,name=number,proto3" json:"number,omitempty" yaml:"number"`
	Sequence  uint64                                        `protobuf:"varint,5,opt,name=sequence,proto3" json:"sequence,omitempty" yaml:"sequence"`
}

func NewAuth

func NewAuth(address sdk.AccAddress) Auth

func (*Auth) Descriptor

func (*Auth) Descriptor() ([]byte, []int)

func (Auth) GetAddress

func (m Auth) GetAddress() sdk.AccAddress

GetAddress

func (Auth) GetNumber

func (m Auth) GetNumber() uint64

GetNumber

func (Auth) GetPubKey

func (m Auth) GetPubKey() (pk crypto.PubKey)

GetPubKey - Implements sdk.Account.

func (Auth) GetSequence

func (m Auth) GetSequence() uint64

GetSequence get sequence number for auth data

func (*Auth) Marshal

func (m *Auth) Marshal() (dAtA []byte, err error)

func (*Auth) MarshalTo

func (m *Auth) MarshalTo(dAtA []byte) (int, error)

func (*Auth) MarshalToSizedBuffer

func (m *Auth) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (Auth) MarshalYAML

func (m Auth) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of an account.

func (*Auth) ProtoMessage

func (*Auth) ProtoMessage()

func (*Auth) Reset

func (m *Auth) Reset()

func (*Auth) SetAccountNum

func (m *Auth) SetAccountNum(num uint64)

SetPubKey - Implements sdk.Account.

func (*Auth) SetAddress

func (m *Auth) SetAddress(address sdk.AccAddress)

SetAddress

func (*Auth) SetPubKey

func (m *Auth) SetPubKey(pubKey crypto.PubKey)

SetPubKey - Implements sdk.Account.

func (*Auth) SetSequence

func (m *Auth) SetSequence(s uint64)

SetSequence - implements exported.Account

func (*Auth) Size

func (m *Auth) Size() (n int)

func (Auth) String

func (m Auth) String() string

String - implements exported.Account

func (*Auth) Unmarshal

func (m *Auth) Unmarshal(dAtA []byte) error

func (*Auth) XXX_DiscardUnknown

func (m *Auth) XXX_DiscardUnknown()

func (*Auth) XXX_Marshal

func (m *Auth) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Auth) XXX_Merge

func (m *Auth) XXX_Merge(src proto.Message)

func (*Auth) XXX_Size

func (m *Auth) XXX_Size() int

func (*Auth) XXX_Unmarshal

func (m *Auth) XXX_Unmarshal(b []byte) error

type AuthAccounts

type AuthAccounts struct {
	Auth     string   `json:"auth"`
	Accounts Accounts `json:"accounts"`
}

func NewAuthAccount

func NewAuthAccount(auth, acc string) AuthAccounts

func (*AuthAccounts) AddAccount

func (a *AuthAccounts) AddAccount(acc string)

func (*AuthAccounts) DeleteAccount

func (a *AuthAccounts) DeleteAccount(acc string)

func (AuthAccounts) GetAccounts

func (a AuthAccounts) GetAccounts() Accounts

type GenesisState

type GenesisState struct {
	Accounts exported.GenesisAccounts `json:"accounts"`
}

GenesisState genesis state for account module

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState get default genesis state for account module

type KuAccount

type KuAccount struct {
	Id            types.AccountID `protobuf:"bytes,1,opt,name=id,proto3" json:"id" yaml:"id"`
	AccountNumber uint64          `protobuf:"varint,2,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty" yaml:"account_number"`
	Auths         []AccountAuth   `protobuf:"bytes,3,rep,name=auths,proto3" json:"auths" yaml:"auths"`
}

KuAccount defines a account for kuchain

func NewKuAccount

func NewKuAccount(id types.AccountID) *KuAccount

NewKuAccount new KuAccount by name

func (*KuAccount) Descriptor

func (*KuAccount) Descriptor() ([]byte, []int)

func (KuAccount) GetAccountNumber

func (m KuAccount) GetAccountNumber() uint64

GetAccountNumber - implements exported.Account

func (KuAccount) GetAuth

func (m KuAccount) GetAuth() types.AccAddress

GetAuth - implements exported.Account

func (KuAccount) GetID

func (m KuAccount) GetID() types.AccountID

GetID - implements exported.Account

func (KuAccount) GetName

func (m KuAccount) GetName() types.Name

GetName - implements exported.Account

func (*KuAccount) Marshal

func (m *KuAccount) Marshal() (dAtA []byte, err error)

func (*KuAccount) MarshalTo

func (m *KuAccount) MarshalTo(dAtA []byte) (int, error)

func (*KuAccount) MarshalToSizedBuffer

func (m *KuAccount) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (KuAccount) MarshalYAML

func (m KuAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of an account.

func (*KuAccount) ProtoMessage

func (*KuAccount) ProtoMessage()

func (*KuAccount) Reset

func (m *KuAccount) Reset()

func (*KuAccount) SetAccountNumber

func (m *KuAccount) SetAccountNumber(n uint64) error

SetAccountNumber - implements exported.Account

func (*KuAccount) SetAuth

func (m *KuAccount) SetAuth(auth types.AccAddress) error

SetAuth - implements exported.Account

func (*KuAccount) SetID

func (m *KuAccount) SetID(id types.AccountID) error

SetID - implements exported.Account

func (*KuAccount) SetName

func (m *KuAccount) SetName(n types.Name) error

SetName - implements exported.Account

func (*KuAccount) Size

func (m *KuAccount) Size() (n int)

func (KuAccount) String

func (m KuAccount) String() string

String - implements exported.Account

func (*KuAccount) Unmarshal

func (m *KuAccount) Unmarshal(dAtA []byte) error

func (KuAccount) Validate

func (m KuAccount) Validate() error

Validate - implements exported.GenesisAccount

func (*KuAccount) XXX_DiscardUnknown

func (m *KuAccount) XXX_DiscardUnknown()

func (*KuAccount) XXX_Marshal

func (m *KuAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*KuAccount) XXX_Merge

func (m *KuAccount) XXX_Merge(src proto.Message)

func (*KuAccount) XXX_Size

func (m *KuAccount) XXX_Size() int

func (*KuAccount) XXX_Unmarshal

func (m *KuAccount) XXX_Unmarshal(b []byte) error

type ModuleAccount

type ModuleAccount struct {
	KuAccount   ``       /* 126-byte string literal not displayed */
	Permissions []string `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"`
}

ModuleAccount defines an account for modules that holds coins on a pool

func NewEmptyModuleAccount

func NewEmptyModuleAccount(name string, permissions ...string) *ModuleAccount

NewEmptyModuleAccount creates a empty ModuleAccount from a string

func NewModuleAccount

func NewModuleAccount(ba KuAccount, name string, permissions ...string) *ModuleAccount

NewModuleAccount creates a new ModuleAccount instance

func (*ModuleAccount) Descriptor

func (*ModuleAccount) Descriptor() ([]byte, []int)

func (ModuleAccount) GetAddress

func (ma ModuleAccount) GetAddress() sdk.AccAddress

GetAddress for some old API calls

func (ModuleAccount) GetPermissions

func (ma ModuleAccount) GetPermissions() []string

GetPermissions returns permissions granted to the module account

func (ModuleAccount) HasPermission

func (ma ModuleAccount) HasPermission(permission string) bool

HasPermission returns whether or not the module account has permission.

func (*ModuleAccount) Marshal

func (m *ModuleAccount) Marshal() (dAtA []byte, err error)

func (ModuleAccount) MarshalJSON

func (ma ModuleAccount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a ModuleAccount.

func (*ModuleAccount) MarshalTo

func (m *ModuleAccount) MarshalTo(dAtA []byte) (int, error)

func (*ModuleAccount) MarshalToSizedBuffer

func (m *ModuleAccount) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (ModuleAccount) MarshalYAML

func (ma ModuleAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of a ModuleAccount.

func (*ModuleAccount) ProtoMessage

func (*ModuleAccount) ProtoMessage()

func (*ModuleAccount) Reset

func (m *ModuleAccount) Reset()

func (ModuleAccount) SetPubKey

func (ma ModuleAccount) SetPubKey(pubKey crypto.PubKey) error

SetPubKey - Implements Account

func (ModuleAccount) SetSequence

func (ma ModuleAccount) SetSequence(seq uint64) error

SetSequence - Implements Account

func (*ModuleAccount) Size

func (m *ModuleAccount) Size() (n int)

func (ModuleAccount) String

func (ma ModuleAccount) String() string

func (*ModuleAccount) Unmarshal

func (m *ModuleAccount) Unmarshal(dAtA []byte) error

func (*ModuleAccount) UnmarshalJSON

func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshal raw JSON bytes into a ModuleAccount.

func (ModuleAccount) Validate

func (ma ModuleAccount) Validate() error

Validate checks for errors on the account fields

func (*ModuleAccount) XXX_DiscardUnknown

func (m *ModuleAccount) XXX_DiscardUnknown()

func (*ModuleAccount) XXX_Marshal

func (m *ModuleAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ModuleAccount) XXX_Merge

func (m *ModuleAccount) XXX_Merge(src proto.Message)

func (*ModuleAccount) XXX_Size

func (m *ModuleAccount) XXX_Size() int

func (*ModuleAccount) XXX_Unmarshal

func (m *ModuleAccount) XXX_Unmarshal(b []byte) error

type MsgCreateAccount

type MsgCreateAccount struct {
	types.KuMsg
}

MsgCreateAccount create account msg

func NewMsgCreateAccount

func NewMsgCreateAccount(auth types.AccAddress, creator types.AccountID, name types.Name, accountAuth types.AccAddress) MsgCreateAccount

func (MsgCreateAccount) GetData

func (msg MsgCreateAccount) GetData() (MsgCreateAccountData, error)

type MsgCreateAccountData

type MsgCreateAccountData struct {
	Creator types.AccountID  `json:"creator" yaml:"creator"`
	Name    types.Name       `json:"name" yaml:"name"`
	Auth    types.AccAddress `json:"auth" yaml:"auth"`
}

MsgCreateAccountData the data struct of MsgCreateAccount

func (MsgCreateAccountData) Marshal

func (m MsgCreateAccountData) Marshal() ([]byte, error)

func (MsgCreateAccountData) Type

func (*MsgCreateAccountData) Unmarshal

func (m *MsgCreateAccountData) Unmarshal(b []byte) error

type MsgUpdateAccountAuth

type MsgUpdateAccountAuth struct {
	types.KuMsg
}

MsgUpdateAccountAuth create account msg

func NewMsgUpdateAccountAuth

func NewMsgUpdateAccountAuth(auth types.AccAddress, name types.Name, accountAuth types.AccAddress) MsgUpdateAccountAuth

NewMsgUpdateAccountAuth create msg to update account auth

type MsgUpdateAccountAuthData

type MsgUpdateAccountAuthData struct {
	Name types.Name       `json:"name" yaml:"name"`
	Auth types.AccAddress `json:"auth" yaml:"auth"`
}

MsgUpdateAccountAuthData the data struct of MsgCreateAccount

func (MsgUpdateAccountAuthData) Type

type NodeQuerier

type NodeQuerier interface {
	// QueryWithData performs a query to a Tendermint node with the provided path
	// and a data payload. It returns the result and height of the query upon success
	// or an error if the query fails.
	QueryWithData(path string, data []byte) ([]byte, int64, error)
}

NodeQuerier is an interface that is satisfied by types that provide the QueryWithData method

type PermissionsForAddress

type PermissionsForAddress struct {
	// contains filtered or unexported fields
}

PermissionsForAddress defines all the registered permissions for an address

func NewPermissionsForAddress

func NewPermissionsForAddress(name string, permissions []string) PermissionsForAddress

NewPermissionsForAddress creates a new PermissionsForAddress object

func (PermissionsForAddress) GetAddress

func (pa PermissionsForAddress) GetAddress() sdk.AccAddress

GetAddress returns the address of the PermissionsForAddress object

func (PermissionsForAddress) GetPermissions

func (pa PermissionsForAddress) GetPermissions() []string

GetPermissions returns the permissions granted to the address

func (PermissionsForAddress) HasPermission

func (pa PermissionsForAddress) HasPermission(permission string) bool

HasPermission returns whether the PermissionsForAddress contains permission.

type QueryAccountParams

type QueryAccountParams struct {
	Id chainTypes.AccountID
}

QueryAccountParams defines the params for querying accounts.

func NewQueryAccountParams

func NewQueryAccountParams(id chainTypes.AccountID) QueryAccountParams

NewQueryAccountParams creates a new instance of QueryAccountParams.

type QueryAccountsByAuthParams

type QueryAccountsByAuthParams struct {
	Auth chainTypes.AccAddress
}

QueryAuthSeqParams defines the params for querying accounts.

func NewQueryAccountsByAuthParams

func NewQueryAccountsByAuthParams(auth string) QueryAccountsByAuthParams

NewQueryAccountsByAuthParams creates a new instance of QueryAccountsByAuthParams.

type QueryAuthByAddressParams

type QueryAuthByAddressParams struct {
	Address chainTypes.AccAddress
}

QueryAuthSeqParams defines the params for querying accounts.

func NewQueryAddAuthParams

func NewQueryAddAuthParams(address chainTypes.AccAddress) QueryAuthByAddressParams

NewQueryAddAuthParams creates a new instance of QueryAuthSeqParams.

type QueryAuthSeqParams

type QueryAuthSeqParams struct {
	Auth chainTypes.AccAddress
}

QueryAuthSeqParams defines the params for querying accounts.

func NewQueryAuthSeqParams

func NewQueryAuthSeqParams(auth chainTypes.AccAddress) QueryAuthSeqParams

NewQueryAuthSeqParams creates a new instance of QueryAuthSeqParams.

Jump to

Keyboard shortcuts

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