use-ink / contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
https://contracts-ui.substrate.io/
GNU General Public License v3.0
61 stars 44 forks source link

`Balance` is always treated like network currency #472

Open wottpal opened 1 year ago

wottpal commented 1 year ago

Hey, when working with fungible token contracts (i.e. PSP-22) we've noticed that contracts-ui is statically assuming that values with the Balance type are always the native chain currency with it's decimals & token identifier.

In the PSP-22 interface, Balance is just an alias type for u128 and can have any decimal & any token identifier. And as the input field is already denominating with the networks decimals (e.g. 12) it's super confusing that it assumes the same for other tokens Balances.

Maybe adding a "Network Currency" switch that switches between networks decimals & token symbol between just the plain u128 value w/o any decimals applied would help here?

Screenshot 2023-05-04 at 17 14 33
andropixels commented 1 year ago

i guess thats not a bug you can enable transfer or other psp22 functions in your contract by importing your contract as dependancy

peetzweg commented 3 months ago

Agree this can be confusing. It's blindly stating the chains token symbol for any Balance type inputs. That's probably often true but not always, therefore this ticket.

Adding some custom logic for detecting an interaction with a psp22 contract could help here, however imho the actual benefits are a bit limited. I would almost rather opt for not showing any Symbol on a Balance input. 🤔

wottpal commented 3 months ago

IMO the most simple fix would be a little toggle in the input field that either denominates the value as a balance (12 decimals) or doesn't denominate at all. Just removing the symbol still leaves up the question: Is this value denominated or now? And if yes, how many decimals?