use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class ContractResultMigration method process.
private boolean process(MigrationContractResult contractResult) {
long consensusTimestamp = contractResult.getConsensusTimestamp();
try {
byte[] functionResult = contractResult.getFunctionResult();
if (functionResult == null || functionResult.length == 0) {
return false;
}
ContractFunctionResult contractFunctionResult = ContractFunctionResult.parseFrom(functionResult);
Long[] createdContractIds = new Long[contractFunctionResult.getCreatedContractIDsCount()];
for (int i = 0; i < createdContractIds.length; ++i) {
createdContractIds[i] = getContractId(contractFunctionResult.getCreatedContractIDs(i));
}
contractResult.setBloom(DomainUtils.toBytes(contractFunctionResult.getBloom()));
contractResult.setCallResult(DomainUtils.toBytes(contractFunctionResult.getContractCallResult()));
contractResult.setContractId(getContractId(contractFunctionResult.getContractID()));
contractResult.setCreatedContractIds(createdContractIds);
contractResult.setErrorMessage(contractFunctionResult.getErrorMessage());
update(contractResult);
for (int index = 0; index < contractFunctionResult.getLogInfoCount(); ++index) {
ContractLoginfo contractLoginfo = contractFunctionResult.getLogInfo(index);
MigrationContractLog migrationContractLog = new MigrationContractLog();
migrationContractLog.setBloom(DomainUtils.toBytes(contractLoginfo.getBloom()));
migrationContractLog.setConsensusTimestamp(consensusTimestamp);
migrationContractLog.setContractId(getContractId(contractLoginfo.getContractID()));
migrationContractLog.setData(DomainUtils.toBytes(contractLoginfo.getData()));
migrationContractLog.setIndex(index);
migrationContractLog.setTopic0(DomainUtils.bytesToHex(Utility.getTopic(contractLoginfo, 0)));
migrationContractLog.setTopic1(DomainUtils.bytesToHex(Utility.getTopic(contractLoginfo, 1)));
migrationContractLog.setTopic2(DomainUtils.bytesToHex(Utility.getTopic(contractLoginfo, 2)));
migrationContractLog.setTopic3(DomainUtils.bytesToHex(Utility.getTopic(contractLoginfo, 3)));
insert(migrationContractLog);
}
return true;
} catch (Exception e) {
log.warn("Unable to parse {} as ContractFunctionResult", consensusTimestamp, e);
}
return false;
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class ContractResultServiceImplIntegrationTest method contractCallResultOnFailure.
@Test
void contractCallResultOnFailure() {
RecordItem recordItem = recordItemBuilder.contractCall().record(x -> x.clearContractCallResult()).receipt(r -> r.clearContractID().setStatus(ResponseCodeEnum.CONTRACT_EXECUTION_EXCEPTION)).build();
ContractFunctionResult contractFunctionResult = recordItem.getRecord().getContractCreateResult();
contractResultsTest(recordItem, contractFunctionResult);
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class ContractResultServiceImplIntegrationTest method getContractResultOnCreate.
@Test
void getContractResultOnCreate() {
RecordItem recordItem = recordItemBuilder.contractCreate(CONTRACT_ID).build();
ContractFunctionResult contractFunctionResult = recordItem.getRecord().getContractCreateResult();
contractResultsTest(recordItem, contractFunctionResult);
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class ContractResultServiceImplIntegrationTest method contractResultZeroStateChanges.
@Test
void contractResultZeroStateChanges() {
RecordItem recordItem = recordItemBuilder.contractCreate().record(x -> x.setContractCreateResult(recordItemBuilder.contractFunctionResult(CONTRACT_ID).clearStateChanges())).receipt(r -> r.setContractID(CONTRACT_ID)).build();
ContractFunctionResult contractFunctionResult = recordItem.getRecord().getContractCreateResult();
contractResultsTest(recordItem, contractFunctionResult);
}
use of com.hederahashgraph.api.proto.java.ContractFunctionResult in project hedera-mirror-node by hashgraph.
the class ContractResultServiceImplIntegrationTest method getContractResultOnTokenMintFT.
@Test
void getContractResultOnTokenMintFT() {
RecordItem recordItem = recordItemBuilder.tokenMint(TokenType.FUNGIBLE_COMMON).record(x -> x.setContractCallResult(recordItemBuilder.contractFunctionResult(CONTRACT_ID))).build();
ContractFunctionResult contractFunctionResult = recordItem.getRecord().getContractCallResult();
contractResultsTest(recordItem, contractFunctionResult);
}
Aggregations