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

Add dev nockma encode command #3135

Merged
merged 4 commits into from
Nov 6, 2024
Merged

Add dev nockma encode command #3135

merged 4 commits into from
Nov 6, 2024

Conversation

janmasrovira
Copy link
Collaborator

@janmasrovira janmasrovira commented Oct 30, 2024

  • New command juvix dev nockma encode --help
Usage: juvix dev nockma encode --to ENCODING --from ENCODING

  Encode and decode nockma terms

Available options:
  --to ENCODING            Choose the source encoding.
                           • base64: Jam and Base 64 encoding
                           • bytes: Jam encoding
                           • debug: Nockma code with annotations
                           • text: Nockma code without annotations
  --from ENCODING          Choose the target encoding.
                           • base64: Jam and Base 64 encoding
                           • bytes: Jam encoding
                           • debug: Nockma code with annotations
                           • text: Nockma code without annotations

@janmasrovira janmasrovira self-assigned this Oct 30, 2024
@janmasrovira janmasrovira marked this pull request as ready for review November 5, 2024 13:51
@@ -60,5 +55,5 @@ runNockma prog inputs = do
res :: Response <- anomaRpc runNockGrpcUrl (Aeson.toJSON msg) >>= fromJSON
logVerbose (mkAnsiText ("Response Payload:\n" <> Aeson.jsonEncodeToPrettyText res))
case res of
ResponseProof x -> decodeJam64 x
ResponseProof x -> decodeCue64 x
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: decodeCue64 is correct here because the value of the 'proof' field is jammed - so we cue it to see the nock term?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's just a matter of renaming decodeJam64 -> decodeCue64. They are the same function. I could leave it to decodeJam64 if that's more intuitive. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed decodeJam64 in af0dd16 because it was a duplicate of decodeCue64

Copy link
Collaborator

@paulcadman paulcadman Nov 5, 2024

Choose a reason for hiding this comment

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

In my dictionary 'jam = nock-encode', 'cue = nock-decode' - and then we overload 'encode / decode' here because we also have base64 encode/decode 😄

So decodeCue64 first base64-decodes the value of proof in response to a bytestring and then this is nock-decoded (i.e cued) to a nock term.

@janmasrovira janmasrovira merged commit bf09ee2 into main Nov 6, 2024
4 checks passed
@janmasrovira janmasrovira deleted the cli-nockma-encode branch November 6, 2024 09:01
@paulcadman paulcadman added this to the 0.6.7 milestone Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants