Comments (14)
@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 theinvolved_accounts_addresses
array containing any of theseaddresses
. This is particularly useful for validators, where you can supply bothdesmos1..
anddesmosvaloper1...
addresses here. For accounts, you can simply pass only thedesmos1...
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 emptyaddresses
will result in an empty result. -
types
Array of types which should be searched for. The resulting messages will have thetype
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 emptytypes
({}
) will result in all types being valid. -
limit
Limits the number of resulting rows.
This parameter is optional* with default value100
. -
offset
Offsets the limit by the specified amount.
This parameter is optional* with default value0
.
Note
All the returned rows are sorted by height
in a descending fashion.
from callisto.
@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.
@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.
@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.
@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.
@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
Our Schema:
Would it be logical/realistic to pull messages
in to it's own table with a one-to-many
relationship to transaction
?
from callisto.
We may try creating a view for the messages.
hasura/graphql-engine#2468 (comment)
from callisto.
@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.
@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.
Hasura doesn't support array ATM.
from callisto.
Closing this as it had no more discussion to it
from callisto.
@RiccardoM Would it be possible to get the total number of transactions? Need it for pagination purposes
total: transaction_aggregate {
aggregate {
count
}
}
from callisto.
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.
closing as the work around seems pretty stable
from callisto.
Related Issues (20)
- Parse some bank messages to import accounts
- BeginBlocker/EndBlocker events HOT 2
- Cannot query data directly from node HOT 3
- How to add customize cosmos app chain into the bdjuno? HOT 8
- bdjuno start return error: ERROR: failed to start client: Not Found HOT 1
- failed to get last block height from database error="pq: permission denied for table block" HOT 1
- Use branch cosmos/v0.46.x got error: failed to get block results from node: error unmarshalling result: illegal base64 data at input byte 44 HOT 1
- Why Average Block Time and Active Validators are 0? HOT 8
- i have error parsing my transaction throw bdjuno HOT 11
- panic: invalid Go type math.LegacyDec for field cosmos.mint.v1beta1.QueryInflationResponse.inflation HOT 3
- Validator status and voting power not updated in some cases
- Gov transactions V1beta1
- Impossible to have staking/validator duplicated `operator address` address
- The bdjuno doesn't cover the proposal status change from the deposit to voting.
- not found github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar
- BDJuno crashes when an invalid prefix arrives HOT 2
- ERR re-enqueueing failed block: no concrete type registered for type URL /ibc.core.client.v1.MsgUpdateClient against interface *types.Msg HOT 9
- failed to get transactions for block HOT 2
- Details page cannot display when running with `yarn build` and `yarn start` HOT 1
- v0.47 - Bad Power Voting % calculation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from callisto.