collectibles

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MPL-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventCollectiblesOwnershipUpdateStarted           walletevent.EventType = "wallet-collectibles-ownership-update-started"
	EventCollectiblesOwnershipUpdatePartial           walletevent.EventType = "wallet-collectibles-ownership-update-partial"
	EventCollectiblesOwnershipUpdateFinished          walletevent.EventType = "wallet-collectibles-ownership-update-finished"
	EventCollectiblesOwnershipUpdateFinishedWithError walletevent.EventType = "wallet-collectibles-ownership-update-finished-with-error"
	EventCommunityCollectiblesReceived                walletevent.EventType = "wallet-collectibles-community-collectibles-received"
	EventCollectiblesDataUpdated                      walletevent.EventType = "wallet-collectibles-data-updated"

	EventOwnedCollectiblesFilteringDone walletevent.EventType = "wallet-owned-collectibles-filtering-done"
	EventGetCollectiblesDetailsDone     walletevent.EventType = "wallet-get-collectibles-details-done"
	EventGetCollectionSocialsDone       walletevent.EventType = "wallet-get-collection-socials-done"
)

These events are used to notify the UI of state changes

View Source
const EventCollectiblesConnectionStatusChanged walletevent.EventType = "wallet-collectible-status-changed"
View Source
const InvalidTimestamp = int64(-1)

Variables

View Source
var (
	ErrAllProvidersFailedForChainID   = errors.New("all providers failed for chainID")
	ErrNoProvidersAvailableForChainID = errors.New("no providers available for chainID")
)

Functions

func IDsFromAssets added in v0.179.4

Types

type Collectible added in v0.171.21

type Collectible struct {
	DataType        CollectibleDataType            `json:"data_type"`
	ID              thirdparty.CollectibleUniqueID `json:"id"`
	ContractType    w_common.ContractType          `json:"contract_type"`
	CollectibleData *CollectibleData               `json:"collectible_data,omitempty"`
	CollectionData  *CollectionData                `json:"collection_data,omitempty"`
	CommunityData   *CommunityData                 `json:"community_data,omitempty"`
	Ownership       []thirdparty.AccountBalance    `json:"ownership,omitempty"`
	IsFirst         bool                           `json:"is_first,omitempty"`
	LatestTxHash    string                         `json:"latest_tx_hash,omitempty"`
	ReceivedAmount  float64                        `json:"received_amount,omitempty"`
}

Combined Collection+Collectible info, used to display a detailed view of a collectible

type CollectibleData added in v0.171.21

type CollectibleData struct {
	Name               string                         `json:"name"`
	Description        *string                        `json:"description,omitempty"`
	ImageURL           *string                        `json:"image_url,omitempty"`
	AnimationURL       *string                        `json:"animation_url,omitempty"`
	AnimationMediaType *string                        `json:"animation_media_type,omitempty"`
	Traits             *[]thirdparty.CollectibleTrait `json:"traits,omitempty"`
	BackgroundColor    *string                        `json:"background_color,omitempty"`
	Soulbound          *bool                          `json:"soulbound,omitempty"`
}

type CollectibleDataDB added in v0.163.4

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

func NewCollectibleDataDB added in v0.163.4

func NewCollectibleDataDB(sqlDb *sql.DB) *CollectibleDataDB

func (*CollectibleDataDB) GetCommunityInfo added in v0.171.8

func (*CollectibleDataDB) GetData added in v0.163.4

func (*CollectibleDataDB) GetIDsNotInDB added in v0.163.4

func (*CollectibleDataDB) SetCommunityInfo added in v0.171.8

func (o *CollectibleDataDB) SetCommunityInfo(id thirdparty.CollectibleUniqueID, communityInfo thirdparty.CollectibleCommunityInfo) (err error)

func (*CollectibleDataDB) SetData added in v0.163.4

func (o *CollectibleDataDB) SetData(collectibles []thirdparty.CollectibleData, allowUpdate bool) (err error)

type CollectibleDataStorage added in v0.182.40

