Skip to content

Commit

Permalink
feat: render name_fee on names/auctions (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
sborrazas committed Mar 25, 2024
1 parent b009208 commit 21a6b8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/ae_mdw/auction_bids.ex
Expand Up @@ -121,13 +121,15 @@ defmodule AeMdw.AuctionBids do
|> Map.delete("tx_index")

name_ttl = Names.expire_after(expire_height)
protocol = :aec_hard_forks.protocol_effective_at_height(last_gen)

%{
name: plain_name,
activation_time: DbUtil.block_index_to_time(state, block_index),
auction_end: expire_height,
approximate_expire_time:
DbUtil.height_to_time(state, expire_height, last_gen, last_micro_time),
name_fee: :aec_governance.name_claim_fee(plain_name, protocol),
last_bid: put_in(last_bid, ["tx", "ttl"], name_ttl)
}
end
Expand Down
3 changes: 3 additions & 0 deletions lib/ae_mdw/names.ex
Expand Up @@ -563,6 +563,8 @@ defmodule AeMdw.Names do
name =
State.fetch!(state, if(is_active?, do: @table_active, else: @table_inactive), plain_name)

protocol = :aec_hard_forks.protocol_effective_at_height(last_gen)

opts = [{:expand?, false}, {:tx_hash?, true} | opts]

name_hash =
Expand Down Expand Up @@ -591,6 +593,7 @@ defmodule AeMdw.Names do
DbUtil.height_to_time(state, active, last_gen, last_micro_time),
expire_height: expire,
approximate_expire_time: DbUtil.height_to_time(state, expire, last_gen, last_micro_time),
name_fee: :aec_governance.name_claim_fee(plain_name, protocol),
revoke: revoke && expand_txi_idx(state, revoke, opts),
auction_timeout: auction_timeout,
ownership: render_ownership(state, name)
Expand Down
7 changes: 4 additions & 3 deletions test/ae_mdw_web/controllers/name_controller_test.exs
Expand Up @@ -995,7 +995,7 @@ defmodule AeMdwWeb.NameControllerTest do
proto_vsn: fn _height -> 1 end
]},
{:aec_db, [], [get_header: fn _block_hash -> :block end]},
{:aec_headers, [], [time_in_msecs: fn :block -> kb_time end]}
{:aec_headers, [:passthrough], [time_in_msecs: fn :block -> kb_time end]}
] do
assert %{"data" => auction_bids, "next" => next} =
conn
Expand All @@ -1009,7 +1009,8 @@ defmodule AeMdwWeb.NameControllerTest do
assert %{
"name" => "1.chain",
"approximate_expire_time" => 123,
"last_bid" => last_bid
"last_bid" => last_bid,
"name_fee" => 0
} = Enum.at(auction_bids, 0)

refute Map.has_key?(last_bid, "tx_index")
Expand Down Expand Up @@ -1218,7 +1219,7 @@ defmodule AeMdwWeb.NameControllerTest do
ownership: fn _state, _mname -> %{current: nil, original: nil} end
]},
{:aec_db, [], [get_header: fn _block_hash -> :block end]},
{:aec_headers, [], [time_in_msecs: fn :block -> 123 end]}
{:aec_headers, [:passthrough], [time_in_msecs: fn :block -> 123 end]}
] do
assert %{"data" => names, "next" => _next} =
conn
Expand Down

0 comments on commit 21a6b8d

Please sign in to comment.