From 3691956600eb1c7fe17a4d4e02c23a5561ee81a0 Mon Sep 17 00:00:00 2001 From: Manfred Touron <94029+moul@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:59:27 +0100 Subject: [PATCH] chore: refactor txlink in order to extend it (#3289) Signed-off-by: moul <94029+moul@users.noreply.github.com>
Contributors' checklist... - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests
--------- Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/gno.land/p/moul/helplink/helplink.gno | 2 +- examples/gno.land/p/moul/txlink/txlink.gno | 12 ++++++------ examples/gno.land/p/moul/txlink/txlink_test.gno | 4 ++-- examples/gno.land/r/demo/boards/board.gno | 2 +- examples/gno.land/r/demo/boards/post.gno | 6 +++--- examples/gno.land/r/docs/adder/adder.gno | 2 +- examples/gno.land/r/gov/dao/v2/render.gno | 6 +++--- examples/gno.land/r/leon/hof/render.gno | 10 +++++----- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/gno.land/p/moul/helplink/helplink.gno b/examples/gno.land/p/moul/helplink/helplink.gno index 0c18f5d0360..14b44622a1e 100644 --- a/examples/gno.land/p/moul/helplink/helplink.gno +++ b/examples/gno.land/p/moul/helplink/helplink.gno @@ -70,7 +70,7 @@ func (r Realm) Func(title string, fn string, args ...string) string { // arguments. func (r Realm) FuncURL(fn string, args ...string) string { tlr := txlink.Realm(r) - return tlr.URL(fn, args...) + return tlr.Call(fn, args...) } // Home returns the base help URL for the specified realm. diff --git a/examples/gno.land/p/moul/txlink/txlink.gno b/examples/gno.land/p/moul/txlink/txlink.gno index 4705161578c..65edda6911e 100644 --- a/examples/gno.land/p/moul/txlink/txlink.gno +++ b/examples/gno.land/p/moul/txlink/txlink.gno @@ -5,7 +5,7 @@ // flexible arguments, allowing users to build dynamic links that integrate // seamlessly with various Gno clients. // -// The primary function, URL, is designed to produce markdown links for +// The primary function, Call, is designed to produce markdown links for // transaction functions in the current "relative realm". By specifying a custom // Realm, you can generate links that either use the current realm path or a // fully qualified path for another realm. @@ -21,10 +21,10 @@ import ( const chainDomain = "gno.land" // XXX: std.ChainDomain (#2911) -// URL returns a URL for the specified function with optional key-value +// Call returns a URL for the specified function with optional key-value // arguments, for the current realm. -func URL(fn string, args ...string) string { - return Realm("").URL(fn, args...) +func Call(fn string, args ...string) string { + return Realm("").Call(fn, args...) } // Realm represents a specific realm for generating tx links. @@ -48,9 +48,9 @@ func (r Realm) prefix() string { return "https://" + string(r) } -// URL returns a URL for the specified function with optional key-value +// Call returns a URL for the specified function with optional key-value // arguments. -func (r Realm) URL(fn string, args ...string) string { +func (r Realm) Call(fn string, args ...string) string { // Start with the base query url := r.prefix() + "$help&func=" + fn diff --git a/examples/gno.land/p/moul/txlink/txlink_test.gno b/examples/gno.land/p/moul/txlink/txlink_test.gno index a598a06b154..61b532270d4 100644 --- a/examples/gno.land/p/moul/txlink/txlink_test.gno +++ b/examples/gno.land/p/moul/txlink/txlink_test.gno @@ -6,7 +6,7 @@ import ( "gno.land/p/demo/urequire" ) -func TestURL(t *testing.T) { +func TestCall(t *testing.T) { tests := []struct { fn string args []string @@ -30,7 +30,7 @@ func TestURL(t *testing.T) { for _, tt := range tests { title := tt.fn t.Run(title, func(t *testing.T) { - got := tt.realm.URL(tt.fn, tt.args...) + got := tt.realm.Call(tt.fn, tt.args...) urequire.Equal(t, tt.want, got) }) } diff --git a/examples/gno.land/r/demo/boards/board.gno b/examples/gno.land/r/demo/boards/board.gno index 79b27da84b2..9b9fb730c68 100644 --- a/examples/gno.land/r/demo/boards/board.gno +++ b/examples/gno.land/r/demo/boards/board.gno @@ -135,5 +135,5 @@ func (board *Board) GetURLFromThreadAndReplyID(threadID, replyID PostID) string } func (board *Board) GetPostFormURL() string { - return txlink.URL("CreateThread", "bid", board.id.String()) + return txlink.Call("CreateThread", "bid", board.id.String()) } diff --git a/examples/gno.land/r/demo/boards/post.gno b/examples/gno.land/r/demo/boards/post.gno index 95d4b2977ba..c6e23cd59d0 100644 --- a/examples/gno.land/r/demo/boards/post.gno +++ b/examples/gno.land/r/demo/boards/post.gno @@ -156,7 +156,7 @@ func (post *Post) GetURL() string { } func (post *Post) GetReplyFormURL() string { - return txlink.URL("CreateReply", + return txlink.Call("CreateReply", "bid", post.board.id.String(), "threadid", post.threadID.String(), "postid", post.id.String(), @@ -164,14 +164,14 @@ func (post *Post) GetReplyFormURL() string { } func (post *Post) GetRepostFormURL() string { - return txlink.URL("CreateRepost", + return txlink.Call("CreateRepost", "bid", post.board.id.String(), "postid", post.id.String(), ) } func (post *Post) GetDeleteFormURL() string { - return txlink.URL("DeletePost", + return txlink.Call("DeletePost", "bid", post.board.id.String(), "threadid", post.threadID.String(), "postid", post.id.String(), diff --git a/examples/gno.land/r/docs/adder/adder.gno b/examples/gno.land/r/docs/adder/adder.gno index cd96d241692..33e971c7c0b 100644 --- a/examples/gno.land/r/docs/adder/adder.gno +++ b/examples/gno.land/r/docs/adder/adder.gno @@ -27,7 +27,7 @@ func Render(path string) string { result += "Last Updated: " + formatTimestamp(lastUpdate) + "\n\n" // Generate a transaction link to call Add with 42 as the default parameter - txLink := txlink.URL("Add", "n", "42") + txLink := txlink.Call("Add", "n", "42") result += "[Increase Number](" + txLink + ")\n" return result diff --git a/examples/gno.land/r/gov/dao/v2/render.gno b/examples/gno.land/r/gov/dao/v2/render.gno index 4cca397e851..57b7b601523 100644 --- a/examples/gno.land/r/gov/dao/v2/render.gno +++ b/examples/gno.land/r/gov/dao/v2/render.gno @@ -111,9 +111,9 @@ func renderActionBar(p dao.Proposal, idx int) string { out += "### Actions\n\n" if p.Status() == dao.Active { out += ufmt.Sprintf("#### [[Vote YES](%s)] - [[Vote NO](%s)] - [[Vote ABSTAIN](%s)]", - txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), - txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), - txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), + txlink.Call("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), + txlink.Call("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), + txlink.Call("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), ) } else { out += "The voting period for this proposal is over." diff --git a/examples/gno.land/r/leon/hof/render.gno b/examples/gno.land/r/leon/hof/render.gno index 6b06ef04051..b4d51d03362 100644 --- a/examples/gno.land/r/leon/hof/render.gno +++ b/examples/gno.land/r/leon/hof/render.gno @@ -64,12 +64,12 @@ func (i Item) Render(dashboard bool) string { out += ufmt.Sprintf("Submitted at Block #%d\n\n", i.blockNum) out += ufmt.Sprintf("#### [%d👍](%s) - [%d👎](%s)\n\n", - i.upvote.Size(), txlink.URL("Upvote", "pkgpath", i.pkgpath), - i.downvote.Size(), txlink.URL("Downvote", "pkgpath", i.pkgpath), + i.upvote.Size(), txlink.Call("Upvote", "pkgpath", i.pkgpath), + i.downvote.Size(), txlink.Call("Downvote", "pkgpath", i.pkgpath), ) if dashboard { - out += ufmt.Sprintf("[Delete](%s)", txlink.URL("Delete", "pkgpath", i.pkgpath)) + out += ufmt.Sprintf("[Delete](%s)", txlink.Call("Delete", "pkgpath", i.pkgpath)) } return out @@ -83,9 +83,9 @@ func renderDashboard() string { out += ufmt.Sprintf("Exhibition admin: %s\n\n", owner.Owner().String()) if !exhibition.IsPaused() { - out += ufmt.Sprintf("[Pause exhibition](%s)\n\n", txlink.URL("Pause")) + out += ufmt.Sprintf("[Pause exhibition](%s)\n\n", txlink.Call("Pause")) } else { - out += ufmt.Sprintf("[Unpause exhibition](%s)\n\n", txlink.URL("Unpause")) + out += ufmt.Sprintf("[Unpause exhibition](%s)\n\n", txlink.Call("Unpause")) } out += "---\n\n"