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

Condense Read and Validation modules in cardano-cli #4516

Merged
merged 6 commits into from
Oct 31, 2022

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Oct 9, 2022

Two things occur before constructing a tx. You must first read the parts you need and then validate that they can indeed be used in a particular era. We condense these into two module in the cli, with the eventual aim of moving them to cardano-api.

@Jimbo4350 Jimbo4350 force-pushed the jordan/separate-reading-and-validation branch 4 times, most recently from 44bee30 to 48f3600 Compare October 10, 2022 09:43
@Jimbo4350 Jimbo4350 force-pushed the jordan/separate-reading-and-validation branch from 48f3600 to c9585e4 Compare October 17, 2022 14:03
@Jimbo4350 Jimbo4350 marked this pull request as ready for review October 17, 2022 14:10
reading all of the necessary things for transaction construction
with disallowing features that are not possible in a particular era.
…lidate

throughout cardano-cli
Delete Cardano.CLI.Shelley.Script
@Jimbo4350 Jimbo4350 force-pushed the jordan/separate-reading-and-validation branch from c9585e4 to cd8b9af Compare October 26, 2022 11:20
import Cardano.Api
import Cardano.Api.Shelley

--TODO: do this nicely via the API too:
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what this TODO means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's actually a comment from Duncan. I think he wanted to expose the CBOR stuff from ledger in a nicer way.

Text.pack $ "Invalid JSON format in file: " <> show fp <>
"\nJSON parse error: " <> jsonErr
renderMetadataError (MetadataErrorConversionError fp metadataErr) =
Text.pack $ "Error reading metadata at: " <> show fp <>
Copy link
Contributor

@newhoggy newhoggy Oct 26, 2022

Choose a reason for hiding this comment

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

Sometimes we say "in file: FilePath" and sometimes we say "at: FilePath".

Is there something different going on? Or should we use the same language in all cases?

Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Oct 30, 2022

Choose a reason for hiding this comment

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

Nope just an inconsistency. I wouldn't fix that in this PR however. Open an issue if you think its worth fixing and we can get to it.

SimpleScriptLanguage _v ->
-- TODO: We likely need another datatype eg data ReferenceScriptWitness lang
-- in order to make this branch unrepresentable.
error "readScriptWitness: Should not be possible to specify a simple script"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

displayError sDataRangeErr
renderScriptDataError (ScriptDataErrorMetadataDecode fp decoderErr) =
Text.pack $ "Error decoding CBOR metadata at: " <> show fp <>
" Error: " <> show decoderErr
Copy link
Contributor

Choose a reason for hiding this comment

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

Language "in file" vs "at"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above

renderCddlError :: CddlError -> Text
renderCddlError (CddlErrorTextEnv textEnvErr cddlErr) =
"Failed to decode neither the cli's serialisation format nor the ledger's \
\CDDL serialisation format. TextEnvelope error: " <> Text.pack (displayError textEnvErr) <> "\n" <>
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer to not use multiline strings. Prefer using <>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah fair enough. We should purge the use of \. Can you open an issue for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@newhoggy newhoggy requested review from newhoggy and removed request for denisshevchenko October 31, 2022 11:18
@Jimbo4350
Copy link
Contributor Author

bors r+

1 similar comment
@Jimbo4350
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 31, 2022
4516: Condense Read and Validation modules in cardano-cli r=Jimbo4350 a=Jimbo4350

 Two things occur before constructing a tx. You must first read the parts you need and then validate that they can indeed be used in a particular era. We condense these into two module in the cli, with the eventual aim of moving them to cardano-api.


Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 31, 2022

Timed out.

@Jimbo4350 Jimbo4350 merged commit 99fdaf9 into master Oct 31, 2022
@iohk-bors iohk-bors bot deleted the jordan/separate-reading-and-validation branch October 31, 2022 15:56
-> Either TxProtocolParametersValidationError (BuildTxWith BuildTx (Maybe ProtocolParameters))
validateProtocolParameters _ Nothing = return (BuildTxWith Nothing)
validateProtocolParameters era (Just pparams) =
case scriptDataSupportedInEra era of
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason we case match on scriptDataSupportedInEra in validateProtocolParameters?

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.

2 participants