Documentation
¶
Index ¶
- Constants
- Variables
- 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 *scalarnet.EventCheckPoint, ...) ([]*parser.EvmEvent[T], error)
- func RecoverEvent[T ValidEvmEvent](c *EvmClient, ctx context.Context, eventName string, ...) error
- func WatchForEvent[T ValidWatchEvent](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) AppendLogs(logs []types.Log)
- func (c *EvmClient) CommandExecutedEvent2Model(event *contracts.IScalarGatewayExecuted) chains.CommandExecuted
- func (c *EvmClient) ConnectWithRetry(ctx context.Context)
- func (c *EvmClient) ContractCallApprovedEvent2Model(event *contracts.IScalarGatewayContractCallApproved) (scalarnet.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(chainId string, symbol string) string
- func (ec *EvmClient) HandleCommandExecuted(event *contracts.IScalarGatewayExecuted) error
- func (ec *EvmClient) HandleContractCallApproved(event *contracts.IScalarGatewayContractCallApproved) error
- func (ec *EvmClient) HandleContractCallWithToken(event *contracts.IScalarGatewayContractCallWithToken) error
- func (ec *EvmClient) HandleTokenDeployed(event *contracts.IScalarGatewayTokenDeployed) 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) ProcessMissingLogs()
- func (c *EvmClient) RecoverAllEvents(ctx context.Context) error
- func (c *EvmClient) RecoverApprovedEvents(ctx context.Context) error
- func (c *EvmClient) RecoverEvents(ctx context.Context, eventNames []string) error
- func (c *EvmClient) RecoverExecutedEvents(ctx context.Context) error
- func (c *EvmClient) RecoverInitiatedEvents(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) TokenDeployedEvent2Model(event *contracts.IScalarGatewayTokenDeployed) chains.TokenDeployed
- func (c *EvmClient) TokenSentEvent2Model(event *contracts.IScalarGatewayTokenSent) (chains.TokenSent, error)
- func (c *EvmClient) UpdateLastCheckPoint(events map[string]abi.Event, logs []types.Log, lastBlock uint64)
- func (c *EvmClient) VerifyDeployTokens(ctx context.Context) error
- func (ec *EvmClient) WaitForTransaction(hash string) (*ethtypes.Receipt, error)
- type EvmNetworkConfig
- type ExecuteData
- type MissingLogs
- type ValidEvmEvent
- type ValidWatchEvent
Constants ¶
View Source
const ( COMPONENT_NAME = "EvmClient" RETRY_INTERVAL = time.Second * 12 // Initial retry interval )
Variables ¶
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 *scalarnet.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
func WatchForEvent ¶
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 {
EvmConfig *EvmNetworkConfig
Client *ethclient.Client
ScalarClient *scalar.Client
ChainName string
GatewayAddress common.Address
Gateway *contracts.IScalarGateway
MissingLogs MissingLogs
// contains filtered or unexported fields
}
func NewEvmClient ¶
func NewEvmClients ¶
func (*EvmClient) AddPendingTx ¶
func (*EvmClient) AppendLogs ¶
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) (scalarnet.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) HandleContractCallWithToken ¶
func (ec *EvmClient) HandleContractCallWithToken(event *contracts.IScalarGatewayContractCallWithToken) error
func (*EvmClient) HandleTokenDeployed ¶
func (ec *EvmClient) HandleTokenDeployed(event *contracts.IScalarGatewayTokenDeployed) error
func (*EvmClient) HandleTokenSent ¶
func (ec *EvmClient) HandleTokenSent(event *contracts.IScalarGatewayTokenSent) error
func (*EvmClient) PollTxForEvents ¶
func (*EvmClient) ProcessMissingLogs ¶
func (c *EvmClient) ProcessMissingLogs()
Go routine for process missing logs
func (*EvmClient) RecoverAllEvents ¶
func (*EvmClient) RecoverApprovedEvents ¶
func (*EvmClient) RecoverEvents ¶
func (*EvmClient) RecoverExecutedEvents ¶
func (*EvmClient) RecoverInitiatedEvents ¶
* Recover initiated events
func (*EvmClient) SetAuth ¶
func (c *EvmClient) SetAuth(auth *bind.TransactOpts)
func (*EvmClient) TokenDeployedEvent2Model ¶
func (c *EvmClient) TokenDeployedEvent2Model(event *contracts.IScalarGatewayTokenDeployed) chains.TokenDeployed
func (*EvmClient) TokenSentEvent2Model ¶
func (*EvmClient) UpdateLastCheckPoint ¶
func (*EvmClient) VerifyDeployTokens ¶
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
RecoverRange uint64 `mapstructure:"recover_range"` //Max block range to recover events in single query
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 MissingLogs ¶
type MissingLogs struct {
Recovered atomic.Bool //True if logs are recovered
// contains filtered or unexported fields
}
func (*MissingLogs) AppendLogs ¶
func (m *MissingLogs) AppendLogs(logs []ethTypes.Log)
func (*MissingLogs) IsRecovered ¶
func (m *MissingLogs) IsRecovered() bool
func (*MissingLogs) SetRecovered ¶
func (m *MissingLogs) SetRecovered(recovered bool)
type ValidEvmEvent ¶
type ValidEvmEvent interface {
*contracts.IScalarGatewayContractCallApproved |
*contracts.IScalarGatewayContractCall |
*contracts.IScalarGatewayContractCallWithToken |
*contracts.IScalarGatewayExecuted |
*contracts.IScalarGatewayTokenSent
}
type ValidWatchEvent ¶
type ValidWatchEvent interface {
*contracts.IScalarGatewayTokenSent |
*contracts.IScalarGatewayContractCallWithToken |
*contracts.IScalarGatewayContractCallApproved |
*contracts.IScalarGatewayExecuted |
*contracts.IScalarGatewayTokenDeployed
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.