@reown/appkit-react-native 0.0.0-feat-multichain-20250520183003 → 0.0.0-feat-multichain-20250604171123
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/AppKit.js +74 -37
- package/lib/commonjs/AppKit.js.map +1 -1
- package/lib/commonjs/client.js +0 -4
- package/lib/commonjs/client.js.map +1 -1
- package/lib/commonjs/connectors/WalletConnectConnector.js.map +1 -1
- package/lib/commonjs/hooks/useAccount.js +2 -2
- package/lib/commonjs/hooks/useAccount.js.map +1 -1
- package/lib/commonjs/hooks/useProvider.js +3 -2
- package/lib/commonjs/hooks/useProvider.js.map +1 -1
- package/lib/commonjs/partials/w3m-account-activity/index.js +2 -3
- package/lib/commonjs/partials/w3m-account-activity/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-account-wallet-features/index.js +15 -16
- package/lib/commonjs/partials/w3m-account-wallet-features/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-send-input-token/index.js +1 -1
- package/lib/commonjs/partials/w3m-send-input-token/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-swap-details/index.js +1 -1
- package/lib/commonjs/partials/w3m-swap-details/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-swap-input/index.js +1 -1
- package/lib/commonjs/utils/UiUtil.js +5 -4
- package/lib/commonjs/utils/UiUtil.js.map +1 -1
- package/lib/commonjs/views/w3m-account-default-view/index.js +14 -17
- package/lib/commonjs/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-connect-view/index.js +1 -0
- package/lib/commonjs/views/w3m-connect-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-swap-preview-view/index.js +3 -3
- package/lib/commonjs/views/w3m-swap-preview-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-swap-view/index.js +7 -2
- package/lib/commonjs/views/w3m-swap-view/index.js.map +1 -1
- package/lib/module/AppKit.js +75 -37
- package/lib/module/AppKit.js.map +1 -1
- package/lib/module/client.js +0 -4
- package/lib/module/client.js.map +1 -1
- package/lib/module/connectors/WalletConnectConnector.js.map +1 -1
- package/lib/module/hooks/useAccount.js +2 -2
- package/lib/module/hooks/useAccount.js.map +1 -1
- package/lib/module/hooks/useProvider.js +3 -2
- package/lib/module/hooks/useProvider.js.map +1 -1
- package/lib/module/partials/w3m-account-activity/index.js +3 -4
- package/lib/module/partials/w3m-account-activity/index.js.map +1 -1
- package/lib/module/partials/w3m-account-wallet-features/index.js +16 -17
- package/lib/module/partials/w3m-account-wallet-features/index.js.map +1 -1
- package/lib/module/partials/w3m-send-input-token/index.js +1 -1
- package/lib/module/partials/w3m-send-input-token/index.js.map +1 -1
- package/lib/module/partials/w3m-swap-details/index.js +2 -2
- package/lib/module/partials/w3m-swap-details/index.js.map +1 -1
- package/lib/module/partials/w3m-swap-input/index.js +1 -1
- package/lib/module/utils/UiUtil.js +5 -4
- package/lib/module/utils/UiUtil.js.map +1 -1
- package/lib/module/views/w3m-account-default-view/index.js +14 -17
- package/lib/module/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/module/views/w3m-connect-view/index.js +1 -0
- package/lib/module/views/w3m-connect-view/index.js.map +1 -1
- package/lib/module/views/w3m-swap-preview-view/index.js +3 -3
- package/lib/module/views/w3m-swap-preview-view/index.js.map +1 -1
- package/lib/module/views/w3m-swap-view/index.js +8 -3
- package/lib/module/views/w3m-swap-view/index.js.map +1 -1
- package/lib/typescript/AppKit.d.ts +7 -4
- package/lib/typescript/AppKit.d.ts.map +1 -1
- package/lib/typescript/AppKitContext.d.ts +1 -1
- package/lib/typescript/client.d.ts.map +1 -1
- package/lib/typescript/connectors/WalletConnectConnector.d.ts +2 -5
- package/lib/typescript/connectors/WalletConnectConnector.d.ts.map +1 -1
- package/lib/typescript/hooks/useProvider.d.ts +1 -1
- package/lib/typescript/hooks/useProvider.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-account-activity/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-account-wallet-features/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-swap-details/index.d.ts.map +1 -1
- package/lib/typescript/utils/UiUtil.d.ts +1 -2
- package/lib/typescript/utils/UiUtil.d.ts.map +1 -1
- package/lib/typescript/views/w3m-account-default-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-connect-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-swap-preview-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-swap-view/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/AppKit.ts +87 -42
- package/src/client.ts +0 -5
- package/src/connectors/WalletConnectConnector.ts +3 -3
- package/src/hooks/useAccount.ts +2 -2
- package/src/hooks/useProvider.ts +5 -3
- package/src/partials/w3m-account-activity/index.tsx +5 -2
- package/src/partials/w3m-account-wallet-features/index.tsx +17 -20
- package/src/partials/w3m-send-input-token/index.tsx +1 -1
- package/src/partials/w3m-swap-details/index.tsx +6 -2
- package/src/partials/w3m-swap-input/index.tsx +1 -1
- package/src/utils/UiUtil.ts +5 -11
- package/src/views/w3m-account-default-view/index.tsx +22 -20
- package/src/views/w3m-connect-view/index.tsx +1 -0
- package/src/views/w3m-swap-preview-view/index.tsx +6 -3
- package/src/views/w3m-swap-view/index.tsx +9 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/UiUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"UiUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/UiUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AAEzC,eAAO,MAAM,MAAM;;;;sCAcJ;QAAE,MAAM,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,kBACzB,QAAQ;CAa3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-default-view/index.tsx"],"names":[],"mappings":"AAuCA,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-default-view/index.tsx"],"names":[],"mappings":"AAuCA,wBAAgB,kBAAkB,4CAySjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-connect-view/index.tsx"],"names":[],"mappings":"AAyBA,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-connect-view/index.tsx"],"names":[],"mappings":"AAyBA,wBAAgB,WAAW,4CAoH1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-preview-view/index.tsx"],"names":[],"mappings":"AAmBA,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-preview-view/index.tsx"],"names":[],"mappings":"AAmBA,wBAAgB,eAAe,4CAgI9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-view/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-view/index.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,QAAQ,4CA+LvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-react-native",
|
|
3
|
-
"version": "0.0.0-feat-multichain-
|
|
3
|
+
"version": "0.0.0-feat-multichain-20250604171123",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"types": "lib/typescript/index.d.ts",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@reown/appkit-common-react-native": "0.0.0-feat-multichain-
|
|
41
|
-
"@reown/appkit-core-react-native": "0.0.0-feat-multichain-
|
|
42
|
-
"@reown/appkit-siwe-react-native": "0.0.0-feat-multichain-
|
|
43
|
-
"@reown/appkit-ui-react-native": "0.0.0-feat-multichain-
|
|
40
|
+
"@reown/appkit-common-react-native": "0.0.0-feat-multichain-20250604171123",
|
|
41
|
+
"@reown/appkit-core-react-native": "0.0.0-feat-multichain-20250604171123",
|
|
42
|
+
"@reown/appkit-siwe-react-native": "0.0.0-feat-multichain-20250604171123",
|
|
43
|
+
"@reown/appkit-ui-react-native": "0.0.0-feat-multichain-20250604171123",
|
|
44
44
|
"@walletconnect/universal-provider": "2.20.2",
|
|
45
45
|
"valtio": "^1.13.2"
|
|
46
46
|
},
|
package/src/AppKit.ts
CHANGED
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
StorageUtil,
|
|
11
11
|
type OptionsControllerState,
|
|
12
12
|
ThemeController,
|
|
13
|
-
ConnectionController
|
|
13
|
+
ConnectionController,
|
|
14
|
+
type Features
|
|
14
15
|
} from '@reown/appkit-core-react-native';
|
|
15
16
|
|
|
16
17
|
import type {
|
|
@@ -26,7 +27,8 @@ import type {
|
|
|
26
27
|
ThemeMode,
|
|
27
28
|
WalletInfo,
|
|
28
29
|
Network,
|
|
29
|
-
ChainNamespace
|
|
30
|
+
ChainNamespace,
|
|
31
|
+
ConnectOptions
|
|
30
32
|
} from '@reown/appkit-common-react-native';
|
|
31
33
|
|
|
32
34
|
import { WalletConnectConnector } from './connectors/WalletConnectConnector';
|
|
@@ -53,7 +55,7 @@ interface AppKitConfig {
|
|
|
53
55
|
themeVariables?: ThemeVariables;
|
|
54
56
|
siweConfig?: AppKitSIWEClient;
|
|
55
57
|
defaultNetwork?: Network;
|
|
56
|
-
|
|
58
|
+
features?: Features;
|
|
57
59
|
// chainImages?: Record<number, string>; //TODO: rename to networkImages
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -102,18 +104,17 @@ export class AppKit {
|
|
|
102
104
|
/**
|
|
103
105
|
* Handles the full connection flow for a given connector type.
|
|
104
106
|
* @param type - The type of connector to use.
|
|
105
|
-
* @param
|
|
107
|
+
* @param options - Optional connection options.
|
|
106
108
|
*/
|
|
107
|
-
async connect(type: New_ConnectorType,
|
|
109
|
+
async connect(type: New_ConnectorType, options?: ConnectOptions): Promise<void> {
|
|
108
110
|
try {
|
|
111
|
+
const { namespaces, defaultChain, universalLink } = options ?? {};
|
|
109
112
|
const connector = await this.createConnector(type);
|
|
110
|
-
const defaultChain = this.defaultNetwork
|
|
111
|
-
? NetworkUtil.getDefaultChainId(this.defaultNetwork)
|
|
112
|
-
: undefined;
|
|
113
113
|
|
|
114
114
|
const approvedNamespaces = await connector.connect({
|
|
115
|
-
namespaces:
|
|
116
|
-
defaultChain
|
|
115
|
+
namespaces: namespaces ?? this.namespaces,
|
|
116
|
+
defaultChain,
|
|
117
|
+
universalLink
|
|
117
118
|
});
|
|
118
119
|
|
|
119
120
|
const walletInfo = connector.getWalletInfo();
|
|
@@ -166,10 +167,12 @@ export class AppKit {
|
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
const connection = ConnectionsController.state.connections
|
|
170
|
+
const connection = ConnectionsController.state.connections.get(
|
|
171
|
+
activeNamespace as ChainNamespace
|
|
172
|
+
);
|
|
170
173
|
const connectorType = connection?.adapter?.connector?.type;
|
|
171
174
|
|
|
172
|
-
await ConnectionsController.disconnect(activeNamespace, isInternal);
|
|
175
|
+
await ConnectionsController.disconnect(activeNamespace as ChainNamespace, isInternal);
|
|
173
176
|
|
|
174
177
|
if (connectorType) {
|
|
175
178
|
await StorageUtil.removeConnectedConnectors(connectorType);
|
|
@@ -203,7 +206,9 @@ export class AppKit {
|
|
|
203
206
|
const activeNamespace = namespace ?? ConnectionsController.state.activeNamespace;
|
|
204
207
|
if (!activeNamespace) return null;
|
|
205
208
|
|
|
206
|
-
const connection = ConnectionsController.state.connections
|
|
209
|
+
const connection = ConnectionsController.state.connections.get(
|
|
210
|
+
activeNamespace as ChainNamespace
|
|
211
|
+
);
|
|
207
212
|
if (!connection || !connection.adapter || !connection.adapter.connector) return null;
|
|
208
213
|
|
|
209
214
|
return connection.adapter.connector.getProvider() as T;
|
|
@@ -227,7 +232,7 @@ export class AppKit {
|
|
|
227
232
|
}
|
|
228
233
|
});
|
|
229
234
|
|
|
230
|
-
ConnectionsController.
|
|
235
|
+
ConnectionsController.setActiveNetwork(
|
|
231
236
|
adapter.getSupportedNamespace(),
|
|
232
237
|
`${adapter.getSupportedNamespace()}:${network.id}` as CaipNetworkId
|
|
233
238
|
);
|
|
@@ -327,28 +332,36 @@ export class AppKit {
|
|
|
327
332
|
}
|
|
328
333
|
|
|
329
334
|
private getAdapterByNamespace(namespace: ChainNamespace): BlockchainAdapter | null {
|
|
330
|
-
const namespaceConnection = ConnectionsController.state.connections
|
|
335
|
+
const namespaceConnection = ConnectionsController.state.connections.get(namespace);
|
|
336
|
+
if (namespaceConnection) {
|
|
337
|
+
return namespaceConnection.adapter;
|
|
338
|
+
}
|
|
331
339
|
|
|
332
|
-
return
|
|
340
|
+
return null;
|
|
333
341
|
}
|
|
334
342
|
|
|
335
343
|
private async syncAccounts(adapters: BlockchainAdapter[]) {
|
|
336
|
-
|
|
337
|
-
adapters.map(adapter => {
|
|
344
|
+
adapters.forEach(async adapter => {
|
|
338
345
|
const namespace = adapter.getSupportedNamespace();
|
|
339
|
-
const connection = ConnectionsController.state.connections
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
346
|
+
const connection = ConnectionsController.state.connections.get(namespace);
|
|
347
|
+
if (connection) {
|
|
348
|
+
const accounts = adapter.getAccounts();
|
|
349
|
+
if (accounts && accounts.length > 0) {
|
|
350
|
+
ConnectionsController.updateAccounts(namespace, accounts);
|
|
351
|
+
|
|
352
|
+
const network = this.networks.find(
|
|
353
|
+
n => n.id?.toString() === connection?.caipNetwork?.split(':')[1]
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
const address = accounts.find(
|
|
357
|
+
a => a.split(':')[1] === connection.caipNetwork?.split(':')[1]
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
if (address) {
|
|
361
|
+
adapter.getBalance({ address, network, tokens: this.config.tokens });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
352
365
|
});
|
|
353
366
|
}
|
|
354
367
|
|
|
@@ -364,14 +377,14 @@ export class AppKit {
|
|
|
364
377
|
|
|
365
378
|
const accounts = namespaceDetails.accounts ?? [];
|
|
366
379
|
const chains = namespaceDetails.chains ?? [];
|
|
367
|
-
const
|
|
380
|
+
const caipNetwork = adapter?.connector?.getChainId(namespace);
|
|
368
381
|
|
|
369
382
|
ConnectionsController.storeConnection({
|
|
370
383
|
namespace,
|
|
371
384
|
adapter,
|
|
372
385
|
accounts,
|
|
373
386
|
chains,
|
|
374
|
-
|
|
387
|
+
caipNetwork,
|
|
375
388
|
wallet
|
|
376
389
|
});
|
|
377
390
|
});
|
|
@@ -387,15 +400,17 @@ export class AppKit {
|
|
|
387
400
|
}
|
|
388
401
|
|
|
389
402
|
private subscribeToAdapterEvents(adapter: BlockchainAdapter): void {
|
|
390
|
-
adapter.on('accountsChanged', ({ accounts
|
|
403
|
+
adapter.on('accountsChanged', ({ accounts }) => {
|
|
404
|
+
const namespace = adapter.getSupportedNamespace();
|
|
391
405
|
//eslint-disable-next-line no-console
|
|
392
406
|
console.log('accountsChanged', accounts, namespace);
|
|
393
407
|
//TODO: check this
|
|
394
408
|
});
|
|
395
409
|
|
|
396
|
-
adapter.on('chainChanged', ({ chainId
|
|
410
|
+
adapter.on('chainChanged', ({ chainId }) => {
|
|
411
|
+
const namespace = adapter.getSupportedNamespace();
|
|
397
412
|
const chain = `${namespace}:${chainId}` as CaipNetworkId;
|
|
398
|
-
ConnectionsController.
|
|
413
|
+
ConnectionsController.setActiveNetwork(namespace, chain);
|
|
399
414
|
|
|
400
415
|
const network = this.networks.find(n => n.id?.toString() === chainId);
|
|
401
416
|
if (network) {
|
|
@@ -406,18 +421,19 @@ export class AppKit {
|
|
|
406
421
|
}
|
|
407
422
|
});
|
|
408
423
|
|
|
409
|
-
adapter.on('disconnect', (
|
|
410
|
-
|
|
424
|
+
adapter.on('disconnect', () => {
|
|
425
|
+
const namespace = adapter.getSupportedNamespace();
|
|
411
426
|
this.disconnect(namespace, false);
|
|
412
427
|
});
|
|
413
428
|
|
|
414
|
-
adapter.on('balanceChanged', ({
|
|
429
|
+
adapter.on('balanceChanged', ({ address, balance }) => {
|
|
430
|
+
const namespace = adapter.getSupportedNamespace();
|
|
415
431
|
ConnectionsController.updateBalance(namespace, address, balance);
|
|
416
432
|
});
|
|
417
433
|
}
|
|
418
434
|
|
|
419
435
|
private async initControllers(options: AppKitConfig) {
|
|
420
|
-
await this.initAsyncValues();
|
|
436
|
+
await this.initAsyncValues(options);
|
|
421
437
|
|
|
422
438
|
OptionsController.setProjectId(options.projectId);
|
|
423
439
|
OptionsController.setMetadata(options.metadata);
|
|
@@ -428,7 +444,7 @@ export class AppKit {
|
|
|
428
444
|
OptionsController.setCustomWallets(options.customWallets);
|
|
429
445
|
OptionsController.setEnableAnalytics(options.enableAnalytics);
|
|
430
446
|
OptionsController.setDebug(options.debug);
|
|
431
|
-
|
|
447
|
+
OptionsController.setFeatures(options.features);
|
|
432
448
|
|
|
433
449
|
ThemeController.setThemeMode(options.themeMode);
|
|
434
450
|
ThemeController.setThemeVariables(options.themeVariables);
|
|
@@ -454,7 +470,7 @@ export class AppKit {
|
|
|
454
470
|
// }
|
|
455
471
|
}
|
|
456
472
|
|
|
457
|
-
private async
|
|
473
|
+
private async initActiveNamespace() {
|
|
458
474
|
const activeNamespace = await StorageUtil.getActiveNamespace();
|
|
459
475
|
if (activeNamespace) {
|
|
460
476
|
ConnectionsController.setActiveNamespace(activeNamespace);
|
|
@@ -462,6 +478,35 @@ export class AppKit {
|
|
|
462
478
|
ConnectionsController.setActiveNamespace(this.defaultNetwork?.chainNamespace);
|
|
463
479
|
}
|
|
464
480
|
}
|
|
481
|
+
|
|
482
|
+
private async initRecentWallets(options: AppKitConfig) {
|
|
483
|
+
const wallets = await StorageUtil.getRecentWallets();
|
|
484
|
+
const connectedWalletImage = await StorageUtil.getConnectedWalletImageUrl();
|
|
485
|
+
|
|
486
|
+
const filteredWallets = wallets.filter(wallet => {
|
|
487
|
+
const { includeWalletIds, excludeWalletIds } = options;
|
|
488
|
+
if (includeWalletIds) {
|
|
489
|
+
return includeWalletIds.includes(wallet.id);
|
|
490
|
+
}
|
|
491
|
+
if (excludeWalletIds) {
|
|
492
|
+
return !excludeWalletIds.includes(wallet.id);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return true;
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
ConnectionController.setRecentWallets(filteredWallets);
|
|
499
|
+
|
|
500
|
+
if (connectedWalletImage) {
|
|
501
|
+
ConnectionController.setConnectedWalletImageUrl(connectedWalletImage);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
private async initAsyncValues(options: AppKitConfig) {
|
|
506
|
+
await this.initActiveNamespace();
|
|
507
|
+
await this.initRecentWallets(options);
|
|
508
|
+
//disable coinbase if connector is not set
|
|
509
|
+
}
|
|
465
510
|
}
|
|
466
511
|
|
|
467
512
|
export function createAppKit(config: AppKitConfig): AppKit {
|
package/src/client.ts
CHANGED
|
@@ -343,7 +343,6 @@ export class AppKitScaffold {
|
|
|
343
343
|
|
|
344
344
|
private async initRecentWallets(options: ScaffoldOptions) {
|
|
345
345
|
const wallets = await StorageUtil.getRecentWallets();
|
|
346
|
-
const connectedWalletImage = await StorageUtil.getConnectedWalletImageUrl();
|
|
347
346
|
|
|
348
347
|
const filteredWallets = wallets.filter(wallet => {
|
|
349
348
|
const { includeWalletIds, excludeWalletIds } = options;
|
|
@@ -358,10 +357,6 @@ export class AppKitScaffold {
|
|
|
358
357
|
});
|
|
359
358
|
|
|
360
359
|
ConnectionController.setRecentWallets(filteredWallets);
|
|
361
|
-
|
|
362
|
-
if (connectedWalletImage) {
|
|
363
|
-
ConnectionController.setConnectedWalletImageUrl(connectedWalletImage);
|
|
364
|
-
}
|
|
365
360
|
}
|
|
366
361
|
|
|
367
362
|
private async initConnectedConnector() {
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
WalletConnector,
|
|
5
5
|
type AppKitNetwork,
|
|
6
6
|
type Namespaces,
|
|
7
|
-
type ProposalNamespaces,
|
|
8
7
|
type Provider,
|
|
9
8
|
type WalletInfo,
|
|
10
9
|
type ChainNamespace,
|
|
11
|
-
type CaipNetworkId
|
|
10
|
+
type CaipNetworkId,
|
|
11
|
+
type ConnectOptions
|
|
12
12
|
} from '@reown/appkit-common-react-native';
|
|
13
13
|
|
|
14
14
|
export class WalletConnectConnector extends WalletConnector {
|
|
@@ -69,7 +69,7 @@ export class WalletConnectConnector extends WalletConnector {
|
|
|
69
69
|
return this.provider.disconnect();
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
override async connect(opts:
|
|
72
|
+
override async connect(opts: ConnectOptions) {
|
|
73
73
|
function onUri(uri: string) {
|
|
74
74
|
ConnectionController.setWcUri(uri);
|
|
75
75
|
}
|
package/src/hooks/useAccount.ts
CHANGED
|
@@ -11,11 +11,11 @@ export function useAccount() {
|
|
|
11
11
|
connections
|
|
12
12
|
} = useSnapshot(ConnectionsController.state);
|
|
13
13
|
|
|
14
|
-
const connection = activeNamespace ? connections
|
|
14
|
+
const connection = activeNamespace ? connections.get(activeNamespace) : undefined;
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
17
|
address: address?.split(':')[2],
|
|
18
18
|
isConnected: !!address,
|
|
19
|
-
chainId: connection?.
|
|
19
|
+
chainId: connection?.caipNetwork
|
|
20
20
|
};
|
|
21
21
|
}
|
package/src/hooks/useProvider.ts
CHANGED
|
@@ -7,12 +7,14 @@ interface ProviderResult {
|
|
|
7
7
|
providerType?: ChainNamespace;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export function useProvider(namespace?:
|
|
10
|
+
export function useProvider(namespace?: ChainNamespace): ProviderResult {
|
|
11
11
|
const { connections, activeNamespace } = useSnapshot(ConnectionsController.state);
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const targetNamespace = namespace ?? activeNamespace;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
if (!targetNamespace) return { provider: undefined, providerType: undefined };
|
|
16
|
+
|
|
17
|
+
const connection = connections.get(targetNamespace);
|
|
16
18
|
|
|
17
19
|
if (!connection) return { provider: undefined, providerType: undefined };
|
|
18
20
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
AccountController,
|
|
16
16
|
AssetUtil,
|
|
17
17
|
ConnectionsController,
|
|
18
|
+
ConstantsUtil,
|
|
18
19
|
EventsController,
|
|
19
20
|
OptionsController,
|
|
20
21
|
TransactionsController
|
|
@@ -32,9 +33,11 @@ export function AccountActivity({ style }: Props) {
|
|
|
32
33
|
const [refreshing, setRefreshing] = useState(false);
|
|
33
34
|
const [initialLoad, setInitialLoad] = useState(true);
|
|
34
35
|
const { loading, transactions, next } = useSnapshot(TransactionsController.state);
|
|
35
|
-
const { activeNetwork
|
|
36
|
+
const { activeNetwork } = useSnapshot(ConnectionsController.state);
|
|
36
37
|
const networkImage = AssetUtil.getNetworkImage(activeNetwork?.id);
|
|
37
|
-
const isSupported =
|
|
38
|
+
const isSupported =
|
|
39
|
+
activeNetwork?.caipNetworkId &&
|
|
40
|
+
ConstantsUtil.ACTIVITY_SUPPORTED_CHAINS.includes(activeNetwork.caipNetworkId);
|
|
38
41
|
|
|
39
42
|
const handleLoadMore = () => {
|
|
40
43
|
const address = ConnectionsController.state.activeAddress?.split(':')[2];
|
|
@@ -3,10 +3,10 @@ import { useSnapshot } from 'valtio';
|
|
|
3
3
|
import { Balance, FlexView, IconLink, Tabs } from '@reown/appkit-ui-react-native';
|
|
4
4
|
import {
|
|
5
5
|
AccountController,
|
|
6
|
+
ConnectionsController,
|
|
6
7
|
ConstantsUtil,
|
|
7
8
|
CoreHelperUtil,
|
|
8
9
|
EventsController,
|
|
9
|
-
NetworkController,
|
|
10
10
|
OnRampController,
|
|
11
11
|
OptionsController,
|
|
12
12
|
RouterController,
|
|
@@ -25,8 +25,12 @@ export function AccountWalletFeatures() {
|
|
|
25
25
|
const [activeTab, setActiveTab] = useState(0);
|
|
26
26
|
const { tokenBalance } = useSnapshot(AccountController.state);
|
|
27
27
|
const { features, isOnRampEnabled } = useSnapshot(OptionsController.state);
|
|
28
|
+
const { activeNetwork } = useSnapshot(ConnectionsController.state);
|
|
28
29
|
const balance = CoreHelperUtil.calculateAndFormatBalance(tokenBalance as BalanceType[]);
|
|
29
|
-
const isSwapsEnabled =
|
|
30
|
+
const isSwapsEnabled =
|
|
31
|
+
features?.swaps &&
|
|
32
|
+
activeNetwork?.caipNetworkId &&
|
|
33
|
+
ConstantsUtil.SWAP_SUPPORTED_NETWORKS.includes(activeNetwork.caipNetworkId);
|
|
30
34
|
|
|
31
35
|
const onTabChange = (index: number) => {
|
|
32
36
|
setActiveTab(index);
|
|
@@ -46,23 +50,16 @@ export function AccountWalletFeatures() {
|
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
const onSwapPress = () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
properties: {
|
|
60
|
-
network: NetworkController.state.caipNetwork?.id || '',
|
|
61
|
-
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount'
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
RouterController.push('Swap');
|
|
65
|
-
}
|
|
53
|
+
SwapController.resetState();
|
|
54
|
+
EventsController.sendEvent({
|
|
55
|
+
type: 'track',
|
|
56
|
+
event: 'OPEN_SWAP',
|
|
57
|
+
properties: {
|
|
58
|
+
network: ConnectionsController.state.activeNetwork?.caipNetworkId || '',
|
|
59
|
+
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
RouterController.push('Swap');
|
|
66
63
|
};
|
|
67
64
|
|
|
68
65
|
const onSendPress = () => {
|
|
@@ -70,7 +67,7 @@ export function AccountWalletFeatures() {
|
|
|
70
67
|
type: 'track',
|
|
71
68
|
event: 'OPEN_SEND',
|
|
72
69
|
properties: {
|
|
73
|
-
network:
|
|
70
|
+
network: ConnectionsController.state.activeNetwork?.caipNetworkId || '',
|
|
74
71
|
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount'
|
|
75
72
|
}
|
|
76
73
|
});
|
|
@@ -43,7 +43,7 @@ export function SendInputToken({
|
|
|
43
43
|
const isNetworkToken =
|
|
44
44
|
token.address === undefined ||
|
|
45
45
|
Object.values(ConstantsUtil.NATIVE_TOKEN_ADDRESS).some(
|
|
46
|
-
nativeAddress => token?.address === nativeAddress
|
|
46
|
+
nativeAddress => token?.address?.split(':')[2] === nativeAddress
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const numericGas = NumberUtil.bigNumber(gasPrice).shiftedBy(-token.quantity.decimals);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { useSnapshot } from 'valtio';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ConnectionsController,
|
|
5
|
+
ConstantsUtil,
|
|
6
|
+
SwapController
|
|
7
|
+
} from '@reown/appkit-core-react-native';
|
|
4
8
|
import {
|
|
5
9
|
FlexView,
|
|
6
10
|
Text,
|
|
@@ -80,7 +84,7 @@ export function SwapDetails({ initialOpen, canClose }: SwapDetailsProps) {
|
|
|
80
84
|
setModalData(
|
|
81
85
|
getModalData('networkCost', {
|
|
82
86
|
networkSymbol: SwapController.state.networkTokenSymbol,
|
|
83
|
-
networkName:
|
|
87
|
+
networkName: ConnectionsController.state.activeNetwork?.name
|
|
84
88
|
})
|
|
85
89
|
);
|
|
86
90
|
};
|
|
@@ -128,7 +128,7 @@ export function SwapInput({
|
|
|
128
128
|
>
|
|
129
129
|
<Text variant="small-400" color="fg-200" numberOfLines={1}>
|
|
130
130
|
{isMarketValueGreaterThanZero
|
|
131
|
-
? `~$${UiUtil.formatNumberToLocalString(marketValue,
|
|
131
|
+
? `~$${UiUtil.formatNumberToLocalString(marketValue, 6)}`
|
|
132
132
|
: ''}
|
|
133
133
|
</Text>
|
|
134
134
|
{showMax && (
|
package/src/utils/UiUtil.ts
CHANGED
|
@@ -4,24 +4,18 @@ import {
|
|
|
4
4
|
StorageUtil,
|
|
5
5
|
type WcWallet
|
|
6
6
|
} from '@reown/appkit-core-react-native';
|
|
7
|
-
import {
|
|
8
|
-
LayoutAnimation,
|
|
9
|
-
type LayoutAnimationProperty,
|
|
10
|
-
type LayoutAnimationType
|
|
11
|
-
} from 'react-native';
|
|
12
7
|
|
|
13
8
|
export const UiUtil = {
|
|
14
9
|
TOTAL_VISIBLE_WALLETS: 4,
|
|
15
10
|
|
|
16
11
|
createViewTransition: () => {
|
|
17
|
-
|
|
12
|
+
//TODO: replace this with reanimated
|
|
13
|
+
// LayoutAnimation.configureNext(LayoutAnimation.create(200, 'easeInEaseOut', 'opacity'));
|
|
18
14
|
},
|
|
19
15
|
|
|
20
|
-
animateChange: (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
) => {
|
|
24
|
-
LayoutAnimation.configureNext(LayoutAnimation.create(150, type, creationProp));
|
|
16
|
+
animateChange: () => {
|
|
17
|
+
//TODO: replace this with reanimated
|
|
18
|
+
// LayoutAnimation.configureNext(LayoutAnimation.create(150, type, creationProp));
|
|
25
19
|
},
|
|
26
20
|
|
|
27
21
|
storeConnectedWallet: async (
|
|
@@ -59,7 +59,16 @@ export function AccountDefaultView() {
|
|
|
59
59
|
const showExplorer = Object.keys(activeNetwork?.blockExplorers ?? {}).length > 0 && !isAuth;
|
|
60
60
|
const showBack = history.length > 1;
|
|
61
61
|
const showSwitchAccountType = isAuth && NetworkController.checkIfSmartAccountEnabled();
|
|
62
|
-
const showActivity =
|
|
62
|
+
const showActivity =
|
|
63
|
+
!isAuth &&
|
|
64
|
+
activeNamespace &&
|
|
65
|
+
activeNetwork?.caipNetworkId &&
|
|
66
|
+
ConstantsUtil.ACTIVITY_SUPPORTED_CHAINS.includes(activeNetwork.caipNetworkId);
|
|
67
|
+
const showSwaps =
|
|
68
|
+
!isAuth &&
|
|
69
|
+
features?.swaps &&
|
|
70
|
+
activeNetwork?.caipNetworkId &&
|
|
71
|
+
ConstantsUtil.SWAP_SUPPORTED_NETWORKS.includes(activeNetwork.caipNetworkId);
|
|
63
72
|
const { padding } = useCustomDimensions();
|
|
64
73
|
const { disconnect } = useAppKit();
|
|
65
74
|
|
|
@@ -82,7 +91,7 @@ export function AccountDefaultView() {
|
|
|
82
91
|
event: 'SET_PREFERRED_ACCOUNT_TYPE',
|
|
83
92
|
properties: {
|
|
84
93
|
accountType,
|
|
85
|
-
network:
|
|
94
|
+
network: ConnectionsController.state.activeNetwork?.caipNetworkId || ''
|
|
86
95
|
}
|
|
87
96
|
});
|
|
88
97
|
}
|
|
@@ -124,23 +133,16 @@ export function AccountDefaultView() {
|
|
|
124
133
|
};
|
|
125
134
|
|
|
126
135
|
const onSwapPress = () => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
properties: {
|
|
138
|
-
network: NetworkController.state.caipNetwork?.id || '',
|
|
139
|
-
isSmartAccount: false
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
RouterController.push('Swap');
|
|
143
|
-
}
|
|
136
|
+
SwapController.resetState();
|
|
137
|
+
EventsController.sendEvent({
|
|
138
|
+
type: 'track',
|
|
139
|
+
event: 'OPEN_SWAP',
|
|
140
|
+
properties: {
|
|
141
|
+
network: ConnectionsController.state.activeNetwork?.caipNetworkId || '',
|
|
142
|
+
isSmartAccount: false
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
RouterController.push('Swap');
|
|
144
146
|
};
|
|
145
147
|
|
|
146
148
|
const onBuyPress = () => {
|
|
@@ -276,7 +278,7 @@ export function AccountDefaultView() {
|
|
|
276
278
|
<Text color="fg-100">Buy crypto</Text>
|
|
277
279
|
</ListItem>
|
|
278
280
|
)}
|
|
279
|
-
{
|
|
281
|
+
{showSwaps && (
|
|
280
282
|
<ListItem
|
|
281
283
|
chevron
|
|
282
284
|
icon="recycleHorizontal"
|
|
@@ -31,6 +31,7 @@ export function ConnectView() {
|
|
|
31
31
|
const { padding } = useCustomDimensions();
|
|
32
32
|
const { keyboardShown, keyboardHeight } = useKeyboard();
|
|
33
33
|
|
|
34
|
+
//TODO: check this
|
|
34
35
|
// const isWalletConnectEnabled = connectors.some(c => c.type === 'WALLET_CONNECT');
|
|
35
36
|
const isWalletConnectEnabled = true;
|
|
36
37
|
const isAuthEnabled = connectors.some(c => c.type === 'AUTH');
|
|
@@ -86,11 +86,14 @@ export function SwapPreviewView() {
|
|
|
86
86
|
Send
|
|
87
87
|
</Text>
|
|
88
88
|
<Text variant="paragraph-400" color="fg-100">
|
|
89
|
-
${UiUtil.formatNumberToLocalString(sourceTokenMarketValue,
|
|
89
|
+
${UiUtil.formatNumberToLocalString(sourceTokenMarketValue, 6)}
|
|
90
90
|
</Text>
|
|
91
91
|
</FlexView>
|
|
92
92
|
<TokenButton
|
|
93
|
-
text={` ${
|
|
93
|
+
text={` ${UiUtil.formatNumberToLocalString(
|
|
94
|
+
sourceTokenAmount,
|
|
95
|
+
8
|
|
96
|
+
)} ${sourceToken?.symbol}`}
|
|
94
97
|
imageUrl={sourceToken?.logoUri}
|
|
95
98
|
inverse
|
|
96
99
|
disabled
|
|
@@ -103,7 +106,7 @@ export function SwapPreviewView() {
|
|
|
103
106
|
Receive
|
|
104
107
|
</Text>
|
|
105
108
|
<Text variant="paragraph-400" color="fg-100">
|
|
106
|
-
${UiUtil.formatNumberToLocalString(toTokenMarketValue,
|
|
109
|
+
${UiUtil.formatNumberToLocalString(toTokenMarketValue, 6)}
|
|
107
110
|
</Text>
|
|
108
111
|
</FlexView>
|
|
109
112
|
<TokenButton
|