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

[gnokey] Make output of queries follow JSON spec #2232

Open
leohhhn opened this issue May 28, 2024 · 3 comments
Open

[gnokey] Make output of queries follow JSON spec #2232

leohhhn opened this issue May 28, 2024 · 3 comments

Comments

@leohhhn
Copy link
Contributor

leohhhn commented May 28, 2024

Description

To consolidate our returns on gnokey queries, I propose that we make them return JSON strings. Currently, most of them return values with no wrapping, such as this:

height: 0
data: gno.mod
wugnot.gno
z0_filetest.gno

One exception is vm/qfuncs, which returns a partly formatted JSON string:

❯ gnokey query vm/qfuncs --data "gno.land/r/demo/userbook" -remote https://rpc.gno.land:443
height: 0
data: [{"FuncName":"SignUp","Params":null,"Results":[{"Name":"_","Type":"string","Value":""}]},{"FuncName":"GetSignupsInRange","Params":[{"Name":"page","Type":"int","Value":""},{"Name":"pageSize","Type":"int","Value":""}],"Results":[{"Name":"_","Type":"[]gno.land/r/demo/userbook.Signup","Value":""},{"Name":"_","Type":"int","Value":""}]},{"FuncName":"Render","Params":[{"Name":"path","Type":"string","Value":""}],"Results":[{"Name":"_","Type":"string","Value":""}]}]

Would be great to wrap height & data properly, such as this:

{
  "height": 0,
  "data": [
    {
      "FuncName": "SignUp",
      "Params": null,
      "Results": [
        {
          "Name": "_",
          "Type": "string",
          "Value": ""
        }
      ]
    },
    {
      "FuncName": "GetSignupsInRange",
      "Params": [
        {
          "Name": "page",
          "Type": "int",
          "Value": ""
        },
        {
          "Name": "pageSize",
          "Type": "int",
          "Value": ""
        }
      ],
      "Results": [
        {
          "Name": "_",
          "Type": "[]gno.land/r/demo/userbook.Signup",
          "Value": ""
        },
        {
          "Name": "_",
          "Type": "int",
          "Value": ""
        }
      ]
    },
    {
      "FuncName": "Render",
      "Params": [
        {
          "Name": "path",
          "Type": "string",
          "Value": ""
        }
      ],
      "Results": [
        {
          "Name": "_",
          "Type": "string",
          "Value": ""
        }
      ]
    }
  ]
}
@leohhhn
Copy link
Contributor Author

leohhhn commented May 28, 2024

Additional thoughts: it would be great to unify the vm/qfuncs query with what DevX is doing with gnoschema, so we have a standard across the board.

I see this as a super useful quick and easy way to get the ABI of a realm, such as with this:

gnokey query vm/qfuncs --data "gno.land/r/demo/userbook" -remote https://rpc.gno.land:443 > abi.json

cc @salmad3 @ilgooz Let's have a discussion on defining the spec for this.

@linhpn99
Copy link
Contributor

#2249
hey @leohhhn , i made a PR to format this query response, wdyt ?

@Kouteki Kouteki moved this from Triage to In Progress in 🧙‍♂️gno.land core team Jun 7, 2024
@Kouteki
Copy link
Contributor

Kouteki commented Jun 7, 2024

Relates to #2301

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

No branches or pull requests

3 participants