eth

package
v0.0.0-...-d3d27b2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallMethod

func CallMethod(ctx context.Context, rpc RPCClient, signer TXSigner, from, addr string, value json.Number, methodABI *ethbinding.ABIMethod, msgParams []interface{}, blocknumber string) (map[string]interface{}, error)

CallMethod performs eth_call to return data from the chain

func CobraInitRPC

func CobraInitRPC(cmd *cobra.Command, rconf *RPCConf)

CobraInitRPC sets the standard command-line parameters for RPC

func DecodeInputs

func DecodeInputs(method *ethbinding.ABIMethod, inputs *ethbinding.HexBytes) (map[string]interface{}, error)

Decode the "input" bytes from a transaction, which are composed of a method ID + encoded arguments

func GetOrionPrivacyGroup

func GetOrionPrivacyGroup(ctx context.Context, rpc RPCClient, addr *ethbinding.Address, privateFrom string, privateFor []string) (string, error)

GetOrionPrivacyGroup resolves privateFrom/privateFor into a privacyGroupID

func GetOrionTXCount

func GetOrionTXCount(ctx context.Context, rpc RPCClient, addr *ethbinding.Address, privacyGroup string) (int64, error)

GetOrionTXCount uses the special Pantheon/Orion interface to check the next nonce for the privacy group associated with the privateFrom/privateFor combination

func GetSolcArgs

func GetSolcArgs(evmVersion string) []string

GetSolcArgs get the correct solc args

func GetTransactionCount

func GetTransactionCount(ctx context.Context, rpc RPCClient, addr *ethbinding.Address, blockNumber string) (int64, error)

GetTransactionCount gets the transaction count for an address

func ProcessRLPBytes

func ProcessRLPBytes(args ethbinding.ABIArguments, retBytes []byte) map[string]interface{}

ProcessRLPBytes converts binary packed set of bytes into a map. Does not throw errors, rather embeds them into the result set to send back to the caller.

Types

type CompiledSolidity

type CompiledSolidity struct {
	ContractName string
	Compiled     []byte
	DevDoc       string
	ABI          ethbinding.ABIMarshaling
	ContractInfo *ethbinding.ContractInfo
}

CompiledSolidity wraps solc compilation of solidity and ABI generation

func CompileContract

func CompileContract(soliditySource, contractName, requestedVersion, evmVersion string) (*CompiledSolidity, error)

CompileContract uses solc to compile the Solidity source and

func ProcessCompiled

func ProcessCompiled(compiled map[string]*ethbinding.Contract, contractName string, isStdin bool) (*CompiledSolidity, error)

ProcessCompiled takes solc output and packs it into our CompiledSolidity structure

type EthCommonConf

type EthCommonConf struct {
	GasEstimationFactor float64 `json:"gasEstimationFactor"`
}

type OrionPrivacyGroup

type OrionPrivacyGroup struct {
	PrivacyGroupID string `json:"privacyGroupId"`
}

OrionPrivacyGroup is the result of the priv_findPrivacyGroup call

type RPCClient

type RPCClient interface {
	CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
}

RPCClient refers to the functions from the ethereum RPC client that we use

type RPCClientAll

type RPCClientAll interface {
	RPCClosable
	RPCClient
	RPCClientAsync
}

RPCClientAll has both sync and async interfaces (splitting out helps callers with limiting their mocks)

func RPCConnect

func RPCConnect(conf *RPCConnOpts) (RPCClientAll, error)

RPCConnect wraps rpc.Dial with useful logging, avoiding logging username/password

type RPCClientAsync

type RPCClientAsync interface {
	Subscribe(ctx context.Context, namespace string, channel interface{}, args ...interface{}) (RPCClientSubscription, error)
}

RPCClientAsync refers to the async functions from the ethereum RPC client that we use

type RPCClientSubscription

type RPCClientSubscription interface {
	Unsubscribe()
	Err() <-chan error
}

RPCClientSubscription local alias type for ClientSubscription

type RPCClosable

type RPCClosable interface {
	Close()
}

RPCClosable contains the close

type RPCConf

type RPCConf struct {
	RPC RPCConnOpts `json:"rpc"`
}

RPCConf is the standard snippet to include in YAML config for RPC

type RPCConnOpts

type RPCConnOpts struct {
	URL string `json:"url"`
}

RPCConnOpts configuration params

type SendTXArgs

type SendTXArgs struct {
	Nonce    *ethbinding.HexUint64 `json:"nonce,omitempty"`
	From     string                `json:"from"`
	To       string                `json:"to,omitempty"`
	Gas      *ethbinding.HexUint64 `json:"gas,omitempty"`
	GasPrice ethbinding.HexBigInt  `json:"gasPrice,omitempty"`
	Value    ethbinding.HexBigInt  `json:"value,omitempty"`
	Data     *ethbinding.HexBytes  `json:"data"`
	// EEA spec extensions
	PrivateFrom    string   `json:"privateFrom,omitempty"`
	PrivateFor     []string `json:"privateFor,omitempty"`
	PrivacyGroupID string   `json:"privacyGroupId,omitempty"`
	Restriction    string   `json:"restriction,omitempty"`
}

