activity

package
v0.176.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventActivityFilteringDone contains a FilterResponse payload
	EventActivityFilteringDone          walletevent.EventType = "wallet-activity-filtering-done"
	EventActivityFilteringUpdate        walletevent.EventType = "wallet-activity-filtering-entries-updated"
	EventActivityGetRecipientsDone      walletevent.EventType = "wallet-activity-get-recipients-result"
	EventActivityGetOldestTimestampDone walletevent.EventType = "wallet-activity-get-oldest-timestamp-result"
	EventActivityGetCollectibles        walletevent.EventType = "wallet-activity-get-collectibles"

	// EventActivitySessionUpdated contains a SessionUpdate payload
	EventActivitySessionUpdated walletevent.EventType = "wallet-activity-session-updated"
)
View Source
const NoLimitTimestampForPeriod = 0

Variables

View Source
var (
	ZeroAddress = eth.Address{}
)

Functions

func GetActivityCollectibles added in v0.167.5

func GetActivityCollectibles(ctx context.Context, db *sql.DB, chainIDs []common.ChainID, owners []eth.Address, offset int, limit int) ([]thirdparty.CollectibleUniqueID, error)

func GetOldestTimestamp added in v0.159.6

func GetOldestTimestamp(ctx context.Context, db *sql.DB, addresses []eth.Address) (timestamp int64, err error)

func GetRecipients added in v0.159.2

func GetRecipients(ctx context.Context, db *sql.DB, chainIDs []common.ChainID, addresses []eth.Address, offset int, limit int) (recipients []eth.Address, hasMore bool, err error)

Types

type CollectibleHeader added in v0.167.5

type CollectibleHeader struct {
	ID       thirdparty.CollectibleUniqueID `json:"id"`
	Name     string                         `json:"name"`
	ImageURL string                         `json:"image_url"`
}

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

func NewActivityEntryWithMultiTransaction

func NewActivityEntryWithMultiTransaction(id transfer.MultiTransactionIDType, timestamp int64, activityType Type, activityStatus Status) Entry

func (*Entry) MarshalJSON

func (e *Entry) MarshalJSON() ([]byte, error)

func (*Entry) PayloadType added in v0.152.2

func (e *Entry) PayloadType() PayloadType

func (*Entry) UnmarshalJSON

func (e *Entry) UnmarshalJSON(data []byte) error

type EntryChainDetails added in v0.171.25

type EntryChainDetails struct {
	ChainID     int64        `json:"chainId"`
	BlockNumber int64        `json:"blockNumber"`
	Hash        eth.Hash     `json:"hash"`
	Contract    *eth.Address `json:"contractAddress,omitempty"`
}

type EntryData added in v0.166.7

type EntryData struct {
	PayloadType     PayloadType                      `json:"payloadType"`
	Transaction     *transfer.TransactionIdentity    `json:"transaction,omitempty"`
	ID              *transfer.MultiTransactionIDType `json:"id,omitempty"`
	Timestamp       *int64                           `json:"timestamp,omitempty"`
	ActivityType    *Type                            `json:"activityType,omitempty"`
	ActivityStatus  *Status                          `json:"activityStatus,omitempty"`
	AmountOut       *hexutil.Big                     `json:"amountOut,omitempty"`
	AmountIn        *hexutil.Big                     `json:"amountIn,omitempty"`
	TokenOut        *Token                           `json:"tokenOut,omitempty"`
	TokenIn         *Token                           `json:"tokenIn,omitempty"`
	SymbolOut       *string                          `json:"symbolOut,omitempty"`
	SymbolIn        *string                          `json:"symbolIn,omitempty"`
	Sender          *eth.Address                     `json:"sender,omitempty"`
	Recipient       *eth.Address                     `json:"recipient,omitempty"`
	ChainIDOut      *common.ChainID                  `json:"chainIdOut,omitempty"`
	ChainIDIn       *common.ChainID                  `json:"chainIdIn,omitempty"`
	TransferType    *TransferType                    `json:"transferType,omitempty"`
	ContractAddress *eth.Address                     `json:"contractAddress,omitempty"`
	CommunityID     *string                          `json:"communityId,omitempty"`

	IsNew *bool `json:"isNew,omitempty"`

	NftName *string `json:"nftName,omitempty"`
	NftURL  *string `json:"nftUrl,omitempty"`
}

Only used for JSON marshalling

type EntryDetails added in v0.166.1

