Search in sources :

Example 1 with TxBuilderException

use of com.radixdlt.atom.TxBuilderException in project radixdlt by radixdlt.

the class ConstructionBuildHandler method handleRequest.

@Override
public ConstructionBuildResponse handleRequest(ConstructionBuildRequest request) throws CoreApiException {
    modelMapper.verifyNetwork(request.getNetworkIdentifier());
    var operationTxBuilder = modelMapper.operationTxBuilder(request.getMessage(), request.getOperationGroups());
    var feePayer = modelMapper.feePayerEntity(request.getFeePayer());
    var disableAllocAndDestroy = request.getDisableResourceAllocateAndDestroy();
    var disable = disableAllocAndDestroy != null && disableAllocAndDestroy;
    TxBuilder builder;
    try {
        builder = radixEngine.constructWithFees(operationTxBuilder, disable, feePayer.accountAddress(), NotEnoughNativeTokensForFeesException::new);
    } catch (TxBuilderException e) {
        throw CoreApiException.badRequest(modelMapper.builderErrorDetails(e));
    }
    var unsignedTransaction = builder.buildForExternalSign();
    return new ConstructionBuildResponse().unsignedTransaction(Bytes.toHexString(unsignedTransaction.blob())).payloadToSign(Bytes.toHexString(unsignedTransaction.hashToSign().asBytes()));
}
Also used : ConstructionBuildResponse(com.radixdlt.api.core.openapitools.model.ConstructionBuildResponse) TxBuilder(com.radixdlt.atom.TxBuilder) TxBuilderException(com.radixdlt.atom.TxBuilderException)

Example 2 with TxBuilderException

use of com.radixdlt.atom.TxBuilderException in project radixdlt by radixdlt.

the class VoteHandler method handleRequest.

@Override
public UpdateVoteResponse handleRequest(UpdateVoteRequest request) throws CoreApiException {
    coreModelMapper.verifyNetwork(request.getNetworkIdentifier());
    final Txn signedTx;
    try {
        signedTx = radixEngine.constructWithFees(this::buildVote, false, REAddr.ofPubKeyAccount(validatorKey), NotEnoughNativeTokensForFeesException::new).signAndBuild(hashSigner::sign);
    } catch (TxBuilderException e) {
        throw CoreApiException.badRequest(coreModelMapper.builderErrorDetails(e));
    }
    try {
        radixEngineStateComputer.addToMempool(signedTx);
        return new UpdateVoteResponse().transactionIdentifier(coreModelMapper.transactionIdentifier(signedTx.getId())).duplicate(false);
    } catch (MempoolDuplicateException e) {
        return new UpdateVoteResponse().transactionIdentifier(coreModelMapper.transactionIdentifier(signedTx.getId())).duplicate(true);
    } catch (MempoolFullException e) {
        throw coreModelMapper.mempoolFullException(e);
    } catch (MempoolRejectedException e) {
        throw coreModelMapper.radixEngineException((RadixEngineException) e.getCause());
    }
}
Also used : MempoolDuplicateException(com.radixdlt.mempool.MempoolDuplicateException) NotEnoughNativeTokensForFeesException(com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException) MempoolRejectedException(com.radixdlt.mempool.MempoolRejectedException) MempoolFullException(com.radixdlt.mempool.MempoolFullException) RadixEngineException(com.radixdlt.engine.RadixEngineException) Txn(com.radixdlt.atom.Txn) UpdateVoteResponse(com.radixdlt.api.core.openapitools.model.UpdateVoteResponse) TxBuilderException(com.radixdlt.atom.TxBuilderException)

Example 3 with TxBuilderException

use of com.radixdlt.atom.TxBuilderException in project radixdlt by radixdlt.

the class WithdrawVoteHandler method handleRequest.

@Override
public UpdateVoteResponse handleRequest(UpdateVoteRequest request) throws CoreApiException {
    coreModelMapper.verifyNetwork(request.getNetworkIdentifier());
    final Txn signedTx;
    try {
        signedTx = radixEngine.constructWithFees(this::buildWithdrawVote, false, REAddr.ofPubKeyAccount(validatorKey), NotEnoughNativeTokensForFeesException::new).signAndBuild(hashSigner::sign);
    } catch (TxBuilderException e) {
        throw CoreApiException.badRequest(coreModelMapper.builderErrorDetails(e));
    }
    try {
        radixEngineStateComputer.addToMempool(signedTx);
        return new UpdateVoteResponse().transactionIdentifier(coreModelMapper.transactionIdentifier(signedTx.getId())).duplicate(false);
    } catch (MempoolDuplicateException e) {
        return new UpdateVoteResponse().transactionIdentifier(coreModelMapper.transactionIdentifier(signedTx.getId())).duplicate(true);
    } catch (MempoolFullException e) {
        throw coreModelMapper.mempoolFullException(e);
    } catch (MempoolRejectedException e) {
        throw coreModelMapper.radixEngineException((RadixEngineException) e.getCause());
    }
}
Also used : MempoolDuplicateException(com.radixdlt.mempool.MempoolDuplicateException) NotEnoughNativeTokensForFeesException(com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException) MempoolRejectedException(com.radixdlt.mempool.MempoolRejectedException) MempoolFullException(com.radixdlt.mempool.MempoolFullException) RadixEngineException(com.radixdlt.engine.RadixEngineException) Txn(com.radixdlt.atom.Txn) UpdateVoteResponse(com.radixdlt.api.core.openapitools.model.UpdateVoteResponse) TxBuilderException(com.radixdlt.atom.TxBuilderException)

Aggregations

TxBuilderException (com.radixdlt.atom.TxBuilderException)3 NotEnoughNativeTokensForFeesException (com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException)2 UpdateVoteResponse (com.radixdlt.api.core.openapitools.model.UpdateVoteResponse)2 Txn (com.radixdlt.atom.Txn)2 RadixEngineException (com.radixdlt.engine.RadixEngineException)2 MempoolDuplicateException (com.radixdlt.mempool.MempoolDuplicateException)2 MempoolFullException (com.radixdlt.mempool.MempoolFullException)2 MempoolRejectedException (com.radixdlt.mempool.MempoolRejectedException)2 ConstructionBuildResponse (com.radixdlt.api.core.openapitools.model.ConstructionBuildResponse)1 TxBuilder (com.radixdlt.atom.TxBuilder)1