use of io.nem.symbol.catapult.builders.HeightDto 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.HeightDto 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();
}
use of io.nem.symbol.catapult.builders.HeightDto 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.HeightDto 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();
}
use of io.nem.symbol.catapult.builders.HeightDto 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();
}
Aggregations