@solana-mobile/mobile-wallet-adapter-walletlib 1.0.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/LICENSE +13 -0
- package/README.md +93 -0
- package/android/build.gradle +150 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +5 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/src/main/AndroidManifest.xml +23 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/Extensions.kt +99 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/JsonSerializationUtils.kt +83 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/MobileWalletAdapterBottomSheetActivity.kt +55 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/MobileWalletAdapterWalletLibReactNativePackage.kt +16 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/SolanaMobileWalletAdapterWalletLibModule.kt +401 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterConfig.kt +60 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterRequest.kt +83 -0
- package/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterResponse.kt +46 -0
- package/android/src/main/res/drawable/background_bottom_sheet_dialog.xml +11 -0
- package/android/src/main/res/values/styles.xml +9 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/mwaSessionEvents.js +24 -0
- package/lib/commonjs/mwaSessionEvents.js.map +1 -0
- package/lib/commonjs/resolve.js +48 -0
- package/lib/commonjs/resolve.js.map +1 -0
- package/lib/commonjs/useMobileWalletAdapterSession.js +50 -0
- package/lib/commonjs/useMobileWalletAdapterSession.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/mwaSessionEvents.js +17 -0
- package/lib/module/mwaSessionEvents.js.map +1 -0
- package/lib/module/resolve.js +46 -0
- package/lib/module/resolve.js.map +1 -0
- package/lib/module/useMobileWalletAdapterSession.js +44 -0
- package/lib/module/useMobileWalletAdapterSession.js.map +1 -0
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/mwaSessionEvents.d.ts +48 -0
- package/lib/typescript/mwaSessionEvents.d.ts.map +1 -0
- package/lib/typescript/resolve.d.ts +94 -0
- package/lib/typescript/resolve.d.ts.map +1 -0
- package/lib/typescript/useMobileWalletAdapterSession.d.ts +12 -0
- package/lib/typescript/useMobileWalletAdapterSession.d.ts.map +1 -0
- package/package.json +69 -0
- package/src/index.ts +3 -0
- package/src/mwaSessionEvents.ts +75 -0
- package/src/resolve.ts +165 -0
- package/src/useMobileWalletAdapterSession.ts +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package com.solanamobile.mobilewalletadapterwalletlib.reactnative.model
|
|
2
|
+
|
|
3
|
+
import kotlinx.serialization.SerialName
|
|
4
|
+
import kotlinx.serialization.Serializable
|
|
5
|
+
import java.util.*
|
|
6
|
+
|
|
7
|
+
@Serializable
|
|
8
|
+
sealed class MobileWalletAdapterRequest
|
|
9
|
+
{
|
|
10
|
+
open val requestId: String = UUID.randomUUID().toString()
|
|
11
|
+
abstract val sessionId: String
|
|
12
|
+
abstract val cluster: String
|
|
13
|
+
abstract val identityName: String?
|
|
14
|
+
abstract val identityUri: String?
|
|
15
|
+
abstract val iconRelativeUri: String?
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Serializable
|
|
19
|
+
@SerialName("AUTHORIZE_DAPP")
|
|
20
|
+
data class AuthorizeDapp(
|
|
21
|
+
override val sessionId: String,
|
|
22
|
+
override val cluster: String,
|
|
23
|
+
override val identityName: String?,
|
|
24
|
+
override val identityUri: String?,
|
|
25
|
+
override val iconRelativeUri: String?
|
|
26
|
+
) : MobileWalletAdapterRequest()
|
|
27
|
+
|
|
28
|
+
@Serializable
|
|
29
|
+
sealed class VerifiableIdentityRequestSurrogate : MobileWalletAdapterRequest() {
|
|
30
|
+
abstract val authorizationScope: ByteArray
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Serializable
|
|
34
|
+
@SerialName("REAUTHORIZE_DAPP")
|
|
35
|
+
data class ReauthorizeDapp(
|
|
36
|
+
override val sessionId: String,
|
|
37
|
+
override val cluster: String,
|
|
38
|
+
override val identityName: String?,
|
|
39
|
+
override val identityUri: String?,
|
|
40
|
+
override val iconRelativeUri: String?,
|
|
41
|
+
override val authorizationScope: ByteArray
|
|
42
|
+
) : VerifiableIdentityRequestSurrogate()
|
|
43
|
+
|
|
44
|
+
@Serializable
|
|
45
|
+
sealed class SignPayloads : VerifiableIdentityRequestSurrogate() {
|
|
46
|
+
abstract val payloads: List<ByteArray>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Serializable
|
|
50
|
+
@SerialName("SIGN_MESSAGES")
|
|
51
|
+
data class SignMessages(
|
|
52
|
+
override val sessionId: String,
|
|
53
|
+
override val cluster: String,
|
|
54
|
+
override val identityName: String?,
|
|
55
|
+
override val identityUri: String?,
|
|
56
|
+
override val iconRelativeUri: String?,
|
|
57
|
+
override val authorizationScope: ByteArray,
|
|
58
|
+
override val payloads: List<ByteArray>
|
|
59
|
+
) : SignPayloads()
|
|
60
|
+
|
|
61
|
+
@Serializable
|
|
62
|
+
@SerialName("SIGN_TRANSACTIONS")
|
|
63
|
+
data class SignTransactions(
|
|
64
|
+
override val sessionId: String,
|
|
65
|
+
override val cluster: String,
|
|
66
|
+
override val identityName: String?,
|
|
67
|
+
override val identityUri: String?,
|
|
68
|
+
override val iconRelativeUri: String?,
|
|
69
|
+
override val authorizationScope: ByteArray,
|
|
70
|
+
override val payloads: List<ByteArray>
|
|
71
|
+
) : SignPayloads()
|
|
72
|
+
|
|
73
|
+
@Serializable
|
|
74
|
+
@SerialName("SIGN_AND_SEND_TRANSACTIONS")
|
|
75
|
+
data class SignAndSendTransactions(
|
|
76
|
+
override val sessionId: String,
|
|
77
|
+
override val cluster: String,
|
|
78
|
+
override val identityName: String?,
|
|
79
|
+
override val identityUri: String?,
|
|
80
|
+
override val iconRelativeUri: String?,
|
|
81
|
+
override val authorizationScope: ByteArray,
|
|
82
|
+
override val payloads: List<ByteArray>
|
|
83
|
+
) : SignPayloads()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package com.solanamobile.mobilewalletadapterwalletlib.reactnative.model
|
|
2
|
+
|
|
3
|
+
import com.solanamobile.mobilewalletadapterwalletlib.reactnative.ByteArrayAsMapSerializer
|
|
4
|
+
import com.solanamobile.mobilewalletadapterwalletlib.reactnative.ByteArrayCollectionAsMapCollectionSerializer
|
|
5
|
+
import kotlinx.serialization.SerialName
|
|
6
|
+
import kotlinx.serialization.Serializable
|
|
7
|
+
|
|
8
|
+
@Serializable
|
|
9
|
+
sealed class MobileWalletAdapterResponse
|
|
10
|
+
|
|
11
|
+
@Serializable
|
|
12
|
+
sealed class MobileWalletAdapterFailureResponse : MobileWalletAdapterResponse()
|
|
13
|
+
|
|
14
|
+
@Serializable
|
|
15
|
+
@SerialName("USER_DECLINED")
|
|
16
|
+
object UserDeclinedResponse : MobileWalletAdapterFailureResponse()
|
|
17
|
+
|
|
18
|
+
@Serializable
|
|
19
|
+
@SerialName("TOO_MANY_PAYLOADS")
|
|
20
|
+
object TooManyPayloadsResponse : MobileWalletAdapterFailureResponse()
|
|
21
|
+
|
|
22
|
+
@Serializable
|
|
23
|
+
@SerialName("AUTHORIZATION_NOT_VALID")
|
|
24
|
+
object AuthorizationNotValidResponse : MobileWalletAdapterFailureResponse()
|
|
25
|
+
|
|
26
|
+
@Serializable
|
|
27
|
+
@SerialName("INVALID_SIGNATURES")
|
|
28
|
+
data class InvalidSignaturesResponse(val valid: BooleanArray) : MobileWalletAdapterFailureResponse()
|
|
29
|
+
|
|
30
|
+
@Serializable
|
|
31
|
+
data class AuthorizeDappResponse(
|
|
32
|
+
@Serializable(with = ByteArrayAsMapSerializer::class) val publicKey: ByteArray,
|
|
33
|
+
val accountLabel: String? = String(publicKey),
|
|
34
|
+
val walletUriBase: String? = null,
|
|
35
|
+
@Serializable(with = ByteArrayAsMapSerializer::class) val authorizationScope: ByteArray? = null
|
|
36
|
+
) : MobileWalletAdapterResponse()
|
|
37
|
+
|
|
38
|
+
@Serializable
|
|
39
|
+
data class SignedPayloads(
|
|
40
|
+
@Serializable(with = ByteArrayCollectionAsMapCollectionSerializer::class) val signedPayloads: List<ByteArray>
|
|
41
|
+
) : MobileWalletAdapterResponse()
|
|
42
|
+
|
|
43
|
+
@Serializable
|
|
44
|
+
data class SignedAndSentTransactions(
|
|
45
|
+
@Serializable(with = ByteArrayCollectionAsMapCollectionSerializer::class) val signedTransactions: List<ByteArray>
|
|
46
|
+
) : MobileWalletAdapterResponse()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
~ Copyright (c) 2022 Solana Mobile Inc.
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
7
|
+
android:shape="rectangle">
|
|
8
|
+
<!-- setting this to be transparent so that react can draw its own ui -->
|
|
9
|
+
<solid
|
|
10
|
+
android:color="#00FFFFFF" />
|
|
11
|
+
</shape>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<resources>
|
|
2
|
+
<style name="Theme.ExampleWallet.BottomSheet" parent="Theme.AppCompat.Dialog">
|
|
3
|
+
<item name="windowActionBar">false</item>
|
|
4
|
+
<item name="windowNoTitle">true</item>
|
|
5
|
+
<item name="android:windowMinWidthMinor">100%</item>
|
|
6
|
+
<item name="android:windowMinWidthMajor">100%</item>
|
|
7
|
+
<item name="android:windowBackground">@drawable/background_bottom_sheet_dialog</item>
|
|
8
|
+
</style>
|
|
9
|
+
</resources>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _mwaSessionEvents = require("./mwaSessionEvents.js");
|
|
7
|
+
Object.keys(_mwaSessionEvents).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _mwaSessionEvents[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _mwaSessionEvents[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _resolve = require("./resolve.js");
|
|
18
|
+
Object.keys(_resolve).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _resolve[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _resolve[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _useMobileWalletAdapterSession = require("./useMobileWalletAdapterSession.js");
|
|
29
|
+
Object.keys(_useMobileWalletAdapterSession).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _useMobileWalletAdapterSession[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _useMobileWalletAdapterSession[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_mwaSessionEvents","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_resolve","_useMobileWalletAdapterSession"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,iBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,iBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,iBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,8BAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,8BAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,8BAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,8BAAA,CAAAN,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MWASessionEventType = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Mobile Wallet Adapter Session Events are notifications and events
|
|
9
|
+
* about the underlying session between the wallet and the dApp.
|
|
10
|
+
*/
|
|
11
|
+
let MWASessionEventType = /*#__PURE__*/function (MWASessionEventType) {
|
|
12
|
+
MWASessionEventType["SessionStartEvent"] = "SESSION_START";
|
|
13
|
+
MWASessionEventType["SessionReadyEvent"] = "SESSION_READY";
|
|
14
|
+
MWASessionEventType["SessionTerminatedEvent"] = "SESSION_TERMINATED";
|
|
15
|
+
MWASessionEventType["SessionServingClientsEvent"] = "SESSION_SERVING_CLIENTS";
|
|
16
|
+
MWASessionEventType["SessionServingCompleteEvent"] = "SESSION_SERVING_COMPLETE";
|
|
17
|
+
MWASessionEventType["SessionCompleteEvent"] = "SESSION_COMPLETE";
|
|
18
|
+
MWASessionEventType["SessionErrorEvent"] = "SESSION_ERROR";
|
|
19
|
+
MWASessionEventType["SessionTeardownCompleteEvent"] = "SESSION_TEARDOWN_COMPLETE";
|
|
20
|
+
MWASessionEventType["LowPowerNoConnectionEvent"] = "LOW_POWER_NO_CONNECTION";
|
|
21
|
+
return MWASessionEventType;
|
|
22
|
+
}({});
|
|
23
|
+
exports.MWASessionEventType = MWASessionEventType;
|
|
24
|
+
//# sourceMappingURL=mwaSessionEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MWASessionEventType","exports"],"sourceRoot":"../../src","sources":["mwaSessionEvents.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAHA,IAIYA,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAAAC,OAAA,CAAAD,mBAAA,GAAAA,mBAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MWARequestType = exports.MWARequestFailReason = void 0;
|
|
7
|
+
exports.resolve = resolve;
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
const LINKING_ERROR = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` + '- You rebuilt the app after installing the package\n' + '- If you are using Lerna workspaces\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` as an explicit dependency, and\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` to the `nohoist` section of your package.json\n' + '- You are not using Expo managed workflow\n';
|
|
10
|
+
const SolanaMobileWalletAdapterWalletLib = _reactNative.Platform.OS === 'android' && _reactNative.NativeModules.SolanaMobileWalletAdapterWalletLib ? _reactNative.NativeModules.SolanaMobileWalletAdapterWalletLib : new Proxy({}, {
|
|
11
|
+
get() {
|
|
12
|
+
throw new Error(_reactNative.Platform.OS !== 'android' ? 'The package `solana-mobile-wallet-adapter-walletlib` is only compatible with React Native Android' : LINKING_ERROR);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Mobile Wallet Adapter Requests are remote requests coming from
|
|
18
|
+
* the dApp for authorization, signing, and sending services.
|
|
19
|
+
*/
|
|
20
|
+
let MWARequestType = /*#__PURE__*/function (MWARequestType) {
|
|
21
|
+
MWARequestType["AuthorizeDappRequest"] = "AUTHORIZE_DAPP";
|
|
22
|
+
MWARequestType["ReauthorizeDappRequest"] = "REAUTHORIZE_DAPP";
|
|
23
|
+
MWARequestType["DeauthorizeDappRequest"] = "DEAUTHORIZE_DAPP";
|
|
24
|
+
MWARequestType["SignMessagesRequest"] = "SIGN_MESSAGES";
|
|
25
|
+
MWARequestType["SignTransactionsRequest"] = "SIGN_TRANSACTIONS";
|
|
26
|
+
MWARequestType["SignAndSendTransactionsRequest"] = "SIGN_AND_SEND_TRANSACTIONS";
|
|
27
|
+
return MWARequestType;
|
|
28
|
+
}({});
|
|
29
|
+
/**
|
|
30
|
+
* MWA Request Responses
|
|
31
|
+
*/
|
|
32
|
+
exports.MWARequestType = MWARequestType;
|
|
33
|
+
/* Failure Responses */
|
|
34
|
+
let MWARequestFailReason = /*#__PURE__*/function (MWARequestFailReason) {
|
|
35
|
+
MWARequestFailReason["UserDeclined"] = "USER_DECLINED";
|
|
36
|
+
MWARequestFailReason["TooManyPayloads"] = "TOO_MANY_PAYLOADS";
|
|
37
|
+
MWARequestFailReason["InvalidSignatures"] = "INVALID_SIGNATURES";
|
|
38
|
+
MWARequestFailReason["AuthorizationNotValid"] = "AUTHORIZATION_NOT_VALID";
|
|
39
|
+
return MWARequestFailReason;
|
|
40
|
+
}({});
|
|
41
|
+
/* Authorize Dapp */
|
|
42
|
+
/* Sign Transactions/Messages */
|
|
43
|
+
/* Sign and Send Transaction */
|
|
44
|
+
exports.MWARequestFailReason = MWARequestFailReason;
|
|
45
|
+
function resolve(request, response) {
|
|
46
|
+
SolanaMobileWalletAdapterWalletLib.resolve(JSON.stringify(request), JSON.stringify(response));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +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,IAWYQ,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAmD1B;AACA;AACA;AAFAC,OAAA,CAAAD,cAAA,GAAAA,cAAA;AAUA;AAAA,IACYE,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAwBhC;AASA;AAWA;AAAAD,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AAaO,SAASC,OAAOA,CAACC,OAAmB,EAAEC,QAAiB,EAAQ;EAClEZ,kCAAkC,CAACU,OAAO,CAACG,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC,EAAEE,IAAI,CAACC,SAAS,CAACF,QAAQ,CAAC,CAAC;AACjG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useMobileWalletAdapterSession = useMobileWalletAdapterSession;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _mwaSessionEvents = require("./mwaSessionEvents.js");
|
|
10
|
+
var _resolve = require("./resolve.js");
|
|
11
|
+
const LINKING_ERROR = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` + '- You rebuilt the app after installing the package\n' + '- If you are using Lerna workspaces\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` as an explicit dependency, and\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` to the `nohoist` section of your package.json\n' + '- You are not using Expo managed workflow\n';
|
|
12
|
+
const SolanaMobileWalletAdapterWalletLib = _reactNative.Platform.OS === 'android' && _reactNative.NativeModules.SolanaMobileWalletAdapterWalletLib ? _reactNative.NativeModules.SolanaMobileWalletAdapterWalletLib : new Proxy({}, {
|
|
13
|
+
get() {
|
|
14
|
+
throw new Error(_reactNative.Platform.OS !== 'android' ? 'The package `solana-mobile-wallet-adapter-walletlib` is only compatible with React Native Android' : LINKING_ERROR);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME = 'MobileWalletAdapterServiceRequestBridge';
|
|
18
|
+
function useMobileWalletAdapterSession(walletName, config, handleRequest, handleSessionEvent) {
|
|
19
|
+
// Start native event listeners
|
|
20
|
+
(0, _react.useEffect)(() => {
|
|
21
|
+
const mwaEventEmitter = new _reactNative.NativeEventEmitter();
|
|
22
|
+
const listener = mwaEventEmitter.addListener(MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME, nativeEvent => {
|
|
23
|
+
if (isMWARequest(nativeEvent)) {
|
|
24
|
+
handleRequest(nativeEvent);
|
|
25
|
+
} else if (isMWASessionEvent(nativeEvent)) {
|
|
26
|
+
handleSessionEvent(nativeEvent);
|
|
27
|
+
} else {
|
|
28
|
+
console.warn('Unexpected native event type');
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
listener.remove();
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
initializeScenario(walletName, config);
|
|
36
|
+
}
|
|
37
|
+
async function initializeScenario(walletName, walletConfig) {
|
|
38
|
+
// Get initial URL
|
|
39
|
+
const initialUrl = await _reactNative.Linking.getInitialURL();
|
|
40
|
+
|
|
41
|
+
// Create Scenario and establish session with dapp
|
|
42
|
+
SolanaMobileWalletAdapterWalletLib.createScenario(walletName, initialUrl, JSON.stringify(walletConfig));
|
|
43
|
+
}
|
|
44
|
+
function isMWARequest(nativeEvent) {
|
|
45
|
+
return Object.values(_resolve.MWARequestType).includes(nativeEvent.__type);
|
|
46
|
+
}
|
|
47
|
+
function isMWASessionEvent(nativeEvent) {
|
|
48
|
+
return Object.values(_mwaSessionEvents.MWASessionEventType).includes(nativeEvent.__type);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=useMobileWalletAdapterSession.js.map
|
|
@@ -0,0 +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","remove","initializeScenario","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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EAAW;EAC7C,OAAOc,MAAM,CAACC,MAAM,CAACC,uBAAc,CAAC,CAACC,QAAQ,CAACjB,WAAW,CAACkB,MAAM,CAAC;AACrE;AAEA,SAAShB,iBAAiBA,CAACF,WAAgB,EAAE;EACzC,OAAOc,MAAM,CAACC,MAAM,CAACI,qCAAmB,CAAC,CAACF,QAAQ,CAACjB,WAAW,CAACkB,MAAM,CAAC;AAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,cAAc;AAC5B,cAAc,oCAAoC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile Wallet Adapter Session Events are notifications and events
|
|
3
|
+
* about the underlying session between the wallet and the dApp.
|
|
4
|
+
*/
|
|
5
|
+
export let MWASessionEventType = /*#__PURE__*/function (MWASessionEventType) {
|
|
6
|
+
MWASessionEventType["SessionStartEvent"] = "SESSION_START";
|
|
7
|
+
MWASessionEventType["SessionReadyEvent"] = "SESSION_READY";
|
|
8
|
+
MWASessionEventType["SessionTerminatedEvent"] = "SESSION_TERMINATED";
|
|
9
|
+
MWASessionEventType["SessionServingClientsEvent"] = "SESSION_SERVING_CLIENTS";
|
|
10
|
+
MWASessionEventType["SessionServingCompleteEvent"] = "SESSION_SERVING_COMPLETE";
|
|
11
|
+
MWASessionEventType["SessionCompleteEvent"] = "SESSION_COMPLETE";
|
|
12
|
+
MWASessionEventType["SessionErrorEvent"] = "SESSION_ERROR";
|
|
13
|
+
MWASessionEventType["SessionTeardownCompleteEvent"] = "SESSION_TEARDOWN_COMPLETE";
|
|
14
|
+
MWASessionEventType["LowPowerNoConnectionEvent"] = "LOW_POWER_NO_CONNECTION";
|
|
15
|
+
return MWASessionEventType;
|
|
16
|
+
}({});
|
|
17
|
+
//# sourceMappingURL=mwaSessionEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MWASessionEventType"],"sourceRoot":"../../src","sources":["mwaSessionEvents.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA,WAAYA,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
const LINKING_ERROR = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` + '- You rebuilt the app after installing the package\n' + '- If you are using Lerna workspaces\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` as an explicit dependency, and\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` to the `nohoist` section of your package.json\n' + '- You are not using Expo managed workflow\n';
|
|
3
|
+
const SolanaMobileWalletAdapterWalletLib = Platform.OS === 'android' && NativeModules.SolanaMobileWalletAdapterWalletLib ? NativeModules.SolanaMobileWalletAdapterWalletLib : new Proxy({}, {
|
|
4
|
+
get() {
|
|
5
|
+
throw new Error(Platform.OS !== 'android' ? 'The package `solana-mobile-wallet-adapter-walletlib` is only compatible with React Native Android' : LINKING_ERROR);
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Mobile Wallet Adapter Requests are remote requests coming from
|
|
11
|
+
* the dApp for authorization, signing, and sending services.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export let MWARequestType = /*#__PURE__*/function (MWARequestType) {
|
|
15
|
+
MWARequestType["AuthorizeDappRequest"] = "AUTHORIZE_DAPP";
|
|
16
|
+
MWARequestType["ReauthorizeDappRequest"] = "REAUTHORIZE_DAPP";
|
|
17
|
+
MWARequestType["DeauthorizeDappRequest"] = "DEAUTHORIZE_DAPP";
|
|
18
|
+
MWARequestType["SignMessagesRequest"] = "SIGN_MESSAGES";
|
|
19
|
+
MWARequestType["SignTransactionsRequest"] = "SIGN_TRANSACTIONS";
|
|
20
|
+
MWARequestType["SignAndSendTransactionsRequest"] = "SIGN_AND_SEND_TRANSACTIONS";
|
|
21
|
+
return MWARequestType;
|
|
22
|
+
}({});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* MWA Request Responses
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/* Failure Responses */
|
|
29
|
+
export let MWARequestFailReason = /*#__PURE__*/function (MWARequestFailReason) {
|
|
30
|
+
MWARequestFailReason["UserDeclined"] = "USER_DECLINED";
|
|
31
|
+
MWARequestFailReason["TooManyPayloads"] = "TOO_MANY_PAYLOADS";
|
|
32
|
+
MWARequestFailReason["InvalidSignatures"] = "INVALID_SIGNATURES";
|
|
33
|
+
MWARequestFailReason["AuthorizationNotValid"] = "AUTHORIZATION_NOT_VALID";
|
|
34
|
+
return MWARequestFailReason;
|
|
35
|
+
}({});
|
|
36
|
+
|
|
37
|
+
/* Authorize Dapp */
|
|
38
|
+
|
|
39
|
+
/* Sign Transactions/Messages */
|
|
40
|
+
|
|
41
|
+
/* Sign and Send Transaction */
|
|
42
|
+
|
|
43
|
+
export function resolve(request, response) {
|
|
44
|
+
SolanaMobileWalletAdapterWalletLib.resolve(JSON.stringify(request), JSON.stringify(response));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;;AAQA,WAAYM,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;;AAmD1B;AACA;AACA;;AAQA;AACA,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;;AAwBhC;;AASA;;AAWA;;AAaA,OAAO,SAASC,OAAOA,CAACC,OAAmB,EAAEC,QAAiB,EAAQ;EAClET,kCAAkC,CAACO,OAAO,CAACG,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC,EAAEE,IAAI,CAACC,SAAS,CAACF,QAAQ,CAAC,CAAC;AACjG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { Linking, NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
3
|
+
import { MWASessionEventType } from './mwaSessionEvents.js';
|
|
4
|
+
import { MWARequestType } from './resolve.js';
|
|
5
|
+
const LINKING_ERROR = `The package 'solana-mobile-wallet-adapter-walletlib' doesn't seem to be linked. Make sure: \n\n` + '- You rebuilt the app after installing the package\n' + '- If you are using Lerna workspaces\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` as an explicit dependency, and\n' + ' - You have added `@solana-mobile/mobile-wallet-adapter-walletlib` to the `nohoist` section of your package.json\n' + '- You are not using Expo managed workflow\n';
|
|
6
|
+
const SolanaMobileWalletAdapterWalletLib = Platform.OS === 'android' && NativeModules.SolanaMobileWalletAdapterWalletLib ? NativeModules.SolanaMobileWalletAdapterWalletLib : new Proxy({}, {
|
|
7
|
+
get() {
|
|
8
|
+
throw new Error(Platform.OS !== 'android' ? 'The package `solana-mobile-wallet-adapter-walletlib` is only compatible with React Native Android' : LINKING_ERROR);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME = 'MobileWalletAdapterServiceRequestBridge';
|
|
12
|
+
export function useMobileWalletAdapterSession(walletName, config, handleRequest, handleSessionEvent) {
|
|
13
|
+
// Start native event listeners
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const mwaEventEmitter = new NativeEventEmitter();
|
|
16
|
+
const listener = mwaEventEmitter.addListener(MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME, nativeEvent => {
|
|
17
|
+
if (isMWARequest(nativeEvent)) {
|
|
18
|
+
handleRequest(nativeEvent);
|
|
19
|
+
} else if (isMWASessionEvent(nativeEvent)) {
|
|
20
|
+
handleSessionEvent(nativeEvent);
|
|
21
|
+
} else {
|
|
22
|
+
console.warn('Unexpected native event type');
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
listener.remove();
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
initializeScenario(walletName, config);
|
|
30
|
+
}
|
|
31
|
+
async function initializeScenario(walletName, walletConfig) {
|
|
32
|
+
// Get initial URL
|
|
33
|
+
const initialUrl = await Linking.getInitialURL();
|
|
34
|
+
|
|
35
|
+
// Create Scenario and establish session with dapp
|
|
36
|
+
SolanaMobileWalletAdapterWalletLib.createScenario(walletName, initialUrl, JSON.stringify(walletConfig));
|
|
37
|
+
}
|
|
38
|
+
function isMWARequest(nativeEvent) {
|
|
39
|
+
return Object.values(MWARequestType).includes(nativeEvent.__type);
|
|
40
|
+
}
|
|
41
|
+
function isMWASessionEvent(nativeEvent) {
|
|
42
|
+
return Object.values(MWASessionEventType).includes(nativeEvent.__type);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=useMobileWalletAdapterSession.js.map
|
|
@@ -0,0 +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","remove","initializeScenario","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,CA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MAAM,CAAC;AAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile Wallet Adapter Session Events are notifications and events
|
|
3
|
+
* about the underlying session between the wallet and the dApp.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum MWASessionEventType {
|
|
6
|
+
SessionStartEvent = "SESSION_START",
|
|
7
|
+
SessionReadyEvent = "SESSION_READY",
|
|
8
|
+
SessionTerminatedEvent = "SESSION_TERMINATED",
|
|
9
|
+
SessionServingClientsEvent = "SESSION_SERVING_CLIENTS",
|
|
10
|
+
SessionServingCompleteEvent = "SESSION_SERVING_COMPLETE",
|
|
11
|
+
SessionCompleteEvent = "SESSION_COMPLETE",
|
|
12
|
+
SessionErrorEvent = "SESSION_ERROR",
|
|
13
|
+
SessionTeardownCompleteEvent = "SESSION_TEARDOWN_COMPLETE",
|
|
14
|
+
LowPowerNoConnectionEvent = "LOW_POWER_NO_CONNECTION"
|
|
15
|
+
}
|
|
16
|
+
export interface IMWASessionEvent {
|
|
17
|
+
__type: MWASessionEventType;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
}
|
|
20
|
+
export declare type SessionStartEvent = Readonly<{
|
|
21
|
+
__type: MWASessionEventType.SessionStartEvent;
|
|
22
|
+
}> & IMWASessionEvent;
|
|
23
|
+
export declare type SessionReadyEvent = Readonly<{
|
|
24
|
+
__type: MWASessionEventType.SessionReadyEvent;
|
|
25
|
+
}> & IMWASessionEvent;
|
|
26
|
+
export declare type SessionTerminatedEvent = Readonly<{
|
|
27
|
+
__type: MWASessionEventType.SessionTerminatedEvent;
|
|
28
|
+
}> & IMWASessionEvent;
|
|
29
|
+
export declare type SessionServingClientsEvent = Readonly<{
|
|
30
|
+
__type: MWASessionEventType.SessionServingClientsEvent;
|
|
31
|
+
}> & IMWASessionEvent;
|
|
32
|
+
export declare type SessionServingCompleteEvent = Readonly<{
|
|
33
|
+
__type: MWASessionEventType.SessionServingCompleteEvent;
|
|
34
|
+
}> & IMWASessionEvent;
|
|
35
|
+
export declare type SessionCompleteEvent = Readonly<{
|
|
36
|
+
__type: MWASessionEventType.SessionCompleteEvent;
|
|
37
|
+
}> & IMWASessionEvent;
|
|
38
|
+
export declare type SessionErrorEvent = Readonly<{
|
|
39
|
+
__type: MWASessionEventType.SessionErrorEvent;
|
|
40
|
+
}> & IMWASessionEvent;
|
|
41
|
+
export declare type SessionTeardownCompleteEvent = Readonly<{
|
|
42
|
+
__type: MWASessionEventType.SessionTeardownCompleteEvent;
|
|
43
|
+
}> & IMWASessionEvent;
|
|
44
|
+
export declare type LowPowerNoConnectionEvent = Readonly<{
|
|
45
|
+
__type: MWASessionEventType.LowPowerNoConnectionEvent;
|
|
46
|
+
}> & IMWASessionEvent;
|
|
47
|
+
export declare type MWASessionEvent = SessionStartEvent | SessionReadyEvent | SessionTerminatedEvent | SessionServingClientsEvent | SessionServingCompleteEvent | SessionCompleteEvent | SessionErrorEvent | SessionTeardownCompleteEvent | LowPowerNoConnectionEvent;
|
|
48
|
+
//# sourceMappingURL=mwaSessionEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mwaSessionEvents.d.ts","sourceRoot":"","sources":["../../src/mwaSessionEvents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,mBAAmB;IAC3B,iBAAiB,kBAAkB;IACnC,iBAAiB,kBAAkB;IACnC,sBAAsB,uBAAuB;IAC7C,0BAA0B,4BAA4B;IACtD,2BAA2B,6BAA6B;IACxD,oBAAoB,qBAAqB;IACzC,iBAAiB,kBAAkB;IACnC,4BAA4B,8BAA8B;IAC1D,yBAAyB,4BAA4B;CACxD;AACD,MAAM,WAAW,gBAAgB;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B,2BAA2B,GAC3B,oBAAoB,GACpB,iBAAiB,GACjB,4BAA4B,GAC5B,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
declare type AppIdentity = Readonly<{
|
|
2
|
+
identityUri?: string;
|
|
3
|
+
iconRelativeUri?: string;
|
|
4
|
+
identityName?: string;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Mobile Wallet Adapter Requests are remote requests coming from
|
|
8
|
+
* the dApp for authorization, signing, and sending services.
|
|
9
|
+
*/
|
|
10
|
+
export declare type MWARequest = SignMessagesRequest | SignTransactionsRequest | SignAndSendTransactionsRequest | AuthorizeDappRequest;
|
|
11
|
+
export declare enum MWARequestType {
|
|
12
|
+
AuthorizeDappRequest = "AUTHORIZE_DAPP",
|
|
13
|
+
ReauthorizeDappRequest = "REAUTHORIZE_DAPP",
|
|
14
|
+
DeauthorizeDappRequest = "DEAUTHORIZE_DAPP",
|
|
15
|
+
SignMessagesRequest = "SIGN_MESSAGES",
|
|
16
|
+
SignTransactionsRequest = "SIGN_TRANSACTIONS",
|
|
17
|
+
SignAndSendTransactionsRequest = "SIGN_AND_SEND_TRANSACTIONS"
|
|
18
|
+
}
|
|
19
|
+
interface IMWARequest {
|
|
20
|
+
__type: MWARequestType;
|
|
21
|
+
requestId: string;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
cluster: string;
|
|
24
|
+
authorizationScope: Uint8Array;
|
|
25
|
+
appIdentity?: AppIdentity;
|
|
26
|
+
}
|
|
27
|
+
export declare type AuthorizeDappRequest = Readonly<{
|
|
28
|
+
__type: MWARequestType.AuthorizeDappRequest;
|
|
29
|
+
}> & IMWARequest;
|
|
30
|
+
export declare type ReauthorizeDappRequest = Readonly<{
|
|
31
|
+
__type: MWARequestType.ReauthorizeDappRequest;
|
|
32
|
+
}> & IMWARequest;
|
|
33
|
+
export declare type DeauthorizeDappRequest = Readonly<{
|
|
34
|
+
__type: MWARequestType.DeauthorizeDappRequest;
|
|
35
|
+
}> & IMWARequest;
|
|
36
|
+
export declare type SignMessagesRequest = Readonly<{
|
|
37
|
+
__type: MWARequestType.SignMessagesRequest;
|
|
38
|
+
payloads: Uint8Array[];
|
|
39
|
+
}> & IMWARequest;
|
|
40
|
+
export declare type SignTransactionsRequest = Readonly<{
|
|
41
|
+
__type: MWARequestType.SignTransactionsRequest;
|
|
42
|
+
payloads: Uint8Array[];
|
|
43
|
+
}> & IMWARequest;
|
|
44
|
+
export declare type SignAndSendTransactionsRequest = Readonly<{
|
|
45
|
+
__type: MWARequestType.SignAndSendTransactionsRequest;
|
|
46
|
+
payloads: Uint8Array[];
|
|
47
|
+
minContextSlot?: number;
|
|
48
|
+
}> & IMWARequest;
|
|
49
|
+
/**
|
|
50
|
+
* MWA Request Responses
|
|
51
|
+
*/
|
|
52
|
+
export declare type MWAResponse = AuthorizeDappResponse | SignMessagesResponse | SignTransactionsResponse | SignAndSendTransactionsResponse;
|
|
53
|
+
export declare enum MWARequestFailReason {
|
|
54
|
+
UserDeclined = "USER_DECLINED",
|
|
55
|
+
TooManyPayloads = "TOO_MANY_PAYLOADS",
|
|
56
|
+
InvalidSignatures = "INVALID_SIGNATURES",
|
|
57
|
+
AuthorizationNotValid = "AUTHORIZATION_NOT_VALID"
|
|
58
|
+
}
|
|
59
|
+
export declare type UserDeclinedResponse = Readonly<{
|
|
60
|
+
failReason: MWARequestFailReason.UserDeclined;
|
|
61
|
+
}>;
|
|
62
|
+
export declare type TooManyPayloadsResponse = Readonly<{
|
|
63
|
+
failReason: MWARequestFailReason.TooManyPayloads;
|
|
64
|
+
}>;
|
|
65
|
+
export declare type AuthorizationNotValidResponse = Readonly<{
|
|
66
|
+
failReason: MWARequestFailReason.AuthorizationNotValid;
|
|
67
|
+
}>;
|
|
68
|
+
export declare type InvalidSignaturesResponse = Readonly<{
|
|
69
|
+
failReason: MWARequestFailReason.InvalidSignatures;
|
|
70
|
+
valid: boolean[];
|
|
71
|
+
}>;
|
|
72
|
+
export declare type AuthorizeDappCompleteResponse = Readonly<{
|
|
73
|
+
publicKey: Uint8Array;
|
|
74
|
+
accountLabel?: string;
|
|
75
|
+
walletUriBase?: string;
|
|
76
|
+
authorizationScope?: Uint8Array;
|
|
77
|
+
}>;
|
|
78
|
+
export declare type AuthorizeDappResponse = AuthorizeDappCompleteResponse | UserDeclinedResponse;
|
|
79
|
+
export declare type SignPayloadsCompleteResponse = Readonly<{
|
|
80
|
+
signedPayloads: Uint8Array[];
|
|
81
|
+
}>;
|
|
82
|
+
export declare type SignPayloadsFailResponse = UserDeclinedResponse | TooManyPayloadsResponse | AuthorizationNotValidResponse | InvalidSignaturesResponse;
|
|
83
|
+
export declare type SignTransactionsResponse = SignPayloadsCompleteResponse | SignPayloadsFailResponse;
|
|
84
|
+
export declare type SignMessagesResponse = SignPayloadsCompleteResponse | SignPayloadsFailResponse;
|
|
85
|
+
export declare type SignAndSendTransactionsCompleteResponse = Readonly<{
|
|
86
|
+
signedTransactions: Uint8Array[];
|
|
87
|
+
}>;
|
|
88
|
+
export declare type SignAndSendTransactionsResponse = SignAndSendTransactionsCompleteResponse | UserDeclinedResponse | TooManyPayloadsResponse | AuthorizationNotValidResponse | InvalidSignaturesResponse;
|
|
89
|
+
export declare function resolve(request: AuthorizeDappRequest, response: AuthorizeDappResponse): void;
|
|
90
|
+
export declare function resolve(request: SignMessagesRequest, response: SignMessagesResponse): void;
|
|
91
|
+
export declare function resolve(request: SignTransactionsRequest, response: SignTransactionsResponse): void;
|
|
92
|
+
export declare function resolve(request: SignAndSendTransactionsRequest, response: SignAndSendTransactionsResponse): void;
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=resolve.d.ts.map
|