@reown/appkit-core-react-native 0.0.0-feat-multichain-20250724181758 → 0.0.0-feat-multichain-20250725183909
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/controllers/AccountController.js +1 -66
- package/lib/commonjs/controllers/AccountController.js.map +1 -1
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/AssetController.js.map +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +17 -38
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +2 -2
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
- package/lib/commonjs/controllers/EnsController.js +4 -4
- package/lib/commonjs/controllers/EnsController.js.map +1 -1
- package/lib/commonjs/controllers/EventsController.js +4 -4
- package/lib/commonjs/controllers/EventsController.js.map +1 -1
- package/lib/commonjs/controllers/ModalController.js.map +1 -1
- package/lib/commonjs/controllers/OnRampController.js +117 -53
- package/lib/commonjs/controllers/OnRampController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/PublicStateController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SendController.js +5 -5
- package/lib/commonjs/controllers/SendController.js.map +1 -1
- package/lib/commonjs/controllers/SnackController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +3 -3
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
- package/lib/commonjs/index.js +0 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ApiUtil.js.map +1 -1
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +10 -422
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +2 -3
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/EventUtil.js.map +1 -1
- package/lib/commonjs/utils/FetchUtil.js +34 -10
- package/lib/commonjs/utils/FetchUtil.js.map +1 -1
- package/lib/commonjs/utils/RouterUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js +35 -2
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/commonjs/utils/TypeUtil.js +25 -0
- package/lib/commonjs/utils/TypeUtil.js.map +1 -1
- package/lib/module/controllers/AccountController.js +1 -66
- package/lib/module/controllers/AccountController.js.map +1 -1
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/AssetController.js.map +1 -1
- package/lib/module/controllers/BlockchainApiController.js +16 -37
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +1 -1
- package/lib/module/controllers/ConnectionsController.js.map +1 -1
- package/lib/module/controllers/EnsController.js +2 -2
- package/lib/module/controllers/EnsController.js.map +1 -1
- package/lib/module/controllers/EventsController.js +1 -1
- package/lib/module/controllers/EventsController.js.map +1 -1
- package/lib/module/controllers/ModalController.js.map +1 -1
- package/lib/module/controllers/OnRampController.js +116 -52
- package/lib/module/controllers/OnRampController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/PublicStateController.js.map +1 -1
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SendController.js +2 -2
- package/lib/module/controllers/SendController.js.map +1 -1
- package/lib/module/controllers/SnackController.js.map +1 -1
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +1 -1
- package/lib/module/controllers/TransactionsController.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ApiUtil.js.map +1 -1
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +10 -422
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +1 -1
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/EventUtil.js.map +1 -1
- package/lib/module/utils/FetchUtil.js +34 -10
- package/lib/module/utils/FetchUtil.js.map +1 -1
- package/lib/module/utils/RouterUtil.js.map +1 -1
- package/lib/module/utils/StorageUtil.js +35 -2
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js.map +1 -1
- package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/module/utils/TypeUtil.js +23 -1
- package/lib/module/utils/TypeUtil.js.map +1 -1
- package/lib/typescript/controllers/AccountController.d.ts +0 -21
- package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts +5 -2
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- 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 +3 -2
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +5 -414
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +3 -1
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +16 -3
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/controllers/AccountController.ts +1 -90
- package/src/controllers/BlockchainApiController.ts +23 -40
- package/src/controllers/ConnectionsController.ts +1 -1
- package/src/controllers/EnsController.ts +2 -2
- package/src/controllers/EventsController.ts +1 -1
- package/src/controllers/ModalController.ts +1 -2
- package/src/controllers/OnRampController.ts +178 -81
- package/src/controllers/SendController.ts +2 -2
- package/src/controllers/TransactionsController.ts +1 -1
- package/src/index.ts +0 -6
- package/src/utils/ConstantsUtil.ts +10 -424
- package/src/utils/CoreHelperUtil.ts +1 -1
- package/src/utils/FetchUtil.ts +37 -10
- package/src/utils/StorageUtil.ts +42 -2
- package/src/utils/TypeUtil.ts +30 -3
- package/lib/commonjs/controllers/NetworkController.js +0 -90
- package/lib/commonjs/controllers/NetworkController.js.map +0 -1
- package/lib/module/controllers/NetworkController.js +0 -85
- package/lib/module/controllers/NetworkController.js.map +0 -1
- package/lib/typescript/controllers/NetworkController.d.ts +0 -34
- package/lib/typescript/controllers/NetworkController.d.ts.map +0 -1
- package/src/controllers/NetworkController.ts +0 -120
|
@@ -1,38 +1,16 @@
|
|
|
1
1
|
import { proxy } from 'valtio';
|
|
2
2
|
import { subscribeKey as subKey } from 'valtio/utils';
|
|
3
|
-
import type { AccountType, CaipAddress } from '@reown/appkit-common-react-native';
|
|
4
|
-
|
|
5
|
-
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
6
|
-
import type { ConnectedWalletInfo, BlockchainApiBalance } from '../utils/TypeUtil';
|
|
7
|
-
// import { NetworkController } from './NetworkController';
|
|
8
|
-
// import { BlockchainApiController } from './BlockchainApiController';
|
|
9
|
-
// import { SnackController } from './SnackController';
|
|
10
3
|
|
|
11
4
|
// -- Types --------------------------------------------- //
|
|
12
5
|
export interface AccountControllerState {
|
|
13
|
-
isConnected: boolean;
|
|
14
|
-
caipAddress?: CaipAddress;
|
|
15
|
-
address?: string;
|
|
16
|
-
balance?: string;
|
|
17
|
-
balanceSymbol?: string;
|
|
18
|
-
tokenBalance?: BlockchainApiBalance[];
|
|
19
6
|
profileName?: string;
|
|
20
7
|
profileImage?: string;
|
|
21
|
-
addressExplorerUrl?: string;
|
|
22
|
-
connectedWalletInfo?: ConnectedWalletInfo;
|
|
23
|
-
preferredAccountType?: AccountType;
|
|
24
|
-
smartAccountDeployed?: boolean;
|
|
25
8
|
}
|
|
26
9
|
|
|
27
10
|
type StateKey = keyof AccountControllerState;
|
|
28
11
|
|
|
29
12
|
// -- State --------------------------------------------- //
|
|
30
|
-
const state = proxy<AccountControllerState>({
|
|
31
|
-
isConnected: false,
|
|
32
|
-
tokenBalance: [],
|
|
33
|
-
smartAccountDeployed: false,
|
|
34
|
-
preferredAccountType: 'eoa'
|
|
35
|
-
});
|
|
13
|
+
const state = proxy<AccountControllerState>({});
|
|
36
14
|
|
|
37
15
|
// -- Controller ---------------------------------------- //
|
|
38
16
|
export const AccountController = {
|
|
@@ -42,28 +20,6 @@ export const AccountController = {
|
|
|
42
20
|
return subKey(state, key, callback);
|
|
43
21
|
},
|
|
44
22
|
|
|
45
|
-
setIsConnected(isConnected: AccountControllerState['isConnected']) {
|
|
46
|
-
state.isConnected = isConnected;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
setCaipAddress(caipAddress: AccountControllerState['caipAddress']) {
|
|
50
|
-
const address = caipAddress ? CoreHelperUtil.getPlainAddress(caipAddress) : undefined;
|
|
51
|
-
state.caipAddress = caipAddress;
|
|
52
|
-
state.address = address;
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
setBalance(
|
|
56
|
-
balance: AccountControllerState['balance'],
|
|
57
|
-
balanceSymbol: AccountControllerState['balanceSymbol']
|
|
58
|
-
) {
|
|
59
|
-
state.balance = balance;
|
|
60
|
-
state.balanceSymbol = balanceSymbol;
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
setTokenBalance(tokenBalance: AccountControllerState['tokenBalance']) {
|
|
64
|
-
state.tokenBalance = tokenBalance;
|
|
65
|
-
},
|
|
66
|
-
|
|
67
23
|
setProfileName(profileName: AccountControllerState['profileName']) {
|
|
68
24
|
state.profileName = profileName;
|
|
69
25
|
},
|
|
@@ -72,53 +28,8 @@ export const AccountController = {
|
|
|
72
28
|
state.profileImage = profileImage;
|
|
73
29
|
},
|
|
74
30
|
|
|
75
|
-
setConnectedWalletInfo(connectedWalletInfo: AccountControllerState['connectedWalletInfo']) {
|
|
76
|
-
state.connectedWalletInfo = connectedWalletInfo;
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
setAddressExplorerUrl(explorerUrl: AccountControllerState['addressExplorerUrl']) {
|
|
80
|
-
state.addressExplorerUrl = explorerUrl;
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
setPreferredAccountType(accountType: AccountControllerState['preferredAccountType']) {
|
|
84
|
-
state.preferredAccountType = accountType;
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
setSmartAccountDeployed(smartAccountDeployed: AccountControllerState['smartAccountDeployed']) {
|
|
88
|
-
state.smartAccountDeployed = smartAccountDeployed;
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
async fetchTokenBalance() {
|
|
92
|
-
// const chainId = NetworkController.state.caipNetwork?.id;
|
|
93
|
-
// const address = AccountController.state.address;
|
|
94
|
-
// try {
|
|
95
|
-
// if (address && chainId) {
|
|
96
|
-
// const response = await BlockchainApiController.getBalance(address, chainId);
|
|
97
|
-
// if (!response) {
|
|
98
|
-
// throw new Error('Failed to fetch token balance');
|
|
99
|
-
// }
|
|
100
|
-
// const filteredBalances = response.balances.filter(
|
|
101
|
-
// balance => balance.quantity.decimals !== '0'
|
|
102
|
-
// );
|
|
103
|
-
// this.setTokenBalance(filteredBalances);
|
|
104
|
-
// }
|
|
105
|
-
// } catch (error) {
|
|
106
|
-
// SnackController.showError('Failed to fetch token balance');
|
|
107
|
-
// }
|
|
108
|
-
},
|
|
109
|
-
|
|
110
31
|
resetAccount() {
|
|
111
|
-
state.isConnected = false;
|
|
112
|
-
state.caipAddress = undefined;
|
|
113
|
-
state.address = undefined;
|
|
114
|
-
state.balance = undefined;
|
|
115
|
-
state.balanceSymbol = undefined;
|
|
116
32
|
state.profileName = undefined;
|
|
117
33
|
state.profileImage = undefined;
|
|
118
|
-
state.addressExplorerUrl = undefined;
|
|
119
|
-
state.tokenBalance = [];
|
|
120
|
-
state.connectedWalletInfo = undefined;
|
|
121
|
-
state.preferredAccountType = 'eoa';
|
|
122
|
-
state.smartAccountDeployed = false;
|
|
123
34
|
}
|
|
124
35
|
};
|
|
@@ -32,7 +32,8 @@ import type {
|
|
|
32
32
|
OnRampQuote,
|
|
33
33
|
BlockchainApiOnRampWidgetRequest,
|
|
34
34
|
BlockchainApiOnRampQuotesRequest,
|
|
35
|
-
OnRampFiatLimit
|
|
35
|
+
OnRampFiatLimit,
|
|
36
|
+
OnRampCountryDefaults
|
|
36
37
|
} from '../utils/TypeUtil';
|
|
37
38
|
import { OptionsController } from './OptionsController';
|
|
38
39
|
import { ConstantsUtil } from '../utils/ConstantsUtil';
|
|
@@ -56,6 +57,8 @@ const getHeaders = () => {
|
|
|
56
57
|
};
|
|
57
58
|
};
|
|
58
59
|
|
|
60
|
+
export const EXCLUDED_ONRAMP_PROVIDERS = ['BINANCECONNECT', 'COINBASEPAY'];
|
|
61
|
+
|
|
59
62
|
// -- Types --------------------------------------------- //
|
|
60
63
|
type WithCaipNetworkId = { caipNetworkId: CaipNetworkId };
|
|
61
64
|
|
|
@@ -330,17 +333,6 @@ export const BlockchainApiController = {
|
|
|
330
333
|
});
|
|
331
334
|
},
|
|
332
335
|
|
|
333
|
-
async fetchOnRampCountries() {
|
|
334
|
-
return await state.api.get<OnRampCountry[]>({
|
|
335
|
-
path: '/v1/onramp/providers/properties',
|
|
336
|
-
headers: getHeaders(),
|
|
337
|
-
params: {
|
|
338
|
-
projectId: OptionsController.state.projectId,
|
|
339
|
-
type: 'countries'
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
},
|
|
343
|
-
|
|
344
336
|
async fetchOnRampServiceProviders() {
|
|
345
337
|
return await state.api.get<OnRampServiceProvider[]>({
|
|
346
338
|
path: '/v1/onramp/providers',
|
|
@@ -351,48 +343,39 @@ export const BlockchainApiController = {
|
|
|
351
343
|
});
|
|
352
344
|
},
|
|
353
345
|
|
|
346
|
+
async fetchOnRampCountries() {
|
|
347
|
+
return await this.fetchProperties<OnRampCountry[]>('countries');
|
|
348
|
+
},
|
|
349
|
+
|
|
354
350
|
async fetchOnRampPaymentMethods(params: { countries?: string }) {
|
|
355
|
-
return await
|
|
356
|
-
path: '/v1/onramp/providers/properties',
|
|
357
|
-
headers: getHeaders(),
|
|
358
|
-
params: {
|
|
359
|
-
projectId: OptionsController.state.projectId,
|
|
360
|
-
type: 'payment-methods',
|
|
361
|
-
...params
|
|
362
|
-
}
|
|
363
|
-
});
|
|
351
|
+
return await this.fetchProperties<OnRampPaymentMethod[]>('payment-methods', params);
|
|
364
352
|
},
|
|
365
353
|
|
|
366
354
|
async fetchOnRampCryptoCurrencies(params: { countries?: string }) {
|
|
367
|
-
return await
|
|
368
|
-
path: '/v1/onramp/providers/properties',
|
|
369
|
-
headers: getHeaders(),
|
|
370
|
-
params: {
|
|
371
|
-
projectId: OptionsController.state.projectId,
|
|
372
|
-
type: 'crypto-currencies',
|
|
373
|
-
...params
|
|
374
|
-
}
|
|
375
|
-
});
|
|
355
|
+
return await this.fetchProperties<OnRampCryptoCurrency[]>('crypto-currencies', params);
|
|
376
356
|
},
|
|
377
357
|
|
|
378
358
|
async fetchOnRampFiatCurrencies() {
|
|
379
|
-
return await
|
|
380
|
-
path: '/v1/onramp/providers/properties',
|
|
381
|
-
headers: getHeaders(),
|
|
382
|
-
params: {
|
|
383
|
-
projectId: OptionsController.state.projectId,
|
|
384
|
-
type: 'fiat-currencies'
|
|
385
|
-
}
|
|
386
|
-
});
|
|
359
|
+
return await this.fetchProperties<OnRampFiatCurrency[]>('fiat-currencies');
|
|
387
360
|
},
|
|
388
361
|
|
|
389
362
|
async fetchOnRampFiatLimits() {
|
|
390
|
-
return await
|
|
363
|
+
return await this.fetchProperties<OnRampFiatLimit[]>('fiat-purchases-limits');
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
async fetchOnRampCountriesDefaults() {
|
|
367
|
+
return await this.fetchProperties<OnRampCountryDefaults[]>('countries-defaults');
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
async fetchProperties<T>(type: string, params?: Record<string, string>) {
|
|
371
|
+
return await state.api.get<T>({
|
|
391
372
|
path: '/v1/onramp/providers/properties',
|
|
392
373
|
headers: getHeaders(),
|
|
393
374
|
params: {
|
|
394
375
|
projectId: OptionsController.state.projectId,
|
|
395
|
-
type
|
|
376
|
+
type,
|
|
377
|
+
excludeProviders: EXCLUDED_ONRAMP_PROVIDERS.join(','),
|
|
378
|
+
...params
|
|
396
379
|
}
|
|
397
380
|
});
|
|
398
381
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { subscribeKey as subKey } from 'valtio/
|
|
2
|
-
import { proxy, subscribe as sub } from 'valtio
|
|
1
|
+
import { subscribeKey as subKey } from 'valtio/utils';
|
|
2
|
+
import { proxy, subscribe as sub } from 'valtio';
|
|
3
3
|
import { BlockchainApiController } from './BlockchainApiController';
|
|
4
4
|
import type { BlockchainApiEnsError } from '../utils/TypeUtil';
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { proxy, subscribe as sub } from 'valtio
|
|
1
|
+
import { proxy, subscribe as sub } from 'valtio';
|
|
2
2
|
import { ApiController } from './ApiController';
|
|
3
3
|
import { OptionsController } from './OptionsController';
|
|
4
4
|
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { proxy } from 'valtio';
|
|
2
|
-
import type
|
|
3
|
-
import { RouterController } from './RouterController';
|
|
2
|
+
import { RouterController, type RouterControllerState } from './RouterController';
|
|
4
3
|
import { PublicStateController } from './PublicStateController';
|
|
5
4
|
import { EventsController } from './EventsController';
|
|
6
5
|
import { ApiController } from './ApiController';
|