Skip to content

feat: better unknown account error #4166

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gno.land/pkg/sdk/vm/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
}
creatorAcc := vm.acck.GetAccount(ctx, creator)
if creatorAcc == nil {
return std.ErrUnknownAddress(fmt.Sprintf("account %s does not exist", creator))
return std.ErrUnknownAddress(fmt.Sprintf("account %s has not been initialized. does it have coins?", creator))

Check warning on line 339 in gno.land/pkg/sdk/vm/keeper.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/keeper.go#L339

Added line #L339 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return std.ErrUnknownAddress(fmt.Sprintf("account %s has not been initialized. does it have coins?", creator))
return std.ErrUnknownAddress(fmt.Sprintf("account %s does not exist or has not been initialized. does it have coins?", creator))

We still want the error to make sense if an address doesn't exist at all.

Copy link
Member

Choose a reason for hiding this comment

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

it's a rhetorical question - accounts that don't exist don't have coins.

I'd prefer something like account %s does not exist, it must receive coins to be created so we point the user to a clearer problem and solution

}
if err := msg.Package.Validate(); err != nil {
return ErrInvalidPkgPath(err.Error())
Expand Down Expand Up @@ -575,7 +575,7 @@
// Validate arguments.
callerAcc := vm.acck.GetAccount(ctx, caller)
if callerAcc == nil {
return "", std.ErrUnknownAddress(fmt.Sprintf("account %s does not exist", caller))
return "", std.ErrUnknownAddress(fmt.Sprintf("account %s has not been initialized. does it have coins?", caller))

Check warning on line 578 in gno.land/pkg/sdk/vm/keeper.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/keeper.go#L578

Added line #L578 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return "", std.ErrUnknownAddress(fmt.Sprintf("account %s has not been initialized. does it have coins?", caller))
return "", std.ErrUnknownAddress(fmt.Sprintf("account %s does not exist or has not been initialized. does it have coins?", caller))

}
if err := msg.Package.Validate(); err != nil {
return "", ErrInvalidPkgPath(err.Error())
Expand Down
Loading