Search in sources :

Example 1 with AccountKeyTypeFlagsDto

use of io.nem.symbol.catapult.builders.AccountKeyTypeFlagsDto 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();
    }
}
Also used : VotingKeyDto(io.nem.symbol.catapult.builders.VotingKeyDto) KeyDto(io.nem.symbol.catapult.builders.KeyDto) PinnedVotingKeyBuilder(io.nem.symbol.catapult.builders.PinnedVotingKeyBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto) AccountKeyTypeFlagsDto(io.nem.symbol.catapult.builders.AccountKeyTypeFlagsDto) ImportanceHeightDto(io.nem.symbol.catapult.builders.ImportanceHeightDto) HeightDto(io.nem.symbol.catapult.builders.HeightDto) AccountTypeDto(io.nem.symbol.catapult.builders.AccountTypeDto) ImportanceDto(io.nem.symbol.catapult.builders.ImportanceDto) ImportanceHeightDto(io.nem.symbol.catapult.builders.ImportanceHeightDto) MosaicBuilder(io.nem.symbol.catapult.builders.MosaicBuilder) ImportanceSnapshotBuilder(io.nem.symbol.catapult.builders.ImportanceSnapshotBuilder) HeightActivityBucketsBuilder(io.nem.symbol.catapult.builders.HeightActivityBucketsBuilder)

Aggregations

AccountKeyTypeFlagsDto (io.nem.symbol.catapult.builders.AccountKeyTypeFlagsDto)1 AccountTypeDto (io.nem.symbol.catapult.builders.AccountTypeDto)1 AddressDto (io.nem.symbol.catapult.builders.AddressDto)1 HeightActivityBucketsBuilder (io.nem.symbol.catapult.builders.HeightActivityBucketsBuilder)1 HeightDto (io.nem.symbol.catapult.builders.HeightDto)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 MosaicBuilder (io.nem.symbol.catapult.builders.MosaicBuilder)1 PinnedVotingKeyBuilder (io.nem.symbol.catapult.builders.PinnedVotingKeyBuilder)1 VotingKeyDto (io.nem.symbol.catapult.builders.VotingKeyDto)1