Search in sources :

Example 1 with UpdateVoteResponse

use of com.radixdlt.api.core.openapitools.model.UpdateVoteResponse 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 2 with UpdateVoteResponse

use of com.radixdlt.api.core.openapitools.model.UpdateVoteResponse 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

NotEnoughNativeTokensForFeesException (com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException)2 UpdateVoteResponse (com.radixdlt.api.core.openapitools.model.UpdateVoteResponse)2 TxBuilderException (com.radixdlt.atom.TxBuilderException)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