Merge pull request #5625 from blockscout/np-fix-redirects

Get rid of some redirects to checksummed address url
pull/5629/head
Victor Baranov 3 years ago committed by GitHub
commit fbab75768c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 8
      apps/block_scout_web/lib/phoenix/param.ex
  3. 4
      apps/block_scout_web/test/block_scout_web/controllers/tokens/holder_controller_test.exs
  4. 5
      apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs

@ -17,6 +17,7 @@
- [#5538](https://github.com/blockscout/blockscout/pull/5538) - Fix internal transaction's tile bug
### Chore
- [#5625](https://github.com/blockscout/blockscout/pull/5625) - Get rid of some redirects to checksummed address url
- [#5623](https://github.com/blockscout/blockscout/pull/5623) - Allow hyphen in DB password
- [#5543](https://github.com/blockscout/blockscout/pull/5543) - Increase max_restarts to 1_000 (from 3 by default) for explorer, block_scout_web supervisors
- [#5536](https://github.com/blockscout/blockscout/pull/5536) - NPM audit fix

@ -1,11 +1,17 @@
alias Explorer.Chain.{Address, Block, Hash, Transaction}
defimpl Phoenix.Param, for: [Address, Transaction] do
defimpl Phoenix.Param, for: Transaction do
def to_param(%@for{hash: hash}) do
@protocol.to_param(hash)
end
end
defimpl Phoenix.Param, for: Address do
def to_param(%@for{} = address) do
@for.checksum(address)
end
end
defimpl Phoenix.Param, for: Block do
def to_param(%@for{consensus: true, number: number}) do
to_string(number)

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.Tokens.HolderControllerTest do
use BlockScoutWeb.ConnCase, async: true
alias Explorer.Chain.Hash
alias Explorer.Chain.{Address, Hash}
describe "GET index/3" do
test "with invalid address hash", %{conn: conn} do
@ -67,7 +67,7 @@ defmodule BlockScoutWeb.Tokens.HolderControllerTest do
assert Enum.all?(second_page_token_balances, fn token_balance ->
Enum.any?(token_balance_tiles, fn tile ->
String.contains?(tile, to_string(token_balance.address_hash))
String.contains?(tile, Address.checksum(token_balance.address_hash))
end)
end)
end

@ -5,6 +5,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
import BlockScoutWeb.WebRouter.Helpers, only: [transaction_log_path: 3]
alias Explorer.Chain.Address
alias Explorer.ExchangeRates.Token
describe "GET index/2" do
@ -44,7 +45,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
{:ok, %{"items" => items}} = conn.resp_body |> Poison.decode()
first_log = List.first(items)
assert String.contains?(first_log, to_string(address.hash))
assert String.contains?(first_log, Address.checksum(address.hash))
end
test "returns logs for the transaction with nil to_address", %{conn: conn} do
@ -67,7 +68,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
{:ok, %{"items" => items}} = conn.resp_body |> Poison.decode()
first_log = List.first(items)
assert String.contains?(first_log, to_string(address.hash))
assert String.contains?(first_log, Address.checksum(address.hash))
end
test "assigns no logs when there are none", %{conn: conn} do

Loading…
Cancel
Save