use of com.hedera.services.exceptions.MissingAccountException in project hedera-services by hashgraph.
the class CryptoDeleteTransitionLogic method doStateTransition.
@Override
public void doStateTransition() {
try {
CryptoDeleteTransactionBody op = txnCtx.accessor().getTxn().getCryptoDelete();
AccountID id = op.getDeleteAccountID();
if (ledger.isKnownTreasury(id)) {
txnCtx.setStatus(ACCOUNT_IS_TREASURY);
return;
}
AccountID beneficiary = op.getTransferAccountID();
if (ledger.isDetached(id) || ledger.isDetached(beneficiary)) {
txnCtx.setStatus(ACCOUNT_EXPIRED_AND_PENDING_REMOVAL);
return;
}
if (!ledger.allTokenBalancesVanish(id)) {
txnCtx.setStatus(TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES);
return;
}
ledger.delete(id, beneficiary);
sigImpactHistorian.markEntityChanged(id.getAccountNum());
txnCtx.setStatus(SUCCESS);
} catch (MissingAccountException mae) {
txnCtx.setStatus(INVALID_ACCOUNT_ID);
} catch (DeletedAccountException dae) {
txnCtx.setStatus(ACCOUNT_DELETED);
} catch (Exception e) {
log.warn("Avoidable exception!", e);
txnCtx.setStatus(FAIL_INVALID);
}
}
Aggregations