Merge pull request #1669 from poanetwork/ab-fix-search-by-token-name

do not fail if multiple matching tokens are found
ab-decrease-blocks-number-for-geth
Ayrat Badykov 6 years ago committed by GitHub
commit 1b4172edc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 6
      apps/explorer/lib/explorer/chain.ex
  3. 9
      apps/explorer/test/explorer/chain_test.exs

@ -4,6 +4,8 @@
### Fixes
- [#1669](https://github.com/poanetwork/blockscout/pull/1669) - do not fail if multiple matching tokens are found
### Chore

@ -691,10 +691,10 @@ defmodule Explorer.Chain do
)
query
|> Repo.one()
|> Repo.all()
|> case do
nil -> {:error, :not_found}
hash -> {:ok, hash}
[] -> {:error, :not_found}
hashes -> {:ok, List.first(hashes)}
end
end

@ -869,6 +869,15 @@ defmodule Explorer.ChainTest do
assert {:ok, _} = Chain.token_contract_address_from_token_name(name)
end
test "return only one result if multiple records are found" do
name = "TOKEN"
insert(:token, symbol: name)
insert(:token, symbol: name)
assert {:ok, _} = Chain.token_contract_address_from_token_name(name)
end
end
describe "find_or_insert_address_from_hash/1" do

Loading…
Cancel
Save