type CollectibleDataStorage interface {
	SetData(collectibles []thirdparty.CollectibleData, allowUpdate bool) error
	GetIDsNotInDB(ids []thirdparty.CollectibleUniqueID) ([]thirdparty.CollectibleUniqueID, error)
	GetData(ids []thirdparty.CollectibleUniqueID) (map[string]thirdparty.CollectibleData, error)
	SetCommunityInfo(id thirdparty.CollectibleUniqueID, communityInfo thirdparty.CollectibleCommunityInfo) error
	GetCommunityInfo(id thirdparty.CollectibleUniqueID) (*thirdparty.CollectibleCommunityInfo, error)
}

type CollectibleDataType added in v0.171.21

type CollectibleDataType byte
const (
	CollectibleDataTypeUniqueID CollectibleDataType = iota
	CollectibleDataTypeHeader
	CollectibleDataTypeDetails
	CollectibleDataTypeCommunityHeader
)

type CollectionData added in v0.171.21

type CollectionData struct {
	Name     string             `json:"name"`
	Slug     string             `json:"slug"`
	ImageURL string             `json:"image_url"`
	Socials  *CollectionSocials `json:"socials"`
}

type CollectionDataDB added in v0.163.4

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

func NewCollectionDataDB added in v0.163.4

func NewCollectionDataDB(sqlDb *sql.DB) *CollectionDataDB

func (*CollectionDataDB) GetData added in v0.163.4

func (*CollectionDataDB) GetIDsNotInDB added in v0.163.4

func (o *CollectionDataDB) GetIDsNotInDB(ids []thirdparty.ContractID) ([]thirdparty.ContractID, error)

func (*CollectionDataDB) GetSocialsForID added in v0.179.17

func (o *CollectionDataDB) GetSocialsForID(contractID thirdparty.ContractID) (*thirdparty.CollectionSocials, error)

func (*CollectionDataDB) SetCollectionSocialsData added in v0.179.17

func (o *CollectionDataDB) SetCollectionSocialsData(id thirdparty.ContractID, collectionSocials *thirdparty.CollectionSocials) (err error)

func (*CollectionDataDB) SetData added in v0.163.4

func (o *CollectionDataDB) SetData(collections []thirdparty.CollectionData, allowUpdate bool) (err error)

type CollectionDataStorage added in v0.182.40

type CollectionDataStorage interface {
	SetData(collections []thirdparty.CollectionData, allowUpdate bool) error
	GetIDsNotInDB(ids []thirdparty.ContractID) ([]thirdparty.ContractID, error)
	GetData(ids []thirdparty.ContractID) (map[string]thirdparty.CollectionData, error)
	SetCollectionSocialsData(id thirdparty.ContractID, collectionSocials *thirdparty.CollectionSocials) error
	GetSocialsForID(contractID thirdparty.ContractID) (*thirdparty.CollectionSocials, error)
}

type CollectionSocials added in v0.179.17

type CollectionSocials struct {
	Website       string `json:"website"`
	TwitterHandle string `json:"twitter_handle"`
}

type CollectionSocialsMessage added in v0.179.17

type CollectionSocialsMessage struct {
	ID      thirdparty.ContractID         `json:"id"`
	Socials *thirdparty.CollectionSocials `json:"socials"`
}

type CommunityData added in v0.171.21

type CommunityData struct {
	ID              string                `json:"id"`
	Name            string                `json:"name"`
	Color           string                `json:"color"`
	PrivilegesLevel token.PrivilegesLevel `json:"privileges_level"`
	ImageURL        *string               `json:"image_url,omitempty"`
}

type Controller added in v0.170.0

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

func NewController added in v0.170.0

func NewController(
	db *sql.DB,
	walletFeed *event.Feed,
	accountsDB *accounts.Database,
	accountsFeed *event.Feed,
	settingsFeed *event.Feed,
	networkManager *network.Manager,
	manager *Manager) *Controller

func (*Controller) GetCommandState added in v0.170.0

func (c *Controller) GetCommandState(chainID walletCommon.ChainID, address common.Address) OwnershipState

func (*Controller) RefetchOwnedCollectibles added in v0.170.0

func (c *Controller) RefetchOwnedCollectibles()

func (*Controller) SetCollectiblesTransferCb added in v0.172.5

func (c *Controller) SetCollectiblesTransferCb(cb TransferCb)

func (*Controller) SetOwnedCollectiblesChangeCb added in v0.172.5

func (c *Controller) SetOwnedCollectiblesChangeCb(cb OwnedCollectiblesChangeCb)

func (*Controller) Start added in v0.170.0

func (c *Controller) Start()

func (*Controller) Stop added in v0.170.0

func (c *Controller) Stop()

type ErrorCode added in v0.162.13

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

type FetchCriteria added in v0.171.21

type FetchCriteria struct {
	FetchType          FetchType `json:"fetch_type"`
	MaxCacheAgeSeconds int64     `json:"max_cache_age_seconds"`
}

type FetchType added in v0.171.21

type FetchType byte
const (
	FetchTypeNeverFetch FetchType = iota
	FetchTypeAlwaysFetch
	FetchTypeFetchIfNotCached
	FetchTypeFetchIfCacheOld
)

type Filter added in v0.171.9

type Filter struct {
	CollectibleIDs            []thirdparty.CollectibleUniqueID `json:"collectible_ids"`
	CommunityIDs              []string                         `json:"community_ids"`
	CommunityPrivilegesLevels []token.PrivilegesLevel          `json:"community_privileges_levels"`

	FilterCommunity FilterCommunityType `json:"filter_community"`
}

type FilterCommunityType added in v0.171.9

type FilterCommunityType int
const (
	All FilterCommunityType = iota
	OnlyNonCommunity
	OnlyCommunity
)

type GetCollectiblesByUniqueIDResponse added in v0.171.21

type GetCollectiblesByUniqueIDResponse struct {
	Collectibles []Collectible `json:"collectibles"`
	ErrorCode    ErrorCode     `json:"errorCode"`
}

type GetCollectiblesByUniqueIDReturnType added in v0.171.21

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

type GetOwnedCollectiblesResponse added in v0.171.21

type GetOwnedCollectiblesResponse struct {
	Collectibles []Collectible `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"`
	OwnershipStatus OwnershipStatusPerAddressAndChainID `json:"ownershipStatus"`
	ErrorCode       ErrorCode                           `json:"errorCode"`
}

type GetOwnedCollectiblesReturnType added in v0.171.21

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

type Manager

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

func NewManager

func NewManager(
	db *sql.DB,
	rpcClient rpc.ClientInterface,
	communityManager *community.Manager,
	providers thirdparty.CollectibleProviders,
	mediaServer *server.MediaServer,
	feed *event.Feed) *Manager

func (*Manager) FetchAllAssetsByOwner

func (o *Manager) FetchAllAssetsByOwner(ctx context.Context, chainID walletCommon.ChainID, owner common.Address, cursor string, limit int, providerID string) (*thirdparty.FullCollectibleDataContainer, error)

func (*Manager) FetchAllAssetsByOwnerAndContractAddress

func (o *Manager) FetchAllAssetsByOwnerAndContractAddress(ctx context.Context, chainID walletCommon.ChainID, owner common.Address, contractAddresses []common.Address, cursor string, limit int, providerID string) (*thirdparty.FullCollectibleDataContainer, error)

func (*Manager) FetchAssetsByCollectibleUniqueID added in v0.162.13

func (o *Manager) FetchAssetsByCollectibleUniqueID(ctx context.Context, uniqueIDs []thirdparty.CollectibleUniqueID, asyncFetch bool) ([]thirdparty.FullCollectibleData, error)

Returns collectible metadata for the given unique IDs. If asyncFetch is true, empty metadata will be returned for any missing collectibles and an EventCollectiblesDataUpdated will be sent when the data is ready. If asyncFetch is false, it will wait for all collectibles' metadata to be retrieved before returning.

func (*Manager) FetchBalancesByOwnerAndContractAddress added in v0.162.5

