Documentation ¶
Index ¶
- Constants
- type AlchemyResult
- type AlchemyTokenDataResult
- type AlchemyTransactionHistoryFetcher
- type AssetTransferDirection
- type CacheingTransactionHistoryFetcher
- type GetAssetTransferParam
- type GetAssetTransfersRequest
- type RetryTransactionHistoryFetcher
- type TransactionHistoryFetcher
- func NewCacheingTransactionHistoryFetcher(fetcher TransactionHistoryFetcher) TransactionHistoryFetcher
- func NewDefaultTransactionHistoryFetcher(apiUrl string, log *zap.Logger) TransactionHistoryFetcher
- func NewRetryTransactionHistoryFetcher(fetcher TransactionHistoryFetcher, numRetries int, ...) TransactionHistoryFetcher
- type TransactionHistoryResult
Constants ¶
const ( HTTP_TIMEOUT_SECONDS = 5 PAGE_SIZE = 100 )
const (
CACHE_SIZE = 1000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlchemyResult ¶
type AlchemyResult struct { Result struct { PageKey string `json:"pageKey"` Transfers []struct { Category string `json:"category"` From string `json:"from"` To *string `json:"to"` Value *float64 `json:"value"` Asset *string `json:"asset"` } `json:"transfers"` } `json:"result"` }
AlchemyResult is a simplified version of the response struct
type AlchemyTokenDataResult ¶
type AlchemyTokenDataResult struct {
// contains filtered or unexported fields
}
An implementation of the TokenDataResult interface
func (AlchemyTokenDataResult) HasTransactions ¶
func (r AlchemyTokenDataResult) HasTransactions() bool
type AlchemyTransactionHistoryFetcher ¶
type AlchemyTransactionHistoryFetcher struct {
// contains filtered or unexported fields
}
An implementation of the TransactionHistoryFetcher interface for Alchemy
func NewAlchemyTransactionHistoryFetcher ¶
func NewAlchemyTransactionHistoryFetcher(apiUrl string, log *zap.Logger) *AlchemyTransactionHistoryFetcher
Return a new instance of the AlchemyTransactionHistoryFetcher
func (AlchemyTransactionHistoryFetcher) Fetch ¶
func (fetcher AlchemyTransactionHistoryFetcher) Fetch(ctx context.Context, walletAddress string) (res TransactionHistoryResult, err error)
Fetch in parallel transactions to and from the wallet address Question: is it really necessary to have to AND from. Seems impossible to have a transaction from a wallet without a transaction to the wallet
type AssetTransferDirection ¶
type AssetTransferDirection int64
AssetTransferDirection determines whether we are looking for transfers to or from the given wallet address
const ( To AssetTransferDirection = 0 From AssetTransferDirection = 1 )
type CacheingTransactionHistoryFetcher ¶
type CacheingTransactionHistoryFetcher struct {
// contains filtered or unexported fields
}
CacheingTransactionHistoryFetcher wraps a TransactionHistoryFetcher in a LRU cache
func (*CacheingTransactionHistoryFetcher) Fetch ¶
func (f *CacheingTransactionHistoryFetcher) Fetch(ctx context.Context, walletAddress string) (res TransactionHistoryResult, err error)
type GetAssetTransferParam ¶
type GetAssetTransferParam struct { FromAddress string `json:"fromAddress,omitempty"` FromBlock string `json:"fromBlock,omitempty"` ToAddress string `json:"toAddress,omitempty"` MaxCount string `json:"maxCount,omitempty"` Category []string `json:"category,omitempty"` PageKey *string `json:"pageKey,omitempty"` }
GetAssetTransferParam is the structure of the params expected in GetAssetTransfersRequest
type GetAssetTransfersRequest ¶
type GetAssetTransfersRequest struct { JsonRPC string `json:"jsonrpc"` Id string `json:"id"` Method string `json:"method"` Params []GetAssetTransferParam `json:"params"` }
GetAssetTransfersRequest is the format expected by the Alchemy API https://docs.alchemy.com/alchemy/enhanced-apis/transfers-api
type RetryTransactionHistoryFetcher ¶
type RetryTransactionHistoryFetcher struct {
// contains filtered or unexported fields
}
RetryTransactionHistoryFetcher wraps a TransactionHistoryFetcher and will retry errors up to `numRetries` times with a sleep of `retrySleepTime` between each attempt
func (*RetryTransactionHistoryFetcher) Fetch ¶
func (f *RetryTransactionHistoryFetcher) Fetch(ctx context.Context, walletAddress string) (res TransactionHistoryResult, err error)
type TransactionHistoryFetcher ¶
type TransactionHistoryFetcher interface {
Fetch(ctx context.Context, walletAddress string) (TransactionHistoryResult, error)
}
func NewCacheingTransactionHistoryFetcher ¶
func NewCacheingTransactionHistoryFetcher(fetcher TransactionHistoryFetcher) TransactionHistoryFetcher
func NewDefaultTransactionHistoryFetcher ¶
func NewDefaultTransactionHistoryFetcher(apiUrl string, log *zap.Logger) TransactionHistoryFetcher
NewDefaultTransactionHistory fetcher returns a cacheing, retrying, alchemy transaction history fetcher
func NewRetryTransactionHistoryFetcher ¶
func NewRetryTransactionHistoryFetcher(fetcher TransactionHistoryFetcher, numRetries int, retrySleepTime time.Duration) TransactionHistoryFetcher
type TransactionHistoryResult ¶
type TransactionHistoryResult interface {
HasTransactions() bool
}