Search in sources :

Example 1 with Contract

use of org.aion.solidity.CompilationResult.Contract in project aion by aionnetwork.

the class Api method processCompileRsp.

private Map<String, CompiledContr> processCompileRsp(Compiler.Result res, String source) {
    Map<String, CompiledContr> compiledContracts = new HashMap<String, CompiledContr>();
    if (res.isFailed()) {
        LOG.info("contract compile error: [{}]", res.errors);
        /*
             Enhance performance by separating the log threads and kernel TODO: Implement a
             queue for strings TODO: Put every LOG message onto the queue TODO: Use a thread
             service to process these message
            */
        CompiledContr ret = new CompiledContr();
        ret.error = res.errors;
        compiledContracts.put("compile-error", ret);
        return compiledContracts;
    }
    CompilationResult result = CompilationResult.parse(res.output);
    for (Entry<String, Contract> stringContractEntry : result.contracts.entrySet()) {
        CompiledContr ret = new CompiledContr();
        Contract Contract = stringContractEntry.getValue();
        ret.code = StringUtils.toJsonHex(Contract.bin);
        ret.info = new CompiContrInfo();
        ret.info.source = source;
        ret.info.language = "Solidity";
        ret.info.languageVersion = "0";
        ret.info.compilerVersion = result.version;
        ret.info.abiDefinition = Abi.fromJSON(Contract.abi, new ExternalCapabilities()).getEntries();
        compiledContracts.put(stringContractEntry.getKey(), ret);
    }
    return compiledContracts;
}
Also used : HashMap(java.util.HashMap) CompiContrInfo(org.aion.api.server.types.CompiContrInfo) CompilationResult(org.aion.solidity.CompilationResult) Contract(org.aion.solidity.CompilationResult.Contract) CompiledContr(org.aion.api.server.types.CompiledContr)

Aggregations

HashMap (java.util.HashMap)1 CompiContrInfo (org.aion.api.server.types.CompiContrInfo)1 CompiledContr (org.aion.api.server.types.CompiledContr)1 CompilationResult (org.aion.solidity.CompilationResult)1 Contract (org.aion.solidity.CompilationResult.Contract)1