use of com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException in project starcoin-java by starcoinorg.
the class TokenContractRPCClient method getTreasurBalance.
/**
* 用于获取某个 token 在国库中的数量
*/
public BigInteger getTreasurBalance(String tokenTypeTag) throws JSONRPC2SessionException {
ContractCall call = new ContractCall();
call.setFunctionId(TreasuryBalanceTypeTag);
List<String> typeTags = new ArrayList<>();
typeTags.add(tokenTypeTag);
call.setTypeArgs(typeTags);
call.setArgs(new ArrayList<>());
List result = this.call(call);
if (result != null && result.size() > 0) {
String capInString = String.valueOf(result.get(0));
return new BigInteger(capInString);
} else {
throw new JSONRPC2SessionException("fetch token" + tokenTypeTag + " market cap failed");
}
}
use of com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException in project starcoin-java by starcoinorg.
the class StateRPCClientTest method testGetState.
@Ignore
public void testGetState() {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss");
System.out.println(format.format(new Date()));
stateRPCClient.getState("0x5c04bb88984f933151bf69504692074d");
long amount = stateRPCClient.getAddressAmount("0x5c04bb88984f933151bf69504692074d", "0x9350502a3af6c617e9a42fa9e306a385::BX_USDT::BX_USDT");
System.out.println("amount: " + amount);
amount = stateRPCClient.getAddressAmount("0x5c04bb88984f933151bf69504692074d", "0x00000000000000000000000000000001::STC::STC");
System.out.println("amount: " + amount);
TokenInfo tokenInfo = stateRPCClient.getTokenInfo("0x44366bba9bc9ed51bc8f564ecb18b12a", "0x44366bba9bc9ed51bc8f564ecb18b12a::DummyToken::BBB");
System.out.println(tokenInfo);
tokenInfo = stateRPCClient.getTokenInfo("0x1", "0x1::STC::STC");
System.out.println(tokenInfo);
} catch (JSONRPC2SessionException e) {
e.printStackTrace();
}
}
Aggregations