Skip to content

Commit f7ed97a

Browse files
committed
cleanup / small linter fixes
1 parent d623b49 commit f7ed97a

7 files changed

Lines changed: 44 additions & 30 deletions

File tree

internal/collections/collection.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ func NewCollection(contractAddress common.Address, name string, nodes *provider.
103103

104104
// cache collection name
105105
// gbCache.CacheCollectionName(contractAddress, collectionName)
106-
rueidi.StoreContractName(ctx, contractAddress, collectionName)
106+
err := rueidi.StoreContractName(ctx, contractAddress, collectionName)
107+
if err != nil {
108+
gbl.Log.Errorf("error storing contract name: %s | %s", style.ShortenAddress(&contractAddress), err)
109+
}
107110
}
108111

109112
default:

internal/collections/collectiondb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (cs *CollectionDB) OpenseaSlugsAndAddresses() map[string]common.Address {
3737
slugAddresses := make(map[string]common.Address, 0)
3838

3939
for _, c := range cs.Collections {
40-
if slug := c.OpenseaSlug; slug != "" && !c.IgnorePrinting && c.Show.Listings {
40+
if slug := c.OpenseaSlug; slug != "" && !c.IgnorePrinting { // && c.Show.Listings {
4141
slugAddresses[slug] = c.ContractAddress
4242
}
4343
}

internal/nemo/provider/pool.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,10 @@ func (pp *Pool) ReverseResolveAddressToENS(ctx context.Context, address common.A
665665

666666
if ensName, ok := name.(string); err == nil && ok && ensName != "" {
667667
// cache.StoreENSName(ctx, address, ensName)
668-
pp.Rueidi.StoreENSName(ctx, address, ensName)
668+
err := pp.Rueidi.StoreENSName(ctx, address, ensName)
669+
if err != nil {
670+
gbl.Log.Errorf("error storing ensName %s for address %s: %s", ensName, address.Hex(), err)
671+
}
669672

670673
return ensName, nil
671674
}
@@ -683,10 +686,13 @@ func (pp *Pool) ResolveENS(ctx context.Context, ensName string) (common.Address,
683686

684687
if err == nil && address != "" {
685688
if addr, ok := address.(common.Address); ok {
689+
err := pp.Rueidi.StoreENSName(ctx, addr, ensName)
690+
if err != nil {
691+
gbl.Log.Errorf("error storing ensName %s for address %s: %s", ensName, address, err)
692+
}
693+
686694
return addr, nil
687695
}
688-
// cache.StoreENSName(ctx, address, ensName)
689-
// return ensName, nil
690696
}
691697

692698
if err != nil {

internal/pusu/pusu.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func SubscribeToListings(gb *gloomberg.Gloomberg, queueTokenTransactions chan *t
5555

5656
// create a list of channels to subscribe to
5757
channels := make([]string, 0)
58+
5859
for _, collectionAddress := range slugAddresses {
5960
channelPattern := internal.TopicSeaWatcher + "/" + collectionAddress.String() + "/*"
6061

internal/rueidica/rueidica.go

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ import (
2121
)
2222

2323
const (
24-
keywordContractName string = "contractName"
25-
keywordENS string = "ensDomain"
26-
keywordOSSlug string = "osslug"
27-
keywordBlurSlug string = "blurslug"
28-
keywordSalira string = "salira"
29-
keywordNotificationsLock string = "notification"
30-
keyDelimiter string = ":"
31-
// keywordFloorPrice string = "floor"
24+
keywordContractName string = "contractName"
25+
keywordENS string = "ensDomain"
26+
keywordOSSlug string = "osslug"
27+
keywordBlurSlug string = "blurslug"
28+
keywordSalira string = "salira"
29+
keyDelimiter string = ":"
3230
)
3331

3432
type Rueidica struct {
@@ -103,11 +101,12 @@ func (r *Rueidica) getCachedName(ctx context.Context, address common.Address, ke
103101
if r != nil {
104102
cachedName, err := r.DoCache(ctx, r.B().Get().Key(keyFunc(address)).Cache(), clientCacheTTL).ToString()
105103

106-
if err != nil && rueidis.IsRedisNil(err) {
104+
switch {
105+
case err != nil && rueidis.IsRedisNil(err):
107106
gbl.Log.Debugf("rueidis | no name in cache for %s", address.Hex())
108-
} else if err != nil {
107+
case err != nil:
109108
gbl.Log.Errorf("rueidis | error getting cached name: %s", err)
110-
} else {
109+
default:
111110
gbl.Log.Debugf("rueidis | found name: %s -> %s", keyFunc(address), cachedName)
112111
}
113112

@@ -123,13 +122,14 @@ func (r *Rueidica) getCachedNumber(ctx context.Context, address common.Address,
123122
if r != nil {
124123
cachedNumber, err := r.DoCache(ctx, r.B().Get().Key(keyFunc(address)).Cache(), clientCacheTTL).ToString()
125124

126-
if err != nil && rueidis.IsRedisNil(err) {
125+
switch {
126+
case err != nil && rueidis.IsRedisNil(err):
127127
gbl.Log.Debugf("rueidis | no number in cache for %s", address.Hex())
128128

129129
return 0, err
130-
} else if err != nil {
130+
case err != nil:
131131
gbl.Log.Errorf("rueidis | error getting cached number: %s", err)
132-
} else {
132+
default:
133133
gbl.Log.Debugf("rueidis | found number: %s -> %f", keyFunc(address), cachedNumber)
134134
}
135135

@@ -274,10 +274,6 @@ func keyENS(address common.Address) string {
274274
return fmt.Sprint(address.Hex(), keyDelimiter, keywordENS)
275275
}
276276

277-
func keyNotificationsLock(txID common.Hash) string {
278-
return fmt.Sprint(txID.Hex(), keyDelimiter, keywordNotificationsLock)
279-
}
280-
281277
func keyOSSlug(address common.Address) string {
282278
return fmt.Sprint(address.Hex(), keyDelimiter, keywordOSSlug)
283279
}
@@ -289,7 +285,3 @@ func keyBlurSlug(address common.Address) string {
289285
func keySalira(address common.Address) string {
290286
return fmt.Sprint(address.Hex(), keyDelimiter, keywordSalira)
291287
}
292-
293-
// func KeyFloorPrice(address common.Address) string {
294-
// return fmt.Sprint(address.Hex(), keyDelimiter, keywordFloorPrice)
295-
// }

internal/trapri/trapri.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func formatTokenTransaction(gb *gloomberg.Gloomberg, ttx *totra.TokenTransaction
117117
// defaults
118118
priceStyle := style.DarkWhiteStyle
119119
priceArrowColor := style.DarkGray
120+
120121
if ttx.GetPrice().Ether() >= 0.01 {
121122
priceArrowColor = style.GetPriceShadeColor(ttx.GetPrice().Ether())
122123
}
@@ -253,6 +254,7 @@ func formatTokenTransaction(gb *gloomberg.Gloomberg, ttx *totra.TokenTransaction
253254
// for erc1155 we get the current total supply of the token
254255
// useful for mints, burns, etc., especially if they happen over a long* period of time
255256
var fmtTotalSupply string
257+
256258
if transfer.Standard == standard.ERC1155 && (isOwnWallet || isOwnCollection || isWatchUsersWallet) {
257259
// if supply, err := gb.Nodes.TotalSupplyERC1155(ctx, transfer.Token.Address, transfer.Token.ID); err == nil {
258260
if supply, err := gb.ProviderPool.ERC1155TotalSupply(ctx, transfer.Token.Address, transfer.Token.ID); err == nil {
@@ -288,7 +290,6 @@ func formatTokenTransaction(gb *gloomberg.Gloomberg, ttx *totra.TokenTransaction
288290
if numCollectionTokens == int64(len(transfers)) && ttx.From == sender {
289291
// all tokens sold by the same address -> dumped into bids
290292
// isBidDump = true
291-
292293
if numCollectionTokens > 5 || ttx.GetPrice().Ether() > 3.0 {
293294
// if its a significant amount of tokens or ether we use a reddish style
294295
numberStyle = style.TrendRedStyle
@@ -416,6 +417,7 @@ func formatTokenTransaction(gb *gloomberg.Gloomberg, ttx *totra.TokenTransaction
416417

417418
if len(fmtTokensTransferred) == 0 {
418419
gbl.Log.Debugf("🧐 no tokens transferred: %s | %+v", style.TerminalLink(utils.GetEtherscanTxURL(txHash.String()), txHash.String()), ttx.Transfers)
420+
419421
for _, transfer := range ttx.Transfers {
420422
gbl.Log.Debugf(
421423
" transfer of %dx %s | %+v",
@@ -492,6 +494,7 @@ func formatTokenTransaction(gb *gloomberg.Gloomberg, ttx *totra.TokenTransaction
492494
// print sales for collection
493495
if viper.GetBool("show.sales") {
494496
out.WriteString(" | " + fmt.Sprintf("%dx", currentCollection.Counters.Sales) + style.BoldStyle.Render(""))
497+
495498
if currentCollection.Counters.Sales < 10 {
496499
out.WriteString(" ")
497500
}

internal/utils/slugs/slugs.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/benleb/gloomberg/internal/gbl"
1313
"github.com/benleb/gloomberg/internal/opensea"
1414
"github.com/benleb/gloomberg/internal/rueidica"
15+
"github.com/benleb/gloomberg/internal/style"
1516
"github.com/benleb/gloomberg/internal/utils"
1617
"github.com/ethereum/go-ethereum/common"
1718
)
@@ -35,7 +36,11 @@ func SlugWorker(slugTicker *time.Ticker, slugQueue *chan common.Address, rueidic
3536
gbl.Log.Infof("fetching opensea slug for: %s", address.Hex())
3637

3738
if osslug := opensea.GetCollectionSlug(address); osslug != "" {
38-
rueidica.StoreOSSlug(context.Background(), address, osslug)
39+
err := rueidica.StoreOSSlug(context.Background(), address, osslug)
40+
if err != nil {
41+
gbl.Log.Errorf("error storing opensea slug: %s | %s", style.ShortenAddress(&address), err)
42+
}
43+
3944
gbl.Log.Infof("caching opensea slug for: %s\n", address.Hex())
4045
} else {
4146
gbl.Log.Warnf("❌ fetching opensea slug for collection %s failed: no slug found", address.Hex())
@@ -46,7 +51,11 @@ func SlugWorker(slugTicker *time.Ticker, slugQueue *chan common.Address, rueidic
4651
gbl.Log.Infof("fetching blur slug for: %s", address.Hex())
4752

4853
if blurslug, err := GetBlurSlugByName(address); err == nil && blurslug != "" {
49-
rueidica.StoreBlurSlug(context.Background(), address, blurslug)
54+
err := rueidica.StoreBlurSlug(context.Background(), address, blurslug)
55+
if err != nil {
56+
gbl.Log.Errorf("error storing blur slug: %s | %s", style.ShortenAddress(&address), err)
57+
}
58+
5059
gbl.Log.Infof("caching blur slug for: %s\n", address.Hex())
5160
} else {
5261
gbl.Log.Warnf("❌ fetching blur slug for collection %s failed: no slug found", address.Hex())

0 commit comments

Comments
 (0)