-
Notifications
You must be signed in to change notification settings - Fork 362
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
chore: Add Keybase HasByNameOrAddress, HasByName and HasByAddress #1313
Merged
thehowl
merged 4 commits into
gnolang:master
from
jefft0:chore/add-Keybase-HasByNameOrAddress
Nov 9, 2023
Merged
chore: Add Keybase HasByNameOrAddress, HasByName and HasByAddress #1313
thehowl
merged 4 commits into
gnolang:master
from
jefft0:chore/add-Keybase-HasByNameOrAddress
Nov 9, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1313 +/- ##
==========================================
+ Coverage 47.87% 55.11% +7.24%
==========================================
Files 372 421 +49
Lines 63019 67456 +4437
==========================================
+ Hits 30168 37179 +7011
+ Misses 30384 27369 -3015
- Partials 2467 2908 +441
☔ View full report in Codecov by Sentry. |
jefft0
force-pushed
the
chore/add-Keybase-HasByNameOrAddress
branch
from
October 30, 2023 08:32
c3f6354
to
e8c2917
Compare
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
jefft0
force-pushed
the
chore/add-Keybase-HasByNameOrAddress
branch
from
October 30, 2023 11:41
e8c2917
to
21e9172
Compare
This was referenced Oct 30, 2023
…if possible Signed-off-by: Jeff Thompson <jeff@thefirst.org>
jefft0
force-pushed
the
chore/add-Keybase-HasByNameOrAddress
branch
from
October 31, 2023 13:49
c6d0075
to
17e247b
Compare
moul
approved these changes
Nov 6, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, makes sense.
thehowl
approved these changes
Nov 9, 2023
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
zivkovicmilos
approved these changes
Nov 9, 2023
thehowl
approved these changes
Nov 9, 2023
3 tasks
moul
pushed a commit
to moul/gno
that referenced
this pull request
Nov 14, 2023
…olang#1313) The Keybase [interface has](https://github.com/gnolang/gno/blob/7105d00e10209003ea41fbae7a4d7c463c4167c3/tm2/pkg/crypto/keys/types.go#L16C2-L18) `GetByNameOrAddress`, `GetByName` and `GetByAddress`. If an application simply wants to check if the key is in the key base, it must use one of these and check for an error, as is done [in the gnokey command line](https://github.com/gnolang/gno/blob/7105d00e10209003ea41fbae7a4d7c463c4167c3/tm2/pkg/crypto/keys/client/add.go#L159-L160). ``` _, err = kb.GetByName(name) if err == nil { // account exists, ask for user confirmation ... } ``` A GnoMobile app also needs to check for the key. But it's expensive to return the entire key info. The byte buffer must be copies multiple times, in the Keybase and in the gRPC interface, and the key info structure must be reformatted to Protobuf and then to the application's language. And not preferable to generate errors to pass information in normal program flow. In the underlying `DB` interface, there is already a [Has function](https://github.com/gnolang/gno/blob/7105d00e10209003ea41fbae7a4d7c463c4167c3/tm2/pkg/db/types.go#L13). This PR updates the `Keybase` with the related functions `HasByNameOrAddress`, `HasByName` and `HasByAddress` which use `Has` to inexpensively return a simple bool. It also updates the gnokey command line to use `HasByName` to be more clear: ``` if has, err := kb.HasByName(name); err == nil && has { // account exists, ask for user confirmation ... } ``` --------- Signed-off-by: Jeff Thompson <jeff@thefirst.org> Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Keybase interface has
GetByNameOrAddress
,GetByName
andGetByAddress
. If an application simply wants to check if the key is in the key base, it must use one of these and check for an error, as is done in the gnokey command line.A GnoMobile app also needs to check for the key. But it's expensive to return the entire key info. The byte buffer must be copies multiple times, in the Keybase and in the gRPC interface, and the key info structure must be reformatted to Protobuf and then to the application's language. And not preferable to generate errors to pass information in normal program flow.
In the underlying
DB
interface, there is already a Has function. This PR updates theKeybase
with the related functionsHasByNameOrAddress
,HasByName
andHasByAddress
which useHas
to inexpensively return a simple bool. It also updates the gnokey command line to useHasByName
to be more clear: