@reown/appkit-core-react-native 0.0.0-chore-spring-effect-20250909214820 → 0.0.0-chore-added-import-20251002170458

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.
Files changed (149) hide show
  1. package/lib/commonjs/controllers/ApiController.js +19 -8
  2. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  3. package/lib/commonjs/controllers/BlockchainApiController.js +31 -28
  4. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  5. package/lib/commonjs/controllers/ConnectionsController.js +13 -3
  6. package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
  7. package/lib/commonjs/controllers/EnsController.js +2 -0
  8. package/lib/commonjs/controllers/EnsController.js.map +1 -1
  9. package/lib/commonjs/controllers/EventsController.js +1 -0
  10. package/lib/commonjs/controllers/EventsController.js.map +1 -1
  11. package/lib/commonjs/controllers/LogController.js +194 -0
  12. package/lib/commonjs/controllers/LogController.js.map +1 -0
  13. package/lib/commonjs/controllers/OnRampController.js +14 -0
  14. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  15. package/lib/commonjs/controllers/OptionsController.js +6 -3
  16. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  17. package/lib/commonjs/controllers/SendController.js +18 -2
  18. package/lib/commonjs/controllers/SendController.js.map +1 -1
  19. package/lib/commonjs/controllers/SwapController.js +10 -2
  20. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  21. package/lib/commonjs/controllers/ThemeController.js +5 -0
  22. package/lib/commonjs/controllers/ThemeController.js.map +1 -1
  23. package/lib/commonjs/controllers/TransactionsController.js +2 -0
  24. package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
  25. package/lib/commonjs/features/reown-authentication/ReownAuthentication.js +272 -0
  26. package/lib/commonjs/features/reown-authentication/ReownAuthentication.js.map +1 -0
  27. package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js +48 -0
  28. package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
  29. package/lib/commonjs/features/reown-authentication/index.js +28 -0
  30. package/lib/commonjs/features/reown-authentication/index.js.map +1 -0
  31. package/lib/commonjs/index.js +28 -0
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/utils/ApiUtil.js +1 -1
  34. package/lib/commonjs/utils/ApiUtil.js.map +1 -1
  35. package/lib/commonjs/utils/ConstantsUtil.js +0 -1
  36. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  37. package/lib/commonjs/utils/CoreHelperUtil.js +13 -2
  38. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  39. package/lib/commonjs/utils/FetchUtil.js +7 -2
  40. package/lib/commonjs/utils/FetchUtil.js.map +1 -1
  41. package/lib/commonjs/utils/LogUtils.js +131 -0
  42. package/lib/commonjs/utils/LogUtils.js.map +1 -0
  43. package/lib/commonjs/utils/StorageUtil.js +75 -76
  44. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  45. package/lib/module/controllers/ApiController.js +19 -8
  46. package/lib/module/controllers/ApiController.js.map +1 -1
  47. package/lib/module/controllers/BlockchainApiController.js +31 -28
  48. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  49. package/lib/module/controllers/ConnectionsController.js +14 -4
  50. package/lib/module/controllers/ConnectionsController.js.map +1 -1
  51. package/lib/module/controllers/EnsController.js +2 -0
  52. package/lib/module/controllers/EnsController.js.map +1 -1
  53. package/lib/module/controllers/EventsController.js +1 -0
  54. package/lib/module/controllers/EventsController.js.map +1 -1
  55. package/lib/module/controllers/LogController.js +191 -0
  56. package/lib/module/controllers/LogController.js.map +1 -0
  57. package/lib/module/controllers/OnRampController.js +14 -0
  58. package/lib/module/controllers/OnRampController.js.map +1 -1
  59. package/lib/module/controllers/OptionsController.js +6 -3
  60. package/lib/module/controllers/OptionsController.js.map +1 -1
  61. package/lib/module/controllers/SendController.js +18 -2
  62. package/lib/module/controllers/SendController.js.map +1 -1
  63. package/lib/module/controllers/SwapController.js +10 -2
  64. package/lib/module/controllers/SwapController.js.map +1 -1
  65. package/lib/module/controllers/ThemeController.js +5 -0
  66. package/lib/module/controllers/ThemeController.js.map +1 -1
  67. package/lib/module/controllers/TransactionsController.js +2 -0
  68. package/lib/module/controllers/TransactionsController.js.map +1 -1
  69. package/lib/module/features/reown-authentication/ReownAuthentication.js +268 -0
  70. package/lib/module/features/reown-authentication/ReownAuthentication.js.map +1 -0
  71. package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js +43 -0
  72. package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
  73. package/lib/module/features/reown-authentication/index.js +5 -0
  74. package/lib/module/features/reown-authentication/index.js.map +1 -0
  75. package/lib/module/index.js +6 -0
  76. package/lib/module/index.js.map +1 -1
  77. package/lib/module/utils/ApiUtil.js +1 -1
  78. package/lib/module/utils/ApiUtil.js.map +1 -1
  79. package/lib/module/utils/ConstantsUtil.js +0 -1
  80. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  81. package/lib/module/utils/CoreHelperUtil.js +13 -2
  82. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  83. package/lib/module/utils/FetchUtil.js +8 -2
  84. package/lib/module/utils/FetchUtil.js.map +1 -1
  85. package/lib/module/utils/LogUtils.js +121 -0
  86. package/lib/module/utils/LogUtils.js.map +1 -0
  87. package/lib/module/utils/StorageUtil.js +76 -77
  88. package/lib/module/utils/StorageUtil.js.map +1 -1
  89. package/lib/typescript/controllers/ApiController.d.ts +6 -4
  90. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  91. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  92. package/lib/typescript/controllers/ConnectionsController.d.ts +1 -0
  93. package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
  94. package/lib/typescript/controllers/EnsController.d.ts.map +1 -1
  95. package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
  96. package/lib/typescript/controllers/LogController.d.ts +69 -0
  97. package/lib/typescript/controllers/LogController.d.ts.map +1 -0
  98. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  99. package/lib/typescript/controllers/OptionsController.d.ts +3 -3
  100. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  101. package/lib/typescript/controllers/RouterController.d.ts +1 -1
  102. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  103. package/lib/typescript/controllers/SendController.d.ts.map +1 -1
  104. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  105. package/lib/typescript/controllers/ThemeController.d.ts +2 -0
  106. package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
  107. package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
  108. package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts +174 -0
  109. package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts.map +1 -0
  110. package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts +16 -0
  111. package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts.map +1 -0
  112. package/lib/typescript/features/reown-authentication/index.d.ts +3 -0
  113. package/lib/typescript/features/reown-authentication/index.d.ts.map +1 -0
  114. package/lib/typescript/index.d.ts +4 -0
  115. package/lib/typescript/index.d.ts.map +1 -1
  116. package/lib/typescript/utils/ApiUtil.d.ts +1 -1
  117. package/lib/typescript/utils/ConstantsUtil.d.ts +0 -1
  118. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  119. package/lib/typescript/utils/CoreHelperUtil.d.ts +3 -2
  120. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  121. package/lib/typescript/utils/FetchUtil.d.ts +2 -2
  122. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  123. package/lib/typescript/utils/LogUtils.d.ts +15 -0
  124. package/lib/typescript/utils/LogUtils.d.ts.map +1 -0
  125. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  126. package/package.json +6 -5
  127. package/src/controllers/ApiController.ts +28 -8
  128. package/src/controllers/BlockchainApiController.ts +39 -29
  129. package/src/controllers/ConnectionsController.ts +27 -3
  130. package/src/controllers/EnsController.ts +2 -0
  131. package/src/controllers/EventsController.ts +1 -0
  132. package/src/controllers/LogController.ts +258 -0
  133. package/src/controllers/OnRampController.ts +12 -0
  134. package/src/controllers/OptionsController.ts +11 -6
  135. package/src/controllers/RouterController.ts +3 -3
  136. package/src/controllers/SendController.ts +28 -3
  137. package/src/controllers/SwapController.ts +10 -2
  138. package/src/controllers/ThemeController.ts +7 -0
  139. package/src/controllers/TransactionsController.ts +2 -0
  140. package/src/features/reown-authentication/ReownAuthentication.ts +475 -0
  141. package/src/features/reown-authentication/ReownAuthenticationMessenger.ts +80 -0
  142. package/src/features/reown-authentication/index.ts +2 -0
  143. package/src/index.ts +12 -0
  144. package/src/utils/ApiUtil.ts +1 -1
  145. package/src/utils/ConstantsUtil.ts +0 -1
  146. package/src/utils/CoreHelperUtil.ts +21 -3
  147. package/src/utils/FetchUtil.ts +12 -3
  148. package/src/utils/LogUtils.ts +179 -0
  149. 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
+ };
@@ -10,33 +10,34 @@ import {
10
10
  type ConnectorType,
11
11
  type ChainNamespace,
12
12
  type WalletDeepLink,
13
- ConstantsUtil
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(ConstantsUtil.STORAGE_KEYS.WC_DEEPLINK, {
22
+ OptionsController.getStorage().setItem(SafeStorageKeys.WC_DEEPLINK, {
22
23
  href,
23
24
  name
24
25
  });
25
- } catch {
26
- console.info('Unable to set WalletConnect deep link');
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
- ConstantsUtil.STORAGE_KEYS.WC_DEEPLINK
34
+ SafeStorageKeys.WC_DEEPLINK
34
35
  );
35
36
  if (deepLink) {
36
37
  return deepLink;
37
38
  }
38
- } catch {
39
- console.info('Unable to get WalletConnect deep link');
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(ConstantsUtil.STORAGE_KEYS.WC_DEEPLINK);
48
- } catch {
49
- console.info('Unable to remove WalletConnect deep link');
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
- console.info('Unable to set recent wallet');
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
- ConstantsUtil.STORAGE_KEYS.RECENT_WALLET,
83
- wallets
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
- console.info('Unable to get recent wallets');
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
- ConstantsUtil.STORAGE_KEYS.CONNECTED_CONNECTORS,
110
+ SafeStorageKeys.CONNECTED_CONNECTORS,
118
111
  updatedConnectors
119
112
  );
120
113
  }
