-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathenable-walletconnect.patch
74 lines (69 loc) · 2.06 KB
/
enable-walletconnect.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
diff --git a/shim.js b/shim.js
index 73c130d..deae975 100644
--- a/shim.js
+++ b/shim.js
@@ -26,3 +26,20 @@ if (typeof localStorage !== 'undefined') {
// If using the crypto shim, uncomment the following line to ensure
// crypto is loaded first, so it can populate global.crypto
require('crypto')
+
+const { TextEncoder, TextDecoder } = require('text-encoding');
+
+global.TextDecoder = TextDecoder;
+global.TextEncoder = TextEncoder;
+
+if (typeof btoa === 'undefined') {
+ global.btoa = function (str) {
+ return Buffer.from(str, 'binary').toString('base64');
+ };
+}
+
+if (typeof atob === 'undefined') {
+ global.atob = function (b64Encoded) {
+ return Buffer.from(b64Encoded, 'base64').toString('binary');
+ };
+}
diff --git a/src/sagas/walletConnect.js b/src/sagas/walletConnect.js
index 160cb11..07ccb34 100644
--- a/src/sagas/walletConnect.js
+++ b/src/sagas/walletConnect.js
@@ -45,6 +45,7 @@
* loaded.
*/
+import '@walletconnect/react-native-compat';
import {
call,
fork,
@@ -62,6 +63,8 @@ import {
} from 'redux-saga/effects';
import { eventChannel } from 'redux-saga';
import { get, values } from 'lodash';
+import { Core } from '@walletconnect/core';
+import { Web3Wallet } from '@walletconnect/web3wallet';
import {
TriggerTypes,
TriggerResponseTypes,
@@ -100,12 +103,6 @@ const AVAILABLE_METHODS = {
};
const AVAILABLE_EVENTS = [];
-// We're mocking it here because we don't want to add the walletconnect
-// libraries in our production build. If you really want to add it, just run the
-// src/walletconnect.sh script
-const Core = class {};
-const Web3Wallet = class {};
-
/**
* Those are the only ones we are currently using, extracted from
* https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes
@@ -118,13 +115,10 @@ const ERROR_CODES = {
INVALID_PAYLOAD: 5003,
};
-function isWalletConnectEnabled() {
- return false;
- /*
+function* isWalletConnectEnabled() {
const walletConnectEnabled = yield call(checkForFeatureFlag, WALLET_CONNECT_FEATURE_TOGGLE);
return walletConnectEnabled;
- */
}
function* init() {