Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred while requesting height 87704323! #530

Open
Albert-Youngg opened this issue May 7, 2024 · 2 comments
Open

An error occurred while requesting height 87704323! #530

Albert-Youngg opened this issue May 7, 2024 · 2 comments

Comments

@Albert-Youngg
Copy link

com.fasterxml.jackson.databind.JsonMappingException: Cannot construct instance of org.xrpl.xrpl4j.model.transactions.ImmutableIssuedCurrencyAmount$Json (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('10')\n at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: org.xrpl.xrpl4j.model.transactions.ImmutableAmmBid$Json["BidMax"]) (through reference chain: org.xrpl.xrpl4j.model.client.ledger.ImmutableLedgerResult$Json["ledger"]->org.xrpl.xrpl4j.model.ledger.ImmutableLedgerHeader$Json["transactions"]->java.util.ArrayList[13])

@Albert-Youngg
Copy link
Author

use: v3.3.0

public Mono<BlockTx> getBlockTx(Long height, String userAgent) {
    UnsignedInteger ledgerIndex = UnsignedInteger.valueOf(height);
    LedgerSpecifier ledgerSpecifier = LedgerSpecifier.of(ledgerIndex);
    LedgerRequestParams params = LedgerRequestParams.builder()
            .ledgerSpecifier(ledgerSpecifier)
            .transactions(true)
            .build();
    return Mono.fromCallable(() -> client.ledger(params))
            .subscribeOn(Schedulers.boundedElastic())
            .flatMap(result -> {
                if (resultIsSuccess(result)) {
                    LedgerHeader block = result.ledger();
                    long blockTime = block.closeTimeHuman()
                            .map(zdt -> zdt.toInstant().toEpochMilli())
                            .orElse(System.currentTimeMillis());
                    String blockHash = block.ledgerHash().map(Hash256::value).orElse(null);
                    return Mono.just(BlockTx.builder()
                            .blockHeight(height)
                            .blockHash(blockHash)
                            .parentHash(block.parentHash().value())
                            .blockTime(blockTime)
                            .txs(
                                    block.transactions().stream()
                                            .filter(it -> it.transaction().transactionType().equals(TransactionType.PAYMENT))
                                            .map(it -> buildTxByResult(
                                                            (TransactionResult<Payment>) it,
                                                            blockTime,
                                                            height,
                                                            blockHash,
                                                            PaymentStatusEnum.CONFIRMED.getCode()
                                                    )
                                            )
                                            .collect(Collectors.toList())
                            )
                            .build());
                }
                return Mono.error(new RuntimeException("getBlockTx is not success"));
            })
            .onErrorResume(Exception.class, Mono::error);
}

@exp0nge
Copy link

exp0nge commented May 10, 2024

FYI: #529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants