Skip to content

Commit

Permalink
Improving documentation Get_Account_Balance
Browse files Browse the repository at this point in the history
  • Loading branch information
deleterium committed Feb 9, 2024
1 parent ce5b0ab commit 59b42e7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
17 changes: 13 additions & 4 deletions docs/1.5-Built-in-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ void distributeToHoldersFx(
);
long getAssetHoldersCount(long minimumQuantity, long assetId);
long getAssetCirculating(long assetId);
long getAccountBalance(long accountId);
fixed getAccountBalanceFx(long accountId);
long getAccountQuantity(long accountId, long assetId);

// Special instructions
long mdv(long m1, long m2, long div);
Expand Down Expand Up @@ -498,21 +501,27 @@ Returns the quantity of 'assetId' currently in circulation.
2) In sell orders;
3) In accountId zero (burn address).

### getAccountBalance
### getAccountBalance, getAccountBalanceFx
* Prototype:
`long getAccountBalance(long accountId);`
* Fixed version prototype:
`fixed getAccountBalanceFx(long accountId);`
* Description:
Returns the SIGNA balance owned by 'accountId'.
If there is no accountId, returns zero.
When used to get the balances from smart contracts, it will return the balance on last block, not the one after the execution on current block.
Same applies to get the own contract balance, which is the same as signum API Get_Previous_Balance and most of times not useful.
* Note that some parts of the balance are also considered:
1) Commitment;
1) Commitment.

### getAccountAssetQuantity
* Prototype:
`long getAccountAssetQuantity(long accountId, long assetId);`
`long getAccountQuantity(long accountId, long assetId);`
* Description:
Returns the quantity of 'assetId' owned by 'accountId'.
When used to get the balances from smart contracts, it will return the balance on last block, not the one after the execution on current block.
* Note that some quantities are also considered:
1) In sell orders;
1) In sell orders.
</details>
<details>
<summary>
Expand Down
30 changes: 30 additions & 0 deletions docs/2-API-Pseudo-Code.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,21 @@ long Get_Asset_Circulating(void) {
treasury account.
*/
}
long Get_Account_Balance(void) {
// Assembly name: Get_Account_Balance
accountId = B1;
assetId = B2;
if(assetId == 0L){
balance = Blockchain.getAccountBalance(accountId);
// if there is no account, then return zero
return balance
}
quantity = Blockchain.getAccountQuatity(accountId, assetId);
// If there is no account, or if account does not have the given asset, returns 0
return quantity
}
```
</details>
<details>
Expand Down Expand Up @@ -821,6 +836,21 @@ fixed F_Get_Activation_Fee(void) {
}
return 0;
}

fixed F_Get_Account_Balance(void) {
// Assembly name: Get_Account_Balance
accountId = B1;
assetId = B2;

if(assetId == 0L){
balance = Blockchain.getAccountBalance(accountId);
// if there is no account, then return zero
return balance
}
quantity = Blockchain.getAccountQuatity(accountId, assetId);
// If there is no account, or if account does not have the given asset, returns 0
return quantity
}
```
</details>
Expand Down

0 comments on commit 59b42e7

Please sign in to comment.