Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort by address.hash column in accountlist API endpoint #6032

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Fixes

- [#6032](https://github.com/blockscout/blockscout/pull/6032) - Sort by address.hash column in accountlist API endpoint
- [#6017](https://github.com/blockscout/blockscout/pull/6017), [#6028](https://github.com/blockscout/blockscout/pull/6028) - Move "contract interaction" and "Add chain to MM" env vars to runtime
- [#6012](https://github.com/blockscout/blockscout/pull/6012) - Fix display of estimated addresses counter on the main page
- [#5978](https://github.com/blockscout/blockscout/pull/5978) - Allow timestamp param in the log of eth_getTransactionReceipt method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,49 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
] = response["result"]
end

test "sort by hash", %{params: params, conn: conn} do
inserted_at = Timex.shift(Timex.now(), minutes: -10)

first_address =
insert(:address,
hash: "0x0000000000000000000000000000000000000001",
fetched_coin_balance: 10,
inserted_at: inserted_at
)

second_address =
insert(:address,
hash: "0x0000000000000000000000000000000000000002",
fetched_coin_balance: 100,
inserted_at: inserted_at
)

first_address_hash = to_string(first_address.hash)
second_address_hash = to_string(second_address.hash)

first_address_inserted_at = to_string(first_address.inserted_at)
second_address_inserted_at = to_string(second_address.inserted_at)

response =
conn
|> get("/api", params)
|> json_response(200)

schema = listaccounts_schema()
assert :ok = ExJsonSchema.Validator.validate(schema, response)
assert response["message"] == "OK"
assert response["status"] == "1"

assert [
%{
"address" => ^first_address_hash
},
%{
"address" => ^second_address_hash
}
] = response["result"]
end

test "with a stale balance", %{conn: conn, params: params} do
now = Timex.now()

Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/lib/explorer/etherscan/addresses.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Explorer.Etherscan.Addresses do
query =
from(
address in Address,
order_by: [asc: address.inserted_at],
order_by: [asc: address.inserted_at, asc: address.hash],
offset: ^offset,
limit: ^limit
)
Expand Down