tweag / cooked-validators

MIT License
39 stars 11 forks source link

`Wallet` module makeover #254

Closed florentc closed 1 year ago

florentc commented 1 year ago

This applies a cleanup pass to the Wallet module including the following changes (see individual commits), mostly listed here to keep track of them for V2 changelog:

  1. Qualifies imported modules in a saner way. This module used to be messy in that regard. This follows a convention we aim to unify throughout the cooked codebase: Cardano for Cardano.*** modules, Pl for everything Ledger-y, and Pl1/Pl2 for everything that is explicitly from Plutus.V1 or Plutus.V2 (and cannot be changed to generic Ledger.***).
  2. Overhaul comments (adds them where they were missing + a little introduction heading paragraph). This ticks a box in the TODO list of #245
  3. Remove everything dealing with minAda since the real minAda amount per UTxO is not that trivial to determine. The information was therefore misleading. This also simplifies InitialDistribution. We do not issue a dedicated custom (unreliable) error anymore. We will stumble upon validation errors if we forget to provide enough lovelace per UTxO in our initial distributions.
  4. initialDistribution' loses its prime. There was no initialDistribution (no prime) anyway. Also the field accessor for InitialDistribution has a more conventional (and less misleading) name.
  5. Unused functions (both in the rest of the codebase and during actual usage of cooked during audits) have been removed: toPKHMap and valuesForWallet.
  6. There is a hack to retrieve private keys from Pl.MockPrivateKey because no constructor or field accessor is exposed to do so. Since we have decided not to rely on explicit export lists in cooked, part of that hack has been moved away from the top-level and the weird-to-export-everywhere please field accessor is gone. See issue #255: we need to make a PR to expose the info we need. We could also investigate using Solo from Data.Tuple in base instead of HACK if at some point we update our index state in cabal.project and require at least base 4.16