Search in sources :

Example 1 with TxBuilder

use of com.radixdlt.atom.TxBuilder 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)

Aggregations

ConstructionBuildResponse (com.radixdlt.api.core.openapitools.model.ConstructionBuildResponse)1 TxBuilder (com.radixdlt.atom.TxBuilder)1 TxBuilderException (com.radixdlt.atom.TxBuilderException)1