JoinSEEDS / seeds_light_wallet

http://www.joinseeds.earth/
MIT License
42 stars 22 forks source link

Rationalize handling of token decimal precision #1932

Open chuck-h opened 2 years ago

chuck-h commented 2 years ago

Is your feature request related to a problem? Please describe. This FR was inspired by being unable to send a token that was displayed in LW. The failure was caused by an incorrect decimal precision (defaulted to 4) in the TokenModel. I suggest that when generating a blockchain transaction (e.g. the send transfer) the precision should always be based on the contract itself rather than metadata provided by the app. Nonetheless the app should have control over the precision displayed at various screens in LW, and the preferred display precision may not equal the contract precision. Finally, while looking thru the code it appears that a few different algorithms are used to set display precision in different screens. At some point there may be benefit to refactoring display precision in a coherent way.

Describe the solution you'd like

  1. Ensure that correct precision is used when generating blockchain transactions (e.g. send).
  2. (Lower priority) Document a display precision policy and implement it.

Additional context A working fix to use contract precision for send transactions is at https://github.com/JoinSEEDS/seeds_light_wallet/commit/71f064fb1b9db2258a750e2f05b24fa626aed969 for receive QR generator at https://github.com/JoinSEEDS/seeds_light_wallet/commit/6d4dbaab2671ac280e8cd7f2cb46653718dee242