Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch on refresh, don't use unidentified contract names #1164

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions service/multichain/multichain.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const staleCommunityTime = time.Minute * 30

const maxCommunitySize = 10_000

var contractNameBlacklist = map[string]bool{
"unidentified contract": true,
"unknown contract": true,
"unknown": true,
}

// SendTokens is called to process a user's batch of tokens
type SendTokens func(context.Context, task.TokenProcessingUserMessage) error

Expand Down Expand Up @@ -185,6 +191,7 @@ type OpenSeaChildContractFetcher interface {

// ContractRefresher supports refreshes of a contract
type ContractRefresher interface {
ContractsFetcher
RefreshContract(context.Context, persist.Address) error
}

Expand Down Expand Up @@ -1218,7 +1225,7 @@ func (p *Provider) RefreshToken(ctx context.Context, ti persist.TokenIdentifiers
}

// contract
if contract.Name != "" && finalContractDescriptors.Name == "" {
if (contract.Name != "" && !contractNameBlacklist[strings.ToLower(contract.Name)]) && finalContractDescriptors.Name == "" {
finalContractDescriptors.Name = contract.Name
}
if contract.Description != "" && finalContractDescriptors.Description == "" {
Expand Down Expand Up @@ -1260,12 +1267,20 @@ func (p *Provider) RefreshToken(ctx context.Context, ti persist.TokenIdentifiers
// RefreshContract refreshes a contract on the given chain using the chain provider for that chain
func (p *Provider) RefreshContract(ctx context.Context, ci persist.ContractIdentifiers) error {
contractRefreshers := matchingProvidersForChain[ContractRefresher](p.Chains, ci.Chain)
for _, refresher := range contractRefreshers {
var contracts []chainContracts
for i, refresher := range contractRefreshers {
if err := refresher.RefreshContract(ctx, ci.ContractAddress); err != nil {
return err
}
c, err := refresher.GetContractByAddress(ctx, ci.ContractAddress)
if err != nil {
return err
}
contracts = append(contracts, chainContracts{priority: i, chain: ci.Chain, contracts: []ChainAgnosticContract{c}})
}
return nil

_, err := p.processContracts(ctx, contracts, false)
return err
}

// RefreshTokensForContract refreshes all tokens in a given contract
Expand Down Expand Up @@ -1789,7 +1804,7 @@ func contractsToNewDedupedContracts(contracts []chainContracts) []persist.Contra
if contract.Descriptors.Symbol != "" {
meta.Symbol = contract.Descriptors.Symbol
}
if contract.Descriptors.Name != "" {
if contract.Descriptors.Name != "" && !contractNameBlacklist[strings.ToLower(contract.Descriptors.Name)] {
meta.Name = contract.Descriptors.Name
}
if contract.Descriptors.CreatorAddress != "" {
Expand Down
Loading