tx

package
v0.0.0-...-0001d10 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const StatusOK = 1

StatusOK defined by ethereum is the value of status for a transaction that succeeds

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks interface {
	// TransactionCommitted is called when the owner has successfully committed a
	// transaction
	TransactionCommitted(ctx context.Context, body callback.TransactionCommittedBody)

	// WalletOutOfFunds is called when the wallet owned by the
	// WalletOwner does not have enough funds for a transaction
	WalletOutOfFunds(ctx context.Context, body callback.WalletOutOfFundsBody)

	// WalletReachedFundsThreshold is called when the wallet owned by the
	// WalletOwner realizes it's wallet balance has go down a certain
	// threshold
	WalletReachedFundsThreshold(ctx context.Context, body callback.WalletReachedFundsThresholdBody)
}

Callbacks implemented by the WalletOwner

type ExecuteRequest

type ExecuteRequest struct {
	// AAD is the identifier of the original issuer for the transaction data
	AAD string

	// Transaction ID
	ID uint64

	// Address to which to execute transaction
	Address string

	// Transaction data
	Data []byte
}

ExecuteRequest is the request to execute an Ethereum transaction

type ExecuteResponse

type ExecuteResponse struct {
	Address string
	Output  string
	Hash    string
}

type Executor

type Executor struct {
	WalletAddresses []common.Address
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(ctx context.Context, services *ExecutorServices, props *ExecutorProps) (*Executor, error)

func (*Executor) Execute

Executes the desired transaction.

func (*Executor) Name

func (m *Executor) Name() string

func (*Executor) Stats

func (m *Executor) Stats() stats.Metrics

type ExecutorProps

type ExecutorProps struct {
	PrivateKeys []*ecdsa.PrivateKey
}

type ExecutorServices

type ExecutorServices struct {
	Logger    log.Logger
	Client    eth.Client
	Callbacks Callbacks
}

type InternalWallet

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

func NewWallet

func NewWallet(
	privateKey *ecdsa.PrivateKey,
	signer types.Signer,
) *InternalWallet

func (*InternalWallet) Address

func (w *InternalWallet) Address() common.Address

func (*InternalWallet) SignTransaction

func (w *InternalWallet) SignTransaction(tx *types.Transaction) (*types.Transaction, errors.Err)

type Wallet

type Wallet interface {
	Address() common.Address
	SignTransaction(tx *types.Transaction) (*types.Transaction, errors.Err)
}

Wallet is an interface for any type that signs transactions and receives responses

type WalletOwner

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

WalletOwner is the only instance that should interact with a wallet. Its main goal is to send transactions and keep the funding and nonce of the wallet up to date

func NewWalletOwner

func NewWalletOwner(
	ctx context.Context,
	services *WalletOwnerServices,
	props *WalletOwnerProps,
) (*WalletOwner, error)

NewWalletOwner creates a new instance of a wallet owner. The wallet is derived from the private key provided

type WalletOwnerProps

type WalletOwnerProps struct {
	PrivateKey *ecdsa.PrivateKey
	Signer     types.Signer
	Nonce      uint64
}

type WalletOwnerServices

type WalletOwnerServices struct {
	Client    eth.Client
	Callbacks Callbacks
	Logger    log.Logger
}

Jump to

Keyboard shortcuts

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