Search in sources :

Example 6 with CompiledContr

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

the class ApiWeb3Aion method eth_compileSolidity.

public RpcMsg eth_compileSolidity(Object _params) {
    String _contract;
    if (_params instanceof JSONArray) {
        _contract = ((JSONArray) _params).get(0) + "";
    } else if (_params instanceof JSONObject) {
        _contract = ((JSONObject) _params).get("contract") + "";
    } else {
        return new RpcMsg(null, RpcError.INVALID_PARAMS, "Invalid parameters");
    }
    @SuppressWarnings("unchecked") Map<String, CompiledContr> compiled = contract_compileSolidity(_contract);
    JSONObject obj = new JSONObject();
    for (String key : compiled.keySet()) {
        CompiledContr cc = compiled.get(key);
        obj.put(key, cc.toJSON());
    }
    return new RpcMsg(obj);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Hex.toHexString(org.aion.util.conversions.Hex.toHexString) CompiledContr(org.aion.api.server.types.CompiledContr)

Aggregations

CompiledContr (org.aion.api.server.types.CompiledContr)6 JSONArray (org.json.JSONArray)3 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 CompiContrInfo (org.aion.api.server.types.CompiContrInfo)2 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 ByteBuffer (java.nio.ByteBuffer)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1