type EntryDetails struct {
	ID           string              `json:"id"`
	MultiTxID    int                 `json:"multiTxId"`
	Nonce        uint64              `json:"nonce"`
	ChainDetails []EntryChainDetails `json:"chainDetails"`
	Input        string              `json:"input"`
	ProtocolType *ProtocolType       `json:"protocolType,omitempty"`
	MaxFeePerGas *hexutil.Big        `json:"maxFeePerGas"`
	GasLimit     uint64              `json:"gasLimit"`
	TotalFees    *hexutil.Big        `json:"totalFees,omitempty"`
}

type EntryIdentity added in v0.173.0

type EntryIdentity struct {
	// contains filtered or unexported fields
}

type EntryUpdate added in v0.176.3

type EntryUpdate struct {
	Pos   int    `json:"pos"`
	Entry *Entry `json:"entry"`
}

type ErrorCode added in v0.158.0

type ErrorCode = int
const (
	ErrorCodeSuccess ErrorCode = iota + 1
	ErrorCodeTaskCanceled
	ErrorCodeFailed
)

type Filter

type Filter struct {
	Period                Period        `json:"period"`
	Types                 []Type        `json:"types"`
	Statuses              []Status      `json:"statuses"`
	CounterpartyAddresses []eth.Address `json:"counterpartyAddresses"`

	// Tokens
	Assets                []Token `json:"assets"`
	Collectibles          []Token `json:"collectibles"`
	FilterOutAssets       bool    `json:"filterOutAssets"`
	FilterOutCollectibles bool    `json:"filterOutCollectibles"`
}

func (*Filter) IsEmpty added in v0.176.3

func (f *Filter) IsEmpty() bool

type FilterDependencies added in v0.159.2

type FilterDependencies struct {
	// contains filtered or unexported fields
}

type FilterResponse added in v0.158.0

type FilterResponse struct {
	Activities []Entry `json:"activities"`
	Offset     int     `json:"offset"`
	// Used to indicate that there might be more entries that were not returned
	// based on a simple heuristic
	HasMore   bool      `json:"hasMore"`
	ErrorCode ErrorCode `json:"errorCode"`
}

type GetOldestTimestampResponse added in v0.161.2

type GetOldestTimestampResponse struct {
	Timestamp int64     `json:"timestamp"`
	ErrorCode ErrorCode `json:"errorCode"`
}

type GetRecipientsResponse added in v0.161.2

type GetRecipientsResponse struct {
	Addresses []common.Address `json:"addresses"`
	Offset    int              `json:"offset"`
	// Used to indicate that there might be more entries that were not returned
	// based on a simple heuristic
	HasMore   bool      `json:"hasMore"`
	ErrorCode ErrorCode `json:"errorCode"`
}

type GetollectiblesResponse added in v0.167.5

type GetollectiblesResponse struct {
	Collectibles []CollectibleHeader `json:"collectibles"`
	Offset       int                 `json:"offset"`
	// Used to indicate that there might be more collectibles that were not returned
	// based on a simple heuristic
	HasMore   bool      `json:"hasMore"`
	ErrorCode ErrorCode `json:"errorCode"`
}

type PayloadType

type PayloadType = int
const (
	MultiTransactionPT PayloadType = iota + 1
	SimpleTransactionPT
	PendingTransactionPT
)

Beware: please update multiTransactionTypeToActivityType if changing this enum

type Period

type Period struct {
	StartTimestamp int64 `json:"startTimestamp"`
	EndTimestamp   int64 `json:"endTimestamp"`
}

type ProtocolType added in v0.166.1

type ProtocolType = int
const (
	ProtocolHop ProtocolType = iota + 1
	ProtocolUniswap
)

type Service added in v0.158.0

type Service struct {
	// contains filtered or unexported fields
}

Service provides an async interface, ensuring only one filter request, of each type, is running at a time. It also provides lazy load of NFT info and token mapping

func NewService added in v0.158.0

func NewService(db *sql.DB, tokenManager token.ManagerInterface, collectibles collectibles.ManagerInterface, eventFeed *event.Feed, pendingTracker *transactions.PendingTxTracker) *Service

func (*Service) CancelFilterTask added in v0.167.5

func (s *Service) CancelFilterTask(requestID int32)

func (*Service) FilterActivityAsync added in v0.158.0

func (s *Service) FilterActivityAsync(requestID int32, addresses []common.Address, allAddresses bool, chainIDs []w_common.ChainID, filter Filter, offset int, limit int)

FilterActivityAsync allows only one filter task to run at a time it cancels the current one if a new one is started and should not expect other owners to have data in one of the queried tables

