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

StargateClient.searchTx doesn't work if you passing KV-array #1462

Closed
seleniumforest opened this issue Aug 12, 2023 · 4 comments · Fixed by #1503
Closed

StargateClient.searchTx doesn't work if you passing KV-array #1462

seleniumforest opened this issue Aug 12, 2023 · 4 comments · Fixed by #1503
Milestone

Comments

@seleniumforest
Copy link

seleniumforest commented Aug 12, 2023

It works only if you pass raw string query, but doesn't work with key-value array.
Version "@cosmjs/stargate": "^0.31.0"

const { StargateClient } = require("@cosmjs/stargate");

(async () => {
    let client = await StargateClient.connect("https://stargaze-rpc.polkachu.com/");
    let stringResult = await client.searchTx(`tx.height=9525321`);

    //stringResult: 4CB5DC2A0F6EB0F256CCA245CFE10979B091DB281851190B8CB8BBCEE7503137 
    console.log(`stringResult: ${stringResult[0].hash} \n`);

    //Error: Bad status on response: 500
    //[{ key: "height", value: "9525321" }] also doesn't work
    let keyValueResult = await client.searchTx([{ key: "tx.height", value: "9525321" }]);
    console.log(`keyValueResult: ${keyValueResult}`);
})();
@webmaster128
Copy link
Member

webmaster128 commented Aug 16, 2023

Nice find, thank you. What about

await client.searchTx(`tx.height='9525321'`);

? This is what the array version is converted to internally.

@seleniumforest
Copy link
Author

Nice find, thank you. What about

await client.searchTx(`tx.height='9525321'`);

? This is what the array version is converted to internally.

Error: Bad status on response: 500

@seleniumforest
Copy link
Author

There shouldn't be quotes. This is right query
https://stargaze-rpc.polkachu.com/tx_search?query=%22tx.height=9525321%22

That query with '' doesn't work, seems like server parses it as string, but expects int
https://stargaze-rpc.polkachu.com/tx_search?query=%22tx.height=%279525321%27%22

@webmaster128
Copy link
Member

Interesting. I was not aware there is a difference between types in that interface. Maybe that changed at some point.

I think we can change the array elements as follows:

 {
   readonly key: string;
-  readonly value: string;
+  readonly value: string | number | bigint | Uint53 | Uint64;
 }

and avoid the quotes for the number case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants