Skip to content

Conversation

@jefft0
Copy link
Contributor

@jefft0 jefft0 commented Sep 2, 2024

We want to use Gno Native Kit as a service where multiple clients are interacting with it simultaneously. Therefore we want to move away from the statefulness of the "active account", and instead require the client to specify the address of the account to use on each call. This PR adds this functionality but still supports the "active account". (We will remove "active account" when dSocial and Gnokey Mobile are changed to use the new API). This PR has four commits:

  1. Many API methods such as HasKeyByName only need to interact with the Keybase (not the RPC connection or signing). In gnoNativeService, add the field keybase and use this where possible instead of getSigner().Keybase. This is helpful because we will change getSigner.
  2. The userAccount struct currently holds the password. We change this to hold the signer (which has the password inside). In gnoNativeService, we also save the chainID separately. When SelectAccountRequest creates a new userAccount, create a new signer including the chainID. Change getSigner to take an account address and use this to look up the signer in s.userAccounts. For temporary backwards comptability, if the address is nil then use the active account.
  3. In gnoNativeService, change the gnomobile client field to only hold the rpcClient. Change getClient to take an optional signer and to return a new gnoclient.Client with the signer and the rpcClient. In Call, Send and Run, use getSigner to use the CallerAddress if available (instead of the "active account").
  4. Add API methods ActivateAccount and GetActivatedAccount. Deprecate SelectAccount and GetActiveAccount. See rpc.proto for details. In gnonativetypes.go, add an Address field to SetPasswordRequest, UpdatePasswordRequest and SignTxRequest. Use this address in getSigner. Update the interface for GnoNativeService.ClientSignTx to take the address.

(Due to circular dependencies with gnokey-mobile, this PR doesn't update the expo module. We'll do another PR.)

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@jefft0 jefft0 force-pushed the feat/use-any-activated-account branch from f075c32 to 04acf2e Compare September 2, 2024 13:34
…p addr in userAccounts. See the PR.

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@jefft0 jefft0 force-pushed the feat/use-any-activated-account branch 8 times, most recently from ce2b149 to af7dd8d Compare September 3, 2024 12:07
…gner). See the PR

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

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@jefft0 jefft0 force-pushed the feat/use-any-activated-account branch from af7dd8d to 2284a81 Compare September 3, 2024 13:52
@jefft0 jefft0 marked this pull request as ready for review September 3, 2024 14:03
@jefft0 jefft0 requested a review from D4ryl00 September 3, 2024 14:03
Copy link
Contributor

@D4ryl00 D4ryl00 left a comment

Choose a reason for hiding this comment

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

LGTM

@jefft0 jefft0 merged commit 1a678ad into gnolang:main Sep 3, 2024
@jefft0 jefft0 deleted the feat/use-any-activated-account branch September 3, 2024 14:25
jefft0 added a commit to jefft0/gnonative that referenced this pull request Sep 4, 2024
Signed-off-by: Jeff Thompson <jeff@thefirst.org>
jefft0 added a commit that referenced this pull request Sep 4, 2024
PR #172 update the API to
support using any activated account. We need to update the expo provider
to the same API. This PR has 3 commits:

1. Update go.mod to use the latest gnokey-mobile following changes in PR
gnolang/gnokey-mobile#9
2. In expo, npm install the latest gnolang_gnonative.bufbuild_es and
connectrpc_es to access the new API
3. Update expo/src/api/GnoNativeApi.ts to match the new API to use any
activated account, specified by address. Note that the address
parameters are optional for temporary backwards compatibility. When
dSocial and Gnokey Mobile are updated to use the new API and specify the
address, we will do a PR to require the address parameter, and to remove
the deprecated `selectAccount` and `getActiveAccount`.

---------

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
@github-actions
Copy link

github-actions bot commented Sep 4, 2024

🎉 This PR is included in version 1.8.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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants