Merge pull request #8678 from blockscout/np-fix-is-verified-flag

Fix is_verified for /addresses and /smart-contracts
pull/8695/head
Victor Baranov 1 year ago committed by GitHub
commit f5de3d2fd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 8
      apps/block_scout_web/lib/block_scout_web/views/api/v2/smart_contract_view.ex
  3. 11
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs
  4. 2
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs
  5. 2
      apps/explorer/lib/explorer/chain.ex

@ -8,6 +8,7 @@
### Fixes
- [#8678](https://github.com/blockscout/blockscout/pull/8678) - Fix `is_verified` for `/addresses` and `/smart-contracts`
- [#8685](https://github.com/blockscout/blockscout/pull/8685) - Fix db pool size exceeds Postgres max connections
### Chore

@ -257,7 +257,13 @@ defmodule BlockScoutWeb.API.V2.SmartContractView do
token = smart_contract.address.token
%{
"address" => Helper.address_with_info(nil, smart_contract.address, smart_contract.address.hash, false),
"address" =>
Helper.address_with_info(
nil,
%Address{smart_contract.address | smart_contract: smart_contract},
smart_contract.address.hash,
false
),
"compiler_version" => smart_contract.compiler_version,
"optimization_enabled" => smart_contract.optimization,
"tx_count" => smart_contract.address.transactions_count,

@ -1668,6 +1668,17 @@ defmodule BlockScoutWeb.API.V2.AddressControllerTest do
compare_item(address, address_json)
end
test "check smart contract preload", %{conn: conn} do
smart_contract = insert(:smart_contract, address_hash: insert(:contract_address, fetched_coin_balance: 1).hash)
request = get(conn, "/api/v2/addresses")
assert %{"items" => [address]} = json_response(request, 200)
assert String.downcase(address["hash"]) == to_string(smart_contract.address_hash)
assert address["is_contract"] == true
assert address["is_verified"] == true
end
end
describe "/addresses/{address_hash}/tabs-counters" do

@ -2375,6 +2375,8 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
assert %{"items" => [sc], "next_page_params" => nil} = json_response(request, 200)
compare_item(smart_contract, sc)
assert sc["address"]["is_verified"] == true
assert sc["address"]["is_contract"] == true
end
test "check pagination", %{conn: conn} do

@ -2062,7 +2062,7 @@ defmodule Explorer.Chain do
from(a in Address,
where: a.fetched_coin_balance > ^0,
order_by: [desc: a.fetched_coin_balance, asc: a.hash],
preload: [:names],
preload: [:names, :smart_contract],
select: {a, fragment("coalesce(1 + ?, 0)", a.nonce)}
)

Loading…
Cancel
Save