chore: split collection data provider

This commit is contained in:
Dario Gabriel Lipicar 2023-08-16 10:01:57 -03:00 committed by dlipicar
parent 7c08429689
commit 3734f03645
3 changed files with 15 additions and 3 deletions

View File

@ -43,6 +43,7 @@ type Manager struct {
contractOwnershipProviders []thirdparty.CollectibleContractOwnershipProvider
accountOwnershipProviders []thirdparty.CollectibleAccountOwnershipProvider
collectibleDataProviders []thirdparty.CollectibleDataProvider
collectionDataProviders []thirdparty.CollectionDataProvider
metadataProvider thirdparty.CollectibleMetadataProvider
opensea *opensea.Client
httpClient *http.Client
@ -50,7 +51,7 @@ type Manager struct {
collectionsDataDB *CollectionDataDB
}
func NewManager(db *sql.DB, rpcClient *rpc.Client, contractOwnershipProviders []thirdparty.CollectibleContractOwnershipProvider, accountOwnershipProviders []thirdparty.CollectibleAccountOwnershipProvider, collectibleDataProviders []thirdparty.CollectibleDataProvider, opensea *opensea.Client) *Manager {
func NewManager(db *sql.DB, rpcClient *rpc.Client, contractOwnershipProviders []thirdparty.CollectibleContractOwnershipProvider, accountOwnershipProviders []thirdparty.CollectibleAccountOwnershipProvider, collectibleDataProviders []thirdparty.CollectibleDataProvider, collectionDataProviders []thirdparty.CollectionDataProvider, opensea *opensea.Client) *Manager {
hystrix.ConfigureCommand(hystrixContractOwnershipClientName, hystrix.CommandConfig{
Timeout: 10000,
MaxConcurrentRequests: 100,
@ -63,6 +64,7 @@ func NewManager(db *sql.DB, rpcClient *rpc.Client, contractOwnershipProviders []
contractOwnershipProviders: contractOwnershipProviders,
accountOwnershipProviders: accountOwnershipProviders,
collectibleDataProviders: collectibleDataProviders,
collectionDataProviders: collectionDataProviders,
opensea: opensea,
httpClient: &http.Client{
Timeout: requestTimeout,
@ -293,7 +295,7 @@ func (o *Manager) FetchCollectionsDataByContractID(ids []thirdparty.ContractID)
missingIDsPerChainID := thirdparty.GroupContractIDsByChainID(missingIDs)
for chainID, idsToFetch := range missingIDsPerChainID {
for _, provider := range o.collectibleDataProviders {
for _, provider := range o.collectionDataProviders {
if !provider.IsChainSupported(chainID) {
continue
}

View File

@ -127,7 +127,13 @@ func NewService(
alchemyClient,
}
collectiblesManager := collectibles.NewManager(db, rpcClient, contractOwnershipProviders, accountOwnershipProviders, collectibleDataProviders, openseaClient)
collectionDataProviders := []thirdparty.CollectionDataProvider{
openseaClient,
infuraClient,
alchemyClient,
}
collectiblesManager := collectibles.NewManager(db, rpcClient, contractOwnershipProviders, accountOwnershipProviders, collectibleDataProviders, collectionDataProviders, openseaClient)
collectibles := collectibles.NewService(db, walletFeed, accountsDB, accountFeed, rpcClient.NetworkManager, collectiblesManager)
return &Service{
db: db,

View File

@ -173,5 +173,9 @@ type CollectibleAccountOwnershipProvider interface {
type CollectibleDataProvider interface {
CollectibleProvider
FetchAssetsByCollectibleUniqueID(uniqueIDs []CollectibleUniqueID) ([]FullCollectibleData, error)
}
type CollectionDataProvider interface {
CollectibleProvider
FetchCollectionsDataByContractID(ids []ContractID) ([]CollectionData, error)
}