use of com.hederahashgraph.api.proto.java.SystemDeleteTransactionBody in project hedera-services by hashgraph.
the class SmartContractRequestHandler method systemDelete.
/**
* System account deletes any contract. This simply marks the contract as deleted.
*
* @param txBody
* API request to delete the contract
* @param consensusTimestamp
* Platform consensus time
* @return Details of contract deletion result
*/
public TransactionRecord systemDelete(TransactionBody txBody, Instant consensusTimestamp) {
SystemDeleteTransactionBody op = txBody.getSystemDelete();
ContractID cid = op.getContractID();
long newExpiry = op.getExpirationTime().getSeconds();
TransactionReceipt receipt;
receipt = updateDeleteFlag(cid, true);
try {
if (receipt.getStatus().equals(ResponseCodeEnum.SUCCESS)) {
AccountID id = asAccount(cid);
long oldExpiry = ledger.expiry(id);
var entity = EntityId.fromGrpcContractId(cid);
entityExpiries.put(entity, oldExpiry);
HederaAccountCustomizer customizer = new HederaAccountCustomizer().expiry(newExpiry);
ledger.customizePotentiallyDeleted(id, customizer);
}
} catch (Exception e) {
log.warn("Unhandled exception in SystemDelete", e);
log.debug("File System Exception {} tx= {}", () -> e, () -> TextFormat.shortDebugString(op));
receipt = getTransactionReceipt(ResponseCodeEnum.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.SystemDeleteTransactionBody in project hedera-services by hashgraph.
the class HapiSysDelete method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
if (file.isPresent() && contract.isPresent()) {
Assertions.fail("Ambiguous SystemDelete---both file and contract present!");
}
SystemDeleteTransactionBody opBody = spec.txns().<SystemDeleteTransactionBody, SystemDeleteTransactionBody.Builder>body(SystemDeleteTransactionBody.class, b -> {
newExpiry.ifPresent(l -> b.setExpirationTime(TimestampSeconds.newBuilder().setSeconds(l)));
file.ifPresent(n -> b.setFileID(asFileId(n, spec)));
contract.ifPresent(n -> b.setContractID(asContractId(n, spec)));
});
return b -> b.setSystemDelete(opBody);
}
Aggregations