cosmosaccount

package
v29.0.0-...-0018c38 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyringServiceName used for the name of keyring in OS backend.
	KeyringServiceName = "starport"

	// DefaultAccount is the name of the default account.
	DefaultAccount = "default"
)
View Source
const (
	AccountPrefixCosmos = "cosmos"
)

Variables

View Source
var ErrAccountExists = errors.New("account already exists")
View Source
var KeyringHome = os.ExpandEnv("$HOME/.ignite/accounts")

KeyringHome used to store account related data.

Functions

This section is empty.

Types

type Account

type Account struct {
	// Name of the account.
	Name string

	// Record holds additional info about the account.
	Record *keyring.Record
}

Account represents a Cosmos SDK account.

func (Account) Address

func (a Account) Address(accPrefix string) (string, error)

Address returns the address of the account from given prefix.

func (Account) PubKey

func (a Account) PubKey() (string, error)

PubKey returns a public key for account.

type AccountDoesNotExistError

type AccountDoesNotExistError struct {
	Name string
}

func (*AccountDoesNotExistError) Error

func (e *AccountDoesNotExistError) Error() string

type KeyringBackend

type KeyringBackend string

KeyringBackend is the backend for where keys are stored.

const (
	// KeyringTest is the test keyring backend. With this backend, your keys will be
	// stored under your app's data dir.
	KeyringTest KeyringBackend = "test"

	// KeyringOS is the OS keyring backend. With this backend, your keys will be
	// stored in your operating system's secured keyring.
	KeyringOS KeyringBackend = "os"

	// KeyringMemory is in memory keyring backend, your keys will be stored in application memory.
	KeyringMemory KeyringBackend = "memory"
)

type Option

type Option func(*Registry)

Option configures your registry.

func WithHome

func WithHome(path string) Option

func WithKeyringBackend

func WithKeyringBackend(backend KeyringBackend) Option

func WithKeyringServiceName

func WithKeyringServiceName(name string) Option

type Registry

type Registry struct {
	Keyring keyring.Keyring
	// contains filtered or unexported fields
}

Registry for accounts.

func New

func New(options ...Option) (Registry, error)

New creates a new registry to manage accounts.

func NewInMemory

func NewInMemory(options ...Option) (Registry, error)

func NewStandalone

func NewStandalone(options ...Option) (Registry, error)

func (Registry) Create

func (r Registry) Create(name string) (acc Account, mnemonic string, err error)

Create creates a new account with name.

func (Registry) DeleteByName

func (r Registry) DeleteByName(name string) error

DeleteByName deletes an account by name.

func (Registry) EnsureDefaultAccount

func (r Registry) EnsureDefaultAccount() error

EnsureDefaultAccount ensures that default account exists.

func (Registry) Export

func (r Registry) Export(name, passphrase string) (key string, err error)

Export exports an account as a private key.

func (Registry) ExportHex

func (r Registry) ExportHex(name, passphrase string) (hex string, err error)

ExportHex exports an account as a private key in hex.

func (Registry) GetByAddress

func (r Registry) GetByAddress(address string) (Account, error)

GetByAddress returns an account by its address.

func (Registry) GetByName

func (r Registry) GetByName(name string) (Account, error)

GetByName returns an account by its name.

func (Registry) Import

func (r Registry) Import(name, secret, passphrase string) (Account, error)

Import imports an existing account with name and passphrase and secret where secret can be a mnemonic or a private key.

func (Registry) List

func (r Registry) List() ([]Account, error)

List lists all accounts.

Jump to

Keyboard shortcuts

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