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

v1.1.0 Walletlib React Native #763

Merged
merged 4 commits into from
Apr 24, 2024
Merged
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 @@ -21,5 +21,24 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MobileWalletAdapterBottomSheetActivity"
android:launchMode="singleTask"
android:theme="@style/Theme.ExampleWallet.BottomSheet"
android:layout_gravity="bottom"
android:exported="true">
<!-- Default solana-wallet URI from a browser or native dapp -->
<intent-filter android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="solana-wallet" />
</intent-filter>
<!-- Any other uncategorized solana-wallet URI not covered by above -->
<intent-filter android:order="0">
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="solana-wallet" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.solanamobile.mobilewalletadapterwalletlib.reactnative
package com.mobilewalletadapterreactnative

import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.ReactRootView
Expand All @@ -14,31 +13,31 @@ class MobileWalletAdapterBottomSheetActivity : ReactActivity() {
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override protected fun getMainComponentName() = "MobileWalletAdapterEntrypoint"
override protected fun getMainComponentName() = "MobileWalletAdapterEntrypoint"

override fun onCreate(savedInstanceState: Bundle?) {

val windowLayoutParams = window.attributes

windowLayoutParams.gravity = Gravity.BOTTOM
windowLayoutParams.flags =
windowLayoutParams.flags and WindowManager.LayoutParams.FLAG_DIM_BEHIND
windowLayoutParams.flags and WindowManager.LayoutParams.FLAG_DIM_BEHIND

window.attributes = windowLayoutParams
super.onCreate(null)
}

/**
* Returns the instance of the [ReactActivityDelegate]. There the RootView is created and
* you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
* Returns the instance of the [ReactActivityDelegate]. There the RootView is created and you
* can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
* (Paper).
*/
override protected fun createReactActivityDelegate(): ReactActivityDelegate {
return MainActivityDelegate(this, mainComponentName)
}

class MainActivityDelegate(val activity: ReactActivity?, mainComponentName: String?) :
ReactActivityDelegate(activity, mainComponentName) {
ReactActivityDelegate(activity, mainComponentName) {

override protected fun createRootView(): ReactRootView {
val reactRootView = ReactRootView(getContext())
Expand All @@ -52,4 +51,4 @@ class MobileWalletAdapterBottomSheetActivity : ReactActivity() {
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
override protected fun isConcurrentRootEnabled() = false
}
}
}
4,731 changes: 2,233 additions & 2,498 deletions examples/example-react-native-wallet/yarn.lock

Large diffs are not rendered by default.

19 changes: 2 additions & 17 deletions js/packages/mobile-wallet-adapter-walletlib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,13 @@ This is a package that provides React Native bridge for the native `mobile-walle

Deep dive and read the full Mobile Wallet Adapter protocol [specification](https://solana-mobile.github.io/mobile-wallet-adapter/spec/spec.html#mobile-wallet-adapter-specification).

## TODO
- Separate bottom sheet signing experience or make optional

## Note
This package is still in alpha and is not production ready. However, the API is stable and will not change drastically, so you can begin integration with your wallet.


## Quickstart

### 1. Define your MWA entrypoint

To support bottom sheet signing flow, you need to define a React component to be the entrypoint for MWA. When the dApp sends out an intent for `solana-wallet://`, this entrypoint component will be rendered.

Define your entrypoint component in `index.js`:
```typescript
AppRegistry.registerComponent(
'MobileWalletAdapterEntrypoint', // Constant
() => YourMWAComponent,
);
```

### 2. Start listening and handling MWA requests
### 1. Start listening and handling MWA requests

Use this API to start a session and start handling requests:
```typescript
Expand Down Expand Up @@ -64,7 +49,7 @@ useMobileWalletAdapterSession(
);
```

### 3. Handling requests
### 2. Handling requests

A `MWARequest` is handled by calling `resolve(request, response)` and each request have their appropriate response types.

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 1 addition & 3 deletions js/packages/mobile-wallet-adapter-walletlib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@solana-mobile/mobile-wallet-adapter-walletlib",
"description": "A React Native wrapper of the Solana Mobile, Mobile Wallet Adapter Wallet Library. Wallet apps can use this to handle dapp requests for signing and sending.",
"version": "1.0.3",
Copy link
Contributor

@Funkatronics Funkatronics Mar 27, 2024

Choose a reason for hiding this comment

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

versioning should be done separately, on release. ex: https://github.com/solana-mobile/mobile-wallet-adapter/pull/721/files

"version": "1.1.0",
"author": "Michael Sulistio <mike.sulistio@solanamobile.com>",
"repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
"license": "Apache-2.0",
Expand All @@ -12,8 +12,6 @@
"module": "lib/esm/index",
"types": "lib/types/index.d.ts",
"files": [
"android",
"!android/build",
"lib",
"LICENSE"
],
Expand Down