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

Panic when getting keypair information #2133

Closed
linhpn99 opened this issue May 17, 2024 · 0 comments
Closed

Panic when getting keypair information #2133

linhpn99 opened this issue May 17, 2024 · 0 comments
Labels
🐞 bug Something isn't working

Comments

@linhpn99
Copy link
Contributor

linhpn99 commented May 17, 2024

My Problem :
In case I'm trying to use a signer without passing an account param to sign transaction, I expect this function to return an error as the second output, allowing me to catch the exception without a panic() inside

// Create signer
signer := gnoclient.SignerFromKeybase{
	Keybase:  keybase,
	Account:  "", // Name of your keypair in keybase
	Password: "",      // Password to decrypt your keypair
	ChainID:  "test3", // id of Gno.land chain
}

Output:

panic: should not happen at line 59 gno.land/pkg/gnoclient/signer.go

// Info gets keypair information.
func (s SignerFromKeybase) Info() keys.Info {
	info, err := s.Keybase.GetByNameOrAddress(s.Account)
	if err != nil {
		panic("should not happen")
	}
	return info
}

My suggestion :

// Info gets keypair information.
func (s SignerFromKeybase) Info() (keys.Info, error) {
	info, err := s.Keybase.GetByNameOrAddress(s.Account)
	if err != nil {
		return nil, err // Return an empty Info and the error
	}
	return info, nil
}
@Kouteki Kouteki added the 🐞 bug Something isn't working label May 31, 2024
thehowl pushed a commit that referenced this issue Jun 20, 2024
Relate to #2133

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [ ] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Miloš Živković <milos@zmilos.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
gfanton pushed a commit to gfanton/gno that referenced this issue Jul 23, 2024
…g#2300)

Relate to gnolang#2133

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [ ] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Miloš Živković <milos@zmilos.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Development

No branches or pull requests

2 participants