use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class MapperUtilsTest method toUnresolvedAddressFromNamespace.
@Test
void toUnresolvedAddressFromNamespace() {
Assertions.assertNull(MapperUtils.toUnresolvedAddress(null));
NamespaceId namespaceId = NamespaceId.createFromName("some.name");
Assertions.assertEquals("91D9E338F78767ED95000000000000000000000000000000", namespaceId.encoded(networkType));
Assertions.assertEquals(namespaceId.encoded(networkType), MapperUtils.toUnresolvedAddress(namespaceId.encoded(networkType)).encoded(networkType));
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImpl method getNamespaceNames.
@Override
public Observable<List<NamespaceName>> getNamespaceNames(List<NamespaceId> namespaceIds) {
NamespaceIds ids = new NamespaceIds().namespaceIds(namespaceIds.stream().map(NamespaceId::getIdAsHex).collect(Collectors.toList()));
Callable<List<NamespaceNameDTO>> callback = () -> getClient().getNamespacesNames(ids);
return exceptionHandling(call(callback).flatMapIterable(item -> item).map(this::toNamespaceName).toList().toObservable());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class AddressAliasTransactionMapper method createFactory.
@Override
protected AddressAliasTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AddressAliasTransactionDTO transaction) {
NamespaceId namespaceId = MapperUtils.toNamespaceId(transaction.getNamespaceId());
AliasAction aliasAction = AliasAction.rawValueOf(transaction.getAliasAction().getValue().byteValue());
return AddressAliasTransactionFactory.create(networkType, deadline, aliasAction, namespaceId, MapperUtils.toAddress(transaction.getAddress()));
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class TransferTransactionTest method serializeNamespaceTransaction.
@Test
void serializeNamespaceTransaction() {
NamespaceId namespaceId = NamespaceId.createFromName("testaccount2");
Assertions.assertEquals("E7CA7E22727DDD88", namespaceId.getIdAsHex());
TransferTransaction transaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), namespaceId, Collections.singletonList(Currency.CAT_CURRENCY.createAbsolute(BigInteger.ONE))).message(new PlainMessage("test-message")).build();
byte[] payload = transaction.serialize();
String payloadHex = ConvertUtils.toHex(payload);
TransferTransaction newTransaction = (TransferTransaction) new BinarySerializationImpl().deserialize(payload);
String newPayloadHex = ConvertUtils.toHex(newTransaction.serialize());
Assertions.assertEquals(transaction.getRecipient().encoded(networkType), newTransaction.getRecipient().encoded(networkType));
Assertions.assertEquals(payloadHex, newPayloadHex);
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceMetadataTransactionMapper method createFactory.
@Override
protected NamespaceMetadataTransactionFactory createFactory(NetworkType networkType, Deadline deadline, NamespaceMetadataTransactionDTO transaction) {
UnresolvedAddress targetAddress = MapperUtils.toUnresolvedAddress(transaction.getTargetAddress());
Integer valueSizeDelta = transaction.getValueSizeDelta();
BigInteger scopedMetaDataKey = MapperUtils.fromHexToBigInteger(transaction.getScopedMetadataKey());
byte[] value = ConvertUtils.fromHexToBytes(transaction.getValue());
NamespaceId targetNamespace = MapperUtils.toNamespaceId(transaction.getTargetNamespaceId());
NamespaceMetadataTransactionFactory factory = NamespaceMetadataTransactionFactory.create(networkType, deadline, targetAddress, targetNamespace, scopedMetaDataKey, value);
factory.valueSizeDelta(valueSizeDelta);
Long valueSize = transaction.getValueSize();
if (valueSize != null) {
factory.valueSize(valueSize);
}
return factory;
}
Aggregations