From 86ab868316216ef7c9efd8ac240755b8e6034f25 Mon Sep 17 00:00:00 2001 From: Samuel Date: Thu, 27 Jan 2022 12:06:43 +0100 Subject: [PATCH] Revert change for the faucet - fix by #204 --- .../controllers/faucet_controller.ex | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/lib/archethic_web/controllers/faucet_controller.ex b/lib/archethic_web/controllers/faucet_controller.ex index 647e12ee9..13c89ca09 100644 --- a/lib/archethic_web/controllers/faucet_controller.ex +++ b/lib/archethic_web/controllers/faucet_controller.ex @@ -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 @@ -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