-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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]>
- Loading branch information
Showing
27 changed files
with
506 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ | |
|
||
# generated files from reveal tool | ||
slides.html | ||
|
||
presentations/static/ | ||
presentations/templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
run: | ||
cd ..; go run golang.org/x/tools/cmd/present -http 0.0.0.0:3999 # -base ../.. | ||
|
||
runx: | ||
cd ..; go run github.com/soypat/go-presentx -http 0.0.0.0:3999 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.png |
21 changes: 21 additions & 0 deletions
21
presentations/2025-01-09--buidleu--manfred/code/buidl20.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// https://gno.land/r/moul/x/buidl20$source | ||
package buidl20 | ||
|
||
import ( | ||
"std" | ||
"gno.land/p/demo/grc/grc20" | ||
) | ||
|
||
// Token: public safe object for composability | ||
// adm: privileged object for minting | ||
var Token, adm = grc20.NewToken("Buidl", "BDL", 4) | ||
|
||
// grc20 API for the caller | ||
var UserTeller = Token.CallerTeller() | ||
|
||
func init() { | ||
adm.Mint(1_000_000, std.GetOrigCaller()) // mint 1M to the contract deployer. | ||
} | ||
|
||
// optional helpers | ||
// [...] |
11 changes: 11 additions & 0 deletions
11
presentations/2025-01-09--buidleu--manfred/code/counter.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package counter | ||
|
||
var Counter int | ||
|
||
func Inc() { | ||
Counter += 1 | ||
} | ||
|
||
func Render(path string) string { | ||
return "My Super Counter: " + Counter | ||
} |
22 changes: 22 additions & 0 deletions
22
presentations/2025-01-09--buidleu--manfred/code/counter_2.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package counter | ||
|
||
import "std" | ||
|
||
var ( | ||
Counter int | ||
LastCaller std.Address | ||
) | ||
|
||
func Inc() int { | ||
return addToCounter(1) | ||
} | ||
|
||
func Add(amount int) int { | ||
return addToCounter(amount) | ||
} | ||
|
||
func addToCounter(amount int) int { | ||
Counter += amount | ||
LastCaller = std.GetOrigCaller() | ||
return Counter | ||
} |
23 changes: 23 additions & 0 deletions
23
presentations/2025-01-09--buidleu--manfred/code/dao_aggregated.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package aggregateddao | ||
|
||
import "gno.land/p/dao" | ||
|
||
type AggregatedDAO struct { dao1, dao2 dao.DAO } | ||
|
||
func (a *AggregatedDAO) Propose(def dao.PropDefinition) (dao.Proposal, error) { | ||
prop1, _ := a.dao1.Propose(def) | ||
prop2, _ := a.dao2.Propose(def) | ||
// [...] | ||
} | ||
|
||
func (a *AggregatedDAO) Len() int { return a.dao1.Len() + a.dao2.Len() } | ||
|
||
func (a *AggregatedDAO) ActiveProposals() dao.PropList { | ||
return append(a.dao1.ActiveProposals(), a.dao2.ActiveProposals()...) | ||
} | ||
|
||
func (a *AggregatedDAO) ArchivedProposals() dao.PropList { | ||
return append(a.dao1.ArchivedProposals(), a.dao2.ArchivedProposals()...) | ||
} | ||
|
||
// [...] |
10 changes: 10 additions & 0 deletions
10
presentations/2025-01-09--buidleu--manfred/code/dao_composition.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// gno.land/r/foobardao | ||
package foobardao | ||
|
||
import ( | ||
"gno.land/r/foodao" | ||
"gno.land/r/bardao" | ||
"gno.land/p/aggregateddao" | ||
) | ||
|
||
var FooBarDAO = aggregateddao.New(foodao.DAO, bardao.DAO) |
13 changes: 13 additions & 0 deletions
13
presentations/2025-01-09--buidleu--manfred/code/dao_impl.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package foodao | ||
|
||
import "gno.land/p/dao" // interface | ||
|
||
// FooDAO implements the dao.DAO interface. | ||
type FooDAO struct { proposals []dao.Proposal, voters []std.Address } | ||
|
||
func (d *FooDAO) Propose(def PropDefinition) (Proposal, error) { /* [...] */ } | ||
func (d *FooDAO) GetProposal(proposalID uint64) (Proposal, error) { /* [...] */ } | ||
func (d *FooDAO) Execute(proposalID uint64) error { /* [...] */ } | ||
func (d *FooDAO) ActiveProposals() PropList { /* [...] */ } | ||
func (d *FooDAO) ArchivedProposals() PropList { /* [...] */ } | ||
func (d *FooDAO) Len() int { /* [...] */ } |
14 changes: 14 additions & 0 deletions
14
presentations/2025-01-09--buidleu--manfred/code/dao_type.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// gno.land/p/dao | ||
package dao | ||
|
||
type DAO interface { | ||
// Core proposal operations | ||
Propose(def PropDefinition) (Proposal, error) | ||
GetProposal(proposalID uint64) (Proposal, error) | ||
Execute(proposalID uint64) error | ||
|
||
// List operations | ||
ActiveProposals() PropList | ||
ArchivedProposals() PropList | ||
Len() int | ||
} |
23 changes: 23 additions & 0 deletions
23
presentations/2025-01-09--buidleu--manfred/code/executable_proposal.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// prop1.gno | ||
|
||
import "gno.land/r/gov/dao" | ||
import "gno.land/r/buidl/buidl20" | ||
|
||
func init() { | ||
closure := func() error { | ||
// this closure will preserve the execution context at the time of | ||
// creation, even if the proposal is executed by someone else. | ||
return executor() | ||
} | ||
prop := dao.ProposalRequest{ | ||
Title: "", | ||
Description: "lorem ipsum dolor sit amet", | ||
Executor: closure, | ||
} | ||
dao.Propose(prop) | ||
} | ||
|
||
func executor() error { | ||
buidl20.TransferTo("g12345678", 1_000_000) // transfer 1M $BUIDL | ||
return nil | ||
} |
23 changes: 23 additions & 0 deletions
23
presentations/2025-01-09--buidleu--manfred/code/grc20_type.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package grc20 // gno.land/p/demo/grc/grc20 | ||
|
||
type Teller interface { | ||
TotalSupply() uint64 | ||
BalanceOf(account std.Address) uint64 | ||
Transfer(to std.Address, amount uint64) error | ||
Allowance(owner, spender std.Address) uint64 | ||
Approve(spender std.Address, amount uint64) error | ||
TransferFrom(from, to std.Address, amount uint64) error | ||
} | ||
|
||
type Token struct { | ||
name, symbol string | ||
decimals uint | ||
ledger *PrivateLedger | ||
} | ||
|
||
type PrivateLedger struct { | ||
totalSupply uint64 | ||
balances, allowances avl.Tree | ||
} | ||
|
||
func NewToken(name, symbol string, decs uint) (*Token, *PrivateLedger) { /*...*/ } |
23 changes: 23 additions & 0 deletions
23
presentations/2025-01-09--buidleu--manfred/code/grc20factory.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// gno.land/r/demo/grc20factory | ||
package grc20factory | ||
|
||
var instances avl.Tree // symbol -> instance | ||
|
||
type instance struct { | ||
token *grc20.Token | ||
ledger *grc20.PrivateLedger | ||
admin *ownable.Ownable | ||
faucet uint64 // per-request amount. disabled if 0. | ||
} | ||
|
||
func New(name, symbol string, decimals uint, initialMint, faucet uint64) { | ||
caller := std.PrevRealm().Addr() | ||
token, ledger := grc20.NewToken(name, symbol, decimals) | ||
if initialMint > 0 { | ||
ledger.Mint(admin, initialMint) | ||
} | ||
owner := ownable.NewWithAddress(admin) | ||
inst := instance{token: token, ledger: ledger, admin: owner, faucet: faucet} | ||
instances.Set(symbol, &inst) | ||
grc20reg.Register(token.Getter(), symbol) | ||
} |
14 changes: 14 additions & 0 deletions
14
presentations/2025-01-09--buidleu--manfred/code/grc20reg.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// gno.land/r/demo/grc20reg | ||
package grc20reg | ||
|
||
var registry = avl.NewTree() // rlmPath -> TokenGetter | ||
|
||
func Register(tokenGetter grc20.TokenGetter) { | ||
rlmPath := std.PrevRealm().PkgPath() | ||
registry.Set(rlmPath, tokenGetter) | ||
} | ||
|
||
func Get(key string) grc20.TokenGetter { | ||
tokenGetter, _ := registry.Get(key) | ||
return tokenGetter | ||
} |
21 changes: 21 additions & 0 deletions
21
presentations/2025-01-09--buidleu--manfred/code/guest_book.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package guest | ||
|
||
import "std" | ||
|
||
var messages avl.Tree // std.Address -> string (message) | ||
|
||
func AddMessage(message string) { | ||
caller := std.GetOrigCaller() | ||
if _, ok := messages.Get(caller); ok { | ||
panic("this user already post a message") | ||
} | ||
messages.Set(caller, message) // add message to our messages list | ||
} | ||
|
||
func Render(path string) string { | ||
var view string | ||
for _, message := range messages { | ||
view = view + "\n" + message // add message to the render | ||
} | ||
return view | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
func main() { | ||
println("Hello, BUIDL! It's Manfred.") | ||
} |
5 changes: 5 additions & 0 deletions
5
presentations/2025-01-09--buidleu--manfred/code/hello_world.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package hello | ||
|
||
func Hello() string { | ||
return "hello world" | ||
} |
11 changes: 11 additions & 0 deletions
11
presentations/2025-01-09--buidleu--manfred/code/interop.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package alice | ||
|
||
var x int | ||
|
||
func GetX() int { | ||
return x | ||
} | ||
|
||
func SetX(n int) { | ||
x = n | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package bob | ||
|
||
import "alice" | ||
|
||
func IncrAlice() { | ||
x := alice.GetX() | ||
alice.SetX(x + 1) | ||
} |
Oops, something went wrong.