-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Metadata in pallet-assets cannot be accessed by other pallet #9877
Comments
do you only need a read access ? |
Yes, read access is enough, it seems like
|
Now we define the decimal with hardcode in runtime to solve the problem, but this is error-prone. |
@MrPai in what way are you using the decimal information in the runtime? In general this sounds really bad because the runtime should never be doing floating point logic. The decimal, and all of the metadata should be used exclusively for front-end experiences outside of the blockchain. |
Hi, @shawntabrizi We have not done any floating-point logic on-chain. we used As you know, USDT may have 6 decimal while KSM has 12, and DOT has 10.
when oracle feed price to on-chain, the
IMPORTANT This is the reason why we need the decimal on-chain. Can you help solve this requirement, we just change from |
I have opened a simple PR to help you here, but in general, hard-coding things might not be such a bad idea. For example, how in general can you determine which asset corresponds to KSM, DOT, and USDT? At that level, you must program that Asset ID X maps to some specific asset you care about, and in that case, it probably makes sense to hardcode all of the metadata about that asset in the interface. But anyway, hopefully that PR will solve things the way you envision. |
Yes, the PR helps a lot, we are thinking about dynamically specifying and associate assets in our own pallet. and it will be easy for us to maintain decimal only in one place, |
@shawntabrizi just one question here, I just checked that your pr is not in polkadot-v0.9.11, will we have chance to see it enters polkadot-v0.9.12 OR polkadot-v1.0.0? we kind of need it |
The PR will make it into the next release that branches off master, so 0.9.12 seems likely |
Hi, I have a question about pallet-assets.
we are developing a DeFi project that need to use asset's decimal when calculating, however when we import pallet-assets in our project, the storage Metadata can not be accessed by other pallets.
I wonder can we make it public or abstract a trait, so the other pallet can access its decimal?
The text was updated successfully, but these errors were encountered: