Search in sources :

Example 1 with NumericalValue

use of org.aion.api.server.types.NumericalValue in project aion by aionnetwork.

the class ApiWeb3Aion method syncInfoToJson.

private JSONObject syncInfoToJson(SyncInfo syncInfo) {
    JSONObject syncInfoAsJson = new JSONObject();
    syncInfoAsJson.put("startingBlock", new NumericalValue(syncInfo.chainStartingBlkNumber).toHexString());
    syncInfoAsJson.put("currentBlock", new NumericalValue(syncInfo.chainBestBlkNumber).toHexString());
    syncInfoAsJson.put("highestBlock", new NumericalValue(syncInfo.networkBestBlkNumber).toHexString());
    return syncInfoAsJson;
}
Also used : JSONObject(org.json.JSONObject) NumericalValue(org.aion.api.server.types.NumericalValue)

Example 2 with NumericalValue

use of org.aion.api.server.types.NumericalValue in project aion by aionnetwork.

the class ApiWeb3Aion method eth_estimateGas.

public RpcMsg eth_estimateGas(Object _params) {
    JSONObject _tx;
    if (_params instanceof JSONArray) {
        _tx = ((JSONArray) _params).getJSONObject(0);
    } else if (_params instanceof JSONObject) {
        _tx = ((JSONObject) _params).getJSONObject("transaction");
    } else {
        return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid parameters");
    }
    ArgTxCall txParams = ArgTxCall.fromJSONforCall(_tx, getRecommendedNrgPrice());
    NumericalValue estimate = new NumericalValue(estimateNrg(txParams));
    return new RpcMsg(estimate.toHexString());
}
Also used : ArgTxCall(org.aion.api.server.types.ArgTxCall) JSONObject(org.json.JSONObject) NumericalValue(org.aion.api.server.types.NumericalValue) JSONArray(org.json.JSONArray)

Aggregations

NumericalValue (org.aion.api.server.types.NumericalValue)2 JSONObject (org.json.JSONObject)2 ArgTxCall (org.aion.api.server.types.ArgTxCall)1 JSONArray (org.json.JSONArray)1