Skip to content

Commit

Permalink
api: allow filter EVM tokens by name
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-wh committed Jun 26, 2023
1 parent 7062d20 commit 8cdc980
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 @@ -1439,6 +1439,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 @@ -461,10 +461,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`

AccountRuntimeSdkBalances = `
SELECT
Expand Down

0 comments on commit 8cdc980

Please sign in to comment.