Skip to content

Commit

Permalink
chore: add misc/list-gnophers and .mailmap (gnolang#1265)
Browse files Browse the repository at this point in the history
```console
$ cd ./misc/list-gnophers
$ ./main.sh
```

```csv
1617467419,53785+jaekwon@users.noreply.github.com,./examples/gno.land/p/demo/flow/flow.gno
1651096034,94029+moul@users.noreply.github.com,./examples/gno.land/p/demo/grc/grc721/igrc721.gno
1673524438,hariom.verma@tendermint.com,./examples/gno.land/p/demo/grc/grc721/basic_nft.gno
1677669053,100383075+Jammyaa@users.noreply.github.com,./examples/gno.land/p/demo/grc/grc1155/basic_grc1155_token.gno
1678259597,350354+grepsuzette@users.noreply.github.com,./examples/gno.land/r/demo/deep/very/deep/render.gno
1678709422,pushkarshetye803@gmail.com,./examples/gno.land/r/demo/groups/group.gno
1684921090,contact@albttx.tech,./examples/gno.land/p/demo/merkle/merkle.gno
1687179019,nir1218@users.noreply.github.com,./examples/gno.land/r/x/nir1218_evaluation_proposal/category.gno
1687263124,zack.scholl@gmail.com,./examples/gno.land/p/demo/microblog/microblog.gno
```

- Translate into GitHub usernames.
- Share the gnopher list on `r/gh` (gnolang#1134).
- Create a new `r/gnoland/gnophers` page with the following features:
  - Add a widget on `r/gnoland/home` displaying the "latest gnophers."
- Create a helper function like
`r/gnoland/gnophers.NumberByAddr("g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq`)
-> `(2 int)` to use this info on other meta profiles, such as the future
"gnolinkedin" mixing facts and personal presentation
(gnolang/game-of-realms#5).
- Create a `r/gnoland/gnophers:username` route that returns a badge with
the username, gnopher number, "gnopher since <date>," and a `gnoface`
(gnolang#690).
- Stop checking and order t-shirts for the first 100 official gnophers.

```markdown
  |||||||
 ////////\
 |       |
 | ~   . |
)| X   X |.
 |       |
 |   C   |
 |       |
 |  __/  |
 |       |
 \~~~~~~~/
Gnopher#1
```

```markdown
  |||||||
 ////////\
 |       |
 | ~   . |
)| X   X |.
 |       |
 |   C   |
 |       |
 |  __/  |
 |       |
 \~~~~~~~/
Gnopher#2
```

cc @gnolang/devrels

Signed-off-by: moul <94029+moul@users.noreply.github.com>

SetTokenURI wip
  • Loading branch information
web-flow authored and irreverentsimplicity committed Oct 27, 2023
1 parent 7dee385 commit 0ff9ced
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# man 5 gitmailmap
# git log --mailmap --pretty=short | grep ^Author: | sort -u
Jae Kwon <53785+jaekwon@users.noreply.github.com> Jae Kwon <jae@tendermint.com>
Jae Kwon <53785+jaekwon@users.noreply.github.com> Jae Kwon <jae@gno.land>
Jae Kwon <53785+jaekwon@users.noreply.github.com> jaekwon <jae@tendermint.com>
Jae Kwon <53785+jaekwon@users.noreply.github.com> Naut Jae <naut_jae@Nauts-Mac-mini.local>
Thomas Bruyelle <thomas.bruyelle@tendermint.com> Thomas Bruyelle <thomas.bruyelle@gmail.com>
Thomas Bruyelle <thomas.bruyelle@tendermint.com> Thomas Bruyelle <thomasbruyelle@hey.com>
Miloš Živković <milos.zivkovic@tendermint.com> Miloš Živković <milos@zmilos.com>
Hariom Verma <hariom.verma@tendermint.com> Hariom Verma <hariom18599@gmail.com>
Giancarlos Salas <me@giansalex.dev> Giancarlos Salas <giansalex@gmail.com>
Morgan <morgan@morganbaz.com> Morgan <git@howl.moe>
20 changes: 20 additions & 0 deletions examples/gno.land/p/demo/grc/grc721/basic_nft.gno
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ func (s *basicNFT) TokenURI(tid TokenID) (string, error) {
return uri.(string), nil
}

func (s *basicNFT) SetTokenURI(tid TokenID, TokenURI string) (string, error) {
owner, found := s.owners.Get(string(tid))
if !found {
return "", ErrInvalidTokenId
}

owner, err := s.OwnerOf(tid)
if err != nil {
return "", ErrCallerIsNotOwner
}

s.tokenURIs.Set(string(tid), TokenURI)
storedURI, added := s.tokenURIs.Get(string(tid))
if !added {
return "", ErrTokenURINotSet
}
tokenURIData := storedURI.(string)
return tokenURIData, nil
}

// IsApprovedForAll returns true if operator is approved for all by the owner.
// Otherwise, returns false
func (s *basicNFT) IsApprovedForAll(owner, operator std.Address) bool {
Expand Down
39 changes: 39 additions & 0 deletions examples/gno.land/p/demo/grc/grc721/basic_nft_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,45 @@ func TestOwnerOf(t *testing.T) {
}
}

func TestSetTokenURI(t *testing.T) {
dummy := NewBasicNFT(dummyNFTName, dummyNFTSymbol)
if dummy == nil {
t.Errorf("should not be nil")
}

tokenID := "123"
owner := "owner1"
tokenURI := "http://example.com/token"

// Test case: Invalid token ID
_, err := dummy.SetTokenURI(tokenID, tokenURI)
if err != ErrInvalidTokenId {
t.Errorf("Expected error %v, got %v", ErrInvalidTokenId, err)
}

// Set owner for the token ID
dummy.owners[tokenID] = owner

// Test case: Caller is not owner
_, err = dummy.SetTokenURI(tokenID, tokenURI)
if err != ErrCallerIsNotOwner {
t.Errorf("Expected error %v, got %v", ErrCallerIsNotOwner, err)
}

// Set correct owner (mock the owner check)
dummy.owners[tokenID] = "correctOwner"

// Test case: Setting and retrieving TokenURI
setURI, err := dummy.SetTokenURI(tokenID, tokenURI)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if setURI != tokenURI {
t.Errorf("Expected URI %v, got %v", tokenURI, setURI)
}

}

func TestIsApprovedForAll(t *testing.T) {
dummy := NewBasicNFT(dummyNFTName, dummyNFTSymbol)
if dummy == nil {
Expand Down
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/grc/grc721/errors.gno
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ var (
ErrTransferToNonGRC721Receiver = errors.New("transfer to non GRC721Receiver implementer")
ErrCallerIsNotOwnerOrApproved = errors.New("caller is not token owner or approved")
ErrTokenIdAlreadyExists = errors.New("token id already exists")
ErrTokenURINotSet = errors.New("tokenURI could not be set")
)
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/grc/grc721/igrc721.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "std"
type IGRC721 interface {
BalanceOf(owner std.Address) (uint64, error)
OwnerOf(tid TokenID) (std.Address, error)
SetTokenURI(tid TokenID, tokenURI string) (string, error)
SafeTransferFrom(from, to std.Address, tid TokenID) error
TransferFrom(from, to std.Address, tid TokenID) error
Approve(approved std.Address, tid TokenID) error
Expand Down
35 changes: 35 additions & 0 deletions misc/list-gnophers/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

main() {
cd ../..
for file in $(list_gno_files); do
extract_file_metadata $file
done > gno_file_commits.csv
echo
cat gno_file_commits.csv | sort_by_date | unique_by_author
}

list_gno_files() {
# list .gno file in examples/, remove tests and unit tests
find ./examples -name "*.gno" | grep -v _filetest.gno | grep -v _test.gno | grep -v gno.land/r/demo/tests
}

extract_file_metadata() {
file=$1
# get the first commit date of the file
first_commit_date=$(git log --pretty=format:%ct --follow $file | tail -n 1)
# get the email of the first contributor of the file
email=$(git log --mailmap --pretty=format:%aE --follow $file | tail -n 1)
# print the file name, first commit date, and email
echo "$first_commit_date,$email,$file"
}

sort_by_date() {
sort -t, -k1
}

unique_by_author() {
awk -F, '!seek[$2]++'
}

main

0 comments on commit 0ff9ced

Please sign in to comment.