Skip to content

Commit 951a817

Browse files
authored
feat: buidl slides (#64)
* feat: buidl slides Signed-off-by: moul <[email protected]> * chore: fixup Signed-off-by: moul <[email protected]> * chore: fixup Signed-off-by: moul <[email protected]> * chore: fixup Signed-off-by: moul <[email protected]> * chore: fixup Signed-off-by: moul <[email protected]> * chore: fixup Signed-off-by: moul <[email protected]> * chore: fixup Signed-off-by: moul <[email protected]> * chore: fixup Signed-off-by: moul <[email protected]> --------- Signed-off-by: moul <[email protected]>
1 parent 96d6ab8 commit 951a817

27 files changed

+506
-20
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77

88
# generated files from reveal tool
99
slides.html
10+
11+
presentations/static/
12+
presentations/templates

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ presentations.
99

1010
|Date |Title |Speakers |Presentation |Recording |
1111
|---- |----- |-------- |------------ |--------- |
12+
|2025.01.09 |Designing Seamless Interconnected dApps with Gno |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2025-01-09--buidleu--manfred/presentation.slide.html#1) |--- |
1213
|2024.09.23 |Distributed Communities - How to build timeless and decentralized apps, with Go |[@thehowl](https://github.com/thehowl) |[Slides](https://gnolang.github.io/workshops/presentations/2024-09-23--distributed-communities--morgan/slides.html) |[Video](https://www.youtube.com/watch?v=b3zRbVcJxyE) |
1314
|2024.08.20 |A gentle intro to gno.land |[@leohhhn](https://github.com/leohhhn) |[Slides](presentations/2024-08-20--gentle-intro-to-gnoland--leon/presentation.pdf) |[Video](https://www.youtube.com/watch?v=hTGeG0z09NU) |
1415
|2024.08.05 |Intro to gno.land |[@leohhhn](https://github.com/leohhhn) |[Slides](https://docs.google.com/presentation/d/1tnplCWxhg-RFatDS3w1iJnO0vSfBAuw2ZA0ommNJQOU/edit?usp=sharing) |--- |
15-
|2024.07.13 |Building with Gno.land: A Practical Workshop on Smart Contracts |[@gfanton](https://github.com/gfanton) |[Slides](presentations/2024-07-13--nebular--gfanton/README.md) |[Video](https://www.youtube.com/watch?v=oBQ-t_E0QpI) |
1616
|2024.07.13 |Gno: Examples and Comparisons |[@moul](https://github.com/moul) |[Slides](https://gnolang.github.io/workshops/presentations/2024-07-13--nebular--manfred/presentation.slide.html#1) |[Video](https://www.youtube.com/watch?v=Zsl3xu_Edcc) |
17+
|2024.07.13 |Building with Gno.land: A Practical Workshop on Smart Contracts |[@gfanton](https://github.com/gfanton) |[Slides](presentations/2024-07-13--nebular--gfanton/README.md) |[Video](https://www.youtube.com/watch?v=oBQ-t_E0QpI) |
1718
|2024.07.09 |Building a Deterministic Interpreter in Go: Readability vs Performance |[@jaekwon](https://github.com/jaekwon) |[Slides](presentations/2024-07-09--gophercon-us--jae) |[Video](https://www.youtube.com/watch?v=betUkghf_jo) |
1819
|2024.07.08 |Building a Decentralized App on gno.land |[@deelawn](https://github.com/deelawn) |[Slides](presentations/2024-07-08--gophercon-us--dylan) |[Video](https://www.youtube.com/watch?v=lwL2VyjaV-A) |
1920
|2024.06.17 |Envisioning a Go-Powered Ecosystem: The Ultimate Go Computer |[@moul](https://github.com/moul) |[Slides](presentations/2024-06-17--gophercon-berlin--manfred) |[Video](https://youtu.be/dLE2-8QPK64?si=IidxNLGrwwS6jbYL) |
@@ -42,6 +43,10 @@ presentations.
4243
|2022.09.29 |Intro to Gno |[@moul](https://github.com/moul), [@pwnh4](https://github.com/pwnh4) |[Slides](https://github.com/xplrz/gnoland-workshop) |--- |
4344
|2022.09.13 |Intro to the Gno Smart Contract Platform and Blockchain |[@moul](https://github.com/moul) |[Slides](presentations/2022-09-13--berlin--manfred/slides.pdf) |[Video](https://www.youtube.com/watch?v=S36kA5RqLvs) |
4445

46+
47+
48+
49+
4550
_This table is autogenerated based on the [./presentations](./presentations) folder._
4651

4752
## Resources

go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ toolchain go1.22.3
66

77
require (
88
github.com/campoy/embedmd v1.0.0
9-
github.com/gnolang/gno v0.2.0
9+
github.com/gnolang/gno v0.0.0-20250109171001-b60f86478da2
1010
github.com/soypat/go-presentx v1.1.0
11-
golang.org/x/tools v0.23.0
11+
golang.org/x/tools v0.24.0
1212
gopkg.in/yaml.v3 v3.0.1
1313
moul.io/mdtable v1.0.0
1414
)
@@ -17,10 +17,10 @@ require (
1717
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
1818
github.com/pmezard/go-difflib v1.0.0 // indirect
1919
github.com/soypat/rebed v0.2.2 // indirect
20-
github.com/yuin/goldmark v1.4.13 // indirect
21-
golang.org/x/net v0.27.0 // indirect
22-
golang.org/x/sys v0.22.0 // indirect
23-
golang.org/x/term v0.22.0 // indirect
20+
github.com/yuin/goldmark v1.7.2 // indirect
21+
golang.org/x/net v0.28.0 // indirect
22+
golang.org/x/sys v0.24.0 // indirect
23+
golang.org/x/term v0.23.0 // indirect
2424
moul.io/banner v1.0.1 // indirect
2525
moul.io/climan v1.0.0 // indirect
2626
)

go.sum

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
55
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
66
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
77
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8-
github.com/gnolang/gno v0.2.0 h1:s33kyRByweDxxHMZMQKJtCDQpueTCYCFBqlLHwr6P+Y=
9-
github.com/gnolang/gno v0.2.0/go.mod h1:dBaL1Au2MNLol+3FXdCv+IKLJnMKtTmIt778zsKjVu0=
8+
github.com/gnolang/gno v0.0.0-20250109171001-b60f86478da2 h1:NSdDGlVJtDDrocvtIQ9/1CN1NpeTfcqTTTd3lvB429s=
9+
github.com/gnolang/gno v0.0.0-20250109171001-b60f86478da2/go.mod h1:60XncI6LLLwujdl/jAX5APhSf5t3pn+PTVdK2vmbYJE=
1010
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
1111
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
1212
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -34,8 +34,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
3434
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
3535
github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8=
3636
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
37-
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
38-
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
37+
github.com/yuin/goldmark v1.7.2 h1:NjGd7lO7zrUn/A7eKwn5PEOt4ONYGqpxSEeZuduvgxc=
38+
github.com/yuin/goldmark v1.7.2/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
3939
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
4040
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
4141
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
@@ -51,28 +51,28 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
5151
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5252
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
5353
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
54-
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
55-
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
54+
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
55+
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
5656
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5757
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5858
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5959
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6060
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6161
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6262
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
63-
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
64-
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
65-
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
66-
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
63+
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
64+
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
65+
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
66+
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
6767
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
6868
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
6969
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7070
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
7171
golang.org/x/tools v0.0.0-20201109182053-3db8fd265862/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
7272
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
7373
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
74-
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
75-
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
74+
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
75+
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
7676
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7777
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7878
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
run:
2+
cd ..; go run golang.org/x/tools/cmd/present -http 0.0.0.0:3999 # -base ../..
3+
4+
runx:
5+
cd ..; go run github.com/soypat/go-presentx -http 0.0.0.0:3999
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// https://gno.land/r/moul/x/buidl20$source
2+
package buidl20
3+
4+
import (
5+
"std"
6+
"gno.land/p/demo/grc/grc20"
7+
)
8+
9+
// Token: public safe object for composability
10+
// adm: privileged object for minting
11+
var Token, adm = grc20.NewToken("Buidl", "BDL", 4)
12+
13+
// grc20 API for the caller
14+
var UserTeller = Token.CallerTeller()
15+
16+
func init() {
17+
adm.Mint(1_000_000, std.GetOrigCaller()) // mint 1M to the contract deployer.
18+
}
19+
20+
// optional helpers
21+
// [...]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package counter
2+
3+
var Counter int
4+
5+
func Inc() {
6+
Counter += 1
7+
}
8+
9+
func Render(path string) string {
10+
return "My Super Counter: " + Counter
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package counter
2+
3+
import "std"
4+
5+
var (
6+
Counter int
7+
LastCaller std.Address
8+
)
9+
10+
func Inc() int {
11+
return addToCounter(1)
12+
}
13+
14+
func Add(amount int) int {
15+
return addToCounter(amount)
16+
}
17+
18+
func addToCounter(amount int) int {
19+
Counter += amount
20+
LastCaller = std.GetOrigCaller()
21+
return Counter
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package aggregateddao
2+
3+
import "gno.land/p/dao"
4+
5+
type AggregatedDAO struct { dao1, dao2 dao.DAO }
6+
7+
func (a *AggregatedDAO) Propose(def dao.PropDefinition) (dao.Proposal, error) {
8+
prop1, _ := a.dao1.Propose(def)
9+
prop2, _ := a.dao2.Propose(def)
10+
// [...]
11+
}
12+
13+
func (a *AggregatedDAO) Len() int { return a.dao1.Len() + a.dao2.Len() }
14+
15+
func (a *AggregatedDAO) ActiveProposals() dao.PropList {
16+
return append(a.dao1.ActiveProposals(), a.dao2.ActiveProposals()...)
17+
}
18+
19+
func (a *AggregatedDAO) ArchivedProposals() dao.PropList {
20+
return append(a.dao1.ArchivedProposals(), a.dao2.ArchivedProposals()...)
21+
}
22+
23+
// [...]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// gno.land/r/foobardao
2+
package foobardao
3+
4+
import (
5+
"gno.land/r/foodao"
6+
"gno.land/r/bardao"
7+
"gno.land/p/aggregateddao"
8+
)
9+
10+
var FooBarDAO = aggregateddao.New(foodao.DAO, bardao.DAO)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package foodao
2+
3+
import "gno.land/p/dao" // interface
4+
5+
// FooDAO implements the dao.DAO interface.
6+
type FooDAO struct { proposals []dao.Proposal, voters []std.Address }
7+
8+
func (d *FooDAO) Propose(def PropDefinition) (Proposal, error) { /* [...] */ }
9+
func (d *FooDAO) GetProposal(proposalID uint64) (Proposal, error) { /* [...] */ }
10+
func (d *FooDAO) Execute(proposalID uint64) error { /* [...] */ }
11+
func (d *FooDAO) ActiveProposals() PropList { /* [...] */ }
12+
func (d *FooDAO) ArchivedProposals() PropList { /* [...] */ }
13+
func (d *FooDAO) Len() int { /* [...] */ }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// gno.land/p/dao
2+
package dao
3+
4+
type DAO interface {
5+
// Core proposal operations
6+
Propose(def PropDefinition) (Proposal, error)
7+
GetProposal(proposalID uint64) (Proposal, error)
8+
Execute(proposalID uint64) error
9+
10+
// List operations
11+
ActiveProposals() PropList
12+
ArchivedProposals() PropList
13+
Len() int
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// prop1.gno
2+
3+
import "gno.land/r/gov/dao"
4+
import "gno.land/r/buidl/buidl20"
5+
6+
func init() {
7+
closure := func() error {
8+
// this closure will preserve the execution context at the time of
9+
// creation, even if the proposal is executed by someone else.
10+
return executor()
11+
}
12+
prop := dao.ProposalRequest{
13+
Title: "",
14+
Description: "lorem ipsum dolor sit amet",
15+
Executor: closure,
16+
}
17+
dao.Propose(prop)
18+
}
19+
20+
func executor() error {
21+
buidl20.TransferTo("g12345678", 1_000_000) // transfer 1M $BUIDL
22+
return nil
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package grc20 // gno.land/p/demo/grc/grc20
2+
3+
type Teller interface {
4+
TotalSupply() uint64
5+
BalanceOf(account std.Address) uint64
6+
Transfer(to std.Address, amount uint64) error
7+
Allowance(owner, spender std.Address) uint64
8+
Approve(spender std.Address, amount uint64) error
9+
TransferFrom(from, to std.Address, amount uint64) error
10+
}
11+
12+
type Token struct {
13+
name, symbol string
14+
decimals uint
15+
ledger *PrivateLedger
16+
}
17+
18+
type PrivateLedger struct {
19+
totalSupply uint64
20+
balances, allowances avl.Tree
21+
}
22+
23+
func NewToken(name, symbol string, decs uint) (*Token, *PrivateLedger) { /*...*/ }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// gno.land/r/demo/grc20factory
2+
package grc20factory
3+
4+
var instances avl.Tree // symbol -> instance
5+
6+
type instance struct {
7+
token *grc20.Token
8+
ledger *grc20.PrivateLedger
9+
admin *ownable.Ownable
10+
faucet uint64 // per-request amount. disabled if 0.
11+
}
12+
13+
func New(name, symbol string, decimals uint, initialMint, faucet uint64) {
14+
caller := std.PrevRealm().Addr()
15+
token, ledger := grc20.NewToken(name, symbol, decimals)
16+
if initialMint > 0 {
17+
ledger.Mint(admin, initialMint)
18+
}
19+
owner := ownable.NewWithAddress(admin)
20+
inst := instance{token: token, ledger: ledger, admin: owner, faucet: faucet}
21+
instances.Set(symbol, &inst)
22+
grc20reg.Register(token.Getter(), symbol)
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// gno.land/r/demo/grc20reg
2+
package grc20reg
3+
4+
var registry = avl.NewTree() // rlmPath -> TokenGetter
5+
6+
func Register(tokenGetter grc20.TokenGetter) {
7+
rlmPath := std.PrevRealm().PkgPath()
8+
registry.Set(rlmPath, tokenGetter)
9+
}
10+
11+
func Get(key string) grc20.TokenGetter {
12+
tokenGetter, _ := registry.Get(key)
13+
return tokenGetter
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package guest
2+
3+
import "std"
4+
5+
var messages avl.Tree // std.Address -> string (message)
6+
7+
func AddMessage(message string) {
8+
caller := std.GetOrigCaller()
9+
if _, ok := messages.Get(caller); ok {
10+
panic("this user already post a message")
11+
}
12+
messages.Set(caller, message) // add message to our messages list
13+
}
14+
15+
func Render(path string) string {
16+
var view string
17+
for _, message := range messages {
18+
view = view + "\n" + message // add message to the render
19+
}
20+
return view
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package main
2+
3+
func main() {
4+
println("Hello, BUIDL! It's Manfred.")
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package hello
2+
3+
func Hello() string {
4+
return "hello world"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package alice
2+
3+
var x int
4+
5+
func GetX() int {
6+
return x
7+
}
8+
9+
func SetX(n int) {
10+
x = n
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package bob
2+
3+
import "alice"
4+
5+
func IncrAlice() {
6+
x := alice.GetX()
7+
alice.SetX(x + 1)
8+
}

0 commit comments

Comments
 (0)