use of io.nem.symbol.catapult.builders.MosaicIdDto 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.MosaicIdDto in project nem2-sdk-java by nemtech.
the class MosaicGlobalRestriction method toGlobalKeyValueSetBuilder.
private GlobalKeyValueBuilder toGlobalKeyValueSetBuilder(Entry<BigInteger, MosaicGlobalRestrictionItem> entry) {
MosaicRestrictionKeyDto key = new MosaicRestrictionKeyDto(entry.getKey().longValue());
MosaicIdDto referenceMosaicId = SerializationUtils.toMosaicIdDto(entry.getValue().getReferenceMosaicId());
long restrictionValue = entry.getValue().getRestrictionValue().longValue();
MosaicRestrictionTypeDto restrictionType = MosaicRestrictionTypeDto.rawValueOf(entry.getValue().getRestrictionType().getValue());
RestrictionRuleBuilder restrictionRule = RestrictionRuleBuilder.create(referenceMosaicId, restrictionValue, restrictionType);
return GlobalKeyValueBuilder.create(key, restrictionRule);
}
use of io.nem.symbol.catapult.builders.MosaicIdDto 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();
}
use of io.nem.symbol.catapult.builders.MosaicIdDto 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();
}
}
use of io.nem.symbol.catapult.builders.MosaicIdDto in project nem2-sdk-java by nemtech.
the class ArtifactExpiryReceiptTest method shouldMosaicExpiryReceiptBuilderSerialize.
@Test
void shouldMosaicExpiryReceiptBuilderSerialize() {
MosaicId mosaicId = new MosaicId("85BBEA6CC462B244");
MosaicExpiryReceiptBuilder builder = MosaicExpiryReceiptBuilder.create((short) 1, ReceiptTypeDto.INFLATION, new MosaicIdDto(mosaicId.getId().longValue()));
byte[] serialize = builder.serialize();
// NOTE, size must be ignored for some reason!
Assertions.assertEquals(12, serialize.length);
Assertions.assertEquals(16, builder.getSize());
String hex = ConvertUtils.toHex(serialize);
Assertions.assertEquals("0100435144B262C46CEABB85", hex);
}
Aggregations