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: In gnoNativeService, support using the remote Gnokey Mobile service #163

Merged

Conversation

jefft0
Copy link
Contributor

@jefft0 jefft0 commented Aug 8, 2024

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 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 <jeff@thefirst.org>
…ent. Add getClient() and use it in QueryAccount, etc. See the PR.

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
…remote service.

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@jefft0 jefft0 requested a review from D4ryl00 August 8, 2024 15:03
…ey Mobile service to sign the tx. See the PR.

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@jefft0 jefft0 force-pushed the chore/gnoNativeService-support-useGnokeyMobile branch from 57b3f96 to c2c7283 Compare August 8, 2024 15:10
@jefft0 jefft0 requested review from iuricmp and removed request for D4ryl00 August 12, 2024 08:14
…t in GnoNativeApi initClient to call startGnokeyMobileService().

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@jefft0 jefft0 marked this pull request as draft August 13, 2024 12:43
@jefft0 jefft0 marked this pull request as ready for review August 13, 2024 12:54
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
Copy link
Contributor

@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.

👍

@jefft0 jefft0 merged commit 69d4f3e into gnolang:main Aug 14, 2024
@jefft0 jefft0 deleted the chore/gnoNativeService-support-useGnokeyMobile branch August 14, 2024 14:24
Copy link

🎉 This PR is included in version 1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants