@walletconnect/react-native-compat 2.10.5-rc-e12288e → 2.10.5-rc-c91a538
Sign up to get free protection for your applications and to get access to all the features.
- package/module/NativeRNWalletConnectModule.ts +12 -0
- package/module/index.ts +47 -0
- package/package.json +2 -2
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { TurboModule } from "react-native";
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
3
|
+
|
4
|
+
export interface Spec extends TurboModule {
|
5
|
+
isAppInstalled(bundleId?: string): Promise<boolean>;
|
6
|
+
getConstants(): {
|
7
|
+
applicationName: string;
|
8
|
+
applicationId: string;
|
9
|
+
};
|
10
|
+
}
|
11
|
+
|
12
|
+
export default TurboModuleRegistry.getEnforcing<Spec>("RNWalletConnectModule");
|
package/module/index.ts
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
import { NativeModules } from "react-native";
|
2
|
+
|
3
|
+
const LINKING_ERROR =
|
4
|
+
`The package to get the RNWalletConnectModule doesn't seem to be linked. Make sure: \n\n` +
|
5
|
+
"- You rebuilt the app after installing the package\n" +
|
6
|
+
"- If you are using Expo: install expo-application \n";
|
7
|
+
|
8
|
+
// @ts-expect-error
|
9
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
10
|
+
|
11
|
+
const RNWalletConnectModule = isTurboModuleEnabled
|
12
|
+
? require("../module/NativeRNWalletConnectModule").default
|
13
|
+
: NativeModules.RNWalletConnectModule;
|
14
|
+
|
15
|
+
function getExpoModule(): any | undefined {
|
16
|
+
try {
|
17
|
+
const ExpoApplication = require("expo-application");
|
18
|
+
|
19
|
+
if (!ExpoApplication) throw new Error();
|
20
|
+
|
21
|
+
return ExpoApplication;
|
22
|
+
} catch {
|
23
|
+
throw new Error();
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
function getRNModule(): any | undefined {
|
28
|
+
try {
|
29
|
+
if (!RNWalletConnectModule) throw new Error();
|
30
|
+
return RNWalletConnectModule;
|
31
|
+
} catch {
|
32
|
+
throw new Error();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
// Public
|
37
|
+
export function getApplicationModule(): any | undefined {
|
38
|
+
try {
|
39
|
+
return getRNModule();
|
40
|
+
} catch (error) {
|
41
|
+
try {
|
42
|
+
return getExpoModule();
|
43
|
+
} catch (error) {
|
44
|
+
throw new Error(LINKING_ERROR);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@walletconnect/react-native-compat",
|
3
3
|
"description": "Shims for WalletConnect Protocol in React Native Projects",
|
4
|
-
"version": "2.10.5-rc-
|
4
|
+
"version": "2.10.5-rc-c91a538",
|
5
5
|
"author": "WalletConnect, Inc. <walletconnect.com>",
|
6
6
|
"homepage": "https://github.com/walletconnect/walletconnect-monorepo/",
|
7
7
|
"license": "Apache-2.0",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
"dist",
|
11
11
|
"android",
|
12
12
|
"ios",
|
13
|
-
"
|
13
|
+
"module",
|
14
14
|
"cpp",
|
15
15
|
"*.podspec",
|
16
16
|
"!ios/build",
|