io.proximax.sdk.model.transaction.builder.ModifyAccountPropertyMosaicTransactionBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-xpx-chain-sdk Show documentation
Show all versions of java-xpx-chain-sdk Show documentation
The ProximaX Sirius Chain Java SDK is a Java library for interacting with the Sirius Blockchain.
The newest version!
/*
* Copyright 2019 ProximaX Limited. All rights reserved.
* Use of this source code is governed by the Apache 2.0
* license that can be found in the LICENSE file.
*/
package io.proximax.sdk.model.transaction.builder;
import java.math.BigInteger;
import java.util.List;
import io.proximax.sdk.model.account.props.AccountPropertyModification;
import io.proximax.sdk.model.account.props.AccountPropertyType;
import io.proximax.sdk.model.transaction.EntityType;
import io.proximax.sdk.model.transaction.EntityVersion;
import io.proximax.sdk.model.transaction.ModifyAccountPropertyTransaction;
import io.proximax.sdk.model.transaction.UInt64Id;
/**
*
* Builder for account address property modification
*
*
* Standard use: call {@link #allowed(List)} or {@link #blocked(List)} to manage the allowed and blocked addresses
*
*/
public class ModifyAccountPropertyMosaicTransactionBuilder extends ModifyAccountPropertyTransactionBuilder {
public ModifyAccountPropertyMosaicTransactionBuilder() {
super(EntityType.ACCOUNT_PROPERTIES_MOSAIC, EntityVersion.ACCOUNT_PROPERTIES_MOSAIC.getValue());
}
@Override
public ModifyAccountPropertyTransaction build() {
// use or calculate maxFee
BigInteger maxFee = getMaxFee().orElseGet(() -> getMaxFeeCalculation(
ModifyAccountPropertyTransaction.MosaicModification.calculatePayloadSize(getModifications().size())));
// create transaction instance
return new ModifyAccountPropertyTransaction.MosaicModification(getNetworkType(), getVersion(), getDeadline(),
maxFee, getSignature(), getSigner(), getTransactionInfo(), getPropertyType(), getModifications());
}
// -------------------------------------- convenience --------------------------------------------//
/**
* convenience call to manage allowed mosaics for account
*
* @param modifications modifications to be made to the list of allowed mosaics
* @return self
*/
public ModifyAccountPropertyTransactionBuilder allowed(
List> modifications) {
return propertyType(AccountPropertyType.ALLOW_MOSAIC).modifications(modifications);
}
/**
* convenience call to manage blocked mosaics for account
*
* @param modifications modifications to be made to the list of blocked mosaics
* @return self
*/
public ModifyAccountPropertyTransactionBuilder blocked(
List> modifications) {
return propertyType(AccountPropertyType.BLOCK_MOSAIC).modifications(modifications);
}
}