@reown/appkit-react-native 0.0.0-develop-20251008155354 → 0.0.0-develop-20251030154825
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 +20 -6
- package/lib/commonjs/AppKit.js.map +1 -1
- package/lib/commonjs/hooks/useAccount.js +65 -2
- package/lib/commonjs/hooks/useAccount.js.map +1 -1
- package/lib/commonjs/partials/w3m-send-input-token/index.js +6 -3
- package/lib/commonjs/partials/w3m-send-input-token/index.js.map +1 -1
- package/lib/commonjs/partials/w3m-swap-input/index.js +6 -3
- package/lib/commonjs/partials/w3m-swap-input/index.js.map +1 -1
- package/lib/commonjs/views/w3m-account-default-view/index.js +2 -1
- package/lib/commonjs/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-onramp-settings-view/index.js +2 -0
- package/lib/commonjs/views/w3m-onramp-settings-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-onramp-view/index.js +3 -2
- package/lib/commonjs/views/w3m-onramp-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-swap-view/components/select-token-modal/index.js +2 -1
- package/lib/commonjs/views/w3m-swap-view/components/select-token-modal/index.js.map +1 -1
- package/lib/commonjs/views/w3m-swap-view/index.js +4 -2
- package/lib/commonjs/views/w3m-swap-view/index.js.map +1 -1
- package/lib/commonjs/views/w3m-wallet-send-view/index.js +2 -1
- package/lib/commonjs/views/w3m-wallet-send-view/index.js.map +1 -1
- package/lib/module/AppKit.js +20 -6
- package/lib/module/AppKit.js.map +1 -1
- package/lib/module/hooks/useAccount.js +66 -2
- package/lib/module/hooks/useAccount.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/partials/w3m-send-input-token/index.js +6 -3
- package/lib/module/partials/w3m-send-input-token/index.js.map +1 -1
- package/lib/module/partials/w3m-swap-input/index.js +6 -3
- package/lib/module/partials/w3m-swap-input/index.js.map +1 -1
- package/lib/module/views/w3m-account-default-view/index.js +2 -1
- package/lib/module/views/w3m-account-default-view/index.js.map +1 -1
- package/lib/module/views/w3m-onramp-settings-view/index.js +2 -0
- package/lib/module/views/w3m-onramp-settings-view/index.js.map +1 -1
- package/lib/module/views/w3m-onramp-view/index.js +3 -2
- package/lib/module/views/w3m-onramp-view/index.js.map +1 -1
- package/lib/module/views/w3m-swap-view/components/select-token-modal/index.js +2 -1
- package/lib/module/views/w3m-swap-view/components/select-token-modal/index.js.map +1 -1
- package/lib/module/views/w3m-swap-view/index.js +4 -2
- package/lib/module/views/w3m-swap-view/index.js.map +1 -1
- package/lib/module/views/w3m-wallet-send-view/index.js +2 -1
- package/lib/module/views/w3m-wallet-send-view/index.js.map +1 -1
- package/lib/typescript/AppKit.d.ts +9 -2
- package/lib/typescript/AppKit.d.ts.map +1 -1
- package/lib/typescript/AppKitContext.d.ts +1 -1
- package/lib/typescript/hooks/useAccount.d.ts +57 -33
- package/lib/typescript/hooks/useAccount.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-send-input-token/index.d.ts +2 -1
- package/lib/typescript/partials/w3m-send-input-token/index.d.ts.map +1 -1
- package/lib/typescript/partials/w3m-swap-input/index.d.ts +2 -1
- package/lib/typescript/partials/w3m-swap-input/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-onramp-settings-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-onramp-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-swap-view/index.d.ts.map +1 -1
- package/lib/typescript/views/w3m-wallet-send-view/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/AppKit.ts +27 -7
- package/src/hooks/useAccount.ts +89 -3
- package/src/index.ts +1 -1
- package/src/partials/w3m-send-input-token/index.tsx +5 -1
- package/src/partials/w3m-swap-input/index.tsx +5 -1
- package/src/views/w3m-account-default-view/index.tsx +6 -1
- package/src/views/w3m-onramp-settings-view/index.tsx +7 -1
- package/src/views/w3m-onramp-view/index.tsx +3 -2
- package/src/views/w3m-swap-view/components/select-token-modal/index.tsx +1 -1
- package/src/views/w3m-swap-view/index.tsx +2 -0
- package/src/views/w3m-wallet-send-view/index.tsx +1 -0
|
@@ -6,6 +6,7 @@ export interface SendInputTokenProps {
|
|
|
6
6
|
style?: StyleProp<ViewStyle>;
|
|
7
7
|
onTokenPress?: () => void;
|
|
8
8
|
loading?: boolean;
|
|
9
|
+
testID?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare function SendInputToken({ token, sendTokenAmount, style, onTokenPress, loading }: SendInputTokenProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function SendInputToken({ token, sendTokenAmount, style, onTokenPress, loading, testID }: SendInputTokenProps): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-send-input-token/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AASzE,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAM7E,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-send-input-token/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AASzE,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAM7E,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,eAAe,EACf,KAAK,EACL,YAAY,EACZ,OAAO,EACP,MAAM,EACP,EAAE,mBAAmB,2CAwFrB"}
|
|
@@ -15,6 +15,7 @@ export interface SwapInputProps {
|
|
|
15
15
|
marketValue?: number;
|
|
16
16
|
editable?: boolean;
|
|
17
17
|
autoFocus?: boolean;
|
|
18
|
+
testID?: string;
|
|
18
19
|
}
|
|
19
|
-
export declare function SwapInput({ token, value, style, loading, loadingValues, onTokenPress, onMaxPress, onChange, marketValue, editable, autoFocus }: SwapInputProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function SwapInput({ token, value, style, loading, loadingValues, onTokenPress, onMaxPress, onChange, marketValue, editable, autoFocus, testID }: SwapInputProps): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-swap-input/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAa,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAYzE,OAAO,EAAc,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE1F,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/partials/w3m-swap-input/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAa,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAYzE,OAAO,EAAc,KAAK,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE1F,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,aAAa,EACb,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,SAAS,EACT,MAAM,EACP,EAAE,cAAc,2CAqHhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-default-view/index.tsx"],"names":[],"mappings":"AAqCA,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-account-default-view/index.tsx"],"names":[],"mappings":"AAqCA,wBAAgB,kBAAkB,4CAkUjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-onramp-settings-view/index.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-onramp-settings-view/index.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,kBAAkB,4CAqIjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-onramp-view/index.tsx"],"names":[],"mappings":"AAuCA,wBAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-onramp-view/index.tsx"],"names":[],"mappings":"AAuCA,wBAAgB,UAAU,4CAuOzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-view/index.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-swap-view/index.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,QAAQ,4CAgMvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-wallet-send-view/index.tsx"],"names":[],"mappings":"AAeA,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/w3m-wallet-send-view/index.tsx"],"names":[],"mappings":"AAeA,wBAAgB,cAAc,4CA0G7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-react-native",
|
|
3
|
-
"version": "0.0.0-develop-
|
|
3
|
+
"version": "0.0.0-develop-20251030154825",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"types": "lib/typescript/index.d.ts",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"provenance": true
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@reown/appkit-common-react-native": "0.0.0-develop-
|
|
43
|
-
"@reown/appkit-core-react-native": "0.0.0-develop-
|
|
44
|
-
"@reown/appkit-ui-react-native": "0.0.0-develop-
|
|
42
|
+
"@reown/appkit-common-react-native": "0.0.0-develop-20251030154825",
|
|
43
|
+
"@reown/appkit-core-react-native": "0.0.0-develop-20251030154825",
|
|
44
|
+
"@reown/appkit-ui-react-native": "0.0.0-develop-20251030154825",
|
|
45
45
|
"@walletconnect/universal-provider": "2.21.10",
|
|
46
46
|
"valtio": "2.1.8"
|
|
47
47
|
},
|
package/src/AppKit.ts
CHANGED
|
@@ -271,29 +271,49 @@ export class AppKit {
|
|
|
271
271
|
return this.networks;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
/**
|
|
275
|
+
* Switches to a different network.
|
|
276
|
+
* @param network - Either an AppKitNetwork object or a CAIP network ID string (e.g., 'eip155:1')
|
|
277
|
+
* @throws {Error} When the network is not found in configured networks
|
|
278
|
+
* @throws {Error} When no active adapter is available (only when connected)
|
|
279
|
+
* @returns Promise that resolves when the network switch is complete
|
|
280
|
+
*/
|
|
281
|
+
async switchNetwork(network: AppKitNetwork | CaipNetworkId): Promise<void> {
|
|
275
282
|
const { isConnected } = ConnectionsController.state;
|
|
276
283
|
|
|
284
|
+
const appKitNetwork =
|
|
285
|
+
typeof network === 'string' ? this.networks.find(n => n.caipNetworkId === network) : network;
|
|
286
|
+
|
|
287
|
+
if (!appKitNetwork) {
|
|
288
|
+
const error = new Error(`Network not found: ${network}`);
|
|
289
|
+
LogController.sendError(`Network not found: ${network}`, 'AppKit.ts', 'switchNetwork');
|
|
290
|
+
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
|
|
277
294
|
if (!isConnected) {
|
|
278
|
-
OptionsController.setDefaultNetwork(
|
|
295
|
+
OptionsController.setDefaultNetwork(appKitNetwork);
|
|
279
296
|
|
|
280
|
-
return
|
|
297
|
+
return;
|
|
281
298
|
}
|
|
282
299
|
|
|
283
|
-
const adapter = this.getAdapterByNamespace(
|
|
300
|
+
const adapter = this.getAdapterByNamespace(appKitNetwork.chainNamespace);
|
|
284
301
|
if (!adapter) throw new Error('No active adapter');
|
|
285
302
|
|
|
286
|
-
await adapter.switchNetwork(
|
|
303
|
+
await adapter.switchNetwork(appKitNetwork);
|
|
287
304
|
|
|
288
305
|
EventsController.sendEvent({
|
|
289
306
|
type: 'track',
|
|
290
307
|
event: 'SWITCH_NETWORK',
|
|
291
308
|
properties: {
|
|
292
|
-
network:
|
|
309
|
+
network: appKitNetwork.caipNetworkId
|
|
293
310
|
}
|
|
294
311
|
});
|
|
295
312
|
|
|
296
|
-
ConnectionsController.setActiveNetwork(
|
|
313
|
+
ConnectionsController.setActiveNetwork(
|
|
314
|
+
appKitNetwork.chainNamespace,
|
|
315
|
+
appKitNetwork.caipNetworkId
|
|
316
|
+
);
|
|
297
317
|
}
|
|
298
318
|
|
|
299
319
|
open(options?: AppKitOpenOptions) {
|
package/src/hooks/useAccount.ts
CHANGED
|
@@ -1,9 +1,68 @@
|
|
|
1
1
|
/* eslint-disable valtio/state-snapshot-rule */
|
|
2
|
+
import {
|
|
3
|
+
ConnectionsController,
|
|
4
|
+
CoreHelperUtil,
|
|
5
|
+
LogController
|
|
6
|
+
} from '@reown/appkit-core-react-native';
|
|
2
7
|
import { useMemo } from 'react';
|
|
3
8
|
import { useSnapshot } from 'valtio';
|
|
4
|
-
import { ConnectionsController, CoreHelperUtil } from '@reown/appkit-core-react-native';
|
|
5
9
|
import { useAppKit } from './useAppKit';
|
|
10
|
+
import type { AccountType, AppKitNetwork } from '@reown/appkit-common-react-native';
|
|
6
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Represents a blockchain account with its associated metadata
|
|
14
|
+
*/
|
|
15
|
+
export interface Account {
|
|
16
|
+
/** The blockchain address of the account */
|
|
17
|
+
address: string;
|
|
18
|
+
/** The blockchain namespace (e.g., 'eip155' for Ethereum, 'solana' for Solana) */
|
|
19
|
+
namespace: string;
|
|
20
|
+
/** The chain ID where this account is active */
|
|
21
|
+
chainId: string;
|
|
22
|
+
/** Optional account type (e.g. 'eoa' or 'smartAccount') */
|
|
23
|
+
type?: AccountType;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook to access the current account state and connection information
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* This hook provides access to all connected accounts, the currently active account,
|
|
31
|
+
* connection status, and active chain information. It automatically subscribes to
|
|
32
|
+
* connection state changes via valtio.
|
|
33
|
+
*
|
|
34
|
+
* The hook parses account data from CAIP-10 format (namespace:chainId:address)
|
|
35
|
+
* and provides a normalized structure.
|
|
36
|
+
*
|
|
37
|
+
* @returns An object containing:
|
|
38
|
+
* - `allAccounts` - Array of all connected accounts across all connections
|
|
39
|
+
* - `address` - The plain address of the currently active account (without namespace or chain prefix)
|
|
40
|
+
* - `isConnected` - Boolean indicating if a wallet is currently connected
|
|
41
|
+
* - `chainId` - The ID of the currently active chain
|
|
42
|
+
* - `chain` - The full chain/network object of the currently active chain
|
|
43
|
+
* - `namespace` - The namespace of the currently active account (e.g. 'eip155', 'solana' or 'bip122')
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* function MyComponent() {
|
|
48
|
+
* const { address, isConnected, chainId, allAccounts } = useAccount();
|
|
49
|
+
*
|
|
50
|
+
* if (!isConnected) {
|
|
51
|
+
* return <Text>Not connected</Text>;
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <View>
|
|
56
|
+
* <Text>Connected: {address}</Text>
|
|
57
|
+
* <Text>Chain: {chainId}</Text>
|
|
58
|
+
* <Text>Total accounts: {allAccounts.length}</Text>
|
|
59
|
+
* </View>
|
|
60
|
+
* );
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @throws Will log errors via LogController if account parsing fails
|
|
65
|
+
*/
|
|
7
66
|
export function useAccount() {
|
|
8
67
|
useAppKit(); // Use the hook for checks
|
|
9
68
|
|
|
@@ -11,9 +70,35 @@ export function useAccount() {
|
|
|
11
70
|
activeAddress: address,
|
|
12
71
|
activeNamespace,
|
|
13
72
|
connection,
|
|
73
|
+
connections,
|
|
14
74
|
networks
|
|
15
75
|
} = useSnapshot(ConnectionsController.state);
|
|
16
76
|
|
|
77
|
+
const allAccounts: Account[] = useMemo(() => {
|
|
78
|
+
return Array.from(connections.values()).flatMap(
|
|
79
|
+
_connection =>
|
|
80
|
+
_connection.accounts
|
|
81
|
+
.map(account => {
|
|
82
|
+
const [namespace, chainId, plainAddress] = account.split(':');
|
|
83
|
+
if (!plainAddress || !namespace || !chainId) {
|
|
84
|
+
LogController.sendError('Invalid account', 'useAccount.ts', 'useAccount', {
|
|
85
|
+
account
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
address: plainAddress,
|
|
93
|
+
namespace,
|
|
94
|
+
chainId,
|
|
95
|
+
type: _connection.type
|
|
96
|
+
};
|
|
97
|
+
})
|
|
98
|
+
.filter(account => account !== undefined) as Account[]
|
|
99
|
+
);
|
|
100
|
+
}, [connections]);
|
|
101
|
+
|
|
17
102
|
const activeChain = useMemo(
|
|
18
103
|
() =>
|
|
19
104
|
connection?.caipNetwork
|
|
@@ -23,10 +108,11 @@ export function useAccount() {
|
|
|
23
108
|
);
|
|
24
109
|
|
|
25
110
|
return {
|
|
111
|
+
allAccounts,
|
|
26
112
|
address: CoreHelperUtil.getPlainAddress(address),
|
|
27
113
|
isConnected: !!address,
|
|
28
|
-
chainId: activeChain?.id,
|
|
29
|
-
chain: activeChain,
|
|
114
|
+
chainId: activeChain?.id !== undefined ? String(activeChain.id) : undefined,
|
|
115
|
+
chain: activeChain as AppKitNetwork | undefined,
|
|
30
116
|
namespace: activeNamespace
|
|
31
117
|
};
|
|
32
118
|
}
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type { AppKitConfig } from './types';
|
|
|
31
31
|
/****** Hooks *******/
|
|
32
32
|
export { useAppKit } from './hooks/useAppKit';
|
|
33
33
|
export { useProvider } from './hooks/useProvider';
|
|
34
|
-
export { useAccount } from './hooks/useAccount';
|
|
34
|
+
export { useAccount, type Account as UseAccountReturn } from './hooks/useAccount';
|
|
35
35
|
export { useWalletInfo } from './hooks/useWalletInfo';
|
|
36
36
|
export { useAppKitEvents, useAppKitEventSubscription } from './hooks/useAppKitEvents';
|
|
37
37
|
export { useAppKitState } from './hooks/useAppKitState';
|
|
@@ -20,6 +20,7 @@ export interface SendInputTokenProps {
|
|
|
20
20
|
style?: StyleProp<ViewStyle>;
|
|
21
21
|
onTokenPress?: () => void;
|
|
22
22
|
loading?: boolean;
|
|
23
|
+
testID?: string;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export function SendInputToken({
|
|
@@ -27,7 +28,8 @@ export function SendInputToken({
|
|
|
27
28
|
sendTokenAmount,
|
|
28
29
|
style,
|
|
29
30
|
onTokenPress,
|
|
30
|
-
loading
|
|
31
|
+
loading,
|
|
32
|
+
testID
|
|
31
33
|
}: SendInputTokenProps) {
|
|
32
34
|
const Theme = useTheme();
|
|
33
35
|
const valueInputRef = useRef<TextInput | null>(null);
|
|
@@ -86,12 +88,14 @@ export function SendInputToken({
|
|
|
86
88
|
selectTextOnFocus={false}
|
|
87
89
|
numberOfLines={1}
|
|
88
90
|
autoFocus={!!token}
|
|
91
|
+
testID={testID}
|
|
89
92
|
/>
|
|
90
93
|
<TokenButton
|
|
91
94
|
imageUrl={token?.iconUrl}
|
|
92
95
|
text={token?.symbol}
|
|
93
96
|
onPress={onTokenPress}
|
|
94
97
|
chevron
|
|
98
|
+
testID={testID ? `${testID}-button` : undefined}
|
|
95
99
|
/>
|
|
96
100
|
</FlexView>
|
|
97
101
|
{token ? (
|
|
@@ -28,6 +28,7 @@ export interface SwapInputProps {
|
|
|
28
28
|
marketValue?: number;
|
|
29
29
|
editable?: boolean;
|
|
30
30
|
autoFocus?: boolean;
|
|
31
|
+
testID?: string;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const MINIMUM_USD_VALUE_TO_CONVERT = 0.00005;
|
|
@@ -43,7 +44,8 @@ export function SwapInput({
|
|
|
43
44
|
onChange,
|
|
44
45
|
marketValue,
|
|
45
46
|
editable,
|
|
46
|
-
autoFocus
|
|
47
|
+
autoFocus,
|
|
48
|
+
testID
|
|
47
49
|
}: SwapInputProps) {
|
|
48
50
|
const Theme = useTheme();
|
|
49
51
|
const valueInputRef = useRef<TextInput | null>(null);
|
|
@@ -118,6 +120,7 @@ export function SwapInput({
|
|
|
118
120
|
numberOfLines={1}
|
|
119
121
|
editable={editable}
|
|
120
122
|
autoFocus={autoFocus}
|
|
123
|
+
testID={testID}
|
|
121
124
|
/>
|
|
122
125
|
)}
|
|
123
126
|
<TokenButton
|
|
@@ -125,6 +128,7 @@ export function SwapInput({
|
|
|
125
128
|
imageUrl={token?.logoUri}
|
|
126
129
|
onPress={onTokenPress}
|
|
127
130
|
chevron
|
|
131
|
+
testID={testID ? `${testID}-button` : undefined}
|
|
128
132
|
/>
|
|
129
133
|
</FlexView>
|
|
130
134
|
{loadingValues ? (
|
|
@@ -186,7 +186,12 @@ export function AccountDefaultView() {
|
|
|
186
186
|
return (
|
|
187
187
|
<>
|
|
188
188
|
{showBack ? (
|
|
189
|
-
<IconLink
|
|
189
|
+
<IconLink
|
|
190
|
+
icon="chevronLeft"
|
|
191
|
+
style={styles.backIcon}
|
|
192
|
+
onPress={RouterController.goBack}
|
|
193
|
+
testID="header-back"
|
|
194
|
+
/>
|
|
190
195
|
) : null}
|
|
191
196
|
<IconLink
|
|
192
197
|
icon="close"
|
|
@@ -90,6 +90,7 @@ export function OnRampSettingsView() {
|
|
|
90
90
|
chevron
|
|
91
91
|
style={styles.firstItem}
|
|
92
92
|
contentStyle={styles.listItem}
|
|
93
|
+
testID="button-select-country"
|
|
93
94
|
>
|
|
94
95
|
<FlexView
|
|
95
96
|
alignItems="center"
|
|
@@ -111,7 +112,12 @@ export function OnRampSettingsView() {
|
|
|
111
112
|
) : null}
|
|
112
113
|
</FlexView>
|
|
113
114
|
</ListItem>
|
|
114
|
-
<ListItem
|
|
115
|
+
<ListItem
|
|
116
|
+
onPress={onPaymentCurrencyPress}
|
|
117
|
+
chevron
|
|
118
|
+
contentStyle={styles.listItem}
|
|
119
|
+
testID="button-select-currency"
|
|
120
|
+
>
|
|
115
121
|
<FlexView
|
|
116
122
|
alignItems="center"
|
|
117
123
|
justifyContent="center"
|
|
@@ -61,6 +61,7 @@ export function OnRampView() {
|
|
|
61
61
|
const purchaseCurrencyCode =
|
|
62
62
|
purchaseCurrency?.currencyCode?.split('_')[0] ?? purchaseCurrency?.currencyCode;
|
|
63
63
|
const networkImage = AssetUtil.getNetworkImage(activeNetwork, networkImages);
|
|
64
|
+
const isContinueDisabled = quotesLoading || loading || !selectedQuote;
|
|
64
65
|
|
|
65
66
|
const getQuotes = useCallback(() => {
|
|
66
67
|
if (OnRampController.canGenerateQuote()) {
|
|
@@ -240,8 +241,8 @@ export function OnRampView() {
|
|
|
240
241
|
<Button
|
|
241
242
|
style={styles.continueButton}
|
|
242
243
|
onPress={handleContinue}
|
|
243
|
-
disabled={
|
|
244
|
-
testID=
|
|
244
|
+
disabled={isContinueDisabled}
|
|
245
|
+
testID={`button-continue${isContinueDisabled ? '-disabled' : '-enabled'}`}
|
|
245
246
|
>
|
|
246
247
|
Continue
|
|
247
248
|
</Button>
|
|
@@ -98,7 +98,7 @@ export function SwapSelectTokenModal({ onClose, type, style, visible }: Props) {
|
|
|
98
98
|
alignItems="center"
|
|
99
99
|
padding={['0', 'm', 'm', 'm']}
|
|
100
100
|
>
|
|
101
|
-
<IconLink icon="chevronLeft" size="md" onPress={onClose} />
|
|
101
|
+
<IconLink icon="chevronLeft" size="md" onPress={onClose} testID="button-back" />
|
|
102
102
|
<Text variant="paragraph-600">Select token</Text>
|
|
103
103
|
<View style={styles.iconPlaceholder} />
|
|
104
104
|
</FlexView>
|
|
@@ -174,6 +174,7 @@ export function SwapView() {
|
|
|
174
174
|
onChange={onSourceTokenChange}
|
|
175
175
|
onTokenPress={() => setShowModal('sourceToken')}
|
|
176
176
|
onMaxPress={onSourceMaxPress}
|
|
177
|
+
testID="swap-input-source"
|
|
177
178
|
/>
|
|
178
179
|
<FlexView alignItems="center" justifyContent="center" style={styles.bottomInputContainer}>
|
|
179
180
|
<SwapInput
|
|
@@ -186,6 +187,7 @@ export function SwapView() {
|
|
|
186
187
|
onChange={onToTokenChange}
|
|
187
188
|
onTokenPress={() => setShowModal('toToken')}
|
|
188
189
|
editable={false}
|
|
190
|
+
testID="swap-input-to"
|
|
189
191
|
/>
|
|
190
192
|
{showSwitch ? (
|
|
191
193
|
<IconLink
|
|
@@ -92,6 +92,7 @@ export function WalletSendView() {
|
|
|
92
92
|
style={styles.tokenInput}
|
|
93
93
|
onTokenPress={() => RouterController.push('WalletSendSelectToken')}
|
|
94
94
|
loading={isBalanceLoading}
|
|
95
|
+
testID="send-input-token"
|
|
95
96
|
/>
|
|
96
97
|
<FlexView alignItems="center" justifyContent="center" style={styles.addressContainer}>
|
|
97
98
|
<SendInputAddress value={receiverProfileName || receiverAddress} />
|