SendTXArgs is the JSON arguments that can be passed to an eth_sendTransaction call, and also the interface passed to the signer in the case of pre-signing

type SolcVersion

type SolcVersion struct {
	Path    string
	Version string
}

func GetSolc

func GetSolc(requestedVersion string) (*SolcVersion, error)

GetSolc returns the appropriate solc command based on the combination of env vars, and message-specific request parameters passed in

type TXSigner

type TXSigner interface {
	Type() string
	Address() string
	Sign(tx *ethbinding.Transaction) ([]byte, error)
}

TXSigner is an interface for pre-signing signing using the parameters of eth_sendTransaction

type Txn

type Txn struct {
	NodeAssignNonce  bool
	OrionPrivateAPIS bool
	From             ethbinding.Address
	EthTX            *ethbinding.Transaction
	Hash             string
	Receipt          TxnReceipt
	PrivateFrom      string
	PrivateFor       []string
	PrivacyGroupID   string
	Signer           TXSigner
	Method           *ethbinding.ABIMethod
}

Txn wraps an ethereum transaction, along with the logic to send it over JSON/RPC to a node

func NewContractDeployTxn

func NewContractDeployTxn(msg *messages.DeployContract, signer TXSigner) (tx *Txn, err error)

NewContractDeployTxn builds a new ethereum transaction from the supplied SendTranasction message

func NewNilTX

func NewNilTX(from string, nonce int64, signer TXSigner) (tx *Txn, err error)

NewNilTX returns a transaction without any data from/to the same address

func NewRawSendTxn

func NewRawSendTxn(signer TXSigner, from, to string, nonce, value, gas, gasPrice json.Number, txData []byte) (tx *Txn, err error)

NewRawSendTxn is used for sending a transaction (cannot use to call), where the input data is already formatted.

func NewSendTxn

func NewSendTxn(msg *messages.SendTransaction, signer TXSigner) (tx *Txn, err error)

NewSendTxn builds a new ethereum transaction from the supplied SendTranasction message

func (*Txn) Call

func (tx *Txn) Call(ctx context.Context, rpc RPCClient, blocknumber string) (res []byte, reverted bool, err error)

Call synchronously calls the method, without mining a transaction, and returns the result as RLP encoded bytes or nil

func (*Txn) CallAndProcessReply

func (tx *Txn) CallAndProcessReply(ctx context.Context, rpc RPCClient, blocknumber string) (map[string]interface{}, error)

func (*Txn) Estimate

func (tx *Txn) Estimate(ctx context.Context, rpc RPCClient, estimationFactor float64) (data ethbinding.HexBytes, gas ethbinding.HexUint64, reverted bool, err error)

func (*Txn) GetTXReceipt

func (tx *Txn) GetTXReceipt(ctx context.Context, rpc RPCClient) (bool, error)

GetTXReceipt gets the receipt for the transaction

func (*Txn) Send

func (tx *Txn) Send(ctx context.Context, rpc RPCClient, estimationFactor float64) (err error)

Send sends an individual transaction, choosing external or internal signing

type TxnInfo

type TxnInfo struct {
	BlockHash        *ethbinding.Hash      `json:"blockHash,omitempty"`
	BlockNumber      *ethbinding.HexBigInt `json:"blockNumber,omitempty"`
	From             *ethbinding.Address   `json:"from,omitempty"`
	To               *ethbinding.Address   `json:"to,omitempty"`
	Gas              *ethbinding.HexUint64 `json:"gas"`
	GasPrice         *ethbinding.HexBigInt `json:"gasPrice"`
	Hash             *ethbinding.Hash      `json:"hash"`
	Nonce            *ethbinding.HexUint64 `json:"nonce"`
	TransactionIndex *ethbinding.HexUint64 `json:"transactionIndex"`
	Value            *ethbinding.HexBigInt `json:"value"`
	Input            *ethbinding.HexBytes  `json:"input"`
}

TxnInfo is the detailed transaction info returned by eth_getTransactionByXXXXX

func GetTransactionInfo

func GetTransactionInfo(ctx context.Context, rpc RPCClient, txHash string) (*TxnInfo, error)

type TxnReceipt

type TxnReceipt struct {
	BlockHash         *ethbinding.Hash      `json:"blockHash"`
	BlockNumber       *ethbinding.HexBigInt `json:"blockNumber"`
	ContractAddress   *ethbinding.Address   `json:"contractAddress"`
	CumulativeGasUsed *ethbinding.HexBigInt `json:"cumulativeGasUsed"`
	TransactionHash   *ethbinding.Hash      `json:"transactionHash"`
	From              *ethbinding.Address   `json:"from"`
	GasUsed           *ethbinding.HexBigInt `json:"gasUsed"`
	Status            *ethbinding.HexBigInt `json:"status"`
	To                *ethbinding.Address   `json:"to"`
	TransactionIndex  *ethbinding.HexUint   `json:"transactionIndex"`
}

TxnReceipt is the receipt obtained over JSON/RPC from the ethereum client

Jump to

Keyboard shortcuts

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