@reown/appkit-core-react-native 2.0.0 → 2.0.1
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/ApiController.js +148 -82
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/AssetController.js +0 -4
- package/lib/commonjs/controllers/AssetController.js.map +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +127 -134
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +280 -60
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
- package/lib/commonjs/controllers/EnsController.js +6 -4
- package/lib/commonjs/controllers/EnsController.js.map +1 -1
- package/lib/commonjs/controllers/EventsController.js +55 -5
- package/lib/commonjs/controllers/EventsController.js.map +1 -1
- package/lib/commonjs/controllers/LogController.js +188 -0
- package/lib/commonjs/controllers/LogController.js.map +1 -0
- package/lib/commonjs/controllers/ModalController.js +9 -7
- package/lib/commonjs/controllers/ModalController.js.map +1 -1
- package/lib/commonjs/controllers/OnRampController.js +134 -53
- package/lib/commonjs/controllers/OnRampController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +20 -7
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/PublicStateController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js +7 -22
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SendController.js +115 -99
- package/lib/commonjs/controllers/SendController.js.map +1 -1
- package/lib/commonjs/controllers/SnackController.js +29 -5
- package/lib/commonjs/controllers/SnackController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +119 -119
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js +5 -0
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +25 -19
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
- package/lib/commonjs/controllers/WcController.js +73 -0
- package/lib/commonjs/controllers/WcController.js.map +1 -0
- package/lib/commonjs/features/reown-authentication/ReownAuthentication.js +272 -0
- package/lib/commonjs/features/reown-authentication/ReownAuthentication.js.map +1 -0
- package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js +48 -0
- package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
- package/lib/commonjs/features/reown-authentication/index.js +28 -0
- package/lib/commonjs/features/reown-authentication/index.js.map +1 -0
- package/lib/commonjs/index.js +30 -37
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/utils/ApiUtil.js +1 -1
- package/lib/commonjs/utils/ApiUtil.js.map +1 -1
- package/lib/commonjs/utils/AssetUtil.js +8 -17
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +14 -431
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +33 -10
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/EventUtil.js.map +1 -1
- package/lib/commonjs/utils/FetchUtil.js +41 -12
- package/lib/commonjs/utils/FetchUtil.js.map +1 -1
- package/lib/commonjs/utils/LogUtils.js +131 -0
- package/lib/commonjs/utils/LogUtils.js.map +1 -0
- package/lib/commonjs/utils/StorageUtil.js +119 -172
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js +2 -17
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/commonjs/utils/WalletUtil.js +23 -0
- package/lib/commonjs/utils/WalletUtil.js.map +1 -0
- package/lib/module/controllers/ApiController.js +150 -82
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/AssetController.js +2 -4
- package/lib/module/controllers/AssetController.js.map +1 -1
- package/lib/module/controllers/BlockchainApiController.js +128 -133
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +282 -60
- package/lib/module/controllers/ConnectionsController.js.map +1 -1
- package/lib/module/controllers/EnsController.js +6 -2
- package/lib/module/controllers/EnsController.js.map +1 -1
- package/lib/module/controllers/EventsController.js +54 -2
- package/lib/module/controllers/EventsController.js.map +1 -1
- package/lib/module/controllers/LogController.js +185 -0
- package/lib/module/controllers/LogController.js.map +1 -0
- package/lib/module/controllers/ModalController.js +11 -7
- package/lib/module/controllers/ModalController.js.map +1 -1
- package/lib/module/controllers/OnRampController.js +135 -52
- package/lib/module/controllers/OnRampController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +22 -7
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/PublicStateController.js +2 -0
- package/lib/module/controllers/PublicStateController.js.map +1 -1
- package/lib/module/controllers/RouterController.js +9 -22
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SendController.js +114 -96
- package/lib/module/controllers/SendController.js.map +1 -1
- package/lib/module/controllers/SnackController.js +31 -5
- package/lib/module/controllers/SnackController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +121 -119
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +7 -0
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +25 -17
- package/lib/module/controllers/TransactionsController.js.map +1 -1
- package/lib/module/controllers/WcController.js +70 -0
- package/lib/module/controllers/WcController.js.map +1 -0
- package/lib/module/features/reown-authentication/ReownAuthentication.js +268 -0
- package/lib/module/features/reown-authentication/ReownAuthentication.js.map +1 -0
- package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js +43 -0
- package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
- package/lib/module/features/reown-authentication/index.js +5 -0
- package/lib/module/features/reown-authentication/index.js.map +1 -0
- package/lib/module/index.js +12 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ApiUtil.js +3 -1
- package/lib/module/utils/ApiUtil.js.map +1 -1
- package/lib/module/utils/AssetUtil.js +10 -17
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +16 -431
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +35 -8
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/EventUtil.js +2 -0
- package/lib/module/utils/EventUtil.js.map +1 -1
- package/lib/module/utils/FetchUtil.js +44 -12
- package/lib/module/utils/FetchUtil.js.map +1 -1
- package/lib/module/utils/LogUtils.js +121 -0
- package/lib/module/utils/LogUtils.js.map +1 -0
- package/lib/module/utils/StorageUtil.js +122 -172
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js +4 -17
- package/lib/module/utils/SwapApiUtil.js.map +1 -1
- package/lib/module/utils/SwapCalculationUtil.js +3 -0
- package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/module/utils/WalletUtil.js +19 -0
- package/lib/module/utils/WalletUtil.js.map +1 -0
- package/lib/typescript/controllers/ApiController.d.ts +8 -7
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/AssetController.d.ts +0 -2
- package/lib/typescript/controllers/AssetController.d.ts.map +1 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts +21 -13
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts +22 -18
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/EnsController.d.ts +1 -1
- package/lib/typescript/controllers/EnsController.d.ts.map +1 -1
- package/lib/typescript/controllers/EventsController.d.ts +13 -1
- package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
- package/lib/typescript/controllers/LogController.d.ts +65 -0
- package/lib/typescript/controllers/LogController.d.ts.map +1 -0
- package/lib/typescript/controllers/ModalController.d.ts +1 -1
- package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
- package/lib/typescript/controllers/OnRampController.d.ts +4 -3
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +8 -6
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +6 -21
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- package/lib/typescript/controllers/SendController.d.ts +5 -7
- package/lib/typescript/controllers/SendController.d.ts.map +1 -1
- package/lib/typescript/controllers/SnackController.d.ts +3 -3
- package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
- package/lib/typescript/controllers/SwapController.d.ts +11 -11
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
- package/lib/typescript/controllers/ThemeController.d.ts +2 -0
- package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
- package/lib/typescript/controllers/TransactionsController.d.ts +3 -3
- package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/WcController.d.ts +27 -0
- package/lib/typescript/controllers/WcController.d.ts.map +1 -0
- package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts +174 -0
- package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts.map +1 -0
- package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts +16 -0
- package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts.map +1 -0
- package/lib/typescript/features/reown-authentication/index.d.ts +3 -0
- package/lib/typescript/features/reown-authentication/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/ApiUtil.d.ts +1 -1
- package/lib/typescript/utils/AssetUtil.d.ts +3 -4
- package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +7 -416
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +8 -6
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/EventUtil.d.ts +1 -1
- package/lib/typescript/utils/EventUtil.d.ts.map +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts +3 -3
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
- package/lib/typescript/utils/LogUtils.d.ts +15 -0
- package/lib/typescript/utils/LogUtils.d.ts.map +1 -0
- package/lib/typescript/utils/StorageUtil.d.ts +8 -19
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapApiUtil.d.ts +3 -4
- package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapCalculationUtil.d.ts +1 -1
- package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
- package/lib/typescript/utils/WalletUtil.d.ts +5 -0
- package/lib/typescript/utils/WalletUtil.d.ts.map +1 -0
- package/package.json +12 -25
- package/src/controllers/ApiController.ts +158 -80
- package/src/controllers/AssetController.ts +0 -6
- package/src/controllers/BlockchainApiController.ts +109 -144
- package/src/controllers/ConnectionsController.ts +372 -88
- package/src/controllers/EnsController.ts +5 -3
- package/src/controllers/EventsController.ts +74 -3
- package/src/controllers/LogController.ts +250 -0
- package/src/controllers/ModalController.ts +11 -9
- package/src/controllers/OnRampController.ts +195 -82
- package/src/controllers/OptionsController.ts +40 -13
- package/src/controllers/RouterController.ts +20 -58
- package/src/controllers/SendController.ts +148 -112
- package/src/controllers/SnackController.ts +31 -5
- package/src/controllers/SwapController.ts +140 -148
- package/src/controllers/ThemeController.ts +7 -0
- package/src/controllers/TransactionsController.ts +26 -18
- package/src/controllers/WcController.ts +93 -0
- package/src/features/reown-authentication/ReownAuthentication.ts +475 -0
- package/src/features/reown-authentication/ReownAuthenticationMessenger.ts +80 -0
- package/src/features/reown-authentication/index.ts +2 -0
- package/src/index.ts +15 -22
- package/src/utils/ApiUtil.ts +1 -1
- package/src/utils/AssetUtil.ts +9 -20
- package/src/utils/ConstantsUtil.ts +16 -435
- package/src/utils/CoreHelperUtil.ts +62 -11
- package/src/utils/EventUtil.ts +1 -1
- package/src/utils/FetchUtil.ts +50 -14
- package/src/utils/LogUtils.ts +179 -0
- package/src/utils/StorageUtil.ts +171 -199
- package/src/utils/SwapApiUtil.ts +18 -37
- package/src/utils/SwapCalculationUtil.ts +1 -2
- package/src/utils/WalletUtil.ts +14 -0
- package/lib/commonjs/controllers/AccountController.js +0 -93
- package/lib/commonjs/controllers/AccountController.js.map +0 -1
- package/lib/commonjs/controllers/ConnectionController.js +0 -132
- package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
- package/lib/commonjs/controllers/ConnectorController.js +0 -50
- package/lib/commonjs/controllers/ConnectorController.js.map +0 -1
- package/lib/commonjs/controllers/NetworkController.js +0 -90
- package/lib/commonjs/controllers/NetworkController.js.map +0 -1
- package/lib/commonjs/controllers/WebviewController.js +0 -52
- package/lib/commonjs/controllers/WebviewController.js.map +0 -1
- package/lib/commonjs/utils/NetworkUtil.js +0 -46
- package/lib/commonjs/utils/NetworkUtil.js.map +0 -1
- package/lib/commonjs/utils/RouterUtil.js +0 -25
- package/lib/commonjs/utils/RouterUtil.js.map +0 -1
- package/lib/commonjs/utils/TypeUtil.js +0 -6
- package/lib/commonjs/utils/TypeUtil.js.map +0 -1
- package/lib/module/controllers/AccountController.js +0 -88
- package/lib/module/controllers/AccountController.js.map +0 -1
- package/lib/module/controllers/ConnectionController.js +0 -127
- package/lib/module/controllers/ConnectionController.js.map +0 -1
- package/lib/module/controllers/ConnectorController.js +0 -45
- package/lib/module/controllers/ConnectorController.js.map +0 -1
- package/lib/module/controllers/NetworkController.js +0 -85
- package/lib/module/controllers/NetworkController.js.map +0 -1
- package/lib/module/controllers/WebviewController.js +0 -47
- package/lib/module/controllers/WebviewController.js.map +0 -1
- package/lib/module/utils/NetworkUtil.js +0 -40
- package/lib/module/utils/NetworkUtil.js.map +0 -1
- package/lib/module/utils/RouterUtil.js +0 -19
- package/lib/module/utils/RouterUtil.js.map +0 -1
- package/lib/module/utils/TypeUtil.js +0 -2
- package/lib/module/utils/TypeUtil.js.map +0 -1
- package/lib/typescript/controllers/AccountController.d.ts +0 -33
- package/lib/typescript/controllers/AccountController.d.ts.map +0 -1
- package/lib/typescript/controllers/ConnectionController.d.ts +0 -68
- package/lib/typescript/controllers/ConnectionController.d.ts.map +0 -1
- package/lib/typescript/controllers/ConnectorController.d.ts +0 -18
- package/lib/typescript/controllers/ConnectorController.d.ts.map +0 -1
- package/lib/typescript/controllers/NetworkController.d.ts +0 -34
- package/lib/typescript/controllers/NetworkController.d.ts.map +0 -1
- package/lib/typescript/controllers/WebviewController.d.ts +0 -21
- package/lib/typescript/controllers/WebviewController.d.ts.map +0 -1
- package/lib/typescript/utils/NetworkUtil.d.ts +0 -8
- package/lib/typescript/utils/NetworkUtil.d.ts.map +0 -1
- package/lib/typescript/utils/RouterUtil.d.ts +0 -5
- package/lib/typescript/utils/RouterUtil.d.ts.map +0 -1
- package/lib/typescript/utils/TypeUtil.d.ts +0 -817
- package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
- package/src/controllers/AccountController.ts +0 -128
- package/src/controllers/ConnectionController.ts +0 -208
- package/src/controllers/ConnectorController.ts +0 -64
- package/src/controllers/NetworkController.ts +0 -120
- package/src/controllers/WebviewController.ts +0 -63
- package/src/utils/NetworkUtil.ts +0 -33
- package/src/utils/RouterUtil.ts +0 -21
- package/src/utils/TypeUtil.ts +0 -995
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { subscribeKey as subKey } from 'valtio/
|
|
2
|
-
import { proxy, subscribe as sub } from 'valtio
|
|
3
|
-
import
|
|
4
|
-
OnRampPaymentMethod,
|
|
5
|
-
OnRampCountry,
|
|
6
|
-
OnRampFiatCurrency,
|
|
7
|
-
OnRampQuote,
|
|
8
|
-
OnRampFiatLimit,
|
|
9
|
-
OnRampCryptoCurrency,
|
|
10
|
-
OnRampServiceProvider,
|
|
11
|
-
OnRampError,
|
|
12
|
-
OnRampErrorTypeValues
|
|
13
|
-
|
|
1
|
+
import { subscribeKey as subKey } from 'valtio/utils';
|
|
2
|
+
import { proxy, subscribe as sub } from 'valtio';
|
|
3
|
+
import {
|
|
4
|
+
type OnRampPaymentMethod,
|
|
5
|
+
type OnRampCountry,
|
|
6
|
+
type OnRampFiatCurrency,
|
|
7
|
+
type OnRampQuote,
|
|
8
|
+
type OnRampFiatLimit,
|
|
9
|
+
type OnRampCryptoCurrency,
|
|
10
|
+
type OnRampServiceProvider,
|
|
11
|
+
type OnRampError,
|
|
12
|
+
type OnRampErrorTypeValues,
|
|
13
|
+
type OnRampCountryDefaults,
|
|
14
|
+
BlockchainOnRampError
|
|
15
|
+
} from '@reown/appkit-common-react-native';
|
|
14
16
|
|
|
15
17
|
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
16
|
-
import { NetworkController } from './NetworkController';
|
|
17
|
-
import { AccountController } from './AccountController';
|
|
18
18
|
import { OptionsController } from './OptionsController';
|
|
19
19
|
import { ConstantsUtil, OnRampErrorType } from '../utils/ConstantsUtil';
|
|
20
20
|
import { StorageUtil } from '../utils/StorageUtil';
|
|
21
21
|
import { SnackController } from './SnackController';
|
|
22
|
+
import { LogController } from './LogController';
|
|
22
23
|
import { EventsController } from './EventsController';
|
|
23
|
-
import { BlockchainApiController } from './BlockchainApiController';
|
|
24
|
+
import { BlockchainApiController, EXCLUDED_ONRAMP_PROVIDERS } from './BlockchainApiController';
|
|
25
|
+
import { ConnectionsController } from './ConnectionsController';
|
|
24
26
|
|
|
25
27
|
// -- Helpers ------------------------------------------- //
|
|
26
28
|
|
|
@@ -32,23 +34,27 @@ const mapErrorMessage = (errorCode: string): OnRampError => {
|
|
|
32
34
|
const errorMap: Record<string, { type: OnRampErrorTypeValues; message: string }> = {
|
|
33
35
|
[OnRampErrorType.AMOUNT_TOO_LOW]: {
|
|
34
36
|
type: OnRampErrorType.AMOUNT_TOO_LOW,
|
|
35
|
-
message: '
|
|
37
|
+
message: 'The amount is too low'
|
|
36
38
|
},
|
|
37
39
|
[OnRampErrorType.AMOUNT_TOO_HIGH]: {
|
|
38
40
|
type: OnRampErrorType.AMOUNT_TOO_HIGH,
|
|
39
|
-
message: '
|
|
41
|
+
message: 'The amount is too high'
|
|
40
42
|
},
|
|
41
43
|
[OnRampErrorType.INVALID_AMOUNT]: {
|
|
42
44
|
type: OnRampErrorType.INVALID_AMOUNT,
|
|
43
|
-
message: '
|
|
45
|
+
message: 'Enter a valid amount'
|
|
44
46
|
},
|
|
45
47
|
[OnRampErrorType.INCOMPATIBLE_REQUEST]: {
|
|
46
48
|
type: OnRampErrorType.INCOMPATIBLE_REQUEST,
|
|
47
|
-
message: '
|
|
49
|
+
message: 'Enter a valid amount'
|
|
48
50
|
},
|
|
49
51
|
[OnRampErrorType.BAD_REQUEST]: {
|
|
50
52
|
type: OnRampErrorType.BAD_REQUEST,
|
|
51
|
-
message: '
|
|
53
|
+
message: 'Enter a valid amount'
|
|
54
|
+
},
|
|
55
|
+
[OnRampErrorType.NO_VALID_QUOTES]: {
|
|
56
|
+
type: OnRampErrorType.NO_VALID_QUOTES,
|
|
57
|
+
message: 'No quotes available'
|
|
52
58
|
}
|
|
53
59
|
};
|
|
54
60
|
|
|
@@ -63,6 +69,7 @@ const mapErrorMessage = (errorCode: string): OnRampError => {
|
|
|
63
69
|
// -- Types --------------------------------------------- //
|
|
64
70
|
export interface OnRampControllerState {
|
|
65
71
|
countries: OnRampCountry[];
|
|
72
|
+
countriesDefaults?: OnRampCountryDefaults[];
|
|
66
73
|
selectedCountry?: OnRampCountry;
|
|
67
74
|
serviceProviders: OnRampServiceProvider[];
|
|
68
75
|
selectedServiceProvider?: OnRampServiceProvider;
|
|
@@ -109,33 +116,44 @@ export const OnRampController = {
|
|
|
109
116
|
},
|
|
110
117
|
|
|
111
118
|
async setSelectedCountry(country: OnRampCountry, updateCurrency = true) {
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
try {
|
|
120
|
+
state.selectedCountry = country;
|
|
121
|
+
state.loading = true;
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
] || 'USD';
|
|
123
|
+
if (updateCurrency) {
|
|
124
|
+
const currencyCode =
|
|
125
|
+
state.countriesDefaults?.find(d => d.countryCode === country.countryCode)
|
|
126
|
+
?.defaultCurrencyCode || 'USD';
|
|
120
127
|
|
|
121
|
-
|
|
128
|
+
let currency = state.paymentCurrencies?.find(c => c.currencyCode === currencyCode);
|
|
122
129
|
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
if (!currency) {
|
|
131
|
+
currency = state.paymentCurrencies?.find(c => c.currencyCode === 'USD');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (currency) {
|
|
135
|
+
this.setPaymentCurrency(currency);
|
|
136
|
+
}
|
|
125
137
|
}
|
|
126
|
-
}
|
|
127
138
|
|
|
128
|
-
|
|
139
|
+
await Promise.all([this.fetchPaymentMethods(), this.fetchCryptoCurrencies()]);
|
|
140
|
+
this.clearQuotes();
|
|
129
141
|
|
|
130
|
-
|
|
142
|
+
state.loading = false;
|
|
131
143
|
|
|
132
|
-
|
|
144
|
+
StorageUtil.setOnRampPreferredCountry(country);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
LogController.sendError(error, 'OnRampController.ts', 'setSelectedCountry');
|
|
147
|
+
state.loading = false;
|
|
148
|
+
state.error = {
|
|
149
|
+
type: OnRampErrorType.FAILED_TO_LOAD_COUNTRIES,
|
|
150
|
+
message: 'Failed to load countries'
|
|
151
|
+
};
|
|
152
|
+
}
|
|
133
153
|
},
|
|
134
154
|
|
|
135
155
|
setSelectedPaymentMethod(paymentMethod: OnRampPaymentMethod) {
|
|
136
156
|
state.selectedPaymentMethod = paymentMethod;
|
|
137
|
-
|
|
138
|
-
this.clearQuotes();
|
|
139
157
|
},
|
|
140
158
|
|
|
141
159
|
setPurchaseCurrency(currency: OnRampCryptoCurrency) {
|
|
@@ -175,16 +193,16 @@ export const OnRampController = {
|
|
|
175
193
|
|
|
176
194
|
updateSelectedPurchaseCurrency() {
|
|
177
195
|
let selectedCurrency;
|
|
178
|
-
if (
|
|
196
|
+
if (ConnectionsController.state.activeNetwork?.caipNetworkId) {
|
|
179
197
|
const defaultCurrency =
|
|
180
198
|
ConstantsUtil.NETWORK_DEFAULT_CURRENCIES[
|
|
181
|
-
|
|
182
|
-
?.
|
|
199
|
+
ConnectionsController.state.activeNetwork
|
|
200
|
+
?.caipNetworkId as keyof typeof ConstantsUtil.NETWORK_DEFAULT_CURRENCIES
|
|
183
201
|
];
|
|
184
202
|
selectedCurrency = state.purchaseCurrencies?.find(c => c.currencyCode === defaultCurrency);
|
|
185
203
|
}
|
|
186
204
|
|
|
187
|
-
state.purchaseCurrency = selectedCurrency
|
|
205
|
+
state.purchaseCurrency = selectedCurrency ?? undefined;
|
|
188
206
|
},
|
|
189
207
|
|
|
190
208
|
getServiceProviderImage(serviceProviderName?: string) {
|
|
@@ -224,6 +242,7 @@ export const OnRampController = {
|
|
|
224
242
|
countries.find(c => c.countryCode === countryCode) || countries[0] || undefined;
|
|
225
243
|
}
|
|
226
244
|
} catch (error) {
|
|
245
|
+
LogController.sendError(error, 'OnRampController.ts', 'fetchCountries');
|
|
227
246
|
state.error = {
|
|
228
247
|
type: OnRampErrorType.FAILED_TO_LOAD_COUNTRIES,
|
|
229
248
|
message: 'Failed to load countries'
|
|
@@ -231,6 +250,28 @@ export const OnRampController = {
|
|
|
231
250
|
}
|
|
232
251
|
},
|
|
233
252
|
|
|
253
|
+
async fetchCountriesDefaults() {
|
|
254
|
+
try {
|
|
255
|
+
let countriesDefaults = await StorageUtil.getOnRampCountriesDefaults();
|
|
256
|
+
|
|
257
|
+
if (!countriesDefaults.length) {
|
|
258
|
+
countriesDefaults = (await BlockchainApiController.fetchOnRampCountriesDefaults()) ?? [];
|
|
259
|
+
|
|
260
|
+
if (countriesDefaults.length) {
|
|
261
|
+
StorageUtil.setOnRampCountriesDefaults(countriesDefaults);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
state.countriesDefaults = countriesDefaults;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
LogController.sendError(error, 'OnRampController.ts', 'fetchCountriesDefaults');
|
|
268
|
+
state.error = {
|
|
269
|
+
type: OnRampErrorType.FAILED_TO_LOAD_COUNTRIES,
|
|
270
|
+
message: 'Failed to load countries defaults'
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
|
|
234
275
|
async fetchServiceProviders() {
|
|
235
276
|
try {
|
|
236
277
|
let serviceProviders = await StorageUtil.getOnRampServiceProviders();
|
|
@@ -245,6 +286,7 @@ export const OnRampController = {
|
|
|
245
286
|
|
|
246
287
|
state.serviceProviders = serviceProviders || [];
|
|
247
288
|
} catch (error) {
|
|
289
|
+
LogController.sendError(error, 'OnRampController.ts', 'fetchServiceProviders');
|
|
248
290
|
state.error = {
|
|
249
291
|
type: OnRampErrorType.FAILED_TO_LOAD_PROVIDERS,
|
|
250
292
|
message: 'Failed to load service providers'
|
|
@@ -259,10 +301,8 @@ export const OnRampController = {
|
|
|
259
301
|
});
|
|
260
302
|
|
|
261
303
|
const defaultCountryPaymentMethods =
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
?.countryCode as keyof typeof ConstantsUtil.COUNTRY_DEFAULT_PAYMENT_METHOD
|
|
265
|
-
];
|
|
304
|
+
state.countriesDefaults?.find(d => d.countryCode === state.selectedCountry?.countryCode)
|
|
305
|
+
?.defaultPaymentMethods || [];
|
|
266
306
|
|
|
267
307
|
state.paymentMethods =
|
|
268
308
|
paymentMethods?.sort((a, b) => {
|
|
@@ -276,10 +316,9 @@ export const OnRampController = {
|
|
|
276
316
|
return aIndex - bIndex;
|
|
277
317
|
}) || [];
|
|
278
318
|
|
|
279
|
-
state.selectedPaymentMethod = paymentMethods
|
|
280
|
-
|
|
281
|
-
this.clearQuotes();
|
|
319
|
+
state.selectedPaymentMethod = state.paymentMethods[0];
|
|
282
320
|
} catch (error) {
|
|
321
|
+
LogController.sendError(error, 'OnRampController.ts', 'fetchPaymentMethods');
|
|
283
322
|
state.error = {
|
|
284
323
|
type: OnRampErrorType.FAILED_TO_LOAD_METHODS,
|
|
285
324
|
message: 'Failed to load payment methods'
|
|
@@ -298,17 +337,18 @@ export const OnRampController = {
|
|
|
298
337
|
state.purchaseCurrencies = cryptoCurrencies || [];
|
|
299
338
|
|
|
300
339
|
let selectedCurrency;
|
|
301
|
-
if (
|
|
340
|
+
if (ConnectionsController.state.activeNetwork?.caipNetworkId) {
|
|
302
341
|
const defaultCurrency =
|
|
303
342
|
ConstantsUtil.NETWORK_DEFAULT_CURRENCIES[
|
|
304
|
-
|
|
305
|
-
?.
|
|
306
|
-
]
|
|
343
|
+
ConnectionsController.state.activeNetwork
|
|
344
|
+
?.caipNetworkId as keyof typeof ConstantsUtil.NETWORK_DEFAULT_CURRENCIES
|
|
345
|
+
];
|
|
307
346
|
selectedCurrency = state.purchaseCurrencies?.find(c => c.currencyCode === defaultCurrency);
|
|
308
347
|
}
|
|
309
348
|
|
|
310
|
-
state.purchaseCurrency = selectedCurrency ||
|
|
349
|
+
state.purchaseCurrency = selectedCurrency || undefined;
|
|
311
350
|
} catch (error) {
|
|
351
|
+
LogController.sendError(error, 'OnRampController.ts', 'fetchCryptoCurrencies');
|
|
312
352
|
state.error = {
|
|
313
353
|
type: OnRampErrorType.FAILED_TO_LOAD_CURRENCIES,
|
|
314
354
|
message: 'Failed to load crypto currencies'
|
|
@@ -336,9 +376,8 @@ export const OnRampController = {
|
|
|
336
376
|
|
|
337
377
|
if (countryCode) {
|
|
338
378
|
currencyCode =
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
];
|
|
379
|
+
state.countriesDefaults?.find(d => d.countryCode === countryCode)?.defaultCurrencyCode ||
|
|
380
|
+
'USD';
|
|
342
381
|
}
|
|
343
382
|
|
|
344
383
|
const preferredCurrency = await StorageUtil.getOnRampPreferredFiatCurrency();
|
|
@@ -353,6 +392,7 @@ export const OnRampController = {
|
|
|
353
392
|
this.setPaymentCurrency(defaultCurrency);
|
|
354
393
|
}
|
|
355
394
|
} catch (error) {
|
|
395
|
+
LogController.sendError(error, 'OnRampController.ts', 'fetchFiatCurrencies');
|
|
356
396
|
state.error = {
|
|
357
397
|
type: OnRampErrorType.FAILED_TO_LOAD_CURRENCIES,
|
|
358
398
|
message: 'Failed to load fiat currencies'
|
|
@@ -375,50 +415,103 @@ export const OnRampController = {
|
|
|
375
415
|
}
|
|
376
416
|
},
|
|
377
417
|
|
|
378
|
-
getQuotesDebounced: CoreHelperUtil.debounce(function () {
|
|
379
|
-
OnRampController.getQuotes();
|
|
380
|
-
}, 500),
|
|
381
|
-
|
|
382
418
|
async getQuotes() {
|
|
383
|
-
if (!
|
|
419
|
+
if (!this.canGenerateQuote()) {
|
|
384
420
|
this.clearQuotes();
|
|
385
421
|
|
|
386
422
|
return;
|
|
387
423
|
}
|
|
388
424
|
|
|
389
|
-
state.quotesLoading = true;
|
|
390
|
-
state.error = undefined;
|
|
391
|
-
|
|
392
425
|
this.abortGetQuotes(false);
|
|
393
426
|
quotesAbortController = new AbortController();
|
|
427
|
+
const currentSignal = quotesAbortController.signal;
|
|
394
428
|
|
|
395
429
|
try {
|
|
430
|
+
if (
|
|
431
|
+
!state.selectedCountry?.countryCode ||
|
|
432
|
+
!state.purchaseCurrency?.currencyCode ||
|
|
433
|
+
!state.paymentCurrency?.currencyCode ||
|
|
434
|
+
!ConnectionsController.state.activeAddress
|
|
435
|
+
) {
|
|
436
|
+
throw new BlockchainOnRampError(OnRampErrorType.UNKNOWN, 'Invalid quote parameters');
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
state.quotesLoading = true;
|
|
440
|
+
state.selectedQuote = undefined;
|
|
441
|
+
state.selectedServiceProvider = undefined;
|
|
442
|
+
state.error = undefined;
|
|
443
|
+
|
|
444
|
+
const plainAddress = CoreHelperUtil.getPlainAddress(
|
|
445
|
+
ConnectionsController.state.activeAddress
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
if (!plainAddress) {
|
|
449
|
+
throw new Error('Invalid address');
|
|
450
|
+
}
|
|
451
|
+
|
|
396
452
|
const body = {
|
|
397
|
-
countryCode: state.selectedCountry
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
453
|
+
countryCode: state.selectedCountry.countryCode,
|
|
454
|
+
destinationCurrencyCode: state.purchaseCurrency.currencyCode,
|
|
455
|
+
sourceAmount: state.paymentAmount!,
|
|
456
|
+
sourceCurrencyCode: state.paymentCurrency.currencyCode,
|
|
457
|
+
walletAddress: plainAddress,
|
|
458
|
+
excludeProviders: EXCLUDED_ONRAMP_PROVIDERS
|
|
403
459
|
};
|
|
404
460
|
|
|
405
|
-
const response = await BlockchainApiController.getOnRampQuotes(
|
|
406
|
-
body,
|
|
407
|
-
quotesAbortController.signal
|
|
408
|
-
);
|
|
461
|
+
const response = await BlockchainApiController.getOnRampQuotes(body, currentSignal);
|
|
409
462
|
|
|
410
463
|
if (!response || !response.length) {
|
|
411
|
-
throw new
|
|
464
|
+
throw new BlockchainOnRampError(OnRampErrorType.NO_VALID_QUOTES, 'No valid quotes');
|
|
412
465
|
}
|
|
413
466
|
|
|
414
467
|
const quotes = response.sort((a, b) => b.customerScore - a.customerScore);
|
|
415
468
|
|
|
416
469
|
state.quotes = quotes;
|
|
417
|
-
|
|
470
|
+
|
|
471
|
+
//Replace payment method if it's not in the quotes
|
|
472
|
+
const isValidPaymentMethod =
|
|
473
|
+
state.selectedPaymentMethod &&
|
|
474
|
+
quotes.some(
|
|
475
|
+
quote => quote.paymentMethodType === state.selectedPaymentMethod?.paymentMethod
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
if (!isValidPaymentMethod) {
|
|
479
|
+
const countryMethods =
|
|
480
|
+
state.countriesDefaults?.find(d => d.countryCode === state.selectedCountry?.countryCode)
|
|
481
|
+
?.defaultPaymentMethods || [];
|
|
482
|
+
|
|
483
|
+
const availableQuoteMethods = new Set(quotes.map(q => q.paymentMethodType));
|
|
484
|
+
|
|
485
|
+
let newPaymentMethodType: string | undefined;
|
|
486
|
+
for (const dpm of countryMethods) {
|
|
487
|
+
if (availableQuoteMethods.has(dpm)) {
|
|
488
|
+
newPaymentMethodType = dpm;
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (newPaymentMethodType) {
|
|
494
|
+
state.selectedPaymentMethod =
|
|
495
|
+
state.paymentMethods.find(m => m.paymentMethod === newPaymentMethodType) ||
|
|
496
|
+
state.paymentMethods.find(
|
|
497
|
+
method => method.paymentMethod === quotes[0]?.paymentMethodType
|
|
498
|
+
);
|
|
499
|
+
} else {
|
|
500
|
+
state.selectedPaymentMethod = state.paymentMethods.find(
|
|
501
|
+
method => method.paymentMethod === quotes[0]?.paymentMethodType
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
state.selectedQuote = quotes.find(
|
|
507
|
+
quote => quote.paymentMethodType === state.selectedPaymentMethod?.paymentMethod
|
|
508
|
+
);
|
|
509
|
+
|
|
418
510
|
state.selectedServiceProvider = state.serviceProviders.find(
|
|
419
|
-
sp => sp.serviceProvider ===
|
|
511
|
+
sp => sp.serviceProvider === state.selectedQuote?.serviceProvider
|
|
420
512
|
);
|
|
421
513
|
} catch (error: any) {
|
|
514
|
+
LogController.sendError(error, 'OnRampController.ts', 'getQuotes');
|
|
422
515
|
if (error.name === 'AbortError') {
|
|
423
516
|
// Do nothing, another request was made
|
|
424
517
|
return;
|
|
@@ -435,7 +528,9 @@ export const OnRampController = {
|
|
|
435
528
|
this.clearQuotes();
|
|
436
529
|
state.error = mapErrorMessage(error?.code || 'UNKNOWN_ERROR');
|
|
437
530
|
} finally {
|
|
438
|
-
|
|
531
|
+
if (!currentSignal.aborted) {
|
|
532
|
+
state.quotesLoading = false;
|
|
533
|
+
}
|
|
439
534
|
}
|
|
440
535
|
},
|
|
441
536
|
|
|
@@ -449,7 +544,7 @@ export const OnRampController = {
|
|
|
449
544
|
state.paymentCurrency?.currencyCode &&
|
|
450
545
|
state.selectedCountry &&
|
|
451
546
|
!state.loading &&
|
|
452
|
-
|
|
547
|
+
ConnectionsController.state.activeAddress
|
|
453
548
|
);
|
|
454
549
|
},
|
|
455
550
|
|
|
@@ -467,6 +562,7 @@ export const OnRampController = {
|
|
|
467
562
|
|
|
468
563
|
state.paymentCurrenciesLimits = limits;
|
|
469
564
|
} catch (error) {
|
|
565
|
+
LogController.sendError(error, 'OnRampController.ts', 'fetchFiatLimits');
|
|
470
566
|
state.error = {
|
|
471
567
|
type: OnRampErrorType.FAILED_TO_LOAD_LIMITS,
|
|
472
568
|
message: 'Failed to load fiat limits'
|
|
@@ -476,6 +572,10 @@ export const OnRampController = {
|
|
|
476
572
|
},
|
|
477
573
|
|
|
478
574
|
async generateWidget({ quote }: { quote: OnRampQuote }) {
|
|
575
|
+
if (!ConnectionsController.state.activeAddress) {
|
|
576
|
+
throw new Error('No active address');
|
|
577
|
+
}
|
|
578
|
+
|
|
479
579
|
const metadata = OptionsController.state.metadata;
|
|
480
580
|
const eventProperties = {
|
|
481
581
|
asset: quote.destinationCurrencyCode,
|
|
@@ -492,16 +592,26 @@ export const OnRampController = {
|
|
|
492
592
|
throw new Error('Invalid quote');
|
|
493
593
|
}
|
|
494
594
|
|
|
495
|
-
const
|
|
595
|
+
const plainAddress = CoreHelperUtil.getPlainAddress(
|
|
596
|
+
ConnectionsController.state.activeAddress
|
|
597
|
+
);
|
|
598
|
+
|
|
599
|
+
if (!plainAddress) {
|
|
600
|
+
throw new Error('Invalid address');
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const body = {
|
|
496
604
|
countryCode: quote.countryCode,
|
|
497
605
|
destinationCurrencyCode: quote.destinationCurrencyCode,
|
|
498
606
|
paymentMethodType: quote.paymentMethodType,
|
|
499
607
|
serviceProvider: quote.serviceProvider,
|
|
500
608
|
sourceAmount: quote.sourceAmount,
|
|
501
609
|
sourceCurrencyCode: quote.sourceCurrencyCode,
|
|
502
|
-
walletAddress:
|
|
610
|
+
walletAddress: plainAddress,
|
|
503
611
|
redirectUrl: metadata?.redirect?.universal ?? metadata?.redirect?.native
|
|
504
|
-
}
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
const widget = await BlockchainApiController.getOnRampWidget(body);
|
|
505
615
|
|
|
506
616
|
if (!widget || !widget.widgetUrl) {
|
|
507
617
|
throw new Error('Invalid widget response');
|
|
@@ -517,6 +627,7 @@ export const OnRampController = {
|
|
|
517
627
|
|
|
518
628
|
return widget;
|
|
519
629
|
} catch (e: any) {
|
|
630
|
+
LogController.sendError(e, 'OnRampController.ts', 'generateWidget', { quote });
|
|
520
631
|
EventsController.sendEvent({
|
|
521
632
|
type: 'track',
|
|
522
633
|
event: 'BUY_FAIL',
|
|
@@ -555,12 +666,14 @@ export const OnRampController = {
|
|
|
555
666
|
await this.fetchServiceProviders();
|
|
556
667
|
|
|
557
668
|
await Promise.all([
|
|
669
|
+
this.fetchCountriesDefaults(),
|
|
558
670
|
this.fetchPaymentMethods(),
|
|
559
671
|
this.fetchFiatLimits(),
|
|
560
672
|
this.fetchCryptoCurrencies(),
|
|
561
673
|
this.fetchFiatCurrencies()
|
|
562
674
|
]);
|
|
563
675
|
} catch (error) {
|
|
676
|
+
LogController.sendError(error, 'OnRampController.ts', 'loadOnRampData');
|
|
564
677
|
if (!state.error) {
|
|
565
678
|
state.error = {
|
|
566
679
|
type: OnRampErrorType.FAILED_TO_LOAD,
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { proxy, ref } from 'valtio';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
Storage,
|
|
4
|
+
Metadata,
|
|
5
|
+
AppKitNetwork,
|
|
6
|
+
CustomWallet,
|
|
7
|
+
Features,
|
|
8
|
+
ProjectId,
|
|
9
|
+
SdkType,
|
|
10
|
+
SdkVersion,
|
|
11
|
+
SIWXConfig
|
|
12
|
+
} from '@reown/appkit-common-react-native';
|
|
4
13
|
|
|
5
14
|
import { ConstantsUtil } from '../utils/ConstantsUtil';
|
|
6
15
|
|
|
@@ -17,23 +26,25 @@ export interface OptionsControllerState {
|
|
|
17
26
|
excludeWalletIds?: string[];
|
|
18
27
|
featuredWalletIds?: string[];
|
|
19
28
|
customWallets?: CustomWallet[];
|
|
20
|
-
tokens?: Tokens;
|
|
21
29
|
enableAnalytics?: boolean;
|
|
22
30
|
sdkType: SdkType;
|
|
23
31
|
sdkVersion: SdkVersion;
|
|
24
32
|
metadata?: Metadata;
|
|
25
|
-
|
|
33
|
+
siwx?: SIWXConfig;
|
|
26
34
|
isOnRampEnabled?: boolean;
|
|
27
35
|
features?: Features;
|
|
28
36
|
debug?: boolean;
|
|
37
|
+
defaultNetwork?: AppKitNetwork;
|
|
38
|
+
requestedNetworks?: AppKitNetwork[];
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
// -- State --------------------------------------------- //
|
|
32
42
|
const state = proxy<OptionsControllerState>({
|
|
33
43
|
projectId: '',
|
|
34
44
|
sdkType: 'appkit',
|
|
35
|
-
sdkVersion: 'react-native-
|
|
45
|
+
sdkVersion: 'react-native-undefined-undefined',
|
|
36
46
|
features: ConstantsUtil.DEFAULT_FEATURES,
|
|
47
|
+
customWallets: [],
|
|
37
48
|
debug: false
|
|
38
49
|
});
|
|
39
50
|
|
|
@@ -61,10 +72,6 @@ export const OptionsController = {
|
|
|
61
72
|
state.featuredWalletIds = featuredWalletIds;
|
|
62
73
|
},
|
|
63
74
|
|
|
64
|
-
setTokens(tokens: OptionsControllerState['tokens']) {
|
|
65
|
-
state.tokens = tokens;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
75
|
setCustomWallets(customWallets: OptionsControllerState['customWallets']) {
|
|
69
76
|
state.customWallets = customWallets;
|
|
70
77
|
},
|
|
@@ -81,10 +88,6 @@ export const OptionsController = {
|
|
|
81
88
|
state.metadata = metadata;
|
|
82
89
|
},
|
|
83
90
|
|
|
84
|
-
setIsSiweEnabled(isSiweEnabled: OptionsControllerState['isSiweEnabled']) {
|
|
85
|
-
state.isSiweEnabled = isSiweEnabled;
|
|
86
|
-
},
|
|
87
|
-
|
|
88
91
|
setFeatures(features: OptionsControllerState['features']) {
|
|
89
92
|
state.features = { ...ConstantsUtil.DEFAULT_FEATURES, ...features };
|
|
90
93
|
},
|
|
@@ -103,10 +106,34 @@ export const OptionsController = {
|
|
|
103
106
|
}
|
|
104
107
|
},
|
|
105
108
|
|
|
109
|
+
setDefaultNetwork(defaultNetwork?: OptionsControllerState['defaultNetwork']) {
|
|
110
|
+
state.defaultNetwork = defaultNetwork;
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
setRequestedNetworks(requestedNetworks?: OptionsControllerState['requestedNetworks']) {
|
|
114
|
+
state.requestedNetworks = requestedNetworks;
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
setSiwx(siwx?: OptionsControllerState['siwx']) {
|
|
118
|
+
if (siwx && (siwx?.signOutOnDisconnect === undefined || siwx?.signOutOnDisconnect === null)) {
|
|
119
|
+
siwx.signOutOnDisconnect = true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
state.siwx = siwx;
|
|
123
|
+
},
|
|
124
|
+
|
|
106
125
|
isClipboardAvailable() {
|
|
107
126
|
return !!state.clipboardClient;
|
|
108
127
|
},
|
|
109
128
|
|
|
129
|
+
getStorage() {
|
|
130
|
+
if (!state.storage) {
|
|
131
|
+
throw new Error('AppKit: Storage is not set');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return state.storage;
|
|
135
|
+
},
|
|
136
|
+
|
|
110
137
|
copyToClipboard(value: string) {
|
|
111
138
|
const client = state.clipboardClient;
|
|
112
139
|
if (client) {
|