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

feat(examples): add hello_world, update r/demo/event #3130

Merged
merged 10 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/gno.land/r/demo/emit/emit.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Package emit demonstrates how to use the std.Emit() function
// to emit Gno events that can be used to track data changes off-chain.
// std.Emit is variadic; apart from the event name, it can take in any number of key-value pairs to emit.
package emit

import (
"std"
)

func Emit(value string) {
std.Emit("EventName", "key", value)
}
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/emit/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/demo/emit
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package main

import "gno.land/r/demo/event"
import "gno.land/r/demo/emit"

func main() {
event.Emit("foo")
event.Emit("bar")
emit.Emit("foo")
emit.Emit("bar")
}

// Events:
// [
// {
// "type": "TAG",
// "type": "EventName",
// "attrs": [
// {
// "key": "key",
// "value": "foo"
// }
// ],
// "pkg_path": "gno.land/r/demo/event",
// "pkg_path": "gno.land/r/demo/emit",
// "func": "Emit"
// },
// {
// "type": "TAG",
// "type": "EventName",
// "attrs": [
// {
// "key": "key",
// "value": "bar"
// }
// ],
// "pkg_path": "gno.land/r/demo/event",
// "pkg_path": "gno.land/r/demo/emit",
// "func": "Emit"
// }
// ]
9 changes: 0 additions & 9 deletions examples/gno.land/r/demo/event/event.gno

This file was deleted.

1 change: 0 additions & 1 deletion examples/gno.land/r/demo/event/gno.mod

This file was deleted.

1 change: 1 addition & 0 deletions examples/gno.land/r/demo/hello_world/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/demo/hello_world
18 changes: 18 additions & 0 deletions examples/gno.land/r/demo/hello_world/hello.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Package hello_world demonstrates the usage of the Render() function.
// Render() can be called via the vm/qrender ABCI query off-chain to retrieve
// realm state or any other custom data defined by the realm developer.
// The vm/qrender query allows for additional data to be passed in with the call
// which can be utilized as the path argument to the Render() function.
// This allows developers to create different "renders" of their realms
// depending on the data which is passed in, such as pagination, admin dashboards, and more.
// Check out other example realms and packages for more advanced use-cases, such as
// r/gnoland/blog, r/gnoland/events, r/demo/hof, etc.
leohhhn marked this conversation as resolved.
Show resolved Hide resolved
leohhhn marked this conversation as resolved.
Show resolved Hide resolved
package hello_world

func Render(path string) string {
if path == "" {
return "# Hello, 世界!"
}

return "# Hello, " + path + "!"
}
Loading