I created https://github.com/anoma/anoma/pull/500 to fix issues with type mistmatch between Nock encoded lists and their Elixir counterparts. There's some confusion about the fix so I'm raising this issue to highlight the supposed bug.
In the REPL, let's parse a noun with 0 (i.e Nock encoded []) in the proofs and delta fields of a transaction:
iex(paul@Pauls-MacBook-Pro)8> "[0 0 0 0 0 0 0]" |> Noun.Format.parse_always |> Transaction.from_noun
** (Protocol.UndefinedError) protocol Enumerable not implemented for 0 of type Integer. This protocol is implemented for the following type(s): Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, Kino.Control, Kino.Input, Kino.JS.Live, List, Map, MapSet, Range, Stream, Table.Mapper, Table.Zipper
(elixir 1.16.2) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.16.2) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.16.2) lib/enum.ex:4396: Enum.map/2
(anoma 0.15.0) lib/anoma/resource/transaction.ex:56: Anoma.Resource.Transaction.from_noun/1
iex:8: (file)
The error is due to the fact that we're treating the 0 as a list in the from_noun code:
I created https://github.com/anoma/anoma/pull/500 to fix issues with type mistmatch between Nock encoded lists and their Elixir counterparts. There's some confusion about the fix so I'm raising this issue to highlight the supposed bug.
In the REPL, let's parse a noun with
0
(i.e Nock encoded[]
) in the proofs and delta fields of a transaction:The error is due to the fact that we're treating the
0
as a list in thefrom_noun
code:https://github.com/anoma/anoma/blob/base/lib/anoma/resource/transaction.ex#L55-L58
You can fix it by setting the proofs and transaction fields to Elixir lists:
This was the reason why I used the
list_nock_to_erlang
to convert the noun proof field into an elixir list before it's mapped over.