-
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
c3b0a51
commit 78f65f0
Showing
36 changed files
with
151 additions
and
222 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
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,6 @@ | ||
{"tx":{"msg":[{"@type":"/bank.MsgSend","from_address":"g13d7jc32adhc39erm5me38w5v7ej7lpvlnqjk73","to_address":"g1xyx283r3tfrcnszzhkccwuq7rgjplywvq8653w","amount":"20000000ugnot"}],"fee":{"gas_wanted":"2000000","gas_fee":"1ugnot"},"signatures":[{"pub_key":{"@type":"/tm.PubKeySecp256k1","value":"A/+cjV0/gZkWzMqCul8aP5hC7M3yliIs17uinn/+66uR"},"signature":"wksPSidBG0nPbKdBRWpp53m2Jt+2F2PfJRmSS9HHB6pGx0ehaFTRyoaFOKFXs3Pl8PCT5DHdI+SHHrhayEb96w=="}],"memo":""},"blockNum":"449929"} | ||
{"tx":{"msg":[{"@type":"/vm.m_addpkg","creator":"g1xyx283r3tfrcnszzhkccwuq7rgjplywvq8653w","package":{"Name":"demo1","Path":"gno.land/r/hello/demo1","Files":[{"Name":"package.gno","Body":"package demo1\n\nfunc Render(path string) string {\n return \"Hello World!\"\n}\n"}]},"deposit":"1ugnot"}],"fee":{"gas_wanted":"10000000","gas_fee":"50000ugnot"},"signatures":[{"pub_key":{"@type":"/tm.PubKeySecp256k1","value":"AssW3lOgY+ito4Dl4c0QNyp6SqB5r2NDXzJVQ0JGDEG6"},"signature":"SX2qG+rqNN7J+kPCmSPwLCoXBTWMH0twtydXJsEl46Q6X5cH1/87eG4hXg3y66YnSc6Yl5n66yfZWhpKvVATiw=="}],"memo":"Deployed through play.gno.land"},"blockNum":"449931"} | ||
{"tx":{"msg":[{"@type":"/bank.MsgSend","from_address":"g13d7jc32adhc39erm5me38w5v7ej7lpvlnqjk73","to_address":"g18cnw0nyv0yn2twwt5yfdu53zdgpesj7gcxshdz","amount":"20000000ugnot"}],"fee":{"gas_wanted":"2000000","gas_fee":"1ugnot"},"signatures":[{"pub_key":{"@type":"/tm.PubKeySecp256k1","value":"A/+cjV0/gZkWzMqCul8aP5hC7M3yliIs17uinn/+66uR"},"signature":"rF3OtH7/6yjDkhSyfvk+777ccXDxI6hK1JCOD1Y6xaJicnzssRff3I5S2zyFcI3oaRcqJqkm649Zy9SdJpZzUQ=="}],"memo":""},"blockNum":"450477"} | ||
{"tx":{"msg":[{"@type":"/vm.m_addpkg","creator":"g18cnw0nyv0yn2twwt5yfdu53zdgpesj7gcxshdz","package":{"Name":"hello","Path":"gno.land/r/test/hello","Files":[{"Name":"package.gno","Body":"package hello\n\nfunc Render(path string) string {\n return \"Hello World!\"\n}\n"}]},"deposit":"1ugnot"}],"fee":{"gas_wanted":"10000000","gas_fee":"50000ugnot"},"signatures":[{"pub_key":{"@type":"/tm.PubKeySecp256k1","value":"AsjfwZC/yNFtNUv0OpjSZsogpMYydznAInXb5xiyT0cr"},"signature":"Fl0nyRq+gA6IL0V8ST6F01TP3aJHl06HF/F6DkMYpRxAba9rs1p4ITw82qdcBfWYExSA/otlJGAFq1UwYO7uWw=="}],"memo":"Deployed through play.gno.land"},"blockNum":"450479"} | ||
{"tx":{"msg":[{"@type":"/bank.MsgSend","from_address":"g13d7jc32adhc39erm5me38w5v7ej7lpvlnqjk73","to_address":"g18cnw0nyv0yn2twwt5yfdu53zdgpesj7gcxshdz","amount":"20000000ugnot"}],"fee":{"gas_wanted":"2000000","gas_fee":"1ugnot"},"signatures":[{"pub_key":{"@type":"/tm.PubKeySecp256k1","value":"A/+cjV0/gZkWzMqCul8aP5hC7M3yliIs17uinn/+66uR"},"signature":"/AqUV120fezQCAn2IdGj9QgNG3S4JqsfgJLFwg0Ij8UjK7QYuaHvJp7Y4x3pbGyOx3kjcx5h8zU2s3RJBuEkug=="}],"memo":""},"blockNum":"450481"} | ||
{"tx":{"msg":[{"@type":"/vm.m_addpkg","creator":"g18cnw0nyv0yn2twwt5yfdu53zdgpesj7gcxshdz","package":{"Name":"hello","Path":"gno.land/r/sanbor/hello","Files":[{"Name":"package.gno","Body":"package hello\n\nfunc Render(path string) string {\n return \"Hello World!\"\n}\n"}]},"deposit":"1ugnot"}],"fee":{"gas_wanted":"10000000","gas_fee":"50000ugnot"},"signatures":[{"pub_key":{"@type":"/tm.PubKeySecp256k1","value":"AsjfwZC/yNFtNUv0OpjSZsogpMYydznAInXb5xiyT0cr"},"signature":"07PQCPUnIDjalh3LgAD9fJl04Bank2kCryrfi+68ohFmiHQnAJw9uYwJ3gEwVeNaDoreZMcpitPYQAQ791zrcA=="}],"memo":"Deployed through play.gno.land"},"blockNum":"450483"} |
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":"g15wmukt79xymnnu6c4de32trnufudqum60yrxu8","deposit":""} | ||
{"creator":"g1fsu3z335h5qngf7t3lmakvpmpwg9ae76tqwh7c","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,117 +1,17 @@ | ||
package mynonfungibletoken | ||
package counter | ||
|
||
import ( | ||
"std" | ||
"gno.land/p/demo/grc/grc721" | ||
"gno.land/p/demo/users" | ||
"gno.land/p/demo/ufmt" | ||
) | ||
import "fmt" | ||
|
||
var ( | ||
admin std.Address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // set admin account | ||
mynonfungibletoken = grc721.NewBasicNFT("mynonfungibletoken", "MNFT") | ||
) | ||
var count int | ||
|
||
func init() { | ||
mintNNFT(admin, 10) // @administrator (initial supply = 10 NFTs) | ||
func Increment() { | ||
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 Decrement() { | ||
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") | ||
} | ||
} | ||
func Render(_ string) string { | ||
return fmt.Sprintf("Count: %d", count) | ||
} |
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":"g1dnllrdzwfhxv3evyk09y48mgn5phfjvtyrlzm7","deposit":""} | ||
{"creator":"g1ghfakgzr6q77etpg8jtas6llg4uvqnfl8skxxq","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,13 +1,5 @@ | ||
package hello | ||
|
||
var { | ||
hello string | ||
} | ||
|
||
func SetHello(msg string){ | ||
hello = msg | ||
} | ||
|
||
func GetHello() string { | ||
return hello | ||
func Render(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":"g1v4e0gv2m6gpqh6mx0auu6x6gmep9yt6cxj6q5f","deposit":""} | ||
{"creator":"g100xslzk674xuv3s0q8yp44cr63l26z2y4n7ycg","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":"g1c4pdj3lx0t8n9k5yay2gnw2ewkxxdxhnknnvqz","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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"creator":"g10y2y4l4g7cx23tkl9jy5u638lw5aykvx7upqaz","deposit":"1ugnot"} | ||
{"creator":"g1j8jwsce3vcry6s8qmmkxuwuhzww0j8396n3rgm","deposit":""} |
Oops, something went wrong.