@reown/appkit-core-react-native 0.0.0-accounts-canary.1-20251023174733
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 +410 -0
- package/lib/commonjs/controllers/ApiController.js.map +1 -0
- package/lib/commonjs/controllers/AssetController.js +30 -0
- package/lib/commonjs/controllers/AssetController.js.map +1 -0
- package/lib/commonjs/controllers/BlockchainApiController.js +384 -0
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -0
- package/lib/commonjs/controllers/ConnectionsController.js +425 -0
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -0
- package/lib/commonjs/controllers/EnsController.js +37 -0
- package/lib/commonjs/controllers/EnsController.js.map +1 -0
- package/lib/commonjs/controllers/EventsController.js +122 -0
- package/lib/commonjs/controllers/EventsController.js.map +1 -0
- package/lib/commonjs/controllers/LogController.js +188 -0
- package/lib/commonjs/controllers/LogController.js.map +1 -0
- package/lib/commonjs/controllers/ModalController.js +68 -0
- package/lib/commonjs/controllers/ModalController.js.map +1 -0
- package/lib/commonjs/controllers/OnRampController.js +502 -0
- package/lib/commonjs/controllers/OnRampController.js.map +1 -0
- package/lib/commonjs/controllers/OptionsController.js +96 -0
- package/lib/commonjs/controllers/OptionsController.js.map +1 -0
- package/lib/commonjs/controllers/PublicStateController.js +33 -0
- package/lib/commonjs/controllers/PublicStateController.js.map +1 -0
- package/lib/commonjs/controllers/RouterController.js +63 -0
- package/lib/commonjs/controllers/RouterController.js.map +1 -0
- package/lib/commonjs/controllers/SendController.js +192 -0
- package/lib/commonjs/controllers/SendController.js.map +1 -0
- package/lib/commonjs/controllers/SnackController.js +83 -0
- package/lib/commonjs/controllers/SnackController.js.map +1 -0
- package/lib/commonjs/controllers/SwapController.js +674 -0
- package/lib/commonjs/controllers/SwapController.js.map +1 -0
- package/lib/commonjs/controllers/ThemeController.js +45 -0
- package/lib/commonjs/controllers/ThemeController.js.map +1 -0
- package/lib/commonjs/controllers/TransactionsController.js +118 -0
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -0
- 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 +202 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/utils/ApiUtil.js +43 -0
- package/lib/commonjs/utils/ApiUtil.js.map +1 -0
- package/lib/commonjs/utils/AssetUtil.js +27 -0
- package/lib/commonjs/utils/AssetUtil.js.map +1 -0
- package/lib/commonjs/utils/ConstantsUtil.js +226 -0
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -0
- package/lib/commonjs/utils/CoreHelperUtil.js +298 -0
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -0
- package/lib/commonjs/utils/EventUtil.js +25 -0
- package/lib/commonjs/utils/EventUtil.js.map +1 -0
- package/lib/commonjs/utils/FetchUtil.js +158 -0
- package/lib/commonjs/utils/FetchUtil.js.map +1 -0
- package/lib/commonjs/utils/LogUtils.js +131 -0
- package/lib/commonjs/utils/LogUtils.js.map +1 -0
- package/lib/commonjs/utils/StorageUtil.js +319 -0
- package/lib/commonjs/utils/StorageUtil.js.map +1 -0
- package/lib/commonjs/utils/SwapApiUtil.js +75 -0
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -0
- package/lib/commonjs/utils/SwapCalculationUtil.js +97 -0
- package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -0
- package/lib/commonjs/utils/WalletUtil.js +23 -0
- package/lib/commonjs/utils/WalletUtil.js.map +1 -0
- package/lib/module/controllers/ApiController.js +407 -0
- package/lib/module/controllers/ApiController.js.map +1 -0
- package/lib/module/controllers/AssetController.js +27 -0
- package/lib/module/controllers/AssetController.js.map +1 -0
- package/lib/module/controllers/BlockchainApiController.js +381 -0
- package/lib/module/controllers/BlockchainApiController.js.map +1 -0
- package/lib/module/controllers/ConnectionsController.js +422 -0
- package/lib/module/controllers/ConnectionsController.js.map +1 -0
- package/lib/module/controllers/EnsController.js +34 -0
- package/lib/module/controllers/EnsController.js.map +1 -0
- package/lib/module/controllers/EventsController.js +118 -0
- package/lib/module/controllers/EventsController.js.map +1 -0
- package/lib/module/controllers/LogController.js +185 -0
- package/lib/module/controllers/LogController.js.map +1 -0
- package/lib/module/controllers/ModalController.js +65 -0
- package/lib/module/controllers/ModalController.js.map +1 -0
- package/lib/module/controllers/OnRampController.js +499 -0
- package/lib/module/controllers/OnRampController.js.map +1 -0
- package/lib/module/controllers/OptionsController.js +93 -0
- package/lib/module/controllers/OptionsController.js.map +1 -0
- package/lib/module/controllers/PublicStateController.js +30 -0
- package/lib/module/controllers/PublicStateController.js.map +1 -0
- package/lib/module/controllers/RouterController.js +60 -0
- package/lib/module/controllers/RouterController.js.map +1 -0
- package/lib/module/controllers/SendController.js +189 -0
- package/lib/module/controllers/SendController.js.map +1 -0
- package/lib/module/controllers/SnackController.js +80 -0
- package/lib/module/controllers/SnackController.js.map +1 -0
- package/lib/module/controllers/SwapController.js +671 -0
- package/lib/module/controllers/SwapController.js.map +1 -0
- package/lib/module/controllers/ThemeController.js +42 -0
- package/lib/module/controllers/ThemeController.js.map +1 -0
- package/lib/module/controllers/TransactionsController.js +115 -0
- package/lib/module/controllers/TransactionsController.js.map +1 -0
- 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 +38 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/utils/ApiUtil.js +39 -0
- package/lib/module/utils/ApiUtil.js.map +1 -0
- package/lib/module/utils/AssetUtil.js +23 -0
- package/lib/module/utils/AssetUtil.js.map +1 -0
- package/lib/module/utils/ConstantsUtil.js +222 -0
- package/lib/module/utils/ConstantsUtil.js.map +1 -0
- package/lib/module/utils/CoreHelperUtil.js +294 -0
- package/lib/module/utils/CoreHelperUtil.js.map +1 -0
- package/lib/module/utils/EventUtil.js +21 -0
- package/lib/module/utils/EventUtil.js.map +1 -0
- package/lib/module/utils/FetchUtil.js +154 -0
- package/lib/module/utils/FetchUtil.js.map +1 -0
- package/lib/module/utils/LogUtils.js +121 -0
- package/lib/module/utils/LogUtils.js.map +1 -0
- package/lib/module/utils/StorageUtil.js +315 -0
- package/lib/module/utils/StorageUtil.js.map +1 -0
- package/lib/module/utils/SwapApiUtil.js +71 -0
- package/lib/module/utils/SwapApiUtil.js.map +1 -0
- package/lib/module/utils/SwapCalculationUtil.js +94 -0
- package/lib/module/utils/SwapCalculationUtil.js.map +1 -0
- package/lib/module/utils/WalletUtil.js +19 -0
- package/lib/module/utils/WalletUtil.js.map +1 -0
- package/lib/typescript/controllers/ApiController.d.ts +40 -0
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -0
- package/lib/typescript/controllers/AssetController.d.ts +12 -0
- package/lib/typescript/controllers/AssetController.d.ts.map +1 -0
- package/lib/typescript/controllers/BlockchainApiController.d.ts +55 -0
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -0
- 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 +10 -0
- package/lib/typescript/controllers/EnsController.d.ts.map +1 -0
- package/lib/typescript/controllers/EventsController.d.ts +25 -0
- package/lib/typescript/controllers/EventsController.d.ts.map +1 -0
- 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 +17 -0
- package/lib/typescript/controllers/ModalController.d.ts.map +1 -0
- package/lib/typescript/controllers/OnRampController.d.ts +55 -0
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -0
- package/lib/typescript/controllers/OptionsController.d.ts +46 -0
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -0
- package/lib/typescript/controllers/PublicStateController.d.ts +12 -0
- package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -0
- package/lib/typescript/controllers/RouterController.d.ts +21 -0
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -0
- package/lib/typescript/controllers/SendController.d.ts +39 -0
- package/lib/typescript/controllers/SendController.d.ts.map +1 -0
- package/lib/typescript/controllers/SnackController.d.ts +20 -0
- package/lib/typescript/controllers/SnackController.d.ts.map +1 -0
- package/lib/typescript/controllers/SwapController.d.ts +116 -0
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -0
- package/lib/typescript/controllers/ThemeController.d.ts +14 -0
- package/lib/typescript/controllers/ThemeController.d.ts.map +1 -0
- package/lib/typescript/controllers/TransactionsController.d.ts +21 -0
- package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -0
- 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 +29 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/utils/ApiUtil.d.ts +7 -0
- package/lib/typescript/utils/ApiUtil.d.ts.map +1 -0
- package/lib/typescript/utils/AssetUtil.d.ts +6 -0
- package/lib/typescript/utils/AssetUtil.d.ts.map +1 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts +79 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -0
- package/lib/typescript/utils/CoreHelperUtil.d.ts +43 -0
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -0
- package/lib/typescript/utils/EventUtil.d.ts +5 -0
- package/lib/typescript/utils/EventUtil.d.ts.map +1 -0
- package/lib/typescript/utils/FetchUtil.d.ts +29 -0
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -0
- 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 +36 -0
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -0
- package/lib/typescript/utils/SwapApiUtil.d.ts +11 -0
- package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -0
- package/lib/typescript/utils/SwapCalculationUtil.d.ts +24 -0
- package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -0
- package/lib/typescript/utils/WalletUtil.d.ts +5 -0
- package/lib/typescript/utils/WalletUtil.d.ts.map +1 -0
- package/package.json +57 -0
- package/readme.md +9 -0
- package/src/controllers/ApiController.ts +454 -0
- package/src/controllers/AssetController.ts +32 -0
- package/src/controllers/BlockchainApiController.ts +418 -0
- package/src/controllers/ConnectionsController.ts +575 -0
- package/src/controllers/EnsController.ts +41 -0
- package/src/controllers/EventsController.ts +146 -0
- package/src/controllers/LogController.ts +250 -0
- package/src/controllers/ModalController.ts +68 -0
- package/src/controllers/OnRampController.ts +698 -0
- package/src/controllers/OptionsController.ts +143 -0
- package/src/controllers/PublicStateController.ts +37 -0
- package/src/controllers/RouterController.ts +112 -0
- package/src/controllers/SendController.ts +270 -0
- package/src/controllers/SnackController.ts +95 -0
- package/src/controllers/SwapController.ts +863 -0
- package/src/controllers/ThemeController.ts +47 -0
- package/src/controllers/TransactionsController.ts +150 -0
- 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 +70 -0
- package/src/utils/ApiUtil.ts +50 -0
- package/src/utils/AssetUtil.ts +27 -0
- package/src/utils/ConstantsUtil.ts +303 -0
- package/src/utils/CoreHelperUtil.ts +377 -0
- package/src/utils/EventUtil.ts +22 -0
- package/src/utils/FetchUtil.ts +164 -0
- package/src/utils/LogUtils.ts +179 -0
- package/src/utils/StorageUtil.ts +405 -0
- package/src/utils/SwapApiUtil.ts +101 -0
- package/src/utils/SwapCalculationUtil.ts +145 -0
- package/src/utils/WalletUtil.ts +14 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import type { ChainNamespace, Features } from '@reown/appkit-common-react-native';
|
|
2
|
+
|
|
3
|
+
const defaultFeatures: Features = {
|
|
4
|
+
swaps: true,
|
|
5
|
+
onramp: true,
|
|
6
|
+
socials: ['email', 'google', 'x', 'discord', 'apple', 'facebook', 'github', 'farcaster'],
|
|
7
|
+
showWallets: true
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const OnRampErrorType = {
|
|
11
|
+
AMOUNT_TOO_LOW: 'INVALID_AMOUNT_TOO_LOW',
|
|
12
|
+
AMOUNT_TOO_HIGH: 'INVALID_AMOUNT_TOO_HIGH',
|
|
13
|
+
INVALID_AMOUNT: 'INVALID_AMOUNT',
|
|
14
|
+
INCOMPATIBLE_REQUEST: 'INCOMPATIBLE_REQUEST',
|
|
15
|
+
BAD_REQUEST: 'BAD_REQUEST',
|
|
16
|
+
NO_VALID_QUOTES: 'NO_VALID_QUOTES',
|
|
17
|
+
FAILED_TO_LOAD: 'FAILED_TO_LOAD',
|
|
18
|
+
FAILED_TO_LOAD_COUNTRIES: 'FAILED_TO_LOAD_COUNTRIES',
|
|
19
|
+
FAILED_TO_LOAD_PROVIDERS: 'FAILED_TO_LOAD_PROVIDERS',
|
|
20
|
+
FAILED_TO_LOAD_METHODS: 'FAILED_TO_LOAD_METHODS',
|
|
21
|
+
FAILED_TO_LOAD_CURRENCIES: 'FAILED_TO_LOAD_CURRENCIES',
|
|
22
|
+
FAILED_TO_LOAD_LIMITS: 'FAILED_TO_LOAD_LIMITS',
|
|
23
|
+
UNKNOWN: 'UNKNOWN_ERROR'
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
export const ConstantsUtil = {
|
|
27
|
+
FOUR_MINUTES_MS: 240000,
|
|
28
|
+
|
|
29
|
+
TEN_SEC_MS: 10000,
|
|
30
|
+
|
|
31
|
+
ONE_SEC_MS: 1000,
|
|
32
|
+
|
|
33
|
+
EMAIL_REGEX: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/,
|
|
34
|
+
|
|
35
|
+
LINKING_ERROR: 'LINKING_ERROR',
|
|
36
|
+
|
|
37
|
+
NATIVE_TOKEN_ADDRESS: {
|
|
38
|
+
eip155: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
39
|
+
solana: 'So11111111111111111111111111111111111111111',
|
|
40
|
+
bip122: '0x'
|
|
41
|
+
} as const satisfies Record<ChainNamespace, string>,
|
|
42
|
+
|
|
43
|
+
ONRAMP_ERROR_TYPES: OnRampErrorType,
|
|
44
|
+
|
|
45
|
+
SWAP_SUGGESTED_TOKENS: [
|
|
46
|
+
'ETH',
|
|
47
|
+
'UNI',
|
|
48
|
+
'1INCH',
|
|
49
|
+
'AAVE',
|
|
50
|
+
'SOL',
|
|
51
|
+
'ADA',
|
|
52
|
+
'AVAX',
|
|
53
|
+
'DOT',
|
|
54
|
+
'LINK',
|
|
55
|
+
'NITRO',
|
|
56
|
+
'GAIA',
|
|
57
|
+
'MILK',
|
|
58
|
+
'TRX',
|
|
59
|
+
'NEAR',
|
|
60
|
+
'GNO',
|
|
61
|
+
'WBTC',
|
|
62
|
+
'DAI',
|
|
63
|
+
'WETH',
|
|
64
|
+
'USDC',
|
|
65
|
+
'USDT',
|
|
66
|
+
'ARB',
|
|
67
|
+
'BAL',
|
|
68
|
+
'BICO',
|
|
69
|
+
'CRV',
|
|
70
|
+
'ENS',
|
|
71
|
+
'POL',
|
|
72
|
+
'OP'
|
|
73
|
+
],
|
|
74
|
+
|
|
75
|
+
SWAP_POPULAR_TOKENS: [
|
|
76
|
+
'ETH',
|
|
77
|
+
'UNI',
|
|
78
|
+
'1INCH',
|
|
79
|
+
'AAVE',
|
|
80
|
+
'SOL',
|
|
81
|
+
'ADA',
|
|
82
|
+
'AVAX',
|
|
83
|
+
'DOT',
|
|
84
|
+
'LINK',
|
|
85
|
+
'NITRO',
|
|
86
|
+
'GAIA',
|
|
87
|
+
'MILK',
|
|
88
|
+
'TRX',
|
|
89
|
+
'NEAR',
|
|
90
|
+
'GNO',
|
|
91
|
+
'WBTC',
|
|
92
|
+
'DAI',
|
|
93
|
+
'WETH',
|
|
94
|
+
'USDC',
|
|
95
|
+
'USDT',
|
|
96
|
+
'ARB',
|
|
97
|
+
'BAL',
|
|
98
|
+
'BICO',
|
|
99
|
+
'CRV',
|
|
100
|
+
'ENS',
|
|
101
|
+
'POL',
|
|
102
|
+
'OP',
|
|
103
|
+
'METAL',
|
|
104
|
+
'DAI',
|
|
105
|
+
'CHAMP',
|
|
106
|
+
'WOLF',
|
|
107
|
+
'SALE',
|
|
108
|
+
'BAL',
|
|
109
|
+
'BUSD',
|
|
110
|
+
'MUST',
|
|
111
|
+
'BTCpx',
|
|
112
|
+
'ROUTE',
|
|
113
|
+
'HEX',
|
|
114
|
+
'WELT',
|
|
115
|
+
'amDAI',
|
|
116
|
+
'VSQ',
|
|
117
|
+
'VISION',
|
|
118
|
+
'AURUM',
|
|
119
|
+
'pSP',
|
|
120
|
+
'SNX',
|
|
121
|
+
'VC',
|
|
122
|
+
'LINK',
|
|
123
|
+
'CHP',
|
|
124
|
+
'amUSDT',
|
|
125
|
+
'SPHERE',
|
|
126
|
+
'FOX',
|
|
127
|
+
'GIDDY',
|
|
128
|
+
'GFC',
|
|
129
|
+
'OMEN',
|
|
130
|
+
'OX_OLD',
|
|
131
|
+
'DE',
|
|
132
|
+
'WNT'
|
|
133
|
+
],
|
|
134
|
+
|
|
135
|
+
//TODO: replace with supported chains from backend
|
|
136
|
+
ACTIVITY_SUPPORTED_CHAINS: [
|
|
137
|
+
// Arbitrum
|
|
138
|
+
'eip155:42161',
|
|
139
|
+
// BNB Chain
|
|
140
|
+
'eip155:56',
|
|
141
|
+
// Ethereum
|
|
142
|
+
'eip155:1',
|
|
143
|
+
// Blast
|
|
144
|
+
'eip155:81457',
|
|
145
|
+
// Ape Chain
|
|
146
|
+
'eip155:99999',
|
|
147
|
+
// Avalanche
|
|
148
|
+
'eip155:43114',
|
|
149
|
+
// Abstract
|
|
150
|
+
'eip155:900',
|
|
151
|
+
// opBNB
|
|
152
|
+
'eip155:204',
|
|
153
|
+
// Astar zkEVM
|
|
154
|
+
'eip155:3776',
|
|
155
|
+
// ZKsync Era
|
|
156
|
+
'eip155:324',
|
|
157
|
+
// Berachain
|
|
158
|
+
'eip155:80085',
|
|
159
|
+
// BOB
|
|
160
|
+
'eip155:60808',
|
|
161
|
+
// Cyber
|
|
162
|
+
'eip155:7560',
|
|
163
|
+
// Degen Chain
|
|
164
|
+
'eip155:666666666',
|
|
165
|
+
// Fraxtal
|
|
166
|
+
'eip155:252',
|
|
167
|
+
// Gravity Alpha
|
|
168
|
+
'eip155:10003',
|
|
169
|
+
// Ink
|
|
170
|
+
'eip155:999',
|
|
171
|
+
// Lens
|
|
172
|
+
'eip155:1348',
|
|
173
|
+
// Lisk
|
|
174
|
+
'eip155:113',
|
|
175
|
+
// Mode
|
|
176
|
+
'eip155:34443',
|
|
177
|
+
// Base
|
|
178
|
+
'eip155:8453',
|
|
179
|
+
// Mantle
|
|
180
|
+
'eip155:5000',
|
|
181
|
+
// Optimism
|
|
182
|
+
'eip155:10',
|
|
183
|
+
// Polygon
|
|
184
|
+
'eip155:137',
|
|
185
|
+
// Celo
|
|
186
|
+
'eip155:42220',
|
|
187
|
+
// Manta Pacific
|
|
188
|
+
'eip155:169',
|
|
189
|
+
// Gnosis Chain
|
|
190
|
+
'eip155:100',
|
|
191
|
+
// Fantom
|
|
192
|
+
'eip155:250',
|
|
193
|
+
// Ronin
|
|
194
|
+
'eip155:2020',
|
|
195
|
+
// Linea
|
|
196
|
+
'eip155:59144',
|
|
197
|
+
// Metis Andromeda
|
|
198
|
+
'eip155:1088',
|
|
199
|
+
// Aurora
|
|
200
|
+
'eip155:1313161554',
|
|
201
|
+
// XDC
|
|
202
|
+
'eip155:50',
|
|
203
|
+
// Cronos zkEVM
|
|
204
|
+
'eip155:1030',
|
|
205
|
+
// Polygon zkEVM
|
|
206
|
+
'eip155:1101',
|
|
207
|
+
// Polynomial
|
|
208
|
+
'eip155:80001',
|
|
209
|
+
// Rari
|
|
210
|
+
'eip155:1380012617',
|
|
211
|
+
// Redstone
|
|
212
|
+
'eip155:690',
|
|
213
|
+
// Scroll
|
|
214
|
+
'eip155:534352',
|
|
215
|
+
// Sei
|
|
216
|
+
'eip155:1329',
|
|
217
|
+
// Soneium
|
|
218
|
+
'eip155:1499',
|
|
219
|
+
// Sonic
|
|
220
|
+
'eip155:7007',
|
|
221
|
+
// Taiko
|
|
222
|
+
'eip155:167000',
|
|
223
|
+
// Viction
|
|
224
|
+
'eip155:88',
|
|
225
|
+
// Unichain
|
|
226
|
+
'eip155:12345',
|
|
227
|
+
// Wonder
|
|
228
|
+
'eip155:8787',
|
|
229
|
+
// X Layer
|
|
230
|
+
'eip155:196',
|
|
231
|
+
// World Chain
|
|
232
|
+
'eip155:2008',
|
|
233
|
+
// ZERϴ
|
|
234
|
+
'eip155:77777',
|
|
235
|
+
// ZkLink Nova
|
|
236
|
+
'eip155:810180',
|
|
237
|
+
// re.al
|
|
238
|
+
'eip155:666'
|
|
239
|
+
],
|
|
240
|
+
|
|
241
|
+
SWAP_SUPPORTED_NETWORKS: [
|
|
242
|
+
// Ethereum'
|
|
243
|
+
'eip155:1',
|
|
244
|
+
// Arbitrum One'
|
|
245
|
+
'eip155:42161',
|
|
246
|
+
// Optimism'
|
|
247
|
+
'eip155:10',
|
|
248
|
+
// ZKSync Era'
|
|
249
|
+
'eip155:324',
|
|
250
|
+
// Base'
|
|
251
|
+
'eip155:8453',
|
|
252
|
+
// BNB Smart Chain'
|
|
253
|
+
'eip155:56',
|
|
254
|
+
// Polygon'
|
|
255
|
+
'eip155:137',
|
|
256
|
+
// Gnosis'
|
|
257
|
+
'eip155:100',
|
|
258
|
+
// Avalanche'
|
|
259
|
+
'eip155:43114',
|
|
260
|
+
// Fantom'
|
|
261
|
+
'eip155:250',
|
|
262
|
+
// Klaytn'
|
|
263
|
+
'eip155:8217',
|
|
264
|
+
// Aurora
|
|
265
|
+
'eip155:1313161554'
|
|
266
|
+
],
|
|
267
|
+
|
|
268
|
+
SEND_SUPPORTED_NAMESPACES: ['eip155', 'solana'],
|
|
269
|
+
|
|
270
|
+
ONRAMP_SUPPORTED_NAMESPACES: ['eip155', 'solana', 'bip122'],
|
|
271
|
+
|
|
272
|
+
CONVERT_SLIPPAGE_TOLERANCE: 1,
|
|
273
|
+
|
|
274
|
+
DEFAULT_FEATURES: defaultFeatures,
|
|
275
|
+
|
|
276
|
+
NETWORK_DEFAULT_CURRENCIES: {
|
|
277
|
+
'eip155:1': 'ETH', // Ethereum Mainnet
|
|
278
|
+
'eip155:56': 'BNB', // Binance Smart Chain
|
|
279
|
+
'eip155:137': 'POL', // Polygon
|
|
280
|
+
'eip155:42161': 'ETH_ARBITRUM', // Arbitrum One
|
|
281
|
+
'eip155:43114': 'AVAX', // Avalanche C-Chain
|
|
282
|
+
'eip155:10': 'ETH_OPTIMISM', // Optimism
|
|
283
|
+
'eip155:250': 'FTM', // Fantom
|
|
284
|
+
'eip155:100': 'xDAI', // Gnosis Chain (formerly xDai)
|
|
285
|
+
'eip155:8453': 'ETH_BASE', // Base
|
|
286
|
+
'eip155:1284': 'GLMR', // Moonbeam
|
|
287
|
+
'eip155:1285': 'MOVR', // Moonriver
|
|
288
|
+
'eip155:25': 'CRO', // Cronos
|
|
289
|
+
'eip155:42220': 'CELO', // Celo
|
|
290
|
+
'eip155:8217': 'KLAY', // Klaytn
|
|
291
|
+
'eip155:1313161554': 'AURORA_ETH', // Aurora
|
|
292
|
+
'eip155:40': 'TLOS', // Telos EVM
|
|
293
|
+
'eip155:1088': 'METIS', // Metis Andromeda
|
|
294
|
+
'eip155:2222': 'KAVA', // Kava EVM
|
|
295
|
+
'eip155:7777777': 'ZETA', // ZetaChain
|
|
296
|
+
'eip155:7700': 'CANTO', // Canto
|
|
297
|
+
'eip155:59144': 'ETH_LINEA', // Linea
|
|
298
|
+
'eip155:1101': 'ETH_POLYGONZKEVM', // Polygon zkEVM
|
|
299
|
+
'eip155:196': 'XIN', // Mixin
|
|
300
|
+
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'SOL',
|
|
301
|
+
'bip122:000000000019d6689c085ae165831e93': 'BTC'
|
|
302
|
+
}
|
|
303
|
+
};
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/* eslint-disable no-bitwise */
|
|
2
|
+
|
|
3
|
+
import { Linking, Platform } from 'react-native';
|
|
4
|
+
import {
|
|
5
|
+
BlockchainAdapter,
|
|
6
|
+
ConstantsUtil as CommonConstants,
|
|
7
|
+
type AdapterType,
|
|
8
|
+
type Balance,
|
|
9
|
+
type CaipAddress,
|
|
10
|
+
type CaipNetwork,
|
|
11
|
+
type ChainNamespace,
|
|
12
|
+
type SocialProvider,
|
|
13
|
+
type LinkingRecord,
|
|
14
|
+
type DataWallet,
|
|
15
|
+
type SdkVersion
|
|
16
|
+
} from '@reown/appkit-common-react-native';
|
|
17
|
+
|
|
18
|
+
import * as ct from 'countries-and-timezones';
|
|
19
|
+
|
|
20
|
+
import { ConstantsUtil } from './ConstantsUtil';
|
|
21
|
+
import { OptionsController } from '../controllers/OptionsController';
|
|
22
|
+
|
|
23
|
+
// -- Helpers -----------------------------------------------------------------
|
|
24
|
+
async function isAppInstalledIos(deepLink?: string): Promise<boolean> {
|
|
25
|
+
try {
|
|
26
|
+
return deepLink ? Linking.canOpenURL(deepLink) : Promise.resolve(false);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return Promise.resolve(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function isAppInstalledAndroid(packageName?: string): Promise<boolean> {
|
|
33
|
+
try {
|
|
34
|
+
//@ts-ignore
|
|
35
|
+
if (!packageName || typeof global?.Application?.isAppInstalled !== 'function') {
|
|
36
|
+
return Promise.resolve(false);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//@ts-ignore
|
|
40
|
+
return global?.Application?.isAppInstalled(packageName);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return Promise.resolve(false);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// -- Utility --------------------------------------------------------------------
|
|
47
|
+
export const CoreHelperUtil = {
|
|
48
|
+
isPairingExpired(expiry?: number) {
|
|
49
|
+
return expiry ? expiry - Date.now() <= ConstantsUtil.TEN_SEC_MS : true;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
isAllowedRetry(lastRetry: number) {
|
|
53
|
+
return Date.now() - lastRetry >= ConstantsUtil.ONE_SEC_MS;
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
isCaipAddress(address?: unknown): address is CaipAddress {
|
|
57
|
+
if (typeof address !== 'string') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const sections = address.split(':');
|
|
62
|
+
const namespace = sections[0];
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
sections.filter(Boolean).length === 3 &&
|
|
66
|
+
(namespace as string) in CommonConstants.CHAIN_NAME_MAP
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
getPairingExpiry() {
|
|
71
|
+
return Date.now() + ConstantsUtil.FOUR_MINUTES_MS;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
getNetworkId(caipAddress: CaipAddress | undefined) {
|
|
75
|
+
return caipAddress?.split(':')[1];
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
getPlainAddress(address: CaipAddress | string | undefined) {
|
|
79
|
+
if (this.isCaipAddress(address)) {
|
|
80
|
+
return address?.split(':')[2];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return address;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
async wait(milliseconds: number) {
|
|
87
|
+
return new Promise(resolve => {
|
|
88
|
+
setTimeout(resolve, milliseconds);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
isHttpUrl(url: string) {
|
|
93
|
+
return url.startsWith('http://') || url.startsWith('https://');
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
isLinkModeURL(url?: string) {
|
|
97
|
+
if (!url) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return CoreHelperUtil.isHttpUrl(url) && url.includes('wc_ev');
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
formatNativeUrl(appUrl: string, wcUri: string): LinkingRecord {
|
|
105
|
+
if (CoreHelperUtil.isLinkModeURL(wcUri)) {
|
|
106
|
+
return {
|
|
107
|
+
redirect: wcUri,
|
|
108
|
+
href: wcUri
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (CoreHelperUtil.isHttpUrl(appUrl)) {
|
|
113
|
+
return this.formatUniversalUrl(appUrl, wcUri);
|
|
114
|
+
}
|
|
115
|
+
let safeAppUrl = appUrl;
|
|
116
|
+
if (!safeAppUrl.includes('://')) {
|
|
117
|
+
safeAppUrl = appUrl.replaceAll('/', '').replaceAll(':', '');
|
|
118
|
+
safeAppUrl = `${safeAppUrl}://`;
|
|
119
|
+
}
|
|
120
|
+
if (!safeAppUrl.endsWith('/')) {
|
|
121
|
+
safeAppUrl = `${safeAppUrl}/`;
|
|
122
|
+
}
|
|
123
|
+
const encodedWcUrl = encodeURIComponent(wcUri);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
redirect: `${safeAppUrl}wc?uri=${encodedWcUrl}`,
|
|
127
|
+
href: safeAppUrl
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
formatUniversalUrl(appUrl: string, wcUri: string, provider?: SocialProvider): LinkingRecord {
|
|
132
|
+
if (CoreHelperUtil.isLinkModeURL(wcUri)) {
|
|
133
|
+
return {
|
|
134
|
+
redirect: wcUri,
|
|
135
|
+
href: wcUri
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!CoreHelperUtil.isHttpUrl(appUrl)) {
|
|
140
|
+
return this.formatNativeUrl(appUrl, wcUri);
|
|
141
|
+
}
|
|
142
|
+
let safeAppUrl = appUrl;
|
|
143
|
+
if (!safeAppUrl.endsWith('/')) {
|
|
144
|
+
safeAppUrl = `${safeAppUrl}/`;
|
|
145
|
+
}
|
|
146
|
+
const encodedWcUrl = encodeURIComponent(wcUri);
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
redirect: provider
|
|
150
|
+
? `${safeAppUrl}wc?uri=${encodedWcUrl}&provider=${provider}`
|
|
151
|
+
: `${safeAppUrl}wc?uri=${encodedWcUrl}`,
|
|
152
|
+
href: safeAppUrl
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
async openLink(url: string) {
|
|
157
|
+
try {
|
|
158
|
+
await Linking.openURL(url);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw new Error(ConstantsUtil.LINKING_ERROR);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
formatBalance(balance: string | undefined, symbol: string | undefined, decimals = 3) {
|
|
165
|
+
let formattedBalance;
|
|
166
|
+
|
|
167
|
+
if (balance === '0') {
|
|
168
|
+
formattedBalance = '0.000';
|
|
169
|
+
} else if (typeof balance === 'string') {
|
|
170
|
+
const number = Number(balance);
|
|
171
|
+
if (number) {
|
|
172
|
+
const regex = new RegExp(`^-?\\d+(?:\\.\\d{0,${decimals}})?`, 'u');
|
|
173
|
+
formattedBalance = number.toString().match(regex)?.[0];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return formattedBalance ? `${formattedBalance} ${symbol}` : `0.000 ${symbol || ''}`;
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
isAddress(address: string, namespace: ChainNamespace = 'eip155'): boolean {
|
|
181
|
+
switch (namespace) {
|
|
182
|
+
case 'eip155':
|
|
183
|
+
if (!/^(?:0x)?[0-9a-f]{40}$/iu.test(address)) {
|
|
184
|
+
return false;
|
|
185
|
+
} else if (
|
|
186
|
+
/^(?:0x)?[0-9a-f]{40}$/iu.test(address) ||
|
|
187
|
+
/^(?:0x)?[0-9A-F]{40}$/iu.test(address)
|
|
188
|
+
) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return false;
|
|
193
|
+
case 'solana':
|
|
194
|
+
return /[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(address);
|
|
195
|
+
|
|
196
|
+
default:
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
getApiUrl() {
|
|
202
|
+
return CommonConstants.API_URL;
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
getBlockchainApiUrl() {
|
|
206
|
+
return CommonConstants.BLOCKCHAIN_API_RPC_URL;
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
getBlockchainStagingApiUrl() {
|
|
210
|
+
return CommonConstants.BLOCKCHAIN_API_RPC_URL_STAGING;
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
getAnalyticsUrl() {
|
|
214
|
+
return CommonConstants.PULSE_API_URL;
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
getCountryFromTimezone() {
|
|
218
|
+
try {
|
|
219
|
+
const { timeZone } = new Intl.DateTimeFormat().resolvedOptions();
|
|
220
|
+
const country = ct.getCountryForTimezone(timeZone);
|
|
221
|
+
|
|
222
|
+
return country ? country.id : 'US'; // 'id' is the ISO country code (e.g., "US" for United States)
|
|
223
|
+
} catch (error) {
|
|
224
|
+
return 'US';
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
getUUID() {
|
|
229
|
+
if ((global as any)?.crypto.getRandomValues) {
|
|
230
|
+
const buffer = new Uint8Array(16);
|
|
231
|
+
(global as any)?.crypto.getRandomValues(buffer);
|
|
232
|
+
|
|
233
|
+
// Set the version (4) and variant (8, 9, A, or B) bits
|
|
234
|
+
buffer[6] = (buffer[6] ?? 0 & 0x0f) | 0x40;
|
|
235
|
+
buffer[8] = (buffer[8] ?? 0 & 0x3f) | 0x80;
|
|
236
|
+
|
|
237
|
+
// Convert the buffer to a hexadecimal string
|
|
238
|
+
const hexString = Array.from(buffer, byte => byte.toString(16).padStart(2, '0')).join('');
|
|
239
|
+
const formatted = `${hexString.slice(0, 8)}-${hexString.slice(8, 12)}-${hexString.slice(
|
|
240
|
+
12,
|
|
241
|
+
16
|
|
242
|
+
)}-${hexString.slice(16, 20)}-${hexString.slice(20)}`;
|
|
243
|
+
|
|
244
|
+
return formatted;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/gu, c => {
|
|
248
|
+
const r = (Math.random() * 16) | 0;
|
|
249
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
250
|
+
|
|
251
|
+
return v.toString(16);
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
getBundleId(): string | undefined {
|
|
256
|
+
if ((global as any)?.Application?.applicationId) {
|
|
257
|
+
return (global as any)?.Application?.applicationId;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return undefined;
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
parseError(error: any): string {
|
|
264
|
+
if (typeof error === 'string') {
|
|
265
|
+
return error;
|
|
266
|
+
} else if (typeof error?.issues?.[0]?.message === 'string') {
|
|
267
|
+
return error.issues[0].message;
|
|
268
|
+
} else if (error instanceof Error) {
|
|
269
|
+
return error.message;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return 'Unknown error';
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
async checkInstalled(wallet: DataWallet): Promise<boolean> {
|
|
276
|
+
let isInstalled = false;
|
|
277
|
+
const scheme = wallet.ios_schema;
|
|
278
|
+
const appId = wallet.android_app_id;
|
|
279
|
+
try {
|
|
280
|
+
isInstalled = await Platform.select({
|
|
281
|
+
ios: isAppInstalledIos(scheme),
|
|
282
|
+
android: isAppInstalledAndroid(appId),
|
|
283
|
+
default: Promise.resolve(false)
|
|
284
|
+
});
|
|
285
|
+
} catch {
|
|
286
|
+
isInstalled = false;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return isInstalled;
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
isValidEmail(email: string) {
|
|
293
|
+
return ConstantsUtil.EMAIL_REGEX.test(email);
|
|
294
|
+
},
|
|
295
|
+
|
|
296
|
+
allSettled(promises: Promise<unknown>[]) {
|
|
297
|
+
return Promise.all(
|
|
298
|
+
promises.map(promise =>
|
|
299
|
+
promise
|
|
300
|
+
.then(value => ({ status: 'fulfilled', value }))
|
|
301
|
+
.catch(reason => ({ status: 'rejected', reason }))
|
|
302
|
+
)
|
|
303
|
+
);
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
calculateAndFormatBalance(array?: Balance[]) {
|
|
307
|
+
if (!array?.length) {
|
|
308
|
+
return { dollars: '0', pennies: '00' };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
let sum = 0;
|
|
312
|
+
for (const item of array) {
|
|
313
|
+
sum += item?.value ?? 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const roundedNumber = sum.toFixed(2);
|
|
317
|
+
const [dollars, pennies] = roundedNumber.split('.');
|
|
318
|
+
|
|
319
|
+
return { dollars, pennies };
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
sortNetworks(
|
|
323
|
+
approvedCaipNetworkIds: `${string}:${string}`[] | undefined,
|
|
324
|
+
requestedCaipNetworks: CaipNetwork[] = []
|
|
325
|
+
) {
|
|
326
|
+
const approvedIds = approvedCaipNetworkIds;
|
|
327
|
+
const requested = [...requestedCaipNetworks];
|
|
328
|
+
|
|
329
|
+
if (approvedIds?.length) {
|
|
330
|
+
requested?.sort((a, b) => {
|
|
331
|
+
if (approvedIds.includes(a.id) && !approvedIds.includes(b.id)) return -1;
|
|
332
|
+
if (approvedIds.includes(b.id) && !approvedIds.includes(a.id)) return 1;
|
|
333
|
+
|
|
334
|
+
return 0;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return requested;
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
debounce<F extends (...args: any[]) => any>(func: F, wait: number) {
|
|
342
|
+
let timeout: ReturnType<typeof setTimeout> | null = null;
|
|
343
|
+
|
|
344
|
+
return function (...args: Parameters<F>) {
|
|
345
|
+
if (timeout) {
|
|
346
|
+
clearTimeout(timeout);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
timeout = setTimeout(() => {
|
|
350
|
+
func(...args);
|
|
351
|
+
}, wait);
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
generateSdkVersion(adapters: BlockchainAdapter[], version: string): SdkVersion {
|
|
356
|
+
const hasNoAdapters = adapters.length === 0;
|
|
357
|
+
const universalType: AdapterType = 'universal';
|
|
358
|
+
|
|
359
|
+
const adapterNames = hasNoAdapters
|
|
360
|
+
? universalType
|
|
361
|
+
: adapters
|
|
362
|
+
.sort((a, b) => a.adapterType.localeCompare(b.adapterType))
|
|
363
|
+
.map(adapter => adapter.adapterType)
|
|
364
|
+
.join(',');
|
|
365
|
+
|
|
366
|
+
return `react-native-${adapterNames}-${version}`;
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
getRequestedCaipNetworkIds() {
|
|
370
|
+
const chains = OptionsController.state.requestedNetworks;
|
|
371
|
+
if (!chains) return [];
|
|
372
|
+
|
|
373
|
+
const requestedIds = chains.map(caipNetwork => caipNetwork.caipNetworkId);
|
|
374
|
+
|
|
375
|
+
return requestedIds;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Platform, WcWallet } from '@reown/appkit-common-react-native';
|
|
2
|
+
|
|
3
|
+
export const EventUtil = {
|
|
4
|
+
getWalletPlatform(wallet: WcWallet, installed?: boolean): Platform | undefined {
|
|
5
|
+
if (installed) {
|
|
6
|
+
return 'mobile';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (wallet.mobile_link && wallet.webapp_link) {
|
|
10
|
+
// if we cannot assure what platform the wallet is, we return undefined
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
if (wallet.mobile_link) {
|
|
14
|
+
return 'mobile';
|
|
15
|
+
}
|
|
16
|
+
if (wallet.webapp_link) {
|
|
17
|
+
return 'web';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|