cosmosaccount

package
v0.0.0-...-7149754 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: Apache-2.0 Imports: 10 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

	// Info holds additional info about the account.
	Info keyring.Info
}

Account represents an Cosmos SDK account.

func (Account) Address

func (a Account) Address(accPrefix string) string

Address returns the address of the account from given prefix.

func (Account) PubKey

func (a Account) PubKey() string

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) 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