Search in sources :

Example 1 with TransactionStatement

use of io.nem.symbol.sdk.model.receipt.TransactionStatement in project nem2-sdk-java by nemtech.

the class ReceiptRepositoryOkHttpImpl method searchReceipts.

@Override
public Observable<Page<TransactionStatement>> searchReceipts(TransactionStatementSearchCriteria criteria) {
    BigInteger height = criteria.getHeight();
    BigInteger fromHeight = criteria.getFromHeight();
    BigInteger toHeight = criteria.getToHeight();
    List<ReceiptTypeEnum> receiptTypes = toDto(criteria.getReceiptTypes());
    String recipientAddress = toDto(criteria.getRecipientAddress());
    String senderAddress = toDto(criteria.getSenderAddress());
    String targetAddress = toDto(criteria.getTargetAddress());
    String artifactId = criteria.getArtifactId();
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    Callable<TransactionStatementPage> callback = () -> getClient().searchReceipts(height, fromHeight, toHeight, receiptTypes, recipientAddress, senderAddress, targetAddress, artifactId, pageSize, pageNumber, offset, order);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createTransactionStatement).collect(Collectors.toList()))));
}
Also used : BigInteger(java.math.BigInteger) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementPage) ReceiptTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.ReceiptTypeEnum) ReceiptRoutesApi(io.nem.symbol.sdk.openapi.okhttp_gson.api.ReceiptRoutesApi) ApiClient(io.nem.symbol.sdk.openapi.okhttp_gson.invoker.ApiClient) Callable(java.util.concurrent.Callable) Collectors(java.util.stream.Collectors) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptType(io.nem.symbol.sdk.model.receipt.ReceiptType) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) ResolutionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementPage) List(java.util.List) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Page(io.nem.symbol.sdk.api.Page) TransactionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementPage) BigInteger(java.math.BigInteger) ReceiptTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.ReceiptTypeEnum)

Example 2 with TransactionStatement

use of io.nem.symbol.sdk.model.receipt.TransactionStatement in project nem2-sdk-java by nemtech.

the class ReceiptRepositoryTransactionSearchIntegrationTest method assertRecipientType.

List<TransactionStatement> assertRecipientType(RepositoryType type, List<ReceiptType> receiptTypes) {
    ReceiptRepository receiptRepository = getReceiptRepository(type);
    PaginationStreamer<TransactionStatement, TransactionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.transactions(receiptRepository);
    List<TransactionStatement> transactionStatements = get(streamer.search(new TransactionStatementSearchCriteria().receiptTypes(receiptTypes)).toList().toObservable());
    transactionStatements.forEach(s -> Assertions.assertTrue(s.getReceipts().stream().anyMatch(r -> (receiptTypes.contains(r.getType())))));
    return transactionStatements;
}
Also used : TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement)

Example 3 with TransactionStatement

use of io.nem.symbol.sdk.model.receipt.TransactionStatement in project nem2-sdk-java by nemtech.

the class ReceiptMappingOkHttpTest method getTransactionStatements2Recipients.

@Test
public void getTransactionStatements2Recipients() {
    List<TransactionStatementInfoDTO> transactionStatementInfoDTOS = jsonHelper.parseList(TestHelperOkHttp.loadResource("Recipient-TransactionResolutionStatement.json"), TransactionStatementInfoDTO.class);
    List<TransactionStatement> transactionStatements = transactionStatementInfoDTOS.stream().map(mapper::createTransactionStatement).collect(Collectors.toList());
    TransactionStatement transactionStatement = transactionStatements.get(1);
    Assertions.assertEquals("41BF730BD307EB507880CA0576A4CCEFEF95F3060DC334CA364AE737114D1F60", transactionStatement.generateHash().toUpperCase());
    List<Receipt> receipts = transactionStatement.getReceipts();
    Assertions.assertEquals(5, receipts.size());
    Assertions.assertEquals(ReceiptType.NAMESPACE_RENTAL_FEE, receipts.get(0).getType());
    Assertions.assertEquals("85BBEA6CC462B244", ((BalanceTransferReceipt) receipts.get(0)).getMosaicId().getIdAsHex());
    Assertions.assertEquals(ReceiptType.MOSAIC_EXPIRED, receipts.get(1).getType());
    Assertions.assertEquals(MosaicId.class, ((ArtifactExpiryReceipt) receipts.get(1)).getArtifactId().getClass());
    Assertions.assertEquals(ReceiptType.NAMESPACE_EXPIRED, receipts.get(2).getType());
    Assertions.assertEquals(NamespaceId.class, ((ArtifactExpiryReceipt) receipts.get(2)).getArtifactId().getClass());
    Assertions.assertEquals(ReceiptType.NAMESPACE_DELETED, receipts.get(3).getType());
    Assertions.assertEquals(NamespaceId.class, ((ArtifactExpiryReceipt) receipts.get(3)).getArtifactId().getClass());
    Assertions.assertEquals(ReceiptType.INFLATION, receipts.get(4).getType());
    Assertions.assertEquals(333, ((InflationReceipt) receipts.get(4)).getAmount().longValue());
}
Also used : BalanceTransferReceipt(io.nem.symbol.sdk.model.receipt.BalanceTransferReceipt) Receipt(io.nem.symbol.sdk.model.receipt.Receipt) ArtifactExpiryReceipt(io.nem.symbol.sdk.model.receipt.ArtifactExpiryReceipt) InflationReceipt(io.nem.symbol.sdk.model.receipt.InflationReceipt) InflationReceipt(io.nem.symbol.sdk.model.receipt.InflationReceipt) TransactionStatementInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementInfoDTO) ArtifactExpiryReceipt(io.nem.symbol.sdk.model.receipt.ArtifactExpiryReceipt) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) BalanceTransferReceipt(io.nem.symbol.sdk.model.receipt.BalanceTransferReceipt) Test(org.junit.jupiter.api.Test)

