Skip to content

Commit

Permalink
Refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
netboz committed Jan 25, 2023
1 parent 57f29b9 commit 2ee2886
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/archethic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ defmodule Archethic do
Assert the transaction holds a contract and then simulate its execution.
Return an error if the transaction holds no contract.
"""

@spec simulate_contract_execution(Transaction.t(), Transaction.t()) ::
%{valid: false, address: binary(), reason: binary()}
| %{valid: true, address: binary()}
def simulate_contract_execution(
prev_tx = %Transaction{data: %TransactionData{code: code}},
incoming_tx
Expand All @@ -312,7 +314,7 @@ defmodule Archethic do
) do
%{
valid: false,
address: prev_tx,
address: prev_tx.address,
reason: "Transaction doesn't hold any contract"
}
end
Expand Down
3 changes: 2 additions & 1 deletion lib/archethic/contracts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ defmodule Archethic.Contracts do
Simulate the execution of the contract hold in prev_tx with the inputs of next_tx, at a certain date
"""

@spec simulate_contract_execution(Transaction.t(), Transaction.t(), DateTime.t()) :: map()
@spec simulate_contract_execution(Transaction.t(), Transaction.t(), DateTime.t()) ::
%{valid: false, address: binary(), reason: binary()} | %{valid: true, address: binary()}
def simulate_contract_execution(
prev_tx = %Transaction{data: %TransactionData{code: code}},
next_tx = %Transaction{},
Expand Down
2 changes: 0 additions & 2 deletions lib/archethic_web/controllers/api/transaction_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ defmodule ArchethicWeb.API.TransactionController do
conn,
params = %{}
) do
IO.puts("\nValidating #{inspect(params)}")

case TransactionPayload.changeset(params) do
changeset = %{valid?: true} ->
tx =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ defmodule ArchethicWeb.API.TransactionControllerTest do

MockClient
|> stub(:send_message, fn
## These decoded addresses are matching the ones in the code above
_,
%GetTransaction{
address:
Expand Down

0 comments on commit 2ee2886

Please sign in to comment.