From 47c0b81b1d814bfcfff6bafc9db575295cdd4eed Mon Sep 17 00:00:00 2001 From: stefann-01 Date: Mon, 7 Oct 2024 19:06:33 +0200 Subject: [PATCH] Run make fmt -C ./examples --- examples/gno.land/r/stefann/config/config.gno | 2 +- examples/gno.land/r/stefann/home/home.gno | 207 +++++++++--------- 2 files changed, 104 insertions(+), 105 deletions(-) diff --git a/examples/gno.land/r/stefann/config/config.gno b/examples/gno.land/r/stefann/config/config.gno index b35bebec177..3ec1cd6cff4 100644 --- a/examples/gno.land/r/stefann/config/config.gno +++ b/examples/gno.land/r/stefann/config/config.gno @@ -50,4 +50,4 @@ func AssertAuthorized() { if caller != main && caller != backup { panic("config: unauthorized") } -} \ No newline at end of file +} diff --git a/examples/gno.land/r/stefann/home/home.gno b/examples/gno.land/r/stefann/home/home.gno index 02950f4ce57..98d41fffa71 100644 --- a/examples/gno.land/r/stefann/home/home.gno +++ b/examples/gno.land/r/stefann/home/home.gno @@ -1,15 +1,14 @@ package home import ( - "std" - "sort" + "sort" + "std" - "gno.land/p/demo/ufmt" + "gno.land/p/demo/ufmt" - "gno.land/r/stefann/config" + "gno.land/r/stefann/config" ) - type City struct { Name string URL string @@ -21,49 +20,49 @@ type Sponsor struct { } var ( - pfp string - cities []City - currentCityIndex int - aboutMe [2]string - jarLink string - maxSponsors int - sponsors []Sponsor + pfp string + cities []City + currentCityIndex int + aboutMe [2]string + jarLink string + maxSponsors int + sponsors []Sponsor totalDonated std.Coins totalDonations int ) func init() { - pfp = "https://i.ibb.co/Bc5YNCx/DSC-0095a.jpg" - cities = []City{ - {Name: "Venice", URL: "https://i.ibb.co/1mcZ7b1/venice.jpg"}, - {Name: "Tokyo", URL: "https://i.ibb.co/wNDJv3H/tokyo.jpg"}, - {Name: "São Paulo", URL: "https://i.ibb.co/yWMq2Sn/sao-paulo.jpg"}, - {Name: "Toronto", URL: "https://i.ibb.co/pb95HJB/toronto.jpg"}, - {Name: "Bangkok", URL: "https://i.ibb.co/pQy3w2g/bangkok.jpg"}, - {Name: "New York", URL: "https://i.ibb.co/6JWLm0h/new-york.jpg"}, - {Name: "Paris", URL: "https://i.ibb.co/q9vf6Hs/paris.jpg"}, - {Name: "Kandersteg", URL: "https://i.ibb.co/60DzywD/kandersteg.jpg"}, - {Name: "Rothenburg", URL: "https://i.ibb.co/cr8d2rQ/rothenburg.jpg"}, - {Name: "Capetown", URL: "https://i.ibb.co/bPGn0v3/capetown.jpg"}, - {Name: "Sydney", URL: "https://i.ibb.co/TBNzqfy/sydney.jpg"}, - {Name: "Oeschinen Lake", URL: "https://i.ibb.co/QJQwp2y/oeschinen-lake.jpg"}, - {Name: "Barra Grande", URL: "https://i.ibb.co/z4RXKc1/barra-grande.jpg"}, - {Name: "London", URL: "https://i.ibb.co/CPGtvgr/london.jpg"}, - } - currentCityIndex = 0 - jarLink = "https://TODO" - maxSponsors = 5 - aboutMe = [2]string{ - `

About Me

+ pfp = "https://i.ibb.co/Bc5YNCx/DSC-0095a.jpg" + cities = []City{ + {Name: "Venice", URL: "https://i.ibb.co/1mcZ7b1/venice.jpg"}, + {Name: "Tokyo", URL: "https://i.ibb.co/wNDJv3H/tokyo.jpg"}, + {Name: "São Paulo", URL: "https://i.ibb.co/yWMq2Sn/sao-paulo.jpg"}, + {Name: "Toronto", URL: "https://i.ibb.co/pb95HJB/toronto.jpg"}, + {Name: "Bangkok", URL: "https://i.ibb.co/pQy3w2g/bangkok.jpg"}, + {Name: "New York", URL: "https://i.ibb.co/6JWLm0h/new-york.jpg"}, + {Name: "Paris", URL: "https://i.ibb.co/q9vf6Hs/paris.jpg"}, + {Name: "Kandersteg", URL: "https://i.ibb.co/60DzywD/kandersteg.jpg"}, + {Name: "Rothenburg", URL: "https://i.ibb.co/cr8d2rQ/rothenburg.jpg"}, + {Name: "Capetown", URL: "https://i.ibb.co/bPGn0v3/capetown.jpg"}, + {Name: "Sydney", URL: "https://i.ibb.co/TBNzqfy/sydney.jpg"}, + {Name: "Oeschinen Lake", URL: "https://i.ibb.co/QJQwp2y/oeschinen-lake.jpg"}, + {Name: "Barra Grande", URL: "https://i.ibb.co/z4RXKc1/barra-grande.jpg"}, + {Name: "London", URL: "https://i.ibb.co/CPGtvgr/london.jpg"}, + } + currentCityIndex = 0 + jarLink = "https://TODO" + maxSponsors = 5 + aboutMe = [2]string{ + `

About Me

Hey there! I’m Stefan, a student of Computer Science. I’m all about exploring and adventure — whether it’s diving into the latest tech or discovering a new city, I’m always up for the challenge!

`, - `

Contributions

+ `

Contributions

I'm just getting started, but you can follow my journey through Gno.land right here 🔗

`, - } + } } func UpdateMaxSponsors(newMax int) { - config.AssertAuthorized() - maxSponsors = newMax + config.AssertAuthorized() + maxSponsors = newMax } func UpdateCities(newCities []City) { @@ -88,39 +87,39 @@ func UpdateAboutMe(col1, col2 string) { } func Donate() { - address := std.GetOrigCaller() - amount := std.GetOrigSend() - - if amount.AmountOf("ugnot") == 0 { - panic("Donation must include GNOT") - } - - found := false - - for i, sponsor := range sponsors { - if sponsor.Address == address { - sponsors[i].Amount = sponsors[i].Amount.Add(amount) - found = true - break - } - } - - if !found { - sponsors = append(sponsors, Sponsor{Address: address, Amount: amount}) - } - - totalDonated = totalDonated.Add(amount) - - totalDonations++ - - sortSponsorsByAmount() - - if len(cities) > 0 { - currentCityIndex++ - if currentCityIndex >= len(cities) { - currentCityIndex = 0 - } - } + address := std.GetOrigCaller() + amount := std.GetOrigSend() + + if amount.AmountOf("ugnot") == 0 { + panic("Donation must include GNOT") + } + + found := false + + for i, sponsor := range sponsors { + if sponsor.Address == address { + sponsors[i].Amount = sponsors[i].Amount.Add(amount) + found = true + break + } + } + + if !found { + sponsors = append(sponsors, Sponsor{Address: address, Amount: amount}) + } + + totalDonated = totalDonated.Add(amount) + + totalDonations++ + + sortSponsorsByAmount() + + if len(cities) > 0 { + currentCityIndex++ + if currentCityIndex >= len(cities) { + currentCityIndex = 0 + } + } } type SponsorSlice []Sponsor @@ -205,10 +204,10 @@ func renderTips() string { out += renderTipsJar() + "\n" - out += ufmt.Sprintf(`I am currently in %s,
tip the jar to send me somewhere else!
`, cities[currentCityIndex].Name) - - out += `
Click the jar, tip in GNOT coins, and watch my background change as I head to a new adventure!

` + "\n\n" - + out += ufmt.Sprintf(`I am currently in %s,
tip the jar to send me somewhere else!
`, cities[currentCityIndex].Name) + + out += `
Click the jar, tip in GNOT coins, and watch my background change as I head to a new adventure!

` + "\n\n" + out += renderSponsors() out += `` + "\n\n" @@ -219,49 +218,49 @@ func renderTips() string { } func formatAddress(address string) string { - if len(address) <= 8 { - return address - } - return address[:4] + "..." + address[len(address)-4:] + if len(address) <= 8 { + return address + } + return address[:4] + "..." + address[len(address)-4:] } func renderSponsors() string { - out := `

Sponsor Leaderboard

` + "\n" + out := `

Sponsor Leaderboard

` + "\n" - if len(sponsors) == 0 { - out += `

No sponsors yet. Be the first to tip the jar!

` + "\n" - } else { - numSponsors := len(sponsors) - if numSponsors > maxSponsors { - numSponsors = maxSponsors - } + if len(sponsors) == 0 { + out += `

No sponsors yet. Be the first to tip the jar!

` + "\n" + } else { + numSponsors := len(sponsors) + if numSponsors > maxSponsors { + numSponsors = maxSponsors + } - out += `