Example 4 with TransactionStatement

use of io.nem.symbol.sdk.model.receipt.TransactionStatement in project nem2-sdk-java by nemtech.

the class BlockRepositoryIntegrationTest method getMerkleReceiptsFromTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMerkleReceiptsFromTransactions(RepositoryType type) {
    BlockRepository blockRepository = getBlockRepository(type);
    ReceiptRepository receiptRepository = getRepositoryFactory(type).createReceiptRepository();
    PaginationStreamer<TransactionStatement, TransactionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.transactions(receiptRepository);
    List<TransactionStatement> list = get(streamer.search(new TransactionStatementSearchCriteria()).take(5).toList().toObservable());
    System.out.println(list.size());
    list.forEach(s -> {
        String hash = s.generateHash();
        System.out.println(hash);
        System.out.println(s.getHeight());
        MerkleProofInfo merkleProofInfo = get(blockRepository.getMerkleReceipts(s.getHeight(), hash));
        System.out.println(toJson(merkleProofInfo));
    });
}
Also used : TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) BlockRepository(io.nem.symbol.sdk.api.BlockRepository) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with TransactionStatement

use of io.nem.symbol.sdk.model.receipt.TransactionStatement in project nem2-sdk-java by nemtech.

the class ReceiptRepositoryVertxImplTest method searchReceipts.

@Test
public void searchReceipts() throws Exception {
    List<TransactionStatementInfoDTO> transactionStatementInfoDTOS = jsonHelper.parseList(TestHelperVertx.loadResource("Recipient-TransactionResolutionStatement.json"), TransactionStatementInfoDTO.class);
    mockRemoteCall(toPage(transactionStatementInfoDTOS));
    BigInteger height = BigInteger.valueOf(10L);
    List<TransactionStatement> transactionStatements = repository.searchReceipts(new TransactionStatementSearchCriteria().height(height).receiptTypes(Collections.singletonList(ReceiptType.MOSAIC_ALIAS_RESOLUTION))).toFuture().get().getData();
    Assertions.assertEquals(transactionStatementInfoDTOS.size(), transactionStatements.size());
    Assertions.assertEquals("82FEFFC329618ECF56B8A6FDBCFCF1BF0A4B6747AB6A5746B195CEEB810F335C", transactionStatements.get(0).generateHash().toUpperCase());
}
Also used : TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) TransactionStatementInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionStatementInfoDTO) BigInteger(java.math.BigInteger) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionStatement (io.nem.symbol.sdk.model.receipt.TransactionStatement)8 TransactionStatementSearchCriteria (io.nem.symbol.sdk.api.TransactionStatementSearchCriteria)6 ReceiptRepository (io.nem.symbol.sdk.api.ReceiptRepository)4 BigInteger (java.math.BigInteger)4 Test (org.junit.jupiter.api.Test)4 Page (io.nem.symbol.sdk.api.Page)2 ResolutionStatementSearchCriteria (io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria)2 AddressResolutionStatement (io.nem.symbol.sdk.model.receipt.AddressResolutionStatement)2 ArtifactExpiryReceipt (io.nem.symbol.sdk.model.receipt.ArtifactExpiryReceipt)2 BalanceTransferReceipt (io.nem.symbol.sdk.model.receipt.BalanceTransferReceipt)2 InflationReceipt (io.nem.symbol.sdk.model.receipt.InflationReceipt)2 MosaicResolutionStatement (io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement)2 Receipt (io.nem.symbol.sdk.model.receipt.Receipt)2 ReceiptType (io.nem.symbol.sdk.model.receipt.ReceiptType)2 TransactionStatementInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementInfoDTO)2 TransactionStatementInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.TransactionStatementInfoDTO)2 Observable (io.reactivex.Observable)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 BlockRepository (io.nem.symbol.sdk.api.BlockRepository)1