Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

generic asset 'free' balance #187

Open
jordy25519 opened this issue Mar 24, 2021 · 0 comments
Open

generic asset 'free' balance #187

jordy25519 opened this issue Mar 24, 2021 · 0 comments
Labels
enhancement New feature or request generic-asset for the generic asset module

Comments

@jordy25519
Copy link
Contributor

jordy25519 commented Mar 24, 2021

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 jordy25519 added enhancement New feature or request generic-asset for the generic asset module labels Mar 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request generic-asset for the generic asset module
Projects
None yet
Development

No branches or pull requests

1 participant