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());
}
}
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());
}
}
Aggregations