plug-blockchain icon indicating copy to clipboard operation
plug-blockchain copied to clipboard

generic asset 'free' balance

Open jordy25519 opened this issue 3 years ago • 0 comments

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

  1. StakingAssetCurrency and MultiCurrency when asset is the staking asset must return the truely free balance (free balance - locked amount)

  2. 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 using api.query.genericAsset.freeBalance directly

jordy25519 avatar Mar 24 '21 21:03 jordy25519