hexresearch / hschain-utxo

UTXO-based contracts for hschain
0 stars 0 forks source link

We need clearer separation of concerns in UTXO transaction building #65

Open thesz opened 4 years ago

thesz commented 4 years ago

I would like to ask to implement code that allows me or someone else to create transactions (not scripts for boxes, but complete transactions).

We probably need as input current height, current set of UTXO and user task-specific state.

At the output we should have optional result, which may or may not be single transaction, set of transactions or anything user wants.

The type of function can be something like this:

runTransactionCreation :: Height -> Set Box -> userState -> TxCreationM userState a -> Maybe a

TxCreationM is a monad, with functions to obtain height, obtain or set set of UTXO and obtain or set user's state.

As a side note, the interface to create boxes' scripts also should include monadic interface. The pattern "bububa" =: gekoka zuza $ \bububa -> "zhuzhumba" =: mamamuna askid $ \zhuzhumba -> ... calls for monadic code structure. One of side effect is that there will be less string constants as we can use automatic name generation.

anton-k commented 4 years ago

It can be useful to implement quasi-quoter for scrtipts. Scripts rely on Haskell syntax. And we already have functions from and to haskell expressions. This way we can write scripts right in the code.