Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding undocumented API Get_Account_Balance #32

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/*
dist
coverage
.vscode
25 changes: 25 additions & 0 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 @@ -497,6 +500,28 @@ Returns the quantity of 'assetId' currently in circulation.
1) In treasury accounts;
2) In sell orders;
3) In accountId zero (burn address).

### 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.

### getAccountAssetQuantity
* Prototype:
`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.
</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
Loading
Loading