itx

package
v1.0.33 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTransactionOptions = transactor.TransactOptions{
		GasLimit: 400000,
		GasPrice: big.NewInt(1),
		Priority: 1,
		Value:    big.NewInt(0),
	}
)
View Source
var ItxTxPriorities = map[uint8]string{
	1: "slow",
	2: "slow",
	3: "fast",
}

itx only supports priority as string - we use uint8 to save on data currently we support only "slow" and "fast" - that's why 2 (medium) defaults to slow

Functions

This section is empty.

Types

type Forwarder

type Forwarder interface {
	ForwarderAddress() common.Address
	ChainId() *big.Int
	UnsafeNonce() (*big.Int, error)
	UnsafeIncreaseNonce()
	LockNonce()
	UnlockNonce()
	ForwarderData(to *common.Address, data []byte, opts transactor.TransactOptions) ([]byte, error)
}

type ForwarderContract

type ForwarderContract interface {
	GetNonce(from common.Address) (*big.Int, error)
	PrepareExecute(forwardReq forwarder.ForwardRequest, sig []byte) ([]byte, error)
	ContractAddress() *common.Address
}

type ITXTransactor

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

func NewITXTransactor

func NewITXTransactor(relayCaller RelayCaller, forwarder Forwarder, kp *secp256k1.Keypair) *ITXTransactor

func (*ITXTransactor) Transact

func (itx *ITXTransactor) Transact(to *common.Address, data []byte, opts transactor.TransactOptions) (*common.Hash, error)

Transact packs tx into a forwarded transaction, signs it and sends the relayed transaction to Infura ITX

type MinimalForwarder

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

func NewMinimalForwarder

func NewMinimalForwarder(chainID *big.Int, kp *secp256k1.Keypair, forwarderContract ForwarderContract, nonceStore NonceStorer) *MinimalForwarder

NewMinimalForwarder creates an instance of MinimalForwarder

func (*MinimalForwarder) ChainId

func (c *MinimalForwarder) ChainId() *big.Int

func (*MinimalForwarder) ForwarderAddress

func (c *MinimalForwarder) ForwarderAddress() common.Address

func (*MinimalForwarder) ForwarderData

func (c *MinimalForwarder) ForwarderData(to *common.Address, data []byte, opts transactor.TransactOptions) ([]byte, error)

ForwarderData returns ABI packed and signed byte data for a forwarded transaction

func (*MinimalForwarder) LockNonce

func (c *MinimalForwarder) LockNonce()

LockNonce locks mutex for nonce to prevent nonce duplication

func (*MinimalForwarder) UnlockNonce

func (c *MinimalForwarder) UnlockNonce()

UnlockNonce unlocks mutext for nonce and stores nonce into storage.

Nonce is stored on unlock, because current nonce should always be the correct one when unlocking.

func (*MinimalForwarder) UnsafeIncreaseNonce

func (c *MinimalForwarder) UnsafeIncreaseNonce()

UnsafeIncreaseNonce increases nonce value by 1. Should be used while nonce is locked.

func (*MinimalForwarder) UnsafeNonce

func (c *MinimalForwarder) UnsafeNonce() (*big.Int, error)

UnsafeNonce returns current valid nonce for a forwarded transaction.

If nonce is not set, looks for nonce in storage and on contract and returns the higher one. Nonce in storage can be higher if there are pending transactions after relayer has been manually shutdown.

type NonceStorer

type NonceStorer interface {
	StoreNonce(chainID *big.Int, nonce *big.Int) error
	GetNonce(chainID *big.Int) (*big.Int, error)
}

type RelayCaller

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

type RelayTx

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

type SignedRelayTx

type SignedRelayTx struct {
	*RelayTx
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package mock_itx is a generated GoMock package.
Package mock_itx is a generated GoMock package.

Jump to

Keyboard shortcuts

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