Open JoshOrndorff opened 4 years ago
I recently had a similar issue with Perbill
and hacked it into the Apps UI in this PR. We should talk to Jaco about improving UI input. (AFAIK it's on his list of things that need fixing in the UI, but it seems hard to find the time.)
Meanwhile we have solved this in our explorer. Would that be suitable to move upstream? https://github.com/encointer/explorer/blob/7541c77649252800761fb9a067b58b05b606c085/src/utils.js#L16-L38
Will not work with perbill out of the box because it assumes power of 2
Moreover, it converts the fixpoint to a float which is not the same as really supporting fixpoint in js
Would that be suitable to move upstream?
That's up to @jacogr . It would be a PR against https://github.com/polkadot-js/apps
The API doesn't know about I16F16
(it is not one of the types in the API), hence the UI doesn't know anything about I16F16
, hence it doesn't allow input since it cannot be encoded at all.
@jacogr I understand why its not possible now, but we're suggesting the following:
I16F16
as i32
and other types likewiseI16F16
(this is suboptimal because its a lossy function. But its better than nothing)I am not saying it is not possible - I am saying the API is not even aware of this type. So, trying to build UI support is not going to work since the API cannot even encode/decode it.And the UI will never have "custome encoding" that is not in the API types, that is a dead-end.
I don't have "all Rust types that may ever exist and be used someday in the API types", I have anything that is actually used by Substrate master and Polkadot. Since this type is NOT used there in any of the base modules, it never came up.
Having said that, there are a number of types NOT used in Substrate master/Polkadot that does have support ... it was implemented by people requiring it. (BTreeMap/BTreeSet comes to mind - that was available way before Substrate master actually used it since it was used by other parties in their clients)
So, if anybody wants it - then please log it at the correct place - even better, make a PR for it that implements SCALE for this type in the API types. (I don't take "API requests" in random repos since I can't track it, so it just drops off)
Okay, I believe I understand where this needs to be logged and have logged it at https://github.com/polkadot-js/api/issues/2488
The Fixed Point recipe uses substrate-fixed's
I16F16
signed fixed point type. The example works according to test cases, but users ca,not test it through the Apps UI because we don't know how to submit that data type. Apps does not like the input value even when 32 bits are supplied.