Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new realm /r/demo/art/haiku #860

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

schollz
Copy link
Contributor

@schollz schollz commented May 30, 2023

Background: /r/demo/art/haiku is a implementation of a smart contract for creating and transferring text-based NFTs that conform to haiku poetry standards. The contract integrates a 240 kB wordlist into the contract that is used to check syllable counts and whether words are valid English, so that only valid Haikus can be added. Haikus are given a "rarity" score that can be used as a indicator of artificial scarcity.

Add this realm to gno.land:

gnokey maketx addpkg --pkgpath "gno.land/r/demo/art/haikus" --pkgdir "examples/gno.land/r/demo/art/haiku/app" --deposit 1000000ugnot --gas-fee 200000ugnot --gas-wanted 10000000 --broadcast --chainid dev --remote localhost:26657 <YOURKEY>

Mint a haiku:

 gnokey maketx call --pkgpath "gno.land/r/demo/art/haikus" --func "Mint" --args "Knock over a plant,\ncat's innocent eyes proclaim,\n'Nature needed that!'" --gas-fee "1000000ugnot" --gas-wanted "8000000" --broadcast --chainid dev --remote localhost:26657  <YOURKEY>

Transfer a haiku:

gnokey maketx call --pkgpath "gno.land/r/demo/art/haikus" --func "Transfer" --args "g1kn4yg8cxc65e6zgzwykwmng2wczkk2mwu5xsgv" --args "be95708bce28ee9eea54a3ab6a719e24b9408aa753c3583ad8a2336b87ec3ca9" --gas-fee "1000000ugnot" --gas-wanted "8000000" --broadcast --chainid dev --remote localhost:26657 <OWNERKEY>

In this case the g1kn4yg8cxc65e6zgzwykwmng2wczkk2mwu5xsgv is the recipient address and the be95708bce28ee9eea54a3ab6a719e24b9408aa753c3583ad8a2336b87ec3ca9 is the token ID of the haiku to transfer (available from gno.land). Only owners can transfer.

Register a user:

gnokey maketx call --pkgpath "gno.land/r/demo/users" --func "Register" --args "" --args "schollz" --args "https://schollz.com" --gas-fee "1000000ugnot" --gas-wanted "2000000" --broadcast --chainid dev --remote localhost:26657 --send "200000000ugnot" <YOURKEY>

If you register a user, then your username will show up on the haiku pages instead of the address, using the users realm.

Screenshots

All haikus displayed on main page.

Screenshot 2023-05-30 at 11-22-52 Gno land

Clicking on a user shows their creations:

Screenshot 2023-05-30 at 11-23-10 Gno land

Clicking on a user collection shows their collection:

Screenshot 2023-05-30 at 11-23-19 Gno land

Rendering of a single haiku:

Screenshot 2023-05-30 at 11-23-38 Gno land

Rarity static page information:

Screenshot 2023-05-30 at 11-23-58 Gno land

@schollz schollz requested review from jaekwon, moul and a team as code owners May 30, 2023 19:05
@github-actions github-actions bot added 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages. labels May 30, 2023
@moul
Copy link
Member

moul commented May 31, 2023

Loving it. I'm a strong advocate for seemingly trivial PRs that foster creativity, embrace diversity, and unveil novel patterns.

Comment on lines 50 to 54
for _, line := range strings.Split(rawwordlist, "\n") {
line = strings.TrimSpace(line)
word := strings.Replace(line, ";", "", -1)
wordsWithSyllables.Set(word, strings.Count(line, ";")+1)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should encourage offchain codegen for such needs.

It also reminds me what @albttx is doing with merkle tree based airdrops.

Copy link
Member

@moul moul May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to work on a pager system to initialize a contract with a lot of data:

// func init()

var paused = true

func InitBatch(batch string, done bool) {
  assertIsAdmin()
  handleBatch(batch)
  if done {
    paused = false
  }
}

func PublicMethod() {
  assertIsNotPaused()
  // ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @moul, I've been going through some iterations on this and haven't really enabled a big improvement yet.

offchain codegen for such needs.

I'm not sure I am grokking this solution - what do you mean by offchain here? Is there an example to follow?

Another option is to work on a pager

Yeah - this option makes sense - if I understand correctly I can just load up the wordlist from the calling gno maketx call with an authorized call to add words...that solution works, but I feel like it would miss out on one of the gno.land benefits - that the source code is available to publicly view (unless there is a way to view a avl.Tree of a realm?). In this example, it is nice that the wordlist is publicly available so it is completely transparent about the inclusion rules to submit poems.

@thehowl thehowl marked this pull request as draft August 24, 2023 15:26
@thehowl thehowl marked this pull request as ready for review August 24, 2023 15:26
@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 8, 2023
@schollz schollz closed this Sep 14, 2023
@schollz
Copy link
Contributor Author

schollz commented Sep 14, 2023

sorry! did not mean to clsoe this PR, I rebased the branch and it seemed to have closed it automatically. I'm working on bringing it up to speed on the current main

@schollz schollz reopened this Sep 14, 2023
@github-actions github-actions bot removed 📦 🤖 gnovm Issues or PRs gnovm related 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Sep 14, 2023
@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (61f3ada) 47.08% compared to head (17b266d) 47.08%.
Report is 7 commits behind head on master.

❗ Current head 17b266d differs from pull request most recent head e76571a. Consider uploading reports for the commit e76571a to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #860   +/-   ##
=======================================
  Coverage   47.08%   47.08%           
=======================================
  Files         365      365           
  Lines       61156    61156           
=======================================
  Hits        28793    28793           
  Misses      30011    30011           
  Partials     2352     2352           
Flag Coverage Δ
gnovm-_test.cmd 45.89% <ø> (ø)
gnovm-_test.gnolang.native 63.09% <ø> (ø)
gnovm-_test.gnolang.other 16.63% <ø> (ø)
gnovm-_test.gnolang.pkg0 17.98% <ø> (ø)
gnovm-_test.gnolang.pkg1 8.21% <ø> (ø)
gnovm-_test.gnolang.pkg2 9.87% <ø> (ø)
gnovm-_test.gnolang.realm 41.68% <ø> (ø)
gnovm-_test.gnolang.stdlibs 53.53% <ø> (ø)
gnovm-_test.pkg 25.96% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@schollz
Copy link
Contributor Author

schollz commented Sep 19, 2023

@moul and @thehowl , this is again ready for review!

@schollz
Copy link
Contributor Author

schollz commented Sep 20, 2023

also, I should note that I wanted to use the basicNFT from examples/gno.land/p/demo/grc/grc721/basic_nft.gno so I also made a change in this PR to export it. If that's not kosher, let me know. I can either break it out into a separate PR or just fork the grc721 directly into the haiku app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: 🌟 Wanted for Launch
Status: No status
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants