Skip to content

Commit

Permalink
fix STC Treasurbalance (#53)
Browse files Browse the repository at this point in the history
* fix STC Treasurbalance

* update pom version
  • Loading branch information
nkysg authored Dec 15, 2023
1 parent af9713a commit a5e1e8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.starcoin</groupId>
<artifactId>sdk</artifactId>
<version>1.1.28</version>
<version>1.1.29</version>

<name>Starcoin Java SDK</name>
<description>Starcoin Java SDK</description>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/starcoin/api/TokenContractRPCClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class TokenContractRPCClient extends ContractRPCClient {
public static final String TreasuryBalanceTypeTag = "0x00000000000000000000000000000001::Treasury::balance";
public static final String TokenMarketCapTypeTag = "0x00000000000000000000000000000001::Token::market_cap";

public static final String AssociactionAddress = "0x0000000000000000000000000a550c18";

public TokenContractRPCClient(URL baseUrl) {
super(baseUrl);
}
Expand Down Expand Up @@ -105,7 +107,9 @@ public BigInteger getSTCMarketCap() throws JSONRPC2SessionException {
* 用于获取 STC 在国库中的数量
*/
public BigInteger getSTCTreasurBalance() throws JSONRPC2SessionException {
return this.getTreasuryBalance(STCTypeTag);
StateRPCClient stateRPCClient = new StateRPCClient(session.getURL());
BigInteger amount = stateRPCClient.getAddressAmountValue(AssociactionAddress, STCTypeTag);
return this.getTreasuryBalance(STCTypeTag).add(amount);
}

/**
Expand Down

0 comments on commit a5e1e8b

Please sign in to comment.