@reown/appkit-react-native 0.0.0-feat-multi-social-20250703185818 → 0.0.0-feat-multi-social-20250708154835
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 +37 -15
- package/lib/commonjs/AppKit.js.map +1 -1
- package/lib/commonjs/AppKitContext.js +2 -1
- package/lib/commonjs/AppKitContext.js.map +1 -1
- package/lib/commonjs/connectors/WalletConnectConnector.js.map +1 -1
- package/lib/commonjs/partials/w3m-account-tokens/index.js +11 -4
- package/lib/commonjs/partials/w3m-account-tokens/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-account-wallet-features/index.js +5 -2
- 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/views/w3m-account-default-view/index.js +11 -19
- package/lib/commonjs/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-account-view/index.js +11 -6
- package/lib/commonjs/views/w3m-account-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-network-switch-view/index.js +13 -19
- package/lib/commonjs/views/w3m-network-switch-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-swap-select-token-view/utils.js +4 -1
- package/lib/commonjs/views/w3m-swap-select-token-view/utils.js.map +1 -1
- package/lib/commonjs/views/w3m-wallet-send-preview-view/components/preview-send-details.js +2 -2
- package/lib/commonjs/views/w3m-wallet-send-preview-view/components/preview-send-details.js.map +1 -1
- package/lib/commonjs/views/w3m-wallet-send-preview-view/index.js +3 -3
- package/lib/commonjs/views/w3m-wallet-send-preview-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-wallet-send-select-token-view/index.js +1 -1
- package/lib/commonjs/views/w3m-wallet-send-select-token-view/index.js.map +1 -1
- package/lib/module/AppKit.js +37 -15
- package/lib/module/AppKit.js.map +1 -1
- package/lib/module/AppKitContext.js +2 -1
- package/lib/module/AppKitContext.js.map +1 -1
- package/lib/module/connectors/WalletConnectConnector.js.map +1 -1
- package/lib/module/partials/w3m-account-tokens/index.js +12 -5
- package/lib/module/partials/w3m-account-tokens/index.js.map +1 -1
- package/lib/module/partials/w3m-account-wallet-features/index.js +5 -2
- 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/views/w3m-account-default-view/index.js +11 -19
- package/lib/module/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/module/views/w3m-account-view/index.js +12 -7
- package/lib/module/views/w3m-account-view/index.js.map +1 -1
- package/lib/module/views/w3m-network-switch-view/index.js +14 -19
- package/lib/module/views/w3m-network-switch-view/index.js.map +1 -1
- package/lib/module/views/w3m-swap-select-token-view/utils.js +4 -1
- package/lib/module/views/w3m-swap-select-token-view/utils.js.map +1 -1
- package/lib/module/views/w3m-wallet-send-preview-view/components/preview-send-details.js +2 -2
- package/lib/module/views/w3m-wallet-send-preview-view/components/preview-send-details.js.map +1 -1
- package/lib/module/views/w3m-wallet-send-preview-view/index.js +4 -4
- package/lib/module/views/w3m-wallet-send-preview-view/index.js.map +1 -1
- package/lib/module/views/w3m-wallet-send-select-token-view/index.js +1 -1
- package/lib/module/views/w3m-wallet-send-select-token-view/index.js.map +1 -1
- package/lib/typescript/AppKit.d.ts +3 -1
- package/lib/typescript/AppKit.d.ts.map +1 -1
- package/lib/typescript/AppKitContext.d.ts +1 -0
- package/lib/typescript/AppKitContext.d.ts.map +1 -1
- package/lib/typescript/connectors/WalletConnectConnector.d.ts +1 -1
- package/lib/typescript/connectors/WalletConnectConnector.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-account-tokens/index.d.ts +2 -1
- package/lib/typescript/partials/w3m-account-tokens/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-account-wallet-features/index.d.ts +2 -2
- package/lib/typescript/partials/w3m-account-wallet-features/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-account-default-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-account-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-network-switch-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-swap-select-token-view/utils.d.ts +1 -1
- package/lib/typescript/views/w3m-swap-select-token-view/utils.d.ts.map +1 -1
- package/lib/typescript/views/w3m-wallet-send-preview-view/components/preview-send-details.d.ts +3 -3
- package/lib/typescript/views/w3m-wallet-send-preview-view/components/preview-send-details.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/AppKit.ts +44 -20
- package/src/AppKitContext.tsx +2 -1
- package/src/connectors/WalletConnectConnector.ts +1 -1
- package/src/partials/w3m-account-tokens/index.tsx +26 -18
- package/src/partials/w3m-account-wallet-features/index.tsx +5 -3
- package/src/partials/w3m-send-input-token/index.tsx +2 -2
- package/src/views/w3m-account-default-view/index.tsx +7 -21
- package/src/views/w3m-account-view/index.tsx +11 -8
- package/src/views/w3m-network-switch-view/index.tsx +12 -24
- package/src/views/w3m-swap-select-token-view/utils.ts +6 -2
- package/src/views/w3m-wallet-send-preview-view/components/preview-send-details.tsx +4 -4
- package/src/views/w3m-wallet-send-preview-view/index.tsx +3 -3
- package/src/views/w3m-wallet-send-select-token-view/index.tsx +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
2
|
interface Props {
|
|
3
3
|
style?: StyleProp<ViewStyle>;
|
|
4
|
+
isLoading?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export declare function AccountTokens({ style }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function AccountTokens({ style, isLoading }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-account-tokens/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-account-tokens/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAiBtB,UAAU,KAAK;IACb,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,2CAqExD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface AccountWalletFeaturesProps {
|
|
2
|
-
|
|
2
|
+
isBalanceLoading: boolean;
|
|
3
3
|
}
|
|
4
|
-
export declare function AccountWalletFeatures(): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function AccountWalletFeatures({ isBalanceLoading }: AccountWalletFeaturesProps): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-account-wallet-features/index.tsx"],"names":[],"mappings":"AAkBA,MAAM,WAAW,0BAA0B;IACzC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-account-wallet-features/index.tsx"],"names":[],"mappings":"AAkBA,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,qBAAqB,CAAC,EAAE,gBAAgB,EAAE,EAAE,0BAA0B,2CA4HrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-default-view/index.tsx"],"names":[],"mappings":"AAmCA,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-default-view/index.tsx"],"names":[],"mappings":"AAmCA,wBAAgB,kBAAkB,4CAkRjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-view/index.tsx"],"names":[],"mappings":"AAyBA,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-view/index.tsx"],"names":[],"mappings":"AAyBA,wBAAgB,WAAW,4CAkE1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-network-switch-view/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-network-switch-view/index.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,iBAAiB,4CA0GhC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SwapTokenWithBalance } from '@reown/appkit-core-react-native';
|
|
2
|
-
export declare function filterTokens(tokens
|
|
2
|
+
export declare function filterTokens(tokens?: SwapTokenWithBalance[], searchValue?: string): SwapTokenWithBalance[];
|
|
3
3
|
export declare function createSections(isSourceToken: boolean, searchValue: string): {
|
|
4
4
|
title: string;
|
|
5
5
|
data: SwapTokenWithBalance[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-select-token-view/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5F,wBAAgB,YAAY,CAAC,MAAM,EAAE,oBAAoB,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-select-token-view/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5F,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,0BAcjF;AAED,wBAAgB,cAAc,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM;;;IAkBzE"}
|
package/lib/typescript/views/w3m-wallet-send-preview-view/components/preview-send-details.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AppKitNetwork } from '@reown/appkit-common-react-native';
|
|
2
2
|
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
3
|
export interface PreviewSendDetailsProps {
|
|
4
4
|
address?: string;
|
|
5
5
|
name?: string;
|
|
6
|
-
|
|
6
|
+
activeNetwork?: AppKitNetwork;
|
|
7
7
|
networkFee?: number;
|
|
8
8
|
style?: StyleProp<ViewStyle>;
|
|
9
9
|
}
|
|
10
|
-
export declare function PreviewSendDetails({ address, name,
|
|
10
|
+
export declare function PreviewSendDetails({ address, name, activeNetwork, networkFee, style }: PreviewSendDetailsProps): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
//# sourceMappingURL=preview-send-details.d.ts.map
|
package/lib/typescript/views/w3m-wallet-send-preview-view/components/preview-send-details.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-send-details.d.ts","sourceRoot":"","sources":["../../../../../src/views/w3m-wallet-send-preview-view/components/preview-send-details.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"preview-send-details.d.ts","sourceRoot":"","sources":["../../../../../src/views/w3m-wallet-send-preview-view/components/preview-send-details.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAUvE,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,IAAI,EACJ,aAAa,EACb,UAAU,EACV,KAAK,EACN,EAAE,uBAAuB,2CAmDzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-react-native",
|
|
3
|
-
"version": "0.0.0-feat-multi-social-
|
|
3
|
+
"version": "0.0.0-feat-multi-social-20250708154835",
|
|
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-multi-social-
|
|
41
|
-
"@reown/appkit-core-react-native": "0.0.0-feat-multi-social-
|
|
42
|
-
"@reown/appkit-siwe-react-native": "0.0.0-feat-multi-social-
|
|
43
|
-
"@reown/appkit-ui-react-native": "0.0.0-feat-multi-social-
|
|
40
|
+
"@reown/appkit-common-react-native": "0.0.0-feat-multi-social-20250708154835",
|
|
41
|
+
"@reown/appkit-core-react-native": "0.0.0-feat-multi-social-20250708154835",
|
|
42
|
+
"@reown/appkit-siwe-react-native": "0.0.0-feat-multi-social-20250708154835",
|
|
43
|
+
"@reown/appkit-ui-react-native": "0.0.0-feat-multi-social-20250708154835",
|
|
44
44
|
"@walletconnect/universal-provider": "2.20.2",
|
|
45
45
|
"valtio": "^1.13.2"
|
|
46
46
|
},
|
package/src/AppKit.ts
CHANGED
|
@@ -31,7 +31,8 @@ import type {
|
|
|
31
31
|
Storage,
|
|
32
32
|
AppKitConnectOptions,
|
|
33
33
|
AppKitSIWEClient,
|
|
34
|
-
ConnectionProperties
|
|
34
|
+
ConnectionProperties,
|
|
35
|
+
AccountType
|
|
35
36
|
} from '@reown/appkit-common-react-native';
|
|
36
37
|
|
|
37
38
|
import { WalletConnectConnector } from './connectors/WalletConnectConnector';
|
|
@@ -268,6 +269,28 @@ export class AppKit {
|
|
|
268
269
|
ModalController.close();
|
|
269
270
|
}
|
|
270
271
|
|
|
272
|
+
async switchAccountType(namespace: ChainNamespace, type: AccountType, network: AppKitNetwork) {
|
|
273
|
+
const adapter = this.getAdapterByNamespace(namespace);
|
|
274
|
+
if (!adapter) throw new Error('No active adapter');
|
|
275
|
+
|
|
276
|
+
ConnectionsController.setAccountType(namespace, type);
|
|
277
|
+
|
|
278
|
+
// Get balances from API
|
|
279
|
+
ConnectionsController.fetchBalance();
|
|
280
|
+
|
|
281
|
+
// Sync balances from adapter
|
|
282
|
+
this.syncBalances(adapter, network);
|
|
283
|
+
|
|
284
|
+
EventsController.sendEvent({
|
|
285
|
+
type: 'track',
|
|
286
|
+
event: 'SET_PREFERRED_ACCOUNT_TYPE',
|
|
287
|
+
properties: {
|
|
288
|
+
accountType: type,
|
|
289
|
+
network: network?.caipNetworkId || ''
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
271
294
|
private async createConnector(type: New_ConnectorType): Promise<WalletConnector> {
|
|
272
295
|
// Check if an extra connector was provided by the developer
|
|
273
296
|
const CustomConnector = this.extraConnectors.find(
|
|
@@ -384,25 +407,27 @@ export class AppKit {
|
|
|
384
407
|
adapters.forEach(async adapter => {
|
|
385
408
|
const namespace = adapter.getSupportedNamespace();
|
|
386
409
|
const connection = ConnectionsController.state.connections.get(namespace);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
ConnectionsController.updateAccounts(namespace, accounts);
|
|
410
|
+
const network = this.networks.find(
|
|
411
|
+
n => n.id?.toString() === connection?.caipNetwork?.split(':')[1]
|
|
412
|
+
);
|
|
391
413
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
414
|
+
this.syncBalances(adapter, network);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
395
417
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
418
|
+
private syncBalances(adapter: BlockchainAdapter, network?: AppKitNetwork) {
|
|
419
|
+
if (adapter && network) {
|
|
420
|
+
const accounts = adapter.getAccounts();
|
|
421
|
+
if (accounts && accounts.length > 0) {
|
|
422
|
+
const addresses = accounts.filter(a => a.split(':')[1] === network?.id?.toString());
|
|
399
423
|
|
|
400
|
-
|
|
424
|
+
if (addresses.length > 0) {
|
|
425
|
+
addresses.forEach(address => {
|
|
401
426
|
adapter.getBalance({ address, network, tokens: this.config.tokens });
|
|
402
|
-
}
|
|
427
|
+
});
|
|
403
428
|
}
|
|
404
429
|
}
|
|
405
|
-
}
|
|
430
|
+
}
|
|
406
431
|
}
|
|
407
432
|
|
|
408
433
|
private setConnection(
|
|
@@ -457,17 +482,14 @@ export class AppKit {
|
|
|
457
482
|
});
|
|
458
483
|
|
|
459
484
|
adapter.on('chainChanged', ({ chainId }) => {
|
|
485
|
+
//eslint-disable-next-line no-console
|
|
486
|
+
console.log('chainChanged', chainId);
|
|
460
487
|
const namespace = adapter.getSupportedNamespace();
|
|
461
488
|
const chain = `${namespace}:${chainId}` as CaipNetworkId;
|
|
462
489
|
ConnectionsController.setActiveNetwork(namespace, chain);
|
|
463
490
|
|
|
464
491
|
const network = this.networks.find(n => n.id?.toString() === chainId);
|
|
465
|
-
|
|
466
|
-
adapter.getBalance({
|
|
467
|
-
network,
|
|
468
|
-
tokens: this.config.tokens
|
|
469
|
-
});
|
|
470
|
-
}
|
|
492
|
+
this.syncBalances(adapter, network);
|
|
471
493
|
|
|
472
494
|
if (namespace === 'eip155') {
|
|
473
495
|
this.handleSiweChange({ isNetworkChange: true });
|
|
@@ -481,6 +503,8 @@ export class AppKit {
|
|
|
481
503
|
|
|
482
504
|
//TODO: Add types to this events
|
|
483
505
|
adapter.on('balanceChanged', ({ address, balance }) => {
|
|
506
|
+
//eslint-disable-next-line no-console
|
|
507
|
+
console.log('balanceChanged', address, balance);
|
|
484
508
|
const namespace = adapter.getSupportedNamespace();
|
|
485
509
|
ConnectionsController.updateBalance(namespace, address, balance);
|
|
486
510
|
});
|
package/src/AppKitContext.tsx
CHANGED
|
@@ -33,6 +33,7 @@ export const useAppKit = () => {
|
|
|
33
33
|
open: context.appKit.open.bind(context.appKit),
|
|
34
34
|
close: context.appKit.close.bind(context.appKit),
|
|
35
35
|
switchNetwork: context.appKit.switchNetwork.bind(context.appKit),
|
|
36
|
-
getProvider: context.appKit.getProvider.bind(context.appKit)
|
|
36
|
+
getProvider: context.appKit.getProvider.bind(context.appKit),
|
|
37
|
+
switchAccountType: context.appKit.switchAccountType.bind(context.appKit)
|
|
37
38
|
};
|
|
38
39
|
};
|
|
@@ -40,7 +40,7 @@ export class WalletConnectConnector extends WalletConnector {
|
|
|
40
40
|
await this.restoreSession();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
override async restoreSession(): Promise<boolean> {
|
|
44
44
|
const provider = this.getProvider() as IUniversalProvider;
|
|
45
45
|
if (!provider) {
|
|
46
46
|
return false;
|
|
@@ -18,14 +18,16 @@ import {
|
|
|
18
18
|
Text,
|
|
19
19
|
ListToken,
|
|
20
20
|
useTheme,
|
|
21
|
-
Spacing
|
|
21
|
+
Spacing,
|
|
22
|
+
LoadingSpinner
|
|
22
23
|
} from '@reown/appkit-ui-react-native';
|
|
23
24
|
|
|
24
25
|
interface Props {
|
|
25
26
|
style?: StyleProp<ViewStyle>;
|
|
27
|
+
isLoading?: boolean;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
export function AccountTokens({ style }: Props) {
|
|
30
|
+
export function AccountTokens({ style, isLoading }: Props) {
|
|
29
31
|
const Theme = useTheme();
|
|
30
32
|
const [refreshing, setRefreshing] = useState(false);
|
|
31
33
|
const { activeNetwork, balances } = useSnapshot(ConnectionsController.state);
|
|
@@ -46,21 +48,24 @@ export function AccountTokens({ style }: Props) {
|
|
|
46
48
|
|
|
47
49
|
if (!filteredBalances?.length) {
|
|
48
50
|
return (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
<>
|
|
52
|
+
<ListItem
|
|
53
|
+
icon="arrowBottomCircle"
|
|
54
|
+
iconColor="magenta-100"
|
|
55
|
+
onPress={onReceivePress}
|
|
56
|
+
style={styles.receiveButton}
|
|
57
|
+
>
|
|
58
|
+
<FlexView flexDirection="column" alignItems="flex-start">
|
|
59
|
+
<Text variant="paragraph-500" color="fg-100">
|
|
60
|
+
Receive funds
|
|
61
|
+
</Text>
|
|
62
|
+
<Text variant="small-400" color="fg-200">
|
|
63
|
+
Transfer tokens on your wallet
|
|
64
|
+
</Text>
|
|
65
|
+
</FlexView>
|
|
66
|
+
</ListItem>
|
|
67
|
+
{isLoading && <LoadingSpinner size="sm" style={styles.loadingSpinner} />}
|
|
68
|
+
</>
|
|
64
69
|
);
|
|
65
70
|
}
|
|
66
71
|
|
|
@@ -70,7 +75,7 @@ export function AccountTokens({ style }: Props) {
|
|
|
70
75
|
style={style}
|
|
71
76
|
refreshControl={
|
|
72
77
|
<RefreshControl
|
|
73
|
-
refreshing={refreshing}
|
|
78
|
+
refreshing={isLoading || refreshing}
|
|
74
79
|
onRefresh={onRefresh}
|
|
75
80
|
tintColor={Theme['accent-100']}
|
|
76
81
|
colors={[Theme['accent-100']]}
|
|
@@ -97,5 +102,8 @@ const styles = StyleSheet.create({
|
|
|
97
102
|
receiveButton: {
|
|
98
103
|
width: 'auto',
|
|
99
104
|
marginHorizontal: Spacing.s
|
|
105
|
+
},
|
|
106
|
+
loadingSpinner: {
|
|
107
|
+
marginTop: Spacing.m
|
|
100
108
|
}
|
|
101
109
|
});
|
|
@@ -17,10 +17,10 @@ import { AccountTokens } from '../w3m-account-tokens';
|
|
|
17
17
|
import styles from './styles';
|
|
18
18
|
|
|
19
19
|
export interface AccountWalletFeaturesProps {
|
|
20
|
-
|
|
20
|
+
isBalanceLoading: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function AccountWalletFeatures() {
|
|
23
|
+
export function AccountWalletFeatures({ isBalanceLoading }: AccountWalletFeaturesProps) {
|
|
24
24
|
const [activeTab, setActiveTab] = useState(0);
|
|
25
25
|
const { features, isOnRampEnabled } = useSnapshot(OptionsController.state);
|
|
26
26
|
const { activeNetwork, balances } = useSnapshot(ConnectionsController.state);
|
|
@@ -137,7 +137,9 @@ export function AccountWalletFeatures() {
|
|
|
137
137
|
<Tabs tabs={['Tokens', 'Activity']} onTabChange={onTabChange} />
|
|
138
138
|
</FlexView>
|
|
139
139
|
<FlexView padding={['m', '0', '0', '0']} style={styles.tabContainer}>
|
|
140
|
-
{activeTab === 0 &&
|
|
140
|
+
{activeTab === 0 && (
|
|
141
|
+
<AccountTokens style={styles.tabContent} isLoading={isBalanceLoading} />
|
|
142
|
+
)}
|
|
141
143
|
{activeTab === 1 && <AccountActivity style={styles.tabContent} />}
|
|
142
144
|
</FlexView>
|
|
143
145
|
</FlexView>
|
|
@@ -41,9 +41,9 @@ export function SendInputToken({
|
|
|
41
41
|
const onMaxPress = () => {
|
|
42
42
|
if (token?.quantity && gasPrice) {
|
|
43
43
|
const isNetworkToken =
|
|
44
|
-
token.
|
|
44
|
+
token.address === undefined ||
|
|
45
45
|
Object.values(ConstantsUtil.NATIVE_TOKEN_ADDRESS).some(
|
|
46
|
-
nativeAddress => token?.
|
|
46
|
+
nativeAddress => token?.address?.split(':')[2] === nativeAddress
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const numericGas = NumberUtil.bigNumber(gasPrice).shiftedBy(-token.quantity.decimals);
|
|
@@ -34,6 +34,7 @@ import { AuthButtons } from './components/auth-buttons';
|
|
|
34
34
|
import styles from './styles';
|
|
35
35
|
|
|
36
36
|
export function AccountDefaultView() {
|
|
37
|
+
const { switchAccountType, disconnect } = useAppKit();
|
|
37
38
|
const { profileName, profileImage } = useSnapshot(AccountController.state);
|
|
38
39
|
const { loading } = useSnapshot(ModalController.state);
|
|
39
40
|
const {
|
|
@@ -50,14 +51,13 @@ export function AccountDefaultView() {
|
|
|
50
51
|
const { history } = useSnapshot(RouterController.state);
|
|
51
52
|
const networkImage = AssetUtil.getNetworkImage(activeNetwork?.id);
|
|
52
53
|
const showCopy = OptionsController.isClipboardAvailable();
|
|
53
|
-
const isAuth = connection?.properties?.
|
|
54
|
+
const isAuth = !!connection?.properties?.provider;
|
|
54
55
|
const showBalance = balance && !isAuth;
|
|
55
56
|
const showExplorer = Object.keys(activeNetwork?.blockExplorers ?? {}).length > 0 && !isAuth;
|
|
56
57
|
const showBack = history.length > 1;
|
|
57
|
-
const showSwitchAccountType = isAuth;
|
|
58
|
+
const showSwitchAccountType = isAuth && activeNamespace === 'eip155';
|
|
58
59
|
const showActivity =
|
|
59
60
|
!isAuth &&
|
|
60
|
-
activeNamespace &&
|
|
61
61
|
activeNetwork?.caipNetworkId &&
|
|
62
62
|
ConstantsUtil.ACTIVITY_SUPPORTED_CHAINS.includes(activeNetwork.caipNetworkId);
|
|
63
63
|
const showSwaps =
|
|
@@ -66,7 +66,6 @@ export function AccountDefaultView() {
|
|
|
66
66
|
activeNetwork?.caipNetworkId &&
|
|
67
67
|
ConstantsUtil.SWAP_SUPPORTED_NETWORKS.includes(activeNetwork.caipNetworkId);
|
|
68
68
|
const { padding } = useCustomDimensions();
|
|
69
|
-
const { disconnect } = useAppKit();
|
|
70
69
|
|
|
71
70
|
async function onDisconnect() {
|
|
72
71
|
setDisconnecting(true);
|
|
@@ -76,26 +75,13 @@ export function AccountDefaultView() {
|
|
|
76
75
|
|
|
77
76
|
const onSwitchAccountType = async () => {
|
|
78
77
|
try {
|
|
79
|
-
|
|
78
|
+
const namespace = ConnectionsController.state.activeNamespace;
|
|
79
|
+
const network = ConnectionsController.state.activeNetwork;
|
|
80
|
+
if (isAuth && namespace && network) {
|
|
80
81
|
const newType = ConnectionsController.state.accountType === 'eoa' ? 'smartAccount' : 'eoa';
|
|
81
|
-
|
|
82
|
-
ConnectionsController.state.activeNamespace,
|
|
83
|
-
ConnectionsController.state.accountType === 'eoa' ? 'smartAccount' : 'eoa'
|
|
84
|
-
);
|
|
85
|
-
ConnectionsController.fetchBalance();
|
|
86
|
-
|
|
87
|
-
EventsController.sendEvent({
|
|
88
|
-
type: 'track',
|
|
89
|
-
event: 'SET_PREFERRED_ACCOUNT_TYPE',
|
|
90
|
-
properties: {
|
|
91
|
-
// eslint-disable-next-line valtio/state-snapshot-rule
|
|
92
|
-
accountType: newType,
|
|
93
|
-
network: ConnectionsController.state.activeNetwork?.caipNetworkId || ''
|
|
94
|
-
}
|
|
95
|
-
});
|
|
82
|
+
switchAccountType(namespace, newType, network);
|
|
96
83
|
}
|
|
97
84
|
} catch (error) {
|
|
98
|
-
ModalController.setLoading(false);
|
|
99
85
|
SnackController.showError('Error switching account type');
|
|
100
86
|
}
|
|
101
87
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useSnapshot } from 'valtio';
|
|
2
|
-
import { useEffect } from 'react';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import { ScrollView } from 'react-native';
|
|
4
4
|
import {
|
|
5
5
|
AccountPill,
|
|
@@ -25,6 +25,7 @@ import styles from './styles';
|
|
|
25
25
|
|
|
26
26
|
export function AccountView() {
|
|
27
27
|
const Theme = useTheme();
|
|
28
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
28
29
|
const { padding } = useCustomDimensions();
|
|
29
30
|
const { activeNetwork, activeAddress } = useSnapshot(ConnectionsController.state);
|
|
30
31
|
const address = CoreHelperUtil.getPlainAddress(activeAddress);
|
|
@@ -38,15 +39,17 @@ export function AccountView() {
|
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
useEffect(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
async function fetchBalance() {
|
|
43
|
+
setIsLoading(true);
|
|
44
|
+
await ConnectionsController.fetchBalance();
|
|
45
|
+
setIsLoading(false);
|
|
46
|
+
}
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
fetchBalance();
|
|
49
|
+
SendController.resetSend();
|
|
47
50
|
|
|
48
51
|
const balanceInterval = setInterval(() => {
|
|
49
|
-
|
|
52
|
+
fetchBalance();
|
|
50
53
|
}, 10000);
|
|
51
54
|
|
|
52
55
|
return () => {
|
|
@@ -82,7 +85,7 @@ export function AccountView() {
|
|
|
82
85
|
onPress={onProfilePress}
|
|
83
86
|
style={styles.accountPill}
|
|
84
87
|
/>
|
|
85
|
-
<AccountWalletFeatures />
|
|
88
|
+
<AccountWalletFeatures isBalanceLoading={isLoading} />
|
|
86
89
|
</FlexView>
|
|
87
90
|
</ScrollView>
|
|
88
91
|
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable valtio/state-snapshot-rule */
|
|
2
1
|
import { useSnapshot } from 'valtio';
|
|
3
2
|
import { useEffect, useState } from 'react';
|
|
4
3
|
import {
|
|
@@ -6,9 +5,6 @@ import {
|
|
|
6
5
|
AssetUtil,
|
|
7
6
|
ConnectionController,
|
|
8
7
|
ConnectionsController,
|
|
9
|
-
ConnectorController,
|
|
10
|
-
EventsController,
|
|
11
|
-
NetworkController,
|
|
12
8
|
RouterController,
|
|
13
9
|
RouterUtil
|
|
14
10
|
} from '@reown/appkit-core-react-native';
|
|
@@ -20,30 +16,27 @@ import {
|
|
|
20
16
|
NetworkImage,
|
|
21
17
|
Text
|
|
22
18
|
} from '@reown/appkit-ui-react-native';
|
|
19
|
+
import { useAppKit } from '../../AppKitContext';
|
|
23
20
|
import styles from './styles';
|
|
24
21
|
|
|
25
22
|
export function NetworkSwitchView() {
|
|
23
|
+
const { switchNetwork } = useAppKit();
|
|
26
24
|
const { data } = useSnapshot(RouterController.state);
|
|
27
25
|
const { recentWallets } = useSnapshot(ConnectionController.state);
|
|
28
26
|
const { activeNetwork } = useSnapshot(ConnectionsController.state);
|
|
29
|
-
const isAuthConnected = ConnectorController.state.connectedConnector === 'AUTH';
|
|
30
27
|
const [error, setError] = useState<boolean>(false);
|
|
31
28
|
const [showRetry, setShowRetry] = useState<boolean>(false);
|
|
32
|
-
const network = data?.network
|
|
29
|
+
const network = data?.network;
|
|
33
30
|
const wallet = recentWallets?.[0];
|
|
34
31
|
|
|
35
32
|
const onSwitchNetwork = async () => {
|
|
36
33
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
properties: {
|
|
44
|
-
network: network.id
|
|
45
|
-
}
|
|
46
|
-
});
|
|
34
|
+
if (network) {
|
|
35
|
+
setError(false);
|
|
36
|
+
const _network = ConnectionsController.state.networks.find(n => n.id === network.id);
|
|
37
|
+
if (!_network) return;
|
|
38
|
+
await switchNetwork(_network);
|
|
39
|
+
}
|
|
47
40
|
} catch {
|
|
48
41
|
setError(true);
|
|
49
42
|
setShowRetry(true);
|
|
@@ -57,9 +50,12 @@ export function NetworkSwitchView() {
|
|
|
57
50
|
|
|
58
51
|
useEffect(() => {
|
|
59
52
|
// Go back if network is already switched
|
|
53
|
+
// eslint-disable-next-line valtio/state-snapshot-rule
|
|
60
54
|
if (activeNetwork?.id === network?.id) {
|
|
61
55
|
RouterUtil.navigateAfterNetworkSwitch();
|
|
62
56
|
}
|
|
57
|
+
|
|
58
|
+
// eslint-disable-next-line valtio/state-snapshot-rule
|
|
63
59
|
}, [activeNetwork?.id, network?.id]);
|
|
64
60
|
|
|
65
61
|
const retryTemplate = () => {
|
|
@@ -95,14 +91,6 @@ export function NetworkSwitchView() {
|
|
|
95
91
|
);
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
if (isAuthConnected) {
|
|
99
|
-
return (
|
|
100
|
-
<Text variant="paragraph-500" style={styles.text}>
|
|
101
|
-
Switching to {network.name} network
|
|
102
|
-
</Text>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
94
|
return (
|
|
107
95
|
<>
|
|
108
96
|
<Text variant="paragraph-500" style={styles.text}>{`Approve in ${walletName}`}</Text>
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { SwapController, type SwapTokenWithBalance } from '@reown/appkit-core-react-native';
|
|
2
2
|
|
|
3
|
-
export function filterTokens(tokens
|
|
3
|
+
export function filterTokens(tokens?: SwapTokenWithBalance[], searchValue?: string) {
|
|
4
|
+
if (!tokens) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
if (!searchValue) {
|
|
5
9
|
return tokens;
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
return tokens.filter(
|
|
9
13
|
token =>
|
|
10
|
-
token.name
|
|
14
|
+
token.name?.toLowerCase().includes(searchValue.toLowerCase()) ||
|
|
11
15
|
token.symbol.toLowerCase().includes(searchValue.toLowerCase())
|
|
12
16
|
);
|
|
13
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetUtil } from '@reown/appkit-core-react-native';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppKitNetwork } from '@reown/appkit-common-react-native';
|
|
3
3
|
import {
|
|
4
4
|
BorderRadius,
|
|
5
5
|
FlexView,
|
|
@@ -14,7 +14,7 @@ import { StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
|
|
|
14
14
|
export interface PreviewSendDetailsProps {
|
|
15
15
|
address?: string;
|
|
16
16
|
name?: string;
|
|
17
|
-
|
|
17
|
+
activeNetwork?: AppKitNetwork;
|
|
18
18
|
networkFee?: number;
|
|
19
19
|
style?: StyleProp<ViewStyle>;
|
|
20
20
|
}
|
|
@@ -22,7 +22,7 @@ export interface PreviewSendDetailsProps {
|
|
|
22
22
|
export function PreviewSendDetails({
|
|
23
23
|
address,
|
|
24
24
|
name,
|
|
25
|
-
|
|
25
|
+
activeNetwork,
|
|
26
26
|
networkFee,
|
|
27
27
|
style
|
|
28
28
|
}: PreviewSendDetailsProps) {
|
|
@@ -42,7 +42,7 @@ export function PreviewSendDetails({
|
|
|
42
42
|
truncate: 'middle'
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
const networkImage = AssetUtil.getNetworkImage(
|
|
45
|
+
const networkImage = AssetUtil.getNetworkImage(activeNetwork?.id);
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<FlexView
|
|
@@ -3,7 +3,7 @@ import { ScrollView } from 'react-native';
|
|
|
3
3
|
import { Avatar, Button, FlexView, Icon, Image, Text, UiUtil } from '@reown/appkit-ui-react-native';
|
|
4
4
|
import { NumberUtil } from '@reown/appkit-common-react-native';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
ConnectionsController,
|
|
7
7
|
RouterController,
|
|
8
8
|
SendController
|
|
9
9
|
} from '@reown/appkit-core-react-native';
|
|
@@ -14,7 +14,7 @@ import { PreviewSendDetails } from './components/preview-send-details';
|
|
|
14
14
|
|
|
15
15
|
export function WalletSendPreviewView() {
|
|
16
16
|
const { padding } = useCustomDimensions();
|
|
17
|
-
const {
|
|
17
|
+
const { activeNetwork } = useSnapshot(ConnectionsController.state);
|
|
18
18
|
const {
|
|
19
19
|
token,
|
|
20
20
|
receiverAddress,
|
|
@@ -112,7 +112,7 @@ export function WalletSendPreviewView() {
|
|
|
112
112
|
networkFee={gasPriceInUSD}
|
|
113
113
|
address={receiverAddress}
|
|
114
114
|
name={receiverProfileName}
|
|
115
|
-
|
|
115
|
+
activeNetwork={activeNetwork}
|
|
116
116
|
/>
|
|
117
117
|
<FlexView flexDirection="row" alignItems="center" justifyContent="center">
|
|
118
118
|
<Icon name="warningCircle" size="sm" color="fg-200" style={styles.reviewIcon} />
|
|
@@ -65,7 +65,7 @@ export function WalletSendSelectTokenView() {
|
|
|
65
65
|
amount={_token.quantity?.numeric || '0'}
|
|
66
66
|
currency={_token.symbol}
|
|
67
67
|
onPress={() => onTokenPress(_token)}
|
|
68
|
-
disabled={_token.
|
|
68
|
+
disabled={_token.address === token?.address}
|
|
69
69
|
/>
|
|
70
70
|
))
|
|
71
71
|
) : (
|