@solana-mobile/mobile-wallet-adapter-protocol 2.2.0-new-arch-beta → 2.2.0
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.
- package/README.md +69 -69
- package/android/build.gradle +158 -158
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -5
- package/android/gradle.properties +5 -5
- package/android/src/main/java/com/solanamobile/mobilewalletadapter/reactnative/JSONSerializationUtils.kt +11 -9
- package/android/src/main/java/com/solanamobile/mobilewalletadapter/reactnative/SolanaMobileWalletAdapterModule.kt +201 -201
- package/android/src/main/java/com/solanamobile/mobilewalletadapter/reactnative/SolanaMobileWalletAdapterPackage.kt +35 -35
- package/android/src/newarch/SolanaMobileWalletAdapter.kt +7 -7
- package/android/src/oldarch/SolanaMobileWalletAdapter.kt +16 -16
- package/lib/cjs/index.browser.js +249 -184
- package/lib/cjs/index.js +249 -184
- package/lib/cjs/index.native.js +8 -0
- package/lib/esm/index.browser.js +249 -184
- package/lib/esm/index.js +249 -184
- package/lib/types/index.browser.d.ts +10 -4
- package/lib/types/index.browser.d.ts.map +1 -1
- package/lib/types/index.d.ts +10 -4
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.native.d.ts +10 -4
- package/lib/types/index.native.d.ts.map +1 -1
- package/package.json +71 -66
- package/src/__forks__/react-native/base64Utils.ts +1 -1
- package/src/__forks__/react-native/transact.ts +91 -91
- package/src/base64Utils.ts +19 -0
- package/src/codegenSpec/NativeSolanaMobileWalletAdapter.ts +13 -13
- package/src/createMobileWalletProxy.ts +7 -0
- package/src/errors.ts +2 -0
- package/src/getAssociateAndroidIntentURL.ts +3 -4
- package/src/startSession.ts +2 -34
- package/src/transact.ts +593 -499
- package/src/types.ts +9 -0
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.ActivityNotFoundException
|
|
5
|
-
import android.content.Intent
|
|
6
|
-
import android.net.Uri
|
|
7
|
-
import android.util.Log
|
|
8
|
-
import com.facebook.react.bridge.*
|
|
9
|
-
import com.solana.mobilewalletadapter.clientlib.protocol.JsonRpc20Client
|
|
10
|
-
import com.solana.mobilewalletadapter.clientlib.protocol.MobileWalletAdapterClient
|
|
11
|
-
import com.solana.mobilewalletadapter.clientlib.scenario.LocalAssociationIntentCreator
|
|
12
|
-
import com.solana.mobilewalletadapter.clientlib.scenario.LocalAssociationScenario
|
|
13
|
-
import com.solana.mobilewalletadapter.common.protocol.SessionProperties.ProtocolVersion
|
|
14
|
-
import com.solanamobile.mobilewalletadapter.reactnative.JSONSerializationUtils.convertJsonToMap
|
|
15
|
-
import com.solanamobile.mobilewalletadapter.reactnative.JSONSerializationUtils.convertMapToJson
|
|
16
|
-
import java.util.concurrent.ExecutionException
|
|
17
|
-
import java.util.concurrent.TimeUnit
|
|
18
|
-
import java.util.concurrent.TimeoutException
|
|
19
|
-
import kotlinx.coroutines.*
|
|
20
|
-
import kotlinx.coroutines.sync.Mutex
|
|
21
|
-
import org.json.JSONObject
|
|
22
|
-
|
|
23
|
-
class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
|
|
24
|
-
SolanaMobileWalletAdapterSpec(reactContext), CoroutineScope {
|
|
25
|
-
|
|
26
|
-
data class SessionState(
|
|
27
|
-
val client: MobileWalletAdapterClient,
|
|
28
|
-
val localAssociation: LocalAssociationScenario,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
override val coroutineContext =
|
|
32
|
-
Dispatchers.IO + CoroutineName("SolanaMobileWalletAdapterModuleScope") + SupervisorJob()
|
|
33
|
-
|
|
34
|
-
companion object {
|
|
35
|
-
const val NAME = "SolanaMobileWalletAdapter"
|
|
36
|
-
private const val ASSOCIATION_TIMEOUT_MS = 10000
|
|
37
|
-
private const val CLIENT_TIMEOUT_MS = 90000
|
|
38
|
-
private const val REQUEST_LOCAL_ASSOCIATION = 0
|
|
39
|
-
|
|
40
|
-
// Used to ensure that you can't start more than one session at a time.
|
|
41
|
-
private val mutex: Mutex = Mutex()
|
|
42
|
-
private var sessionState: SessionState? = null
|
|
43
|
-
private var associationResultCallback: ((Int) -> Unit)? = null
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private val mActivityEventListener: ActivityEventListener =
|
|
47
|
-
object : BaseActivityEventListener() {
|
|
48
|
-
override fun onActivityResult(
|
|
49
|
-
activity: Activity?,
|
|
50
|
-
requestCode: Int,
|
|
51
|
-
resultCode: Int,
|
|
52
|
-
data: Intent?
|
|
53
|
-
) {
|
|
54
|
-
if (requestCode == REQUEST_LOCAL_ASSOCIATION)
|
|
55
|
-
associationResultCallback?.invoke(resultCode)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
init {
|
|
60
|
-
reactContext.addActivityEventListener(mActivityEventListener)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override fun getName(): String {
|
|
64
|
-
return NAME
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@ReactMethod
|
|
68
|
-
override fun startSession(config: ReadableMap?, promise: Promise): Unit {
|
|
69
|
-
launch {
|
|
70
|
-
mutex.lock()
|
|
71
|
-
Log.d(name, "startSession with config $config")
|
|
72
|
-
try {
|
|
73
|
-
val uriPrefix = config?.getString("baseUri")?.let { Uri.parse(it) }
|
|
74
|
-
val localAssociation =
|
|
75
|
-
LocalAssociationScenario(
|
|
76
|
-
CLIENT_TIMEOUT_MS,
|
|
77
|
-
)
|
|
78
|
-
val intent =
|
|
79
|
-
LocalAssociationIntentCreator.createAssociationIntent(
|
|
80
|
-
uriPrefix,
|
|
81
|
-
localAssociation.port,
|
|
82
|
-
localAssociation.session
|
|
83
|
-
)
|
|
84
|
-
associationResultCallback = { resultCode ->
|
|
85
|
-
if (resultCode == Activity.RESULT_CANCELED) {
|
|
86
|
-
Log.d(name, "Local association cancelled by user, ending session")
|
|
87
|
-
promise.reject(
|
|
88
|
-
"Session not established: Local association cancelled by user",
|
|
89
|
-
LocalAssociationScenario.ConnectionFailedException(
|
|
90
|
-
"Local association cancelled by user"
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
localAssociation.close()
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
currentActivity?.startActivityForResult(intent, REQUEST_LOCAL_ASSOCIATION)
|
|
97
|
-
?: throw NullPointerException(
|
|
98
|
-
"Could not find a current activity from which to launch a local association"
|
|
99
|
-
)
|
|
100
|
-
val client =
|
|
101
|
-
localAssociation
|
|
102
|
-
.start()
|
|
103
|
-
.get(ASSOCIATION_TIMEOUT_MS.toLong(), TimeUnit.MILLISECONDS)
|
|
104
|
-
sessionState = SessionState(client, localAssociation)
|
|
105
|
-
val sessionPropertiesMap: WritableMap = WritableNativeMap()
|
|
106
|
-
sessionPropertiesMap.putString(
|
|
107
|
-
"protocol_version",
|
|
108
|
-
when (localAssociation.session.sessionProperties.protocolVersion) {
|
|
109
|
-
ProtocolVersion.LEGACY -> "legacy"
|
|
110
|
-
ProtocolVersion.V1 -> "v1"
|
|
111
|
-
}
|
|
112
|
-
)
|
|
113
|
-
promise.resolve(sessionPropertiesMap)
|
|
114
|
-
} catch (e: ActivityNotFoundException) {
|
|
115
|
-
Log.e(name, "Found no installed wallet that supports the mobile wallet protocol", e)
|
|
116
|
-
cleanup()
|
|
117
|
-
promise.reject("ERROR_WALLET_NOT_FOUND", e)
|
|
118
|
-
} catch (e: TimeoutException) {
|
|
119
|
-
Log.e(name, "Timed out waiting for local association to be ready", e)
|
|
120
|
-
cleanup()
|
|
121
|
-
promise.reject("Timed out waiting for local association to be ready", e)
|
|
122
|
-
} catch (e: InterruptedException) {
|
|
123
|
-
Log.w(name, "Interrupted while waiting for local association to be ready", e)
|
|
124
|
-
cleanup()
|
|
125
|
-
promise.reject(e)
|
|
126
|
-
} catch (e: ExecutionException) {
|
|
127
|
-
Log.e(name, "Failed establishing local association with wallet", e.cause)
|
|
128
|
-
cleanup()
|
|
129
|
-
promise.reject(e)
|
|
130
|
-
} catch (e: Throwable) {
|
|
131
|
-
Log.e(name, "Failed to start session", e)
|
|
132
|
-
cleanup()
|
|
133
|
-
promise.reject(e)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@ReactMethod
|
|
139
|
-
override fun invoke(method: String, params: ReadableMap?, promise: Promise): Unit =
|
|
140
|
-
sessionState?.let {
|
|
141
|
-
Log.d(name, "invoke `$method` with params $params")
|
|
142
|
-
try {
|
|
143
|
-
val result =
|
|
144
|
-
it.client
|
|
145
|
-
.methodCall(method, convertMapToJson(params), CLIENT_TIMEOUT_MS)
|
|
146
|
-
.get() as
|
|
147
|
-
JSONObject
|
|
148
|
-
promise.resolve(convertJsonToMap(result))
|
|
149
|
-
} catch (e: ExecutionException) {
|
|
150
|
-
val cause = e.cause
|
|
151
|
-
if (cause is JsonRpc20Client.JsonRpc20RemoteException) {
|
|
152
|
-
val userInfo = Arguments.createMap()
|
|
153
|
-
userInfo.putInt("jsonRpcErrorCode", cause.code)
|
|
154
|
-
promise.reject("JSON_RPC_ERROR", cause, userInfo)
|
|
155
|
-
} else if (cause is TimeoutException) {
|
|
156
|
-
promise.reject("Timed out waiting for response", e)
|
|
157
|
-
} else {
|
|
158
|
-
throw e
|
|
159
|
-
}
|
|
160
|
-
} catch (e: Throwable) {
|
|
161
|
-
Log.e(name, "Failed to invoke `$method` with params $params", e)
|
|
162
|
-
promise.reject(e)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
?: throw NullPointerException(
|
|
166
|
-
"Tried to invoke `$method` without an active session"
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
@ReactMethod
|
|
170
|
-
override fun endSession(promise: Promise): Unit {
|
|
171
|
-
sessionState?.let {
|
|
172
|
-
launch {
|
|
173
|
-
Log.d(name, "endSession")
|
|
174
|
-
try {
|
|
175
|
-
it.localAssociation
|
|
176
|
-
.close()
|
|
177
|
-
.get(ASSOCIATION_TIMEOUT_MS.toLong(), TimeUnit.MILLISECONDS)
|
|
178
|
-
cleanup()
|
|
179
|
-
promise.resolve(true)
|
|
180
|
-
} catch (e: TimeoutException) {
|
|
181
|
-
Log.e(name, "Timed out waiting for local association to close", e)
|
|
182
|
-
cleanup()
|
|
183
|
-
promise.reject("Failed to end session", e)
|
|
184
|
-
} catch (e: Throwable) {
|
|
185
|
-
Log.e(name, "Failed to end session", e)
|
|
186
|
-
cleanup()
|
|
187
|
-
promise.reject("Failed to end session", e)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
?: throw NullPointerException("Tried to end a session without an active session")
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
private fun cleanup() {
|
|
195
|
-
sessionState = null
|
|
196
|
-
associationResultCallback = null
|
|
197
|
-
if (mutex.isLocked) {
|
|
198
|
-
mutex.unlock()
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
1
|
+
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.ActivityNotFoundException
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import android.net.Uri
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import com.facebook.react.bridge.*
|
|
9
|
+
import com.solana.mobilewalletadapter.clientlib.protocol.JsonRpc20Client
|
|
10
|
+
import com.solana.mobilewalletadapter.clientlib.protocol.MobileWalletAdapterClient
|
|
11
|
+
import com.solana.mobilewalletadapter.clientlib.scenario.LocalAssociationIntentCreator
|
|
12
|
+
import com.solana.mobilewalletadapter.clientlib.scenario.LocalAssociationScenario
|
|
13
|
+
import com.solana.mobilewalletadapter.common.protocol.SessionProperties.ProtocolVersion
|
|
14
|
+
import com.solanamobile.mobilewalletadapter.reactnative.JSONSerializationUtils.convertJsonToMap
|
|
15
|
+
import com.solanamobile.mobilewalletadapter.reactnative.JSONSerializationUtils.convertMapToJson
|
|
16
|
+
import java.util.concurrent.ExecutionException
|
|
17
|
+
import java.util.concurrent.TimeUnit
|
|
18
|
+
import java.util.concurrent.TimeoutException
|
|
19
|
+
import kotlinx.coroutines.*
|
|
20
|
+
import kotlinx.coroutines.sync.Mutex
|
|
21
|
+
import org.json.JSONObject
|
|
22
|
+
|
|
23
|
+
class SolanaMobileWalletAdapterModule(reactContext: ReactApplicationContext) :
|
|
24
|
+
SolanaMobileWalletAdapterSpec(reactContext), CoroutineScope {
|
|
25
|
+
|
|
26
|
+
data class SessionState(
|
|
27
|
+
val client: MobileWalletAdapterClient,
|
|
28
|
+
val localAssociation: LocalAssociationScenario,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
override val coroutineContext =
|
|
32
|
+
Dispatchers.IO + CoroutineName("SolanaMobileWalletAdapterModuleScope") + SupervisorJob()
|
|
33
|
+
|
|
34
|
+
companion object {
|
|
35
|
+
const val NAME = "SolanaMobileWalletAdapter"
|
|
36
|
+
private const val ASSOCIATION_TIMEOUT_MS = 10000
|
|
37
|
+
private const val CLIENT_TIMEOUT_MS = 90000
|
|
38
|
+
private const val REQUEST_LOCAL_ASSOCIATION = 0
|
|
39
|
+
|
|
40
|
+
// Used to ensure that you can't start more than one session at a time.
|
|
41
|
+
private val mutex: Mutex = Mutex()
|
|
42
|
+
private var sessionState: SessionState? = null
|
|
43
|
+
private var associationResultCallback: ((Int) -> Unit)? = null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private val mActivityEventListener: ActivityEventListener =
|
|
47
|
+
object : BaseActivityEventListener() {
|
|
48
|
+
override fun onActivityResult(
|
|
49
|
+
activity: Activity?,
|
|
50
|
+
requestCode: Int,
|
|
51
|
+
resultCode: Int,
|
|
52
|
+
data: Intent?
|
|
53
|
+
) {
|
|
54
|
+
if (requestCode == REQUEST_LOCAL_ASSOCIATION)
|
|
55
|
+
associationResultCallback?.invoke(resultCode)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
init {
|
|
60
|
+
reactContext.addActivityEventListener(mActivityEventListener)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override fun getName(): String {
|
|
64
|
+
return NAME
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@ReactMethod
|
|
68
|
+
override fun startSession(config: ReadableMap?, promise: Promise): Unit {
|
|
69
|
+
launch {
|
|
70
|
+
mutex.lock()
|
|
71
|
+
Log.d(name, "startSession with config $config")
|
|
72
|
+
try {
|
|
73
|
+
val uriPrefix = config?.getString("baseUri")?.let { Uri.parse(it) }
|
|
74
|
+
val localAssociation =
|
|
75
|
+
LocalAssociationScenario(
|
|
76
|
+
CLIENT_TIMEOUT_MS,
|
|
77
|
+
)
|
|
78
|
+
val intent =
|
|
79
|
+
LocalAssociationIntentCreator.createAssociationIntent(
|
|
80
|
+
uriPrefix,
|
|
81
|
+
localAssociation.port,
|
|
82
|
+
localAssociation.session
|
|
83
|
+
)
|
|
84
|
+
associationResultCallback = { resultCode ->
|
|
85
|
+
if (resultCode == Activity.RESULT_CANCELED) {
|
|
86
|
+
Log.d(name, "Local association cancelled by user, ending session")
|
|
87
|
+
promise.reject(
|
|
88
|
+
"Session not established: Local association cancelled by user",
|
|
89
|
+
LocalAssociationScenario.ConnectionFailedException(
|
|
90
|
+
"Local association cancelled by user"
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
localAssociation.close()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
currentActivity?.startActivityForResult(intent, REQUEST_LOCAL_ASSOCIATION)
|
|
97
|
+
?: throw NullPointerException(
|
|
98
|
+
"Could not find a current activity from which to launch a local association"
|
|
99
|
+
)
|
|
100
|
+
val client =
|
|
101
|
+
localAssociation
|
|
102
|
+
.start()
|
|
103
|
+
.get(ASSOCIATION_TIMEOUT_MS.toLong(), TimeUnit.MILLISECONDS)
|
|
104
|
+
sessionState = SessionState(client, localAssociation)
|
|
105
|
+
val sessionPropertiesMap: WritableMap = WritableNativeMap()
|
|
106
|
+
sessionPropertiesMap.putString(
|
|
107
|
+
"protocol_version",
|
|
108
|
+
when (localAssociation.session.sessionProperties.protocolVersion) {
|
|
109
|
+
ProtocolVersion.LEGACY -> "legacy"
|
|
110
|
+
ProtocolVersion.V1 -> "v1"
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
promise.resolve(sessionPropertiesMap)
|
|
114
|
+
} catch (e: ActivityNotFoundException) {
|
|
115
|
+
Log.e(name, "Found no installed wallet that supports the mobile wallet protocol", e)
|
|
116
|
+
cleanup()
|
|
117
|
+
promise.reject("ERROR_WALLET_NOT_FOUND", e)
|
|
118
|
+
} catch (e: TimeoutException) {
|
|
119
|
+
Log.e(name, "Timed out waiting for local association to be ready", e)
|
|
120
|
+
cleanup()
|
|
121
|
+
promise.reject("Timed out waiting for local association to be ready", e)
|
|
122
|
+
} catch (e: InterruptedException) {
|
|
123
|
+
Log.w(name, "Interrupted while waiting for local association to be ready", e)
|
|
124
|
+
cleanup()
|
|
125
|
+
promise.reject(e)
|
|
126
|
+
} catch (e: ExecutionException) {
|
|
127
|
+
Log.e(name, "Failed establishing local association with wallet", e.cause)
|
|
128
|
+
cleanup()
|
|
129
|
+
promise.reject(e)
|
|
130
|
+
} catch (e: Throwable) {
|
|
131
|
+
Log.e(name, "Failed to start session", e)
|
|
132
|
+
cleanup()
|
|
133
|
+
promise.reject(e)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@ReactMethod
|
|
139
|
+
override fun invoke(method: String, params: ReadableMap?, promise: Promise): Unit =
|
|
140
|
+
sessionState?.let {
|
|
141
|
+
Log.d(name, "invoke `$method` with params $params")
|
|
142
|
+
try {
|
|
143
|
+
val result =
|
|
144
|
+
it.client
|
|
145
|
+
.methodCall(method, convertMapToJson(params), CLIENT_TIMEOUT_MS)
|
|
146
|
+
.get() as
|
|
147
|
+
JSONObject
|
|
148
|
+
promise.resolve(convertJsonToMap(result))
|
|
149
|
+
} catch (e: ExecutionException) {
|
|
150
|
+
val cause = e.cause
|
|
151
|
+
if (cause is JsonRpc20Client.JsonRpc20RemoteException) {
|
|
152
|
+
val userInfo = Arguments.createMap()
|
|
153
|
+
userInfo.putInt("jsonRpcErrorCode", cause.code)
|
|
154
|
+
promise.reject("JSON_RPC_ERROR", cause, userInfo)
|
|
155
|
+
} else if (cause is TimeoutException) {
|
|
156
|
+
promise.reject("Timed out waiting for response", e)
|
|
157
|
+
} else {
|
|
158
|
+
throw e
|
|
159
|
+
}
|
|
160
|
+
} catch (e: Throwable) {
|
|
161
|
+
Log.e(name, "Failed to invoke `$method` with params $params", e)
|
|
162
|
+
promise.reject(e)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
?: throw NullPointerException(
|
|
166
|
+
"Tried to invoke `$method` without an active session"
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
@ReactMethod
|
|
170
|
+
override fun endSession(promise: Promise): Unit {
|
|
171
|
+
sessionState?.let {
|
|
172
|
+
launch {
|
|
173
|
+
Log.d(name, "endSession")
|
|
174
|
+
try {
|
|
175
|
+
it.localAssociation
|
|
176
|
+
.close()
|
|
177
|
+
.get(ASSOCIATION_TIMEOUT_MS.toLong(), TimeUnit.MILLISECONDS)
|
|
178
|
+
cleanup()
|
|
179
|
+
promise.resolve(true)
|
|
180
|
+
} catch (e: TimeoutException) {
|
|
181
|
+
Log.e(name, "Timed out waiting for local association to close", e)
|
|
182
|
+
cleanup()
|
|
183
|
+
promise.reject("Failed to end session", e)
|
|
184
|
+
} catch (e: Throwable) {
|
|
185
|
+
Log.e(name, "Failed to end session", e)
|
|
186
|
+
cleanup()
|
|
187
|
+
promise.reject("Failed to end session", e)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
?: throw NullPointerException("Tried to end a session without an active session")
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private fun cleanup() {
|
|
195
|
+
sessionState = null
|
|
196
|
+
associationResultCallback = null
|
|
197
|
+
if (mutex.isLocked) {
|
|
198
|
+
mutex.unlock()
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.TurboReactPackage
|
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
-
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
-
import java.util.HashMap
|
|
9
|
-
|
|
10
|
-
class SolanaMobileWalletAdapterModulePackage : TurboReactPackage() {
|
|
11
|
-
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
-
return if (name == SolanaMobileWalletAdapterModule.NAME) {
|
|
13
|
-
SolanaMobileWalletAdapterModule(reactContext)
|
|
14
|
-
} else {
|
|
15
|
-
null
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
-
return ReactModuleInfoProvider {
|
|
21
|
-
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
-
moduleInfos[SolanaMobileWalletAdapterModule.NAME] =
|
|
23
|
-
ReactModuleInfo(
|
|
24
|
-
SolanaMobileWalletAdapterModule.NAME,
|
|
25
|
-
SolanaMobileWalletAdapterModule.NAME,
|
|
26
|
-
false, // canOverrideExistingModule
|
|
27
|
-
false, // needsEagerInit
|
|
28
|
-
true, // hasConstants
|
|
29
|
-
false, // isCxxModule
|
|
30
|
-
true // isTurboModule
|
|
31
|
-
)
|
|
32
|
-
moduleInfos
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class SolanaMobileWalletAdapterModulePackage : TurboReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == SolanaMobileWalletAdapterModule.NAME) {
|
|
13
|
+
SolanaMobileWalletAdapterModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[SolanaMobileWalletAdapterModule.NAME] =
|
|
23
|
+
ReactModuleInfo(
|
|
24
|
+
SolanaMobileWalletAdapterModule.NAME,
|
|
25
|
+
SolanaMobileWalletAdapterModule.NAME,
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
true, // hasConstants
|
|
29
|
+
false, // isCxxModule
|
|
30
|
+
true // isTurboModule
|
|
31
|
+
)
|
|
32
|
+
moduleInfos
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
-
|
|
5
|
-
abstract class SolanaMobileWalletAdapterSpec
|
|
6
|
-
internal constructor(context: ReactApplicationContext) :
|
|
7
|
-
NativeSolanaMobileWalletAdapterSpec(context) {}
|
|
1
|
+
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
|
|
5
|
+
abstract class SolanaMobileWalletAdapterSpec
|
|
6
|
+
internal constructor(context: ReactApplicationContext) :
|
|
7
|
+
NativeSolanaMobileWalletAdapterSpec(context) {}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.Promise
|
|
4
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
-
import com.facebook.react.bridge.ReadableMap
|
|
7
|
-
|
|
8
|
-
abstract class SolanaMobileWalletAdapterSpec
|
|
9
|
-
internal constructor(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
10
|
-
|
|
11
|
-
abstract fun startSession(config: ReadableMap?, promise: Promise)
|
|
12
|
-
|
|
13
|
-
abstract fun invoke(method: String, params: ReadableMap?, promise: Promise)
|
|
14
|
-
|
|
15
|
-
abstract fun endSession(promise: Promise)
|
|
16
|
-
}
|
|
1
|
+
package com.solanamobile.mobilewalletadapter.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
|
+
|
|
8
|
+
abstract class SolanaMobileWalletAdapterSpec
|
|
9
|
+
internal constructor(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
10
|
+
|
|
11
|
+
abstract fun startSession(config: ReadableMap?, promise: Promise)
|
|
12
|
+
|
|
13
|
+
abstract fun invoke(method: String, params: ReadableMap?, promise: Promise)
|
|
14
|
+
|
|
15
|
+
abstract fun endSession(promise: Promise)
|
|
16
|
+
}
|