From 465a5263340bbdb3d4fa4368ce44e96af86b0d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20C=2E=20Morency?= <1102868+fmorency@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:22:06 -0500 Subject: [PATCH] fix: yaci query (#35) --- hooks/useQueries.ts | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/hooks/useQueries.ts b/hooks/useQueries.ts index c3dc1a4f..533bcc6f 100644 --- a/hooks/useQueries.ts +++ b/hooks/useQueries.ts @@ -784,25 +784,21 @@ export const useSendTxIncludingAddressQuery = (address: string, direction?: 'sen const fetchTransactions = async () => { const baseUrl = 'https://testnet-indexer.liftedinit.tech/transactions'; - // Build query for both direct MsgSend and nested group proposal MsgSend + // Build query for both direct MsgSend and nested (1 level) group proposal MsgSend const query = ` - or=( - and( - data->tx->body->messages->0->>@type.eq./cosmos.bank.v1beta1.MsgSend, - or( - data->tx->body->messages->0->>fromAddress.eq.${address}, - data->tx->body->messages->0->>toAddress.eq.${address} - ) + and=( + or( + data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}], + data->tx->body->messages.cs.[{"messages": [{"@type": "/cosmos.bank.v1beta1.MsgSend"}]}] ), - and( - data->tx->body->messages->0->>@type.eq./cosmos.group.v1.MsgSubmitProposal, - data->tx->body->messages->0->messages->0->>@type.eq./cosmos.bank.v1beta1.MsgSend, - or( - data->tx->body->messages->0->messages->0->>fromAddress.eq.${address}, - data->tx->body->messages->0->messages->0->>toAddress.eq.${address} - ) + or( + data->tx->body->messages.cs.[{"fromAddress": "${address}"}], + data->tx->body->messages.cs.[{"toAddress": "${address}"}], + data->tx->body->messages.cs.[{"messages": [{"fromAddress": "${address}"}]}], + data->tx->body->messages.cs.[{"messages": [{"toAddress": "${address}"}]}] ) - )`; + ) + `; const response = await axios.get( `${baseUrl}?${query.replace(/\s+/g, '')}&order=data->txResponse->height.desc` @@ -842,7 +838,7 @@ export const useSendTxIncludingAddressQuery = (address: string, direction?: 'sen export const useSendTxQuery = () => { const fetchTransactions = async () => { const baseUrl = 'https://testnet-indexer.liftedinit.tech/transactions'; - const query = `data->tx->body->messages->0->>@type=eq./cosmos.bank.v1beta1.MsgSend`; + const query = `data->tx->body->messages.cs.[{"@type": "/cosmos.bank.v1beta1.MsgSend"}]`; const response = await axios.get(`${baseUrl}?${query}`); return response.data.map(transformTransaction).filter((tx: any) => tx !== null);