func (o *Manager) FetchBalancesByOwnerAndContractAddress(ctx context.Context, chainID walletCommon.ChainID, ownerAddress common.Address, contractAddresses []common.Address) (thirdparty.TokenBalancesPerContractAddress, error)

Need to combine different providers to support all needed ChainIDs

func (*Manager) FetchCachedBalancesByOwnerAndContractAddress added in v0.180.31

func (o *Manager) FetchCachedBalancesByOwnerAndContractAddress(ctx context.Context, chainID walletCommon.ChainID, ownerAddress common.Address, contractAddresses []common.Address) (thirdparty.TokenBalancesPerContractAddress, error)

func (*Manager) FetchCollectibleOwnersByContractAddress added in v0.162.13

func (o *Manager) FetchCollectibleOwnersByContractAddress(ctx context.Context, chainID walletCommon.ChainID, contractAddress common.Address) (*thirdparty.CollectibleContractOwnership, error)

func (*Manager) FetchCollectibleOwnershipByOwner added in v0.162.13

func (o *Manager) FetchCollectibleOwnershipByOwner(ctx context.Context, chainID walletCommon.ChainID, owner common.Address, cursor string, limit int, providerID string) (*thirdparty.CollectibleOwnershipContainer, error)

func (*Manager) FetchCollectionSocialsAsync added in v0.179.17

func (o *Manager) FetchCollectionSocialsAsync(contractID thirdparty.ContractID) error

func (*Manager) FetchCollectionsDataByContractID added in v0.162.15

func (o *Manager) FetchCollectionsDataByContractID(ctx context.Context, ids []thirdparty.ContractID) ([]thirdparty.CollectionData, error)

func (*Manager) FetchERC1155Balances added in v0.176.5

func (o *Manager) FetchERC1155Balances(ctx context.Context, owner common.Address, chainID walletCommon.ChainID, contractAddress common.Address, tokenIDs []*bigint.BigInt) ([]*bigint.BigInt, error)

func (*Manager) FetchMissingAssetsByCollectibleUniqueID added in v0.177.0

func (o *Manager) FetchMissingAssetsByCollectibleUniqueID(ctx context.Context, uniqueIDs []thirdparty.CollectibleUniqueID, asyncFetch bool) error

func (*Manager) GetCollectibleOwnership added in v0.175.3

func (o *Manager) GetCollectibleOwnership(id thirdparty.CollectibleUniqueID) ([]thirdparty.AccountBalance, error)

func (*Manager) ResetConnectionStatus added in v0.167.5

func (o *Manager) ResetConnectionStatus()

Reset connection status to trigger notifications on the next status update

func (*Manager) SearchCollectibles added in v0.177.0

func (o *Manager) SearchCollectibles(ctx context.Context, chainID walletCommon.ChainID, text string, cursor string, limit int, providerID string) (*thirdparty.FullCollectibleDataContainer, error)

func (*Manager) SearchCollections added in v0.177.0

func (o *Manager) SearchCollections(ctx context.Context, chainID walletCommon.ChainID, query string, cursor string, limit int, providerID string) (*thirdparty.CollectionDataContainer, error)

func (*Manager) SetCollectibleTransferID added in v0.174.8

func (o *Manager) SetCollectibleTransferID(ownerAddress common.Address, id thirdparty.CollectibleUniqueID, transferID common.Hash, notify bool) error

type ManagerInterface added in v0.166.7

type ManagerInterface interface {
	FetchAssetsByCollectibleUniqueID(ctx context.Context, uniqueIDs []thirdparty.CollectibleUniqueID, asyncFetch bool) ([]thirdparty.FullCollectibleData, error)
	FetchCollectionSocialsAsync(contractID thirdparty.ContractID) error
}

type OwnedCollectibles added in v0.170.0

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

type OwnedCollectiblesChange added in v0.172.5

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

type OwnedCollectiblesChangeCb added in v0.172.5

type OwnedCollectiblesChangeCb func(OwnedCollectiblesChange)

type OwnedCollectiblesChangeType added in v0.172.5

