use of io.nem.symbol.catapult.builders.MosaicBuilder in project nem2-sdk-java by nemtech.
the class AccountInfo method serialize.
public byte[] serialize() {
AddressDto address = SerializationUtils.toAddressDto(getAddress());
HeightDto addressHeight = new HeightDto(getAddressHeight().longValue());
KeyDto publicKey = SerializationUtils.toKeyDto(getPublicKey());
HeightDto publicKeyHeight = new HeightDto(getPublicKeyHeight().longValue());
AccountTypeDto accountType = AccountTypeDto.rawValueOf((byte) getAccountType().getValue());
EnumSet<AccountKeyTypeFlagsDto> supplementalPublicKeysMask = getAccountKeyTypeFlags();
KeyDto linkedPublicKey = getSupplementalAccountKeys().getLinked().map(SerializationUtils::toKeyDto).orElse(null);
KeyDto nodePublicKey = getSupplementalAccountKeys().getNode().map(SerializationUtils::toKeyDto).orElse(null);
KeyDto vrfPublicKey = getSupplementalAccountKeys().getVrf().map(SerializationUtils::toKeyDto).orElse(null);
List<PinnedVotingKeyBuilder> votingPublicKeys = getSupplementalAccountKeys().getVoting().stream().map(this::toPinnedVotingKeyBuilder).collect(Collectors.toList());
ImportanceDto importanceValue = new ImportanceDto(getImportance().getValue().longValue());
ImportanceHeightDto importanceHeight = new ImportanceHeightDto(getImportance().getHeight().longValue());
ImportanceSnapshotBuilder importanceSnapshots = ImportanceSnapshotBuilder.create(importanceValue, importanceHeight);
HeightActivityBucketsBuilder activityBuckets = toHeightActivityBucketsBuilder();
List<MosaicBuilder> balances = SerializationUtils.toMosaicBuilders(getMosaics());
if (isHighValue()) {
return AccountStateBuilder.createHighValue((short) getVersion(), address, addressHeight, publicKey, publicKeyHeight, accountType, supplementalPublicKeysMask, linkedPublicKey, nodePublicKey, vrfPublicKey, votingPublicKeys, importanceSnapshots, activityBuckets, balances).serialize();
} else {
return AccountStateBuilder.createRegular((short) getVersion(), address, addressHeight, publicKey, publicKeyHeight, accountType, supplementalPublicKeysMask, linkedPublicKey, nodePublicKey, vrfPublicKey, votingPublicKeys, balances).serialize();
}
}
use of io.nem.symbol.catapult.builders.MosaicBuilder in project nem2-sdk-java by nemtech.
the class BalanceTransferReceipt method serialize.
/**
* Serialize receipt and returns receipt bytes
*
* @return receipt bytes
*/
@Override
public byte[] serialize() {
final short version = (short) getVersion().getValue();
final ReceiptTypeDto type = ReceiptTypeDto.rawValueOf((short) getType().getValue());
final MosaicBuilder mosaic = MosaicBuilder.create(new MosaicIdDto(getMosaicId().getIdAsLong()), SerializationUtils.toAmount(getAmount()));
final AddressDto senderAddress = SerializationUtils.toAddressDto(getSenderAddress());
final AddressDto recipientAddress = SerializationUtils.toAddressDto(getRecipientAddress());
return BalanceTransferReceiptBuilder.create(version, type, mosaic, senderAddress, recipientAddress).serialize();
}
use of io.nem.symbol.catapult.builders.MosaicBuilder in project nem2-sdk-java by nemtech.
the class BalanceChangeReceipt method serialize.
/**
* Serialize receipt and returns receipt bytes
*
* @return receipt bytes
*/
@Override
public byte[] serialize() {
short version = (short) getVersion().getValue();
ReceiptTypeDto type = ReceiptTypeDto.rawValueOf((short) getType().getValue());
MosaicBuilder mosaic = MosaicBuilder.create(new MosaicIdDto(getMosaicId().getIdAsLong()), SerializationUtils.toAmount(getAmount()));
AddressDto targetAddress = SerializationUtils.toAddressDto(getTargetAddress());
return BalanceChangeReceiptBuilder.create(version, type, mosaic, targetAddress).serialize();
}
use of io.nem.symbol.catapult.builders.MosaicBuilder in project nem2-sdk-java by nemtech.
the class SecretLockInfo method serialize.
/**
* @return serializes the state of this object.
*/
public byte[] serialize() {
short version = (short) getVersion();
AddressDto ownerAddress = SerializationUtils.toAddressDto(getOwnerAddress());
MosaicBuilder mosaic = MosaicBuilder.create(SerializationUtils.toMosaicIdDto(getMosaicId()), SerializationUtils.toAmount(getAmount()));
HeightDto endHeight = new HeightDto(getEndHeight().longValue());
LockStatusDto status = LockStatusDto.rawValueOf(getStatus().getValue());
Hash256Dto secret = SerializationUtils.toHash256Dto(getSecret());
AddressDto recipient = SerializationUtils.toAddressDto(getRecipientAddress());
LockHashAlgorithmDto hashAlgorithm = LockHashAlgorithmDto.rawValueOf((byte) this.hashAlgorithm.getValue());
return SecretLockInfoBuilder.create(version, ownerAddress, mosaic, endHeight, status, hashAlgorithm, secret, recipient).serialize();
}
use of io.nem.symbol.catapult.builders.MosaicBuilder in project nem2-sdk-java by nemtech.
the class HashLockInfo method serialize.
/**
* @return serializes the state of this object.
*/
public byte[] serialize() {
AddressDto ownerAddress = SerializationUtils.toAddressDto(getOwnerAddress());
MosaicBuilder mosaic = MosaicBuilder.create(SerializationUtils.toMosaicIdDto(getMosaicId()), SerializationUtils.toAmount(getAmount()));
HeightDto endHeight = new HeightDto(getEndHeight().longValue());
LockStatusDto status = LockStatusDto.rawValueOf(getStatus().getValue());
Hash256Dto hash = SerializationUtils.toHash256Dto(getHash());
return HashLockInfoBuilder.create((short) getVersion(), ownerAddress, mosaic, endHeight, status, hash).serialize();
}
Aggregations