use of com.hederahashgraph.api.proto.java.SystemUndeleteTransactionBody in project hedera-services by hashgraph.
the class SmartContractRequestHandler method systemUndelete.
/**
* System account undoes the deletion marker on a smart contract that has been deleted but
* not yet removed.
*
* @param txBody
* API reuest to undelete the contract
* @param consensusTimestamp
* Platform consensus time
* @return Details of contract undeletion result
*/
public TransactionRecord systemUndelete(TransactionBody txBody, Instant consensusTimestamp) {
SystemUndeleteTransactionBody op = txBody.getSystemUndelete();
ContractID cid = op.getContractID();
var entity = EntityId.fromGrpcContractId(cid);
TransactionReceipt receipt = getTransactionReceipt(SUCCESS, exchange.activeRates());
long oldExpiry = 0;
try {
if (entityExpiries.containsKey(entity)) {
oldExpiry = entityExpiries.get(entity);
} else {
receipt = getTransactionReceipt(INVALID_FILE_ID, exchange.activeRates());
}
if (oldExpiry > 0) {
HederaAccountCustomizer customizer = new HederaAccountCustomizer().expiry(oldExpiry);
ledger.customizePotentiallyDeleted(asAccount(cid), customizer);
}
if (receipt.getStatus() == SUCCESS) {
try {
receipt = updateDeleteFlag(cid, false);
} catch (Exception e) {
receipt = getTransactionReceipt(FAIL_INVALID, exchange.activeRates());
if (log.isDebugEnabled()) {
log.debug("systemUndelete exception: can't serialize or deserialize! tx= {} {}", txBody, e);
}
}
}
entityExpiries.remove(entity);
} catch (Exception e) {
log.warn("Unhandled exception in SystemUndelete", e);
log.debug("File System Exception {} tx= {}", () -> e, () -> TextFormat.shortDebugString(op));
receipt = getTransactionReceipt(FILE_SYSTEM_EXCEPTION, exchange.activeRates());
}
TransactionRecord.Builder transactionRecord = getTransactionRecord(txBody.getTransactionFee(), txBody.getMemo(), txBody.getTransactionID(), getTimestamp(consensusTimestamp), receipt);
return transactionRecord.build();
}
use of com.hederahashgraph.api.proto.java.SystemUndeleteTransactionBody in project hedera-services by hashgraph.
the class HapiSysUndelete method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
if (file.isPresent() && contract.isPresent()) {
Assertions.fail("Ambiguous SystemUndelete---both file and contract present!");
}
SystemUndeleteTransactionBody opBody = spec.txns().<SystemUndeleteTransactionBody, SystemUndeleteTransactionBody.Builder>body(SystemUndeleteTransactionBody.class, b -> {
file.ifPresent(n -> b.setFileID(asFileId(n, spec)));
contract.ifPresent(n -> b.setContractID(asContractId(n, spec)));
});
return b -> b.setSystemUndelete(opBody);
}
Aggregations