coblox / nectar

GNU General Public License v3.0
0 stars 1 forks source link

Simplify swap execution #98

Closed luckysori closed 4 years ago

luckysori commented 4 years ago

Separates hbit_herc20 into hbit_herc20_alice and hbit_herc20_bob (same for herc20_hbit).

The value of having a single function for both parties (less code to maintain) was outweighed by the difficulty of modelling executing an action and watching for the event produced by the execution of an action through the same function/trait. These new functions can differentiate between acting and watching, which makes them easier to understand and makes it easier for us to handle edge cases e.g. not having to wait for the other party to refund if we have aborted the swap execution.

I've tried to separate out things that could be upstreamed to COMIT lib into the module swap/comit. Interestingly, the function try_do_it_once stays within Nectar. The idea is that instead of using this function directly within the swap execution functions, implementations of {hbit, herc20}::ExecuteACTION traits in Nectar use it to ensure that swap execution is idempotent and that performing an action for the first time fails if Beta has expired. Other applications may end up needing similar logic, but the previous model was too complex and abusing traits.

D4nte commented 4 years ago

The try_do_it_once problematic is being addressed with one of the upcoming projects in cnd.

luckysori commented 4 years ago

@thomaseizinger One last review request so that you can see how I've implemented your suggestions.