From 9b4e8a3b999ab0825cc7d1943861a0f727bc5ef2 Mon Sep 17 00:00:00 2001 From: Awea Date: Mon, 21 Oct 2024 09:57:27 +0200 Subject: [PATCH] fix(rpc): handle nil value in preapply result --- lib/rpc.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rpc.ex b/lib/rpc.ex index 62c7145..4d819f9 100644 --- a/lib/rpc.ex +++ b/lib/rpc.ex @@ -239,7 +239,7 @@ defmodule Tezex.Rpc do defp do_preapply_operation(%Rpc{} = rpc, payload) do case post(rpc, "/blocks/head/helpers/preapply/operations", payload) do - {:ok, [%{"contents" => preapplied_operations}]} -> + {:ok, [%{"contents" => preapplied_operations}]} when is_list(preapplied_operations) -> applied? = Enum.all?( preapplied_operations, @@ -275,6 +275,9 @@ defmodule Tezex.Rpc do {:error, errors} end + {:ok, [%{"contents" => nil}]} -> + {:error, :nil_preapply} + {:ok, result} -> {:error, result}