Search in sources :

Example 1 with ConstructionDeriveRequestMetadataPreparedUnstakes

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

the class ConstructionDeriveHandlerTest method derive_prepared_unstakes_should_return_entity_identifier.

@Test
public void derive_prepared_unstakes_should_return_entity_identifier() throws CoreApiException {
    // Arrange
    var publicKey = PrivateKeys.ofNumeric(2).getPublicKey();
    start();
    // Act
    var request = new ConstructionDeriveRequest().networkIdentifier(networkIdentifier()).publicKey(coreModelMapper.publicKey(publicKey)).metadata(new ConstructionDeriveRequestMetadataPreparedUnstakes().type("PreparedUnstakes"));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifierPreparedUnstake(REAddr.ofPubKeyAccount(publicKey)));
}
Also used : ConstructionDeriveRequestMetadataPreparedUnstakes(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedUnstakes) ConstructionDeriveRequest(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 2 with ConstructionDeriveRequestMetadataPreparedUnstakes

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

the class UnstakeStakeUnits method toOperationGroups.

@Override
public List<OperationGroup> toOperationGroups(EngineConfiguration configuration, Function<ConstructionDeriveRequestMetadata, EntityIdentifier> identifierFunction) {
    var from = identifierFunction.apply(new ConstructionDeriveRequestMetadataAccount().type("Account"));
    var to = identifierFunction.apply(new ConstructionDeriveRequestMetadataPreparedUnstakes().type("PreparedUnstakes"));
    var resourceIdentifier = new StakeUnitResourceIdentifier().validatorAddress(validatorAddress).type("StakeUnits");
    var operationGroup = new OperationGroup().addOperationsItem(new Operation().type("Resource").amount(new ResourceAmount().resourceIdentifier(resourceIdentifier).value("-" + amount.toSubunits().toString())).entityIdentifier(from)).addOperationsItem(new Operation().type("Resource").amount(new ResourceAmount().resourceIdentifier(resourceIdentifier).value(amount.toSubunits().toString())).entityIdentifier(to));
    return List.of(operationGroup);
}
Also used : ConstructionDeriveRequestMetadataAccount(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount) ResourceAmount(com.radixdlt.api.core.openapitools.model.ResourceAmount) OperationGroup(com.radixdlt.api.core.openapitools.model.OperationGroup) ConstructionDeriveRequestMetadataPreparedUnstakes(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedUnstakes) StakeUnitResourceIdentifier(com.radixdlt.api.core.openapitools.model.StakeUnitResourceIdentifier) Operation(com.radixdlt.api.core.openapitools.model.Operation)

Aggregations

ConstructionDeriveRequestMetadataPreparedUnstakes (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedUnstakes)2 ApiTest (com.radixdlt.api.ApiTest)1 ConstructionDeriveRequest (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest)1 ConstructionDeriveRequestMetadataAccount (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount)1 Operation (com.radixdlt.api.core.openapitools.model.Operation)1 OperationGroup (com.radixdlt.api.core.openapitools.model.OperationGroup)1 ResourceAmount (com.radixdlt.api.core.openapitools.model.ResourceAmount)1 StakeUnitResourceIdentifier (com.radixdlt.api.core.openapitools.model.StakeUnitResourceIdentifier)1 Test (org.junit.Test)1