Search in sources :

Example 11 with AddressDto

use of io.nem.symbol.catapult.builders.AddressDto in project nem2-sdk-java by nemtech.

the class Metadata method serialize.

/**
 * @return serializes the state of this object.
 */
public byte[] serialize() {
    AddressDto sourceAddress = SerializationUtils.toAddressDto(getSourceAddress());
    AddressDto targetAddress = SerializationUtils.toAddressDto(getTargetAddress());
    ScopedMetadataKeyDto scopedMetadataKey = new ScopedMetadataKeyDto(getScopedMetadataKey().longValue());
    long targetId = getTargetId().map(this::toTargetId).orElse(0L);
    MetadataTypeDto metadataType = MetadataTypeDto.rawValueOf((byte) getMetadataType().getValue());
    MetadataValueBuilder value = toMetadataValueBuilder(getValue());
    return MetadataEntryBuilder.create((short) getVersion(), sourceAddress, targetAddress, scopedMetadataKey, targetId, metadataType, value).serialize();
}
Also used : MetadataValueBuilder(io.nem.symbol.catapult.builders.MetadataValueBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto) ScopedMetadataKeyDto(io.nem.symbol.catapult.builders.ScopedMetadataKeyDto) MetadataTypeDto(io.nem.symbol.catapult.builders.MetadataTypeDto)

Example 12 with AddressDto

use of io.nem.symbol.catapult.builders.AddressDto in project nem2-sdk-java by nemtech.

the class MosaicInfo method serialize.

/**
 * @return serializes the state of the mosaic.
 */
public byte[] serialize() {
    MosaicIdDto mosaicId = SerializationUtils.toMosaicIdDto(getMosaicId());
    AmountDto supply = SerializationUtils.toAmount(getSupply());
    HeightDto startHeight = new HeightDto(getStartHeight().longValue());
    AddressDto ownerAddress = SerializationUtils.toAddressDto(getOwnerAddress());
    int revision = (int) getRevision();
    EnumSet<MosaicFlagsDto> flags = SerializationUtils.getMosaicFlagsEnumSet(this.getMosaicFlags());
    MosaicPropertiesBuilder properties = MosaicPropertiesBuilder.create(flags, (byte) getDivisibility(), new BlockDurationDto(getDuration().longValue()));
    MosaicDefinitionBuilder definition = MosaicDefinitionBuilder.create(startHeight, ownerAddress, revision, properties);
    return MosaicEntryBuilder.create((short) getVersion(), mosaicId, supply, definition).serialize();
}
Also used : MosaicDefinitionBuilder(io.nem.symbol.catapult.builders.MosaicDefinitionBuilder) BlockDurationDto(io.nem.symbol.catapult.builders.BlockDurationDto) MosaicIdDto(io.nem.symbol.catapult.builders.MosaicIdDto) MosaicFlagsDto(io.nem.symbol.catapult.builders.MosaicFlagsDto) AmountDto(io.nem.symbol.catapult.builders.AmountDto) AddressDto(io.nem.symbol.catapult.builders.AddressDto) MosaicPropertiesBuilder(io.nem.symbol.catapult.builders.MosaicPropertiesBuilder) HeightDto(io.nem.symbol.catapult.builders.HeightDto)

Aggregations

AddressDto (io.nem.symbol.catapult.builders.AddressDto)12 HeightDto (io.nem.symbol.catapult.builders.HeightDto)5 MosaicBuilder (io.nem.symbol.catapult.builders.MosaicBuilder)5 MosaicIdDto (io.nem.symbol.catapult.builders.MosaicIdDto)5 Hash256Dto (io.nem.symbol.catapult.builders.Hash256Dto)2 LockStatusDto (io.nem.symbol.catapult.builders.LockStatusDto)2 ReceiptTypeDto (io.nem.symbol.catapult.builders.ReceiptTypeDto)2 AccountKeyTypeFlagsDto (io.nem.symbol.catapult.builders.AccountKeyTypeFlagsDto)1 AccountRestrictionsInfoBuilder (io.nem.symbol.catapult.builders.AccountRestrictionsInfoBuilder)1 AccountTypeDto (io.nem.symbol.catapult.builders.AccountTypeDto)1 AddressKeyValueSetBuilder (io.nem.symbol.catapult.builders.AddressKeyValueSetBuilder)1 AddressResolutionEntryBuilder (io.nem.symbol.catapult.builders.AddressResolutionEntryBuilder)1 AmountDto (io.nem.symbol.catapult.builders.AmountDto)1 BlockDurationDto (io.nem.symbol.catapult.builders.BlockDurationDto)1 HeightActivityBucketsBuilder (io.nem.symbol.catapult.builders.HeightActivityBucketsBuilder)1 ImportanceDto (io.nem.symbol.catapult.builders.ImportanceDto)1 ImportanceHeightDto (io.nem.symbol.catapult.builders.ImportanceHeightDto)1 ImportanceSnapshotBuilder (io.nem.symbol.catapult.builders.ImportanceSnapshotBuilder)1 KeyDto (io.nem.symbol.catapult.builders.KeyDto)1 LockHashAlgorithmDto (io.nem.symbol.catapult.builders.LockHashAlgorithmDto)1