use of io.nem.symbol.catapult.builders.ReceiptTypeDto 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.ReceiptTypeDto 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.ReceiptTypeDto in project nem2-sdk-java by nemtech.
the class InflationReceipt 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()));
return InflationReceiptBuilder.create(version, type, mosaic).serialize();
}
use of io.nem.symbol.catapult.builders.ReceiptTypeDto in project nem2-sdk-java by nemtech.
the class ResolutionStatement method serialize.
/**
* Serializes the statement using the catuffer builders
*
* @param networkType the network type.
* @return the serialized content.
*/
private byte[] serialize(NetworkType networkType) {
ReceiptType type = this.resolutionType == ResolutionType.ADDRESS ? ReceiptType.ADDRESS_ALIAS_RESOLUTION : ReceiptType.MOSAIC_ALIAS_RESOLUTION;
ReceiptTypeDto recipientTypeDto = ReceiptTypeDto.rawValueOf((short) type.getValue());
short version = (short) ReceiptVersion.RESOLUTION_STATEMENT.getValue();
Serializer serializer = this.resolutionType == ResolutionType.ADDRESS ? AddressResolutionStatementBuilder.create(version, recipientTypeDto, SerializationUtils.toUnresolvedAddress((UnresolvedAddress) this.unresolved, networkType), this.resolutionEntries.stream().map((entry) -> AddressResolutionEntryBuilder.create(ReceiptSourceBuilder.create((int) entry.getReceiptSource().getPrimaryId(), (int) entry.getReceiptSource().getSecondaryId()), SerializationUtils.toAddressDto((Address) entry.getResolved()))).collect(Collectors.toList())) : MosaicResolutionStatementBuilder.create(version, recipientTypeDto, SerializationUtils.toUnresolvedMosaicIdDto((UnresolvedMosaicId) this.unresolved), this.resolutionEntries.stream().map((entry) -> MosaicResolutionEntryBuilder.create(ReceiptSourceBuilder.create((int) entry.getReceiptSource().getPrimaryId(), (int) entry.getReceiptSource().getSecondaryId()), SerializationUtils.toMosaicIdDto((MosaicId) entry.getResolved()))).collect(Collectors.toList()));
return serializer.serialize();
}
use of io.nem.symbol.catapult.builders.ReceiptTypeDto in project nem2-sdk-java by nemtech.
the class ArtifactExpiryReceipt method serialize.
/**
* Serialize receipt and returns receipt bytes
*
* @return receipt bytes
*/
public byte[] serialize() {
short version = (short) getVersion().getValue();
ReceiptTypeDto type = ReceiptTypeDto.rawValueOf((short) getType().getValue());
if (this.artifactId instanceof MosaicId) {
return MosaicExpiryReceiptBuilder.create(version, type, new MosaicIdDto(getArtifactIdValue().longValue())).serialize();
} else {
return NamespaceExpiryReceiptBuilder.create(version, type, new NamespaceIdDto(getArtifactIdValue().longValue())).serialize();
}
}
Aggregations