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