evm

package
v0.0.0-...-b63df41 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COMPONENT_NAME = "EvmClient"
	RETRY_INTERVAL = time.Second * 12 // Initial retry interval
)

Variables

This section is empty.

Functions

func AbiUnpack

func AbiUnpack(data []byte, types ...string) ([]interface{}, error)

func AbiUnpackIntoMap

func AbiUnpackIntoMap(v map[string]interface{}, data []byte, types ...byte) error

func CreateEvmAuth

func CreateEvmAuth(evmConfig *EvmNetworkConfig) (*bind.TransactOpts, error)

func CreateGateway

func CreateGateway(networName string, gwAddr string, client *ethclient.Client) (*contracts.IScalarGateway, *common.Address, error)

func GetMissingEvents

func GetMissingEvents[T ValidEvmEvent](c *EvmClient, eventName string, lastCheckpoint *models.EventCheckPoint, fnCreateEventData func(types.Log) T) ([]*parser.EvmEvent[T], error)

Get missing events from the last checkpoint block number to the current block number In query we filter out the event with index equal to the last checkpoint log index

func RecoverEvent

func RecoverEvent[T ValidEvmEvent](c *EvmClient, ctx context.Context, eventName string, fnCreateEventData func(types.Log) T) error

Try to recover missing events from the last checkpoint block number to the current block number

Types

type ApproveContractCall

type ApproveContractCall struct {
	ChainId    uint64
	CommandIds [][32]byte
	Commands   []string
	Params     [][]byte
}

func DecodeApproveContractCall

func DecodeApproveContractCall(input []byte) (*ApproveContractCall, error)

type Byte32

type Byte32 [32]uint8

type Bytes

type Bytes []byte

type DecodedExecuteData

type DecodedExecuteData struct {
	//Data
	ChainId    uint64
	CommandIds [][32]byte
	Commands   []string
	Params     [][]byte
	//Proof
	Operators  []common.Address
	Weights    []uint64
	Threshold  uint64
	Signatures []string
	//Input
	Input []byte
}

func DecodeExecuteData

func DecodeExecuteData(executeData string) (*DecodedExecuteData, error)

func DecodeInput

func DecodeInput(input []byte) (*DecodedExecuteData, error)

type DeployToken

type DeployToken struct {
	//Data
	Name         string
	Symbol       string
	Decimals     uint8
	Cap          uint64
	TokenAddress common.Address
	MintLimit    uint64
}

func DecodeDeployToken

func DecodeDeployToken(input []byte) (*DeployToken, error)

type EvmClient

type EvmClient struct {
	Client         *ethclient.Client
	ScalarClient   *scalar.Client
	ChainName      string
	GatewayAddress common.Address
	Gateway        *contracts.IScalarGateway
	// contains filtered or unexported fields
}

func NewEvmClient

func NewEvmClient(globalConfig *config.Config, evmConfig *EvmNetworkConfig, dbAdapter *db.DatabaseAdapter, eventBus *events.EventBus, scalarClient *scalar.Client) (*EvmClient, error)

func NewEvmClients

func NewEvmClients(globalConfig *config.Config, dbAdapter *db.DatabaseAdapter, eventBus *events.EventBus, scalarClient *scalar.Client) ([]*EvmClient, error)

func (*EvmClient) AddPendingTx

func (c *EvmClient) AddPendingTx(txHash string, timestamp time.Time)

func (*EvmClient) CommandExecutedEvent2Model

func (c *EvmClient) CommandExecutedEvent2Model(event *contracts.IScalarGatewayExecuted) chains.CommandExecuted

func (*EvmClient) ConnectWithRetry

func (c *EvmClient) ConnectWithRetry(ctx context.Context)

func (*EvmClient) ContractCallApprovedEvent2Model

func (c *EvmClient) ContractCallApprovedEvent2Model(event *contracts.IScalarGatewayContractCallApproved) (models.ContractCallApproved, error)

func (*EvmClient) ContractCallEvent2Model

func (c *EvmClient) ContractCallEvent2Model(event *contracts.IScalarGatewayContractCall) (chains.ContractCall, error)

func (*EvmClient) ContractCallWithToken2Model