type OwnedCollectiblesChangeType = int
const (
	OwnedCollectiblesChangeTypeAdded OwnedCollectiblesChangeType = iota + 1
	OwnedCollectiblesChangeTypeUpdated
	OwnedCollectiblesChangeTypeRemoved
)

type OwnershipDB added in v0.162.13

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

func NewOwnershipDB added in v0.162.13

func NewOwnershipDB(sqlDb *sql.DB) *OwnershipDB

func (*OwnershipDB) FetchCachedCollectibleOwnersByContractAddress added in v0.180.31

func (o *OwnershipDB) FetchCachedCollectibleOwnersByContractAddress(chainID w_common.ChainID, contractAddress common.Address) (*thirdparty.CollectibleContractOwnership, error)

func (*OwnershipDB) GetCollectiblesWithNoTransferID added in v0.172.5

func (o *OwnershipDB) GetCollectiblesWithNoTransferID(account common.Address, chainID w_common.ChainID) ([]thirdparty.CollectibleUniqueID, error)

func (*OwnershipDB) GetIDsNotInDB added in v0.170.0

func (o *OwnershipDB) GetIDsNotInDB(
	ownerAddress common.Address,
	newIDs []thirdparty.CollectibleUniqueID) ([]thirdparty.CollectibleUniqueID, error)

Returns the list of added/removed IDs when comparing the given list of IDs with the ones in the DB. Call before Update for the result to be useful.

func (*OwnershipDB) GetIsFirstOfCollection added in v0.175.3

func (o *OwnershipDB) GetIsFirstOfCollection(onwerAddress common.Address, newIDs []thirdparty.CollectibleUniqueID) (map[thirdparty.CollectibleUniqueID]bool, error)

func (*OwnershipDB) GetLatestOwnershipUpdateTimestamp added in v0.167.5

func (o *OwnershipDB) GetLatestOwnershipUpdateTimestamp(chainID w_common.ChainID) (int64, error)

func (*OwnershipDB) GetOwnedCollectible added in v0.166.9

func (o *OwnershipDB) GetOwnedCollectible(chainID w_common.ChainID, ownerAddresses common.Address, contractAddress common.Address, tokenID *big.Int) (*thirdparty.CollectibleUniqueID, error)

func (*OwnershipDB) GetOwnedCollectibles added in v0.162.13

func (o *OwnershipDB) GetOwnedCollectibles(chainIDs []w_common.ChainID, ownerAddresses []common.Address, offset int, limit int) ([]thirdparty.CollectibleUniqueID, error)

func (*OwnershipDB) GetOwnership added in v0.171.35

func (*OwnershipDB) GetOwnershipUpdateTimestamp added in v0.166.11

func (o *OwnershipDB) GetOwnershipUpdateTimestamp(owner common.Address, chainID w_common.ChainID) (int64, error)

func (*OwnershipDB) GetTransferID added in v0.172.5

func (o *OwnershipDB) GetTransferID(ownerAddress common.Address, id thirdparty.CollectibleUniqueID) (*common.Hash, error)

func (*OwnershipDB) SetTransferID added in v0.172.5

func (o *OwnershipDB) SetTransferID(ownerAddress common.Address, id thirdparty.CollectibleUniqueID, transferID common.Hash) (bool, error)

func (*OwnershipDB) Update added in v0.162.13

func (o *OwnershipDB) Update(chainID w_common.ChainID, ownerAddress common.Address, balances thirdparty.TokenBalancesPerContractAddress, timestamp int64) (removedIDs, updatedIDs, insertedIDs []thirdparty.CollectibleUniqueID, err error)

type OwnershipState added in v0.166.11

type OwnershipState = int
const (
	OwnershipStateIdle OwnershipState = iota + 1
	OwnershipStateDelayed
	OwnershipStateUpdating
	OwnershipStateError
)

type OwnershipStatus added in v0.166.11

type OwnershipStatus struct {
	State     OwnershipState `json:"state"`
	Timestamp int64          `json:"timestamp"`
}

