Documentation ¶
Index ¶
- func GetContractABI(routerContractABI, erc20ContractABI string) (*abi.ABI, *abi.ABI, error)
- func GetPrivateKey(key cryptotypes.PrivKey) (*ecdsa.PrivateKey, error)
- func IsNative(token string) bool
- type BlockMetaAccessor
- type ERC20Token
- 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) 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 TokenList
- 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 ¶
This section is empty.
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)
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 ERC20Token ¶
type ERC20Token struct { Address string `json:"address"` Symbol string `json:"symbol"` Name string `json:"name"` Decimals int `json:"decimals"` }
ERC20Token is a struct to represent the token
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 tx can be found by TransactionByHash rpc method
func (*EthRPC) EstimateGas ¶
func (*EthRPC) GetBlockHeight ¶
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 remove all block meta that is older than the given block height with exception, if there are unspent transaction output in it , then the block meta will not be removed
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 NewSmartContractLogParser ¶
func NewSmartContractLogParser(validator contractAddressValidator, resolver assetResolver, decimalResolver tokenDecimalResolver, amtConverter amountConverter, vaultABI *abi.ABI, nativeAsset common.Asset, ) SmartContractLogParser
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 []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