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
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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?

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

LocalAssociationIntentCreator.isWalletEndpointAvailable(
reactApplicationContext.packageManager
)
)
}

@ReactMethod
fun startSession(config: ReadableMap?, promise: Promise) = launch {
mutex.lock()
Expand Down