plug-blockchain
plug-blockchain copied to clipboard
generic asset 'free' balance
Due to historic reasons the notion of 'free balance' in GA is a misnomer for the staking currency. We should alter this API / naming to ensure it is fool-proof
Background
expectation: "free balance": the freely spendable balance of an account reality: "free balance": the maybe spendable balance, need to check locks also
This is extremely misleading for dapps which have to be aware of this difference and internal modules when dealing with the staked currency must be aware of this also.
The currency locks API is made especially for staking, so this misnomer is only true for the staked asset. No other asset can have locks, so the 'free balance' really is the freely spendable balance.
Goals
Make the generic asset balance API clear and fool-proof Maintain backwards compatibility with the current API
Proposal
internal module API changes: free_balance
-
StakingAssetCurrency
andMultiCurrency
when asset is the staking asset must return the truely free balance (free balance - locked amount) -
cennznet/api.js Provide a new freeBalance rpc which will always return the truely free balance e.g.:
api.rpc.genericAsset.freeBalance
and encourage dapps to swtich. Maybe place warnings in cennznet/api.js code against usingapi.query.genericAsset.freeBalance
directly