use of com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount 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);
}
use of com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount in project radixdlt by radixdlt.
the class ConstructionDeriveHandlerTest method derive_account_request_should_return_account_entity_identifier.
@Test
public void derive_account_request_should_return_account_entity_identifier() throws CoreApiException {
// Arrange
var publicKey = PrivateKeys.ofNumeric(2).getPublicKey();
start();
// Act
var request = new ConstructionDeriveRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).publicKey(coreModelMapper.publicKey(publicKey)).metadata(new ConstructionDeriveRequestMetadataAccount().type("Account"));
var response = sut.handleRequest(request);
// Assert
assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifier(REAddr.ofPubKeyAccount(publicKey)));
}
use of com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount in project radixdlt by radixdlt.
the class StakeTokens method toOperationGroups.
@Override
public List<OperationGroup> toOperationGroups(EngineConfiguration configuration, Function<ConstructionDeriveRequestMetadata, EntityIdentifier> identifierFunction) {
var nativeToken = configuration.getNativeToken();
var from = identifierFunction.apply(new ConstructionDeriveRequestMetadataAccount().type("Account"));
var to = identifierFunction.apply(new ConstructionDeriveRequestMetadataPreparedStakes().validator(validator).type("PreparedStakes"));
var operationGroup = new OperationGroup().addOperationsItem(new Operation().type("Resource").amount(new ResourceAmount().resourceIdentifier(nativeToken).value("-" + amount.toSubunits().toString())).entityIdentifier(from)).addOperationsItem(new Operation().type("Resource").amount(new ResourceAmount().resourceIdentifier(nativeToken).value(amount.toSubunits().toString())).entityIdentifier(to));
return List.of(operationGroup);
}
use of com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount in project radixdlt by radixdlt.
the class TransferTokens method toOperationGroups.
@Override
public List<OperationGroup> toOperationGroups(EngineConfiguration configuration, Function<ConstructionDeriveRequestMetadata, EntityIdentifier> identifierFunction) {
var from = identifierFunction.apply(new ConstructionDeriveRequestMetadataAccount().type("Account"));
var operationGroup = new OperationGroup().addOperationsItem(new Operation().type("Resource").amount(new ResourceAmount().resourceIdentifier(tokenResourceIdentifier).value("-" + amount.toSubunits().toString())).entityIdentifier(from)).addOperationsItem(new Operation().type("Resource").amount(new ResourceAmount().resourceIdentifier(tokenResourceIdentifier).value(amount.toSubunits().toString())).entityIdentifier(to));
return List.of(operationGroup);
}
Aggregations