OpenElements / hedera-enterprise

Module for Spring that adds support to communicate with the Hedera network
Apache License 2.0
5 stars 14 forks source link

Implement MirrorNodeClient.queryTransaction #26

Open hendrikebbers opened 2 months ago

hendrikebbers commented 2 months ago

πŸ†•πŸ₯ First Timers Only

This issue is reserved for people who have never contributed to this project or any open source project in general. We know that creating a pull request (PR) is a major barrier for new contributors. The goal of this issue and all other issues labeled by 'good first issue' is to help you make your first contribution.

πŸ‘Ύ Description of the issue

The interface MirrorNodeClient provides the method Optional<TransactionInfo> queryTransaction(@NonNull String transactionId). The implementation of the method in MirrorNodeClientImpl calls the Mirror Node REST API but do not use the result of that call. Instead, only a record containing the transactionId as String is returned (see TransactionInfo).

When doing a call against the REST API way more information about a transaction are returned as you can see in the following sample

Query:

curl -X 'GET' \
  'https://testnet.mirrornode.hedera.com/api/v1/transactions/0.0.4457569-1724503621-738000000?nonce=0' \
  -H 'accept: application/json'

Result:

{
  "transactions": [
    {
      "bytes": null,
      "charged_tx_fee": 66529172,
      "consensus_timestamp": "1724503632.496534574",
      "entity_id": "0.0.4738897",
      "max_fee": "1000000000",
      "memo_base64": "",
      "name": "TOKENMINT",
      "nft_transfers": [
        {
          "is_approval": false,
          "receiver_account_id": "0.0.4457569",
          "sender_account_id": null,
          "serial_number": 1,
          "token_id": "0.0.4738897"
        },
        {
          "is_approval": false,
          "receiver_account_id": "0.0.4457569",
          "sender_account_id": null,
          "serial_number": 2,
          "token_id": "0.0.4738897"
        }
      ],
      "node": "0.0.7",
      "nonce": 0,
      "parent_consensus_timestamp": null,
      "result": "SUCCESS",
      "scheduled": false,
      "staking_reward_transfers": [],
      "token_transfers": [],
      "transaction_hash": "VwgHwtzwU23H2mNaX0hl9lo1ZZQ+6VqGOrzqIzfz6D2KHUHgmGfzmTwStFAS2eza",
      "transaction_id": "0.0.4457569-1724503621-738000000",
      "transfers": [
        {
          "account": "0.0.7",
          "amount": 13305834,
          "is_approval": false
        },
        {
          "account": "0.0.98",
          "amount": 47901005,
          "is_approval": false
        },
        {
          "account": "0.0.800",
          "amount": 5322333,
          "is_approval": false
        },
        {
          "account": "0.0.4457569",
          "amount": -66529172,
          "is_approval": false
        }
      ],
      "valid_duration_seconds": "120",
      "valid_start_timestamp": "1724503621.738000000"
    }
  ]
}

The additional information should be added to the TransactionInfo record.

Suggestion for solving the issue

In the MirrorNodeClientImpl class you can already find several samples on how a JSON response of a REST call is parsed and transfered in a custom method return type. The same should be done in the Optional<TransactionInfo> queryTransaction(@NonNull String transactionId) method and TransactionInfo should become a rich object that is based on all the information coming from JSON.

Additional information

Information about the rest api of the mirror node can be found here. The API can be accessed by Swagger UI. The Swagger UI frontend for testnet can be found here.

πŸ“‹ Step by step guide to do a contribution

If you have never contributed to an open source project at GitHub, the following step-by-step guide will introduce you to the workflow. A more detailed general documentation of the GitHub PR workflow can be found here.

πŸŽ‰ Contribute to Hacktoberfest

Solve this issue as part of the Hacktoberfest event and get a chance to receive cool goodies like a T-Shirt. 🎽

πŸ€” Additional informantion

If you have any questions, just ask us directly in this issue by adding a comment. You can join the Hedera community chat at Discord. A general manual about open-source contributions can be found here.

toficzak commented 2 months ago

Hey, seems like an easy introduction task :) I would gladly try my best to solve this.

From my understanding, I should:

hendrikebbers commented 2 months ago

agree :)

toficzak commented 2 months ago

My situation changed, I do not have time right now to participate in any project. Sorry for inconvenience.

Ashleycodesseo commented 1 month ago

Hey @hendrikebbers do you need help with any REST API documentation? I'm looking to get some experience documenting so if you need help please let me know! Thank you

Ndacyayisenga-droid commented 1 month ago

@Ashleycodesseo did you mean you are interested on working on this issue?

Ariho-Seth commented 1 month ago

Hello @Ndacyayisenga-droid can you please assign me this issue, if no one has worked on it.

Ariho-Seth commented 3 weeks ago

Hello @hendrikebbers I worked on this issue and was able to finish all the possible suggestions but when I try running the mvn clean install , it yields a BUILD FAILURE due to some failed tests in some other module of which I didn't edit any file in that module. So am trying to follow up those issues that why I haven't submitted the PR If you can offer any help or prepare a zoom meeting together to help me debug my code , I will be happy ThanksπŸ™

Ariho-Seth commented 3 weeks ago

Hello @Ndacyayisenga-droid please help me here

Ndacyayisenga-droid commented 3 weeks ago

Hello @Ndacyayisenga-droid please help me here

@Ariho-Seth I think you dont have enough HBARs on your testnet account to run all tests in this repo. You can use mvn clean install -DskipTests. For testing, run individual tests in your ide

Ndacyayisenga-droid commented 3 weeks ago

Alternatively, you can test your code in your fork using the current github workflow since github has enough HBARs for that. Like we did last time we had a call