Search in sources :

Example 1 with ResourceAmount

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

the class CreateTokenDefinition method toOperationGroups.

@Override
public List<OperationGroup> toOperationGroups(EngineConfiguration configuration, Function<ConstructionDeriveRequestMetadata, EntityIdentifier> identifierFunction) {
    var entityIdentifier = identifierFunction.apply(new ConstructionDeriveRequestMetadataToken().symbol(symbol).type("Token"));
    var mintOperation = new Operation().type("Resource").amount(new ResourceAmount().value(amount.toString()).resourceIdentifier(new TokenResourceIdentifier().rri(entityIdentifier.getAddress()).type("Token"))).entityIdentifier(to);
    var createTokenGroup = new OperationGroup();
    createTokenGroup.addOperationsItem(new Operation().type("Data").data(new Data().action(Data.ActionEnum.CREATE).dataObject(new TokenData().isMutable(owner != null).granularity("1").owner(owner).type(PreparedValidatorRegistered.class.getSimpleName()))).entityIdentifier(entityIdentifier));
    if (owner == null) {
        createTokenGroup.addOperationsItem(mintOperation);
    }
    createTokenGroup.addOperationsItem(new Operation().type("Data").data(new Data().action(Data.ActionEnum.CREATE).dataObject(new TokenMetadata().symbol(symbol).name("some_name").description("some_description").url("").iconUrl(""))).entityIdentifier(entityIdentifier));
    if (owner == null) {
        return List.of(createTokenGroup);
    }
    var mintTokenGroup = new OperationGroup().addOperationsItem(mintOperation);
    return List.of(createTokenGroup, mintTokenGroup);
}
Also used : ResourceAmount(com.radixdlt.api.core.openapitools.model.ResourceAmount) OperationGroup(com.radixdlt.api.core.openapitools.model.OperationGroup) TokenResourceIdentifier(com.radixdlt.api.core.openapitools.model.TokenResourceIdentifier) Data(com.radixdlt.api.core.openapitools.model.Data) TokenData(com.radixdlt.api.core.openapitools.model.TokenData) TokenData(com.radixdlt.api.core.openapitools.model.TokenData) Operation(com.radixdlt.api.core.openapitools.model.Operation) PreparedValidatorRegistered(com.radixdlt.api.core.openapitools.model.PreparedValidatorRegistered) ConstructionDeriveRequestMetadataToken(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataToken) TokenMetadata(com.radixdlt.api.core.openapitools.model.TokenMetadata)

Example 2 with ResourceAmount

use of com.radixdlt.api.core.openapitools.model.ResourceAmount 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)

Example 3 with ResourceAmount

use of com.radixdlt.api.core.openapitools.model.ResourceAmount 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);
}
Also used : ConstructionDeriveRequestMetadataAccount(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount) ConstructionDeriveRequestMetadataPreparedStakes(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedStakes) ResourceAmount(com.radixdlt.api.core.openapitools.model.ResourceAmount) OperationGroup(com.radixdlt.api.core.openapitools.model.OperationGroup) Operation(com.radixdlt.api.core.openapitools.model.Operation)

Example 4 with ResourceAmount

use of com.radixdlt.api.core.openapitools.model.ResourceAmount 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);
}
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) Operation(com.radixdlt.api.core.openapitools.model.Operation)

Aggregations

Operation (com.radixdlt.api.core.openapitools.model.Operation)4 OperationGroup (com.radixdlt.api.core.openapitools.model.OperationGroup)4 ResourceAmount (com.radixdlt.api.core.openapitools.model.ResourceAmount)4 ConstructionDeriveRequestMetadataAccount (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount)3 ConstructionDeriveRequestMetadataPreparedStakes (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedStakes)1 ConstructionDeriveRequestMetadataPreparedUnstakes (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedUnstakes)1 ConstructionDeriveRequestMetadataToken (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataToken)1 Data (com.radixdlt.api.core.openapitools.model.Data)1 PreparedValidatorRegistered (com.radixdlt.api.core.openapitools.model.PreparedValidatorRegistered)1 StakeUnitResourceIdentifier (com.radixdlt.api.core.openapitools.model.StakeUnitResourceIdentifier)1 TokenData (com.radixdlt.api.core.openapitools.model.TokenData)1 TokenMetadata (com.radixdlt.api.core.openapitools.model.TokenMetadata)1 TokenResourceIdentifier (com.radixdlt.api.core.openapitools.model.TokenResourceIdentifier)1