@reown/appkit-core-react-native 2.0.0-alpha.2 → 2.0.0-alpha.3

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.
Files changed (131) hide show
  1. package/lib/commonjs/controllers/ApiController.js +4 -20
  2. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  3. package/lib/commonjs/controllers/AssetController.js +0 -4
  4. package/lib/commonjs/controllers/AssetController.js.map +1 -1
  5. package/lib/commonjs/controllers/BlockchainApiController.js +0 -2
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionsController.js +0 -15
  8. package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
  9. package/lib/commonjs/controllers/OnRampController.js +3 -3
  10. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  11. package/lib/commonjs/controllers/OptionsController.js +1 -4
  12. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  13. package/lib/commonjs/controllers/RouterController.js +7 -1
  14. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  15. package/lib/commonjs/controllers/SwapController.js +3 -1
  16. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  17. package/lib/commonjs/controllers/WcController.js +73 -0
  18. package/lib/commonjs/controllers/WcController.js.map +1 -0
  19. package/lib/commonjs/index.js +7 -7
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/utils/AssetUtil.js +7 -4
  22. package/lib/commonjs/utils/AssetUtil.js.map +1 -1
  23. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  24. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  25. package/lib/commonjs/utils/StorageUtil.js +0 -46
  26. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  27. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
  28. package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
  29. package/lib/module/controllers/ApiController.js +4 -20
  30. package/lib/module/controllers/ApiController.js.map +1 -1
  31. package/lib/module/controllers/AssetController.js +0 -4
  32. package/lib/module/controllers/AssetController.js.map +1 -1
  33. package/lib/module/controllers/BlockchainApiController.js +0 -2
  34. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  35. package/lib/module/controllers/ConnectionsController.js +0 -15
  36. package/lib/module/controllers/ConnectionsController.js.map +1 -1
  37. package/lib/module/controllers/OnRampController.js +1 -1
  38. package/lib/module/controllers/OnRampController.js.map +1 -1
  39. package/lib/module/controllers/OptionsController.js +1 -4
  40. package/lib/module/controllers/OptionsController.js.map +1 -1
  41. package/lib/module/controllers/RouterController.js +7 -1
  42. package/lib/module/controllers/RouterController.js.map +1 -1
  43. package/lib/module/controllers/SwapController.js +3 -1
  44. package/lib/module/controllers/SwapController.js.map +1 -1
  45. package/lib/module/controllers/WcController.js +70 -0
  46. package/lib/module/controllers/WcController.js.map +1 -0
  47. package/lib/module/index.js +3 -1
  48. package/lib/module/index.js.map +1 -1
  49. package/lib/module/utils/AssetUtil.js +7 -4
  50. package/lib/module/utils/AssetUtil.js.map +1 -1
  51. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  52. package/lib/module/utils/CoreHelperUtil.js +1 -0
  53. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  54. package/lib/module/utils/StorageUtil.js +0 -47
  55. package/lib/module/utils/StorageUtil.js.map +1 -1
  56. package/lib/module/utils/SwapApiUtil.js.map +1 -1
  57. package/lib/module/utils/SwapCalculationUtil.js +1 -0
  58. package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
  59. package/lib/typescript/controllers/ApiController.d.ts +1 -3
  60. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  61. package/lib/typescript/controllers/AssetController.d.ts +0 -2
  62. package/lib/typescript/controllers/AssetController.d.ts.map +1 -1
  63. package/lib/typescript/controllers/BlockchainApiController.d.ts +4 -3
  64. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  65. package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
  66. package/lib/typescript/controllers/EnsController.d.ts +1 -1
  67. package/lib/typescript/controllers/EventsController.d.ts +1 -1
  68. package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
  69. package/lib/typescript/controllers/OnRampController.d.ts +2 -2
  70. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  71. package/lib/typescript/controllers/OptionsController.d.ts +1 -4
  72. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  73. package/lib/typescript/controllers/RouterController.d.ts +3 -5
  74. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  75. package/lib/typescript/controllers/SwapController.d.ts +1 -2
  76. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  77. package/lib/typescript/controllers/WcController.d.ts +27 -0
  78. package/lib/typescript/controllers/WcController.d.ts.map +1 -0
  79. package/lib/typescript/index.d.ts +1 -2
  80. package/lib/typescript/index.d.ts.map +1 -1
  81. package/lib/typescript/utils/AssetUtil.d.ts +2 -2
  82. package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
  83. package/lib/typescript/utils/ConstantsUtil.d.ts +1 -1
  84. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  85. package/lib/typescript/utils/CoreHelperUtil.d.ts +1 -2
  86. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  87. package/lib/typescript/utils/EventUtil.d.ts +1 -1
  88. package/lib/typescript/utils/EventUtil.d.ts.map +1 -1
  89. package/lib/typescript/utils/FetchUtil.d.ts +1 -1
  90. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  91. package/lib/typescript/utils/StorageUtil.d.ts +1 -8
  92. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  93. package/lib/typescript/utils/SwapApiUtil.d.ts +2 -3
  94. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  95. package/lib/typescript/utils/SwapCalculationUtil.d.ts +1 -1
  96. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
  97. package/package.json +2 -2
  98. package/src/controllers/ApiController.ts +10 -27
  99. package/src/controllers/AssetController.ts +0 -6
  100. package/src/controllers/BlockchainApiController.ts +5 -5
  101. package/src/controllers/ConnectionsController.ts +0 -22
  102. package/src/controllers/EnsController.ts +1 -1
  103. package/src/controllers/EventsController.ts +1 -1
  104. package/src/controllers/OnRampController.ts +1 -1
  105. package/src/controllers/OptionsController.ts +11 -8
  106. package/src/controllers/RouterController.ts +15 -7
  107. package/src/controllers/SwapController.ts +4 -3
  108. package/src/controllers/WcController.ts +93 -0
  109. package/src/index.ts +2 -6
  110. package/src/utils/AssetUtil.ts +9 -5
  111. package/src/utils/ConstantsUtil.ts +1 -2
  112. package/src/utils/CoreHelperUtil.ts +3 -2
  113. package/src/utils/EventUtil.ts +1 -1
  114. package/src/utils/FetchUtil.ts +1 -1
  115. package/src/utils/StorageUtil.ts +6 -76
  116. package/src/utils/SwapApiUtil.ts +6 -2
  117. package/src/utils/SwapCalculationUtil.ts +1 -2
  118. package/lib/commonjs/controllers/ConnectionController.js +0 -123
  119. package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
  120. package/lib/commonjs/utils/TypeUtil.js +0 -31
  121. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  122. package/lib/module/controllers/ConnectionController.js +0 -120
  123. package/lib/module/controllers/ConnectionController.js.map +0 -1
  124. package/lib/module/utils/TypeUtil.js +0 -26
  125. package/lib/module/utils/TypeUtil.js.map +0 -1
  126. package/lib/typescript/controllers/ConnectionController.d.ts +0 -55
  127. package/lib/typescript/controllers/ConnectionController.d.ts.map +0 -1
  128. package/lib/typescript/utils/TypeUtil.d.ts +0 -705
  129. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  130. package/src/controllers/ConnectionController.ts +0 -185
  131. package/src/utils/TypeUtil.ts +0 -899
@@ -1,6 +1,14 @@
1
1
  import { proxy, ref } from 'valtio';
2
- import type { Tokens, Storage, Metadata, AppKitNetwork } from '@reown/appkit-common-react-native';
3
- import type { CustomWallet, Features, ProjectId, SdkType, SdkVersion } from '../utils/TypeUtil';
2
+ import type {
3
+ Storage,
4
+ Metadata,
5
+ AppKitNetwork,
6
+ CustomWallet,
7
+ Features,
8
+ ProjectId,
9
+ SdkType,
10
+ SdkVersion
11
+ } from '@reown/appkit-common-react-native';
4
12
 
5
13
  import { ConstantsUtil } from '../utils/ConstantsUtil';
6
14
 
@@ -17,7 +25,6 @@ export interface OptionsControllerState {
17
25
  excludeWalletIds?: string[];
18
26
  featuredWalletIds?: string[];
19
27
  customWallets?: CustomWallet[];
20
- tokens?: Tokens;
21
28
  enableAnalytics?: boolean;
22
29
  sdkType: SdkType;
23
30
  sdkVersion: SdkVersion;
@@ -33,7 +40,7 @@ export interface OptionsControllerState {
33
40
  const state = proxy<OptionsControllerState>({
34
41
  projectId: '',
35
42
  sdkType: 'appkit',
36
- sdkVersion: 'react-native-wagmi-undefined',
43
+ sdkVersion: 'react-native-undefined-undefined',
37
44
  features: ConstantsUtil.DEFAULT_FEATURES,
38
45
  debug: false
39
46
  });
@@ -62,10 +69,6 @@ export const OptionsController = {
62
69
  state.featuredWalletIds = featuredWalletIds;
63
70
  },
64
71
 
65
- setTokens(tokens: OptionsControllerState['tokens']) {
66
- state.tokens = tokens;
67
- },
68
-
69
72
  setCustomWallets(customWallets: OptionsControllerState['customWallets']) {
70
73
  state.customWallets = customWallets;
71
74
  },
@@ -1,7 +1,10 @@
1
1
  import { proxy } from 'valtio';
2
- import type { CaipNetwork, SocialProvider } from '@reown/appkit-common-react-native';
3
-
4
- import type { WcWallet, OnRampTransactionResult } from '../utils/TypeUtil';
2
+ import type {
3
+ AppKitNetwork,
4
+ SocialProvider,
5
+ WcWallet,
6
+ OnRampTransactionResult
7
+ } from '@reown/appkit-common-react-native';
5
8
 
6
9
  // -- Types --------------------------------------------- //
7
10
  export interface RouterControllerState {
@@ -36,11 +39,10 @@ export interface RouterControllerState {
36
39
  | 'WhatIsANetwork'
37
40
  | 'WhatIsAWallet';
38
41
  history: RouterControllerState['view'][];
42
+ navigationDirection: 'forward' | 'backward' | 'none';
39
43
  data?: {
40
44
  wallet?: WcWallet;
41
- network?: CaipNetwork;
42
- email?: string;
43
- newEmail?: string;
45
+ network?: AppKitNetwork;
44
46
  onrampResult?: OnRampTransactionResult;
45
47
  socialProvider?: SocialProvider;
46
48
  };
@@ -49,7 +51,8 @@ export interface RouterControllerState {
49
51
  // -- State --------------------------------------------- //
50
52
  const state = proxy<RouterControllerState>({
51
53
  view: 'Connect',
52
- history: ['Connect']
54
+ history: ['Connect'],
55
+ navigationDirection: 'none'
53
56
  });
54
57
 
55
58
  // -- Controller ---------------------------------------- //
@@ -58,6 +61,7 @@ export const RouterController = {
58
61
 
59
62
  push(view: RouterControllerState['view'], data?: RouterControllerState['data']) {
60
63
  if (view !== state.view) {
64
+ state.navigationDirection = 'forward';
61
65
  state.view = view;
62
66
  state.history = [...state.history, view];
63
67
  state.data = data;
@@ -65,6 +69,7 @@ export const RouterController = {
65
69
  },
66
70
 
67
71
  reset(view: RouterControllerState['view'], data?: RouterControllerState['data']) {
72
+ state.navigationDirection = 'none';
68
73
  state.view = view;
69
74
  state.history = [view];
70
75
  state.data = data;
@@ -72,6 +77,7 @@ export const RouterController = {
72
77
 
73
78
  replace(view: RouterControllerState['view'], data?: RouterControllerState['data']) {
74
79
  if (state.history.length >= 1 && state.history.at(-1) !== view) {
80
+ state.navigationDirection = 'none';
75
81
  state.view = view;
76
82
  state.history[state.history.length - 1] = view;
77
83
  state.data = data;
@@ -83,6 +89,7 @@ export const RouterController = {
83
89
  state.history.pop();
84
90
  const [last] = state.history.slice(-1);
85
91
  if (last) {
92
+ state.navigationDirection = 'backward';
86
93
  state.view = last;
87
94
  }
88
95
  }
@@ -93,6 +100,7 @@ export const RouterController = {
93
100
  state.history = state.history.slice(0, historyIndex + 1);
94
101
  const [last] = state.history.slice(-1);
95
102
  if (last) {
103
+ state.navigationDirection = 'backward';
96
104
  state.view = last;
97
105
  }
98
106
  }
@@ -3,7 +3,9 @@ import { proxy, subscribe as sub } from 'valtio';
3
3
  import {
4
4
  NumberUtil,
5
5
  type CaipAddress,
6
- type CaipNetworkId
6
+ type CaipNetworkId,
7
+ type SwapInputTarget,
8
+ type SwapTokenWithBalance
7
9
  } from '@reown/appkit-common-react-native';
8
10
 
9
11
  import { ConstantsUtil } from '../utils/ConstantsUtil';
@@ -13,7 +15,6 @@ import { OptionsController } from './OptionsController';
13
15
  import { SwapCalculationUtil } from '../utils/SwapCalculationUtil';
14
16
  import { SnackController } from './SnackController';
15
17
  import { RouterController } from './RouterController';
16
- import type { SwapInputTarget, SwapTokenWithBalance } from '../utils/TypeUtil';
17
18
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
18
19
  import { TransactionsController } from './TransactionsController';
19
20
  import { EventsController } from './EventsController';
@@ -140,7 +141,7 @@ const initialState: SwapControllerState = {
140
141
  providerFee: undefined
141
142
  };
142
143
 
143
- const state = proxy<SwapControllerState>(initialState);
144
+ const state = proxy<SwapControllerState>({ ...initialState });
144
145
 
145
146
  // -- Controller ---------------------------------------- //
146
147
  export const SwapController = {
@@ -0,0 +1,93 @@
1
+ import { proxy } from 'valtio';
2
+ import { subscribeKey as subKey } from 'valtio/utils';
3
+ import type { WalletDeepLink, WcWallet } from '@reown/appkit-common-react-native';
4
+ import { CoreHelperUtil } from '../utils/CoreHelperUtil';
5
+ import { StorageUtil } from '../utils/StorageUtil';
6
+
7
+ // -- Types --------------------------------------------- //
8
+ export interface WcControllerState {
9
+ wcUri?: string;
10
+ wcPromise?: Promise<void>;
11
+ wcPairingExpiry?: number;
12
+ wcLinking?: WalletDeepLink;
13
+ wcError?: boolean;
14
+ pressedWallet?: WcWallet;
15
+ recentWallets?: WcWallet[];
16
+ }
17
+
18
+ type StateKey = keyof WcControllerState;
19
+
20
+ // -- State --------------------------------------------- //
21
+ const state = proxy<WcControllerState>({
22
+ wcError: false
23
+ });
24
+
25
+ // -- Controller ---------------------------------------- //
26
+ export const WcController = {
27
+ state,
28
+
29
+ subscribeKey<K extends StateKey>(key: K, callback: (value: WcControllerState[K]) => void) {
30
+ return subKey(state, key, callback);
31
+ },
32
+
33
+ setWcLinking(wcLinking: WcControllerState['wcLinking']) {
34
+ state.wcLinking = wcLinking;
35
+ },
36
+
37
+ removeWcLinking() {
38
+ state.wcLinking = undefined;
39
+ },
40
+
41
+ setWcError(wcError: WcControllerState['wcError']) {
42
+ state.wcError = wcError;
43
+ },
44
+
45
+ setPressedWallet(wallet: WcControllerState['pressedWallet']) {
46
+ state.pressedWallet = wallet;
47
+ },
48
+
49
+ removePressedWallet() {
50
+ state.pressedWallet = undefined;
51
+ },
52
+
53
+ setWcPromise(wcPromise: WcControllerState['wcPromise']) {
54
+ state.wcPromise = wcPromise;
55
+ },
56
+
57
+ setWcUri(wcUri: WcControllerState['wcUri']) {
58
+ state.wcUri = wcUri;
59
+ state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
60
+ },
61
+
62
+ setRecentWallets(wallets: WcControllerState['recentWallets']) {
63
+ state.recentWallets = wallets;
64
+ },
65
+
66
+ async addRecentWallet(wallet: WcWallet) {
67
+ const recentWallets = await StorageUtil.addRecentWallet(wallet);
68
+ if (recentWallets) {
69
+ WcController.setRecentWallets(recentWallets);
70
+ }
71
+ },
72
+
73
+ setConnectedWallet: async (wcLinking: WalletDeepLink, pressedWallet?: WcWallet) => {
74
+ StorageUtil.setWalletConnectDeepLink(wcLinking);
75
+
76
+ if (pressedWallet) {
77
+ WcController.addRecentWallet(pressedWallet);
78
+ }
79
+ },
80
+
81
+ clearUri() {
82
+ state.wcUri = undefined;
83
+ state.wcPairingExpiry = undefined;
84
+ state.wcPromise = undefined;
85
+ state.wcLinking = undefined;
86
+ },
87
+
88
+ resetState() {
89
+ this.clearUri();
90
+ state.pressedWallet = undefined;
91
+ StorageUtil.removeWalletConnectDeepLink();
92
+ }
93
+ };
package/src/index.ts CHANGED
@@ -7,11 +7,7 @@ export {
7
7
 
8
8
  export { RouterController, type RouterControllerState } from './controllers/RouterController';
9
9
 
10
- export {
11
- ConnectionController,
12
- type ConnectionControllerClient,
13
- type ConnectionControllerState
14
- } from './controllers/ConnectionController';
10
+ export { WcController, type WcControllerState } from './controllers/WcController';
15
11
 
16
12
  export {
17
13
  ConnectionsController,
@@ -59,4 +55,4 @@ export { StorageUtil } from './utils/StorageUtil';
59
55
  export { EventUtil } from './utils/EventUtil';
60
56
  export { RouterUtil } from './utils/RouterUtil';
61
57
 
62
- export type * from './utils/TypeUtil';
58
+ // Types are now exported from @reown/appkit-common-react-native
@@ -1,5 +1,5 @@
1
+ import type { AppKitNetwork, WcWallet } from '@reown/appkit-common-react-native';
1
2
  import { AssetController } from '../controllers/AssetController';
2
- import type { WcWallet } from './TypeUtil';
3
3
 
4
4
  export const AssetUtil = {
5
5
  getWalletImage(wallet?: WcWallet) {
@@ -14,11 +14,15 @@ export const AssetUtil = {
14
14
  return undefined;
15
15
  },
16
16
 
17
- getConnectorImage(imageId?: string) {
18
- if (imageId) {
19
- return AssetController.state.connectorImages[imageId];
17
+ getNetworkImage(network?: AppKitNetwork, networkImages?: Record<string, string>) {
18
+ if (!network) {
19
+ return undefined;
20
20
  }
21
21
 
22
- return undefined;
22
+ if (network?.imageUrl) {
23
+ return network.imageUrl;
24
+ }
25
+
26
+ return networkImages?.[network?.id];
23
27
  }
24
28
  };
@@ -1,5 +1,4 @@
1
- import type { ChainNamespace } from '@reown/appkit-common-react-native';
2
- import type { Features } from './TypeUtil';
1
+ import type { ChainNamespace, Features } from '@reown/appkit-common-react-native';
3
2
 
4
3
  const defaultFeatures: Features = {
5
4
  swaps: true,
@@ -10,13 +10,14 @@ import {
10
10
  type CaipNetwork,
11
11
  type ChainNamespace,
12
12
  type SocialProvider,
13
- type LinkingRecord
13
+ type LinkingRecord,
14
+ type DataWallet,
15
+ type SdkVersion
14
16
  } from '@reown/appkit-common-react-native';
15
17
 
16
18
  import * as ct from 'countries-and-timezones';
17
19
 
18
20
  import { ConstantsUtil } from './ConstantsUtil';
19
- import type { DataWallet, SdkVersion } from './TypeUtil';
20
21
 
21
22
  // -- Helpers -----------------------------------------------------------------
22
23
  async function isAppInstalledIos(deepLink?: string): Promise<boolean> {
@@ -1,4 +1,4 @@
1
- import type { Platform, WcWallet } from './TypeUtil';
1
+ import type { Platform, WcWallet } from '@reown/appkit-common-react-native';
2
2
 
3
3
  export const EventUtil = {
4
4
  getWalletPlatform(wallet: WcWallet, installed?: boolean): Platform | undefined {
@@ -1,4 +1,4 @@
1
- import type { RequestCache } from './TypeUtil';
1
+ import type { RequestCache } from '@reown/appkit-common-react-native';
2
2
 
3
3
  // -- Types ----------------------------------------------------------------------
4
4
  interface Options {
@@ -1,15 +1,12 @@
1
1
  /* eslint-disable no-console */
2
- import type {
3
- OnRampCountry,
4
- OnRampFiatCurrency,
5
- OnRampFiatLimit,
6
- OnRampServiceProvider,
7
- OnRampCountryDefaults,
8
- WcWallet
9
- } from './TypeUtil';
10
2
  import {
3
+ type OnRampCountry,
4
+ type OnRampFiatCurrency,
5
+ type OnRampFiatLimit,
6
+ type OnRampServiceProvider,
7
+ type OnRampCountryDefaults,
8
+ type WcWallet,
11
9
  DateUtil,
12
- type SocialProvider,
13
10
  type ConnectorType,
14
11
  type ChainNamespace,
15
12
  type WalletDeepLink,
@@ -153,73 +150,6 @@ export const StorageUtil = {
153
150
  }
154
151
  },
155
152
 
156
- async setConnectedWalletImageUrl(url: string) {
157
- try {
158
- await OptionsController.getStorage().setItem(
159
- ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL,
160
- url
161
- );
162
- } catch {
163
- console.info('Unable to set Connected Wallet Image URL');
164
- }
165
- },
166
-
167
- async getConnectedWalletImageUrl() {
168
- try {
169
- return await OptionsController.getStorage().getItem(
170
- ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL
171
- );
172
- } catch {
173
- console.info('Unable to get Connected Wallet Image URL');
174
- }
175
-
176
- return undefined;
177
- },
178
-
179
- async removeConnectedWalletImageUrl() {
180
- try {
181
- await OptionsController.getStorage().removeItem(
182
- ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL
183
- );
184
- } catch (e) {
185
- console.error(e);
186
- console.info('Unable to remove Connected Wallet Image URL');
187
- }
188
- },
189
-
190
- async setConnectedSocialProvider(provider: SocialProvider) {
191
- try {
192
- await OptionsController.getStorage().setItem(
193
- ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL,
194
- provider
195
- );
196
- } catch {
197
- console.info('Unable to set Connected Social Provider');
198
- }
199
- },
200
-
201
- async getConnectedSocialProvider(): Promise<SocialProvider | undefined> {
202
- try {
203
- const provider = await OptionsController.getStorage().getItem<SocialProvider>(
204
- ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL
205
- );
206
-
207
- return provider ?? undefined;
208
- } catch {
209
- console.info('Unable to get Connected Social Provider');
210
- }
211
-
212
- return undefined;
213
- },
214
-
215
- async removeConnectedSocialProvider() {
216
- try {
217
- await OptionsController.getStorage().removeItem(ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL);
218
- } catch {
219
- console.info('Unable to remove Connected Social Provider');
220
- }
221
- },
222
-
223
153
  async setOnRampPreferredCountry(country: OnRampCountry) {
224
154
  try {
225
155
  await OptionsController.getStorage().setItem(
@@ -1,7 +1,11 @@
1
- import type { Balance, CaipNetworkId } from '@reown/appkit-common-react-native';
1
+ import type {
2
+ Balance,
3
+ CaipNetworkId,
4
+ BlockchainApiSwapAllowanceRequest,
5
+ SwapTokenWithBalance
6
+ } from '@reown/appkit-common-react-native';
2
7
  import { BlockchainApiController } from '../controllers/BlockchainApiController';
3
8
  import { OptionsController } from '../controllers/OptionsController';
4
- import type { BlockchainApiSwapAllowanceRequest, SwapTokenWithBalance } from './TypeUtil';
5
9
  import { ConnectionsController } from '../controllers/ConnectionsController';
6
10
  import { ConstantsUtil } from './ConstantsUtil';
7
11
 
@@ -1,7 +1,6 @@
1
1
  // -- Types --------------------------------------------- //
2
2
 
3
- import { NumberUtil } from '@reown/appkit-common-react-native';
4
- import type { SwapTokenWithBalance } from './TypeUtil';
3
+ import { NumberUtil, type SwapTokenWithBalance } from '@reown/appkit-common-react-native';
5
4
 
6
5
  // -- Util ---------------------------------------- //
7
6
  export const SwapCalculationUtil = {
@@ -1,123 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ConnectionController = void 0;
7
- var _valtio = require("valtio");
8
- var _utils = require("valtio/utils");
9
- var _CoreHelperUtil = require("../utils/CoreHelperUtil");
10
- var _StorageUtil = require("../utils/StorageUtil");
11
- // -- Types --------------------------------------------- //
12
-
13
- // -- State --------------------------------------------- //
14
- const state = (0, _valtio.proxy)({
15
- wcError: false
16
- });
17
-
18
- // -- Controller ---------------------------------------- //
19
- const ConnectionController = exports.ConnectionController = {
20
- state,
21
- subscribeKey(key, callback) {
22
- return (0, _utils.subscribeKey)(state, key, callback);
23
- },
24
- _getClient() {
25
- if (!state._client) {
26
- throw new Error('ConnectionController client not set');
27
- }
28
- return state._client;
29
- },
30
- setClient(client) {
31
- state._client = (0, _valtio.ref)(client);
32
- },
33
- connectWalletConnect(walletUniversalLink) {
34
- state.wcPromise = this._getClient().connectWalletConnect(uri => {
35
- state.wcUri = uri;
36
- state.wcPairingExpiry = _CoreHelperUtil.CoreHelperUtil.getPairingExpiry();
37
- }, walletUniversalLink);
38
- },
39
- async signMessage(message) {
40
- return this._getClient().signMessage(message);
41
- },
42
- setWcLinking(wcLinking) {
43
- state.wcLinking = wcLinking;
44
- },
45
- removeWcLinking() {
46
- state.wcLinking = undefined;
47
- },
48
- setWcError(wcError) {
49
- state.wcError = wcError;
50
- },
51
- setPressedWallet(wallet) {
52
- state.pressedWallet = wallet;
53
- },
54
- removePressedWallet() {
55
- state.pressedWallet = undefined;
56
- },
57
- setWcPromise(wcPromise) {
58
- state.wcPromise = wcPromise;
59
- },
60
- setWcUri(wcUri) {
61
- state.wcUri = wcUri;
62
- state.wcPairingExpiry = _CoreHelperUtil.CoreHelperUtil.getPairingExpiry();
63
- },
64
- setRecentWallets(wallets) {
65
- state.recentWallets = wallets;
66
- },
67
- async setConnectedWalletImageUrl(url) {
68
- state.connectedWalletImageUrl = url;
69
- if (url) {
70
- await _StorageUtil.StorageUtil.setConnectedWalletImageUrl(url);
71
- } else {
72
- _StorageUtil.StorageUtil.removeConnectedWalletImageUrl();
73
- }
74
- },
75
- setConnectedSocialProvider(provider) {
76
- state.connectedSocialProvider = provider;
77
- if (provider) {
78
- _StorageUtil.StorageUtil.setConnectedSocialProvider(provider);
79
- } else {
80
- _StorageUtil.StorageUtil.removeConnectedSocialProvider();
81
- }
82
- },
83
- parseUnits(value, decimals) {
84
- return this._getClient().parseUnits(value, decimals);
85
- },
86
- formatUnits(value, decimals) {
87
- return this._getClient().formatUnits(value, decimals);
88
- },
89
- async sendTransaction(args) {
90
- return this._getClient().sendTransaction(args);
91
- },
92
- async estimateGas(args) {
93
- return this._getClient()?.estimateGas(args);
94
- },
95
- async writeContract(args) {
96
- return this._getClient().writeContract(args);
97
- },
98
- async getEnsAddress(value) {
99
- return this._getClient().getEnsAddress(value);
100
- },
101
- async getEnsAvatar(value) {
102
- return this._getClient().getEnsAvatar(value);
103
- },
104
- clearUri() {
105
- state.wcUri = undefined;
106
- state.wcPairingExpiry = undefined;
107
- state.wcPromise = undefined;
108
- state.wcLinking = undefined;
109
- },
110
- resetWcConnection() {
111
- this.clearUri();
112
- state.pressedWallet = undefined;
113
- ConnectionController.setConnectedWalletImageUrl(undefined);
114
- // ConnectorController.setConnectedConnector(undefined);
115
- _StorageUtil.StorageUtil.removeWalletConnectDeepLink();
116
- },
117
- async disconnect() {
118
- this.resetWcConnection();
119
- // remove transactions
120
- // RouterController.reset('Connect');
121
- }
122
- };
123
- //# sourceMappingURL=ConnectionController.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_valtio","require","_utils","_CoreHelperUtil","_StorageUtil","state","proxy","wcError","ConnectionController","exports","subscribeKey","key","callback","subKey","_getClient","_client","Error","setClient","client","ref","connectWalletConnect","walletUniversalLink","wcPromise","uri","wcUri","wcPairingExpiry","CoreHelperUtil","getPairingExpiry","signMessage","message","setWcLinking","wcLinking","removeWcLinking","undefined","setWcError","setPressedWallet","wallet","pressedWallet","removePressedWallet","setWcPromise","setWcUri","setRecentWallets","wallets","recentWallets","setConnectedWalletImageUrl","url","connectedWalletImageUrl","StorageUtil","removeConnectedWalletImageUrl","setConnectedSocialProvider","provider","connectedSocialProvider","removeConnectedSocialProvider","parseUnits","value","decimals","formatUnits","sendTransaction","args","estimateGas","writeContract","getEnsAddress","getEnsAvatar","clearUri","resetWcConnection","removeWalletConnectDeepLink","disconnect"],"sourceRoot":"../../../src","sources":["controllers/ConnectionController.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAQA;;AAiCA;AACA,MAAMI,KAAK,GAAG,IAAAC,aAAK,EAA4B;EAC7CC,OAAO,EAAE;AACX,CAAC,CAAC;;AAEF;AACO,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG;EAClCH,KAAK;EAELK,YAAYA,CACVC,GAAM,EACNC,QAAuD,EACvD;IACA,OAAO,IAAAC,mBAAM,EAACR,KAAK,EAAEM,GAAG,EAAEC,QAAQ,CAAC;EACrC,CAAC;EAEDE,UAAUA,CAAA,EAAG;IACX,IAAI,CAACT,KAAK,CAACU,OAAO,EAAE;MAClB,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;IACxD;IAEA,OAAOX,KAAK,CAACU,OAAO;EACtB,CAAC;EAEDE,SAASA,CAACC,MAAkC,EAAE;IAC5Cb,KAAK,CAACU,OAAO,GAAG,IAAAI,WAAG,EAACD,MAAM,CAAC;EAC7B,CAAC;EAEDE,oBAAo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AAYA,CAACR,KAAa,EAAE;IAChC,OAAO,IAAI,CAACxC,UAAU,CAAC,CAAC,CAACgD,YAAY,CAACR,KAAK,CAAC;EAC9C,CAAC;EAEDS,QAAQA,CAAA,EAAG;IACT1D,KAAK,CAACmB,KAAK,GAAGS,SAAS;IACvB5B,KAAK,CAACoB,eAAe,GAAGQ,SAAS;IACjC5B,KAAK,CAACiB,SAAS,GAAGW,SAAS;IAC3B5B,KAAK,CAAC0B,SAAS,GAAGE,SAAS;EAC7B,CAAC;EAED+B,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAACD,QAAQ,CAAC,CAAC;IACf1D,KAAK,CAACgC,aAAa,GAAGJ,SAAS;IAC/BzB,oBAAoB,CAACoC,0BAA0B,CAACX,SAAS,CAAC;IAC1D;IACAc,wBAAW,CAACkB,2BAA2B,CAAC,CAAC;EAC3C,CAAC;EAED,MAAMC,UAAUA,CAAA,EAAG;IACjB,IAAI,CAACF,iBAAiB,CAAC,CAAC;IACxB;IACA;EACF;AACF,CAAC","ignoreList":[]}
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.BlockchainOnRampError = void 0;
7
- // -- ApiController Types -------------------------------------------------------
8
-
9
- // -- BlockchainApiController Types ---------------------------------------------
10
-
11
- class BlockchainOnRampError extends Error {
12
- constructor(code, message) {
13
- super(message);
14
- this.code = code;
15
- this.message = message;
16
- }
17
- }
18
-
19
- // -- OptionsController Types ---------------------------------------------------
20
-
21
- // -- OptionsController Types ---------------------------------------------------
22
-
23
- // -- EventsController Types ----------------------------------------------------
24
-
25
- // -- Send Controller Types -------------------------------------
26
-
27
- // -- Swap Controller Types -------------------------------------
28
-
29
- // -- OnRamp Controller Types ------------------------------------------------
30
- exports.BlockchainOnRampError = BlockchainOnRampError;
31
- //# sourceMappingURL=TypeUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["BlockchainOnRampError","Error","constructor","code","message","exports"],"sourceRoot":"../../../src","sources":["utils/TypeUtil.ts"],"mappings":";;;;;;AAwEA;;AAoDA;;AA2MO,MAAMA,qBAAqB,SAASC,KAAK,CAAC;EAE/CC,WAAWA,CAACC,IAAY,EAAEC,OAAe,EAAE;IACzC,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;AACF;;AAEA;;AAMA;;AAgBA;;AA0YA;;AA2BA;;AAqBA;AAAAC,OAAA,CAAAL,qBAAA,GAAAA,qBAAA","ignoreList":[]}