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

feat: Add transaction message filter in GraphQL #20

Merged

Conversation

jinoosss
Copy link
Member

@jinoosss jinoosss commented Apr 1, 2024

Description

I added the data that is fetched by the query.
Then I decoded and processed the data in std.Tx and added filterable parameters.

  • Add transaction message data
  • Implement the filtering functions of the transaction filter model
  • Separate the GraphQL schema

Example Usage

Querying transaction messages

{
  transactions(filter: {}) {
    hash
    # messages 
    messages {
      route
      typeUrl
      value {
        # Data in bank.MsgSend to query  
        ... on BankMsgSend {
          from_address
          to_address
          amount
        }

        # Data in vm.m_call to query  
        ... on MsgCall {
          send
          pkg_path
          func
          caller
          args
        }

        # Data in vm.m_addpkg to query  
        ... on MsgAddPackage {
          creator
          package {
            Name
            Path
            Files {
              Name
              Body
            }
          }
          deposit
        }

        # Data in vm.m_run to query  
        ... on MsgRun {
          caller
          send
          package {
            Name
            Path
            Files {
              Name
              Body
            }
          }
        }
      }
    }
  }
}

Filter transactio messages

{
  transactions(
    filter: {
      message: {
        route: bank 		# bank / vm
        type_url:  send	# send / exec / add_pacakge / run

        # Parameters for messages with route as `bank`  
        bank_param: {
          send: {
            # ...
          }
        }

        # Parameters for messages with route as `vm`
        vm_param: {
          m_call: {
            # ...
          }
          m_addpkg: {
            # ...
          }
          m_run: {
            # ...
          }
        }
      }
    }
  ) {
    hash
  }
}

image

@jinoosss jinoosss added the enhancement New feature or request label Apr 1, 2024
@jinoosss jinoosss self-assigned this Apr 1, 2024
@jinoosss jinoosss requested a review from a team as a code owner April 1, 2024 05:16
Copy link
Collaborator

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature added seems ok, but it is really difficult to review because we have on the same PR a refactoring and a feature.

I would suggest keeping this PR as a feature implementation and avoiding refactors on the code.

gqlgen.yml Show resolved Hide resolved
gqlgen.yml Outdated Show resolved Hide resolved
gqlgen.yml Outdated Show resolved Hide resolved
gqlgen.yml Outdated Show resolved Hide resolved
serve/graph/model/block_filter.go Outdated Show resolved Hide resolved
serve/graph/model/models_gen.go Outdated Show resolved Hide resolved
serve/graph/model/models_gen.go Outdated Show resolved Hide resolved
serve/graph/model/models_gen.go Outdated Show resolved Hide resolved
serve/graph/model/transaction.go Show resolved Hide resolved
serve/graph/model/utils.go Outdated Show resolved Hide resolved
@jinoosss
Copy link
Member Author

jinoosss commented Apr 2, 2024

@ajnavarro,
Thank you for your thorough review 🙏

Your comments have given me some direction.
It seems that the model is sufficient as a data passer, and I've changed it so that the resolver can handle the functionality.

@jinoosss jinoosss force-pushed the feature/add-transaction-message-filter branch from 1f17630 to b11d85c Compare April 3, 2024 01:36
@jinoosss jinoosss requested a review from ajnavarro April 3, 2024 01:36
Copy link
Collaborator

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good work you did here. Just a few more comments UX related, and performance-related.

Thank you very much!

serve/graph/schema/types/transaction.graphql Outdated Show resolved Hide resolved
serve/graph/schema/types/transaction.graphql Outdated Show resolved Hide resolved
serve/graph/schema/filter/transaction_filter.graphql Outdated Show resolved Hide resolved
serve/graph/schema/filter/transaction_filter.graphql Outdated Show resolved Hide resolved
serve/graph/schema/filter/transaction_filter.graphql Outdated Show resolved Hide resolved
serve/graph/subscription.resolvers.go Outdated Show resolved Hide resolved
serve/graph/model/transaction.go Outdated Show resolved Hide resolved
serve/graph/model/transaction.go Outdated Show resolved Hide resolved
@jinoosss jinoosss requested a review from ajnavarro April 4, 2024 12:15
Copy link
Collaborator

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from a final request:

@ajnavarro
Copy link
Collaborator

ajnavarro commented Apr 5, 2024

I had been playing with the new GraphQL API and it is amazing the amount of info you can get, and how fast it is. I just added minor comments on schema parameters that are using uppercase moving them to lowercase for consistency.

🎉

jinoosss and others added 6 commits April 8, 2024 10:10
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone through @ajnavarro's comments after my own review, and have to say that this looks amazing 💯

Thank you for contributing back to the tool, it really means a lot to the team 🙏

@jinoosss jinoosss merged commit 0ad639a into gnolang:main Apr 8, 2024
3 checks passed
@jinoosss jinoosss deleted the feature/add-transaction-message-filter branch April 8, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants