ethereum

package
v0.0.0-...-086ef7a Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtrBRG              = "BridgeToken"
	CtrForwarderFactory = "ForwarderFactory"
	CtrRoot             = "Root"
	CtrSWC              = "SweetToken"
	CtrSWCqueue         = "SWCqueue"
	CtrSWClogic         = "SweetTokenLogic"
	CtrTokenLogic       = "TokenLogic"
	CtrTreasury         = "Treasury"
	CtrUserDirectory    = "UserDirectory"
	CtrVault            = "Vault"
	CtrVaultConfig      = "VaultConfig"
	CtrWallet           = "Wallet"
)

Contract names

Variables

View Source
var ZeroAddress = common.HexToAddress("00")

ZeroAddress represents Ethereum unknown or invalid address

Functions

func FlogTx

func FlogTx(w io.Writer, msg string, tx *types.Transaction)

FlogTx logs transaction into a Writer

func HashToAddress

func HashToAddress(h common.Hash) (common.Address, errstack.E)

HashToAddress encodes address from hash data

func IncNonce

func IncNonce(nonce *big.Int) *big.Int

IncNonce increments nonce by one and returns updated nonce

func IncTxoNonce

func IncTxoNonce(txo *bind.TransactOpts, tx *types.Transaction)

IncTxoNonce increments transaction options nonce

func IsZeroAddr

func IsZeroAddr(a common.Address) bool

IsZeroAddr check if `a` is zero or invalid address

func LogTx

func LogTx(msg string, tx *types.Transaction)

LogTx is a handy function to create debug log for successful transaction

func MustHaveEvents

func MustHaveEvents(e abi.ABI, eventNames ...string)

MustHaveEvents ensures that the ABI object has listed events

func MustParseABI

func MustParseABI(name string, ctrABI string) abi.ABI

MustParseABI parses abi string

func ParseAddress

func ParseAddress(addr string) (a common.Address, err errstack.E)

ParseAddress converts hex string to Ethereum address

func ParseAddressErrp

func ParseAddressErrp(addr string, errp errstack.Putter) common.Address

ParseAddressErrp calls ToAddress and sets the error in the putter

func SubscribeSimple

func SubscribeSimple(ctx context.Context,
	client *ethclient.Client,
	topics [][]common.Hash, addresses []common.Address) (<-chan types.Log, ethereum.Subscription, errstack.E)

SubscribeSimple is a simple utility function to create events subscription

func UnmarshalEvent

func UnmarshalEvent(dest interface{}, data []byte, e abi.Event) errstack.E

UnmarshalEvent blockchain log into the event structure `dest` must be a pointer to initialized structure

Types

type ContractFactory

type ContractFactory interface {
	GetBRG() (*contracts.BridgeToken, common.Address, errstack.E)
	GetSWC() (*contracts.SweetToken, common.Address, errstack.E)
	GetSWClogic() (*contracts.SweetTokenLogic, common.Address, errstack.E)
	GetSWCqueue() (*contracts.SWCqueue, common.Address, errstack.E)
	GetForwarderFactory() (*contracts.ForwarderFactory, common.Address, errstack.E)

	Client() *ethclient.Client
	TxrFactory
}

ContractFactory delivers methods to easily construct contracts

func NewContractFactory

func NewContractFactory(c *ethclient.Client, sf SchemaFactory, txrF TxrFactory, isTestRPC bool) ContractFactory

NewContractFactory is a default contract provider based on truffle schema files.

type KeySimple

type KeySimple struct {
	Address common.Address
	ID      string
	Version int
}

KeySimple is a simple version of keystore.Key structure

func MustReadKeySimple

func MustReadKeySimple(JSONFile string) KeySimple

MustReadKeySimple calls ReadKeySimple and panics if it get's an error

func ReadKeySimple

func ReadKeySimple(JSONFile string) (KeySimple, errstack.E)

ReadKeySimple reads the JSON key into the key object

func (*KeySimple) UnmarshalJSON

func (k *KeySimple) UnmarshalJSON(j []byte) (err error)

UnmarshalJSON implement interface for json.Unmrashall

type NetSchema

type NetSchema struct {
	Address   string
	UpdatedAt int `json:"updated_at"`
}

NetSchema is a type representing truffle-schema network description

type PgtAddress

type PgtAddress struct {
	common.Address
}

PgtAddress is a ethereum Address wrapper to provide DB interface

func (*PgtAddress) Scan

func (a *PgtAddress) Scan(src interface{}) error

Scan implements sql.Sanner interface

func (PgtAddress) Value

func (a PgtAddress) Value() (driver.Value, error)

Value implements sql/driver.Valuer

type PgtHash

type PgtHash struct {
	common.Hash
}

PgtHash is an ethereum common.Hash wrapper to provide DB interface

func (*PgtHash) Scan

func (a *PgtHash) Scan(src interface{}) error

Scan implements sql.Sanner interface

func (*PgtHash) Value

func (a *PgtHash) Value() (driver.Value, error)

Value implements sql/driver.Valuer

type Schema

type Schema struct {
	Name          string `json:"contractName"`
	Networks      map[int]NetSchema
	SchemaVersion string `json:"schemaVersion"`
	UpdatedAt     string `json:"updatedAt"`
}

Schema is a type representing truffle-schema contract file

func (Schema) Address

func (s Schema) Address(networkID int) (a common.Address, e errstack.E)

Address is a handy method which returns smart contract address deployed for given network

type SchemaFactory

type SchemaFactory struct {
	Dir     string
	Network int
}

SchemaFactory is a structure which provides contract schema functions and data

func NewSchemaFactory

func NewSchemaFactory(contractsPath string, network int) (SchemaFactory, errstack.E)

NewSchemaFactory creates new SchemaFactory.

func (SchemaFactory) MustReadGetAddress

func (sf SchemaFactory) MustReadGetAddress(name string) (Schema, common.Address)

MustReadGetAddress returns contract schema and address and panics on error

func (SchemaFactory) Read

func (sf SchemaFactory) Read(name string) (s Schema, err errstack.E)

Read reads truffle-schema file. The name should not finish with ".json"

func (SchemaFactory) ReadGetAddress

func (sf SchemaFactory) ReadGetAddress(name string) (s Schema, a common.Address, err errstack.E)

ReadGetAddress reads schema using `Read` and extract contract address using then network identifier.

type TxrFactory

type TxrFactory interface {
	Txo() *bind.TransactOpts
	Addr() common.Address
}

TxrFactory wraps parameters to create bind.TransactOpts

func NewJSONTxrFactory

func NewJSONTxrFactory(filename, passphrase string) (TxrFactory, errstack.E)

NewJSONTxrFactory creates TxrFactory using on JSON account file and passphrase

func NewPrivKeyTxrFactory

func NewPrivKeyTxrFactory(hexkey string) (TxrFactory, errstack.E)

NewPrivKeyTxrFactory creates new transactor using a hex string of a ECDSA key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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