polkadot-js / apps

Basic Polkadot/Substrate UI for interacting with a Polkadot and Substrate node. This is the main user-facing application, allowing access to all features available on Substrate chains.
https://dotapps.io
Apache License 2.0
1.75k stars 1.54k forks source link

Display and edit of fixed point numbers #10900

Open blakebyrnes opened 1 month ago

blakebyrnes commented 1 month ago

It would be really helpful to be able to view fixed point numbers (and edit them) with the actual numbers they represent. Are you open to adding additional common substrate primitives to the ui?

piggydoughnut commented 1 week ago

Hey @blakebyrnes Could you please give more context?

Thanks

blakebyrnes commented 6 days ago

@piggydoughnut, FixedU128, FixedU64, etc represent decimal numbers using fixed points, but when you edit them in extrinsic creations (or view them in the storage), they show up as full u128 values. For instance, these are prices from the Argon Testnet (Storage -> priceIndex -> current())

{
  btcUsdPrice: 65,926,754,199,999,998,853,120
  argonUsdPrice: 1,000,000,000,000,000,000
  argonUsdTargetPrice: 1,002,545,194,941,447,002
  tick: 8,182
}

The BTC usd price is 65,926.754.... In an ideal world, the decimal place would be visible here. And while editing, you would be able to input a variable with optional decimal precision. Below is what fixed numbers show in the extrinsic ui. As you can see, if you're just hoping to enter a percentage, this can make the it very hard to know what to input.

image