Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: In Keybase GetByAddress, change generic error to NewErrKeyNotFou…
…nd (gnolang#1316) The Keybase method `GetByName` [returns the specific error](https://github.com/gnolang/gno/blob/199cd29584d44812a0aec3606bbff37a320c609a/tm2/pkg/crypto/keys/keybase.go#L184) `ErrKeyNotFound` if the key is not found. This is very nice because the GnoMobile API wraps this with a gRPC function and we use `keyerror.IsErrKeyNotFound` to check the error type and convert it to the gRPC equivalent. But the Keybase method `GetByAddress` just [returns a generic error](https://github.com/gnolang/gno/blob/199cd29584d44812a0aec3606bbff37a320c609a/tm2/pkg/crypto/keys/keybase.go#L192) if the key isn't found. (I assume that it is not intentional to restrict this to a generic error.) This means that the gRPC interface must search the error string for "not found", which is unreliable. We would prefer to use `keyerror.IsErrKeyNotFound`. Furthermore, `GetByNameOrAddress` [can return an error from either](https://github.com/gnolang/gno/blob/199cd29584d44812a0aec3606bbff37a320c609a/tm2/pkg/crypto/keys/keybase.go#L175-L177) `GetByName` or `GetByAddress`. It is preferable to return just one error type for key not found. This pull request updates `GetByAddress` to use `keyerror.NewErrKeyNotFound` with the same error message. <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] 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> Signed-off-by: Jeff Thompson <[email protected]>
- Loading branch information