gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source
https://gno.land/
Other
875 stars 355 forks source link

[gnoweb/realms] Standardize hyperlink structure #2602

Open leohhhn opened 1 month ago

leohhhn commented 1 month ago

Description

With the revamp of gnoweb coming along, we should think about how we can standardize links so that they can be used by other apps.

For example, currently we can get the help page of gnoweb to display all available realm functions with simply pkgpath?help - example here. We can also specify a concrete function name, as well as its parameters: pkgpath?help&__func=ModAddPost&title=NewBlogPost - example here. This will show only the specified function with the prefilled arguments to it from the link.

Standardizing this link pattern would also allow other apps, such as GnoStudio Connect, to directly be able to lead users to a specific function call with a specific argument set - which would be very useful for people who do not know how to use gnokey or the CLI altogether.

@ilgooz @salmad3 - do you think we could support this link structure in Connect?

I would like to be able to display, say, an EDIT button on gnoweb for a specific blog post. The blog realm could have a base link for Connect, where clicking EDIT would lead the user to the specific function call with arguments embedded in the realm, such as the post ID, which would be needed to run the actual function. For example, the EDIT button could lead to gno.studio/connect&pkgpath=blogrealm&func=EditPost&id=1 or similar. I understand its a bit more complex due to having to include the chainID and other info in the link, but this feature would be super useful. Let's discuss.

grepsuzette commented 1 month ago

Since connecting a wallet to gno.land seems on standby ATM (https://github.com/gnolang/gno/issues/1803), it's obvious both the current ?help page (helper to create tx from the cli) and gno.studio can be useful.

The current markdown production which can point to ?help is like:

Assuming we kept the ?help syntax for the moment, the user clicking on a link could be:

  1. brought to current ?help - Drawback: As leohhhn said it can scare non-technical people.
  2. taken to https://gno.studio - Drawback: jumping across domains is unconventional, some people may prefer solution 1.
  3. popped up a choice between 1, 2, 3 - Drawback: Invasive?
  4. given the choice the first time, by going to a special page on gno.land, to choose between 1, 2, 3, 4 - Drawback: Feasibility?

If we don't think about the technology, I like the idea of first being taken to a page on gno.land, to set up what I'd like to do. From where... I would probably ask to get a popup at first, to see what I use the most :)


(In addition to those there is another thing that could be done, which I hope will come true. The current ?help could easily be a large popup, especially when it's showing only 1 function. And one day, you could connect Adena or Keplr on this help popup, to one-time do a tx from there).

leohhhn commented 1 month ago

@grepsuzette Thanks for the considerations.

Since currently we do not want to include non-core-developed products in gnoweb (such as Adena), I think a good way to go forward would be to include a button/hyperlink in each ?help function that could take you to gno.studio/connect to execute that exact function. This is non-invasive, and it's simply a suggestion to the user that could make their life a little easier if they do not use CLI.

This would still need link standardization between gnoweb & Connect.

grepsuzette commented 1 month ago

Oh do you mean on the help page itself, like this?

contract Draw(...)
params seed __ uint64
results _ string
command ### INSECURE BUT QUICK ### <link/button to gno.studio/connect>
contract SetBlah(...)
params text __ string
results _ string
command ### INSECURE BUT QUICK ### <link/btn to gno.studio/connect>

(Or the link is on a new line, or even on a new row).

I like it!


About the connection.

If we take art/millipede as a case study, it has a func Call(size int) string. These URLs work already:

So what you're after seems to be how to prefill parameters like size int with what was entered in the ?help page.

grepsuzette commented 1 month ago

There is a temptation to use a <form method=POST> with various <submit> buttons.

<form> is simple, there may be no javascript involved and practically nothing to change in our help page.

Security considerations need to be double-checked but:

  1. parameters are not stored in history with POST (for regular webbrowsers),
  2. parameters are not transiting in clear text on the network if HTTPS is used.

Some plugins could have access to what's typed, but if you care you would just type everything in a terminal and use gnokey (plus that risk would not just concern gnoweb).

@leohhhn something like this?