@solana-mobile/mobile-wallet-adapter-protocol 2.2.2-hotfix.0 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ buildscript {
8
8
  }
9
9
 
10
10
  dependencies {
11
- classpath 'com.android.tools.build:gradle:8.11.1'
11
+ classpath 'com.android.tools.build:gradle:8.12.0'
12
12
  // noinspection DifferentKotlinGradleVersion
13
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
14
  }
@@ -80,6 +80,17 @@ class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
80
80
  launch {
81
81
  mutex.lock()
82
82
  Log.d(TAG, "startSession with config $config")
83
+ var sessionTaskId: Int? = null
84
+ val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactApplicationContext)
85
+ val finishHeadlessTask = { taskId: Int? ->
86
+ try {
87
+ if (taskId != null && headlessJsTaskContext.isTaskRunning(taskId)) {
88
+ headlessJsTaskContext.finishTask(taskId)
89
+ }
90
+ } catch (e: Exception) {
91
+ Log.w(TAG, "Failed to finish headless JS task", e)
92
+ }
93
+ }
83
94
  try {
84
95
  val uriPrefix = config?.getString("baseUri")?.let { Uri.parse(it) }
85
96
  val localAssociation =
@@ -92,9 +103,9 @@ class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
92
103
  localAssociation.port,
93
104
  localAssociation.session
94
105
  )
95
- val headlessJsTaskContext =
96
- HeadlessJsTaskContext.getInstance(reactApplicationContext)
97
- var sessionTaskId = headlessJsTaskContext.startTask(sessionBackgroundTaskConfig)
106
+ withContext(Dispatchers.Main) {
107
+ sessionTaskId = headlessJsTaskContext.startTask(sessionBackgroundTaskConfig)
108
+ }
98
109
  associationResultCallback = { resultCode ->
99
110
  if (resultCode == Activity.RESULT_CANCELED) {
100
111
  Log.d(TAG, "Local association cancelled by user, ending session")
@@ -108,13 +119,7 @@ class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
108
119
  }
109
120
 
110
121
  // stop the headless js task, regardless if the association was successful or not
111
- try {
112
- if (headlessJsTaskContext.isTaskRunning(sessionTaskId)) {
113
- headlessJsTaskContext.finishTask(sessionTaskId)
114
- }
115
- } catch (e: Exception) {
116
- Log.w(TAG, "Failed to finish headless task during cleanup", e)
117
- }
122
+ finishHeadlessTask(sessionTaskId)
118
123
  }
119
124
  currentActivity?.startActivityForResult(intent, REQUEST_LOCAL_ASSOCIATION)
120
125
  ?: throw NullPointerException(
@@ -134,22 +139,27 @@ class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
134
139
  promise.resolve(sessionPropertiesMap)
135
140
  } catch (e: ActivityNotFoundException) {
136
141
  Log.e(TAG, "Found no installed wallet that supports the mobile wallet protocol", e)
142
+ finishHeadlessTask(sessionTaskId)
137
143
  cleanup()
138
144
  promise.reject("ERROR_WALLET_NOT_FOUND", e)
139
145
  } catch (e: TimeoutException) {
140
146
  Log.e(TAG, "Timed out waiting for local association to be ready", e)
147
+ finishHeadlessTask(sessionTaskId)
141
148
  cleanup()
142
149
  promise.reject("Timed out waiting for local association to be ready", e)
143
150
  } catch (e: InterruptedException) {
144
151
  Log.w(TAG, "Interrupted while waiting for local association to be ready", e)
152
+ finishHeadlessTask(sessionTaskId)
145
153
  cleanup()
146
154
  promise.reject(e)
147
155
  } catch (e: ExecutionException) {
148
156
  Log.e(TAG, "Failed establishing local association with wallet", e.cause)
157
+ finishHeadlessTask(sessionTaskId)
149
158
  cleanup()
150
159
  promise.reject(e)
151
160
  } catch (e: Throwable) {
152
161
  Log.e(TAG, "Failed to start session", e)
162
+ finishHeadlessTask(sessionTaskId)
153
163
  cleanup()
154
164
  promise.reject(e)
155
165
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solana-mobile/mobile-wallet-adapter-protocol",
3
3
  "description": "An implementation of the Solana Mobile Mobile Wallet Adapter protocol. Use this to open a session with a mobile wallet app, and to issue API calls to it.",
4
- "version": "2.2.2-hotfix.0",
4
+ "version": "2.2.3",
5
5
  "author": "Steven Luscher <steven.luscher@solanamobile.com>",
6
6
  "repository": {
7
7
  "type": "git",