Documentation
¶
Index ¶
- Constants
- func AbiUnpack(data []byte, types ...string) ([]interface{}, error)
- func AbiUnpackIntoMap(v map[string]interface{}, data []byte, types ...byte) error
- func CreateEvmAuth(evmConfig *EvmNetworkConfig) (*bind.TransactOpts, error)
- func CreateGateway(networName string, gwAddr string, client *ethclient.Client) (*contracts.IScalarGateway, *common.Address, error)
- func GetMissingEvents[T ValidEvmEvent](c *EvmClient, eventName string, lastCheckpoint *models.EventCheckPoint, ...) ([]*parser.EvmEvent[T], error)
- func RecoverEvent[T ValidEvmEvent](c *EvmClient, ctx context.Context, eventName string, ...) error
- type ApproveContractCall
- type Byte32
- type Bytes
- type DecodedExecuteData
- type DeployToken
- type EvmClient
- func (c *EvmClient) AddPendingTx(txHash string, timestamp time.Time)
- func (c *EvmClient) CommandExecutedEvent2Model(event *contracts.IScalarGatewayExecuted) chains.CommandExecuted
- func (c *EvmClient) ConnectWithRetry(ctx context.Context)
- func (c *EvmClient) ContractCallApprovedEvent2Model(event *contracts.IScalarGatewayContractCallApproved) (models.ContractCallApproved, error)
- func (c *EvmClient) ContractCallEvent2Model(event *contracts.IScalarGatewayContractCall) (chains.ContractCall, error)
- func (c *EvmClient) ContractCallWithToken2Model(event *contracts.IScalarGatewayContractCallWithToken) (chains.ContractCallWithToken, error)
- func (ec *EvmClient) ExecuteDestinationCall(contractAddress common.Address, commandId [32]byte, sourceChain string, ...) (*ethtypes.Transaction, error)
- func (c *EvmClient) GetTokenContractAddressFromSymbol(symbol string, sourceChain string) string
- func (ec *EvmClient) HandleCommandExecuted(event *contracts.IScalarGatewayExecuted) error
- func (ec *EvmClient) HandleContractCallApproved(event *contracts.IScalarGatewayContractCallApproved) error
- func (ec *EvmClient) HandleTokenSent(event *contracts.IScalarGatewayTokenSent) error
- func (c *EvmClient) ListenToEvents(ctx context.Context) error
- func (c *EvmClient) PollTxForEvents(pendingTx pending.PendingTx) (*parser.AllEvmEvents, error)
- func (c *EvmClient) RecoverMissingEvents(ctx context.Context) error
- func (c *EvmClient) SetAuth(auth *bind.TransactOpts)
- func (c *EvmClient) Start(ctx context.Context) error
- func (ec *EvmClient) SubmitTx(signedTx *ethtypes.Transaction, retryAttempt int) (*ethtypes.Receipt, error)
- func (c *EvmClient) TokenSentEvent2Model(event *contracts.IScalarGatewayTokenSent) (chains.TokenSent, error)
- func (c *EvmClient) VerifyDeployTokens(ctx context.Context) error
- func (ec *EvmClient) WaitForTransaction(hash string) (*ethtypes.Receipt, error)
- func (c *EvmClient) WatchEVMTokenSent(watchOpts *bind.WatchOpts) error
- func (c *EvmClient) WatchPendingTxs()
- type EvmNetworkConfig
- type ExecuteData
- type ValidEvmEvent
Constants ¶
View Source
const ( COMPONENT_NAME = "EvmClient" RETRY_INTERVAL = time.Second * 12 // Initial retry interval )
Variables ¶
This section is empty.
Functions ¶
func AbiUnpackIntoMap ¶
func CreateEvmAuth ¶
func CreateEvmAuth(evmConfig *EvmNetworkConfig) (*bind.TransactOpts, error)
func CreateGateway ¶
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 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 NewEvmClients ¶
func (*EvmClient) AddPendingTx ¶
func (*EvmClient) CommandExecutedEvent2Model ¶
func (c *EvmClient) CommandExecutedEvent2Model(event *contracts.IScalarGatewayExecuted) chains.CommandExecuted
func (*EvmClient) ConnectWithRetry ¶
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 (c *EvmClient) ContractCallWithToken2Model(event *contracts.IScalarGatewayContractCallWithToken) (chains.ContractCallWithToken, error)
func (*EvmClient) ExecuteDestinationCall ¶
func (*EvmClient) GetTokenContractAddressFromSymbol ¶
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) PollTxForEvents ¶
func (*EvmClient) RecoverMissingEvents ¶
func (*EvmClient) SetAuth ¶
func (c *EvmClient) SetAuth(auth *bind.TransactOpts)
func (*EvmClient) TokenSentEvent2Model ¶
func (*EvmClient) VerifyDeployTokens ¶
func (*EvmClient) WaitForTransaction ¶
func (*EvmClient) WatchEVMTokenSent ¶
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 ValidEvmEvent ¶
type ValidEvmEvent interface { *contracts.IScalarGatewayContractCallApproved | *contracts.IScalarGatewayContractCall | *contracts.IScalarGatewayContractCallWithToken | *contracts.IScalarGatewayExecuted | *contracts.IScalarGatewayTokenSent }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.