Skip to content

Commit

Permalink
Revert change for the faucet - fix by archethic-foundation#204
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel committed Jan 27, 2022
1 parent c87375e commit 86ab868
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions lib/archethic_web/controllers/faucet_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ defmodule ArchEthicWeb.FaucetController do
def create_transfer(conn, %{"address" => address}) do
with {:ok, recipient_address} <- Base.decode16(address, case: :mixed),
true <- Crypto.valid_hash?(recipient_address),
{:ok, tx_addr} <- transfer(recipient_address) do
:ok <- transfer(recipient_address) do
conn
|> put_resp_header("cache-control", "no-cache, no-store, must-revalidate")
|> put_resp_header("pragma", "no-cache")
|> put_resp_header("expires", "0")
|> put_flash(:info, "Transferred successfully (click to view)")
|> render("index.html", address: "", link_address: Base.encode16(tx_addr))
|> render("index.html", address: "", link_address: address)
else
{:error, _} ->
conn
Expand Down Expand Up @@ -79,27 +79,24 @@ defmodule ArchEthicWeb.FaucetController do
end

defp create_transaction(transaction_index, curve, recipient_address) do
tx =
Transaction.new(
:transfer,
%TransactionData{
ledger: %Ledger{
uco: %UCOLedger{
transfers: [
%UCOLedger.Transfer{
to: recipient_address,
amount: 10_000_000_000
}
]
}
Transaction.new(
:transfer,
%TransactionData{
ledger: %Ledger{
uco: %UCOLedger{
transfers: [
%UCOLedger.Transfer{
to: recipient_address,
amount: 10_000_000_000
}
]
}
},
@pool_seed,
transaction_index,
curve
)

:ok = ArchEthic.send_new_transaction(tx)
{:ok, tx.address}
}
},
@pool_seed,
transaction_index,
curve
)
|> ArchEthic.send_new_transaction()
end
end

0 comments on commit 86ab868

Please sign in to comment.