All calls will trigger an EventActivityFilteringDone event with the result of the filtering TODO #12120: replace with session based APIs

func (*Service) GetActivityCollectiblesAsync added in v0.167.5

func (s *Service) GetActivityCollectiblesAsync(requestID int32, chainIDs []w_common.ChainID, addresses []common.Address, offset int, limit int)

func (*Service) GetMoreForFilterSession added in v0.174.6

func (s *Service) GetMoreForFilterSession(id SessionID, pageCount int) error

func (*Service) GetMultiTxDetails added in v0.166.1

func (s *Service) GetMultiTxDetails(ctx context.Context, multiTxID int) (*EntryDetails, error)

func (*Service) GetOldestTimestampAsync added in v0.161.2

func (s *Service) GetOldestTimestampAsync(requestID int32, addresses []common.Address)

func (*Service) GetRecipientsAsync added in v0.161.2

func (s *Service) GetRecipientsAsync(requestID int32, chainIDs []w_common.ChainID, addresses []common.Address, offset int, limit int) bool

GetRecipientsAsync returns true if a task is already running or scheduled due to a previous call; meaning that this call won't receive an answer but client should rely on the answer from the previous call. If no task is already scheduled false will be returned

func (*Service) GetTxDetails added in v0.166.1

func (s *Service) GetTxDetails(ctx context.Context, id string) (*EntryDetails, error)

func (*Service) ResetFilterSession added in v0.174.5

func (s *Service) ResetFilterSession(id SessionID, firstPageCount int) error

ResetFilterSession is to be called when SessionUpdate.HasNewOnTop == true to update client with the latest state including new on top entries

func (*Service) StartFilterSession added in v0.173.0

func (s *Service) StartFilterSession(addresses []eth.Address, allAddresses bool, chainIDs []common.ChainID, filter Filter, firstPageCount int) SessionID

func (*Service) Stop added in v0.158.0

func (s *Service) Stop()

func (*Service) StopFilterSession added in v0.173.0

func (s *Service) StopFilterSession(id SessionID)

func (*Service) UpdateFilterForSession added in v0.176.3

func (s *Service) UpdateFilterForSession(id SessionID, filter Filter, firstPageCount int) error

UpdateFilterForSession is to be called for updating the filter of a specific session After calling this method to set a filter all the incoming changes will be reported with Entry.isNew = true when filter is reset to empty

type Session added in v0.173.0

type Session struct {
	// contains filtered or unexported fields
}

Session stores state related to a filter session The user happy flow is: 1. StartFilterSession to get a new SessionID and client be notified by the current state 2. GetMoreForFilterSession anytime to get more entries after the first page 3. UpdateFilterForSession to update the filter and get the new state or clean the filter and get the newer entries 4. ResetFilterSession in case client receives SessionUpdate with HasNewOnTop = true to get the latest state 5. StopFilterSession to stop the session when no used (user changed from activity screens or changed addresses and chains)

type SessionID added in v0.173.0

type SessionID int32

type SessionUpdate added in v0.173.0

type SessionUpdate struct {
	HasNewOnTop *bool           `json:"hasNewOnTop,omitempty"`
	New         []*EntryUpdate  `json:"new,omitempty"`
	Removed     []EntryIdentity `json:"removed,omitempty"`
}

SessionUpdate payload for EventActivitySessionUpdated

type Status

type Status int
const (
	FailedAS    Status = iota // failed status or at least one failed transaction for multi-transactions
	PendingAS                 // in pending DB or at least one transaction in pending for multi-transactions
	CompleteAS                // success status
	FinalizedAS               // all multi-transactions have success status
)

type Token added in v0.159.2

type Token struct {
	TokenType TokenType `json:"tokenType"`
	// ChainID is used for TokenType.Native only to lookup the symbol, all chains will be included in the token filter
	ChainID common.ChainID `json:"chainId"`
	Address eth.Address    `json:"address,omitempty"`
	TokenID *hexutil.Big   `json:"tokenId,omitempty"`
}

Token supports all tokens. Some fields might be optional, depending on the TokenType

type TokenType

type TokenType int
const (
	Native TokenType = iota
	Erc20
	Erc721
	Erc1155
)

type TransferType added in v0.162.9

type TransferType = int
const (
	TransferTypeEth TransferType = iota + 1
	TransferTypeErc20
	TransferTypeErc721
	TransferTypeErc1155
)

type Type

type Type int
const (
	SendAT Type = iota
	ReceiveAT
	BuyAT
	SwapAT
	BridgeAT
	ContractDeploymentAT
	MintAT
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL