@reown/appkit-core-react-native 0.0.0-fix-token-balance-20241017200828 → 0.0.0-fix-fetch-error-improvements-20241114122508
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/AccountController.js +11 -1
- package/lib/commonjs/controllers/AccountController.js.map +1 -1
- package/lib/commonjs/controllers/ApiController.js +13 -6
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionController.js +11 -7
- package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectorController.js +9 -1
- package/lib/commonjs/controllers/ConnectorController.js.map +1 -1
- package/lib/commonjs/controllers/NetworkController.js +17 -1
- package/lib/commonjs/controllers/NetworkController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +13 -1
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SendController.js +4 -4
- package/lib/commonjs/controllers/SendController.js.map +1 -1
- package/lib/commonjs/controllers/SnackController.js +21 -1
- package/lib/commonjs/controllers/SnackController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +2 -1
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
- package/lib/commonjs/controllers/WebviewController.js +52 -0
- package/lib/commonjs/controllers/WebviewController.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +7 -1
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js +24 -0
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/module/controllers/AccountController.js +11 -1
- package/lib/module/controllers/AccountController.js.map +1 -1
- package/lib/module/controllers/ApiController.js +13 -6
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionController.js +11 -7
- package/lib/module/controllers/ConnectionController.js.map +1 -1
- package/lib/module/controllers/ConnectorController.js +9 -1
- package/lib/module/controllers/ConnectorController.js.map +1 -1
- package/lib/module/controllers/NetworkController.js +17 -1
- package/lib/module/controllers/NetworkController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +13 -1
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SendController.js +4 -4
- package/lib/module/controllers/SendController.js.map +1 -1
- package/lib/module/controllers/SnackController.js +21 -1
- package/lib/module/controllers/SnackController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +2 -1
- package/lib/module/controllers/TransactionsController.js.map +1 -1
- package/lib/module/controllers/WebviewController.js +47 -0
- package/lib/module/controllers/WebviewController.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +7 -1
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/StorageUtil.js +24 -0
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/typescript/controllers/AccountController.d.ts +5 -1
- package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
- package/lib/typescript/controllers/ApiController.d.ts +2 -1
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionController.d.ts +3 -0
- package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectorController.d.ts +1 -1
- package/lib/typescript/controllers/ConnectorController.d.ts.map +1 -1
- package/lib/typescript/controllers/NetworkController.d.ts +4 -0
- package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +6 -2
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +3 -1
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- package/lib/typescript/controllers/SnackController.d.ts +7 -0
- package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
- package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/WebviewController.d.ts +21 -0
- package/lib/typescript/controllers/WebviewController.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +2 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts +1 -0
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +5 -1
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +106 -4
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/controllers/AccountController.ts +16 -2
- package/src/controllers/ApiController.ts +24 -16
- package/src/controllers/ConnectionController.ts +15 -7
- package/src/controllers/ConnectorController.ts +13 -1
- package/src/controllers/NetworkController.ts +28 -1
- package/src/controllers/OptionsController.ts +24 -3
- package/src/controllers/RouterController.ts +7 -0
- package/src/controllers/SendController.ts +4 -4
- package/src/controllers/SnackController.ts +28 -1
- package/src/controllers/TransactionsController.ts +2 -1
- package/src/controllers/WebviewController.ts +63 -0
- package/src/index.ts +2 -0
- package/src/utils/ConstantsUtil.ts +11 -1
- package/src/utils/StorageUtil.ts +31 -1
- package/src/utils/TypeUtil.ts +105 -4
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { proxy, ref } from 'valtio';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
CustomWallet,
|
|
4
|
+
Features,
|
|
5
|
+
Metadata,
|
|
6
|
+
ProjectId,
|
|
7
|
+
SdkType,
|
|
8
|
+
SdkVersion,
|
|
9
|
+
Tokens
|
|
10
|
+
} from '../utils/TypeUtil';
|
|
11
|
+
import { ConstantsUtil } from '../utils/ConstantsUtil';
|
|
3
12
|
|
|
4
13
|
// -- Types --------------------------------------------- //
|
|
5
14
|
export interface ClipboardClient {
|
|
@@ -15,17 +24,21 @@ export interface OptionsControllerState {
|
|
|
15
24
|
customWallets?: CustomWallet[];
|
|
16
25
|
tokens?: Tokens;
|
|
17
26
|
enableAnalytics?: boolean;
|
|
18
|
-
sdkType:
|
|
27
|
+
sdkType: SdkType;
|
|
19
28
|
sdkVersion: SdkVersion;
|
|
20
29
|
metadata?: Metadata;
|
|
21
30
|
isSiweEnabled?: boolean;
|
|
31
|
+
features?: Features;
|
|
32
|
+
debug?: boolean;
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
// -- State --------------------------------------------- //
|
|
25
36
|
const state = proxy<OptionsControllerState>({
|
|
26
37
|
projectId: '',
|
|
27
38
|
sdkType: 'appkit',
|
|
28
|
-
sdkVersion: 'react-native-wagmi-undefined'
|
|
39
|
+
sdkVersion: 'react-native-wagmi-undefined',
|
|
40
|
+
features: ConstantsUtil.DEFAULT_FEATURES,
|
|
41
|
+
debug: false
|
|
29
42
|
});
|
|
30
43
|
|
|
31
44
|
// -- Controller ---------------------------------------- //
|
|
@@ -76,6 +89,14 @@ export const OptionsController = {
|
|
|
76
89
|
state.isSiweEnabled = isSiweEnabled;
|
|
77
90
|
},
|
|
78
91
|
|
|
92
|
+
setFeatures(features: OptionsControllerState['features']) {
|
|
93
|
+
state.features = { ...ConstantsUtil.DEFAULT_FEATURES, ...features };
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
setDebug(debug: OptionsControllerState['debug']) {
|
|
97
|
+
state.debug = debug;
|
|
98
|
+
},
|
|
99
|
+
|
|
79
100
|
isClipboardAvailable() {
|
|
80
101
|
return !!state._clipboardClient;
|
|
81
102
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { proxy } from 'valtio';
|
|
2
2
|
import type { WcWallet, CaipNetwork, Connector } from '../utils/TypeUtil';
|
|
3
|
+
import type { SocialProvider } from '@reown/appkit-common-react-native';
|
|
3
4
|
|
|
4
5
|
// -- Types --------------------------------------------- //
|
|
5
6
|
type TransactionAction = {
|
|
@@ -17,9 +18,13 @@ export interface RouterControllerState {
|
|
|
17
18
|
| 'AccountDefault'
|
|
18
19
|
| 'AllWallets'
|
|
19
20
|
| 'Connect'
|
|
21
|
+
| 'ConnectSocials'
|
|
20
22
|
| 'ConnectingExternal'
|
|
21
23
|
| 'ConnectingSiwe'
|
|
24
|
+
| 'ConnectingSocial'
|
|
25
|
+
| 'ConnectingFarcaster'
|
|
22
26
|
| 'ConnectingWalletConnect'
|
|
27
|
+
| 'Create'
|
|
23
28
|
| 'EmailVerifyDevice'
|
|
24
29
|
| 'EmailVerifyOtp'
|
|
25
30
|
| 'GetWallet'
|
|
@@ -30,6 +35,7 @@ export interface RouterControllerState {
|
|
|
30
35
|
| 'UpdateEmailSecondaryOtp'
|
|
31
36
|
| 'UpdateEmailWallet'
|
|
32
37
|
| 'UpgradeEmailWallet'
|
|
38
|
+
| 'UpgradeToSmartAccount'
|
|
33
39
|
| 'WalletCompatibleNetworks'
|
|
34
40
|
| 'WalletReceive'
|
|
35
41
|
| 'WalletSend'
|
|
@@ -44,6 +50,7 @@ export interface RouterControllerState {
|
|
|
44
50
|
network?: CaipNetwork;
|
|
45
51
|
email?: string;
|
|
46
52
|
newEmail?: string;
|
|
53
|
+
socialProvider?: SocialProvider;
|
|
47
54
|
};
|
|
48
55
|
transactionStack: TransactionAction[];
|
|
49
56
|
}
|
|
@@ -97,7 +97,7 @@ export const SendController = {
|
|
|
97
97
|
type: 'track',
|
|
98
98
|
event: 'SEND_INITIATED',
|
|
99
99
|
properties: {
|
|
100
|
-
isSmartAccount:
|
|
100
|
+
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount',
|
|
101
101
|
token: this.state.token.address,
|
|
102
102
|
amount: this.state.sendTokenAmount,
|
|
103
103
|
network: NetworkController.state.caipNetwork?.id || ''
|
|
@@ -120,7 +120,7 @@ export const SendController = {
|
|
|
120
120
|
type: 'track',
|
|
121
121
|
event: 'SEND_INITIATED',
|
|
122
122
|
properties: {
|
|
123
|
-
isSmartAccount:
|
|
123
|
+
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount',
|
|
124
124
|
token: this.state.token?.symbol,
|
|
125
125
|
amount: this.state.sendTokenAmount,
|
|
126
126
|
network: NetworkController.state.caipNetwork?.id || ''
|
|
@@ -162,7 +162,7 @@ export const SendController = {
|
|
|
162
162
|
type: 'track',
|
|
163
163
|
event: 'SEND_SUCCESS',
|
|
164
164
|
properties: {
|
|
165
|
-
isSmartAccount:
|
|
165
|
+
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount',
|
|
166
166
|
token: this.state.token?.symbol || '',
|
|
167
167
|
amount: params.sendTokenAmount,
|
|
168
168
|
network: NetworkController.state.caipNetwork?.id || ''
|
|
@@ -175,7 +175,7 @@ export const SendController = {
|
|
|
175
175
|
type: 'track',
|
|
176
176
|
event: 'SEND_ERROR',
|
|
177
177
|
properties: {
|
|
178
|
-
isSmartAccount:
|
|
178
|
+
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount',
|
|
179
179
|
token: this.state.token?.symbol || '',
|
|
180
180
|
amount: params.sendTokenAmount,
|
|
181
181
|
network: NetworkController.state.caipNetwork?.id || ''
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { proxy } from 'valtio';
|
|
2
|
+
import { OptionsController } from './OptionsController';
|
|
2
3
|
|
|
3
4
|
// -- Types --------------------------------------------- //
|
|
5
|
+
interface Message {
|
|
6
|
+
shortMessage: string;
|
|
7
|
+
longMessage?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
export interface SnackControllerState {
|
|
5
11
|
message: string;
|
|
6
12
|
variant: 'error' | 'success';
|
|
7
13
|
open: boolean;
|
|
14
|
+
long: boolean;
|
|
8
15
|
}
|
|
9
16
|
|
|
10
17
|
// -- State --------------------------------------------- //
|
|
11
18
|
const state = proxy<SnackControllerState>({
|
|
12
19
|
message: '',
|
|
13
20
|
variant: 'success',
|
|
14
|
-
open: false
|
|
21
|
+
open: false,
|
|
22
|
+
long: false
|
|
15
23
|
});
|
|
16
24
|
|
|
17
25
|
// -- Controller ---------------------------------------- //
|
|
@@ -30,7 +38,26 @@ export const SnackController = {
|
|
|
30
38
|
state.open = true;
|
|
31
39
|
},
|
|
32
40
|
|
|
41
|
+
showInternalError(error: Message) {
|
|
42
|
+
const { debug } = OptionsController.state;
|
|
43
|
+
|
|
44
|
+
if (debug) {
|
|
45
|
+
state.message = error.shortMessage;
|
|
46
|
+
state.variant = 'error';
|
|
47
|
+
state.open = true;
|
|
48
|
+
state.long = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (error.longMessage) {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.error(error.longMessage);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
33
57
|
hide() {
|
|
34
58
|
state.open = false;
|
|
59
|
+
state.long = false;
|
|
60
|
+
state.message = '';
|
|
61
|
+
state.variant = 'success';
|
|
35
62
|
}
|
|
36
63
|
};
|
|
@@ -5,6 +5,7 @@ import { EventsController } from './EventsController';
|
|
|
5
5
|
import { SnackController } from './SnackController';
|
|
6
6
|
import { NetworkController } from './NetworkController';
|
|
7
7
|
import { BlockchainApiController } from './BlockchainApiController';
|
|
8
|
+
import { AccountController } from './AccountController';
|
|
8
9
|
|
|
9
10
|
// -- Types --------------------------------------------- //
|
|
10
11
|
type TransactionByMonthMap = Record<string, Transaction[]>;
|
|
@@ -74,7 +75,7 @@ export const TransactionsController = {
|
|
|
74
75
|
address: accountAddress,
|
|
75
76
|
projectId,
|
|
76
77
|
cursor: state.next,
|
|
77
|
-
isSmartAccount:
|
|
78
|
+
isSmartAccount: AccountController.state.preferredAccountType === 'smartAccount'
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
SnackController.showError('Failed to fetch transactions');
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { SocialProvider } from '@reown/appkit-common-react-native';
|
|
2
|
+
import { proxy, subscribe as sub } from 'valtio';
|
|
3
|
+
|
|
4
|
+
// -- Types --------------------------------------------- //
|
|
5
|
+
export interface WebviewControllerState {
|
|
6
|
+
frameViewVisible: boolean;
|
|
7
|
+
webviewVisible: boolean;
|
|
8
|
+
webviewUrl?: string;
|
|
9
|
+
connecting?: boolean;
|
|
10
|
+
connectingProvider?: SocialProvider;
|
|
11
|
+
processingAuth?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// -- State --------------------------------------------- //
|
|
15
|
+
const state = proxy<WebviewControllerState>({
|
|
16
|
+
frameViewVisible: false,
|
|
17
|
+
webviewVisible: false,
|
|
18
|
+
connecting: false,
|
|
19
|
+
connectingProvider: undefined,
|
|
20
|
+
processingAuth: false
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// -- Controller ---------------------------------------- //
|
|
24
|
+
export const WebviewController = {
|
|
25
|
+
state,
|
|
26
|
+
|
|
27
|
+
subscribe(callback: (newState: WebviewControllerState) => void) {
|
|
28
|
+
return sub(state, () => callback(state));
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
setFrameViewVisible(frameViewVisible: WebviewControllerState['frameViewVisible']) {
|
|
32
|
+
state.frameViewVisible = frameViewVisible;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
setWebviewVisible(visible: WebviewControllerState['webviewVisible']) {
|
|
36
|
+
state.webviewVisible = visible;
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
setWebviewUrl(url: WebviewControllerState['webviewUrl']) {
|
|
40
|
+
state.webviewUrl = url;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
setConnecting(connecting: WebviewControllerState['connecting']) {
|
|
44
|
+
state.connecting = connecting;
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
setConnectingProvider(provider: WebviewControllerState['connectingProvider']) {
|
|
48
|
+
state.connectingProvider = provider;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
setProcessingAuth(processingAuth: WebviewControllerState['processingAuth']) {
|
|
52
|
+
state.processingAuth = processingAuth;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
reset() {
|
|
56
|
+
state.frameViewVisible = false;
|
|
57
|
+
state.webviewVisible = false;
|
|
58
|
+
state.connecting = false;
|
|
59
|
+
state.connectingProvider = undefined;
|
|
60
|
+
state.processingAuth = false;
|
|
61
|
+
state.webviewUrl = undefined;
|
|
62
|
+
}
|
|
63
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,8 @@ export {
|
|
|
56
56
|
|
|
57
57
|
export { SendController, type SendControllerState } from './controllers/SendController';
|
|
58
58
|
|
|
59
|
+
export { WebviewController, type WebviewControllerState } from './controllers/WebviewController';
|
|
60
|
+
|
|
59
61
|
// -- Utils -------------------------------------------------------------------
|
|
60
62
|
export { ApiUtil } from './utils/ApiUtil';
|
|
61
63
|
export { AssetUtil } from './utils/AssetUtil';
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import type { Features } from './TypeUtil';
|
|
2
|
+
|
|
3
|
+
const defaultFeatures: Features = {
|
|
4
|
+
email: true,
|
|
5
|
+
emailShowWallets: true,
|
|
6
|
+
socials: ['x', 'discord', 'apple', 'farcaster']
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
export const ConstantsUtil = {
|
|
2
10
|
FOUR_MINUTES_MS: 240000,
|
|
3
11
|
|
|
@@ -9,5 +17,7 @@ export const ConstantsUtil = {
|
|
|
9
17
|
|
|
10
18
|
LINKING_ERROR: 'LINKING_ERROR',
|
|
11
19
|
|
|
12
|
-
NATIVE_TOKEN_ADDRESS: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
|
|
20
|
+
NATIVE_TOKEN_ADDRESS: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
21
|
+
|
|
22
|
+
DEFAULT_FEATURES: defaultFeatures
|
|
13
23
|
};
|
package/src/utils/StorageUtil.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
3
|
import type { ConnectorType, WcWallet } from './TypeUtil';
|
|
4
|
+
import type { SocialProvider } from '@reown/appkit-common-react-native';
|
|
4
5
|
|
|
5
6
|
// -- Helpers -----------------------------------------------------------------
|
|
6
7
|
const WC_DEEPLINK = 'WALLETCONNECT_DEEPLINK_CHOICE';
|
|
7
8
|
const RECENT_WALLET = '@w3m/recent';
|
|
8
9
|
const CONNECTED_WALLET_IMAGE_URL = '@w3m/connected_wallet_image_url';
|
|
9
10
|
const CONNECTED_CONNECTOR = '@w3m/connected_connector';
|
|
11
|
+
const CONNECTED_SOCIAL = '@appkit/connected_social';
|
|
10
12
|
|
|
11
13
|
// -- Utility -----------------------------------------------------------------
|
|
12
14
|
export const StorageUtil = {
|
|
@@ -90,7 +92,7 @@ export const StorageUtil = {
|
|
|
90
92
|
}
|
|
91
93
|
},
|
|
92
94
|
|
|
93
|
-
async getConnectedConnector() {
|
|
95
|
+
async getConnectedConnector(): Promise<ConnectorType | undefined> {
|
|
94
96
|
try {
|
|
95
97
|
const connector = (await AsyncStorage.getItem(CONNECTED_CONNECTOR)) as ConnectorType;
|
|
96
98
|
|
|
@@ -134,5 +136,33 @@ export const StorageUtil = {
|
|
|
134
136
|
} catch {
|
|
135
137
|
console.info('Unable to remove Connected Wallet Image URL');
|
|
136
138
|
}
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
async setConnectedSocialProvider(provider: SocialProvider) {
|
|
142
|
+
try {
|
|
143
|
+
await AsyncStorage.setItem(CONNECTED_SOCIAL, JSON.stringify(provider));
|
|
144
|
+
} catch {
|
|
145
|
+
console.info('Unable to set Connected Social Provider');
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
async getConnectedSocialProvider() {
|
|
150
|
+
try {
|
|
151
|
+
const provider = (await AsyncStorage.getItem(CONNECTED_SOCIAL)) as SocialProvider;
|
|
152
|
+
|
|
153
|
+
return provider ? JSON.parse(provider) : undefined;
|
|
154
|
+
} catch {
|
|
155
|
+
console.info('Unable to get Connected Social Provider');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return undefined;
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
async removeConnectedSocialProvider() {
|
|
162
|
+
try {
|
|
163
|
+
await AsyncStorage.removeItem(CONNECTED_SOCIAL);
|
|
164
|
+
} catch {
|
|
165
|
+
console.info('Unable to remove Connected Social Provider');
|
|
166
|
+
}
|
|
137
167
|
}
|
|
138
168
|
};
|
package/src/utils/TypeUtil.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type EventEmitter } from 'events';
|
|
2
|
+
import type { Balance, SocialProvider, Transaction } from '@reown/appkit-common-react-native';
|
|
2
3
|
|
|
3
4
|
export interface BaseError {
|
|
4
5
|
message?: string;
|
|
@@ -55,11 +56,31 @@ export type CaipNamespaces = Record<
|
|
|
55
56
|
}
|
|
56
57
|
>;
|
|
57
58
|
|
|
59
|
+
export type SdkType = 'appkit';
|
|
60
|
+
|
|
58
61
|
export type SdkVersion =
|
|
59
62
|
| `react-native-wagmi-${string}`
|
|
60
63
|
| `react-native-ethers5-${string}`
|
|
61
64
|
| `react-native-ethers-${string}`;
|
|
62
65
|
|
|
66
|
+
export type Features = {
|
|
67
|
+
/**
|
|
68
|
+
* @description Enable or disable the email feature. Enabled by default.
|
|
69
|
+
* @type {boolean}
|
|
70
|
+
*/
|
|
71
|
+
email?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* @description Show or hide the regular wallet options when email is enabled. Enabled by default.
|
|
74
|
+
* @type {boolean}
|
|
75
|
+
*/
|
|
76
|
+
emailShowWallets?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* @description Enable or disable the socials feature. Enabled by default.
|
|
79
|
+
* @type {FeaturesSocials[]}
|
|
80
|
+
*/
|
|
81
|
+
socials?: SocialProvider[] | false;
|
|
82
|
+
};
|
|
83
|
+
|
|
63
84
|
// -- ApiController Types -------------------------------------------------------
|
|
64
85
|
export interface WcWallet {
|
|
65
86
|
id: string;
|
|
@@ -356,18 +377,34 @@ export type Event =
|
|
|
356
377
|
| {
|
|
357
378
|
type: 'track';
|
|
358
379
|
event: 'CLICK_SIGN_SIWE_MESSAGE';
|
|
380
|
+
properties: {
|
|
381
|
+
network: string;
|
|
382
|
+
isSmartAccount: boolean;
|
|
383
|
+
};
|
|
359
384
|
}
|
|
360
385
|
| {
|
|
361
386
|
type: 'track';
|
|
362
387
|
event: 'CLICK_CANCEL_SIWE';
|
|
388
|
+
properties: {
|
|
389
|
+
network: string;
|
|
390
|
+
isSmartAccount: boolean;
|
|
391
|
+
};
|
|
363
392
|
}
|
|
364
393
|
| {
|
|
365
394
|
type: 'track';
|
|
366
395
|
event: 'SIWE_AUTH_SUCCESS';
|
|
396
|
+
properties: {
|
|
397
|
+
network: string;
|
|
398
|
+
isSmartAccount: boolean;
|
|
399
|
+
};
|
|
367
400
|
}
|
|
368
401
|
| {
|
|
369
402
|
type: 'track';
|
|
370
403
|
event: 'SIWE_AUTH_ERROR';
|
|
404
|
+
properties: {
|
|
405
|
+
network: string;
|
|
406
|
+
isSmartAccount: boolean;
|
|
407
|
+
};
|
|
371
408
|
}
|
|
372
409
|
| {
|
|
373
410
|
type: 'track';
|
|
@@ -433,6 +470,35 @@ export type Event =
|
|
|
433
470
|
token: string;
|
|
434
471
|
amount: number;
|
|
435
472
|
};
|
|
473
|
+
}
|
|
474
|
+
| {
|
|
475
|
+
type: 'track';
|
|
476
|
+
event: 'SOCIAL_LOGIN_STARTED';
|
|
477
|
+
properties: {
|
|
478
|
+
provider: SocialProvider;
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
| {
|
|
482
|
+
type: 'track';
|
|
483
|
+
event: 'SOCIAL_LOGIN_SUCCESS';
|
|
484
|
+
properties: {
|
|
485
|
+
provider: SocialProvider;
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
| {
|
|
489
|
+
type: 'track';
|
|
490
|
+
event: 'SOCIAL_LOGIN_ERROR';
|
|
491
|
+
properties: {
|
|
492
|
+
provider: SocialProvider;
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
| {
|
|
496
|
+
type: 'track';
|
|
497
|
+
event: 'SET_PREFERRED_ACCOUNT_TYPE';
|
|
498
|
+
properties: {
|
|
499
|
+
accountType: AppKitFrameAccountType;
|
|
500
|
+
network: string;
|
|
501
|
+
};
|
|
436
502
|
};
|
|
437
503
|
|
|
438
504
|
// -- Send Controller Types -------------------------------------
|
|
@@ -457,24 +523,44 @@ export interface WriteContractArgs {
|
|
|
457
523
|
|
|
458
524
|
// -- Email Types ------------------------------------------------
|
|
459
525
|
/**
|
|
460
|
-
* Matches type defined for packages/
|
|
526
|
+
* Matches type defined for packages/wallet/src/AppKitFrameProvider.ts
|
|
461
527
|
* It's duplicated in order to decouple scaffold from email package
|
|
462
528
|
*/
|
|
529
|
+
|
|
530
|
+
export type AppKitFrameAccountType = 'eoa' | 'smartAccount';
|
|
531
|
+
|
|
463
532
|
export interface AppKitFrameProvider {
|
|
464
533
|
readonly id: string;
|
|
465
534
|
readonly name: string;
|
|
535
|
+
getEventEmitter(): EventEmitter;
|
|
466
536
|
getSecureSiteURL(): string;
|
|
467
537
|
getSecureSiteDashboardURL(): string;
|
|
468
538
|
getSecureSiteIconURL(): string;
|
|
469
539
|
getSecureSiteHeaders(): Record<string, string>;
|
|
470
|
-
getLoginEmailUsed(): Promise<boolean>;
|
|
471
540
|
getEmail(): string | undefined;
|
|
541
|
+
getUsername(): string | undefined;
|
|
542
|
+
getLastUsedChainId(): Promise<number | undefined>;
|
|
472
543
|
rejectRpcRequest(): void;
|
|
473
544
|
connectEmail(payload: { email: string }): Promise<{
|
|
474
545
|
action: 'VERIFY_DEVICE' | 'VERIFY_OTP';
|
|
475
546
|
}>;
|
|
476
547
|
connectDevice(): Promise<unknown>;
|
|
548
|
+
connectSocial(uri: string): Promise<{
|
|
549
|
+
chainId: string | number;
|
|
550
|
+
email: string;
|
|
551
|
+
address: string;
|
|
552
|
+
accounts?: {
|
|
553
|
+
type: AppKitFrameAccountType;
|
|
554
|
+
address: string;
|
|
555
|
+
}[];
|
|
556
|
+
userName?: string;
|
|
557
|
+
}>;
|
|
558
|
+
getSocialRedirectUri(payload: { provider: SocialProvider }): Promise<{
|
|
559
|
+
uri: string;
|
|
560
|
+
}>;
|
|
477
561
|
connectOtp(payload: { otp: string }): Promise<unknown>;
|
|
562
|
+
connectFarcaster: () => Promise<{ userName: string }>;
|
|
563
|
+
getFarcasterUri(): Promise<{ url: string }>;
|
|
478
564
|
isConnected(): Promise<{
|
|
479
565
|
isConnected: boolean;
|
|
480
566
|
}>;
|
|
@@ -495,17 +581,32 @@ export interface AppKitFrameProvider {
|
|
|
495
581
|
syncDappData(payload: {
|
|
496
582
|
projectId: string;
|
|
497
583
|
sdkVersion: SdkVersion;
|
|
584
|
+
sdkType: SdkType;
|
|
498
585
|
metadata?: Metadata;
|
|
499
586
|
}): Promise<unknown>;
|
|
500
587
|
connect(payload?: { chainId: number | undefined }): Promise<{
|
|
501
588
|
chainId: number;
|
|
502
|
-
email
|
|
589
|
+
email?: string | null;
|
|
503
590
|
address: string;
|
|
591
|
+
smartAccountDeployed: boolean;
|
|
592
|
+
preferredAccountType: AppKitFrameAccountType;
|
|
504
593
|
}>;
|
|
505
594
|
switchNetwork(chainId: number): Promise<{
|
|
506
595
|
chainId: number;
|
|
507
596
|
}>;
|
|
597
|
+
setPreferredAccount(type: AppKitFrameAccountType): Promise<{
|
|
598
|
+
type: AppKitFrameAccountType;
|
|
599
|
+
address: string;
|
|
600
|
+
}>;
|
|
601
|
+
setOnTimeout(callback: () => void): void;
|
|
602
|
+
getSmartAccountEnabledNetworks(): Promise<{
|
|
603
|
+
smartAccountEnabledNetworks: number[];
|
|
604
|
+
}>;
|
|
508
605
|
disconnect(): Promise<unknown>;
|
|
509
606
|
request(req: any): Promise<any>;
|
|
510
607
|
AuthView: () => JSX.Element | null;
|
|
608
|
+
Webview: () => JSX.Element | null;
|
|
609
|
+
onSetPreferredAccount: (
|
|
610
|
+
callback: (values: { type: AppKitFrameAccountType; address: string }) => void
|
|
611
|
+
) => void;
|
|
511
612
|
}
|