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