ethui icon indicating copy to clipboard operation
ethui copied to clipboard

Add NumberView and HashView components

Open helenamartins81 opened this issue 1 year ago • 3 comments

Why:

  • Currently, it is not possible to convert numbers into different units (wei, gwei, eth) or different formats (decimal to hex) (Issue #695)

How:

  • Added the NumberView and HashView components to enable conversion between units in numbers, copy to clipboard functionality, and format switching between decimal and hex.
    gui/src/components/NumberView.tsx gui/src/components/HashView.tsx

Preview: image

helenamartins81 avatar Jul 04 '24 09:07 helenamartins81

Overall a nice effort, but I feel this somewhat misses the point.

we can't blindly wrap values in a NumberView and offer a couple of static conversions. Some values already come in wei, others come in gwei or eth. We need to be smart about the parameters, and how to convert between them (viem already has functions to deal with all this, as long as we know the decimals)

What I was expecting, was not a context menu, but a modal showing the different values the number can take, so I can copy to clipboard the one I'm interested in

naps62 avatar Jul 04 '24 14:07 naps62

Update:

Removed the menu and added a modal with all the conversions (hashes only display hex and decimal values). In NumbersView, adjusted the conversion process to consider the initial value unit.

Preview:

image

helenamartins81 avatar Jul 05 '24 14:07 helenamartins81

Update:

In NumbersView, moved the hexadecimal format to another popover. Now, it is possible to see and copy the conversion to hexadecimal for each unit. I also added more units and adjusted the conversion process using formatUnits from viem.

Preview:

image

helenamartins81 avatar Jul 12 '24 14:07 helenamartins81