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

Add React Native bridge method to query wallet availability #168

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sdlaver
Copy link
Contributor

@sdlaver sdlaver commented Jul 26, 2022

No description provided.

@@ -132,7 +132,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.solanamobile:mobile-wallet-adapter-clientlib:0.2.0"
implementation "com.solanamobile:mobile-wallet-adapter-clientlib:0.2.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This hasn't been published yet; to verify that this code compiled, I published to my local Maven repo

Copy link
Contributor

Choose a reason for hiding this comment

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

Oooh can you lazytwitter me and share how to do that?

Copy link
Contributor

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

To finish this up, the new method would have to be threaded through js/packages/mobile-wallet-adapter-protocol/src/__forks__/react-native/transact.ts.

…but hold up on that. I have some feedback on #169.

@@ -41,6 +41,15 @@ class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
return "SolanaMobileWalletAdapter"
}

@ReactMethod
fun isWalletAvailable(promise: Promise) {
promise.resolve(
Copy link
Contributor

Choose a reason for hiding this comment

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

Since isWalletEndpointAvailable is sync, we don't need to do the promise dance. This @ReactMethod can just return a boolean.

@@ -41,6 +41,15 @@ class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
return "SolanaMobileWalletAdapter"
}

@ReactMethod
fun isWalletAvailable(promise: Promise) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned that we haven't covered the case where:

  1. You start a dApp
  2. It tells you the wallet is not available
  3. You install the wallet
  4. You return to your dApp

If your dApp doesn't revalidate every time you foreground it, it will still claim that the wallet is not installed when in fact, it is.

@steveluscher
Copy link
Contributor

I might add an event emitter to this in the RN SDK that rechecks wallet availability every time the app is foregrounded. I'll finish this up.

@steveluscher steveluscher self-assigned this Jul 27, 2022
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