Skip to content

feat(cmd/gno): add fix subcommand #4100

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

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions examples/gno.land/p/agherasie/forms/create.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package forms

import (
"std"
"chain/runtime"
"time"

"gno.land/p/demo/json"
Expand Down Expand Up @@ -64,7 +64,7 @@ func (db *FormDB) CreateForm(title string, description string, openAt string, cl
// Creating the form
form := Form{
ID: id,
Owner: std.PreviousRealm().Address(),
Owner: runtime.PreviousRealm().Address(),
Title: title,
Description: description,
CreatedAt: time.Now(),
Expand Down
8 changes: 4 additions & 4 deletions examples/gno.land/p/agherasie/forms/forms.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package forms

import (
"std"
"chain"
"time"

"gno.land/p/demo/seqid"
Expand All @@ -21,7 +21,7 @@ type Field struct {

type Form struct {
ID string
Owner std.Address
Owner chain.Address
Title string
Description string
Fields []Field
Expand All @@ -34,7 +34,7 @@ type Form struct {
// - ["Alex", 21, true, 0, [0, 1]]
type Submission struct {
FormID string
Author std.Address
Author chain.Address
Answers string // json
SubmittedAt time.Time
}
Expand Down Expand Up @@ -109,7 +109,7 @@ func (db *FormDB) GetForm(id string) (*Form, error) {
}

// GetAnswer returns an answer by its form - and author ids if it exists
func (db *FormDB) GetAnswer(formID string, author std.Address) (*Submission, error) {
func (db *FormDB) GetAnswer(formID string, author chain.Address) (*Submission, error) {
for _, answer := range db.Answers {
if answer.FormID == formID && answer.Author.String() == author.String() {
return answer, nil
Expand Down
6 changes: 3 additions & 3 deletions examples/gno.land/p/agherasie/forms/submit.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package forms

import (
"std"
"chain/runtime"
"time"
)

Expand All @@ -14,7 +14,7 @@ func (db *FormDB) SubmitForm(formID string, answers string) {
}

// Check if form was already submitted by this user
previousAnswer, err := db.GetAnswer(formID, std.PreviousRealm().Address())
previousAnswer, err := db.GetAnswer(formID, runtime.PreviousRealm().Address())
if previousAnswer != nil {
panic(errAlreadySubmitted)
}
Expand All @@ -33,7 +33,7 @@ func (db *FormDB) SubmitForm(formID string, answers string) {
answer := Submission{
FormID: formID,
Answers: answers,
Author: std.PreviousRealm().Address(),
Author: runtime.PreviousRealm().Address(),
SubmittedAt: time.Now(),
}
db.Answers = append(db.Answers, &answer)
Expand Down
10 changes: 5 additions & 5 deletions examples/gno.land/p/demo/acl/acl.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package acl

import (
"std"
"chain"

"gno.land/p/demo/avl"
)
Expand All @@ -18,7 +18,7 @@ type Directory struct {
userGroups avl.Tree // std.Address -> []string
}

func (d *Directory) HasPerm(addr std.Address, verb, resource string) bool {
func (d *Directory) HasPerm(addr chain.Address, verb, resource string) bool {
// FIXME: consider memoize.

// user perms
Expand Down Expand Up @@ -52,11 +52,11 @@ func (d *Directory) getBucketPerms(bucket string) perms {
return perms{}
}

func (d *Directory) HasRole(addr std.Address, role string) bool {
func (d *Directory) HasRole(addr chain.Address, role string) bool {
return d.HasPerm(addr, "role", role)
}

func (d *Directory) AddUserPerm(addr std.Address, verb, resource string) {
func (d *Directory) AddUserPerm(addr chain.Address, verb, resource string) {
bucket := "u:" + addr.String()
p := perm{
verbs: []string{verb},
Expand Down Expand Up @@ -86,7 +86,7 @@ func (d *Directory) addPermToBucket(bucket string, p perm) {
d.permBuckets.Set(bucket, ps)
}

func (d *Directory) AddUserToGroup(user std.Address, group string) {
func (d *Directory) AddUserToGroup(user chain.Address, group string) {
existing, ok := d.userGroups.Get(user.String())
var groups []string
if ok {
Expand Down
10 changes: 5 additions & 5 deletions examples/gno.land/p/demo/acl/acl_test.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package acl

import (
"std"
"chain"
"testing"

"gno.land/p/demo/testutils"
Expand Down Expand Up @@ -109,25 +109,25 @@ func Test(t *testing.T) {
shouldHasPerm(t, dir, cst, "read", "r/demo/boards:gnolang/1") // new
}

func shouldHasRole(t *testing.T, dir *Directory, addr std.Address, role string) {
func shouldHasRole(t *testing.T, dir *Directory, addr chain.Address, role string) {
t.Helper()
check := dir.HasRole(addr, role)
uassert.Equal(t, true, check, ufmt.Sprintf("%s should has role %s", addr.String(), role))
}

func shouldNotHasRole(t *testing.T, dir *Directory, addr std.Address, role string) {
func shouldNotHasRole(t *testing.T, dir *Directory, addr chain.Address, role string) {
t.Helper()
check := dir.HasRole(addr, role)
uassert.Equal(t, false, check, ufmt.Sprintf("%s should not has role %s", addr.String(), role))
}

func shouldHasPerm(t *testing.T, dir *Directory, addr std.Address, verb string, resource string) {
func shouldHasPerm(t *testing.T, dir *Directory, addr chain.Address, verb string, resource string) {
t.Helper()
check := dir.HasPerm(addr, verb, resource)
uassert.Equal(t, true, check, ufmt.Sprintf("%s should has perm for %s - %s", addr.String(), verb, resource))
}

func shouldNotHasPerm(t *testing.T, dir *Directory, addr std.Address, verb string, resource string) {
func shouldNotHasPerm(t *testing.T, dir *Directory, addr chain.Address, verb string, resource string) {
t.Helper()
check := dir.HasPerm(addr, verb, resource)
uassert.Equal(t, false, check, ufmt.Sprintf("%s should not has perm for %s - %s", addr.String(), verb, resource))
Expand Down
10 changes: 5 additions & 5 deletions examples/gno.land/p/demo/blog/blog.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package blog

import (
"std"
"chain"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -131,7 +131,7 @@ func (b Blog) Render(path string) string {
return router.Render(path)
}

func (b *Blog) NewPost(publisher std.Address, slug, title, body, pubDate string, authors, tags []string) error {
func (b *Blog) NewPost(publisher chain.Address, slug, title, body, pubDate string, authors, tags []string) error {
if _, found := b.Posts.Get(slug); found {
return ErrPostSlugExists
}
Expand Down Expand Up @@ -233,7 +233,7 @@ type Post struct {
UpdatedAt time.Time
Comments avl.Tree
Authors []string
Publisher std.Address
Publisher chain.Address
Tags []string
CommentIndex int
}
Expand All @@ -253,7 +253,7 @@ func (p *Post) Update(title, body, publicationDate string, authors, tags []strin
return p.Blog.prepareAndSetPost(p, true)
}

func (p *Post) AddComment(author std.Address, comment string) error {
func (p *Post) AddComment(author chain.Address, comment string) error {
if p == nil {
return ErrNoSuchPost
}
Expand Down Expand Up @@ -379,7 +379,7 @@ func (p *Post) Summary() string {
type Comment struct {
Post *Post
CreatedAt time.Time
Author std.Address
Author chain.Address
Comment string
}

Expand Down
8 changes: 4 additions & 4 deletions examples/gno.land/p/demo/entropy/entropy.gno
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
package entropy

import (
"chain/runtime"
"math"
"std"
"time"
)

Expand Down Expand Up @@ -57,15 +57,15 @@ func (i *Instance) addEntropy() {

// handle callers
{
caller1 := std.CallerAt(1).String()
caller1 := runtime.CallerAt(1).String()
i.djb2String(caller1)
caller2 := std.CallerAt(2).String()
caller2 := runtime.CallerAt(2).String()
i.djb2String(caller2)
}

// height
{
height := std.ChainHeight()
height := runtime.ChainHeight()
if height >= math.MaxUint32 {
height -= math.MaxUint32
}
Expand Down
4 changes: 2 additions & 2 deletions examples/gno.land/p/demo/gnorkle/gnorkle/instance.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package gnorkle

import (
"chain/runtime"
"errors"
"std"
"strings"

"gno.land/p/demo/avl"
Expand Down Expand Up @@ -106,7 +106,7 @@ type PostMessageHandler interface {
// TODO: Consider further message types that could allow administrative action such as modifying
// a feed's whitelist without the owner of this oracle having to maintain a reference to it.
func (i *Instance) HandleMessage(msg string, postHandler PostMessageHandler) (string, error) {
caller := string(std.OriginCaller())
caller := string(runtime.OriginCaller())

funcType, msg := message.ParseFunc(msg)

Expand Down
Loading
Loading