TalismanSociety / talisman

Multi-Chain Made Easy with Talisman Wallet. An ultra-secure Ethereum and Polkadot wallet for both beginners and pros.
https://talisman.xyz/download
GNU General Public License v3.0
57 stars 37 forks source link

Fix typing in balances-substrate-equilibrium #539

Open chidg opened 1 year ago

chidg commented 1 year ago

Describe the bug A lack of typing on one variable in SubEquilibriumModule allowed a major bug to occur The tokenBalances variable here is untyped, which means the value returned when this object is accessed by key here can be undefined, but it is typed as any.

For engineering: Test Please write a couple of unit test that cover the cases of balance queries containing defined and undefined free values.

0xKheops commented 1 year ago

@alecdwm can this issue be closed ?

alecdwm commented 1 year ago

Not yet - maybe when CAPI drops?

alecdwm commented 2 months ago

Thanks to Papi we now have Partial<T> instead of any for decoded data: https://github.com/TalismanSociety/talisman/blob/cfcd47f8b5ee14a0b1fe0413698d6a43b9277e5b/packages/balances/src/modules/SubstrateEquilibriumModule.ts#L121-L137 https://github.com/TalismanSociety/talisman/blob/cfcd47f8b5ee14a0b1fe0413698d6a43b9277e5b/packages/balances/src/modules/SubstrateEquilibriumModule.ts#L343-L361

In the future we can also investigate some papi-idiomatic ways to validate these types against the chain metadata