Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI helper functions for constructing transactions #2335

Merged
merged 5 commits into from
Jul 6, 2021

Conversation

JaredCorduan
Copy link
Contributor

@JaredCorduan JaredCorduan commented Jun 15, 2021

This PR adds four new functions to be used by the cardano-cli for constructing transactions.

Three of the new functions live in a class, CLIHelpers, and are supported in all eras: evaluateTransactionBalance, evaluateTransactionBalance, evaluateTransactionFee. The first two contain default implementations, the class just needs to know the proper minfee and consumed function to use. Finally, there is an Alonzo-specific function evaluateTransactionExecutionUnits which computes the minimal execution budget for the redeemers in an Alonzo transaction.

Additionally, I changed some of the surrounding code (changes separated by commit):

  • the Languages type is bounded and inflexible
  • txInfo now returns a monadic value, as given by EpochInfo m when converting slots to POSIX time for plutus.
  • the totalDeposits function that has been used since Shelley for determining the deposits needed by a given transaction now takes a predicate instead of a mapping of stake pools. Instead of providing the map, you can now use (Map.notMember pools).
  • totExUnits is now a standalone function instead of a HasField instance.

@JaredCorduan JaredCorduan marked this pull request as ready for review July 2, 2021 20:26
@JaredCorduan JaredCorduan changed the title WIP alonzo CLI helper functions CLI helper functions for constructing transactions Jul 2, 2021
@JaredCorduan JaredCorduan requested a review from nc6 July 2, 2021 20:42
@@ -213,6 +225,14 @@ instance
instance (CC.Crypto c) => UsesTxOut (AlonzoEra c) where
makeTxOut _proxy addr val = TxOut addr val Shelley.SNothing

instance CC.Crypto c => API.CLIHelpers (AlonzoEra c) where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I would slightly prefer CLI rather than CLIHelpers, for consistency with the other things (e.g. Wallet rather than WalletHelpers). And we should paint the bikeshed blue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love blue! (what I love even more than blue is when I don't have to pick the color.... :) ) Happy to change the names, I think "helpers" is superfluous indeed.


-- | Evaluate the execution budgets needed for all the redeemers in
-- a given transaction. If a redeemer is invalid, a failure is returned instead.
evaluateTransactionExecutionUnits ::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the intention that the Tx already has some ExUnits in the transaction redeemers, which are then ignored and we pass back appropriately sized ExUnits later (and merge them into this transaction?). In general I find the use of this function a little confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! I should explain that in the haddocks!!

{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

module Shelley.Spec.Ledger.API.CLI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these just for the CLI, or can we merge into Wallet, seeing as these are needed for some Wallet functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. If you think these would be better placed in Wallet, let me know!

Three are in a new class in the API module,
one is Alonzo specific.
@JaredCorduan JaredCorduan merged commit c23f1cb into master Jul 6, 2021
@iohk-bors iohk-bors bot deleted the jc/alonzo-cli-helpers branch July 6, 2021 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants