Commit Graph
3 Commits
Author SHA1 Message Date
Jarvis Carroll 1cd3c2c042 coerce contract call results back to erlang, and clean up error accumulation (#6)
* Coerce in both directions

This is what I have been using in the voting app, via decode_bytearray.
Some smaller fixes are included too, such as exposing the `state` type
of a contract, and wrapping/unwrapping the `{tuple, {...}}` wrapper
produced by aeser.

Add Contract.state to the AACI typedefs

dry_run_result and tx_result

Coerce now has the ability to convert BACK from the format aebytecode
understands, which allows dry_run_result and tx_result to decode the
cb_... stuff and turn it into the kinds of erlang object that could be
passed right back into vanillae, for example. More than anything,
though, these functions just give you the data in the form that you want
it for pattern matching and getting actual work done.

expose decode_bytearray instead of tx_result

wrap/unwrap tuple atom correctly

* better coerce error accumulation

Now coerce errors all have the same format: [{error(), [path_steps()]}]
2023-09-03 11:07:07 +09:00
Spivee 80e80f9f9e Complex AACI type coercion (#3)
* build complex and indirected types into AACI

* break up coerce and coerce_step

coerce_step handles the looping and accumulation logic, whereas coerce
just handles one term, and returns {ok, _} or {error, _}. This way
coerce can become recursive, and even without recursion becomes easier
to read, due to fewer nested tuples.

Pretty insignificant change, but it'll be nice to have something to diff
off of more cleanly.

* coerce some more types

Still haven't covered lists or tuples, but these were enough to cover a
real contract that I want to test properly, once I have a node to test
on.

* process types from all contracts in ACI

This includes the contract itself, which is added as an alias for
`contract`. This way the ACI can describe and use contract interfaces,
and `ct_*` contracts can be passed into vanillae.

* coerce lists and tuples
2023-05-09 20:11:31 +09:00
Spivee e8c0242d19 Fix handle_down error message (#2)
* Fix handle_down error message

It was printing a tuple with `~s`, and also tried to pretty print a fat
call stack more than a hundred columns into the first line, which put
together made for some confusing exception-during-error-handling
messages in the erlang console.

* Switch to unicode formatting in handle_down
2023-05-01 13:37:53 +09:00