@reown/appkit-core-react-native 0.0.0-develop-20250728153935 → 0.0.0-develop-20251008155354
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 +157 -91
- 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 +180 -78
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +425 -0
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -0
- package/lib/commonjs/controllers/EnsController.js +2 -0
- package/lib/commonjs/controllers/EnsController.js.map +1 -1
- package/lib/commonjs/controllers/EventsController.js +51 -1
- 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 +47 -20
- package/lib/commonjs/controllers/OnRampController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +28 -10
- 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 +111 -95
- 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 +162 -151
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js +14 -1
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +24 -18
- 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 +33 -40
- 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 -18
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +117 -5
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +32 -9
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/EventUtil.js.map +1 -1
- package/lib/commonjs/utils/FetchUtil.js +7 -2
- 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 +131 -150
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js +15 -21
- 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 +159 -91
- 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 +182 -78
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +422 -0
- package/lib/module/controllers/ConnectionsController.js.map +1 -0
- package/lib/module/controllers/EnsController.js +4 -0
- package/lib/module/controllers/EnsController.js.map +1 -1
- package/lib/module/controllers/EventsController.js +53 -1
- 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 +45 -16
- package/lib/module/controllers/OnRampController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +30 -10
- 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 +113 -95
- 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 +164 -151
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +16 -1
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +26 -18
- 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 +13 -8
- 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 -18
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +119 -5
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +34 -7
- 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 +10 -2
- 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 +134 -150
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js +17 -21
- 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 +9 -8
- 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 +29 -11
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts +47 -0
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -0
- 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.map +1 -1
- package/lib/typescript/controllers/OnRampController.d.ts +2 -2
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +11 -6
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/PublicStateController.d.ts +1 -1
- package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +6 -20
- 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 +12 -12
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
- package/lib/typescript/controllers/ThemeController.d.ts +3 -1
- 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 +7 -9
- 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 +11 -2
- 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 +4 -4
- 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 +15 -16
- 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 +11 -24
- package/src/controllers/ApiController.ts +167 -84
- package/src/controllers/AssetController.ts +0 -6
- package/src/controllers/BlockchainApiController.ts +168 -66
- package/src/controllers/ConnectionsController.ts +575 -0
- package/src/controllers/EnsController.ts +3 -1
- package/src/controllers/EventsController.ts +73 -2
- package/src/controllers/LogController.ts +250 -0
- package/src/controllers/ModalController.ts +10 -7
- package/src/controllers/OnRampController.ts +54 -19
- package/src/controllers/OptionsController.ts +46 -18
- package/src/controllers/PublicStateController.ts +1 -1
- package/src/controllers/RouterController.ts +20 -57
- package/src/controllers/SendController.ts +147 -111
- package/src/controllers/SnackController.ts +31 -5
- package/src/controllers/SwapController.ts +185 -183
- package/src/controllers/ThemeController.ts +18 -2
- package/src/controllers/TransactionsController.ts +27 -19
- 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 +17 -20
- package/src/utils/ApiUtil.ts +1 -1
- package/src/utils/AssetUtil.ts +9 -22
- package/src/utils/ConstantsUtil.ts +121 -6
- package/src/utils/CoreHelperUtil.ts +66 -10
- package/src/utils/EventUtil.ts +1 -1
- package/src/utils/FetchUtil.ts +14 -5
- package/src/utils/LogUtils.ts +179 -0
- package/src/utils/StorageUtil.ts +191 -176
- package/src/utils/SwapApiUtil.ts +30 -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 -126
- package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
- package/lib/commonjs/controllers/ConnectorController.js +0 -49
- 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/ConnectionUtil.js +0 -33
- package/lib/commonjs/utils/ConnectionUtil.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 -35
- 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 -121
- package/lib/module/controllers/ConnectionController.js.map +0 -1
- package/lib/module/controllers/ConnectorController.js +0 -44
- 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/ConnectionUtil.js +0 -27
- package/lib/module/utils/ConnectionUtil.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 -28
- 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 -66
- 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/ConnectionUtil.d.ts +0 -4
- package/lib/typescript/utils/ConnectionUtil.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 -850
- package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
- package/src/controllers/AccountController.ts +0 -128
- package/src/controllers/ConnectionController.ts +0 -200
- package/src/controllers/ConnectorController.ts +0 -63
- package/src/controllers/NetworkController.ts +0 -120
- package/src/controllers/WebviewController.ts +0 -63
- package/src/utils/ConnectionUtil.ts +0 -27
- package/src/utils/NetworkUtil.ts +0 -33
- package/src/utils/RouterUtil.ts +0 -21
- package/src/utils/TypeUtil.ts +0 -1039
|
@@ -33,22 +33,33 @@ import type {
|
|
|
33
33
|
BlockchainApiOnRampWidgetRequest,
|
|
34
34
|
BlockchainApiOnRampQuotesRequest,
|
|
35
35
|
OnRampFiatLimit,
|
|
36
|
-
OnRampCountryDefaults
|
|
37
|
-
|
|
36
|
+
OnRampCountryDefaults,
|
|
37
|
+
CaipAddress,
|
|
38
|
+
CaipNetworkId
|
|
39
|
+
} from '@reown/appkit-common-react-native';
|
|
38
40
|
import { OptionsController } from './OptionsController';
|
|
39
41
|
import { ConstantsUtil } from '../utils/ConstantsUtil';
|
|
40
42
|
import { ApiUtil } from '../utils/ApiUtil';
|
|
41
43
|
|
|
44
|
+
import { SnackController } from './SnackController';
|
|
45
|
+
import { LogController } from './LogController';
|
|
46
|
+
|
|
42
47
|
// -- Helpers ------------------------------------------- //
|
|
43
48
|
const baseUrl = CoreHelperUtil.getBlockchainApiUrl();
|
|
44
49
|
|
|
45
|
-
const
|
|
46
|
-
const { sdkType, sdkVersion } = OptionsController.state;
|
|
50
|
+
const getParams = () => {
|
|
51
|
+
const { projectId, sdkType, sdkVersion } = OptionsController.state;
|
|
47
52
|
|
|
53
|
+
return {
|
|
54
|
+
projectId,
|
|
55
|
+
st: sdkType,
|
|
56
|
+
sv: sdkVersion
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const getHeaders = () => {
|
|
48
61
|
return {
|
|
49
62
|
'Content-Type': 'application/json',
|
|
50
|
-
'x-sdk-type': sdkType,
|
|
51
|
-
'x-sdk-version': sdkVersion,
|
|
52
63
|
'User-Agent': ApiUtil.getUserAgent(),
|
|
53
64
|
'origin': ApiUtil.getOrigin()
|
|
54
65
|
};
|
|
@@ -57,69 +68,122 @@ const getHeaders = () => {
|
|
|
57
68
|
export const EXCLUDED_ONRAMP_PROVIDERS = ['BINANCECONNECT', 'COINBASEPAY'];
|
|
58
69
|
|
|
59
70
|
// -- Types --------------------------------------------- //
|
|
71
|
+
type WithCaipNetworkId = { caipNetworkId: CaipNetworkId };
|
|
72
|
+
|
|
60
73
|
export interface BlockchainApiControllerState {
|
|
61
74
|
clientId: string | null;
|
|
62
75
|
api: FetchUtil;
|
|
76
|
+
supportedChains: { http: CaipNetworkId[]; ws: CaipNetworkId[] };
|
|
63
77
|
}
|
|
64
78
|
|
|
65
79
|
// -- State --------------------------------------------- //
|
|
66
80
|
const state = proxy<BlockchainApiControllerState>({
|
|
67
81
|
clientId: null,
|
|
68
|
-
api: new FetchUtil({ baseUrl })
|
|
82
|
+
api: new FetchUtil({ baseUrl }),
|
|
83
|
+
supportedChains: { http: [], ws: [] }
|
|
69
84
|
});
|
|
70
85
|
|
|
71
86
|
// -- Controller ---------------------------------------- //
|
|
72
87
|
export const BlockchainApiController = {
|
|
73
88
|
state,
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
async isNetworkSupported(networkId?: CaipNetworkId) {
|
|
91
|
+
if (!networkId) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
if (!state.supportedChains.http.length) {
|
|
96
|
+
await BlockchainApiController.getSupportedNetworks();
|
|
97
|
+
}
|
|
98
|
+
} catch (e) {
|
|
99
|
+
LogController.sendError(e, 'BlockchainApiController.ts', 'isNetworkSupported');
|
|
100
|
+
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return state.supportedChains.http.includes(networkId);
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
async getSupportedNetworks() {
|
|
108
|
+
const supportedChains = await state.api.get<BlockchainApiControllerState['supportedChains']>({
|
|
109
|
+
path: 'v1/supported-chains',
|
|
110
|
+
params: getParams()
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
state.supportedChains = supportedChains!;
|
|
114
|
+
|
|
115
|
+
return supportedChains;
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
async fetchIdentity(params: BlockchainApiIdentityRequest) {
|
|
119
|
+
const { address } = params;
|
|
120
|
+
|
|
76
121
|
return state.api.get<BlockchainApiIdentityResponse>({
|
|
77
122
|
path: `/v1/identity/${address}`,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
headers: getHeaders()
|
|
123
|
+
headers: getHeaders(),
|
|
124
|
+
params: getParams()
|
|
82
125
|
});
|
|
83
126
|
},
|
|
84
127
|
|
|
85
|
-
fetchTransactions({
|
|
86
|
-
account,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
128
|
+
async fetchTransactions(params: BlockchainApiTransactionsRequest) {
|
|
129
|
+
const { account, cursor, signal, cache, chainId } = params;
|
|
130
|
+
const isSupported = ConstantsUtil.ACTIVITY_SUPPORTED_CHAINS.includes(chainId);
|
|
131
|
+
|
|
132
|
+
if (!isSupported) {
|
|
133
|
+
return { data: [], next: undefined };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const response = await state.api.get<BlockchainApiTransactionsResponse>({
|
|
94
137
|
path: `/v1/account/${account}/history`,
|
|
95
138
|
headers: getHeaders(),
|
|
96
139
|
params: {
|
|
97
|
-
|
|
140
|
+
...getParams(),
|
|
98
141
|
cursor,
|
|
99
|
-
|
|
142
|
+
chainId
|
|
100
143
|
},
|
|
101
144
|
signal,
|
|
102
145
|
cache
|
|
103
146
|
});
|
|
147
|
+
|
|
148
|
+
return response;
|
|
104
149
|
},
|
|
105
150
|
|
|
106
|
-
fetchTokenPrice(
|
|
107
|
-
|
|
151
|
+
async fetchTokenPrice(params: BlockchainApiTokenPriceRequest & WithCaipNetworkId) {
|
|
152
|
+
const { projectId, addresses, caipNetworkId } = params;
|
|
153
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(caipNetworkId);
|
|
154
|
+
|
|
155
|
+
if (!isSupported) {
|
|
156
|
+
return { fungibles: [] };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const response = await state.api.post<BlockchainApiTokenPriceResponse>({
|
|
108
160
|
path: '/v1/fungible/price',
|
|
161
|
+
headers: getHeaders(),
|
|
162
|
+
params: getParams(),
|
|
109
163
|
body: {
|
|
110
164
|
projectId,
|
|
111
165
|
currency: 'usd',
|
|
112
166
|
addresses
|
|
113
|
-
}
|
|
114
|
-
headers: getHeaders()
|
|
167
|
+
}
|
|
115
168
|
});
|
|
169
|
+
|
|
170
|
+
return response;
|
|
116
171
|
},
|
|
117
172
|
|
|
118
|
-
fetchSwapAllowance(
|
|
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);
|
|
178
|
+
|
|
179
|
+
if (!isSupported) {
|
|
180
|
+
return { allowance: '0' };
|
|
181
|
+
}
|
|
182
|
+
|
|
119
183
|
return state.api.get<BlockchainApiSwapAllowanceResponse>({
|
|
120
184
|
path: `/v1/convert/allowance`,
|
|
121
185
|
params: {
|
|
122
|
-
|
|
186
|
+
...getParams(),
|
|
123
187
|
tokenAddress,
|
|
124
188
|
userAddress
|
|
125
189
|
},
|
|
@@ -127,30 +191,39 @@ export const BlockchainApiController = {
|
|
|
127
191
|
});
|
|
128
192
|
},
|
|
129
193
|
|
|
130
|
-
fetchGasPrice(
|
|
194
|
+
async fetchGasPrice(params: BlockchainApiGasPriceRequest) {
|
|
195
|
+
const { chainId } = params;
|
|
196
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
|
|
197
|
+
|
|
198
|
+
if (!isSupported) {
|
|
199
|
+
throw new Error('Network not supported for Gas Price');
|
|
200
|
+
}
|
|
201
|
+
|
|
131
202
|
return state.api.get<BlockchainApiGasPriceResponse>({
|
|
132
203
|
path: `/v1/convert/gas-price`,
|
|
133
204
|
headers: getHeaders(),
|
|
134
205
|
params: {
|
|
135
|
-
|
|
206
|
+
...getParams(),
|
|
136
207
|
chainId
|
|
137
208
|
}
|
|
138
209
|
});
|
|
139
210
|
},
|
|
140
211
|
|
|
141
|
-
fetchSwapQuote({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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);
|
|
217
|
+
|
|
218
|
+
if (!isSupported) {
|
|
219
|
+
return { quotes: [] };
|
|
220
|
+
}
|
|
221
|
+
|
|
149
222
|
return state.api.get<BlockchainApiSwapQuoteResponse>({
|
|
150
223
|
path: `/v1/convert/quotes`,
|
|
151
224
|
headers: getHeaders(),
|
|
152
225
|
params: {
|
|
153
|
-
|
|
226
|
+
...getParams(),
|
|
154
227
|
amount,
|
|
155
228
|
userAddress,
|
|
156
229
|
from,
|
|
@@ -160,27 +233,38 @@ export const BlockchainApiController = {
|
|
|
160
233
|
});
|
|
161
234
|
},
|
|
162
235
|
|
|
163
|
-
fetchSwapTokens(
|
|
236
|
+
async fetchSwapTokens(params: BlockchainApiSwapTokensRequest) {
|
|
237
|
+
const { chainId } = params;
|
|
238
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
|
|
239
|
+
|
|
240
|
+
if (!isSupported) {
|
|
241
|
+
return { tokens: [] };
|
|
242
|
+
}
|
|
243
|
+
|
|
164
244
|
return state.api.get<BlockchainApiSwapTokensResponse>({
|
|
165
245
|
path: `/v1/convert/tokens`,
|
|
166
246
|
headers: getHeaders(),
|
|
167
247
|
params: {
|
|
168
|
-
|
|
248
|
+
...getParams(),
|
|
169
249
|
chainId
|
|
170
250
|
}
|
|
171
251
|
});
|
|
172
252
|
},
|
|
173
253
|
|
|
174
|
-
generateSwapCalldata({
|
|
175
|
-
amount,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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);
|
|
259
|
+
|
|
260
|
+
if (!isSupported) {
|
|
261
|
+
throw new Error('Network not supported for Swaps');
|
|
262
|
+
}
|
|
263
|
+
|
|
181
264
|
return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
|
|
182
265
|
path: '/v1/convert/build-transaction',
|
|
183
266
|
headers: getHeaders(),
|
|
267
|
+
params: getParams(),
|
|
184
268
|
body: {
|
|
185
269
|
amount,
|
|
186
270
|
eip155: {
|
|
@@ -194,17 +278,21 @@ export const BlockchainApiController = {
|
|
|
194
278
|
});
|
|
195
279
|
},
|
|
196
280
|
|
|
197
|
-
generateApproveCalldata({
|
|
198
|
-
from,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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);
|
|
286
|
+
|
|
287
|
+
if (!isSupported) {
|
|
288
|
+
throw new Error('Network not supported for Swaps');
|
|
289
|
+
}
|
|
290
|
+
|
|
203
291
|
return state.api.get<BlockchainApiGenerateApproveCalldataResponse>({
|
|
204
292
|
path: `/v1/convert/build-approve`,
|
|
205
293
|
headers: getHeaders(),
|
|
206
294
|
params: {
|
|
207
|
-
|
|
295
|
+
...getParams(),
|
|
208
296
|
userAddress,
|
|
209
297
|
from,
|
|
210
298
|
to
|
|
@@ -212,15 +300,29 @@ export const BlockchainApiController = {
|
|
|
212
300
|
});
|
|
213
301
|
},
|
|
214
302
|
|
|
215
|
-
async getBalance(address
|
|
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
|
+
|
|
312
|
+
if (!isSupported) {
|
|
313
|
+
SnackController.showError('Token Balance Unavailable');
|
|
314
|
+
|
|
315
|
+
return { balances: [] };
|
|
316
|
+
}
|
|
317
|
+
|
|
216
318
|
return state.api.get<BlockchainApiBalanceResponse>({
|
|
217
|
-
path: `/v1/account/${
|
|
319
|
+
path: `/v1/account/${plainAddress}/balance`,
|
|
218
320
|
headers: getHeaders(),
|
|
219
321
|
params: {
|
|
322
|
+
...getParams(),
|
|
220
323
|
currency: 'usd',
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
forceUpdate
|
|
324
|
+
chainId: `${namespace}:${chain}`,
|
|
325
|
+
forceUpdate: forceUpdate?.join(',')
|
|
224
326
|
}
|
|
225
327
|
});
|
|
226
328
|
},
|
|
@@ -230,7 +332,7 @@ export const BlockchainApiController = {
|
|
|
230
332
|
path: `/v1/profile/account/${name}`,
|
|
231
333
|
headers: getHeaders(),
|
|
232
334
|
params: {
|
|
233
|
-
|
|
335
|
+
...getParams(),
|
|
234
336
|
apiVersion: '2'
|
|
235
337
|
}
|
|
236
338
|
});
|
|
@@ -240,9 +342,7 @@ export const BlockchainApiController = {
|
|
|
240
342
|
return await state.api.get<OnRampServiceProvider[]>({
|
|
241
343
|
path: '/v1/onramp/providers',
|
|
242
344
|
headers: getHeaders(),
|
|
243
|
-
params:
|
|
244
|
-
projectId: OptionsController.state.projectId
|
|
245
|
-
}
|
|
345
|
+
params: getParams()
|
|
246
346
|
});
|
|
247
347
|
},
|
|
248
348
|
|
|
@@ -275,7 +375,7 @@ export const BlockchainApiController = {
|
|
|
275
375
|
path: '/v1/onramp/providers/properties',
|
|
276
376
|
headers: getHeaders(),
|
|
277
377
|
params: {
|
|
278
|
-
|
|
378
|
+
...getParams(),
|
|
279
379
|
type,
|
|
280
380
|
excludeProviders: EXCLUDED_ONRAMP_PROVIDERS.join(','),
|
|
281
381
|
...params
|
|
@@ -287,6 +387,7 @@ export const BlockchainApiController = {
|
|
|
287
387
|
return await state.api.post<OnRampQuote[]>({
|
|
288
388
|
path: '/v1/onramp/multi/quotes',
|
|
289
389
|
headers: getHeaders(),
|
|
390
|
+
params: getParams(),
|
|
290
391
|
body: {
|
|
291
392
|
projectId: OptionsController.state.projectId,
|
|
292
393
|
...body
|
|
@@ -299,6 +400,7 @@ export const BlockchainApiController = {
|
|
|
299
400
|
return await state.api.post<BlockchainApiOnRampWidgetResponse>({
|
|
300
401
|
path: '/v1/onramp/widget',
|
|
301
402
|
headers: getHeaders(),
|
|
403
|
+
params: getParams(),
|
|
302
404
|
body: {
|
|
303
405
|
projectId: OptionsController.state.projectId,
|
|
304
406
|
sessionData: {
|