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

chore: Add gRPC Gnokey Mobile service #2

Merged
merged 5 commits into from
Aug 14, 2024

Conversation

jefft0
Copy link
Collaborator

@jefft0 jefft0 commented Aug 8, 2024

This PR adds support for the gRPC GnokeyMobile service.

  • Add .gitignore .
  • In .tool-versions, add buf .
  • In api, add gnokey_mobile_rpc.proto to define GnokeyMobileService with GetRemote, ListKeyInfo and SignTx . These re-use request and response types from Gno Native Kit.
  • In service, add service.go to define GnokeyMobileService and api.go to implement it.
  • Add a Makefile and run make regenerate .
  • In test, add goserver which starts a Gnokey Mobile service and simulates the user selecting the test_1 account. (After we update the Gnokey Mobile app to start this service, we may remove this test.)

@jefft0 jefft0 requested a review from D4ryl00 August 8, 2024 07:56
Copy link
Collaborator

@iuricmp iuricmp left a comment

Choose a reason for hiding this comment

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

Just one single modification to use npm instead of yarn.
We don't need yarn for now.

Makefile Outdated Show resolved Hide resolved
@jefft0 jefft0 merged commit eb333b9 into gnolang:main Aug 14, 2024
@jefft0 jefft0 deleted the chore/add-gRPC-GnokeyMobileService branch August 14, 2024 14:01
jefft0 added a commit to gnolang/gnonative that referenced this pull request Aug 14, 2024
…rvice (#163)

PR gnolang/gnokey-mobile#2 creates the Gnokey
Mobile service. This PR updates `GnoNativeService` with the option to
use the remote Gnokey Mobile service as needed (for example, to sign a
transaction).

* In BridgeConfig and service.Config, add the config flag
`UseGnokeyMobile`.
* In `initService`, if `UseGnokeyMobile` then set `gnokeyMobileClient`
to a gRPC client connected to the remote Gnokey Mobile service. Set
`client` to a gnoclient without a Keybase (because the purpose is to use
Keybase in the remote Gnokey Mobile service).
* In `gnoNativeService`, add `getClient` which returns the correct
`gnoclient.Client`. If not `useGnokeyMobile` then simply return
`s.client` . If `useGnokeyMobile` then it's possible that Gnokey Mobile
has been changed to use a different gno.land remote, so we must call the
Gnokey Mobile method `GetRemote` . If this is different from our local
`s.remote` then reconfigure the `RPCClient` of the gnoclient and save
the new `s.remote`. Change `QueryAccount`, `Query`, `Render` and `QEval`
to call `getClient` and then proceed as normal. This means that if an
app is using Gno Native Kit with `UseGnokeyMobile`, then the app can
send these queries directly to the gno.land remote node, but we must
make sure that it is the correct remote.
* In `GetRemote` and `ListKeyInfo`, if `useGnokeyMobile` then we
directly use the Gnokey Mobile service.
* In `Call`, if `useGnokeyMobile` then use the local `MakeCallTx` to
make the transaction. Use the `SignTx` API of the remote Gnokey Mobile
service to sign the transaction. Then use the local `BroadcastTxCommit`
to broadcast the signed transaction and get the streaming result.

The above changes allow an app to configure its Gno Native Kit to use a
gRPC client with the Gnokey Mobile service. But we still need the Gnokey
Mobile app to start the Gnokey Mobile gRPC server. The following changes
allow the Gnokey Mobile app to set `start_gnokey_mobile_service` in [the
configuration](https://github.com/gnolang/dsocial/blob/925846f2055e9f107cd91ddb776afa3e7be06820/mobile/app/_layout.tsx#L10-L13)
for its `GnoNativeProvider`.

* In the Go `Bridge`, add `StartGnokeyMobileService`. See the
description comment. Add this method to the TypeScript
`GoBridgeInterface` and to the Java and Swift `GnonativeModule`.
* In the TypeScript `Config`, add a flag `start_gnokey_mobile_service`.
Check this flag in the `GnoNativeApi` `initClient` and call
`startGnokeyMobileService()`.

---------

Signed-off-by: Jeff Thompson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants