model

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const ZeroAddress = "0x0"

Variables

View Source
var DefaultConfigSpec = &ConfigSpec{

	ChainID:  "1",
	GasPrice: ethfw.Gwei(8).String(),

	GasLimit:     "10000000",
	AwaitTimeout: "10m",
}
View Source
var PlaceholderAddr = common.BytesToAddress([]byte("0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"))

Functions

func IsCommonDenominator

func IsCommonDenominator(name string) bool

Types

type AppContext

type AppContext struct {
	context.Context
}

func NewAppContext

func NewAppContext(ctx context.Context, appCommand string, appCommandArgs []string, nodeGroup string,
	specDir string, solcCompiler sol.Compiler, keycache ethfw.KeyCache) AppContext

func (AppContext) AppCommand

func (ctx AppContext) AppCommand() string

func (AppContext) AppCommandArgs

func (ctx AppContext) AppCommandArgs() []string

func (AppContext) KeyCache

func (ctx AppContext) KeyCache() ethfw.KeyCache

func (AppContext) NodeGroup

func (ctx AppContext) NodeGroup() string

func (AppContext) SolcCompiler

func (ctx AppContext) SolcCompiler() sol.Compiler

func (AppContext) SpecDir

func (ctx AppContext) SpecDir() string

type ArgReference

type ArgReference struct {
	ArgID int
}

type CallCmdSpec

type CallCmdSpec struct {
	ParamSpec   `yaml:",inline"`
	Description string `yaml:"desc"`

	Wallet string `yaml:"wallet"`
	Method string `yaml:"method"`
	// contains filtered or unexported fields
}

func (*CallCmdSpec) ArgCount

func (spec *CallCmdSpec) ArgCount() int

func (*CallCmdSpec) CountArgsUsing

func (spec *CallCmdSpec) CountArgsUsing(set map[int]struct{})

func (*CallCmdSpec) MatchingWallets

func (spec *CallCmdSpec) MatchingWallets() []*WalletSpec

func (*CallCmdSpec) Validate

func (spec *CallCmdSpec) Validate(ctx AppContext, name string, root *Spec) bool

type CallCmds

type CallCmds map[string]*CallCmdSpec

func (CallCmds) CallCmdSpec

func (cmds CallCmds) CallCmdSpec(name string) (*CallCmdSpec, bool)

func (CallCmds) Validate

func (cmds CallCmds) Validate(ctx AppContext, spec *Spec) bool

type ConfigSpec

type ConfigSpec struct {
	GasPrice     string `yaml:"gasPrice"`
	GasLimit     string `yaml:"gasLimit"`
	ChainID      string `yaml:"chainID"`
	AwaitTimeout string `yaml:"awaitTimeout"`

	SpecDir string `yaml:"-"`
}

func (*ConfigSpec) AwaitTimeoutDuration

func (spec *ConfigSpec) AwaitTimeoutDuration() (time.Duration, error)

func (*ConfigSpec) ChainIDInt

func (spec *ConfigSpec) ChainIDInt() (*big.Int, bool)

func (*ConfigSpec) GasLimitInt

func (spec *ConfigSpec) GasLimitInt() (uint64, error)

func (*ConfigSpec) GasPriceInt

func (spec *ConfigSpec) GasPriceInt() (*big.Int, bool)

func (*ConfigSpec) Validate

func (spec *ConfigSpec) Validate() bool

type ContractInstanceSpec

type ContractInstanceSpec struct {
	Name    string `yaml:"contract"`
	Address string `yaml:"address"`
	// contains filtered or unexported fields
}

func (*ContractInstanceSpec) BoundContract

func (spec *ContractInstanceSpec) BoundContract() *ethfw.BoundContract

func (*ContractInstanceSpec) FetchTokenSymbol

func (spec *ContractInstanceSpec) FetchTokenSymbol(ctx AppContext) string

func (*ContractInstanceSpec) IsDeployed

func (spec *ContractInstanceSpec) IsDeployed() bool

func (*ContractInstanceSpec) TokenSymbol

func (spec *ContractInstanceSpec) TokenSymbol() string

func (*ContractInstanceSpec) Validate

func (spec *ContractInstanceSpec) Validate(ctx AppContext, name string, src *sol.Contract) bool

type ContractSpec

type ContractSpec struct {
	Name          string                  `yaml:"name"`
	SolPath       string                  `yaml:"sol"`
	SolAllowPaths []string                `yaml:"allow"`
	Instances     []*ContractInstanceSpec `yaml:"instances"`
	// contains filtered or unexported fields
}

func (*ContractSpec) Validate

func (spec *ContractSpec) Validate(ctx AppContext, name string) bool

type Contracts

type Contracts map[string]*ContractSpec

func (Contracts) ContractSpec

func (contracts Contracts) ContractSpec(name string) (*ContractSpec, bool)

func (Contracts) FindByTokenSymbol

func (contracts Contracts) FindByTokenSymbol(symbol string) (*ContractInstanceSpec, bool)

func (Contracts) UseSolc

func (contracts Contracts) UseSolc() bool

func (Contracts) Validate

func (contracts Contracts) Validate(ctx AppContext, spec *Spec) bool

type Evaler

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

func NewEvaler

func NewEvaler() *Evaler

func (*Evaler) Run

func (c *Evaler) Run(expr string, expected ...ExprType) (interface{}, error)

type ExprType

type ExprType string
const (
	ExprTypeBool     ExprType = "bool"
	ExprTypeFloat    ExprType = "float"
	ExprTypeInterger ExprType = "integer"
)

type ExtendedValue

type ExtendedValue struct {
	Value       *big.Int
	ValueWei    *ethfw.Wei
	Denominator string
}

type FieldName

type FieldName string
const (
	WalletSpecAddressField  FieldName = "address"
	WalletSpecPasswordField FieldName = "password"
	WalletSpecKeyStoreField FieldName = "keystore"
	WalletSpecKeyFileField  FieldName = "keyfile"
	WalletSpecBalanceField  FieldName = "balance"
)

type Inventory

type Inventory map[string]InventorySpec

func (Inventory) GetClient

func (inventory Inventory) GetClient(groupName string) (*rpc.Client, bool)

func (Inventory) Validate

func (inventory Inventory) Validate(ctx AppContext, spec *Spec) bool

type InventorySpec

type InventorySpec []string

func (*InventorySpec) Validate

func (spec *InventorySpec) Validate(ctx AppContext, groupName string) bool

type ParamSpec

type ParamSpec struct {
	Params []interface{} `yaml:"params"`
	// contains filtered or unexported fields
}

func (*ParamSpec) CountArgsUsing

func (spec *ParamSpec) CountArgsUsing(set map[int]struct{})

func (*ParamSpec) ParamValues

func (spec *ParamSpec) ParamValues() []interface{}

func (*ParamSpec) Validate

func (spec *ParamSpec) Validate(ctx AppContext, name string, root *Spec) bool

type ParamType

type ParamType string
const (
	ParamTypeString  ParamType = "string"
	ParamTypeInt     ParamType = "int"
	ParamTypeInt8    ParamType = "int8"
	ParamTypeInt16   ParamType = "int16"
	ParamTypeInt32   ParamType = "int32"
	ParamTypeInt64   ParamType = "int64"
	ParamTypeInt128  ParamType = "int128"
	ParamTypeInt256  ParamType = "int256"
	ParamTypeUInt    ParamType = "uint"
	ParamTypeUInt8   ParamType = "uint8"
	ParamTypeUInt16  ParamType = "uint16"
	ParamTypeUInt32  ParamType = "uint32"
	ParamTypeUInt64  ParamType = "uint64"
	ParamTypeUInt128 ParamType = "uint128"
	ParamTypeUInt256 ParamType = "uint256"
	ParamTypeBoolean ParamType = "bool"
	ParamTypeAddress ParamType = "address"
	ParamTypeByte    ParamType = "byte"
	ParamTypeBytes   ParamType = "bytes"
)

type Spec

type Spec struct {
	Config    *ConfigSpec `yaml:"CONFIG"`
	Inventory Inventory   `yaml:"INVENTORY"`
	Wallets   Wallets     `yaml:"WALLETS"`
	Contracts Contracts   `yaml:"CONTRACTS"`
	Targets   Targets     `yaml:"TARGETS"`

	ViewCmds  ViewCmds  `yaml:"VIEW"`
	WriteCmds WriteCmds `yaml:"WRITE"`
	CallCmds  CallCmds  `yaml:"CALL"`
	// contains filtered or unexported fields
}

func (*Spec) ArgCount

func (spec *Spec) ArgCount(name string) int

func (*Spec) CountArgsUsing

func (spec *Spec) CountArgsUsing(set map[int]struct{}, name string)

func (*Spec) Validate

func (spec *Spec) Validate(ctx AppContext) bool

type TargetCommandSpec

type TargetCommandSpec string

func (TargetCommandSpec) IsDeferred

func (spec TargetCommandSpec) IsDeferred() bool

func (TargetCommandSpec) Name

func (spec TargetCommandSpec) Name() string

type TargetSpec

type TargetSpec []TargetCommandSpec

func (TargetSpec) ArgCount

func (spec TargetSpec) ArgCount(root *Spec) int

func (TargetSpec) CmdNames

func (spec TargetSpec) CmdNames() []string

func (TargetSpec) Validate

