From 2644b79b3ad5aad436920d7111f5431c09092c78 Mon Sep 17 00:00:00 2001 From: Sebastian Borrazas Date: Wed, 4 Jan 2023 07:28:42 -0300 Subject: [PATCH] feat: rename tx_hash to source_tx_hash on claims/updates/transfers --- lib/ae_mdw/names.ex | 15 +++++++++------ .../controllers/name_controller_test.exs | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/ae_mdw/names.ex b/lib/ae_mdw/names.ex index b29d77be2..cbe29f501 100644 --- a/lib/ae_mdw/names.ex +++ b/lib/ae_mdw/names.ex @@ -603,8 +603,9 @@ defmodule AeMdw.Names do %{ height: height, block_hash: Enc.encode(:micro_block_hash, block_hash), - tx_hash: Enc.encode(:tx_hash, tx_hash), - tx_type: Format.type_to_swagger_name(tx_type), + source_tx_hash: Enc.encode(:tx_hash, tx_hash), + source_tx_type: Format.type_to_swagger_name(tx_type), + internal_source: tx_type != :name_claim_tx, tx: :aens_claim_tx.for_client(claim_aetx) } end @@ -616,8 +617,9 @@ defmodule AeMdw.Names do %{ height: height, block_hash: Enc.encode(:micro_block_hash, block_hash), - tx_hash: Enc.encode(:tx_hash, tx_hash), - tx_type: Format.type_to_swagger_name(tx_type), + source_tx_hash: Enc.encode(:tx_hash, tx_hash), + source_tx_type: Format.type_to_swagger_name(tx_type), + internal_source: tx_type != :name_update_tx, tx: :aens_update_tx.for_client(update_aetx) } end @@ -629,8 +631,9 @@ defmodule AeMdw.Names do %{ height: height, block_hash: Enc.encode(:micro_block_hash, block_hash), - tx_hash: Enc.encode(:tx_hash, tx_hash), - tx_type: Format.type_to_swagger_name(tx_type), + source_tx_hash: Enc.encode(:tx_hash, tx_hash), + source_tx_type: Format.type_to_swagger_name(tx_type), + internal_source: tx_type != :name_transfer_tx, tx: :aens_transfer_tx.for_client(transfer_aetx) } end diff --git a/test/ae_mdw_web/controllers/name_controller_test.exs b/test/ae_mdw_web/controllers/name_controller_test.exs index ceab2a1f2..546544f04 100644 --- a/test/ae_mdw_web/controllers/name_controller_test.exs +++ b/test/ae_mdw_web/controllers/name_controller_test.exs @@ -1811,15 +1811,17 @@ defmodule AeMdwWeb.NameControllerTest do assert %{ "height" => 124, - "tx_type" => "NameClaimTx", - "tx_hash" => ^tx3_hash_enc, + "source_tx_type" => "NameClaimTx", + "source_tx_hash" => ^tx3_hash_enc, + "internal_source" => false, "tx" => %{"fee" => 333_333} } = claim3 assert %{ "height" => 123, - "tx_type" => "NameClaimTx", - "tx_hash" => ^tx2_hash_enc, + "source_tx_type" => "NameClaimTx", + "source_tx_hash" => ^tx2_hash_enc, + "internal_source" => false, "tx" => %{"fee" => 222_222} } = claim2 @@ -1995,8 +1997,9 @@ defmodule AeMdwWeb.NameControllerTest do assert %{ "height" => 123, - "tx_hash" => ^tx1_hash_enc, - "tx_type" => "ContractCallTx", + "source_tx_hash" => ^tx1_hash_enc, + "source_tx_type" => "ContractCallTx", + "internal_source" => true, "tx" => %{"fee" => 111_111, "name" => ^plain_name} } = claim1 end