@solana-mobile/mobile-wallet-adapter-walletlib 1.0.2 → 1.0.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.
- package/README.md +61 -3
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/JsonSerializationUtils.kt +3 -1
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/SolanaMobileWalletAdapterWalletLibModule.kt +15 -2
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterRequest.kt +11 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterResponse.kt +10 -2
- package/lib/commonjs/resolve.js +1 -0
- package/lib/commonjs/resolve.js.map +1 -1
- package/lib/commonjs/useMobileWalletAdapterSession.js +3 -3
- package/lib/commonjs/useMobileWalletAdapterSession.js.map +1 -1
- package/lib/module/resolve.js +2 -0
- package/lib/module/resolve.js.map +1 -1
- package/lib/module/useMobileWalletAdapterSession.js +3 -3
- package/lib/module/useMobileWalletAdapterSession.js.map +1 -1
- package/lib/typescript/resolve.d.ts +18 -9
- package/lib/typescript/resolve.d.ts.map +1 -1
- package/lib/typescript/useMobileWalletAdapterSession.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/resolve.ts +30 -9
- package/src/useMobileWalletAdapterSession.ts +3 -4
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ AppRegistry.registerComponent(
|
|
|
26
26
|
);
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
###
|
|
29
|
+
### 2. Start listening and handling MWA requests
|
|
30
30
|
|
|
31
31
|
Use this API to start a session and start handling requests:
|
|
32
32
|
```typescript
|
|
@@ -83,7 +83,7 @@ const response = {
|
|
|
83
83
|
resolve(authorizationRequest, response)
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
There are a a selection of "fail" responses that you can return to the dApp. These are for cases where the user
|
|
86
|
+
There are a a selection of "fail" responses that you can return to the dApp. These are for cases where the user declines, or an error occurs during signing, etc.
|
|
87
87
|
```typescript
|
|
88
88
|
import {
|
|
89
89
|
UserDeclinedResponse
|
|
@@ -96,5 +96,63 @@ const response = {
|
|
|
96
96
|
// Tells the dApp user has declined the authorization request
|
|
97
97
|
resolve(authorizationRequest, response)
|
|
98
98
|
```
|
|
99
|
-
|
|
99
|
+
|
|
100
|
+
## Properties of an MWA Request
|
|
101
|
+
Each MWA Request is defined in [`resolve.ts`](https://github.com/solana-mobile/mobile-wallet-adapter/blob/main/js/packages/mobile-wallet-adapter-walletlib/src/resolve.ts#L38).
|
|
102
|
+
Each come with their own properties and completion response structures.
|
|
103
|
+
|
|
104
|
+
If you want to understand the dApp perspective and how a dApp would send these requests, see [MWA API Documentation](https://docs.solanamobile.com/reference/) for dAppstypescript/mobile-wallet-adapter.
|
|
105
|
+
|
|
106
|
+
## MWARequest Interfaces
|
|
107
|
+
|
|
108
|
+
### `IMWARequest`
|
|
109
|
+
This is the base interface that all MWARequsts inherit from. The fields defined here are used in the package's internal implementation and the package consumer will generally not use them.
|
|
110
|
+
|
|
111
|
+
Fields:
|
|
112
|
+
- `__type`: An enum defining the type of MWA Request it is.
|
|
113
|
+
- `requestId`: A unique identifier of this specific MWA Request
|
|
114
|
+
- `sessionId`: A unique identifier of the MWA Session this request belongs to.
|
|
115
|
+
|
|
116
|
+
### `IVerifiableIdentityRequest`
|
|
117
|
+
This an interface that describes MWA Requests that come with a verifiable identity and the following 3 fields.
|
|
118
|
+
|
|
119
|
+
Fields:
|
|
120
|
+
- `authorizationScope`: A byte representation of the authorization token granted to the dApp.
|
|
121
|
+
- `cluster`: The Solana RPC cluster that the dApp intends to use.
|
|
122
|
+
- `appIdentity`: An object containing 3 optional identity fields about the dApp:
|
|
123
|
+
- Note: The `iconRelativeUri` is a relative path, relative to `identityUri`.
|
|
124
|
+
```
|
|
125
|
+
{
|
|
126
|
+
identityName: 'dApp Name',
|
|
127
|
+
identityUri: 'https://yourdapp.com'
|
|
128
|
+
iconRelativeUri: "favicon.ico", // Full path resolves to https://yourdapp.com/favicon.ico
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### MWARequest Types
|
|
133
|
+
|
|
134
|
+
- `AuthorizeDappRequest`
|
|
135
|
+
- [Spec](https://solana-mobile.github.io/mobile-wallet-adapter/spec/spec.html#authorize)
|
|
136
|
+
- Interfaces: `IMWARequest`
|
|
137
|
+
|
|
138
|
+
- `ReauthorizeDappRequest`
|
|
139
|
+
- [Spec](https://solana-mobile.github.io/mobile-wallet-adapter/spec/spec.html#reauthorize)
|
|
140
|
+
- Interfaces: `IMWARequest`, `IVerifiableIdentityRequest`
|
|
141
|
+
|
|
142
|
+
- `DeauthorizeDappRequest`
|
|
143
|
+
- [Spec](https://solana-mobile.github.io/mobile-wallet-adapter/spec/spec.html#deauthorize)
|
|
144
|
+
- Interfaces: `IMWARequest`, `IVerifiableIdentityRequest`
|
|
145
|
+
|
|
146
|
+
- `SignMessagesRequest`
|
|
147
|
+
- [Spec](https://solana-mobile.github.io/mobile-wallet-adapter/spec/spec.html#sign_messages)
|
|
148
|
+
- Interfaces: `IMWARequest`, `IVerifiableIdentityRequest`
|
|
149
|
+
|
|
150
|
+
- `SignTransactionsRequest`
|
|
151
|
+
- [Spec](https://solana-mobile.github.io/mobile-wallet-adapter/spec/spec.html#sign_transactions)
|
|
152
|
+
- Interfaces: `IMWARequest`, `IVerifiableIdentityRequest`
|
|
153
|
+
|
|
154
|
+
- `SignAndSendTransactionsRequest`
|
|
155
|
+
- [Spec](https://solana-mobile.github.io/mobile-wallet-adapter/spec/spec.html#sign_and_send_transactions)
|
|
156
|
+
- Interfaces: `IMWARequest`, `IVerifiableIdentityRequest`
|
|
157
|
+
|
|
100
158
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.solanamobile.mobilewalletadapterwalletlib.reactnative
|
|
2
2
|
|
|
3
3
|
import com.solanamobile.mobilewalletadapterwalletlib.reactnative.model.AuthorizeDappResponse
|
|
4
|
+
import com.solanamobile.mobilewalletadapterwalletlib.reactnative.model.DeauthorizeDappResponse
|
|
4
5
|
import com.solanamobile.mobilewalletadapterwalletlib.reactnative.model.MobileWalletAdapterFailureResponse
|
|
5
6
|
import com.solanamobile.mobilewalletadapterwalletlib.reactnative.model.MobileWalletAdapterRequest
|
|
6
7
|
import com.solanamobile.mobilewalletadapterwalletlib.reactnative.model.MobileWalletAdapterResponse
|
|
@@ -76,9 +77,10 @@ internal object MobileWalletAdapterResponseSerializer : JsonContentPolymorphicSe
|
|
|
76
77
|
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<out MobileWalletAdapterResponse> =
|
|
77
78
|
if ((element as? JsonObject)?.containsKey("failReason") == true) FailReasonTransformingSerializer
|
|
78
79
|
else if ((element as? JsonObject)?.containsKey("publicKey") == true) AuthorizeDappResponse.serializer()
|
|
80
|
+
else if ((element as? JsonObject)?.containsKey("authorizationScope") == true) ReauthorizeDappResponse.serializer()
|
|
79
81
|
else if ((element as? JsonObject)?.containsKey("signedPayloads") == true) SignedPayloads.serializer()
|
|
80
82
|
else if ((element as? JsonObject)?.containsKey("signedTransactions") == true) SignedAndSentTransactions.serializer()
|
|
81
|
-
else if ((element as? JsonObject)?.isEmpty() == true)
|
|
83
|
+
else if ((element as? JsonObject)?.isEmpty() == true) DeauthorizeDappResponse.serializer()
|
|
82
84
|
else MobileWalletAdapterResponse.serializer()
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -69,6 +69,7 @@ class SolanaMobileWalletAdapterWalletLibModule(val reactContext: ReactApplicatio
|
|
|
69
69
|
val id: String = UUID.randomUUID().toString()) {
|
|
70
70
|
data class AuthorizeDapp(override val request: AuthorizeRequest) : MobileWalletAdapterRemoteRequest(request)
|
|
71
71
|
data class ReauthorizeDapp(override val request: ReauthorizeRequest) : MobileWalletAdapterRemoteRequest(request)
|
|
72
|
+
data class DeauthorizeDapp(override val request: DeauthorizedEvent) : MobileWalletAdapterRemoteRequest(request)
|
|
72
73
|
|
|
73
74
|
sealed class SignPayloads(override val request: SignPayloadsRequest) : MobileWalletAdapterRemoteRequest(request)
|
|
74
75
|
data class SignTransactions(override val request: SignTransactionsRequest) : SignPayloads(request)
|
|
@@ -196,7 +197,7 @@ class SolanaMobileWalletAdapterWalletLibModule(val reactContext: ReactApplicatio
|
|
|
196
197
|
is ReauthorizeDapp -> when (response) {
|
|
197
198
|
is MobileWalletAdapterFailureResponse -> {
|
|
198
199
|
when (response) {
|
|
199
|
-
is
|
|
200
|
+
is AuthorizationNotValidResponse ->
|
|
200
201
|
(pendingRequest as? MobileWalletAdapterRemoteRequest.ReauthorizeDapp)?.request?.completeWithDecline()
|
|
201
202
|
else -> completeWithInvalidResponse()
|
|
202
203
|
}
|
|
@@ -205,6 +206,11 @@ class SolanaMobileWalletAdapterWalletLibModule(val reactContext: ReactApplicatio
|
|
|
205
206
|
(pendingRequest as? MobileWalletAdapterRemoteRequest.ReauthorizeDapp)?.request?.completeWithReauthorize()
|
|
206
207
|
else -> completeWithInvalidResponse()
|
|
207
208
|
}
|
|
209
|
+
is DeauthorizeDapp -> when (response) {
|
|
210
|
+
is DeauthorizeDappResponse ->
|
|
211
|
+
(pendingRequest as? MobileWalletAdapterRemoteRequest.DeauthorizeDapp)?.request?.complete()
|
|
212
|
+
else -> completeWithInvalidResponse()
|
|
213
|
+
}
|
|
208
214
|
is SignAndSendTransactions -> when (response) {
|
|
209
215
|
is MobileWalletAdapterFailureResponse -> {
|
|
210
216
|
when (response) {
|
|
@@ -277,6 +283,11 @@ class SolanaMobileWalletAdapterWalletLibModule(val reactContext: ReactApplicatio
|
|
|
277
283
|
request.request.identityUri.toString(), request.request.iconRelativeUri.toString(),
|
|
278
284
|
request.request.authorizationScope
|
|
279
285
|
)
|
|
286
|
+
is MobileWalletAdapterRemoteRequest.DeauthorizeDapp -> DeauthorizeDapp(
|
|
287
|
+
scenarioId!!, request.request.cluster, request.request.identityName,
|
|
288
|
+
request.request.identityUri.toString(), request.request.iconRelativeUri.toString(),
|
|
289
|
+
request.request.authorizationScope
|
|
290
|
+
)
|
|
280
291
|
is MobileWalletAdapterRemoteRequest.SignMessages -> SignMessages(
|
|
281
292
|
scenarioId!!, request.request.cluster, request.request.identityName,
|
|
282
293
|
request.request.identityUri.toString(), request.request.iconRelativeUri.toString(),
|
|
@@ -378,7 +389,9 @@ class SolanaMobileWalletAdapterWalletLibModule(val reactContext: ReactApplicatio
|
|
|
378
389
|
}
|
|
379
390
|
|
|
380
391
|
override fun onDeauthorizedEvent(event: DeauthorizedEvent) {
|
|
381
|
-
|
|
392
|
+
val request = MobileWalletAdapterRemoteRequest.DeauthorizeDapp(event)
|
|
393
|
+
pendingRequests.put(request.id, request)
|
|
394
|
+
sendWalletServiceRequestToReact(request)
|
|
382
395
|
}
|
|
383
396
|
}
|
|
384
397
|
|
|
@@ -41,6 +41,17 @@ data class ReauthorizeDapp(
|
|
|
41
41
|
override val authorizationScope: ByteArray
|
|
42
42
|
) : VerifiableIdentityRequestSurrogate()
|
|
43
43
|
|
|
44
|
+
@Serializable
|
|
45
|
+
@SerialName("DEAUTHORIZE_DAPP")
|
|
46
|
+
data class DeauthorizeDapp(
|
|
47
|
+
override val sessionId: String,
|
|
48
|
+
override val cluster: String,
|
|
49
|
+
override val identityName: String?,
|
|
50
|
+
override val identityUri: String?,
|
|
51
|
+
override val iconRelativeUri: String?,
|
|
52
|
+
override val authorizationScope: ByteArray
|
|
53
|
+
) : VerifiableIdentityRequestSurrogate()
|
|
54
|
+
|
|
44
55
|
@Serializable
|
|
45
56
|
sealed class SignPayloads : VerifiableIdentityRequestSurrogate() {
|
|
46
57
|
abstract val payloads: List<ByteArray>
|
|
@@ -32,11 +32,19 @@ data class AuthorizeDappResponse(
|
|
|
32
32
|
@Serializable(with = ByteArrayAsMapSerializer::class) val publicKey: ByteArray,
|
|
33
33
|
val accountLabel: String? = String(publicKey),
|
|
34
34
|
val walletUriBase: String? = null,
|
|
35
|
-
@Serializable(with = ByteArrayAsMapSerializer::class) val authorizationScope: ByteArray
|
|
35
|
+
@Serializable(with = ByteArrayAsMapSerializer::class) val authorizationScope: ByteArray
|
|
36
36
|
) : MobileWalletAdapterResponse()
|
|
37
37
|
|
|
38
38
|
@Serializable
|
|
39
|
-
|
|
39
|
+
data class ReauthorizeDappResponse(
|
|
40
|
+
@Serializable(with = ByteArrayAsMapSerializer::class) val publicKey: ByteArray? = null,
|
|
41
|
+
val accountLabel: String? = publicKey?.let { String(publicKey) },
|
|
42
|
+
val walletUriBase: String? = null,
|
|
43
|
+
@Serializable(with = ByteArrayAsMapSerializer::class) val authorizationScope: ByteArray
|
|
44
|
+
) : MobileWalletAdapterResponse()
|
|
45
|
+
|
|
46
|
+
@Serializable
|
|
47
|
+
object DeauthorizeDappResponse : MobileWalletAdapterResponse()
|
|
40
48
|
|
|
41
49
|
@Serializable
|
|
42
50
|
data class SignedPayloads(
|
package/lib/commonjs/resolve.js
CHANGED
|
@@ -40,6 +40,7 @@ let MWARequestFailReason = /*#__PURE__*/function (MWARequestFailReason) {
|
|
|
40
40
|
}({});
|
|
41
41
|
/* Authorize Dapp */
|
|
42
42
|
/* Reauthorize Dapp */
|
|
43
|
+
/* Deauthorize Dapp */
|
|
43
44
|
/* Sign Transactions/Messages */
|
|
44
45
|
/* Sign and Send Transaction */
|
|
45
46
|
exports.MWARequestFailReason = MWARequestFailReason;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","SolanaMobileWalletAdapterWalletLib","Platform","OS","NativeModules","Proxy","get","Error","MWARequestType","exports","MWARequestFailReason","resolve","request","response","JSON","stringify"],"sourceRoot":"../../src","sources":["resolve.ts"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACd,iGAAgG,GACjG,sDAAsD,GACtD,uCAAuC,GACvC,sGAAsG,GACtG,qHAAqH,GACrH,6CAA6C;AAEjD,MAAMC,kCAAkC,GACpCC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAIC,0BAAa,CAACH,kCAAkC,GACvEG,0BAAa,CAACH,kCAAkC,GAChD,IAAII,KAAK,CACL,CAAC,CAAC,EACF;EACIC,GAAGA,CAAA,EAAG;IACF,MAAM,IAAIC,KAAK,CACXL,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACnB,mGAAmG,GACnGH,aACV,CAAC;EACL;AACJ,CACJ,CAAC;;AAQX;AACA;AACA;AACA;AAHA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","SolanaMobileWalletAdapterWalletLib","Platform","OS","NativeModules","Proxy","get","Error","MWARequestType","exports","MWARequestFailReason","resolve","request","response","JSON","stringify"],"sourceRoot":"../../src","sources":["resolve.ts"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACd,iGAAgG,GACjG,sDAAsD,GACtD,uCAAuC,GACvC,sGAAsG,GACtG,qHAAqH,GACrH,6CAA6C;AAEjD,MAAMC,kCAAkC,GACpCC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAIC,0BAAa,CAACH,kCAAkC,GACvEG,0BAAa,CAACH,kCAAkC,GAChD,IAAII,KAAK,CACL,CAAC,CAAC,EACF;EACIC,GAAGA,CAAA,EAAG;IACF,MAAM,IAAIC,KAAK,CACXL,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACnB,mGAAmG,GACnGH,aACV,CAAC;EACL;AACJ,CACJ,CAAC;;AAQX;AACA;AACA;AACA;AAHA,IAaYQ,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AA8D1B;AACA;AACA;AAFAC,OAAA,CAAAD,cAAA,GAAAA,cAAA;AAYA;AAAA,IACYE,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAwBhC;AASA;AAMA;AAIA;AAWA;AAAAD,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AAeO,SAASC,OAAOA,CAACC,OAAmB,EAAEC,QAAqB,EAAQ;EACtEZ,kCAAkC,CAACU,OAAO,CAACG,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC,EAAEE,IAAI,CAACC,SAAS,CAACF,QAAQ,CAAC,CAAC;AACjG"}
|
|
@@ -28,21 +28,21 @@ function useMobileWalletAdapterSession(walletName, config, handleRequest, handle
|
|
|
28
28
|
console.warn('Unexpected native event type');
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
+
initializeScenario(walletName, config);
|
|
31
32
|
return () => {
|
|
32
33
|
listener.remove();
|
|
33
34
|
};
|
|
34
35
|
}, []);
|
|
35
|
-
initializeScenario(walletName, config);
|
|
36
36
|
}
|
|
37
37
|
async function initializeScenario(walletName, walletConfig) {
|
|
38
38
|
// Get initial URL
|
|
39
39
|
const initialUrl = await _reactNative.Linking.getInitialURL();
|
|
40
40
|
|
|
41
41
|
// Create Scenario and establish session with dapp
|
|
42
|
-
if (initialUrl
|
|
42
|
+
if (initialUrl) {
|
|
43
43
|
SolanaMobileWalletAdapterWalletLib.createScenario(walletName, initialUrl, JSON.stringify(walletConfig));
|
|
44
44
|
} else {
|
|
45
|
-
console.warn('Initial URL is unexpectedly
|
|
45
|
+
console.warn('Initial URL is unexpectedly uninitialized');
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
function isMWARequest(nativeEvent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_mwaSessionEvents","_resolve","LINKING_ERROR","SolanaMobileWalletAdapterWalletLib","Platform","OS","NativeModules","Proxy","get","Error","MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME","useMobileWalletAdapterSession","walletName","config","handleRequest","handleSessionEvent","useEffect","mwaEventEmitter","NativeEventEmitter","listener","addListener","nativeEvent","isMWARequest","isMWASessionEvent","console","warn","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_mwaSessionEvents","_resolve","LINKING_ERROR","SolanaMobileWalletAdapterWalletLib","Platform","OS","NativeModules","Proxy","get","Error","MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME","useMobileWalletAdapterSession","walletName","config","handleRequest","handleSessionEvent","useEffect","mwaEventEmitter","NativeEventEmitter","listener","addListener","nativeEvent","isMWARequest","isMWASessionEvent","console","warn","initializeScenario","remove","walletConfig","initialUrl","Linking","getInitialURL","createScenario","JSON","stringify","Object","values","MWARequestType","includes","__type","MWASessionEventType"],"sourceRoot":"../../src","sources":["useMobileWalletAdapterSession.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,MAAMI,aAAa,GACd,iGAAgG,GACjG,sDAAsD,GACtD,uCAAuC,GACvC,sGAAsG,GACtG,qHAAqH,GACrH,6CAA6C;AAEjD,MAAMC,kCAAkC,GACpCC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAIC,0BAAa,CAACH,kCAAkC,GACvEG,0BAAa,CAACH,kCAAkC,GAChD,IAAII,KAAK,CACL,CAAC,CAAC,EACF;EACIC,GAAGA,CAAA,EAAG;IACF,MAAM,IAAIC,KAAK,CACXL,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACnB,mGAAmG,GACnGH,aACV,CAAC;EACL;AACJ,CACJ,CAAC;AAEX,MAAMQ,uCAAuC,GAAG,yCAAyC;AAUlF,SAASC,6BAA6BA,CACzCC,UAAkB,EAClBC,MAAiC,EACjCC,aAA4C,EAC5CC,kBAA2D,EAC7D;EACE;EACA,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,eAAe,GAAG,IAAIC,+BAAk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olanaMobileWalletAdapterWalletLib","OS","Proxy","get","Error","MWARequestType","MWARequestFailReason","resolve","request","response","JSON","stringify"],"sourceRoot":"../../src","sources":["resolve.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACd,iGAAgG,GACjG,sDAAsD,GACtD,uCAAuC,GACvC,sGAAsG,GACtG,qHAAqH,GACrH,6CAA6C;AAEjD,MAAMC,kCAAkC,GACpCF,QAAQ,CAACG,EAAE,KAAK,SAAS,IAAIJ,aAAa,CAACG,kCAAkC,GACvEH,aAAa,CAACG,kCAAkC,GAChD,IAAIE,KAAK,CACL,CAAC,CAAC,EACF;EACIC,GAAGA,CAAA,EAAG;IACF,MAAM,IAAIC,KAAK,CACXN,QAAQ,CAACG,EAAE,KAAK,SAAS,GACnB,mGAAmG,GACnGF,aACV,CAAC;EACL;AACJ,CACJ,CAAC;;AAQX;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","SolanaMobileWalletAdapterWalletLib","OS","Proxy","get","Error","MWARequestType","MWARequestFailReason","resolve","request","response","JSON","stringify"],"sourceRoot":"../../src","sources":["resolve.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACd,iGAAgG,GACjG,sDAAsD,GACtD,uCAAuC,GACvC,sGAAsG,GACtG,qHAAqH,GACrH,6CAA6C;AAEjD,MAAMC,kCAAkC,GACpCF,QAAQ,CAACG,EAAE,KAAK,SAAS,IAAIJ,aAAa,CAACG,kCAAkC,GACvEH,aAAa,CAACG,kCAAkC,GAChD,IAAIE,KAAK,CACL,CAAC,CAAC,EACF;EACIC,GAAGA,CAAA,EAAG;IACF,MAAM,IAAIC,KAAK,CACXN,QAAQ,CAACG,EAAE,KAAK,SAAS,GACnB,mGAAmG,GACnGF,aACV,CAAC;EACL;AACJ,CACJ,CAAC;;AAQX;AACA;AACA;AACA;;AAUA,WAAYM,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;;AA8D1B;AACA;AACA;;AAUA;AACA,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;;AAwBhC;;AASA;;AAMA;;AAIA;;AAWA;;AAeA,OAAO,SAASC,OAAOA,CAACC,OAAmB,EAAEC,QAAqB,EAAQ;EACtET,kCAAkC,CAACO,OAAO,CAACG,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC,EAAEE,IAAI,CAACC,SAAS,CAACF,QAAQ,CAAC,CAAC;AACjG"}
|
|
@@ -22,21 +22,21 @@ export function useMobileWalletAdapterSession(walletName, config, handleRequest,
|
|
|
22
22
|
console.warn('Unexpected native event type');
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
initializeScenario(walletName, config);
|
|
25
26
|
return () => {
|
|
26
27
|
listener.remove();
|
|
27
28
|
};
|
|
28
29
|
}, []);
|
|
29
|
-
initializeScenario(walletName, config);
|
|
30
30
|
}
|
|
31
31
|
async function initializeScenario(walletName, walletConfig) {
|
|
32
32
|
// Get initial URL
|
|
33
33
|
const initialUrl = await Linking.getInitialURL();
|
|
34
34
|
|
|
35
35
|
// Create Scenario and establish session with dapp
|
|
36
|
-
if (initialUrl
|
|
36
|
+
if (initialUrl) {
|
|
37
37
|
SolanaMobileWalletAdapterWalletLib.createScenario(walletName, initialUrl, JSON.stringify(walletConfig));
|
|
38
38
|
} else {
|
|
39
|
-
console.warn('Initial URL is unexpectedly
|
|
39
|
+
console.warn('Initial URL is unexpectedly uninitialized');
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function isMWARequest(nativeEvent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","Linking","NativeEventEmitter","NativeModules","Platform","MWASessionEventType","MWARequestType","LINKING_ERROR","SolanaMobileWalletAdapterWalletLib","OS","Proxy","get","Error","MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME","useMobileWalletAdapterSession","walletName","config","handleRequest","handleSessionEvent","mwaEventEmitter","listener","addListener","nativeEvent","isMWARequest","isMWASessionEvent","console","warn","
|
|
1
|
+
{"version":3,"names":["useEffect","Linking","NativeEventEmitter","NativeModules","Platform","MWASessionEventType","MWARequestType","LINKING_ERROR","SolanaMobileWalletAdapterWalletLib","OS","Proxy","get","Error","MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME","useMobileWalletAdapterSession","walletName","config","handleRequest","handleSessionEvent","mwaEventEmitter","listener","addListener","nativeEvent","isMWARequest","isMWASessionEvent","console","warn","initializeScenario","remove","walletConfig","initialUrl","getInitialURL","createScenario","JSON","stringify","Object","values","includes","__type"],"sourceRoot":"../../src","sources":["useMobileWalletAdapterSession.ts"],"mappings":"AACA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,OAAO,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEnF,SAA0BC,mBAAmB,QAAQ,uBAAuB;AAC5E,SAAqBC,cAAc,QAAQ,cAAc;AAEzD,MAAMC,aAAa,GACd,iGAAgG,GACjG,sDAAsD,GACtD,uCAAuC,GACvC,sGAAsG,GACtG,qHAAqH,GACrH,6CAA6C;AAEjD,MAAMC,kCAAkC,GACpCJ,QAAQ,CAACK,EAAE,KAAK,SAAS,IAAIN,aAAa,CAACK,kCAAkC,GACvEL,aAAa,CAACK,kCAAkC,GAChD,IAAIE,KAAK,CACL,CAAC,CAAC,EACF;EACIC,GAAGA,CAAA,EAAG;IACF,MAAM,IAAIC,KAAK,CACXR,QAAQ,CAACK,EAAE,KAAK,SAAS,GACnB,mGAAmG,GACnGF,aACV,CAAC;EACL;AACJ,CACJ,CAAC;AAEX,MAAM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OAAOa,MAAM,CAACC,MAAM,CAAC/B,mBAAmB,CAAC,CAACgC,QAAQ,CAACf,WAAW,CAACgB,MAAM,CAAC;AAC1E"}
|
|
@@ -7,7 +7,7 @@ declare type AppIdentity = Readonly<{
|
|
|
7
7
|
* Mobile Wallet Adapter Requests are remote requests coming from
|
|
8
8
|
* the dApp for authorization, signing, and sending services.
|
|
9
9
|
*/
|
|
10
|
-
export declare type MWARequest = SignMessagesRequest | SignTransactionsRequest | SignAndSendTransactionsRequest | AuthorizeDappRequest | ReauthorizeDappRequest;
|
|
10
|
+
export declare type MWARequest = SignMessagesRequest | SignTransactionsRequest | SignAndSendTransactionsRequest | AuthorizeDappRequest | ReauthorizeDappRequest | DeauthorizeDappRequest;
|
|
11
11
|
export declare enum MWARequestType {
|
|
12
12
|
AuthorizeDappRequest = "AUTHORIZE_DAPP",
|
|
13
13
|
ReauthorizeDappRequest = "REAUTHORIZE_DAPP",
|
|
@@ -20,36 +20,40 @@ interface IMWARequest {
|
|
|
20
20
|
__type: MWARequestType;
|
|
21
21
|
requestId: string;
|
|
22
22
|
sessionId: string;
|
|
23
|
+
}
|
|
24
|
+
interface IVerifiableIdentityRequest {
|
|
23
25
|
cluster: string;
|
|
24
26
|
authorizationScope: Uint8Array;
|
|
25
27
|
appIdentity?: AppIdentity;
|
|
26
28
|
}
|
|
27
29
|
export declare type AuthorizeDappRequest = Readonly<{
|
|
28
30
|
__type: MWARequestType.AuthorizeDappRequest;
|
|
31
|
+
cluster: string;
|
|
32
|
+
appIdentity?: AppIdentity;
|
|
29
33
|
}> & IMWARequest;
|
|
30
34
|
export declare type ReauthorizeDappRequest = Readonly<{
|
|
31
35
|
__type: MWARequestType.ReauthorizeDappRequest;
|
|
32
|
-
}> & IMWARequest;
|
|
36
|
+
}> & IMWARequest & IVerifiableIdentityRequest;
|
|
33
37
|
export declare type DeauthorizeDappRequest = Readonly<{
|
|
34
38
|
__type: MWARequestType.DeauthorizeDappRequest;
|
|
35
|
-
}> & IMWARequest;
|
|
39
|
+
}> & IMWARequest & IVerifiableIdentityRequest;
|
|
36
40
|
export declare type SignMessagesRequest = Readonly<{
|
|
37
41
|
__type: MWARequestType.SignMessagesRequest;
|
|
38
42
|
payloads: Uint8Array[];
|
|
39
|
-
}> & IMWARequest;
|
|
43
|
+
}> & IMWARequest & IVerifiableIdentityRequest;
|
|
40
44
|
export declare type SignTransactionsRequest = Readonly<{
|
|
41
45
|
__type: MWARequestType.SignTransactionsRequest;
|
|
42
46
|
payloads: Uint8Array[];
|
|
43
|
-
}> & IMWARequest;
|
|
47
|
+
}> & IMWARequest & IVerifiableIdentityRequest;
|
|
44
48
|
export declare type SignAndSendTransactionsRequest = Readonly<{
|
|
45
49
|
__type: MWARequestType.SignAndSendTransactionsRequest;
|
|
46
50
|
payloads: Uint8Array[];
|
|
47
51
|
minContextSlot?: number;
|
|
48
|
-
}> & IMWARequest;
|
|
52
|
+
}> & IMWARequest & IVerifiableIdentityRequest;
|
|
49
53
|
/**
|
|
50
54
|
* MWA Request Responses
|
|
51
55
|
*/
|
|
52
|
-
export declare type MWAResponse = AuthorizeDappResponse | SignMessagesResponse | SignTransactionsResponse | SignAndSendTransactionsResponse;
|
|
56
|
+
export declare type MWAResponse = AuthorizeDappResponse | ReauthorizeDappResponse | DeauthorizeDappResponse | SignMessagesResponse | SignTransactionsResponse | SignAndSendTransactionsResponse;
|
|
53
57
|
export declare enum MWARequestFailReason {
|
|
54
58
|
UserDeclined = "USER_DECLINED",
|
|
55
59
|
TooManyPayloads = "TOO_MANY_PAYLOADS",
|
|
@@ -76,8 +80,12 @@ export declare type AuthorizeDappCompleteResponse = Readonly<{
|
|
|
76
80
|
authorizationScope?: Uint8Array;
|
|
77
81
|
}>;
|
|
78
82
|
export declare type AuthorizeDappResponse = AuthorizeDappCompleteResponse | UserDeclinedResponse;
|
|
79
|
-
export declare type ReauthorizeDappCompleteResponse = Readonly<{
|
|
80
|
-
|
|
83
|
+
export declare type ReauthorizeDappCompleteResponse = Readonly<{
|
|
84
|
+
authorizationScope?: Uint8Array;
|
|
85
|
+
}>;
|
|
86
|
+
export declare type ReauthorizeDappResponse = ReauthorizeDappCompleteResponse | AuthorizationNotValidResponse;
|
|
87
|
+
export declare type DeauthorizeDappCompleteResponse = Readonly<{}>;
|
|
88
|
+
export declare type DeauthorizeDappResponse = DeauthorizeDappCompleteResponse | AuthorizationNotValidResponse;
|
|
81
89
|
export declare type SignPayloadsCompleteResponse = Readonly<{
|
|
82
90
|
signedPayloads: Uint8Array[];
|
|
83
91
|
}>;
|
|
@@ -90,6 +98,7 @@ export declare type SignAndSendTransactionsCompleteResponse = Readonly<{
|
|
|
90
98
|
export declare type SignAndSendTransactionsResponse = SignAndSendTransactionsCompleteResponse | UserDeclinedResponse | TooManyPayloadsResponse | AuthorizationNotValidResponse | InvalidSignaturesResponse;
|
|
91
99
|
export declare function resolve(request: AuthorizeDappRequest, response: AuthorizeDappResponse): void;
|
|
92
100
|
export declare function resolve(request: ReauthorizeDappRequest, response: ReauthorizeDappResponse): void;
|
|
101
|
+
export declare function resolve(request: DeauthorizeDappRequest, response: DeauthorizeDappResponse): void;
|
|
93
102
|
export declare function resolve(request: SignMessagesRequest, response: SignMessagesResponse): void;
|
|
94
103
|
export declare function resolve(request: SignTransactionsRequest, response: SignTransactionsResponse): void;
|
|
95
104
|
export declare function resolve(request: SignAndSendTransactionsRequest, response: SignAndSendTransactionsResponse): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AA0BA,aAAK,WAAW,GAAG,QAAQ,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEH;;;GAGG;AAEH,oBAAY,UAAU,GAChB,mBAAmB,GACnB,uBAAuB,GACvB,8BAA8B,GAC9B,oBAAoB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
|
|
1
|
+
{"version":3,"file":"useMobileWalletAdapterSession.d.ts","sourceRoot":"","sources":["../../src/useMobileWalletAdapterSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAuB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AA4B1D,MAAM,WAAW,yBAAyB;IACtC,+BAA+B,EAAE,OAAO,CAAC;IACzC,gCAAgC,EAAE,MAAM,CAAC;IACzC,4BAA4B,EAAE,MAAM,CAAC;IACrC,4BAA4B,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACxD,4BAA4B,EAAE,MAAM,CAAC;CACxC;AAED,wBAAgB,6BAA6B,CACzC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,yBAAyB,EACjC,aAAa,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,EAC5C,kBAAkB,EAAE,CAAC,YAAY,EAAE,eAAe,KAAK,IAAI,QAoB9D"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana-mobile/mobile-wallet-adapter-walletlib",
|
|
3
3
|
"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.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"author": "Michael Sulistio <mike.sulistio@solanamobile.com>",
|
|
6
6
|
"repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
|
|
7
7
|
"license": "Apache-2.0",
|
package/src/resolve.ts
CHANGED
|
@@ -40,7 +40,8 @@ export type MWARequest =
|
|
|
40
40
|
| SignTransactionsRequest
|
|
41
41
|
| SignAndSendTransactionsRequest
|
|
42
42
|
| AuthorizeDappRequest
|
|
43
|
-
| ReauthorizeDappRequest
|
|
43
|
+
| ReauthorizeDappRequest
|
|
44
|
+
| DeauthorizeDappRequest;
|
|
44
45
|
|
|
45
46
|
export enum MWARequestType {
|
|
46
47
|
AuthorizeDappRequest = 'AUTHORIZE_DAPP',
|
|
@@ -50,10 +51,14 @@ export enum MWARequestType {
|
|
|
50
51
|
SignTransactionsRequest = 'SIGN_TRANSACTIONS',
|
|
51
52
|
SignAndSendTransactionsRequest = 'SIGN_AND_SEND_TRANSACTIONS',
|
|
52
53
|
}
|
|
54
|
+
|
|
53
55
|
interface IMWARequest {
|
|
54
56
|
__type: MWARequestType;
|
|
55
57
|
requestId: string;
|
|
56
58
|
sessionId: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface IVerifiableIdentityRequest {
|
|
57
62
|
cluster: string;
|
|
58
63
|
authorizationScope: Uint8Array;
|
|
59
64
|
appIdentity?: AppIdentity;
|
|
@@ -61,37 +66,44 @@ interface IMWARequest {
|
|
|
61
66
|
|
|
62
67
|
export type AuthorizeDappRequest = Readonly<{
|
|
63
68
|
__type: MWARequestType.AuthorizeDappRequest;
|
|
69
|
+
cluster: string;
|
|
70
|
+
appIdentity?: AppIdentity;
|
|
64
71
|
}> &
|
|
65
72
|
IMWARequest;
|
|
66
73
|
|
|
67
74
|
export type ReauthorizeDappRequest = Readonly<{
|
|
68
75
|
__type: MWARequestType.ReauthorizeDappRequest;
|
|
69
76
|
}> &
|
|
70
|
-
IMWARequest
|
|
77
|
+
IMWARequest &
|
|
78
|
+
IVerifiableIdentityRequest;
|
|
71
79
|
|
|
72
80
|
export type DeauthorizeDappRequest = Readonly<{
|
|
73
81
|
__type: MWARequestType.DeauthorizeDappRequest;
|
|
74
82
|
}> &
|
|
75
|
-
IMWARequest
|
|
83
|
+
IMWARequest &
|
|
84
|
+
IVerifiableIdentityRequest;
|
|
76
85
|
|
|
77
86
|
export type SignMessagesRequest = Readonly<{
|
|
78
87
|
__type: MWARequestType.SignMessagesRequest;
|
|
79
88
|
payloads: Uint8Array[];
|
|
80
89
|
}> &
|
|
81
|
-
IMWARequest
|
|
90
|
+
IMWARequest &
|
|
91
|
+
IVerifiableIdentityRequest;
|
|
82
92
|
|
|
83
93
|
export type SignTransactionsRequest = Readonly<{
|
|
84
94
|
__type: MWARequestType.SignTransactionsRequest;
|
|
85
95
|
payloads: Uint8Array[];
|
|
86
96
|
}> &
|
|
87
|
-
IMWARequest
|
|
97
|
+
IMWARequest &
|
|
98
|
+
IVerifiableIdentityRequest;
|
|
88
99
|
|
|
89
100
|
export type SignAndSendTransactionsRequest = Readonly<{
|
|
90
101
|
__type: MWARequestType.SignAndSendTransactionsRequest;
|
|
91
102
|
payloads: Uint8Array[];
|
|
92
103
|
minContextSlot?: number;
|
|
93
104
|
}> &
|
|
94
|
-
IMWARequest
|
|
105
|
+
IMWARequest &
|
|
106
|
+
IVerifiableIdentityRequest;
|
|
95
107
|
|
|
96
108
|
/**
|
|
97
109
|
* MWA Request Responses
|
|
@@ -99,6 +111,8 @@ export type SignAndSendTransactionsRequest = Readonly<{
|
|
|
99
111
|
|
|
100
112
|
export type MWAResponse =
|
|
101
113
|
| AuthorizeDappResponse
|
|
114
|
+
| ReauthorizeDappResponse
|
|
115
|
+
| DeauthorizeDappResponse
|
|
102
116
|
| SignMessagesResponse
|
|
103
117
|
| SignTransactionsResponse
|
|
104
118
|
| SignAndSendTransactionsResponse;
|
|
@@ -138,8 +152,14 @@ export type AuthorizeDappCompleteResponse = Readonly<{
|
|
|
138
152
|
export type AuthorizeDappResponse = AuthorizeDappCompleteResponse | UserDeclinedResponse;
|
|
139
153
|
|
|
140
154
|
/* Reauthorize Dapp */
|
|
141
|
-
export type ReauthorizeDappCompleteResponse = Readonly<{
|
|
142
|
-
|
|
155
|
+
export type ReauthorizeDappCompleteResponse = Readonly<{
|
|
156
|
+
authorizationScope?: Uint8Array;
|
|
157
|
+
}>;
|
|
158
|
+
export type ReauthorizeDappResponse = ReauthorizeDappCompleteResponse | AuthorizationNotValidResponse;
|
|
159
|
+
|
|
160
|
+
/* Deauthorize Dapp */
|
|
161
|
+
export type DeauthorizeDappCompleteResponse = Readonly<{}>;
|
|
162
|
+
export type DeauthorizeDappResponse = DeauthorizeDappCompleteResponse | AuthorizationNotValidResponse;
|
|
143
163
|
|
|
144
164
|
/* Sign Transactions/Messages */
|
|
145
165
|
export type SignPayloadsCompleteResponse = Readonly<{ signedPayloads: Uint8Array[] }>;
|
|
@@ -163,9 +183,10 @@ export type SignAndSendTransactionsResponse =
|
|
|
163
183
|
|
|
164
184
|
export function resolve(request: AuthorizeDappRequest, response: AuthorizeDappResponse): void;
|
|
165
185
|
export function resolve(request: ReauthorizeDappRequest, response: ReauthorizeDappResponse): void;
|
|
186
|
+
export function resolve(request: DeauthorizeDappRequest, response: DeauthorizeDappResponse): void;
|
|
166
187
|
export function resolve(request: SignMessagesRequest, response: SignMessagesResponse): void;
|
|
167
188
|
export function resolve(request: SignTransactionsRequest, response: SignTransactionsResponse): void;
|
|
168
189
|
export function resolve(request: SignAndSendTransactionsRequest, response: SignAndSendTransactionsResponse): void;
|
|
169
|
-
export function resolve(request: MWARequest, response:
|
|
190
|
+
export function resolve(request: MWARequest, response: MWAResponse): void {
|
|
170
191
|
SolanaMobileWalletAdapterWalletLib.resolve(JSON.stringify(request), JSON.stringify(response));
|
|
171
192
|
}
|
|
@@ -57,13 +57,12 @@ export function useMobileWalletAdapterSession(
|
|
|
57
57
|
console.warn('Unexpected native event type');
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
initializeScenario(walletName, config);
|
|
60
61
|
|
|
61
62
|
return () => {
|
|
62
63
|
listener.remove();
|
|
63
64
|
};
|
|
64
65
|
}, []);
|
|
65
|
-
|
|
66
|
-
initializeScenario(walletName, config);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
async function initializeScenario(walletName: string, walletConfig: MobileWalletAdapterConfig) {
|
|
@@ -71,10 +70,10 @@ async function initializeScenario(walletName: string, walletConfig: MobileWallet
|
|
|
71
70
|
const initialUrl = await Linking.getInitialURL();
|
|
72
71
|
|
|
73
72
|
// Create Scenario and establish session with dapp
|
|
74
|
-
if (initialUrl
|
|
73
|
+
if (initialUrl) {
|
|
75
74
|
SolanaMobileWalletAdapterWalletLib.createScenario(walletName, initialUrl, JSON.stringify(walletConfig));
|
|
76
75
|
} else {
|
|
77
|
-
console.warn('Initial URL is unexpectedly
|
|
76
|
+
console.warn('Initial URL is unexpectedly uninitialized');
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
|