func (*EvmClient) ExecuteDestinationCall

func (ec *EvmClient) ExecuteDestinationCall(
	contractAddress common.Address,
	commandId [32]byte,
	sourceChain string,
	sourceAddress string,
	payload []byte,
) (*ethtypes.Transaction, error)

func (*EvmClient) GetTokenContractAddressFromSymbol

func (c *EvmClient) GetTokenContractAddressFromSymbol(symbol string, sourceChain string) string

Todo: Implement this function

func (*EvmClient) HandleCommandExecuted

func (ec *EvmClient) HandleCommandExecuted(event *contracts.IScalarGatewayExecuted) error

func (*EvmClient) HandleContractCallApproved

func (ec *EvmClient) HandleContractCallApproved(event *contracts.IScalarGatewayContractCallApproved) error

func (*EvmClient) HandleTokenSent

func (ec *EvmClient) HandleTokenSent(event *contracts.IScalarGatewayTokenSent) error

func (*EvmClient) ListenToEvents

func (c *EvmClient) ListenToEvents(ctx context.Context) error

func (*EvmClient) PollTxForEvents

func (c *EvmClient) PollTxForEvents(pendingTx pending.PendingTx) (*parser.AllEvmEvents, error)

func (*EvmClient) RecoverMissingEvents

func (c *EvmClient) RecoverMissingEvents(ctx context.Context) error

func (*EvmClient) SetAuth

func (c *EvmClient) SetAuth(auth *bind.TransactOpts)

func (*EvmClient) Start

func (c *EvmClient) Start(ctx context.Context) error

func (*EvmClient) SubmitTx

func (ec *EvmClient) SubmitTx(signedTx *ethtypes.Transaction, retryAttempt int) (*ethtypes.Receipt, error)

func (*EvmClient) TokenSentEvent2Model

func (c *EvmClient) TokenSentEvent2Model(event *contracts.IScalarGatewayTokenSent) (chains.TokenSent, error)

func (*EvmClient) VerifyDeployTokens

func (c *EvmClient) VerifyDeployTokens(ctx context.Context) error

func (*EvmClient) WaitForTransaction

func (ec *EvmClient) WaitForTransaction(hash string) (*ethtypes.Receipt, error)

func (*EvmClient) WatchEVMTokenSent

func (c *EvmClient) WatchEVMTokenSent(watchOpts *bind.WatchOpts) error

func (*EvmClient) WatchPendingTxs

func (c *EvmClient) WatchPendingTxs()

Process pending transactions

type EvmNetworkConfig

type EvmNetworkConfig struct {
	ChainID         uint64        `mapstructure:"chain_id"`
	ID              string        `mapstructure:"id"`
	Name            string        `mapstructure:"name"`
	RPCUrl          string        `mapstructure:"rpc_url"`
	Gateway         string        `mapstructure:"gateway"`
	Finality        int           `mapstructure:"finality"`
	LastBlock       uint64        `mapstructure:"last_block"`
	PrivateKey      string        `mapstructure:"private_key"`
	GasLimit        uint64        `mapstructure:"gas_limit"`
	BlockTime       time.Duration `mapstructure:"blockTime"` //Timeout im ms for pending txs
	MaxRetry        int
	MaxRecoverRange uint64 `mapstructure:"max_recover_range"`
	RetryDelay      time.Duration
	TxTimeout       time.Duration `mapstructure:"tx_timeout"` //Timeout for send txs (~3s)
}

func (*EvmNetworkConfig) GetChainId

func (c *EvmNetworkConfig) GetChainId() uint64

func (*EvmNetworkConfig) GetFamily

func (c *EvmNetworkConfig) GetFamily() string

func (*EvmNetworkConfig) GetId

func (c *EvmNetworkConfig) GetId() string

func (*EvmNetworkConfig) GetName

func (c *EvmNetworkConfig) GetName() string

type ExecuteData

type ExecuteData[T any] struct {
	//Data
	Data T
	//Proof
	Operators  []common.Address
	Weights    []uint64
	Threshold  uint64
	Signatures []string
	//Input
	Input []byte
}

Directories

Path Synopsis
contracts

Jump to

Keyboard shortcuts

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