Skip to content

Commit

Permalink
un-whitelist get_calls/1
Browse files Browse the repository at this point in the history
  • Loading branch information
bchamagne authored and Neylix committed Jan 25, 2023
1 parent 3165208 commit 16a5f39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 1 addition & 9 deletions lib/archethic/contracts/interpreter/action.ex
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,7 @@ defmodule Archethic.Contracts.ActionInterpreter do
{node, {:ok, %{context | scope: {:function, function, parent_scope}}}}
end

# Whitelist the get_calls/1
defp prewalk(
node = {{:atom, "get_calls"}, _, [_]},
acc = {:ok, %{scope: {:actions, _}}}
) do
{node, acc}
end

# Whitelist the get_calls/0
# Whitelist the get_calls/0 (this will be expanded to a get_calls(contract.address) in postwalk)
defp prewalk(
node = {{:atom, "get_calls"}, _, []},
acc = {:ok, %{scope: {:actions, _}}}
Expand Down
8 changes: 6 additions & 2 deletions test/archethic/contracts/interpreter/action_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,18 @@ defmodule Archethic.Contracts.ActionInterpreterTest do
assert %Transaction{data: %TransactionData{content: "1"}} =
~s"""
actions triggered_by: transaction do
transactions = get_calls("64F05F5236088FC64D1BB19BD13BC548F1C49A42432AF02AD9024D8A2990B2B4")
transactions = get_calls()
set_content size(transactions)
end
"""
|> Interpreter.sanitize_code()
|> elem(1)
|> ActionInterpreter.parse()
|> elem(2)
|> ActionInterpreter.execute()
|> ActionInterpreter.execute(%{
"contract" => %{
"address" => "64F05F5236088FC64D1BB19BD13BC548F1C49A42432AF02AD9024D8A2990B2B4"
}
})
end
end

0 comments on commit 16a5f39

Please sign in to comment.