func (spec TargetSpec) Validate(ctx AppContext, name string, root *Spec) bool

type Targets

type Targets map[string]TargetSpec

func (Targets) TargetSpec

func (targets Targets) TargetSpec(name string) (TargetSpec, bool)

func (Targets) Validate

func (targets Targets) Validate(ctx AppContext, spec *Spec) bool

type Valuer

type Valuer string

func (Valuer) CountArgsUsing

func (v Valuer) CountArgsUsing(set map[int]struct{})

func (Valuer) Parse

func (v Valuer) Parse(ctx AppContext, root *Spec, additionalDenominators []string) (*ExtendedValue, error)

type ViewCmdSpec

type ViewCmdSpec struct {
	ParamSpec   `yaml:",inline"`
	Description string `yaml:"desc"`

	Wallet string `yaml:"wallet"`
	Method string `yaml:"method"`

	Instance *ContractInstanceSpec `yaml:"instance"`
	// contains filtered or unexported fields
}

func (*ViewCmdSpec) ArgCount

func (spec *ViewCmdSpec) ArgCount() int

func (*ViewCmdSpec) CountArgsUsing

func (spec *ViewCmdSpec) CountArgsUsing(set map[int]struct{})

func (*ViewCmdSpec) MatchingWallets

func (spec *ViewCmdSpec) MatchingWallets() []*WalletSpec

func (*ViewCmdSpec) Validate

func (spec *ViewCmdSpec) Validate(ctx AppContext, name string, root *Spec) bool

type ViewCmds

type ViewCmds map[string]*ViewCmdSpec

func (ViewCmds) Validate

func (cmds ViewCmds) Validate(ctx AppContext, spec *Spec) bool

func (ViewCmds) ViewCmdSpec

func (cmds ViewCmds) ViewCmdSpec(name string) (*ViewCmdSpec, bool)

type WalletFieldReference

type WalletFieldReference struct {
	WalletName string
	FieldName  FieldName
}

type WalletSpec

type WalletSpec struct {
	Address  string   `yaml:"address"`
	PrivKey  string   `yaml:"privkey"`
	Password string   `yaml:"password"`
	KeyStore string   `yaml:"keystore"`
	KeyFile  string   `yaml:"keyfile"`
	Balance  *big.Int `yaml:"-"`
	// contains filtered or unexported fields
}

func (*WalletSpec) FieldValue

func (spec *WalletSpec) FieldValue(name FieldName) interface{}

func (*WalletSpec) HasField

func (spec *WalletSpec) HasField(name FieldName) bool

func (*WalletSpec) PrivKeyECDSA

func (spec *WalletSpec) PrivKeyECDSA() *ecdsa.PrivateKey

func (*WalletSpec) Validate

func (spec *WalletSpec) Validate(ctx AppContext, name string) bool

type Wallets

type Wallets map[string]*WalletSpec

func (Wallets) GetAll

func (wallets Wallets) GetAll(rx *regexp.Regexp) []*WalletSpec

func (Wallets) GetOne

func (wallets Wallets) GetOne(rx *regexp.Regexp, hash string) *WalletSpec

func (Wallets) NameOf

func (wallets Wallets) NameOf(address string) string

func (Wallets) Validate

func (wallets Wallets) Validate(ctx AppContext, spec *Spec) bool

func (Wallets) WalletSpec

func (wallets Wallets) WalletSpec(name string) (*WalletSpec, bool)

type WriteCmdSpec

type WriteCmdSpec struct {
	ParamSpec   `yaml:",inline"`
	Description string `yaml:"desc"`

	Wallet string `yaml:"wallet"`
	Sticky string `yaml:"sticky"`
	To     string `yaml:"to"`
	Value  Valuer `yaml:"value"`
	Method string `yaml:"method"`

	Instance *ContractInstanceSpec `yaml:"instance"`
	// contains filtered or unexported fields
}

func (*WriteCmdSpec) ArgCount

func (spec *WriteCmdSpec) ArgCount() int

func (*WriteCmdSpec) CountArgsUsing

func (spec *WriteCmdSpec) CountArgsUsing(set map[int]struct{})

func (*WriteCmdSpec) MatchingWallet

func (spec *WriteCmdSpec) MatchingWallet() *WalletSpec

func (*WriteCmdSpec) Validate

func (spec *WriteCmdSpec) Validate(ctx AppContext, name string, root *Spec) bool

type WriteCmds

type WriteCmds map[string]*WriteCmdSpec

func (WriteCmds) Validate

func (cmds WriteCmds) Validate(ctx AppContext, spec *Spec) bool

func (WriteCmds) WriteCmdSpec

func (cmds WriteCmds) WriteCmdSpec(name string) (*WriteCmdSpec, bool)

Jump to

Keyboard shortcuts

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