Skip to content

Commit

Permalink
will break
Browse files Browse the repository at this point in the history
  • Loading branch information
benny-conn committed Oct 18, 2023
1 parent 01e1fc7 commit 3872155
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions service/multichain/zora/zora.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ func (d *Provider) getTokens(ctx context.Context, url string, rec chan<- multich
}
defer resp.Body.Close()

var tokens []multichain.ChainAgnosticToken
var contracts []multichain.ChainAgnosticContract
var willBreak bool
if balance {
var result getBalanceTokensResponse
err = json.NewDecoder(resp.Body).Decode(&result)
Expand All @@ -286,21 +289,11 @@ func (d *Provider) getTokens(ctx context.Context, url string, rec chan<- multich

logger.For(ctx).Infof("zora raw tokens retrieved: %d", len(result.Tokens))

tokens, contracts := d.balanceTokensToChainAgnostic(ctx, result.Tokens)

allTokens = append(allTokens, tokens...)
allContracts = append(allContracts, contracts...)

if rec != nil {
rec <- multichain.ChainAgnosticTokensAndContracts{
Tokens: tokens,
Contracts: contracts,
}
}

tokens, contracts = d.balanceTokensToChainAgnostic(ctx, result.Tokens)
if len(result.Tokens) < limit || !result.HasNextPage {
break
willBreak = true
}

} else {
var result getTokensResponse
err = json.NewDecoder(resp.Body).Decode(&result)
Expand All @@ -310,22 +303,24 @@ func (d *Provider) getTokens(ctx context.Context, url string, rec chan<- multich

logger.For(ctx).Infof("zora raw tokens retrieved: %d", len(result.Tokens))

tokens, contracts := d.tokensToChainAgnostic(ctx, result.Tokens)

allTokens = append(allTokens, tokens...)
allContracts = append(allContracts, contracts...)

if rec != nil {
rec <- multichain.ChainAgnosticTokensAndContracts{
Tokens: tokens,
Contracts: contracts,
}
tokens, contracts = d.tokensToChainAgnostic(ctx, result.Tokens)
if len(result.Tokens) < limit || !result.HasNextPage {
willBreak = true
}
}

if len(result.Tokens) < limit || !result.HasNextPage {
break
allTokens = append(allTokens, tokens...)
allContracts = append(allContracts, contracts...)

if rec != nil {
rec <- multichain.ChainAgnosticTokensAndContracts{
Tokens: tokens,
Contracts: contracts,
}
}
if willBreak {
break
}

}

Expand Down

0 comments on commit 3872155

Please sign in to comment.