env

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImplAddressFor

func ImplAddressFor(name string) (common.Address, error)

ImplAddressFor obtains the address for a core contract

func Libraries

func Libraries() []string

Libraries returns all celo-blockchain library names

func LibraryAddressFor

func LibraryAddressFor(name string) (common.Address, error)

LibraryAddressFor obtains the address for a core contract

func MustImplAddressFor

func MustImplAddressFor(name string) common.Address

MustImplAddressFor obtains the address for a core contract this variant panics on error

func MustLibraryAddressFor

func MustLibraryAddressFor(name string) common.Address

MustLibraryAddressFor obtains the address for a core contract this variant panics on error

func MustNewMnemonic

func MustNewMnemonic() string

MustNewMnemonic creates a new mnemonic (panics on error)

func MustProxyAddressFor

func MustProxyAddressFor(name string) common.Address

MustProxyAddressFor obtains the address for a core contract proxy this variant panics on error

func NewMnemonic

func NewMnemonic() (string, error)

NewMnemonic creates a new mnemonic

func ProxyAddressFor

func ProxyAddressFor(name string) (common.Address, error)

ProxyAddressFor obtains the address for a core contract proxy

Types

type Account

type Account struct {
	Address    common.Address
	PrivateKey *ecdsa.PrivateKey
}

Account represents a Celo Account

func DeriveAccount

func DeriveAccount(mnemonic string, accountType AccountType, idx int) (*Account, error)

DeriveAccount will derive the account corresponding to (accountType, idx) using the given mnemonic

func DeriveAccountList

func DeriveAccountList(mnemonic string, accountType AccountType, qty int) ([]Account, error)

DeriveAccountList will generate the desired number of accounts using mnemonic & accountType

func GenerateRandomAccount

func GenerateRandomAccount() (Account, error)

GenerateRandomAccount creates a random new account

func MustGenerateRandomAccount

func MustGenerateRandomAccount() Account

MustGenerateRandomAccount creates new account or panics

func NewAccount

func NewAccount(key *ecdsa.PrivateKey) Account

NewAccount creates a new account for the specified private key

func (*Account) BLSProofOfPossession

func (a *Account) BLSProofOfPossession() ([]byte, error)

BLSProofOfPossession generates bls proof of possession

func (*Account) BLSPublicKey

func (a *Account) BLSPublicKey() (blscrypto.SerializedPublicKey, error)

BLSPublicKey returns the bls public key

func (Account) MarshalJSON

func (a Account) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Account) MustBLSProofOfPossession

func (a *Account) MustBLSProofOfPossession() []byte

MustBLSProofOfPossession variant of BLSProofOfPossession that panics on error

func (*Account) PrivateKeyHex

func (a *Account) PrivateKeyHex() string

PrivateKeyHex hex representation of the private key

func (*Account) PublicKey

func (a *Account) PublicKey() []byte

PublicKeyHex hex representation of the public key

func (*Account) String

func (a *Account) String() string

func (*Account) UnmarshalJSON

func (a *Account) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler

type AccountType

type AccountType int

AccountType represents the different account types for the generator

var (
	ValidatorAT      AccountType = 0
	DeveloperAT      AccountType = 1 // load test
	TxNodeAT         AccountType = 2
	BootnodeAT       AccountType = 3
	FaucetAT         AccountType = 4
	AttestationAT    AccountType = 5
	PriceOracleAT    AccountType = 6
	ProxyAT          AccountType = 7
	AttestationBotAT AccountType = 8
	VotingBotAT      AccountType = 9
	TxNodePrivateAT  AccountType = 10
	ValidatorGroupAT AccountType = 11 // Not in celotool (yet)
	AdminAT          AccountType = 12 // Not in celotool (yet)
	TxFeeRecipientAT AccountType = 13 // Not in celotool (yet)
)

The difference account types for the generator

func (AccountType) MarshalText

func (accountType AccountType) MarshalText() ([]byte, error)

MarshalText marshall account type into text

func (AccountType) String

