Skip to content

Commit

Permalink
Return more info about transactions in /aex9/transfers endpoints [#198]
Browse files Browse the repository at this point in the history
  • Loading branch information
myotp committed Jun 30, 2021
1 parent 2760408 commit 9a394a8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/ae_mdw_web/controllers/aex9_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule AeMdwWeb.Aex9Controller do
alias AeMdw.Error.Input, as: ErrInput
alias AeMdw.Node.Db, as: DBN
alias AeMdw.Db.{Format, Model, Contract}
alias AeMdw.Db.Util
alias AeMdwWeb.SwaggerParameters
alias AeMdwWeb.DataStreamPlug, as: DSPlug

Expand Down Expand Up @@ -358,12 +359,16 @@ defmodule AeMdwWeb.Aex9Controller do
do: transfer_to_map({sender_pk, recipient_pk, amount, call_txi, log_idx}, :aex9_transfer)

def transfer_to_map({sender_pk, recipient_pk, amount, call_txi, log_idx}, :aex9_transfer) do
tx = Util.read_tx!(call_txi) |> Format.to_map()
%{
sender: enc_id(sender_pk),
recipient: enc_id(recipient_pk),
amount: amount,
call_txi: call_txi,
log_idx: log_idx
log_idx: log_idx,
block_height: tx["block_height"],
micro_time: tx["micro_time"],
contract_id: tx["tx"]["contract_id"],
}
end

Expand Down Expand Up @@ -439,14 +444,20 @@ defmodule AeMdwWeb.Aex9Controller do
log_idx(:integer, "Log index", required: true)
recipient(:string, "Recipient of AEX9 transfer", required: true)
sender(:string, "Sender of AEX9 transfer", required: true)
block_height(:integer, "The block height", required: true)
micro_time(:integer, "The unix timestamp", required: true)
contract_id(:string, "Contract identifier", required: true)
end

example(%{
amount: 2,
call_txi: 9_564_978,
log_idx: 0,
recipient: "ak_29GUBTrWTMb3tRUUgbVX1Bgwi2hyVhB8Q1befNsjLnP46Ub1V8",
sender: "ak_2CMNYSgoEjb1GSVJfWXjZ9NFWwnJ9jySBd6YY7uyr5DxvwctZU"
sender: "ak_2CMNYSgoEjb1GSVJfWXjZ9NFWwnJ9jySBd6YY7uyr5DxvwctZU",
block_height: 234208,
micro_time: 1585667337719,
contract_id: "ct_pqfbS94uUpE8reSwgtaAy5odGi7cPRMAxbjMyEzpTGqwTWyn5"
})
end
}
Expand Down

0 comments on commit 9a394a8

Please sign in to comment.