Code Monkey home page Code Monkey logo

Comments (14)

RiccardoM avatar RiccardoM commented on June 1, 2024 2

@ryuash I've decided to solve this using Hasura custom functions. You can now query messages by a given address and which type is contained in a given array of types:

query MessageByAccount {
  messages_by_address(
    args:{
      addresses:"{desmosvaloper14dm0zdemeymhayucp7gchuus3k5m344f0p084p}",
      types:"{}",
      limit:1,
      offset: 0
    },
  ) {
    type
    involved_accounts_addresses
  }
}

Arguments

  • addresses
    Array of addresses which should be searched for. The resulting messages will have the involved_accounts_addresses array containing any of these addresses. This is particularly useful for validators, where you can supply both desmos1.. and desmosvaloper1... addresses here. For accounts, you can simply pass only the desmos1... address.
    Note that this is an array value, and thus it must provided as {value1, value2, ...}.
    This argument is mandatory and cannot be skipped.
    Providing an empty addresses will result in an empty result.

  • types
    Array of types which should be searched for. The resulting messages will have the type that is any of the provided values. This is particularly useful when filtering for module, where you can supply for example "{cosmos.staking.v1beta1.MsgCreateValidator, cosmos.staking.v1beta1.MsgEditValidator}.
    This is an array, thus its value must be provided as {value1, value2, ...}.
    This argument is mandatory and cannot be skipped.
    Providing an empty types ({}) will result in all types being valid.

  • limit
    Limits the number of resulting rows.
    This parameter is optional* with default value 100.

  • offset
    Offsets the limit by the specified amount.
    This parameter is optional* with default value 0.

Note
All the returned rows are sorted by height in a descending fashion.

from callisto.

kwunyeung avatar kwunyeung commented on June 1, 2024

@ryuash you can query txs with the delegator_address as the structure of the tx is like this

"tx": {
        "@type": "/cosmos.tx.v1beta1.Tx",
        "body": {
          "messages": [
            {
              "@type": "/cosmos.staking.v1beta1.MsgUndelegate",
              "delegator_address": "desmos1fc3mdf0ue2f4suyg5vjj75jtaer0cl0dgqvy6u",
              "validator_address": "desmosvaloper1pr7q92pv395pe2tst24ejkthpfz4w5zsh0zpja",
              "amount": {
                "denom": "udaric",
                "amount": "250000000000"
              }
            }
          ],
          "memo": "",
          "timeout_height": "0",
          "extension_options": [],
          "non_critical_extension_options": []
        },
        "auth_info": {
          "signer_infos": [],
          "fee": {
            "amount": [],
            "gas_limit": "205261",
            "payer": "",
            "granter": ""
          }
        }

I think you will be able to query with jsonb like

{
 tx:{
    body:{
        messages:{
            "delegator_address":"desmos1fc3mdf0ue2f4suyg5vjj75jtaer0cl0dgqvy6u"
        }
    }
 }
}

from callisto.

RiccardoM avatar RiccardoM commented on June 1, 2024

@ryuash If what Kwun's depicted doesn't work, we can try connecting each delegation/undelegation/etc to the proper transaction. This should be easily doable. Let me know if the above method works for your or it's too complicated

from callisto.

ryuash avatar ryuash commented on June 1, 2024

@kwunyeung Are we only displaying certain transaction messages in the individual pages? Not all message types have delegator_address. I had originally thought we wanted to display all transaction messages that were signed by the selected address. Please give me clarification on the activities component in validator_details and user_details.

@RiccardoM Since i had previously asked about filtering transaction messages by type I thought the current bdjuno isn't able to query/filter jsonb.

I updated the title. I was actually going to see how I can query all transactions initiated by the selected address (both validator and normal delegator addresses)

from callisto.

kwunyeung avatar kwunyeung commented on June 1, 2024

@ryuash I see. To query all transactions, you will have to query base on every message types. Different messages will have different fields in the transactions. Querying the auth_info is not enough as you can only get the transactions that are signed by the account but not all that related to the account. The address maybe in the to_address in a send or maybe it's in the withdraw_address.

from callisto.

ryuash avatar ryuash commented on June 1, 2024

@kwunyeung @RiccardoM
Currently I have no way of querying messages at all.
In the Hasura docs example there is a table with a list of JSONB but in our data structure I get a transactions table with a messages key that's contains an array of JSONB. It seems i'm unable to query on that level
image

Our Schema:

image

Would it be logical/realistic to pull messages in to it's own table with a one-to-many relationship to transaction?

from callisto.

kwunyeung avatar kwunyeung commented on June 1, 2024

We may try creating a view for the messages.

hasura/graphql-engine#2468 (comment)

from callisto.

RiccardoM avatar RiccardoM commented on June 1, 2024

@ryuash I've added a message table. You can query it using

query Messages {
  message {
    index
    transaction {
      hash
    }
    type
    value
    involved_accounts_addresses
  }
}

Please let me know if this fixes the issue

from callisto.

ryuash avatar ryuash commented on June 1, 2024

@RiccardoM I'm unable to query involved_accounts_addresses

query:

query ValidatorActivities {
  message(where: {involved_accounts_addresses: {_in: ["desmosvaloper14dm0zdemeymhayucp7gchuus3k5m344f0p084p"]}}) {
    value
    type
    transaction_hash
    involved_accounts_addresses
    index
  }
}

results:

{
  "errors": [
    {
      "extensions": {
        "path": "$",
        "code": "constraint-error"
      },
      "message": "type \"_text[]\" does not exist"
    }
  ]
}

I found a related github issue hasura/graphql-engine#2797

from callisto.

kwunyeung avatar kwunyeung commented on June 1, 2024

Hasura doesn't support array ATM.

from callisto.

RiccardoM avatar RiccardoM commented on June 1, 2024

Closing this as it had no more discussion to it

from callisto.

ryuash avatar ryuash commented on June 1, 2024

@RiccardoM Would it be possible to get the total number of transactions? Need it for pagination purposes

total: transaction_aggregate {
    aggregate {
      count
    }
  }

from callisto.

ryuash avatar ryuash commented on June 1, 2024

I did a temporary work around until you have time to work on this (or if you can't then just close the issue)

from callisto.

ryuash avatar ryuash commented on June 1, 2024

closing as the work around seems pretty stable

from callisto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.