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

generic asset 'free' balance #187

@jordy25519

Description

@jordy25519

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgeneric-assetfor the generic asset module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions