Search in sources :

Example 26 with ContractExeException

use of org.tron.core.exception.ContractExeException in project java-tron by tronprotocol.

the class WitnessUpdateActuator method execute.

@Override
public boolean execute(TransactionResultCapsule ret) throws ContractExeException {
    long fee = calcFee();
    try {
        final WitnessUpdateContract witnessUpdateContract = this.contract.unpack(WitnessUpdateContract.class);
        this.updateWitness(witnessUpdateContract);
        ret.setStatus(fee, code.SUCESS);
    } catch (final InvalidProtocolBufferException e) {
        logger.debug(e.getMessage(), e);
        ret.setStatus(fee, code.FAILED);
        throw new ContractExeException(e.getMessage());
    }
    return true;
}
Also used : WitnessUpdateContract(org.tron.protos.Contract.WitnessUpdateContract) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ContractExeException(org.tron.core.exception.ContractExeException)

Example 27 with ContractExeException

use of org.tron.core.exception.ContractExeException in project java-tron by tronprotocol.

the class CreateAccountActuator method execute.

@Override
public boolean execute(TransactionResultCapsule ret) throws ContractExeException {
    long fee = calcFee();
    try {
        AccountCreateContract accountCreateContract = contract.unpack(AccountCreateContract.class);
        AccountCapsule accountCapsule = new AccountCapsule(accountCreateContract);
        dbManager.getAccountStore().put(accountCreateContract.getOwnerAddress().toByteArray(), accountCapsule);
        ret.setStatus(fee, code.SUCESS);
        return true;
    } catch (InvalidProtocolBufferException e) {
        ret.setStatus(fee, code.FAILED);
        logger.debug(e.getMessage(), e);
        throw new ContractExeException(e.getMessage());
    }
}
Also used : AccountCapsule(org.tron.core.capsule.AccountCapsule) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) AccountCreateContract(org.tron.protos.Contract.AccountCreateContract) ContractExeException(org.tron.core.exception.ContractExeException)

Example 28 with ContractExeException

use of org.tron.core.exception.ContractExeException in project java-tron by tronprotocol.

the class TransferActuator method execute.

@Override
public boolean execute(TransactionResultCapsule ret) throws ContractExeException {
    long fee = calcFee();
    try {
        TransferContract transferContract = null;
        transferContract = contract.unpack(TransferContract.class);
        dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(), -calcFee());
        ret.setStatus(fee, code.SUCESS);
        dbManager.adjustBalance(transferContract.getOwnerAddress().toByteArray(), -transferContract.getAmount());
        dbManager.adjustBalance(transferContract.getToAddress().toByteArray(), transferContract.getAmount());
    } catch (InvalidProtocolBufferException e) {
        logger.debug(e.getMessage(), e);
        ret.setStatus(fee, code.FAILED);
        throw new ContractExeException(e.getMessage());
    } catch (BalanceInsufficientException e) {
        logger.debug(e.getMessage(), e);
        ret.setStatus(fee, code.FAILED);
        throw new ContractExeException(e.getMessage());
    }
    return true;
}
Also used : BalanceInsufficientException(org.tron.core.exception.BalanceInsufficientException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) TransferContract(org.tron.protos.Contract.TransferContract) ContractExeException(org.tron.core.exception.ContractExeException)

Aggregations

ContractExeException (org.tron.core.exception.ContractExeException)28 ContractValidateException (org.tron.core.exception.ContractValidateException)20 AccountCapsule (org.tron.core.capsule.AccountCapsule)19 Test (org.junit.Test)16 TransactionResultCapsule (org.tron.core.capsule.TransactionResultCapsule)15 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)9 DateTime (org.joda.time.DateTime)5 AssetIssueCapsule (org.tron.core.capsule.AssetIssueCapsule)4 BlockCapsule (org.tron.core.capsule.BlockCapsule)4 ValidateSignatureException (org.tron.core.exception.ValidateSignatureException)4 ByteString (com.google.protobuf.ByteString)3 Dialog (org.tron.core.db.AbstractRevokingStore.Dialog)3 BalanceInsufficientException (org.tron.core.exception.BalanceInsufficientException)3 RevokingStoreIllegalStateException (org.tron.core.exception.RevokingStoreIllegalStateException)3 TransactionCapsule (org.tron.core.capsule.TransactionCapsule)2 UnLinkedBlockException (org.tron.core.exception.UnLinkedBlockException)2 Contract (org.tron.protos.Contract)2 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 NumberMessage (org.tron.api.GrpcAPI.NumberMessage)1