@reown/appkit-core-react-native 0.0.0-feat-multichain-20250925184834 → 0.0.0-feat-multichain-20250930155416
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 +5 -0
- 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 +1 -0
- package/lib/commonjs/controllers/EventsController.js.map +1 -1
- package/lib/commonjs/controllers/LogController.js +189 -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/SendController.js +2 -0
- package/lib/commonjs/controllers/SendController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +8 -0
- package/lib/commonjs/controllers/SwapController.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 +14 -6
- package/lib/commonjs/features/reown-authentication/ReownAuthentication.js.map +1 -1
- package/lib/commonjs/index.js +14 -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/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 +48 -49
- 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 +5 -0
- 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 +1 -0
- package/lib/module/controllers/EventsController.js.map +1 -1
- package/lib/module/controllers/LogController.js +186 -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/SendController.js +2 -0
- package/lib/module/controllers/SendController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +8 -0
- package/lib/module/controllers/SwapController.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 +14 -6
- package/lib/module/features/reown-authentication/ReownAuthentication.js.map +1 -1
- package/lib/module/index.js +2 -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/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 +48 -49
- 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.map +1 -1
- package/lib/typescript/controllers/EnsController.d.ts.map +1 -1
- package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
- package/lib/typescript/controllers/LogController.d.ts +69 -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/SendController.d.ts.map +1 -1
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
- package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
- package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/ApiUtil.d.ts +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts +1 -1
- 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 +3 -3
- package/src/controllers/ApiController.ts +28 -8
- package/src/controllers/BlockchainApiController.ts +39 -29
- package/src/controllers/ConnectionsController.ts +5 -0
- package/src/controllers/EnsController.ts +2 -0
- package/src/controllers/EventsController.ts +1 -0
- package/src/controllers/LogController.ts +253 -0
- package/src/controllers/OnRampController.ts +12 -0
- package/src/controllers/SendController.ts +2 -0
- package/src/controllers/SwapController.ts +8 -0
- package/src/controllers/TransactionsController.ts +2 -0
- package/src/features/reown-authentication/ReownAuthentication.ts +11 -6
- package/src/index.ts +8 -0
- package/src/utils/ApiUtil.ts +1 -1
- package/src/utils/CoreHelperUtil.ts +1 -1
- package/src/utils/FetchUtil.ts +11 -2
- package/src/utils/LogUtils.ts +179 -0
- package/src/utils/StorageUtil.ts +48 -49
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/StorageUtil.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EAEb,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"StorageUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/StorageUtil.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EAEb,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,mCAAmC,CAAC;AAK3C,eAAO,MAAM,WAAW;6CACmB,cAAc;;;4BAkCzB,QAAQ;8BAuBN,QAAQ,EAAE;wBAQhB,QAAQ,QAAQ,EAAE,CAAC;;cAgBrC,aAAa;oBACP,MAAM,EAAE;;8BAiBU,QAAQ;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;oCAclD,aAAa;uCAaV,aAAa;;6CAyBP,kBAAkB;;kCAyB7B,aAAa,EAAE;;kDAsBC,qBAAqB,EAAE;;gDAsCzB,qBAAqB,EAAE;;oCAsCnC,eAAe,EAAE;;4CAsCT,kBAAkB,EAAE;;mCAsC7B,cAAc;;;CAmCpD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-core-react-native",
|
|
3
|
-
"version": "0.0.0-feat-multichain-
|
|
3
|
+
"version": "0.0.0-feat-multichain-20250930155416",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"types": "lib/typescript/index.d.ts",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"provenance": true
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@reown/appkit-common-react-native": "0.0.0-feat-multichain-
|
|
43
|
+
"@reown/appkit-common-react-native": "0.0.0-feat-multichain-20250930155416",
|
|
44
44
|
"countries-and-timezones": "3.7.2",
|
|
45
45
|
"derive-valtio": "0.2.0",
|
|
46
|
-
"valtio": "2.1.
|
|
46
|
+
"valtio": "2.1.8"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@walletconnect/react-native-compat": ">=2.16.1",
|
|
@@ -19,6 +19,7 @@ import { WcController } from './WcController';
|
|
|
19
19
|
import { ApiUtil } from '../utils/ApiUtil';
|
|
20
20
|
import { SnackController } from './SnackController';
|
|
21
21
|
import { ConnectionsController } from './ConnectionsController';
|
|
22
|
+
import { LogController } from './LogController';
|
|
22
23
|
|
|
23
24
|
// -- Helpers ------------------------------------------- //
|
|
24
25
|
const baseUrl = CoreHelperUtil.getApiUrl();
|
|
@@ -65,13 +66,18 @@ export const ApiController = {
|
|
|
65
66
|
return subKey(state, key, callback);
|
|
66
67
|
},
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
_getApiParams() {
|
|
69
70
|
const { projectId, sdkType, sdkVersion } = OptionsController.state;
|
|
70
71
|
|
|
71
72
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
projectId,
|
|
74
|
+
st: sdkType,
|
|
75
|
+
sv: sdkVersion
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
_getApiHeaders() {
|
|
80
|
+
return {
|
|
75
81
|
'User-Agent': ApiUtil.getUserAgent(),
|
|
76
82
|
'origin': ApiUtil.getOrigin()
|
|
77
83
|
};
|
|
@@ -79,7 +85,11 @@ export const ApiController = {
|
|
|
79
85
|
|
|
80
86
|
async _fetchWalletImage(imageId: string) {
|
|
81
87
|
const headers = ApiController._getApiHeaders();
|
|
82
|
-
const url = await api.fetchImage(
|
|
88
|
+
const url = await api.fetchImage(
|
|
89
|
+
`/getWalletImage/${imageId}`,
|
|
90
|
+
headers,
|
|
91
|
+
ApiController._getApiParams()
|
|
92
|
+
);
|
|
83
93
|
if (url) {
|
|
84
94
|
AssetController.setWalletImage(imageId, url);
|
|
85
95
|
}
|
|
@@ -92,7 +102,11 @@ export const ApiController = {
|
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
const headers = ApiController._getApiHeaders();
|
|
95
|
-
const url = await api.fetchImage(
|
|
105
|
+
const url = await api.fetchImage(
|
|
106
|
+
`/public/getAssetImage/${imageId}`,
|
|
107
|
+
headers,
|
|
108
|
+
ApiController._getApiParams()
|
|
109
|
+
);
|
|
96
110
|
if (url) {
|
|
97
111
|
AssetController.setNetworkImage(networkId, url);
|
|
98
112
|
}
|
|
@@ -117,6 +131,7 @@ export const ApiController = {
|
|
|
117
131
|
const path = Platform.select({ default: 'getIosData', android: 'getAndroidData' });
|
|
118
132
|
const response = await api.get<ApiGetDataWalletsResponse>({
|
|
119
133
|
path,
|
|
134
|
+
params: ApiController._getApiParams(),
|
|
120
135
|
headers: ApiController._getApiHeaders()
|
|
121
136
|
});
|
|
122
137
|
|
|
@@ -157,6 +172,7 @@ export const ApiController = {
|
|
|
157
172
|
path: '/getWallets',
|
|
158
173
|
headers: ApiController._getApiHeaders(),
|
|
159
174
|
params: {
|
|
175
|
+
...ApiController._getApiParams(),
|
|
160
176
|
page: '1',
|
|
161
177
|
platform: this.platform(),
|
|
162
178
|
entries: installed?.length.toString(),
|
|
@@ -204,8 +220,7 @@ export const ApiController = {
|
|
|
204
220
|
} catch (error) {
|
|
205
221
|
state.installed = [];
|
|
206
222
|
clearTimeout(timeoutId);
|
|
207
|
-
|
|
208
|
-
console.log('Error fetching installed wallets', error);
|
|
223
|
+
LogController.sendError(error, 'ApiController.ts', 'fetchInstalledWallets');
|
|
209
224
|
}
|
|
210
225
|
},
|
|
211
226
|
|
|
@@ -219,6 +234,7 @@ export const ApiController = {
|
|
|
219
234
|
path: '/getWallets',
|
|
220
235
|
headers: ApiController._getApiHeaders(),
|
|
221
236
|
params: {
|
|
237
|
+
...ApiController._getApiParams(),
|
|
222
238
|
page: '1',
|
|
223
239
|
platform: this.platform(),
|
|
224
240
|
entries: featuredWalletIds?.length
|
|
@@ -270,6 +286,7 @@ export const ApiController = {
|
|
|
270
286
|
path: '/getWallets',
|
|
271
287
|
headers: ApiController._getApiHeaders(),
|
|
272
288
|
params: {
|
|
289
|
+
...ApiController._getApiParams(),
|
|
273
290
|
page: '1',
|
|
274
291
|
platform: this.platform(),
|
|
275
292
|
entries: recommendedEntries,
|
|
@@ -309,6 +326,7 @@ export const ApiController = {
|
|
|
309
326
|
path: '/getWallets',
|
|
310
327
|
headers: ApiController._getApiHeaders(),
|
|
311
328
|
params: {
|
|
329
|
+
...ApiController._getApiParams(),
|
|
312
330
|
page: String(page),
|
|
313
331
|
platform: this.platform(),
|
|
314
332
|
entries: String(defaultEntries),
|
|
@@ -343,6 +361,7 @@ export const ApiController = {
|
|
|
343
361
|
path: '/getWallets',
|
|
344
362
|
headers: ApiController._getApiHeaders(),
|
|
345
363
|
params: {
|
|
364
|
+
...ApiController._getApiParams(),
|
|
346
365
|
page: '1',
|
|
347
366
|
platform: this.platform(),
|
|
348
367
|
entries: String(defaultEntries),
|
|
@@ -426,6 +445,7 @@ export const ApiController = {
|
|
|
426
445
|
async fetchAnalyticsConfig() {
|
|
427
446
|
const response = await api.get<ApiGetAnalyticsConfigResponse>({
|
|
428
447
|
path: '/getAnalyticsConfig',
|
|
448
|
+
params: ApiController._getApiParams(),
|
|
429
449
|
headers: ApiController._getApiHeaders()
|
|
430
450
|
});
|
|
431
451
|
if (!response) return;
|
|
@@ -42,17 +42,24 @@ import { ConstantsUtil } from '../utils/ConstantsUtil';
|
|
|
42
42
|
import { ApiUtil } from '../utils/ApiUtil';
|
|
43
43
|
|
|
44
44
|
import { SnackController } from './SnackController';
|
|
45
|
+
import { LogController } from './LogController';
|
|
45
46
|
|
|
46
47
|
// -- Helpers ------------------------------------------- //
|
|
47
48
|
const baseUrl = CoreHelperUtil.getBlockchainApiUrl();
|
|
48
49
|
|
|
49
|
-
const
|
|
50
|
-
const { sdkType, sdkVersion } = OptionsController.state;
|
|
50
|
+
const getParams = () => {
|
|
51
|
+
const { projectId, sdkType, sdkVersion } = OptionsController.state;
|
|
51
52
|
|
|
53
|
+
return {
|
|
54
|
+
projectId,
|
|
55
|
+
st: sdkType,
|
|
56
|
+
sv: sdkVersion
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const getHeaders = () => {
|
|
52
61
|
return {
|
|
53
62
|
'Content-Type': 'application/json',
|
|
54
|
-
'x-sdk-type': sdkType,
|
|
55
|
-
'x-sdk-version': sdkVersion,
|
|
56
63
|
'User-Agent': ApiUtil.getUserAgent(),
|
|
57
64
|
'origin': ApiUtil.getOrigin()
|
|
58
65
|
};
|
|
@@ -89,6 +96,8 @@ export const BlockchainApiController = {
|
|
|
89
96
|
await BlockchainApiController.getSupportedNetworks();
|
|
90
97
|
}
|
|
91
98
|
} catch (e) {
|
|
99
|
+
LogController.sendError(e, 'BlockchainApiController.ts', 'isNetworkSupported');
|
|
100
|
+
|
|
92
101
|
return false;
|
|
93
102
|
}
|
|
94
103
|
|
|
@@ -97,7 +106,8 @@ export const BlockchainApiController = {
|
|
|
97
106
|
|
|
98
107
|
async getSupportedNetworks() {
|
|
99
108
|
const supportedChains = await state.api.get<BlockchainApiControllerState['supportedChains']>({
|
|
100
|
-
path: 'v1/supported-chains'
|
|
109
|
+
path: 'v1/supported-chains',
|
|
110
|
+
params: getParams()
|
|
101
111
|
});
|
|
102
112
|
|
|
103
113
|
state.supportedChains = supportedChains!;
|
|
@@ -110,15 +120,13 @@ export const BlockchainApiController = {
|
|
|
110
120
|
|
|
111
121
|
return state.api.get<BlockchainApiIdentityResponse>({
|
|
112
122
|
path: `/v1/identity/${address}`,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
headers: getHeaders()
|
|
123
|
+
headers: getHeaders(),
|
|
124
|
+
params: getParams()
|
|
117
125
|
});
|
|
118
126
|
},
|
|
119
127
|
|
|
120
128
|
async fetchTransactions(params: BlockchainApiTransactionsRequest) {
|
|
121
|
-
const { account,
|
|
129
|
+
const { account, cursor, signal, cache, chainId } = params;
|
|
122
130
|
const isSupported = ConstantsUtil.ACTIVITY_SUPPORTED_CHAINS.includes(chainId);
|
|
123
131
|
|
|
124
132
|
if (!isSupported) {
|
|
@@ -129,7 +137,7 @@ export const BlockchainApiController = {
|
|
|
129
137
|
path: `/v1/account/${account}/history`,
|
|
130
138
|
headers: getHeaders(),
|
|
131
139
|
params: {
|
|
132
|
-
|
|
140
|
+
...getParams(),
|
|
133
141
|
cursor,
|
|
134
142
|
chainId
|
|
135
143
|
},
|
|
@@ -150,19 +158,20 @@ export const BlockchainApiController = {
|
|
|
150
158
|
|
|
151
159
|
const response = await state.api.post<BlockchainApiTokenPriceResponse>({
|
|
152
160
|
path: '/v1/fungible/price',
|
|
161
|
+
headers: getHeaders(),
|
|
162
|
+
params: getParams(),
|
|
153
163
|
body: {
|
|
154
164
|
projectId,
|
|
155
165
|
currency: 'usd',
|
|
156
166
|
addresses
|
|
157
|
-
}
|
|
158
|
-
headers: getHeaders()
|
|
167
|
+
}
|
|
159
168
|
});
|
|
160
169
|
|
|
161
170
|
return response;
|
|
162
171
|
},
|
|
163
172
|
|
|
164
173
|
async fetchSwapAllowance(params: BlockchainApiSwapAllowanceRequest) {
|
|
165
|
-
const {
|
|
174
|
+
const { tokenAddress, userAddress } = params;
|
|
166
175
|
const [namespace, chain] = userAddress.split(':');
|
|
167
176
|
const networkId: CaipNetworkId = `${namespace}:${chain}`;
|
|
168
177
|
const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
|
|
@@ -174,7 +183,7 @@ export const BlockchainApiController = {
|
|
|
174
183
|
return state.api.get<BlockchainApiSwapAllowanceResponse>({
|
|
175
184
|
path: `/v1/convert/allowance`,
|
|
176
185
|
params: {
|
|
177
|
-
|
|
186
|
+
...getParams(),
|
|
178
187
|
tokenAddress,
|
|
179
188
|
userAddress
|
|
180
189
|
},
|
|
@@ -183,7 +192,7 @@ export const BlockchainApiController = {
|
|
|
183
192
|
},
|
|
184
193
|
|
|
185
194
|
async fetchGasPrice(params: BlockchainApiGasPriceRequest) {
|
|
186
|
-
const {
|
|
195
|
+
const { chainId } = params;
|
|
187
196
|
const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
|
|
188
197
|
|
|
189
198
|
if (!isSupported) {
|
|
@@ -194,14 +203,14 @@ export const BlockchainApiController = {
|
|
|
194
203
|
path: `/v1/convert/gas-price`,
|
|
195
204
|
headers: getHeaders(),
|
|
196
205
|
params: {
|
|
197
|
-
|
|
206
|
+
...getParams(),
|
|
198
207
|
chainId
|
|
199
208
|
}
|
|
200
209
|
});
|
|
201
210
|
},
|
|
202
211
|
|
|
203
212
|
async fetchSwapQuote(params: BlockchainApiSwapQuoteRequest) {
|
|
204
|
-
const {
|
|
213
|
+
const { amount, userAddress, from, to, gasPrice } = params;
|
|
205
214
|
const [namespace, chain] = userAddress.split(':');
|
|
206
215
|
const networkId: CaipNetworkId = `${namespace}:${chain}`;
|
|
207
216
|
const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
|
|
@@ -214,7 +223,7 @@ export const BlockchainApiController = {
|
|
|
214
223
|
path: `/v1/convert/quotes`,
|
|
215
224
|
headers: getHeaders(),
|
|
216
225
|
params: {
|
|
217
|
-
|
|
226
|
+
...getParams(),
|
|
218
227
|
amount,
|
|
219
228
|
userAddress,
|
|
220
229
|
from,
|
|
@@ -225,7 +234,7 @@ export const BlockchainApiController = {
|
|
|
225
234
|
},
|
|
226
235
|
|
|
227
236
|
async fetchSwapTokens(params: BlockchainApiSwapTokensRequest) {
|
|
228
|
-
const {
|
|
237
|
+
const { chainId } = params;
|
|
229
238
|
const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
|
|
230
239
|
|
|
231
240
|
if (!isSupported) {
|
|
@@ -236,7 +245,7 @@ export const BlockchainApiController = {
|
|
|
236
245
|
path: `/v1/convert/tokens`,
|
|
237
246
|
headers: getHeaders(),
|
|
238
247
|
params: {
|
|
239
|
-
|
|
248
|
+
...getParams(),
|
|
240
249
|
chainId
|
|
241
250
|
}
|
|
242
251
|
});
|
|
@@ -255,6 +264,7 @@ export const BlockchainApiController = {
|
|
|
255
264
|
return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
|
|
256
265
|
path: '/v1/convert/build-transaction',
|
|
257
266
|
headers: getHeaders(),
|
|
267
|
+
params: getParams(),
|
|
258
268
|
body: {
|
|
259
269
|
amount,
|
|
260
270
|
eip155: {
|
|
@@ -269,7 +279,7 @@ export const BlockchainApiController = {
|
|
|
269
279
|
},
|
|
270
280
|
|
|
271
281
|
async generateApproveCalldata(params: BlockchainApiGenerateApproveCalldataRequest) {
|
|
272
|
-
const { from,
|
|
282
|
+
const { from, to, userAddress } = params;
|
|
273
283
|
const [namespace, chain] = userAddress.split(':');
|
|
274
284
|
const networkId: CaipNetworkId = `${namespace}:${chain}`;
|
|
275
285
|
const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
|
|
@@ -282,7 +292,7 @@ export const BlockchainApiController = {
|
|
|
282
292
|
path: `/v1/convert/build-approve`,
|
|
283
293
|
headers: getHeaders(),
|
|
284
294
|
params: {
|
|
285
|
-
|
|
295
|
+
...getParams(),
|
|
286
296
|
userAddress,
|
|
287
297
|
from,
|
|
288
298
|
to
|
|
@@ -309,8 +319,8 @@ export const BlockchainApiController = {
|
|
|
309
319
|
path: `/v1/account/${plainAddress}/balance`,
|
|
310
320
|
headers: getHeaders(),
|
|
311
321
|
params: {
|
|
322
|
+
...getParams(),
|
|
312
323
|
currency: 'usd',
|
|
313
|
-
projectId: OptionsController.state.projectId,
|
|
314
324
|
chainId: `${namespace}:${chain}`,
|
|
315
325
|
forceUpdate: forceUpdate?.join(',')
|
|
316
326
|
}
|
|
@@ -322,7 +332,7 @@ export const BlockchainApiController = {
|
|
|
322
332
|
path: `/v1/profile/account/${name}`,
|
|
323
333
|
headers: getHeaders(),
|
|
324
334
|
params: {
|
|
325
|
-
|
|
335
|
+
...getParams(),
|
|
326
336
|
apiVersion: '2'
|
|
327
337
|
}
|
|
328
338
|
});
|
|
@@ -332,9 +342,7 @@ export const BlockchainApiController = {
|
|
|
332
342
|
return await state.api.get<OnRampServiceProvider[]>({
|
|
333
343
|
path: '/v1/onramp/providers',
|
|
334
344
|
headers: getHeaders(),
|
|
335
|
-
params:
|
|
336
|
-
projectId: OptionsController.state.projectId
|
|
337
|
-
}
|
|
345
|
+
params: getParams()
|
|
338
346
|
});
|
|
339
347
|
},
|
|
340
348
|
|
|
@@ -367,7 +375,7 @@ export const BlockchainApiController = {
|
|
|
367
375
|
path: '/v1/onramp/providers/properties',
|
|
368
376
|
headers: getHeaders(),
|
|
369
377
|
params: {
|
|
370
|
-
|
|
378
|
+
...getParams(),
|
|
371
379
|
type,
|
|
372
380
|
excludeProviders: EXCLUDED_ONRAMP_PROVIDERS.join(','),
|
|
373
381
|
...params
|
|
@@ -379,6 +387,7 @@ export const BlockchainApiController = {
|
|
|
379
387
|
return await state.api.post<OnRampQuote[]>({
|
|
380
388
|
path: '/v1/onramp/multi/quotes',
|
|
381
389
|
headers: getHeaders(),
|
|
390
|
+
params: getParams(),
|
|
382
391
|
body: {
|
|
383
392
|
projectId: OptionsController.state.projectId,
|
|
384
393
|
...body
|
|
@@ -391,6 +400,7 @@ export const BlockchainApiController = {
|
|
|
391
400
|
return await state.api.post<BlockchainApiOnRampWidgetResponse>({
|
|
392
401
|
path: '/v1/onramp/widget',
|
|
393
402
|
headers: getHeaders(),
|
|
403
|
+
params: getParams(),
|
|
394
404
|
body: {
|
|
395
405
|
projectId: OptionsController.state.projectId,
|
|
396
406
|
sessionData: {
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { StorageUtil } from '../utils/StorageUtil';
|
|
20
20
|
import { BlockchainApiController } from './BlockchainApiController';
|
|
21
21
|
import { SnackController } from './SnackController';
|
|
22
|
+
import { LogController } from './LogController';
|
|
22
23
|
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
23
24
|
|
|
24
25
|
// -- Types --------------------------------------------- //
|
|
@@ -531,6 +532,10 @@ export const ConnectionsController = {
|
|
|
531
532
|
});
|
|
532
533
|
});
|
|
533
534
|
} catch (error) {
|
|
535
|
+
LogController.sendError(error, 'ConnectionsController.ts', 'fetchBalance', {
|
|
536
|
+
address,
|
|
537
|
+
namespace
|
|
538
|
+
});
|
|
534
539
|
SnackController.showError('Failed to get account balance');
|
|
535
540
|
}
|
|
536
541
|
},
|
|
@@ -2,6 +2,7 @@ import { subscribeKey as subKey } from 'valtio/utils';
|
|
|
2
2
|
import { proxy, subscribe as sub } from 'valtio';
|
|
3
3
|
import { BlockchainApiController } from './BlockchainApiController';
|
|
4
4
|
import type { BlockchainApiEnsError } from '@reown/appkit-common-react-native';
|
|
5
|
+
import { LogController } from './LogController';
|
|
5
6
|
|
|
6
7
|
// -- Types --------------------------------------------- //
|
|
7
8
|
|
|
@@ -32,6 +33,7 @@ export const EnsController = {
|
|
|
32
33
|
try {
|
|
33
34
|
return await BlockchainApiController.lookupEnsName(name);
|
|
34
35
|
} catch (e) {
|
|
36
|
+
LogController.sendError(e, 'EnsController.ts', 'resolveName');
|
|
35
37
|
const error = e as BlockchainApiEnsError;
|
|
36
38
|
throw new Error(error?.reasons?.[0]?.description || 'Error resolving name');
|
|
37
39
|
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { proxy } from 'valtio';
|
|
2
|
+
import { OptionsController } from './OptionsController';
|
|
3
|
+
import { sanitizeString, sanitizeStackTrace, sanitizeValue, sanitizeData } from '../utils/LogUtils';
|
|
4
|
+
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
5
|
+
|
|
6
|
+
// -- Types --------------------------------------------- //
|
|
7
|
+
export type LogLevel = 'info' | 'warn' | 'error' | 'debug';
|
|
8
|
+
|
|
9
|
+
export interface LogEntry {
|
|
10
|
+
id: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
message: string;
|
|
14
|
+
fileName?: string;
|
|
15
|
+
functionName?: string;
|
|
16
|
+
data?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LogControllerState {
|
|
20
|
+
logs: LogEntry[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// -- Constants ----------------------------------------- //
|
|
24
|
+
const MAX_LOGS_COUNT = 300; // Prevent memory issues
|
|
25
|
+
|
|
26
|
+
// -- State --------------------------------------------- //
|
|
27
|
+
const state = proxy<LogControllerState>({
|
|
28
|
+
logs: []
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const generateLogId = (): string => {
|
|
32
|
+
return CoreHelperUtil.getUUID();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const logToConsole = (entry: LogEntry) => {
|
|
36
|
+
const { debug } = OptionsController.state;
|
|
37
|
+
|
|
38
|
+
if (!debug) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const location =
|
|
43
|
+
entry.fileName && entry.functionName
|
|
44
|
+
? `[${entry.fileName}:${entry.functionName}]`
|
|
45
|
+
: entry.fileName
|
|
46
|
+
? `[${entry.fileName}]`
|
|
47
|
+
: '';
|
|
48
|
+
|
|
49
|
+
const logMessage = `[AppKit] ${location} ${entry.message}`;
|
|
50
|
+
|
|
51
|
+
switch (entry.level) {
|
|
52
|
+
case 'error':
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.error(logMessage);
|
|
55
|
+
break;
|
|
56
|
+
case 'warn':
|
|
57
|
+
console.warn(logMessage);
|
|
58
|
+
break;
|
|
59
|
+
case 'debug':
|
|
60
|
+
// eslint-disable-next-line no-console
|
|
61
|
+
console.debug(logMessage);
|
|
62
|
+
break;
|
|
63
|
+
case 'info':
|
|
64
|
+
default:
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
console.log(logMessage);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// -- Controller ---------------------------------------- //
|
|
72
|
+
export const LogController = {
|
|
73
|
+
state,
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Initialize the LogController
|
|
77
|
+
*/
|
|
78
|
+
initialize() {
|
|
79
|
+
// Initialize the LogController
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Destroy the LogController (cleanup resources)
|
|
84
|
+
*/
|
|
85
|
+
destroy() {
|
|
86
|
+
// Clear all logs
|
|
87
|
+
state.logs = [];
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Send a general log entry
|
|
92
|
+
*/
|
|
93
|
+
sendLog(
|
|
94
|
+
level: LogLevel,
|
|
95
|
+
message: string,
|
|
96
|
+
fileName?: string,
|
|
97
|
+
functionName?: string,
|
|
98
|
+
data?: Record<string, unknown>
|
|
99
|
+
) {
|
|
100
|
+
if (!OptionsController.state.debug) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const entry: LogEntry = {
|
|
105
|
+
id: generateLogId(),
|
|
106
|
+
timestamp: Date.now(),
|
|
107
|
+
level,
|
|
108
|
+
message: sanitizeString(message),
|
|
109
|
+
fileName,
|
|
110
|
+
functionName,
|
|
111
|
+
data: sanitizeData(data)
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
state.logs.push(entry);
|
|
115
|
+
|
|
116
|
+
// Enforce maximum log count
|
|
117
|
+
if (state.logs.length > MAX_LOGS_COUNT) {
|
|
118
|
+
state.logs = state.logs.slice(-MAX_LOGS_COUNT);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
logToConsole(entry);
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Send an error log entry - convenience method for try/catch blocks
|
|
126
|
+
*/
|
|
127
|
+
sendError(
|
|
128
|
+
error: Error | string | unknown,
|
|
129
|
+
fileName?: string,
|
|
130
|
+
functionName?: string,
|
|
131
|
+
additionalData?: Record<string, unknown>
|
|
132
|
+
) {
|
|
133
|
+
let message: string;
|
|
134
|
+
let data: Record<string, unknown> = sanitizeData(additionalData) || {};
|
|
135
|
+
|
|
136
|
+
if (error instanceof Error) {
|
|
137
|
+
message = error.message || 'Error occurred';
|
|
138
|
+
// Sanitize stack trace to remove sensitive file paths
|
|
139
|
+
data['stack'] = error.stack ? sanitizeStackTrace(error.stack) : undefined;
|
|
140
|
+
data['name'] = error.name;
|
|
141
|
+
|
|
142
|
+
// Sanitize any additional properties on the error object
|
|
143
|
+
const errorProps: Record<string, unknown> = {};
|
|
144
|
+
Object.getOwnPropertyNames(error).forEach(prop => {
|
|
145
|
+
if (prop !== 'message' && prop !== 'stack' && prop !== 'name') {
|
|
146
|
+
errorProps[prop] = (error as any)[prop];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (Object.keys(errorProps).length > 0) {
|
|
151
|
+
Object.assign(data, sanitizeValue(errorProps) as Record<string, unknown>);
|
|
152
|
+
}
|
|
153
|
+
} else if (typeof error === 'string') {
|
|
154
|
+
message = error;
|
|
155
|
+
} else {
|
|
156
|
+
message = 'Unknown error occurred';
|
|
157
|
+
// Sanitize the original error object
|
|
158
|
+
data['originalError'] = sanitizeValue(error);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Note: sanitization happens in sendLog method
|
|
162
|
+
this.sendLog('error', message, fileName, functionName, data);
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Send an info log entry
|
|
167
|
+
*/
|
|
168
|
+
sendInfo(
|
|
169
|
+
message: string,
|
|
170
|
+
fileName?: string,
|
|
171
|
+
functionName?: string,
|
|
172
|
+
data?: Record<string, unknown>
|
|
173
|
+
) {
|
|
174
|
+
this.sendLog('info', message, fileName, functionName, data);
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Send a warning log entry
|
|
179
|
+
*/
|
|
180
|
+
sendWarn(
|
|
181
|
+
message: string,
|
|
182
|
+
fileName?: string,
|
|
183
|
+
functionName?: string,
|
|
184
|
+
data?: Record<string, unknown>
|
|
185
|
+
) {
|
|
186
|
+
this.sendLog('warn', message, fileName, functionName, data);
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Send a debug log entry
|
|
191
|
+
*/
|
|
192
|
+
sendDebug(
|
|
193
|
+
message: string,
|
|
194
|
+
fileName?: string,
|
|
195
|
+
functionName?: string,
|
|
196
|
+
data?: Record<string, unknown>
|
|
197
|
+
) {
|
|
198
|
+
this.sendLog('debug', message, fileName, functionName, data);
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Get all logs
|
|
203
|
+
*/
|
|
204
|
+
getLogs(): LogEntry[] {
|
|
205
|
+
return [...state.logs];
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get logs by level
|
|
210
|
+
*/
|
|
211
|
+
getLogsByLevel(level: LogLevel): LogEntry[] {
|
|
212
|
+
return state.logs.filter(log => log.level === level);
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Get recent logs (last N entries)
|
|
217
|
+
*/
|
|
218
|
+
getRecentLogs(count: number = 100): LogEntry[] {
|
|
219
|
+
return state.logs.slice(-count);
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Clear all logs
|
|
224
|
+
*/
|
|
225
|
+
clearLogs() {
|
|
226
|
+
state.logs = [];
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Export logs as JSON string for debugging
|
|
231
|
+
*/
|
|
232
|
+
exportLogs(): string {
|
|
233
|
+
return JSON.stringify(state.logs, null, 2);
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Get logs count by level
|
|
238
|
+
*/
|
|
239
|
+
getLogsStats(): Record<LogLevel, number> {
|
|
240
|
+
const stats: Record<LogLevel, number> = {
|
|
241
|
+
info: 0,
|
|
242
|
+
warn: 0,
|
|
243
|
+
error: 0,
|
|
244
|
+
debug: 0
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
state.logs.forEach(log => {
|
|
248
|
+
stats[log.level]++;
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
return stats;
|
|
252
|
+
}
|
|
253
|
+
};
|