Search in sources :

Example 1 with Result

use of org.aion.solidity.Compiler.Result in project aion by aionnetwork.

the class SolidityTypeTest method createRepository.

private RepositoryCache createRepository(AionTransaction tx) throws IOException {
    Result r = Compiler.getInstance().compile(ContractUtils.readContract("SolidityType.sol"), Options.BIN);
    CompilationResult cr = CompilationResult.parse(r.output);
    String deployer = cr.contracts.get("SolidityType").bin;
    String contract = deployer.substring(deployer.indexOf("60506040", 1));
    AionRepositoryImpl repo = blockchain.getRepository();
    RepositoryCache track = repo.startTracking();
    track.addBalance(tx.getSenderAddress(), BigInteger.valueOf(tx.getEnergyPrice()).multiply(BigInteger.valueOf(500_000L)));
    track.createAccount(tx.getDestinationAddress());
    track.saveCode(tx.getDestinationAddress(), Hex.decode(contract));
    track.saveVmType(tx.getDestinationAddress(), InternalVmType.FVM);
    track.flushTo(repo, true);
    return track;
}
Also used : RepositoryCache(org.aion.base.db.RepositoryCache) AionRepositoryImpl(org.aion.zero.impl.db.AionRepositoryImpl) CompilationResult(org.aion.solidity.CompilationResult) Result(org.aion.solidity.Compiler.Result) CompilationResult(org.aion.solidity.CompilationResult)

Aggregations

RepositoryCache (org.aion.base.db.RepositoryCache)1 CompilationResult (org.aion.solidity.CompilationResult)1 Result (org.aion.solidity.Compiler.Result)1 AionRepositoryImpl (org.aion.zero.impl.db.AionRepositoryImpl)1