type OwnershipStatusPerAddressAndChainID added in v0.166.11

type OwnershipStatusPerAddressAndChainID = map[common.Address]OwnershipStatusPerChainID

type OwnershipStatusPerChainID added in v0.166.11

type OwnershipStatusPerChainID = map[walletCommon.ChainID]OwnershipStatus

type OwnershipUpdateMessage added in v0.172.5

type OwnershipUpdateMessage struct {
	Added   []thirdparty.CollectibleUniqueID `json:"added"`
	Updated []thirdparty.CollectibleUniqueID `json:"updated"`
	Removed []thirdparty.CollectibleUniqueID `json:"removed"`
}

type Service added in v0.162.13

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

func NewService added in v0.162.13

func NewService(
	db *sql.DB,
	walletFeed *event.Feed,
	accountsDB *accounts.Database,
	accountsFeed *event.Feed,
	settingsFeed *event.Feed,
	communityManager *community.Manager,
	networkManager *network.Manager,
	manager *Manager) *Service

func (*Service) FilterOwnedCollectibles added in v0.171.9

func (s *Service) FilterOwnedCollectibles(chainIDs []walletCommon.ChainID, owners []common.Address, filter Filter, offset int, limit int) ([]thirdparty.CollectibleUniqueID, bool, error)

func (*Service) GetCollectiblesByUniqueID added in v0.171.21

func (s *Service) GetCollectiblesByUniqueID(
	ctx context.Context,
	uniqueIDs []thirdparty.CollectibleUniqueID,
	dataType CollectibleDataType) (*GetCollectiblesByUniqueIDReturnType, error)

func (*Service) GetCollectiblesByUniqueIDAsync added in v0.171.21

func (s *Service) GetCollectiblesByUniqueIDAsync(
	requestID int32,
	uniqueIDs []thirdparty.CollectibleUniqueID,
	dataType CollectibleDataType)

func (*Service) GetOwnedCollectible added in v0.166.9

func (s *Service) GetOwnedCollectible(chainID walletCommon.ChainID, owner common.Address, contractAddress common.Address, tokenID *big.Int) (*thirdparty.CollectibleUniqueID, error)

func (*Service) GetOwnedCollectibles added in v0.162.13

func (s *Service) GetOwnedCollectibles(
	ctx context.Context,
	chainIDs []walletCommon.ChainID,
	addresses []common.Address,
	filter Filter,
	offset int,
	limit int,
	dataType CollectibleDataType,
	fetchCriteria FetchCriteria) (*GetOwnedCollectiblesReturnType, error)

func (*Service) GetOwnedCollectiblesAsync added in v0.171.21

func (s *Service) GetOwnedCollectiblesAsync(
	requestID int32,
	chainIDs []walletCommon.ChainID,
	addresses []common.Address,
	filter Filter,
	offset int,
	limit int,
	dataType CollectibleDataType,
	fetchCriteria FetchCriteria)

GetOwnedCollectiblesAsync allows only one filter task to run at a time and it cancels the current one if a new one is started All calls will trigger an EventOwnedCollectiblesFilteringDone event with the result of the filtering

func (*Service) GetOwnershipStatus added in v0.166.11

func (s *Service) GetOwnershipStatus(chainIDs []walletCommon.ChainID, owners []common.Address) (OwnershipStatusPerAddressAndChainID, error)

func (*Service) RefetchOwnedCollectibles added in v0.167.5

func (s *Service) RefetchOwnedCollectibles()

func (*Service) Start added in v0.162.13

func (s *Service) Start()

func (*Service) Stop added in v0.162.13

func (s *Service) Stop()

type TransferCb added in v0.172.5

type TransferCb func(common.Address, walletCommon.ChainID, []transfer.Transfer)

type TxHashData added in v0.175.3

type TxHashData struct {
	Hash common.Hash
	TxID common.Hash
}

Directories

Path Synopsis
Package mock_collectibles is a generated GoMock package.
Package mock_collectibles is a generated GoMock package.

Jump to

Keyboard shortcuts

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