use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class AggregateTransactionTest method createAAggregateTransactionViaStaticConstructor.
@Test
void createAAggregateTransactionViaStaticConstructor() {
TransferTransaction transferTx = TransferTransaction.create(new Deadline(2, ChronoUnit.HOURS), new Address("SDGLFW-DSHILT-IUHGIB-H5UGX2-VYF5VN-JEKCCD-BR26", NetworkType.MIJIN_TEST), Collections.emptyList(), PlainMessage.Empty, NetworkType.MIJIN_TEST);
AggregateTransaction aggregateTx = AggregateTransaction.createComplete(new Deadline(2, ChronoUnit.HOURS), Arrays.asList(transferTx.toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", NetworkType.MIJIN_TEST))), NetworkType.MIJIN_TEST);
assertEquals(NetworkType.MIJIN_TEST, aggregateTx.getNetworkType());
assertTrue(2 == aggregateTx.getVersion());
assertTrue(LocalDateTime.now().isBefore(aggregateTx.getDeadline().getLocalDateTime()));
assertEquals(BigInteger.valueOf(0), aggregateTx.getFee());
assertEquals(1, aggregateTx.getInnerTransactions().size());
}
use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class MosaicHttp method getMosaics.
@Override
public Observable<List<MosaicInfo>> getMosaics(List<MosaicId> mosaicIds) {
JsonObject requestBody = new JsonObject();
requestBody.put("mosaicIds", mosaicIds.stream().map(id -> UInt64.bigIntegerToHex(id.getId())).collect(Collectors.toList()));
Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
return networkTypeResolve.flatMap(networkType -> this.client.postAbs(this.url + "/mosaic").as(BodyCodec.jsonArray()).rxSendJson(requestBody).toObservable().map(HttpResponse::body).map(json -> objectMapper.<List<MosaicInfoDTO>>readValue(json.toString(), new TypeReference<List<MosaicInfoDTO>>() {
})).flatMapIterable(item -> item).map(mosaicInfoDTO -> new MosaicInfo(mosaicInfoDTO.getMeta().isActive(), mosaicInfoDTO.getMeta().getIndex(), mosaicInfoDTO.getMeta().getId(), new NamespaceId(mosaicInfoDTO.getMosaic().getNamespaceId().extractIntArray()), new MosaicId(mosaicInfoDTO.getMosaic().getMosaicId().extractIntArray()), mosaicInfoDTO.getMosaic().getSupply().extractIntArray(), mosaicInfoDTO.getMosaic().getHeight().extractIntArray(), new PublicAccount(mosaicInfoDTO.getMosaic().getOwner(), networkType), extractMosaicProperties(mosaicInfoDTO.getMosaic().getProperties()))).toList().toObservable());
}
use of io.nem.sdk.model.account.PublicAccount in project nem2-sdk-java by nemtech.
the class NamespaceHttp method getNamespacesFromAccounts.
private Observable<List<NamespaceInfo>> getNamespacesFromAccounts(List<Address> addresses, Optional<QueryParams> queryParams) {
JsonObject requestBody = new JsonObject();
requestBody.put("addresses", addresses.stream().map((address -> address.plain())).collect(Collectors.toList()));
Observable<NetworkType> networkTypeResolve = getNetworkTypeObservable();
return networkTypeResolve.flatMap(networkType -> this.client.postAbs(this.url + "/account/namespaces" + (queryParams.isPresent() ? queryParams.get().toUrl() : "")).as(BodyCodec.jsonArray()).rxSendJson(requestBody).toObservable().map(HttpResponse::body).map(json -> objectMapper.<List<NamespaceInfoDTO>>readValue(json.toString(), new TypeReference<List<NamespaceInfoDTO>>() {
})).flatMapIterable(item -> item).map(namespaceInfoDTO -> new NamespaceInfo(namespaceInfoDTO.getMeta().isActive(), namespaceInfoDTO.getMeta().getIndex(), namespaceInfoDTO.getMeta().getId(), NamespaceType.rawValueOf(namespaceInfoDTO.getNamespace().getType()), namespaceInfoDTO.getNamespace().getDepth(), extractLevels(namespaceInfoDTO), new NamespaceId(namespaceInfoDTO.getNamespace().getParentId().extractIntArray()), new PublicAccount(namespaceInfoDTO.getNamespace().getOwner(), networkType), namespaceInfoDTO.getNamespace().getStartHeight().extractIntArray(), namespaceInfoDTO.getNamespace().getEndHeight().extractIntArray())).toList().toObservable());
}
Aggregations