@reown/appkit-core-react-native 0.0.0-chore-spring-effect-20250909214820 → 0.0.0-chore-examples-20251009175707
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/lib/commonjs/controllers/ApiController.js +19 -8
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +31 -28
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +13 -3
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
- package/lib/commonjs/controllers/EnsController.js +2 -0
- package/lib/commonjs/controllers/EnsController.js.map +1 -1
- package/lib/commonjs/controllers/EventsController.js +51 -1
- package/lib/commonjs/controllers/EventsController.js.map +1 -1
- package/lib/commonjs/controllers/LogController.js +188 -0
- package/lib/commonjs/controllers/LogController.js.map +1 -0
- package/lib/commonjs/controllers/OnRampController.js +14 -0
- package/lib/commonjs/controllers/OnRampController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +6 -3
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/SendController.js +18 -2
- package/lib/commonjs/controllers/SendController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +10 -2
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js +5 -0
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +2 -0
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
- package/lib/commonjs/features/reown-authentication/ReownAuthentication.js +272 -0
- package/lib/commonjs/features/reown-authentication/ReownAuthentication.js.map +1 -0
- package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js +48 -0
- package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
- package/lib/commonjs/features/reown-authentication/index.js +28 -0
- package/lib/commonjs/features/reown-authentication/index.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ApiUtil.js +1 -1
- package/lib/commonjs/utils/ApiUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +0 -1
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +13 -2
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/FetchUtil.js +7 -2
- package/lib/commonjs/utils/FetchUtil.js.map +1 -1
- package/lib/commonjs/utils/LogUtils.js +131 -0
- package/lib/commonjs/utils/LogUtils.js.map +1 -0
- package/lib/commonjs/utils/StorageUtil.js +75 -76
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/module/controllers/ApiController.js +19 -8
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/BlockchainApiController.js +31 -28
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +14 -4
- package/lib/module/controllers/ConnectionsController.js.map +1 -1
- package/lib/module/controllers/EnsController.js +2 -0
- package/lib/module/controllers/EnsController.js.map +1 -1
- package/lib/module/controllers/EventsController.js +51 -1
- package/lib/module/controllers/EventsController.js.map +1 -1
- package/lib/module/controllers/LogController.js +185 -0
- package/lib/module/controllers/LogController.js.map +1 -0
- package/lib/module/controllers/OnRampController.js +14 -0
- package/lib/module/controllers/OnRampController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +6 -3
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/SendController.js +18 -2
- package/lib/module/controllers/SendController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +10 -2
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +5 -0
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +2 -0
- package/lib/module/controllers/TransactionsController.js.map +1 -1
- package/lib/module/features/reown-authentication/ReownAuthentication.js +268 -0
- package/lib/module/features/reown-authentication/ReownAuthentication.js.map +1 -0
- package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js +43 -0
- package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
- package/lib/module/features/reown-authentication/index.js +5 -0
- package/lib/module/features/reown-authentication/index.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ApiUtil.js +1 -1
- package/lib/module/utils/ApiUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +0 -1
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +13 -2
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/FetchUtil.js +8 -2
- package/lib/module/utils/FetchUtil.js.map +1 -1
- package/lib/module/utils/LogUtils.js +121 -0
- package/lib/module/utils/LogUtils.js.map +1 -0
- package/lib/module/utils/StorageUtil.js +76 -77
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/typescript/controllers/ApiController.d.ts +6 -4
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts +1 -0
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/EnsController.d.ts.map +1 -1
- package/lib/typescript/controllers/EventsController.d.ts +13 -1
- package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
- package/lib/typescript/controllers/LogController.d.ts +65 -0
- package/lib/typescript/controllers/LogController.d.ts.map +1 -0
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +3 -3
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +1 -1
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- package/lib/typescript/controllers/SendController.d.ts.map +1 -1
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
- package/lib/typescript/controllers/ThemeController.d.ts +2 -0
- package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
- package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
- package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts +174 -0
- package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts.map +1 -0
- package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts +16 -0
- package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts.map +1 -0
- package/lib/typescript/features/reown-authentication/index.d.ts +3 -0
- package/lib/typescript/features/reown-authentication/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/ApiUtil.d.ts +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +0 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +3 -2
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts +2 -2
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
- package/lib/typescript/utils/LogUtils.d.ts +15 -0
- package/lib/typescript/utils/LogUtils.d.ts.map +1 -0
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/controllers/ApiController.ts +28 -8
- package/src/controllers/BlockchainApiController.ts +39 -29
- package/src/controllers/ConnectionsController.ts +27 -3
- package/src/controllers/EnsController.ts +2 -0
- package/src/controllers/EventsController.ts +73 -2
- package/src/controllers/LogController.ts +250 -0
- package/src/controllers/OnRampController.ts +12 -0
- package/src/controllers/OptionsController.ts +11 -6
- package/src/controllers/RouterController.ts +3 -3
- package/src/controllers/SendController.ts +28 -3
- package/src/controllers/SwapController.ts +10 -2
- package/src/controllers/ThemeController.ts +7 -0
- package/src/controllers/TransactionsController.ts +2 -0
- package/src/features/reown-authentication/ReownAuthentication.ts +475 -0
- package/src/features/reown-authentication/ReownAuthenticationMessenger.ts +80 -0
- package/src/features/reown-authentication/index.ts +2 -0
- package/src/index.ts +12 -0
- package/src/utils/ApiUtil.ts +1 -1
- package/src/utils/ConstantsUtil.ts +0 -1
- package/src/utils/CoreHelperUtil.ts +21 -3
- package/src/utils/FetchUtil.ts +12 -3
- package/src/utils/LogUtils.ts +179 -0
- package/src/utils/StorageUtil.ts +85 -102
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// -- Constants ----------------------------------------- //
|
|
2
|
+
const SENSITIVE_KEYS = [
|
|
3
|
+
'password',
|
|
4
|
+
'pass',
|
|
5
|
+
'pwd',
|
|
6
|
+
'secret',
|
|
7
|
+
'token',
|
|
8
|
+
'key',
|
|
9
|
+
'auth',
|
|
10
|
+
'authorization',
|
|
11
|
+
'bearer',
|
|
12
|
+
'credential',
|
|
13
|
+
'api_key',
|
|
14
|
+
'apikey',
|
|
15
|
+
'access_token',
|
|
16
|
+
'refresh_token',
|
|
17
|
+
'private_key',
|
|
18
|
+
'privatekey',
|
|
19
|
+
'mnemonic',
|
|
20
|
+
'seed',
|
|
21
|
+
'phrase',
|
|
22
|
+
'wallet',
|
|
23
|
+
'address',
|
|
24
|
+
'email',
|
|
25
|
+
'phone',
|
|
26
|
+
'ssn',
|
|
27
|
+
'social',
|
|
28
|
+
'credit',
|
|
29
|
+
'card',
|
|
30
|
+
'cvv',
|
|
31
|
+
'connection_string',
|
|
32
|
+
'connection',
|
|
33
|
+
'user_token'
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const MAX_STRING_LENGTH = 480; // Maximum length for any string value (account for potential replacements)
|
|
37
|
+
const MAX_STACK_LINES = 10; // Maximum lines in stack trace
|
|
38
|
+
|
|
39
|
+
// -- Data Sanitization Functions ---------------------- //
|
|
40
|
+
export const sanitizeString = (value: string): string => {
|
|
41
|
+
if (typeof value !== 'string') {
|
|
42
|
+
value = String(value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (value.length > MAX_STRING_LENGTH) {
|
|
46
|
+
return value.substring(0, MAX_STRING_LENGTH) + '... [truncated]';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return value;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const sanitizeStackTrace = (stack: string): string => {
|
|
53
|
+
if (typeof stack !== 'string') {
|
|
54
|
+
stack = String(stack);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const lines = stack.split('\n');
|
|
58
|
+
const sanitizedLines = lines.slice(0, MAX_STACK_LINES).map(line => {
|
|
59
|
+
// Remove file paths that might contain sensitive info
|
|
60
|
+
return line.replace(/\/[^\s]*\//g, '/[path]/');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (lines.length > MAX_STACK_LINES) {
|
|
64
|
+
sanitizedLines.push('... [stack trace truncated]');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return sanitizedLines.join('\n');
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const sanitizeUrl = (url: string): string => {
|
|
71
|
+
try {
|
|
72
|
+
const urlObj = new URL(url);
|
|
73
|
+
// Remove query parameters that might contain sensitive data
|
|
74
|
+
urlObj.search = '';
|
|
75
|
+
// Keep only the origin and pathname
|
|
76
|
+
|
|
77
|
+
return urlObj.origin + urlObj.pathname;
|
|
78
|
+
} catch {
|
|
79
|
+
// If URL parsing fails, just return sanitized string
|
|
80
|
+
|
|
81
|
+
return sanitizeString(url);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const isSensitiveKey = (key: string): boolean => {
|
|
86
|
+
const lowerKey = key.toLowerCase();
|
|
87
|
+
|
|
88
|
+
return SENSITIVE_KEYS.some(sensitiveKey => lowerKey.includes(sensitiveKey));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const sanitizeValue = (value: unknown, visited = new WeakSet()): unknown => {
|
|
92
|
+
if (value === null || value === undefined) {
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (typeof value === 'string') {
|
|
97
|
+
// Check if it looks like a URL
|
|
98
|
+
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
99
|
+
return sanitizeUrl(value);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return sanitizeString(value);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (Array.isArray(value)) {
|
|
110
|
+
// Prevent circular references in arrays
|
|
111
|
+
if (visited.has(value)) {
|
|
112
|
+
return '[Circular Reference]';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
visited.add(value);
|
|
116
|
+
const result = value.slice(0, 10).map(item => sanitizeValue(item, visited));
|
|
117
|
+
visited.delete(value);
|
|
118
|
+
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (typeof value === 'object') {
|
|
123
|
+
return sanitizeObject(value as Record<string, unknown>, visited);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// For other types, convert to string and sanitize
|
|
127
|
+
return sanitizeString(String(value));
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const sanitizeObject = (
|
|
131
|
+
obj: Record<string, unknown>,
|
|
132
|
+
visited = new WeakSet()
|
|
133
|
+
): Record<string, unknown> => {
|
|
134
|
+
// Prevent circular references
|
|
135
|
+
if (visited.has(obj)) {
|
|
136
|
+
return { '[Circular Reference]': true };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
visited.add(obj);
|
|
140
|
+
|
|
141
|
+
const sanitized: Record<string, unknown> = {};
|
|
142
|
+
const keys = Object.keys(obj).slice(0, 20); // Limit number of keys
|
|
143
|
+
|
|
144
|
+
for (const key of keys) {
|
|
145
|
+
if (isSensitiveKey(key)) {
|
|
146
|
+
sanitized[key] = '[REDACTED]';
|
|
147
|
+
} else {
|
|
148
|
+
sanitized[key] = sanitizeValue(obj[key], visited);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (Object.keys(obj).length > 20) {
|
|
153
|
+
sanitized['...'] = '[additional properties truncated]';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
visited.delete(obj);
|
|
157
|
+
|
|
158
|
+
return sanitized;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const sanitizeData = (
|
|
162
|
+
data?: Record<string, unknown>
|
|
163
|
+
): Record<string, unknown> | undefined => {
|
|
164
|
+
if (!data) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return sanitizeObject(data);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// -- Utility Functions --------------------------------- //
|
|
172
|
+
export const LogUtils = {
|
|
173
|
+
sanitizeString,
|
|
174
|
+
sanitizeStackTrace,
|
|
175
|
+
sanitizeUrl,
|
|
176
|
+
sanitizeValue,
|
|
177
|
+
sanitizeObject,
|
|
178
|
+
sanitizeData
|
|
179
|
+
};
|
package/src/utils/StorageUtil.ts
CHANGED
|
@@ -10,33 +10,34 @@ import {
|
|
|
10
10
|
type ConnectorType,
|
|
11
11
|
type ChainNamespace,
|
|
12
12
|
type WalletDeepLink,
|
|
13
|
-
|
|
13
|
+
SafeStorageKeys
|
|
14
14
|
} from '@reown/appkit-common-react-native';
|
|
15
15
|
import { OptionsController } from '../controllers/OptionsController';
|
|
16
|
+
import { LogController } from '../controllers/LogController';
|
|
16
17
|
|
|
17
18
|
// -- Utility -----------------------------------------------------------------
|
|
18
19
|
export const StorageUtil = {
|
|
19
20
|
setWalletConnectDeepLink({ href, name }: WalletDeepLink) {
|
|
20
21
|
try {
|
|
21
|
-
OptionsController.getStorage().setItem(
|
|
22
|
+
OptionsController.getStorage().setItem(SafeStorageKeys.WC_DEEPLINK, {
|
|
22
23
|
href,
|
|
23
24
|
name
|
|
24
25
|
});
|
|
25
|
-
} catch {
|
|
26
|
-
|
|
26
|
+
} catch (error) {
|
|
27
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setWalletConnectDeepLink');
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
30
|
|
|
30
31
|
async getWalletConnectDeepLink() {
|
|
31
32
|
try {
|
|
32
33
|
const deepLink = await OptionsController.getStorage().getItem<WalletDeepLink>(
|
|
33
|
-
|
|
34
|
+
SafeStorageKeys.WC_DEEPLINK
|
|
34
35
|
);
|
|
35
36
|
if (deepLink) {
|
|
36
37
|
return deepLink;
|
|
37
38
|
}
|
|
38
|
-
} catch {
|
|
39
|
-
|
|
39
|
+
} catch (error) {
|
|
40
|
+
LogController.sendError(error, 'StorageUtil.ts', 'getWalletConnectDeepLink');
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
return undefined;
|
|
@@ -44,9 +45,9 @@ export const StorageUtil = {
|
|
|
44
45
|
|
|
45
46
|
async removeWalletConnectDeepLink() {
|
|
46
47
|
try {
|
|
47
|
-
await OptionsController.getStorage().removeItem(
|
|
48
|
-
} catch {
|
|
49
|
-
|
|
48
|
+
await OptionsController.getStorage().removeItem(SafeStorageKeys.WC_DEEPLINK);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
LogController.sendError(error, 'StorageUtil.ts', 'removeWalletConnectDeepLink');
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
53
|
|
|
@@ -63,14 +64,11 @@ export const StorageUtil = {
|
|
|
63
64
|
if (recentWallets.length > 2) {
|
|
64
65
|
recentWallets.pop();
|
|
65
66
|
}
|
|
66
|
-
OptionsController.getStorage().setItem(
|
|
67
|
-
ConstantsUtil.STORAGE_KEYS.RECENT_WALLET,
|
|
68
|
-
recentWallets
|
|
69
|
-
);
|
|
67
|
+
OptionsController.getStorage().setItem(SafeStorageKeys.RECENT_WALLET, recentWallets);
|
|
70
68
|
|
|
71
69
|
return recentWallets;
|
|
72
|
-
} catch {
|
|
73
|
-
|
|
70
|
+
} catch (error) {
|
|
71
|
+
LogController.sendError(error, 'StorageUtil.ts', 'addRecentWallet');
|
|
74
72
|
|
|
75
73
|
return undefined;
|
|
76
74
|
}
|
|
@@ -78,24 +76,19 @@ export const StorageUtil = {
|
|
|
78
76
|
|
|
79
77
|
async setRecentWallets(wallets: WcWallet[]) {
|
|
80
78
|
try {
|
|
81
|
-
await OptionsController.getStorage().setItem(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
} catch {
|
|
86
|
-
console.info('Unable to set recent wallets');
|
|
79
|
+
await OptionsController.getStorage().setItem(SafeStorageKeys.RECENT_WALLET, wallets);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setRecentWallets');
|
|
87
82
|
}
|
|
88
83
|
},
|
|
89
84
|
|
|
90
85
|
async getRecentWallets(): Promise<WcWallet[]> {
|
|
91
86
|
try {
|
|
92
|
-
const recent = await OptionsController.getStorage().getItem(
|
|
93
|
-
ConstantsUtil.STORAGE_KEYS.RECENT_WALLET
|
|
94
|
-
);
|
|
87
|
+
const recent = await OptionsController.getStorage().getItem(SafeStorageKeys.RECENT_WALLET);
|
|
95
88
|
|
|
96
89
|
return recent ?? [];
|
|
97
|
-
} catch {
|
|
98
|
-
|
|
90
|
+
} catch (error) {
|
|
91
|
+
LogController.sendError(error, 'StorageUtil.ts', 'getRecentWallets');
|
|
99
92
|
}
|
|
100
93
|
|
|
101
94
|
return [];
|
|
@@ -114,12 +107,12 @@ export const StorageUtil = {
|
|
|
114
107
|
if (!currentConnectors.some(c => c.type === type)) {
|
|
115
108
|
const updatedConnectors = [...currentConnectors, { type, namespaces }];
|
|
116
109
|
await OptionsController.getStorage().setItem(
|
|
117
|
-
|
|
110
|
+
SafeStorageKeys.CONNECTED_CONNECTORS,
|
|
118
111
|
updatedConnectors
|
|
119
112
|
);
|
|
120
113
|
}
|
|
121
|
-
} catch {
|
|
122
|
-
|
|
114
|
+
} catch (error) {
|
|
115
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setConnectedConnectors');
|
|
123
116
|
}
|
|
124
117
|
},
|
|
125
118
|
|
|
@@ -127,11 +120,11 @@ export const StorageUtil = {
|
|
|
127
120
|
try {
|
|
128
121
|
const connectors = await OptionsController.getStorage().getItem<
|
|
129
122
|
{ type: ConnectorType; namespaces: string[] }[]
|
|
130
|
-
>(
|
|
123
|
+
>(SafeStorageKeys.CONNECTED_CONNECTORS);
|
|
131
124
|
|
|
132
125
|
return connectors ?? [];
|
|
133
126
|
} catch (err) {
|
|
134
|
-
|
|
127
|
+
LogController.sendError(err, 'StorageUtil.ts', 'getConnectedConnectors');
|
|
135
128
|
}
|
|
136
129
|
|
|
137
130
|
return [];
|
|
@@ -142,29 +135,29 @@ export const StorageUtil = {
|
|
|
142
135
|
const currentConnectors = await StorageUtil.getConnectedConnectors();
|
|
143
136
|
const updatedConnectors = currentConnectors.filter(c => c.type !== type);
|
|
144
137
|
await OptionsController.getStorage().setItem(
|
|
145
|
-
|
|
138
|
+
SafeStorageKeys.CONNECTED_CONNECTORS,
|
|
146
139
|
updatedConnectors
|
|
147
140
|
);
|
|
148
|
-
} catch {
|
|
149
|
-
|
|
141
|
+
} catch (error) {
|
|
142
|
+
LogController.sendError(error, 'StorageUtil.ts', 'removeConnectedConnectors');
|
|
150
143
|
}
|
|
151
144
|
},
|
|
152
145
|
|
|
153
146
|
async setOnRampPreferredCountry(country: OnRampCountry) {
|
|
154
147
|
try {
|
|
155
148
|
await OptionsController.getStorage().setItem(
|
|
156
|
-
|
|
149
|
+
SafeStorageKeys.ONRAMP_PREFERRED_COUNTRY,
|
|
157
150
|
country
|
|
158
151
|
);
|
|
159
|
-
} catch {
|
|
160
|
-
|
|
152
|
+
} catch (error) {
|
|
153
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setOnRampPreferredCountry');
|
|
161
154
|
}
|
|
162
155
|
},
|
|
163
156
|
|
|
164
157
|
async getOnRampPreferredCountry() {
|
|
165
158
|
try {
|
|
166
159
|
const country = await OptionsController.getStorage().getItem<OnRampCountry>(
|
|
167
|
-
|
|
160
|
+
SafeStorageKeys.ONRAMP_PREFERRED_COUNTRY
|
|
168
161
|
);
|
|
169
162
|
|
|
170
163
|
return country ?? undefined;
|
|
@@ -178,23 +171,23 @@ export const StorageUtil = {
|
|
|
178
171
|
async setOnRampPreferredFiatCurrency(currency: OnRampFiatCurrency) {
|
|
179
172
|
try {
|
|
180
173
|
await OptionsController.getStorage().setItem(
|
|
181
|
-
|
|
174
|
+
SafeStorageKeys.ONRAMP_PREFERRED_FIAT_CURRENCY,
|
|
182
175
|
currency
|
|
183
176
|
);
|
|
184
|
-
} catch {
|
|
185
|
-
|
|
177
|
+
} catch (error) {
|
|
178
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setOnRampPreferredFiatCurrency');
|
|
186
179
|
}
|
|
187
180
|
},
|
|
188
181
|
|
|
189
182
|
async getOnRampPreferredFiatCurrency() {
|
|
190
183
|
try {
|
|
191
184
|
const currency = await OptionsController.getStorage().getItem<OnRampFiatCurrency>(
|
|
192
|
-
|
|
185
|
+
SafeStorageKeys.ONRAMP_PREFERRED_FIAT_CURRENCY
|
|
193
186
|
);
|
|
194
187
|
|
|
195
188
|
return currency ?? undefined;
|
|
196
|
-
} catch {
|
|
197
|
-
|
|
189
|
+
} catch (error) {
|
|
190
|
+
LogController.sendError(error, 'StorageUtil.ts', 'getOnRampPreferredFiatCurrency');
|
|
198
191
|
}
|
|
199
192
|
|
|
200
193
|
return undefined;
|
|
@@ -202,24 +195,21 @@ export const StorageUtil = {
|
|
|
202
195
|
|
|
203
196
|
async setOnRampCountries(countries: OnRampCountry[]) {
|
|
204
197
|
try {
|
|
205
|
-
await OptionsController.getStorage().setItem(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
);
|
|
209
|
-
} catch {
|
|
210
|
-
console.info('Unable to set OnRamp Countries');
|
|
198
|
+
await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_COUNTRIES, countries);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setOnRampCountries');
|
|
211
201
|
}
|
|
212
202
|
},
|
|
213
203
|
|
|
214
204
|
async getOnRampCountries() {
|
|
215
205
|
try {
|
|
216
206
|
const countries = await OptionsController.getStorage().getItem<OnRampCountry[]>(
|
|
217
|
-
|
|
207
|
+
SafeStorageKeys.ONRAMP_COUNTRIES
|
|
218
208
|
);
|
|
219
209
|
|
|
220
210
|
return countries ?? [];
|
|
221
|
-
} catch {
|
|
222
|
-
|
|
211
|
+
} catch (error) {
|
|
212
|
+
LogController.sendError(error, 'StorageUtil.ts', 'getOnRampCountries');
|
|
223
213
|
}
|
|
224
214
|
|
|
225
215
|
return [];
|
|
@@ -229,19 +219,19 @@ export const StorageUtil = {
|
|
|
229
219
|
try {
|
|
230
220
|
const timestamp = Date.now();
|
|
231
221
|
|
|
232
|
-
await OptionsController.getStorage().setItem(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
);
|
|
236
|
-
} catch {
|
|
237
|
-
|
|
222
|
+
await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_COUNTRIES_DEFAULTS, {
|
|
223
|
+
data: countriesDefaults,
|
|
224
|
+
timestamp
|
|
225
|
+
});
|
|
226
|
+
} catch (error) {
|
|
227
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setOnRampCountriesDefaults');
|
|
238
228
|
}
|
|
239
229
|
},
|
|
240
230
|
|
|
241
231
|
async getOnRampCountriesDefaults() {
|
|
242
232
|
try {
|
|
243
233
|
const result = await OptionsController.getStorage().getItem(
|
|
244
|
-
|
|
234
|
+
SafeStorageKeys.ONRAMP_COUNTRIES_DEFAULTS
|
|
245
235
|
);
|
|
246
236
|
|
|
247
237
|
if (!result) {
|
|
@@ -256,8 +246,8 @@ export const StorageUtil = {
|
|
|
256
246
|
}
|
|
257
247
|
|
|
258
248
|
return (data as OnRampCountryDefaults[]) ?? [];
|
|
259
|
-
} catch {
|
|
260
|
-
|
|
249
|
+
} catch (error) {
|
|
250
|
+
LogController.sendError(error, 'StorageUtil.ts', 'getOnRampCountriesDefaults');
|
|
261
251
|
}
|
|
262
252
|
|
|
263
253
|
return [];
|
|
@@ -267,19 +257,19 @@ export const StorageUtil = {
|
|
|
267
257
|
try {
|
|
268
258
|
const timestamp = Date.now();
|
|
269
259
|
|
|
270
|
-
await OptionsController.getStorage().setItem(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
);
|
|
274
|
-
} catch {
|
|
275
|
-
|
|
260
|
+
await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_SERVICE_PROVIDERS, {
|
|
261
|
+
data: serviceProviders,
|
|
262
|
+
timestamp
|
|
263
|
+
});
|
|
264
|
+
} catch (error) {
|
|
265
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setOnRampServiceProviders');
|
|
276
266
|
}
|
|
277
267
|
},
|
|
278
268
|
|
|
279
269
|
async getOnRampServiceProviders() {
|
|
280
270
|
try {
|
|
281
271
|
const result = await OptionsController.getStorage().getItem(
|
|
282
|
-
|
|
272
|
+
SafeStorageKeys.ONRAMP_SERVICE_PROVIDERS
|
|
283
273
|
);
|
|
284
274
|
|
|
285
275
|
if (!result) {
|
|
@@ -295,8 +285,7 @@ export const StorageUtil = {
|
|
|
295
285
|
|
|
296
286
|
return (data as OnRampServiceProvider[]) ?? [];
|
|
297
287
|
} catch (err) {
|
|
298
|
-
|
|
299
|
-
console.info('Unable to get OnRamp Service Providers');
|
|
288
|
+
LogController.sendError(err, 'StorageUtil.ts', 'getOnRampServiceProviders');
|
|
300
289
|
}
|
|
301
290
|
|
|
302
291
|
return [];
|
|
@@ -306,19 +295,19 @@ export const StorageUtil = {
|
|
|
306
295
|
try {
|
|
307
296
|
const timestamp = Date.now();
|
|
308
297
|
|
|
309
|
-
await OptionsController.getStorage().setItem(
|
|
298
|
+
await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_FIAT_LIMITS, {
|
|
310
299
|
data: fiatLimits,
|
|
311
300
|
timestamp
|
|
312
301
|
});
|
|
313
|
-
} catch {
|
|
314
|
-
|
|
302
|
+
} catch (error) {
|
|
303
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setOnRampFiatLimits');
|
|
315
304
|
}
|
|
316
305
|
},
|
|
317
306
|
|
|
318
307
|
async getOnRampFiatLimits() {
|
|
319
308
|
try {
|
|
320
309
|
const result = await OptionsController.getStorage().getItem(
|
|
321
|
-
|
|
310
|
+
SafeStorageKeys.ONRAMP_FIAT_LIMITS
|
|
322
311
|
);
|
|
323
312
|
|
|
324
313
|
if (!result) {
|
|
@@ -333,8 +322,8 @@ export const StorageUtil = {
|
|
|
333
322
|
}
|
|
334
323
|
|
|
335
324
|
return (data as OnRampFiatLimit[]) ?? [];
|
|
336
|
-
} catch {
|
|
337
|
-
|
|
325
|
+
} catch (error) {
|
|
326
|
+
LogController.sendError(error, 'StorageUtil.ts', 'getOnRampFiatLimits');
|
|
338
327
|
}
|
|
339
328
|
|
|
340
329
|
return [];
|
|
@@ -344,19 +333,19 @@ export const StorageUtil = {
|
|
|
344
333
|
try {
|
|
345
334
|
const timestamp = Date.now();
|
|
346
335
|
|
|
347
|
-
await OptionsController.getStorage().setItem(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
);
|
|
351
|
-
} catch {
|
|
352
|
-
|
|
336
|
+
await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_FIAT_CURRENCIES, {
|
|
337
|
+
data: fiatCurrencies,
|
|
338
|
+
timestamp
|
|
339
|
+
});
|
|
340
|
+
} catch (error) {
|
|
341
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setOnRampFiatCurrencies');
|
|
353
342
|
}
|
|
354
343
|
},
|
|
355
344
|
|
|
356
345
|
async getOnRampFiatCurrencies() {
|
|
357
346
|
try {
|
|
358
347
|
const result = await OptionsController.getStorage().getItem(
|
|
359
|
-
|
|
348
|
+
SafeStorageKeys.ONRAMP_FIAT_CURRENCIES
|
|
360
349
|
);
|
|
361
350
|
|
|
362
351
|
if (!result) {
|
|
@@ -371,8 +360,8 @@ export const StorageUtil = {
|
|
|
371
360
|
}
|
|
372
361
|
|
|
373
362
|
return (data as OnRampFiatCurrency[]) ?? [];
|
|
374
|
-
} catch {
|
|
375
|
-
|
|
363
|
+
} catch (error) {
|
|
364
|
+
LogController.sendError(error, 'StorageUtil.ts', 'getOnRampFiatCurrencies');
|
|
376
365
|
}
|
|
377
366
|
|
|
378
367
|
return [];
|
|
@@ -381,32 +370,26 @@ export const StorageUtil = {
|
|
|
381
370
|
async setActiveNamespace(namespace?: ChainNamespace) {
|
|
382
371
|
try {
|
|
383
372
|
if (!namespace) {
|
|
384
|
-
await OptionsController.getStorage().removeItem(
|
|
385
|
-
ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE
|
|
386
|
-
);
|
|
373
|
+
await OptionsController.getStorage().removeItem(SafeStorageKeys.ACTIVE_NAMESPACE);
|
|
387
374
|
|
|
388
375
|
return;
|
|
389
376
|
}
|
|
390
377
|
|
|
391
|
-
await OptionsController.getStorage().setItem(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
);
|
|
395
|
-
} catch {
|
|
396
|
-
console.info('Unable to set Active Namespace');
|
|
378
|
+
await OptionsController.getStorage().setItem(SafeStorageKeys.ACTIVE_NAMESPACE, namespace);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
LogController.sendError(error, 'StorageUtil.ts', 'setActiveNamespace');
|
|
397
381
|
}
|
|
398
382
|
},
|
|
399
383
|
|
|
400
384
|
async getActiveNamespace() {
|
|
401
385
|
try {
|
|
402
386
|
const namespace = (await OptionsController.getStorage().getItem(
|
|
403
|
-
|
|
387
|
+
SafeStorageKeys.ACTIVE_NAMESPACE
|
|
404
388
|
)) as ChainNamespace;
|
|
405
389
|
|
|
406
390
|
return namespace ?? undefined;
|
|
407
391
|
} catch (err) {
|
|
408
|
-
|
|
409
|
-
console.info('Unable to get Active Namespace');
|
|
392
|
+
LogController.sendError(err, 'StorageUtil.ts', 'getActiveNamespace');
|
|
410
393
|
}
|
|
411
394
|
|
|
412
395
|
return undefined;
|
|
@@ -414,9 +397,9 @@ export const StorageUtil = {
|
|
|
414
397
|
|
|
415
398
|
async removeActiveNamespace() {
|
|
416
399
|
try {
|
|
417
|
-
await OptionsController.getStorage().removeItem(
|
|
418
|
-
} catch {
|
|
419
|
-
|
|
400
|
+
await OptionsController.getStorage().removeItem(SafeStorageKeys.ACTIVE_NAMESPACE);
|
|
401
|
+
} catch (error) {
|
|
402
|
+
LogController.sendError(error, 'StorageUtil.ts', 'removeActiveNamespace');
|
|
420
403
|
}
|
|
421
404
|
}
|
|
422
405
|
};
|