Documentation ¶
Index ¶
- Constants
- func GetContractABI(routerContractABI, erc20ContractABI string) (*abi.ABI, *abi.ABI, error)
- func GetPrivateKey(key cryptotypes.PrivKey) (*ecdsa.PrivateKey, error)
- func IsNative(token string) bool
- func IsSmartContractCall(tx *etypes.Transaction, receipt *etypes.Receipt) bool
- type BlockMetaAccessor
- type EthRPC
- func (e *EthRPC) CheckTransaction(hash string) bool
- func (e *EthRPC) EstimateGas(from string, tx *etypes.Transaction) (uint64, error)
- func (e *EthRPC) GetBlock(height int64) (*etypes.Block, error)
- func (e *EthRPC) GetBlockHeight() (int64, error)
- func (e *EthRPC) GetHeader(height int64) (*etypes.Header, error)
- func (e *EthRPC) GetNonce(addr string) (uint64, error)
- func (e *EthRPC) GetNonceFinalized(addr string) (uint64, error)
- func (e *EthRPC) GetRPCBlock(height int64) (*etypes.Block, error)
- func (e *EthRPC) GetReceipt(hash string) (*etypes.Receipt, error)
- type KeySignWrapper
- type LevelDBBlockMetaAccessor
- func (t *LevelDBBlockMetaAccessor) AddSignedTxItem(item evmtypes.SignedTxItem) error
- func (t *LevelDBBlockMetaAccessor) GetBlockMeta(height int64) (*evmtypes.BlockMeta, error)
- func (t *LevelDBBlockMetaAccessor) GetBlockMetas() ([]*evmtypes.BlockMeta, error)
- func (t *LevelDBBlockMetaAccessor) GetSignedTxItems() ([]evmtypes.SignedTxItem, error)
- func (t *LevelDBBlockMetaAccessor) PruneBlockMeta(height int64) error
- func (t *LevelDBBlockMetaAccessor) RemoveSignedTxItem(hash string) error
- func (t *LevelDBBlockMetaAccessor) SaveBlockMeta(height int64, blockMeta *evmtypes.BlockMeta) error
- type LevelDBTokenMeta
- type RouterCoin
- type SmartContractLogParser
- type THORChainRouterTransferOutAndCall
- type TokenManager
- func (h *TokenManager) ConvertAmount(token string, amt *big.Int) cosmos.Uint
- func (h *TokenManager) ConvertSigningAmount(amt *big.Int, token string) *big.Int
- func (h *TokenManager) ConvertThorchainAmountToWei(amt *big.Int) *big.Int
- func (h *TokenManager) GetAssetFromTokenAddress(token string) (common.Asset, error)
- func (h *TokenManager) GetBalance(addr, token string, height *big.Int, vaultAddr string) (*big.Int, error)
- func (h *TokenManager) GetTokenDecimalsForTHORChain(token string) int64
- func (h *TokenManager) GetTokenMeta(token string) (types.TokenMeta, error)
- func (h *TokenManager) GetTokens() ([]*types.TokenMeta, error)
- func (h *TokenManager) SaveTokenMeta(symbol, address string, decimals uint64) error
Constants ¶
const (
NativeTokenAddr = "0x0000000000000000000000000000000000000000"
)
Variables ¶
This section is empty.
Functions ¶
func GetContractABI ¶
initSmartContracts load the erc20 contract and vault contract
func GetPrivateKey ¶
func GetPrivateKey(key cryptotypes.PrivKey) (*ecdsa.PrivateKey, error)
func IsSmartContractCall ¶
func IsSmartContractCall(tx *etypes.Transaction, receipt *etypes.Receipt) bool
isSmartContractCall - determine if the transaction is a smart contract call and thus should be parsed using the SmartContractLogParser - these txs may have a DepositEvent from the THORChain Router. This is determined by checking if the tx data is at least 4 bytes and there is at least one log in the receipt. It is possible for a smart contract call to have no logs or no data, but these cannot be THORChain deposits, so they can be parsed as a normal tx. On the other hand, simple ETH/ERC20 transfer CAN have logs & data, but again these will not be THORChain deposits or outbounds.
Types ¶
type BlockMetaAccessor ¶
type BlockMetaAccessor interface { GetBlockMetas() ([]*evmtypes.BlockMeta, error) GetBlockMeta(height int64) (*evmtypes.BlockMeta, error) SaveBlockMeta(height int64, block *evmtypes.BlockMeta) error PruneBlockMeta(height int64) error AddSignedTxItem(item evmtypes.SignedTxItem) error RemoveSignedTxItem(hash string) error GetSignedTxItems() ([]evmtypes.SignedTxItem, error) }
BlockMetaAccessor define methods need to access block meta storage
type EthRPC ¶
type EthRPC struct {
// contains filtered or unexported fields
}
EthRPC is a struct that interacts with an ETH RPC compatible blockchain
func (*EthRPC) CheckTransaction ¶
CheckTransaction returns true if a transaction is found and successful on chain. This is used to determine when a transaction has been dropped from the chain or failed on subsequent execution after reorgs. This can return false positives, but should not return false negatives - as we want to errata an observation only when we are certain it has later been dropped or failed.
func (*EthRPC) EstimateGas ¶
func (*EthRPC) GetBlockHeight ¶
func (*EthRPC) GetNonceFinalized ¶
GetNonceFinalized gets the nonce excluding pending transactions.
type KeySignWrapper ¶
type KeySignWrapper struct {
// contains filtered or unexported fields
}
KeySignWrapper is a wrap of private key and also tss instance
func NewKeySignWrapper ¶
func NewKeySignWrapper(privateKey *ecdsa.PrivateKey, pubKey common.PubKey, keyManager tss.ThorchainKeyManager, chainID *big.Int, chain string) (*KeySignWrapper, error)
NewKeySignWrapper create a new instance of keysign wrapper
func (*KeySignWrapper) GetPrivKey ¶
func (w *KeySignWrapper) GetPrivKey() *ecdsa.PrivateKey
GetPrivKey return the private key
func (*KeySignWrapper) GetPubKey ¶
func (w *KeySignWrapper) GetPubKey() common.PubKey
GetPubKey return the public key
func (*KeySignWrapper) Sign ¶
func (w *KeySignWrapper) Sign(tx *etypes.Transaction, poolPubKey common.PubKey) ([]byte, error)
Sign the given transaction
type LevelDBBlockMetaAccessor ¶
type LevelDBBlockMetaAccessor struct { PrefixBlockMeta string PrefixSignedTxItem string // contains filtered or unexported fields }
LevelDBBlockMetaAccessor struct
func NewLevelDBBlockMetaAccessor ¶
func NewLevelDBBlockMetaAccessor(prefixBlockMeta, prefixSignedTxItem string, db *leveldb.DB) (*LevelDBBlockMetaAccessor, error)
NewLevelDBBlockMetaAccessor creates a new level db backed BlockMeta accessor
func (*LevelDBBlockMetaAccessor) AddSignedTxItem ¶
func (t *LevelDBBlockMetaAccessor) AddSignedTxItem(item evmtypes.SignedTxItem) error
AddSignedTxItem add a signed tx item to key value store
func (*LevelDBBlockMetaAccessor) GetBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) GetBlockMeta(height int64) (*evmtypes.BlockMeta, error)
GetBlockMeta at given block height , when the requested block meta doesn't exist , it will return nil , thus caller need to double check it
func (*LevelDBBlockMetaAccessor) GetBlockMetas ¶
func (t *LevelDBBlockMetaAccessor) GetBlockMetas() ([]*evmtypes.BlockMeta, error)
GetBlockMetas returns all the block metas in storage The chain client will Prune block metas every time it finished scan a block , so at maximum it will keep BlockCacheSize blocks thus it should not grow out of control
func (*LevelDBBlockMetaAccessor) GetSignedTxItems ¶
func (t *LevelDBBlockMetaAccessor) GetSignedTxItems() ([]evmtypes.SignedTxItem, error)
GetSignedTxItems get all the signed tx items that in the key value store
func (*LevelDBBlockMetaAccessor) PruneBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) PruneBlockMeta(height int64) error
PruneBlockMeta removes all block meta that is older than the given block height.
func (*LevelDBBlockMetaAccessor) RemoveSignedTxItem ¶
func (t *LevelDBBlockMetaAccessor) RemoveSignedTxItem(hash string) error
RemoveSignedTxItem remove a signed item from key value store
func (*LevelDBBlockMetaAccessor) SaveBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) SaveBlockMeta(height int64, blockMeta *evmtypes.BlockMeta) error
SaveBlockMeta persistent the given BlockMeta into storage
type LevelDBTokenMeta ¶
type LevelDBTokenMeta struct {
// contains filtered or unexported fields
}
LevelDBTokenMeta struct
func NewLevelDBTokenMeta ¶
func NewLevelDBTokenMeta(db *leveldb.DB, prefixTokenMeta string) (*LevelDBTokenMeta, error)
NewLevelDBTokenMeta creates a new level db backed TokenMeta
func (*LevelDBTokenMeta) GetTokenMeta ¶
func (t *LevelDBTokenMeta) GetTokenMeta(address string) (types.TokenMeta, error)
GetTokenMeta for given token address
func (*LevelDBTokenMeta) GetTokens ¶
func (t *LevelDBTokenMeta) GetTokens() ([]*types.TokenMeta, error)
GetTokens returns all the token metas in storage
func (*LevelDBTokenMeta) SaveTokenMeta ¶
func (t *LevelDBTokenMeta) SaveTokenMeta(symbol, address string, decimals uint64) error
SaveTokenMeta persistent the given TokenMeta into storage
type RouterCoin ¶
RouterCoin represent the coins transfer between vault
type SmartContractLogParser ¶
type SmartContractLogParser struct {
// contains filtered or unexported fields
}
func (*SmartContractLogParser) GetTxInItem ¶
type THORChainRouterTransferOutAndCall ¶
type THORChainRouterTransferOutAndCall struct { Vault ecommon.Address Target ecommon.Address Amount *big.Int FinalAsset ecommon.Address To ecommon.Address AmountOutMin *big.Int Memo string }
THORChainRouterTransferOutAndCall represents a TransferOutAndCall event raised by the THORChainRouter contract.
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
TokenManager manages a LevelDB of ERC20 token meta data and interfaces with token smart contracts
func NewTokenManager ¶
func NewTokenManager(db *leveldb.DB, prefixTokenMeta string, nativeAsset common.Asset, defaultDecimals uint64, requestTimeout time.Duration, tokenWhitelist []tokenlist.ERC20Token, ethClient *ethclient.Client, routerContractABI, erc20ContractABI string, ) (*TokenManager, error)
NewTokenManager returns an instance of TokenManager
func (*TokenManager) ConvertAmount ¶
convertAmount will convert the amount to 1e8 , the decimals used by THORChain
func (*TokenManager) ConvertSigningAmount ¶
ConvertSigningAmount converts a value of a token to wei (1e18 decimals)
func (*TokenManager) ConvertThorchainAmountToWei ¶
func (h *TokenManager) ConvertThorchainAmountToWei(amt *big.Int) *big.Int
ConvertThorchainAmountToWei converts amt in 1e8 decimals to wei (1e18 decimals)
func (*TokenManager) GetAssetFromTokenAddress ¶
func (h *TokenManager) GetAssetFromTokenAddress(token string) (common.Asset, error)
func (*TokenManager) GetBalance ¶
func (h *TokenManager) GetBalance(addr, token string, height *big.Int, vaultAddr string) (*big.Int, error)
GetBalance call smart contract to find out the balance of the given address and token
func (*TokenManager) GetTokenDecimalsForTHORChain ¶
func (h *TokenManager) GetTokenDecimalsForTHORChain(token string) int64
return value 0 means use the default value which is common.THORChainDecimals, use 1e8 as precision
func (*TokenManager) GetTokenMeta ¶
func (h *TokenManager) GetTokenMeta(token string) (types.TokenMeta, error)
func (*TokenManager) GetTokens ¶
func (h *TokenManager) GetTokens() ([]*types.TokenMeta, error)
GetTokens return all the token meta data
func (*TokenManager) SaveTokenMeta ¶
func (h *TokenManager) SaveTokenMeta(symbol, address string, decimals uint64) error