@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
|
@@ -32,31 +32,44 @@ import type {
|
|
|
32
32
|
OnRampQuote,
|
|
33
33
|
BlockchainApiOnRampWidgetRequest,
|
|
34
34
|
BlockchainApiOnRampQuotesRequest,
|
|
35
|
-
OnRampFiatLimit
|
|
36
|
-
|
|
35
|
+
OnRampFiatLimit,
|
|
36
|
+
OnRampCountryDefaults,
|
|
37
|
+
CaipAddress,
|
|
38
|
+
CaipNetworkId
|
|
39
|
+
} from '@reown/appkit-common-react-native';
|
|
37
40
|
import { OptionsController } from './OptionsController';
|
|
38
41
|
import { ConstantsUtil } from '../utils/ConstantsUtil';
|
|
39
42
|
import { ApiUtil } from '../utils/ApiUtil';
|
|
40
|
-
|
|
41
|
-
import { ConnectionsController } from './ConnectionsController';
|
|
43
|
+
|
|
42
44
|
import { SnackController } from './SnackController';
|
|
45
|
+
import { LogController } from './LogController';
|
|
43
46
|
|
|
44
47
|
// -- Helpers ------------------------------------------- //
|
|
45
48
|
const baseUrl = CoreHelperUtil.getBlockchainApiUrl();
|
|
46
49
|
|
|
47
|
-
const
|
|
48
|
-
const { sdkType, sdkVersion } = OptionsController.state;
|
|
50
|
+
const getParams = () => {
|
|
51
|
+
const { projectId, sdkType, sdkVersion } = OptionsController.state;
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
projectId,
|
|
55
|
+
st: sdkType,
|
|
56
|
+
sv: sdkVersion
|
|
57
|
+
};
|
|
58
|
+
};
|
|
49
59
|
|
|
60
|
+
const getHeaders = () => {
|
|
50
61
|
return {
|
|
51
62
|
'Content-Type': 'application/json',
|
|
52
|
-
'x-sdk-type': sdkType,
|
|
53
|
-
'x-sdk-version': sdkVersion,
|
|
54
63
|
'User-Agent': ApiUtil.getUserAgent(),
|
|
55
64
|
'origin': ApiUtil.getOrigin()
|
|
56
65
|
};
|
|
57
66
|
};
|
|
58
67
|
|
|
68
|
+
export const EXCLUDED_ONRAMP_PROVIDERS = ['BINANCECONNECT', 'COINBASEPAY'];
|
|
69
|
+
|
|
59
70
|
// -- Types --------------------------------------------- //
|
|
71
|
+
type WithCaipNetworkId = { caipNetworkId: CaipNetworkId };
|
|
72
|
+
|
|
60
73
|
export interface BlockchainApiControllerState {
|
|
61
74
|
clientId: string | null;
|
|
62
75
|
api: FetchUtil;
|
|
@@ -83,6 +96,8 @@ export const BlockchainApiController = {
|
|
|
83
96
|
await BlockchainApiController.getSupportedNetworks();
|
|
84
97
|
}
|
|
85
98
|
} catch (e) {
|
|
99
|
+
LogController.sendError(e, 'BlockchainApiController.ts', 'isNetworkSupported');
|
|
100
|
+
|
|
86
101
|
return false;
|
|
87
102
|
}
|
|
88
103
|
|
|
@@ -91,7 +106,8 @@ export const BlockchainApiController = {
|
|
|
91
106
|
|
|
92
107
|
async getSupportedNetworks() {
|
|
93
108
|
const supportedChains = await state.api.get<BlockchainApiControllerState['supportedChains']>({
|
|
94
|
-
path: 'v1/supported-chains'
|
|
109
|
+
path: 'v1/supported-chains',
|
|
110
|
+
params: getParams()
|
|
95
111
|
});
|
|
96
112
|
|
|
97
113
|
state.supportedChains = supportedChains!;
|
|
@@ -99,35 +115,19 @@ export const BlockchainApiController = {
|
|
|
99
115
|
return supportedChains;
|
|
100
116
|
},
|
|
101
117
|
|
|
102
|
-
async fetchIdentity(
|
|
103
|
-
const
|
|
104
|
-
ConnectionsController.state.activeCaipNetworkId
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
if (!isSupported) {
|
|
108
|
-
return { avatar: '', name: '' };
|
|
109
|
-
}
|
|
118
|
+
async fetchIdentity(params: BlockchainApiIdentityRequest) {
|
|
119
|
+
const { address } = params;
|
|
110
120
|
|
|
111
121
|
return state.api.get<BlockchainApiIdentityResponse>({
|
|
112
122
|
path: `/v1/identity/${address}`,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
headers: getHeaders()
|
|
123
|
+
headers: getHeaders(),
|
|
124
|
+
params: getParams()
|
|
117
125
|
});
|
|
118
126
|
},
|
|
119
127
|
|
|
120
|
-
async fetchTransactions({
|
|
121
|
-
account,
|
|
122
|
-
|
|
123
|
-
cursor,
|
|
124
|
-
onramp,
|
|
125
|
-
signal,
|
|
126
|
-
cache,
|
|
127
|
-
chainId
|
|
128
|
-
}: BlockchainApiTransactionsRequest) {
|
|
129
|
-
const _chainId = chainId ?? ConnectionsController.state.activeCaipNetworkId;
|
|
130
|
-
const isSupported = await BlockchainApiController.isNetworkSupported(_chainId);
|
|
128
|
+
async fetchTransactions(params: BlockchainApiTransactionsRequest) {
|
|
129
|
+
const { account, cursor, signal, cache, chainId } = params;
|
|
130
|
+
const isSupported = ConstantsUtil.ACTIVITY_SUPPORTED_CHAINS.includes(chainId);
|
|
131
131
|
|
|
132
132
|
if (!isSupported) {
|
|
133
133
|
return { data: [], next: undefined };
|
|
@@ -137,10 +137,9 @@ export const BlockchainApiController = {
|
|
|
137
137
|
path: `/v1/account/${account}/history`,
|
|
138
138
|
headers: getHeaders(),
|
|
139
139
|
params: {
|
|
140
|
-
|
|
140
|
+
...getParams(),
|
|
141
141
|
cursor,
|
|
142
|
-
|
|
143
|
-
chainId: _chainId
|
|
142
|
+
chainId
|
|
144
143
|
},
|
|
145
144
|
signal,
|
|
146
145
|
cache
|
|
@@ -149,10 +148,9 @@ export const BlockchainApiController = {
|
|
|
149
148
|
return response;
|
|
150
149
|
},
|
|
151
150
|
|
|
152
|
-
async fetchTokenPrice(
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
);
|
|
151
|
+
async fetchTokenPrice(params: BlockchainApiTokenPriceRequest & WithCaipNetworkId) {
|
|
152
|
+
const { projectId, addresses, caipNetworkId } = params;
|
|
153
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(caipNetworkId);
|
|
156
154
|
|
|
157
155
|
if (!isSupported) {
|
|
158
156
|
return { fungibles: [] };
|
|
@@ -160,25 +158,23 @@ export const BlockchainApiController = {
|
|
|
160
158
|
|
|
161
159
|
const response = await state.api.post<BlockchainApiTokenPriceResponse>({
|
|
162
160
|
path: '/v1/fungible/price',
|
|
161
|
+
headers: getHeaders(),
|
|
162
|
+
params: getParams(),
|
|
163
163
|
body: {
|
|
164
164
|
projectId,
|
|
165
165
|
currency: 'usd',
|
|
166
166
|
addresses
|
|
167
|
-
}
|
|
168
|
-
headers: getHeaders()
|
|
167
|
+
}
|
|
169
168
|
});
|
|
170
169
|
|
|
171
170
|
return response;
|
|
172
171
|
},
|
|
173
172
|
|
|
174
|
-
async fetchSwapAllowance({
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const isSupported = await BlockchainApiController.isNetworkSupported(
|
|
180
|
-
ConnectionsController.state.activeCaipNetworkId
|
|
181
|
-
);
|
|
173
|
+
async fetchSwapAllowance(params: BlockchainApiSwapAllowanceRequest) {
|
|
174
|
+
const { tokenAddress, userAddress } = params;
|
|
175
|
+
const [namespace, chain] = userAddress.split(':');
|
|
176
|
+
const networkId: CaipNetworkId = `${namespace}:${chain}`;
|
|
177
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
|
|
182
178
|
|
|
183
179
|
if (!isSupported) {
|
|
184
180
|
return { allowance: '0' };
|
|
@@ -187,7 +183,7 @@ export const BlockchainApiController = {
|
|
|
187
183
|
return state.api.get<BlockchainApiSwapAllowanceResponse>({
|
|
188
184
|
path: `/v1/convert/allowance`,
|
|
189
185
|
params: {
|
|
190
|
-
|
|
186
|
+
...getParams(),
|
|
191
187
|
tokenAddress,
|
|
192
188
|
userAddress
|
|
193
189
|
},
|
|
@@ -195,10 +191,9 @@ export const BlockchainApiController = {
|
|
|
195
191
|
});
|
|
196
192
|
},
|
|
197
193
|
|
|
198
|
-
async fetchGasPrice(
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
);
|
|
194
|
+
async fetchGasPrice(params: BlockchainApiGasPriceRequest) {
|
|
195
|
+
const { chainId } = params;
|
|
196
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
|
|
202
197
|
|
|
203
198
|
if (!isSupported) {
|
|
204
199
|
throw new Error('Network not supported for Gas Price');
|
|
@@ -208,23 +203,17 @@ export const BlockchainApiController = {
|
|
|
208
203
|
path: `/v1/convert/gas-price`,
|
|
209
204
|
headers: getHeaders(),
|
|
210
205
|
params: {
|
|
211
|
-
|
|
206
|
+
...getParams(),
|
|
212
207
|
chainId
|
|
213
208
|
}
|
|
214
209
|
});
|
|
215
210
|
},
|
|
216
211
|
|
|
217
|
-
async fetchSwapQuote({
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
to,
|
|
223
|
-
gasPrice
|
|
224
|
-
}: BlockchainApiSwapQuoteRequest) {
|
|
225
|
-
const isSupported = await BlockchainApiController.isNetworkSupported(
|
|
226
|
-
ConnectionsController.state.activeCaipNetworkId
|
|
227
|
-
);
|
|
212
|
+
async fetchSwapQuote(params: BlockchainApiSwapQuoteRequest) {
|
|
213
|
+
const { amount, userAddress, from, to, gasPrice } = params;
|
|
214
|
+
const [namespace, chain] = userAddress.split(':');
|
|
215
|
+
const networkId: CaipNetworkId = `${namespace}:${chain}`;
|
|
216
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
|
|
228
217
|
|
|
229
218
|
if (!isSupported) {
|
|
230
219
|
return { quotes: [] };
|
|
@@ -234,7 +223,7 @@ export const BlockchainApiController = {
|
|
|
234
223
|
path: `/v1/convert/quotes`,
|
|
235
224
|
headers: getHeaders(),
|
|
236
225
|
params: {
|
|
237
|
-
|
|
226
|
+
...getParams(),
|
|
238
227
|
amount,
|
|
239
228
|
userAddress,
|
|
240
229
|
from,
|
|
@@ -244,10 +233,9 @@ export const BlockchainApiController = {
|
|
|
244
233
|
});
|
|
245
234
|
},
|
|
246
235
|
|
|
247
|
-
async fetchSwapTokens(
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
);
|
|
236
|
+
async fetchSwapTokens(params: BlockchainApiSwapTokensRequest) {
|
|
237
|
+
const { chainId } = params;
|
|
238
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
|
|
251
239
|
|
|
252
240
|
if (!isSupported) {
|
|
253
241
|
return { tokens: [] };
|
|
@@ -257,22 +245,17 @@ export const BlockchainApiController = {
|
|
|
257
245
|
path: `/v1/convert/tokens`,
|
|
258
246
|
headers: getHeaders(),
|
|
259
247
|
params: {
|
|
260
|
-
|
|
248
|
+
...getParams(),
|
|
261
249
|
chainId
|
|
262
250
|
}
|
|
263
251
|
});
|
|
264
252
|
},
|
|
265
253
|
|
|
266
|
-
async generateSwapCalldata({
|
|
267
|
-
amount,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
userAddress
|
|
272
|
-
}: BlockchainApiGenerateSwapCalldataRequest) {
|
|
273
|
-
const isSupported = await BlockchainApiController.isNetworkSupported(
|
|
274
|
-
ConnectionsController.state.activeCaipNetworkId
|
|
275
|
-
);
|
|
254
|
+
async generateSwapCalldata(params: BlockchainApiGenerateSwapCalldataRequest) {
|
|
255
|
+
const { amount, from, projectId, to, userAddress } = params;
|
|
256
|
+
const [namespace, chain] = userAddress.split(':');
|
|
257
|
+
const networkId: CaipNetworkId = `${namespace}:${chain}`;
|
|
258
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
|
|
276
259
|
|
|
277
260
|
if (!isSupported) {
|
|
278
261
|
throw new Error('Network not supported for Swaps');
|
|
@@ -281,6 +264,7 @@ export const BlockchainApiController = {
|
|
|
281
264
|
return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
|
|
282
265
|
path: '/v1/convert/build-transaction',
|
|
283
266
|
headers: getHeaders(),
|
|
267
|
+
params: getParams(),
|
|
284
268
|
body: {
|
|
285
269
|
amount,
|
|
286
270
|
eip155: {
|
|
@@ -294,15 +278,11 @@ export const BlockchainApiController = {
|
|
|
294
278
|
});
|
|
295
279
|
},
|
|
296
280
|
|
|
297
|
-
async generateApproveCalldata({
|
|
298
|
-
from,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}: BlockchainApiGenerateApproveCalldataRequest) {
|
|
303
|
-
const isSupported = await BlockchainApiController.isNetworkSupported(
|
|
304
|
-
ConnectionsController.state.activeCaipNetworkId
|
|
305
|
-
);
|
|
281
|
+
async generateApproveCalldata(params: BlockchainApiGenerateApproveCalldataRequest) {
|
|
282
|
+
const { from, to, userAddress } = params;
|
|
283
|
+
const [namespace, chain] = userAddress.split(':');
|
|
284
|
+
const networkId: CaipNetworkId = `${namespace}:${chain}`;
|
|
285
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
|
|
306
286
|
|
|
307
287
|
if (!isSupported) {
|
|
308
288
|
throw new Error('Network not supported for Swaps');
|
|
@@ -312,7 +292,7 @@ export const BlockchainApiController = {
|
|
|
312
292
|
path: `/v1/convert/build-approve`,
|
|
313
293
|
headers: getHeaders(),
|
|
314
294
|
params: {
|
|
315
|
-
|
|
295
|
+
...getParams(),
|
|
316
296
|
userAddress,
|
|
317
297
|
from,
|
|
318
298
|
to
|
|
@@ -320,10 +300,15 @@ export const BlockchainApiController = {
|
|
|
320
300
|
});
|
|
321
301
|
},
|
|
322
302
|
|
|
323
|
-
async getBalance(address
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
)
|
|
303
|
+
async getBalance(address?: CaipAddress, forceUpdate?: CaipAddress[]) {
|
|
304
|
+
const [namespace, chain, plainAddress] = address?.split(':') ?? [];
|
|
305
|
+
|
|
306
|
+
if (!namespace || !chain || !plainAddress) {
|
|
307
|
+
throw new Error('Invalid address');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(`${namespace}:${chain}`);
|
|
311
|
+
|
|
327
312
|
if (!isSupported) {
|
|
328
313
|
SnackController.showError('Token Balance Unavailable');
|
|
329
314
|
|
|
@@ -331,13 +316,13 @@ export const BlockchainApiController = {
|
|
|
331
316
|
}
|
|
332
317
|
|
|
333
318
|
return state.api.get<BlockchainApiBalanceResponse>({
|
|
334
|
-
path: `/v1/account/${
|
|
319
|
+
path: `/v1/account/${plainAddress}/balance`,
|
|
335
320
|
headers: getHeaders(),
|
|
336
321
|
params: {
|
|
322
|
+
...getParams(),
|
|
337
323
|
currency: 'usd',
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
forceUpdate
|
|
324
|
+
chainId: `${namespace}:${chain}`,
|
|
325
|
+
forceUpdate: forceUpdate?.join(',')
|
|
341
326
|
}
|
|
342
327
|
});
|
|
343
328
|
},
|
|
@@ -347,75 +332,53 @@ export const BlockchainApiController = {
|
|
|
347
332
|
path: `/v1/profile/account/${name}`,
|
|
348
333
|
headers: getHeaders(),
|
|
349
334
|
params: {
|
|
350
|
-
|
|
335
|
+
...getParams(),
|
|
351
336
|
apiVersion: '2'
|
|
352
337
|
}
|
|
353
338
|
});
|
|
354
339
|
},
|
|
355
340
|
|
|
356
|
-
async fetchOnRampCountries() {
|
|
357
|
-
return await state.api.get<OnRampCountry[]>({
|
|
358
|
-
path: '/v1/onramp/providers/properties',
|
|
359
|
-
headers: getHeaders(),
|
|
360
|
-
params: {
|
|
361
|
-
projectId: OptionsController.state.projectId,
|
|
362
|
-
type: 'countries'
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
},
|
|
366
|
-
|
|
367
341
|
async fetchOnRampServiceProviders() {
|
|
368
342
|
return await state.api.get<OnRampServiceProvider[]>({
|
|
369
343
|
path: '/v1/onramp/providers',
|
|
370
344
|
headers: getHeaders(),
|
|
371
|
-
params:
|
|
372
|
-
projectId: OptionsController.state.projectId
|
|
373
|
-
}
|
|
345
|
+
params: getParams()
|
|
374
346
|
});
|
|
375
347
|
},
|
|
376
348
|
|
|
349
|
+
async fetchOnRampCountries() {
|
|
350
|
+
return await this.fetchProperties<OnRampCountry[]>('countries');
|
|
351
|
+
},
|
|
352
|
+
|
|
377
353
|
async fetchOnRampPaymentMethods(params: { countries?: string }) {
|
|
378
|
-
return await
|
|
379
|
-
path: '/v1/onramp/providers/properties',
|
|
380
|
-
headers: getHeaders(),
|
|
381
|
-
params: {
|
|
382
|
-
projectId: OptionsController.state.projectId,
|
|
383
|
-
type: 'payment-methods',
|
|
384
|
-
...params
|
|
385
|
-
}
|
|
386
|
-
});
|
|
354
|
+
return await this.fetchProperties<OnRampPaymentMethod[]>('payment-methods', params);
|
|
387
355
|
},
|
|
388
356
|
|
|
389
357
|
async fetchOnRampCryptoCurrencies(params: { countries?: string }) {
|
|
390
|
-
return await
|
|
391
|
-
path: '/v1/onramp/providers/properties',
|
|
392
|
-
headers: getHeaders(),
|
|
393
|
-
params: {
|
|
394
|
-
projectId: OptionsController.state.projectId,
|
|
395
|
-
type: 'crypto-currencies',
|
|
396
|
-
...params
|
|
397
|
-
}
|
|
398
|
-
});
|
|
358
|
+
return await this.fetchProperties<OnRampCryptoCurrency[]>('crypto-currencies', params);
|
|
399
359
|
},
|
|
400
360
|
|
|
401
361
|
async fetchOnRampFiatCurrencies() {
|
|
402
|
-
return await
|
|
403
|
-
path: '/v1/onramp/providers/properties',
|
|
404
|
-
headers: getHeaders(),
|
|
405
|
-
params: {
|
|
406
|
-
projectId: OptionsController.state.projectId,
|
|
407
|
-
type: 'fiat-currencies'
|
|
408
|
-
}
|
|
409
|
-
});
|
|
362
|
+
return await this.fetchProperties<OnRampFiatCurrency[]>('fiat-currencies');
|
|
410
363
|
},
|
|
411
364
|
|
|
412
365
|
async fetchOnRampFiatLimits() {
|
|
413
|
-
return await
|
|
366
|
+
return await this.fetchProperties<OnRampFiatLimit[]>('fiat-purchases-limits');
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
async fetchOnRampCountriesDefaults() {
|
|
370
|
+
return await this.fetchProperties<OnRampCountryDefaults[]>('countries-defaults');
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
async fetchProperties<T>(type: string, params?: Record<string, string>) {
|
|
374
|
+
return await state.api.get<T>({
|
|
414
375
|
path: '/v1/onramp/providers/properties',
|
|
415
376
|
headers: getHeaders(),
|
|
416
377
|
params: {
|
|
417
|
-
|
|
418
|
-
type
|
|
378
|
+
...getParams(),
|
|
379
|
+
type,
|
|
380
|
+
excludeProviders: EXCLUDED_ONRAMP_PROVIDERS.join(','),
|
|
381
|
+
...params
|
|
419
382
|
}
|
|
420
383
|
});
|
|
421
384
|
},
|
|
@@ -424,6 +387,7 @@ export const BlockchainApiController = {
|
|
|
424
387
|
return await state.api.post<OnRampQuote[]>({
|
|
425
388
|
path: '/v1/onramp/multi/quotes',
|
|
426
389
|
headers: getHeaders(),
|
|
390
|
+
params: getParams(),
|
|
427
391
|
body: {
|
|
428
392
|
projectId: OptionsController.state.projectId,
|
|
429
393
|
...body
|
|
@@ -436,6 +400,7 @@ export const BlockchainApiController = {
|
|
|
436
400
|
return await state.api.post<BlockchainApiOnRampWidgetResponse>({
|
|
437
401
|
path: '/v1/onramp/widget',
|
|
438
402
|
headers: getHeaders(),
|
|
403
|
+
params: getParams(),
|
|
439
404
|
body: {
|
|
440
405
|
projectId: OptionsController.state.projectId,
|
|
441
406
|
sessionData: {
|