Search in sources :

Example 6 with AddressDto

use of io.nem.symbol.catapult.builders.AddressDto 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();
}
Also used : Hash256Dto(io.nem.symbol.catapult.builders.Hash256Dto) MosaicBuilder(io.nem.symbol.catapult.builders.MosaicBuilder) LockHashAlgorithmDto(io.nem.symbol.catapult.builders.LockHashAlgorithmDto) AddressDto(io.nem.symbol.catapult.builders.AddressDto) HeightDto(io.nem.symbol.catapult.builders.HeightDto) LockStatusDto(io.nem.symbol.catapult.builders.LockStatusDto)

Example 7 with AddressDto

use of io.nem.symbol.catapult.builders.AddressDto 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();
}
Also used : Hash256Dto(io.nem.symbol.catapult.builders.Hash256Dto) MosaicBuilder(io.nem.symbol.catapult.builders.MosaicBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto) HeightDto(io.nem.symbol.catapult.builders.HeightDto) LockStatusDto(io.nem.symbol.catapult.builders.LockStatusDto)

Example 8 with AddressDto

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

the class AccountRestrictions method serialize.

/**
 * @return serializes the state of this object.
 */
public byte[] serialize() {
    AddressDto address = SerializationUtils.toAddressDto(getAddress());
    List<AccountRestrictionsInfoBuilder> restrictions = getRestrictions().stream().map(this::toAccountRestrictionsInfoBuilder).collect(Collectors.toList());
    return AccountRestrictionsBuilder.create((short) getVersion(), address, restrictions).serialize();
}
Also used : AccountRestrictionsInfoBuilder(io.nem.symbol.catapult.builders.AccountRestrictionsInfoBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto)

Example 9 with AddressDto

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

the class MultisigAccountInfo method serialize.

/**
 * @return serializes the state of this object.
 */
public byte[] serialize() {
    int minApproval = (int) getMinApproval();
    int minRemoval = (int) getMinRemoval();
    AddressDto accountAddress = SerializationUtils.toAddressDto(getAccountAddress());
    List<AddressDto> cosignatoryAddresses = getCosignatoryAddresses().stream().map(SerializationUtils::toAddressDto).collect(Collectors.toList());
    List<AddressDto> multisigAddresses = getMultisigAddresses().stream().map(SerializationUtils::toAddressDto).collect(Collectors.toList());
    return MultisigEntryBuilder.create((short) getVersion(), minApproval, minRemoval, accountAddress, cosignatoryAddresses, multisigAddresses).serialize();
}
Also used : AddressDto(io.nem.symbol.catapult.builders.AddressDto)

Example 10 with AddressDto

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

the class NamespaceInfo method serialize.

/**
 * @return serializes the state of this object.
 */
public byte[] serialize(List<NamespaceInfo> fullPath) {
    if (!this.isRoot()) {
        throw new IllegalArgumentException("Namespace must be root in order to serialize!");
    }
    List<NamespaceInfo> children = sortList(fullPath, this.getId());
    if (fullPath.size() != children.size()) {
        throw new IllegalArgumentException("Some of the children do not belong to this root namespace");
    }
    NamespaceIdDto id = new NamespaceIdDto(getId().getIdAsLong());
    AddressDto ownerAddress = SerializationUtils.toAddressDto(getOwnerAddress());
    NamespaceLifetimeBuilder lifetime = NamespaceLifetimeBuilder.create(new HeightDto(getStartHeight().longValue()), new HeightDto(getEndHeight().longValue()));
    NamespaceAliasBuilder rootAlias = getAlias().createAliasBuilder();
    List<NamespacePathBuilder> paths = children.stream().map(this::toNamespaceAliasTypeDto).collect(Collectors.toList());
    RootNamespaceHistoryBuilder builder = RootNamespaceHistoryBuilder.create((short) getVersion(), id, ownerAddress, lifetime, rootAlias, paths);
    return builder.serialize();
}
Also used : NamespaceIdDto(io.nem.symbol.catapult.builders.NamespaceIdDto) RootNamespaceHistoryBuilder(io.nem.symbol.catapult.builders.RootNamespaceHistoryBuilder) NamespaceLifetimeBuilder(io.nem.symbol.catapult.builders.NamespaceLifetimeBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto) HeightDto(io.nem.symbol.catapult.builders.HeightDto) NamespaceAliasBuilder(io.nem.symbol.catapult.builders.NamespaceAliasBuilder) NamespacePathBuilder(io.nem.symbol.catapult.builders.NamespacePathBuilder)

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