Search in sources :

Example 1 with MissingAccountException

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);
    }
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) MissingAccountException(com.hedera.services.exceptions.MissingAccountException) CryptoDeleteTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody) DeletedAccountException(com.hedera.services.exceptions.DeletedAccountException) MissingAccountException(com.hedera.services.exceptions.MissingAccountException) DeletedAccountException(com.hedera.services.exceptions.DeletedAccountException)

Aggregations

DeletedAccountException (com.hedera.services.exceptions.DeletedAccountException)1 MissingAccountException (com.hedera.services.exceptions.MissingAccountException)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 CryptoDeleteTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody)1