-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6c907c
commit b2b8ae4
Showing
23 changed files
with
187 additions
and
53 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -1,5 +1,20 @@ | ||
package hello | ||
package userinvokes | ||
|
||
func Render(path string) string { | ||
return "Hello World!" | ||
import "fmt" | ||
|
||
var user_invokes map[string]int | ||
|
||
func Render(name string) string { | ||
if (!user_invokes) { | ||
user_invokes = make(map[string]int) | ||
} | ||
|
||
|
||
if (!user_invokes[name]) { | ||
user_invokes[name] += 1 | ||
} else { | ||
user_invokes = 1 | ||
} | ||
|
||
return fmt.Println("Total user invokes %d", user_invokes[name]) | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g1fsu3z335h5qngf7t3lmakvpmpwg9ae76tqwh7c","deposit":"1ugnot"} | ||
{"creator":"g15x46up6w3v9ey7wkltf05jt20pa6g39kkjjx8a","deposit":""} |
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 |
---|---|---|
@@ -1,17 +1,117 @@ | ||
package counter | ||
package mynonfungibletoken | ||
|
||
import "fmt" | ||
import ( | ||
"std" | ||
"gno.land/p/demo/grc/grc721" | ||
"gno.land/p/demo/users" | ||
"gno.land/p/demo/ufmt" | ||
) | ||
|
||
var count int | ||
var ( | ||
admin std.Address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // set admin account | ||
mynonfungibletoken = grc721.NewBasicNFT("mynonfungibletoken", "MNFT") | ||
) | ||
|
||
func Increment() { | ||
count++ | ||
func init() { | ||
mintNNFT(admin, 10) // @administrator (initial supply = 10 NFTs) | ||
} | ||
|
||
func Decrement() { | ||
count-- | ||
func mintNNFT(owner std.Address, n uint64) { | ||
count := mynonfungibletoken.TokenCount() | ||
for i := count; i < count+n; i++ { | ||
tid := grc721.TokenID(ufmt.Sprintf("%d", i)) | ||
mynonfungibletoken.Mint(owner, tid) | ||
} | ||
} | ||
|
||
func Render(_ string) string { | ||
return fmt.Sprintf("Count: %d", count) | ||
} | ||
// Getters | ||
|
||
func BalanceOf(user users.AddressOrName) uint64 { | ||
balance, err := mynonfungibletoken.BalanceOf(user.Resolve()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return balance | ||
} | ||
|
||
func OwnerOf(tid grc721.TokenID) std.Address { | ||
owner, err := mynonfungibletoken.OwnerOf(tid) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return owner | ||
} | ||
|
||
func IsApprovedForAll(owner, user users.AddressOrName) bool { | ||
return mynonfungibletoken.IsApprovedForAll(owner.Resolve(), user.Resolve()) | ||
} | ||
|
||
func GetApproved(tid grc721.TokenID) std.Address { | ||
addr, err := mynonfungibletoken.GetApproved(tid) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return addr | ||
} | ||
|
||
// Setters | ||
|
||
func Approve(user users.AddressOrName, tid grc721.TokenID) { | ||
err := mynonfungibletoken.Approve(user.Resolve(), tid) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func SetApprovalForAll(user users.AddressOrName, approved bool) { | ||
err := mynonfungibletoken.SetApprovalForAll(user.Resolve(), approved) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func TransferFrom(from, to users.AddressOrName, tid grc721.TokenID) { | ||
err := mynonfungibletoken.TransferFrom(from.Resolve(), to.Resolve(), tid) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
// Admin | ||
|
||
func Mint(to users.AddressOrName, tid grc721.TokenID) { | ||
caller := std.PrevRealm().Addr() | ||
assertIsAdmin(caller) | ||
err := mynonfungibletoken.Mint(to.Resolve(), tid) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func Burn(tid grc721.TokenID) { | ||
caller := std.PrevRealm().Addr() | ||
assertIsAdmin(caller) | ||
err := mynonfungibletoken.Burn(tid) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
// Render | ||
|
||
func Render(path string) string { | ||
switch { | ||
case path == "": | ||
return mynonfungibletoken.RenderHome() | ||
default: | ||
return "404\n" | ||
} | ||
} | ||
|
||
// Util | ||
|
||
func assertIsAdmin(address std.Address) { | ||
if address != admin { | ||
panic("restricted access") | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g1ghfakgzr6q77etpg8jtas6llg4uvqnfl8skxxq","deposit":"1ugnot"} | ||
{"creator":"g1dnllrdzwfhxv3evyk09y48mgn5phfjvtyrlzm7","deposit":""} |
12 changes: 9 additions & 3 deletions
12
test3.gno.land/extracted/r/bluehoneybadger/person/person.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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package person | ||
|
||
// Importing `strconv` to be able to cast the age to string so it can be concatenated | ||
import "strconv" | ||
|
||
var ( | ||
myName = "John Smith" | ||
myAge = 42 | ||
myAddress = "123 Main Street" | ||
) | ||
|
||
function Render(path string) string { | ||
return "My name is: " + myName "my Age is: " + myAge "& my Address is: " myAddress | ||
func Render(path string) string { | ||
// You could also use "gno.land/p/demo/ufmt" package, check `ufmt.Sprintf()` | ||
// See: https://test3.gno.land/p/demo/ufmt/ufmt.gno | ||
// It works like standard Go's "Sprintf" but it only support "%s" and "%d" it think | ||
return "My name is: " + myName + "my Age is: " + strconv.Itoa(myAge) + "& my Address is: " + myAddress | ||
} | ||
|
||
function UpdateAdddress(NewAddress string) string { | ||
func updateAddress(NewAddress string) string { | ||
myAddress = NewAddress | ||
return "Your address has been updated" | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g1098kpwkwv3r08cat9ssucrq4mznxyv855jgqvx","deposit":""} | ||
{"creator":"g1sycj68ur0n7xytglx0me3f207ktudm80aqpysm","deposit":""} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g10jtus48tdlp93l9jw9q0tws5jh7gmpjdtyqkxh","deposit":""} | ||
{"creator":"g148vmqxzgp4yc996pasredy3v9sw8sxzsgem0qv","deposit":""} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5","deposit":""} | ||
{"creator":"g1ndzpczjr2rzrchtkm3tsut2xjfn50mlgax2v77","deposit":"1ugnot"} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g1ggcgpqp2jfs2sgsnlcmzscd38jjvgk0y66sl2x","deposit":""} | ||
{"creator":"g1s67msjqmq0jwyzqlm8y578stkxppzyrt6nuhsw","deposit":"1ugnot"} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g1p809wnm9glgxu8lauaeattqlwh92gd0vcrlm46","deposit":""} | ||
{"creator":"g140pvdhzwxtg8yazp5zfqtmshqnt2mefs764yrw","deposit":""} |
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 |
---|---|---|
@@ -1,5 +1,14 @@ | ||
package hello | ||
|
||
func Render(path string) string { | ||
return "Hello World!" | ||
var ( | ||
greeting string | ||
) | ||
|
||
func SetGreeting(msg string) { | ||
greeting = msg | ||
} | ||
|
||
func GetGreeting()) string { | ||
return "greeting" | ||
} | ||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g10y2y4l4g7cx23tkl9jy5u638lw5aykvx7upqaz","deposit":"1ugnot"} | ||
{"creator":"g15wmukt79xymnnu6c4de32trnufudqum60yrxu8","deposit":""} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
package hello | ||
|
||
func Render(path string) string { | ||
func B(path []string) string { | ||
return "Hello World!" | ||
} | ||
|
||
func A(path string) string { | ||
return "Hello World!" | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g1uf8u5jf2m9l80g0zsfq7tufl3qufqc4393jtkl","deposit":"1ugnot"} | ||
{"creator":"g1ejrxf88yp390dr48a0wxyaed3vxj0243at292p","deposit":"1ugnot"} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g15wmukt79xymnnu6c4de32trnufudqum60yrxu8","deposit":"1ugnot"} | ||
{"creator":"g10y2y4l4g7cx23tkl9jy5u638lw5aykvx7upqaz","deposit":"1ugnot"} |
Oops, something went wrong.