Browse Source

storage-node: rename freeBalance to availableBalance and update function doc

Mokhtar Naamani 4 years ago
parent
commit
42eb0d191e

+ 4 - 4
storage-node/packages/runtime-api/balances.js

@@ -36,10 +36,10 @@ class BalancesApi {
   }
 
   /*
-   * Return true/false if the account has the minimum balance given.
+   * Return true/false if the account has a minimum spendable balance.
    */
   async hasMinimumBalanceOf(accountId, min) {
-    const balance = await this.freeBalance(accountId)
+    const balance = await this.availableBalance(accountId)
     if (typeof min === 'number') {
       return balance.cmpn(min) >= 0
     }
@@ -47,9 +47,9 @@ class BalancesApi {
   }
 
   /*
-   * Return the account's current free balance.
+   * Return the account's available balance which can be spent.
    */
-  async freeBalance(accountId) {
+  async availableBalance(accountId) {
     const decoded = this.base.identities.keyring.decodeAddress(accountId, true)
     return (await this.base.api.derive.balances.all(decoded)).availableBalance
   }

+ 1 - 1
storage-node/packages/runtime-api/test/balances.js

@@ -31,7 +31,7 @@ describe('Balances', () => {
   })
 
   it('returns free balance for an account', async () => {
-    const balance = await api.balances.freeBalance(key.address)
+    const balance = await api.balances.availableBalance(key.address)
     // Should be exactly zero
     expect(balance.cmpn(0)).to.equal(0)
   })