|
|
@ -2,43 +2,29 @@ defmodule BlockScoutWeb.Tokens.Instance.TransferControllerTest do |
|
|
|
use BlockScoutWeb.ConnCase, async: false |
|
|
|
use BlockScoutWeb.ConnCase, async: false |
|
|
|
|
|
|
|
|
|
|
|
describe "GET token-transfers/2" do |
|
|
|
describe "GET token-transfers/2" do |
|
|
|
test "works for ERC-721 tokens", %{conn: conn} do |
|
|
|
test "fetches the instance", %{conn: conn} do |
|
|
|
contract_address = insert(:address) |
|
|
|
contract_address = insert(:address) |
|
|
|
|
|
|
|
|
|
|
|
insert(:token, contract_address: contract_address) |
|
|
|
insert(:token, contract_address: contract_address) |
|
|
|
|
|
|
|
|
|
|
|
token_id = 10 |
|
|
|
contract_address_hash = contract_address.hash |
|
|
|
|
|
|
|
|
|
|
|
%{log_index: log_index} = |
|
|
|
token_id = Decimal.new(10) |
|
|
|
insert(:token_transfer, |
|
|
|
|
|
|
|
from_address: contract_address, |
|
|
|
|
|
|
|
token_contract_address: contract_address, |
|
|
|
|
|
|
|
token_id: token_id |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn = get(conn, "/token/#{contract_address.hash}/instance/#{token_id}/token-transfers") |
|
|
|
insert(:token_instance, |
|
|
|
|
|
|
|
token_contract_address_hash: contract_address_hash, |
|
|
|
|
|
|
|
token_id: token_id |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
assert %{assigns: %{token_instance: %{log_index: ^log_index}}} = conn |
|
|
|
conn = get(conn, "/token/#{contract_address_hash}/instance/#{token_id}/token-transfers") |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "works for ERC-1155 tokens", %{conn: conn} do |
|
|
|
|
|
|
|
contract_address = insert(:address) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insert(:token, contract_address: contract_address) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
token_id = 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%{log_index: log_index} = |
|
|
|
|
|
|
|
insert(:token_transfer, |
|
|
|
|
|
|
|
from_address: contract_address, |
|
|
|
|
|
|
|
token_contract_address: contract_address, |
|
|
|
|
|
|
|
token_id: nil, |
|
|
|
|
|
|
|
token_ids: [token_id] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn = get(conn, "/token/#{contract_address.hash}/instance/#{token_id}/token-transfers") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert %{assigns: %{token_instance: %{log_index: ^log_index}}} = conn |
|
|
|
assert %{ |
|
|
|
|
|
|
|
assigns: %{ |
|
|
|
|
|
|
|
token_instance: %{ |
|
|
|
|
|
|
|
instance: %{token_contract_address_hash: ^contract_address_hash, token_id: ^token_id} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} = conn |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|