Skip to content

Commit

Permalink
Merge pull request #460 from oasisprotocol/pro-wh/feature/tokenname
Browse files Browse the repository at this point in the history
 api: allow filter EVM tokens by name
  • Loading branch information
pro-wh authored Jun 27, 2023
2 parents b3c55bf + f29b2db commit beeaf1c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,11 @@ paths:
- *limit
- *offset
- *runtime
- in: query
name: name
schema:
type: string
description: A filter on the name, the name must contain this value as a substring.
responses:
'200':
description: The requested tokens.
Expand Down
1 change: 1 addition & 0 deletions storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,7 @@ func (c *StorageClient) RuntimeTokens(ctx context.Context, p apiTypes.GetRuntime
queries.EvmTokens,
runtimeFromCtx(ctx),
address,
p.Name,
p.Limit,
p.Offset,
)
Expand Down
5 changes: 3 additions & 2 deletions storage/client/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,11 @@ const (
WHERE
(tokens.runtime = $1) AND
($2::oasis_addr IS NULL OR tokens.token_address = $2::oasis_addr) AND
($3::text IS NULL OR tokens.token_name ILIKE '%' || $3 || '%' OR tokens.symbol ILIKE '%' || $3 || '%') AND
tokens.token_type != 0 -- exclude unknown-type tokens; they're often just contracts that emitted Transfer events but don't expose the token ticker, name, balance etc.
ORDER BY num_holders DESC
LIMIT $3::bigint
OFFSET $4::bigint`
LIMIT $4::bigint
OFFSET $5::bigint`

//nolint:gosec // Linter suspects a hardcoded credentials token.
EvmTokenHolders = `
Expand Down

0 comments on commit beeaf1c

Please sign in to comment.