use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class MosaicAliasTransactionMapper method createFactory.
@Override
protected TransactionFactory<MosaicAliasTransaction> createFactory(NetworkType networkType, Deadline deadline, MosaicAliasTransactionDTO transaction) {
NamespaceId namespaceId = MapperUtils.toNamespaceId(transaction.getNamespaceId());
AliasAction aliasAction = AliasAction.rawValueOf(transaction.getAliasAction().getValue().byteValue());
return MosaicAliasTransactionFactory.create(networkType, deadline, aliasAction, namespaceId, MapperUtils.toMosaicId(transaction.getMosaicId()));
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest method getNamespaceMerkle.
@Test
public void getNamespaceMerkle() throws Exception {
NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
mockRemoteCall(new MerkleStateInfoDTO().raw("abc"));
MerkleStateInfo merkle = repository.getNamespaceMerkle(namespaceId).toFuture().get();
Assertions.assertEquals("abc", merkle.getRaw());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest method shouldGetNamespaceNames.
@Test
public void shouldGetNamespaceNames() throws Exception {
NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
NamespaceNameDTO dto1 = new NamespaceNameDTO();
dto1.setName("someName1");
dto1.setId("1");
dto1.setParentId("2");
NamespaceNameDTO dto2 = new NamespaceNameDTO();
dto2.setName("someName2");
dto2.setId("3");
mockRemoteCall(Arrays.asList(dto1, dto2));
List<NamespaceName> names = repository.getNamespaceNames(Arrays.asList(namespaceId)).toFuture().get();
Assertions.assertNotNull(names);
Assertions.assertEquals(2, names.size());
Assertions.assertEquals("someName1", names.get(0).getName());
Assertions.assertEquals(BigInteger.valueOf(1L), names.get(0).getNamespaceId().getId());
Assertions.assertEquals(BigInteger.valueOf(2L), names.get(0).getParentId().orElseThrow(() -> new IllegalStateException("No parent id")).getId());
Assertions.assertEquals("someName2", names.get(1).getName());
Assertions.assertEquals(BigInteger.valueOf(3L), names.get(1).getNamespaceId().getId());
Assertions.assertFalse(names.get(1).getParentId().isPresent());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceRepositoryOkHttpImplTest method shouldGetLinkedMosaicId.
@Test
public void shouldGetLinkedMosaicId() throws Exception {
Address ownerAccount = Account.generateNewAccount(NetworkType.MIJIN_TEST).getAddress();
NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
NamespaceInfoDTO dto = new NamespaceInfoDTO();
NamespaceMetaDTO meta = new NamespaceMetaDTO();
meta.setActive(true);
dto.setId("SomeId");
meta.setIndex(123);
dto.setMeta(meta);
NamespaceDTO namespace = new NamespaceDTO();
namespace.setDepth(111);
namespace.setRegistrationType(NamespaceRegistrationTypeEnum.NUMBER_0);
namespace.setOwnerAddress(ownerAccount.encoded());
AliasDTO alias = new AliasDTO();
alias.setType(AliasTypeEnum.NUMBER_1);
alias.setMosaicId("528280977531AAA");
namespace.setAlias(alias);
dto.setNamespace(namespace);
mockRemoteCall(dto);
MosaicId linkedMosaicId = repository.getLinkedMosaicId(namespaceId).toFuture().get();
Assertions.assertNotNull(linkedMosaicId);
Assertions.assertEquals(MapperUtils.fromHexToBigInteger("528280977531AAA"), linkedMosaicId.getId());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class CurrencyServiceImpl method getCurrency.
/**
* Creates a network currency model given mosaic info and mosaic names
*/
private Currency getCurrency(MosaicInfo mosaicInfo, List<MosaicNames> mosaicNamesList) {
MosaicId mosaicId = mosaicInfo.getMosaicId();
Optional<String> namespaceName = getName(mosaicNamesList, mosaicId);
Optional<NamespaceId> namespaceId = namespaceName.map(NamespaceId::createFromName);
return createCurrency(mosaicInfo, namespaceId).build();
}
Aggregations