-
Notifications
You must be signed in to change notification settings - Fork 11
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 custom names pretty printing for hashes #384
Conversation
I lean towards keeping it either. It does not hurt and bring an info that somebody who has not worked on a codebase will need in order to understand the outcome of a trace.
I believe it should be postponed.
It could be good indeed to have names highlighted. Now that I think about it, there could be a different highlight if it's a script or a pubkey, which would also kinda solve the first question. Something like
I'd say that would be nice to have but not mandatory. It practice, the only way I see that happening is by having a list of types as a type or something like that which would require type families.
I like the idea of having the 3 by default. And if in turn the user overrides it, well it's ok. |
This PR is ready for review. The first post has been edited accordingly. Decisions regarding the discussion items:
In addition:
|
This addresses #379
This PR introduces a quality of life feature to associate readable names to hashes in a new pretty-pretting option.
The option is grouped among others in the
pcOptHashes
field ofPrettyCookedOpts
. This field has the following subfields:pcOptHashLength
: this option already existed before, at the top level ofPrettyCookedOpts
, it sets how many characters of a hash to printpcOptHashNames
: This is the core of the new feature, it associates hashes to names. Use thehashNamesFromList
smart constructor. It takes a list of key/value pairs but the keys can be anything that has a hash: wallets, scripts, minting policies, datums, transaction ids, and pretty much all the associated types (might not be exhaustive). The associated new class,Hashable
, is defined inPretty.Cooked.Hashable
.pcOptHashVerbose
: By default, when a corresponding name is found for a hash, the hex representation is no longer printed. This flag forces it to be printed alongside the name just in case.(postponed)pcOptHashParseTokenNames
: Not yet implemented. This is intended to parse token names for a hex representation of a hash and if something is found inpcOptHashNames
, print it instead.Example:
TODO and discussion topics
Maybe stop displaying "pubkey" vs "script" as a prefix when a hash has been resolved to a name (I lean towards keeping it)#
and hexadecimal characters. Now names, in particular if they have spaces or are lowercased, can be hard to notice in the middle of the text. For exampleSpends from script foo (Reference Script at 28282838!0)
, orPays to pubkey Clint Eastwood
could becomePays to pubkey [Clint Eastwood]
orSpends from script [foo]
,Pays to pubkey #"Clint Eastwood"
, etc. (I'd keep it like it is for now)Investigate using existential types or something to avoid having to split the names into several sublists for each concrete type. (That would be nice to have)