func (accountType AccountType) String() string

String implements the stringer interface.

func (*AccountType) UnmarshalText

func (accountType *AccountType) UnmarshalText(text []byte) error

UnmarshalText creates AccountType from string

type AccountsConfig

type AccountsConfig struct {
	Mnemonic             string `json:"mnemonic"`            // Accounts mnemonic
	NumValidators        int    `json:"validators"`          // Number of initial validators
	ValidatorsPerGroup   int    `json:"validatorsPerGroup"`  // Number of validators per group in the initial set
	NumDeveloperAccounts int    `json:"developerAccounts"`   // Number of developers accounts
	UseValidatorAsAdmin  bool   `json:"useValidatorAsAdmin"` // Whether to use the first validator as the admin (for compatibility with monorepo)
}

AccountsConfig represents accounts configuration for the environment

func (*AccountsConfig) Account

func (ac *AccountsConfig) Account(accType AccountType, idx int) (*Account, error)

Account retrieves the account corresponding to the (accountType, idx)

func (*AccountsConfig) AdminAccount

func (ac *AccountsConfig) AdminAccount() *Account

AdminAccount returns the environment's admin account

func (*AccountsConfig) DeveloperAccounts

func (ac *AccountsConfig) DeveloperAccounts() []Account

DeveloperAccounts returns the environment's developers accounts

func (*AccountsConfig) NumValidatorGroups

func (ac *AccountsConfig) NumValidatorGroups() int

NumValidatorGroups retrieves the number of validator groups for the genesis

func (*AccountsConfig) TxFeeRecipientAccounts

func (ac *AccountsConfig) TxFeeRecipientAccounts() []Account

ValidatorAccounts returns the environment's validators accounts

func (*AccountsConfig) ValidatorAccounts

func (ac *AccountsConfig) ValidatorAccounts() []Account

ValidatorAccounts returns the environment's validators accounts

func (*AccountsConfig) ValidatorGroupAccounts

func (ac *AccountsConfig) ValidatorGroupAccounts() []Account

ValidatorGroupAccounts returns the environment's validators group accounts

func (*AccountsConfig) ValidatorGroups

func (ac *AccountsConfig) ValidatorGroups() []ValidatorGroup

ValidatorGroups return the list of validator groups on genesis

type Config

type Config struct {
	ChainID  *big.Int       `json:"chainId"`  // chainId identifies the current chain and is used for replay protection
	Accounts AccountsConfig `json:"accounts"` // Accounts configuration for the environment
}

Config represents mycelo environment parameters

type Environment

type Environment struct {
	Config Config
	// contains filtered or unexported fields
}

Environment represents a mycelo environment which is the home to any mycelo operation within a computer

func Load

func Load(envpath string) (*Environment, error)

Load will load an environment located in envpath folder

func New

func New(envpath string, cfg *Config) (*Environment, error)

New creates a new environment

func (*Environment) Accounts

func (env *Environment) Accounts() *AccountsConfig

Accounts retrieves accounts config

func (*Environment) GenesisPath

func (env *Environment) GenesisPath() string

GenesisPath returns the paths to the genesis.json file (if present on the environment)

func (*Environment) IPC

func (env *Environment) IPC() string

IPC returns the IPC path to the first validator

func (*Environment) Save

func (env *Environment) Save() error

Save will save environment's config into the environment folder

func (*Environment) SaveGenesis

func (env *Environment) SaveGenesis(genesis *core.Genesis) error

SaveGenesis writes genesis.json within the env.json

func (*Environment) ValidatorDatadir

func (env *Environment) ValidatorDatadir(idx int) string

ValidatorDatadir returns the datadir that mycelo uses to run the validator-[idx]

func (*Environment) ValidatorIPC

func (env *Environment) ValidatorIPC(idx int) string

ValidatorIPC returns the ipc path to validator-[idx]

type ValidatorGroup

type ValidatorGroup struct {
	Account
	Validators []Account
}

ValidatorGroup represents a group plus its validators members

Jump to

Keyboard shortcuts

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