Documentation ¶
Index ¶
- Constants
- func IsTokenTransfer(logs []*types.Log) bool
- type BalanceCache
- type BalanceReader
- type BatchDownloader
- type Block
- func (b *Block) GetBlocks(chainID uint64) (rst []*DBHeader, err error)
- func (b *Block) GetBlocksByAddress(chainID uint64, address common.Address, limit int) (rst []*big.Int, err error)
- func (b *Block) GetFirstKnownBlock(chainID uint64, address common.Address) (rst *big.Int, err error)
- func (b *Block) GetLastBlockByAddress(chainID uint64, address common.Address, limit int) (rst *big.Int, err error)
- func (b *Block) GetLastKnownBlockByAddress(chainID uint64, address common.Address) (block *LastKnownBlock, err error)
- func (b *Block) GetLastKnownBlockByAddresses(chainID uint64, addresses []common.Address) (map[common.Address]*LastKnownBlock, []common.Address, error)
- func (b *Block) GetLastSavedBlock(chainID uint64) (rst *DBHeader, err error)
- func (b *Block) GetLastSavedBlockBefore(chainID uint64, block *big.Int) (rst *DBHeader, err error)
- func (b *Block) RemoveBlockWithTransfer(chainID uint64, address common.Address, block *big.Int) error
- type BlocksRange
- type ConcurrentDownloader
- type Controller
- func (c *Controller) CheckRecentHistory(chainIDs []uint64, accounts []common.Address) error
- func (c *Controller) GetCachedBalances(ctx context.Context, chainID uint64, addresses []common.Address) ([]LastKnownBlockView, error)
- func (c *Controller) GetTransfersByAddress(ctx context.Context, chainID uint64, address common.Address, toBlock *big.Int, ...) ([]View, error)
- func (c *Controller) LoadTransferByHash(ctx context.Context, rpcClient *rpc.Client, address common.Address, ...) error
- func (c *Controller) SetInitialBlocksRange(chainIDs []uint64) error
- func (c *Controller) Start()
- func (c *Controller) Stop()
- type DBHeader
- type Database
- func (db *Database) Close() error
- func (db *Database) GetHeaderByNumber(chainID uint64, number *big.Int) (header *DBHeader, err error)
- func (db *Database) GetPreloadedTransactions(chainID uint64, address common.Address, blockHash common.Hash) (rst []Transfer, err error)
- func (db *Database) GetTransactionsLog(chainID uint64, address common.Address, transactionHash common.Hash) (*types.Log, error)
- func (db *Database) GetTransfers(chainID uint64, start, end *big.Int) (rst []Transfer, err error)
- func (db *Database) GetTransfersByAddress(chainID uint64, address common.Address, toBlock *big.Int, limit int64) (rst []Transfer, err error)
- func (db *Database) GetTransfersByAddressAndBlock(chainID uint64, address common.Address, block *big.Int, limit int64) (rst []Transfer, err error)
- func (db *Database) GetTransfersInRange(chainID uint64, address common.Address, start, end *big.Int) (rst []Transfer, err error)
- func (db *Database) InsertBlock(chainID uint64, account common.Address, blockNumber *big.Int, ...) error
- func (db *Database) ProcessBlocks(chainID uint64, account common.Address, from *big.Int, to *LastKnownBlock, ...) (err error)
- func (db *Database) ProcessTransfers(chainID uint64, transfers []Transfer, removed []*DBHeader) (err error)
- func (db *Database) SaveBlocks(chainID uint64, account common.Address, headers []*DBHeader) (err error)
- func (db *Database) SaveHeaders(chainID uint64, headers []*types.Header, address common.Address) (err error)
- func (db *Database) SaveTransfers(chainID uint64, address common.Address, transfers []Transfer, ...) (err error)
- type Downloader
- type ERC20TransfersDownloader
- type ETHDownloader
- type HeaderReader
- type IterativeDownloader
- type JSONBlob
- type LastKnownBlock
- type LastKnownBlockView
- type MultiTransaction
- type MultiTransactionIDType
- type MultiTransactionResult
- type MultiTransactionType
- type PendingTransaction
- type PendingTrxType
- type Reactor
- type Result
- type SyncOption
- type TransactionManager
- func (tm *TransactionManager) AddPending(transaction PendingTransaction) error
- func (tm *TransactionManager) CreateMultiTransaction(ctx context.Context, multiTransaction *MultiTransaction, ...) (*MultiTransactionResult, error)
- func (tm *TransactionManager) DeletePending(chainID uint64, hash common.Hash) error
- func (tm *TransactionManager) GetAllPending(chainIDs []uint64) ([]*PendingTransaction, error)
- func (tm *TransactionManager) GetPendingByAddress(chainIDs []uint64, address common.Address) ([]*PendingTransaction, error)
- func (tm *TransactionManager) GetPendingEntry(chainID uint64, hash common.Hash) (*PendingTransaction, error)
- func (tm *TransactionManager) Watch(ctx context.Context, transactionHash common.Hash, ...) error
- type Transfer
- type Type
- type View
Constants ¶
const ( // EventNewTransfers emitted when new block was added to the same canonical chan. EventNewTransfers walletevent.EventType = "new-transfers" // EventFetchingRecentHistory emitted when fetching of lastest tx history is started EventFetchingRecentHistory walletevent.EventType = "recent-history-fetching" // EventRecentHistoryReady emitted when fetching of lastest tx history is started EventRecentHistoryReady walletevent.EventType = "recent-history-ready" // EventFetchingHistoryError emitted when fetching of tx history failed EventFetchingHistoryError walletevent.EventType = "fetching-history-error" // EventNonArchivalNodeDetected emitted when a connection to a non archival node is detected EventNonArchivalNodeDetected walletevent.EventType = "non-archival-node-detected" )
const ( MultiTransactionSend = iota MultiTransactionSwap MultiTransactionBridge )
const (
NoMultiTransactionID = MultiTransactionIDType(0)
)
Variables ¶
This section is empty.
Functions ¶
func IsTokenTransfer ¶
Types ¶
type BalanceCache ¶
type BalanceReader ¶
type BalanceReader interface { BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) }
BalanceReader interface for reading balance at a specifeid address.
type BatchDownloader ¶
type BatchDownloader interface {
GetHeadersInRange(ctx context.Context, from, to *big.Int) ([]*DBHeader, error)
}
BatchDownloader interface for loading transfers in batches in speificed range of blocks.
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func (*Block) GetBlocksByAddress ¶
func (b *Block) GetBlocksByAddress(chainID uint64, address common.Address, limit int) (rst []*big.Int, err error)
GetBlocksByAddress loads blocks for a given address.
func (*Block) GetFirstKnownBlock ¶
func (*Block) GetLastBlockByAddress ¶
func (*Block) GetLastKnownBlockByAddress ¶
func (*Block) GetLastKnownBlockByAddresses ¶
func (*Block) GetLastSavedBlock ¶
func (*Block) GetLastSavedBlockBefore ¶
type BlocksRange ¶
type BlocksRange struct {
// contains filtered or unexported fields
}
type ConcurrentDownloader ¶
type ConcurrentDownloader struct { *async.AtomicGroup *Result }
func NewConcurrentDownloader ¶
func NewConcurrentDownloader(ctx context.Context) *ConcurrentDownloader
NewConcurrentDownloader creates ConcurrentDownloader instance.
type Controller ¶
func NewTransferController ¶
func NewTransferController(db *sql.DB, rpcClient *rpc.Client, accountFeed *event.Feed, transferFeed *event.Feed, transactionManager *TransactionManager) *Controller
func (*Controller) CheckRecentHistory ¶
func (c *Controller) CheckRecentHistory(chainIDs []uint64, accounts []common.Address) error
func (*Controller) GetCachedBalances ¶
func (c *Controller) GetCachedBalances(ctx context.Context, chainID uint64, addresses []common.Address) ([]LastKnownBlockView, error)
func (*Controller) GetTransfersByAddress ¶
func (*Controller) LoadTransferByHash ¶ added in v0.91.10
func (*Controller) SetInitialBlocksRange ¶
func (c *Controller) SetInitialBlocksRange(chainIDs []uint64) error
func (*Controller) Start ¶
func (c *Controller) Start()
func (*Controller) Stop ¶
func (c *Controller) Stop()
type DBHeader ¶
type DBHeader struct { Number *big.Int Hash common.Hash Timestamp uint64 Erc20Transfers []*Transfer Network uint64 Address common.Address // Head is true if the block was a head at the time it was pulled from chain. Head bool // Loaded is true if trasfers from this block has been already fetched Loaded bool }
DBHeader fields from header that are stored in database.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database sql wrapper for operations with wallet objects.
func (*Database) GetHeaderByNumber ¶
func (db *Database) GetHeaderByNumber(chainID uint64, number *big.Int) (header *DBHeader, err error)
GetHeaderByNumber selects header using block number.
func (*Database) GetPreloadedTransactions ¶
func (*Database) GetTransactionsLog ¶
func (*Database) GetTransfers ¶
GetTransfers load transfers transfer betweeen two blocks.
func (*Database) GetTransfersByAddress ¶
func (db *Database) GetTransfersByAddress(chainID uint64, address common.Address, toBlock *big.Int, limit int64) (rst []Transfer, err error)
GetTransfersByAddress loads transfers for a given address between two blocks.
func (*Database) GetTransfersByAddressAndBlock ¶
func (db *Database) GetTransfersByAddressAndBlock(chainID uint64, address common.Address, block *big.Int, limit int64) (rst []Transfer, err error)
GetTransfersByAddressAndBlock loads transfers for a given address and block.
func (*Database) GetTransfersInRange ¶
func (db *Database) GetTransfersInRange(chainID uint64, address common.Address, start, end *big.Int) (rst []Transfer, err error)
GetTransfersInRange loads transfers for a given address between two blocks.
func (*Database) InsertBlock ¶ added in v0.91.10
func (*Database) ProcessBlocks ¶
func (*Database) ProcessTransfers ¶ added in v0.135.2
func (db *Database) ProcessTransfers(chainID uint64, transfers []Transfer, removed []*DBHeader) (err error)
ProcessTransfers atomically adds/removes blocks and adds new transfers.
func (*Database) SaveBlocks ¶
type Downloader ¶
Downloader downloads transfers from single block using number.
type ERC20TransfersDownloader ¶
type ERC20TransfersDownloader struct {
// contains filtered or unexported fields
}
ERC20TransfersDownloader is a downloader for erc20 tokens transfers.
func NewERC20TransfersDownloader ¶
func NewERC20TransfersDownloader(client *chain.ClientWithFallback, accounts []common.Address, signer types.Signer) *ERC20TransfersDownloader
NewERC20TransfersDownloader returns new instance.
func (*ERC20TransfersDownloader) GetHeadersInRange ¶
func (d *ERC20TransfersDownloader) GetHeadersInRange(parent context.Context, from, to *big.Int) ([]*DBHeader, error)
GetHeadersInRange returns transfers between two blocks. time to get logs for 100000 blocks = 1.144686979s. with 249 events in the result set.
func (*ERC20TransfersDownloader) GetTransfers ¶
func (d *ERC20TransfersDownloader) GetTransfers(ctx context.Context, header *DBHeader) ([]Transfer, error)
GetTransfers for erc20 uses eth_getLogs rpc with Transfer event signature and our address acount.
type ETHDownloader ¶
type ETHDownloader struct {
// contains filtered or unexported fields
}
ETHDownloader downloads regular eth transfers.
func (*ETHDownloader) GetTransfers ¶
func (d *ETHDownloader) GetTransfers(ctx context.Context, header *DBHeader) (rst []Transfer, err error)
GetTransfers checks if the balance was changed between two blocks. If so it downloads transaction that transfer ethereum from that block.
func (*ETHDownloader) GetTransfersByNumber ¶
type HeaderReader ¶
type HeaderReader interface { HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) }
HeaderReader interface for reading headers using block number or hash.
type IterativeDownloader ¶
type IterativeDownloader struct {
// contains filtered or unexported fields
}
IterativeDownloader downloads batches of transfers in a specified size.
func SetupIterativeDownloader ¶
func SetupIterativeDownloader( db *Database, client HeaderReader, address common.Address, downloader BatchDownloader, size *big.Int, to *big.Int, from *big.Int) (*IterativeDownloader, error)
SetupIterativeDownloader configures IterativeDownloader with last known synced block.
func (*IterativeDownloader) Finished ¶
func (d *IterativeDownloader) Finished() bool
Finished true when earliest block with given sync option is zero.
func (*IterativeDownloader) Header ¶
func (d *IterativeDownloader) Header() *big.Int
Header return last synced header.
func (*IterativeDownloader) Revert ¶
func (d *IterativeDownloader) Revert()
Revert reverts last step progress. Should be used if application failed to process transfers. For example failed to persist them.
type JSONBlob ¶
type JSONBlob struct {
// contains filtered or unexported fields
}
JSONBlob type for marshaling/unmarshaling inner type to json.
type LastKnownBlockView ¶
type MultiTransaction ¶ added in v0.135.2
type MultiTransaction struct { ID uint `json:"id"` Timestamp uint64 `json:"timestamp"` FromAddress common.Address `json:"fromAddress"` ToAddress common.Address `json:"toAddress"` FromAsset string `json:"fromAsset"` ToAsset string `json:"toAsset"` FromAmount *hexutil.Big `json:"fromAmount"` Type MultiTransactionType `json:"type"` }
type MultiTransactionIDType ¶ added in v0.135.2
type MultiTransactionIDType int64
type MultiTransactionResult ¶ added in v0.135.2
type MultiTransactionType ¶ added in v0.135.2
type MultiTransactionType uint8
type PendingTransaction ¶ added in v0.135.2
type PendingTransaction struct { Hash common.Hash `json:"hash"` Timestamp uint64 `json:"timestamp"` Value bigint.BigInt `json:"value"` From common.Address `json:"from"` To common.Address `json:"to"` Data string `json:"data"` Symbol string `json:"symbol"` GasPrice bigint.BigInt `json:"gasPrice"` GasLimit bigint.BigInt `json:"gasLimit"` Type PendingTrxType `json:"type"` AdditionalData string `json:"additionalData"` ChainID uint64 `json:"network_id"` MultiTransactionID MultiTransactionIDType `json:"multi_transaction_id"` }
type PendingTrxType ¶ added in v0.135.2
type PendingTrxType string
const ( RegisterENS PendingTrxType = "RegisterENS" ReleaseENS PendingTrxType = "ReleaseENS" SetPubKey PendingTrxType = "SetPubKey" BuyStickerPack PendingTrxType = "BuyStickerPack" WalletTransfer PendingTrxType = "WalletTransfer" CollectibleDeployment PendingTrxType = "CollectibleDeployment" )
type Reactor ¶
type Reactor struct {
// contains filtered or unexported fields
}
Reactor listens to new blocks and stores transfers into the database.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (*Result) GetHeaders ¶
func (*Result) PushHeader ¶
type SyncOption ¶
type SyncOption uint
SyncOption is used to specify that application processed transfers for that block.
type TransactionManager ¶ added in v0.135.2
type TransactionManager struct {
// contains filtered or unexported fields
}
func NewTransactionManager ¶ added in v0.135.2
func NewTransactionManager(db *sql.DB, gethManager *account.GethManager, transactor *transactions.Transactor, config *params.NodeConfig, accountsDB *accounts.Database) *TransactionManager
func (*TransactionManager) AddPending ¶ added in v0.135.2
func (tm *TransactionManager) AddPending(transaction PendingTransaction) error
func (*TransactionManager) CreateMultiTransaction ¶ added in v0.135.2
func (tm *TransactionManager) CreateMultiTransaction(ctx context.Context, multiTransaction *MultiTransaction, data []*bridge.TransactionBridge, bridges map[string]bridge.Bridge, password string) (*MultiTransactionResult, error)
func (*TransactionManager) DeletePending ¶ added in v0.135.2
func (tm *TransactionManager) DeletePending(chainID uint64, hash common.Hash) error
func (*TransactionManager) GetAllPending ¶ added in v0.135.2
func (tm *TransactionManager) GetAllPending(chainIDs []uint64) ([]*PendingTransaction, error)
func (*TransactionManager) GetPendingByAddress ¶ added in v0.135.2
func (tm *TransactionManager) GetPendingByAddress(chainIDs []uint64, address common.Address) ([]*PendingTransaction, error)
func (*TransactionManager) GetPendingEntry ¶ added in v0.135.2
func (tm *TransactionManager) GetPendingEntry(chainID uint64, hash common.Hash) (*PendingTransaction, error)
GetPendingEntry returns sql.ErrNoRows if no pending transaction is found for the given identity
func (*TransactionManager) Watch ¶ added in v0.135.2
func (tm *TransactionManager) Watch(ctx context.Context, transactionHash common.Hash, client *chain.ClientWithFallback) error
type Transfer ¶
type Transfer struct { Type Type `json:"type"` ID common.Hash `json:"-"` Address common.Address `json:"address"` BlockNumber *big.Int `json:"blockNumber"` BlockHash common.Hash `json:"blockhash"` Timestamp uint64 `json:"timestamp"` Transaction *types.Transaction `json:"transaction"` Loaded bool NetworkID uint64 // From is derived from tx signature in order to offload this computation from UI component. From common.Address `json:"from"` Receipt *types.Receipt `json:"receipt"` // Log that was used to generate erc20 transfer. Nil for eth transfer. Log *types.Log `json:"log"` BaseGasFees string // Internal field that is used to track multi-transaction transfers. MultiTransactionID MultiTransactionIDType `json:"multi_transaction_id"` }
Transfer stores information about transfer.
type View ¶
type View struct { ID common.Hash `json:"id"` Type Type `json:"type"` Address common.Address `json:"address"` BlockNumber *hexutil.Big `json:"blockNumber"` BlockHash common.Hash `json:"blockhash"` Timestamp hexutil.Uint64 `json:"timestamp"` GasPrice *hexutil.Big `json:"gasPrice"` MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` EffectiveTip *hexutil.Big `json:"effectiveTip"` EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` GasLimit hexutil.Uint64 `json:"gasLimit"` GasUsed hexutil.Uint64 `json:"gasUsed"` Nonce hexutil.Uint64 `json:"nonce"` TxStatus hexutil.Uint64 `json:"txStatus"` Input hexutil.Bytes `json:"input"` TxHash common.Hash `json:"txHash"` Value *hexutil.Big `json:"value"` From common.Address `json:"from"` To common.Address `json:"to"` Contract common.Address `json:"contract"` NetworkID uint64 `json:"networkId"` MultiTransactionID int64 `json:"multiTransactionID"` BaseGasFees string `json:"base_gas_fee"` }
View stores only fields used by a client and ensures that all relevant fields are encoded in hex.