Search in sources :

Example 1 with ConstructionBuildRequest

use of com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest in project radixdlt by radixdlt.

the class NodeApiClient method submit.

public void submit(NodeTransactionAction action, boolean disableResourceAllocateAndDestroy) throws Exception {
    var networkIdentifier = networkIdentifier();
    var engineConfigurationResponse = engineConfigurationHandler.handleRequest(new EngineConfigurationRequest().networkIdentifier(networkIdentifier));
    var keyListResponse = keyListHandler.handleRequest(new KeyListRequest().networkIdentifier(networkIdentifier));
    var nodePublicKey = keyListResponse.getPublicKeys().get(0).getPublicKey();
    var configuration = engineConfigurationResponse.getForks().get(0).getEngineConfiguration();
    var accountIdentifier = deriveAccount(nodePublicKey);
    var operationGroups = action.toOperationGroups(configuration, this::selfDerive);
    var buildRequest = new ConstructionBuildRequest().networkIdentifier(networkIdentifier).feePayer(accountIdentifier).operationGroups(operationGroups).disableResourceAllocateAndDestroy(disableResourceAllocateAndDestroy);
    var buildResponse = constructionBuildHandler.handleRequest(buildRequest);
    var unsignedTransaction = buildResponse.getUnsignedTransaction();
    var response = keySignHandler.handleRequest(new KeySignRequest().networkIdentifier(networkIdentifier).publicKey(nodePublicKey).unsignedTransaction(unsignedTransaction));
    constructionSubmitHandler.handleRequest(new ConstructionSubmitRequest().networkIdentifier(networkIdentifier).signedTransaction(response.getSignedTransaction()));
}
Also used : EngineConfigurationRequest(com.radixdlt.api.core.openapitools.model.EngineConfigurationRequest) ConstructionBuildRequest(com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest) KeyListRequest(com.radixdlt.api.core.openapitools.model.KeyListRequest) KeySignRequest(com.radixdlt.api.core.openapitools.model.KeySignRequest) ConstructionSubmitRequest(com.radixdlt.api.core.openapitools.model.ConstructionSubmitRequest)

Example 2 with ConstructionBuildRequest

use of com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest in project radixdlt by radixdlt.

the class ConstructionBuildFeePayerTest method buildRequestWithFeePayer.

private ConstructionBuildRequest buildRequestWithFeePayer(EntityIdentifier feePayer) {
    var transferAmount = getLiquidAmount().toSubunits().subtract(Amount.ofTokens(1).toSubunits());
    var accountAddress = REAddr.ofPubKeyAccount(self);
    var otherKey = PrivateKeys.ofNumeric(2).getPublicKey();
    var otherAddress = REAddr.ofPubKeyAccount(otherKey);
    return new ConstructionBuildRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).feePayer(feePayer).addOperationGroupsItem(new OperationGroup().addOperationsItem(new Operation().entityIdentifier(coreModelMapper.entityIdentifier(accountAddress)).amount(coreModelMapper.nativeTokenAmount(false, transferAmount))).addOperationsItem(new Operation().entityIdentifier(coreModelMapper.entityIdentifier(otherAddress)).amount(coreModelMapper.nativeTokenAmount(true, transferAmount))));
}
Also used : OperationGroup(com.radixdlt.api.core.openapitools.model.OperationGroup) ConstructionBuildRequest(com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) Operation(com.radixdlt.api.core.openapitools.model.Operation)

Example 3 with ConstructionBuildRequest

use of com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest in project radixdlt by radixdlt.

the class ConstructionBuildMessageTest method buildRequestWithMessage.

private ConstructionBuildRequest buildRequestWithMessage(String message) {
    var transferAmount = UInt256.ONE;
    var accountAddress = REAddr.ofPubKeyAccount(self);
    var otherKey = PrivateKeys.ofNumeric(2).getPublicKey();
    var otherAddress = REAddr.ofPubKeyAccount(otherKey);
    return new ConstructionBuildRequest().message(message).networkIdentifier(new NetworkIdentifier().network("localnet")).feePayer(coreModelMapper.entityIdentifier(accountAddress)).addOperationGroupsItem(new OperationGroup().addOperationsItem(new Operation().entityIdentifier(coreModelMapper.entityIdentifier(accountAddress)).amount(coreModelMapper.nativeTokenAmount(false, transferAmount))).addOperationsItem(new Operation().entityIdentifier(coreModelMapper.entityIdentifier(otherAddress)).amount(coreModelMapper.nativeTokenAmount(true, transferAmount))));
}
Also used : OperationGroup(com.radixdlt.api.core.openapitools.model.OperationGroup) ConstructionBuildRequest(com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) Operation(com.radixdlt.api.core.openapitools.model.Operation)

Aggregations

ConstructionBuildRequest (com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest)3 NetworkIdentifier (com.radixdlt.api.core.openapitools.model.NetworkIdentifier)2 Operation (com.radixdlt.api.core.openapitools.model.Operation)2 OperationGroup (com.radixdlt.api.core.openapitools.model.OperationGroup)2 ConstructionSubmitRequest (com.radixdlt.api.core.openapitools.model.ConstructionSubmitRequest)1 EngineConfigurationRequest (com.radixdlt.api.core.openapitools.model.EngineConfigurationRequest)1 KeyListRequest (com.radixdlt.api.core.openapitools.model.KeyListRequest)1 KeySignRequest (com.radixdlt.api.core.openapitools.model.KeySignRequest)1