121
- } catch {
122
- console.info('Unable to set Connected Connector');
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
- >(ConstantsUtil.STORAGE_KEYS.CONNECTED_CONNECTORS);
123
+ >(SafeStorageKeys.CONNECTED_CONNECTORS);
131
124
 
132
125
  return connectors ?? [];
133
126
  } catch (err) {
134
- console.info('Unable to get Connected Connector');
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
- ConstantsUtil.STORAGE_KEYS.CONNECTED_CONNECTORS,
138
+ SafeStorageKeys.CONNECTED_CONNECTORS,
146
139
  updatedConnectors
147
140
  );
148
- } catch {
149
- console.info('Unable to remove Connected Connector');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_COUNTRY,
149
+ SafeStorageKeys.ONRAMP_PREFERRED_COUNTRY,
157
150
  country
158
151
  );
159
- } catch {
160
- console.info('Unable to set OnRamp Preferred Country');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_COUNTRY
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_FIAT_CURRENCY,
174
+ SafeStorageKeys.ONRAMP_PREFERRED_FIAT_CURRENCY,
182
175
  currency
183
176
  );
184
- } catch {
185
- console.info('Unable to set OnRamp Preferred Fiat Currency');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_FIAT_CURRENCY
185
+ SafeStorageKeys.ONRAMP_PREFERRED_FIAT_CURRENCY
193
186
  );
194
187
 
195
188
  return currency ?? undefined;
196
- } catch {
197
- console.info('Unable to get OnRamp Preferred Fiat Currency');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES,
207
- countries
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES
207
+ SafeStorageKeys.ONRAMP_COUNTRIES
218
208
  );
219
209
 
220
210
  return countries ?? [];
221
- } catch {
222
- console.info('Unable to get OnRamp Countries');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES_DEFAULTS,
234
- { data: countriesDefaults, timestamp }
235
- );
236
- } catch {
237
- console.info('Unable to set OnRamp Countries Defaults');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES_DEFAULTS
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
- console.info('Unable to get OnRamp Countries Defaults');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_SERVICE_PROVIDERS,
272
- { data: serviceProviders, timestamp }
273
- );
274
- } catch {
275
- console.info('Unable to set OnRamp Service Providers');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_SERVICE_PROVIDERS
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
- console.error(err);
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(ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_LIMITS, {
298
+ await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_FIAT_LIMITS, {
310
299
  data: fiatLimits,
311
300
  timestamp
312
301
  });
313
- } catch {
314
- console.info('Unable to set OnRamp Fiat Limits');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_LIMITS
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
- console.info('Unable to get OnRamp Fiat Limits');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_CURRENCIES,
349
- { data: fiatCurrencies, timestamp }
350
- );
351
- } catch {
352
- console.info('Unable to set OnRamp Fiat Currencies');
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
- ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_CURRENCIES
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
- console.info('Unable to get OnRamp Fiat Currencies');
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
- ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE,
393
- namespace
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
- ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE
387
+ SafeStorageKeys.ACTIVE_NAMESPACE
404
388
  )) as ChainNamespace;
405
389
 
406
390
  return namespace ?? undefined;
407
391
  } catch (err) {
408
- console.error(err);
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(ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE);
418
- } catch {
419
- console.info('Unable to remove Active Namespace');
400
+ await OptionsController.getStorage().removeItem(SafeStorageKeys.ACTIVE_NAMESPACE);
401
+ } catch (error) {
402
+ LogController.sendError(error, 'StorageUtil.ts', 'removeActiveNamespace');
420
403
  }
421
404
  }
422
405
  };