@reown/appkit-core-react-native 0.0.0-fix-email-login-20241010173711 → 0.0.0-fix-fetch-error-improvements-20241114122508

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.
Files changed (172) hide show
  1. package/lib/commonjs/controllers/AccountController.js +35 -1
  2. package/lib/commonjs/controllers/AccountController.js.map +1 -1
  3. package/lib/commonjs/controllers/ApiController.js +16 -9
  4. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  5. package/lib/commonjs/controllers/BlockchainApiController.js +84 -0
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionController.js +30 -7
  8. package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
  9. package/lib/commonjs/controllers/ConnectorController.js +9 -1
  10. package/lib/commonjs/controllers/ConnectorController.js.map +1 -1
  11. package/lib/commonjs/controllers/EnsController.js +35 -0
  12. package/lib/commonjs/controllers/EnsController.js.map +1 -0
  13. package/lib/commonjs/controllers/EventsController.js +1 -15
  14. package/lib/commonjs/controllers/EventsController.js.map +1 -1
  15. package/lib/commonjs/controllers/ModalController.js +3 -1
  16. package/lib/commonjs/controllers/ModalController.js.map +1 -1
  17. package/lib/commonjs/controllers/NetworkController.js +20 -1
  18. package/lib/commonjs/controllers/NetworkController.js.map +1 -1
  19. package/lib/commonjs/controllers/OptionsController.js +14 -2
  20. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  21. package/lib/commonjs/controllers/RouterController.js +22 -1
  22. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  23. package/lib/commonjs/controllers/SendController.js +176 -0
  24. package/lib/commonjs/controllers/SendController.js.map +1 -0
  25. package/lib/commonjs/controllers/SnackController.js +21 -1
  26. package/lib/commonjs/controllers/SnackController.js.map +1 -1
  27. package/lib/commonjs/controllers/SwapController.js +91 -0
  28. package/lib/commonjs/controllers/SwapController.js.map +1 -0
  29. package/lib/commonjs/controllers/TransactionsController.js +112 -0
  30. package/lib/commonjs/controllers/TransactionsController.js.map +1 -0
  31. package/lib/commonjs/controllers/WebviewController.js +52 -0
  32. package/lib/commonjs/controllers/WebviewController.js.map +1 -0
  33. package/lib/commonjs/index.js +42 -0
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/utils/ApiUtil.js +18 -0
  36. package/lib/commonjs/utils/ApiUtil.js.map +1 -0
  37. package/lib/commonjs/utils/ConstantsUtil.js +8 -1
  38. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  39. package/lib/commonjs/utils/CoreHelperUtil.js +33 -0
  40. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  41. package/lib/commonjs/utils/FetchUtil.js.map +1 -1
  42. package/lib/commonjs/utils/StorageUtil.js +24 -0
  43. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  44. package/lib/commonjs/utils/SwapApiUtil.js +23 -0
  45. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -0
  46. package/lib/commonjs/utils/SwapCalculationUtil.js +24 -0
  47. package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -0
  48. package/lib/commonjs/utils/TypeUtil.js +4 -0
  49. package/lib/module/controllers/AccountController.js +35 -1
  50. package/lib/module/controllers/AccountController.js.map +1 -1
  51. package/lib/module/controllers/ApiController.js +16 -9
  52. package/lib/module/controllers/ApiController.js.map +1 -1
  53. package/lib/module/controllers/BlockchainApiController.js +84 -0
  54. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  55. package/lib/module/controllers/ConnectionController.js +30 -7
  56. package/lib/module/controllers/ConnectionController.js.map +1 -1
  57. package/lib/module/controllers/ConnectorController.js +9 -1
  58. package/lib/module/controllers/ConnectorController.js.map +1 -1
  59. package/lib/module/controllers/EnsController.js +30 -0
  60. package/lib/module/controllers/EnsController.js.map +1 -0
  61. package/lib/module/controllers/EventsController.js +1 -15
  62. package/lib/module/controllers/EventsController.js.map +1 -1
  63. package/lib/module/controllers/ModalController.js +3 -1
  64. package/lib/module/controllers/ModalController.js.map +1 -1
  65. package/lib/module/controllers/NetworkController.js +20 -1
  66. package/lib/module/controllers/NetworkController.js.map +1 -1
  67. package/lib/module/controllers/OptionsController.js +14 -2
  68. package/lib/module/controllers/OptionsController.js.map +1 -1
  69. package/lib/module/controllers/RouterController.js +22 -1
  70. package/lib/module/controllers/RouterController.js.map +1 -1
  71. package/lib/module/controllers/SendController.js +171 -0
  72. package/lib/module/controllers/SendController.js.map +1 -0
  73. package/lib/module/controllers/SnackController.js +21 -1
  74. package/lib/module/controllers/SnackController.js.map +1 -1
  75. package/lib/module/controllers/SwapController.js +86 -0
  76. package/lib/module/controllers/SwapController.js.map +1 -0
  77. package/lib/module/controllers/TransactionsController.js +107 -0
  78. package/lib/module/controllers/TransactionsController.js.map +1 -0
  79. package/lib/module/controllers/WebviewController.js +47 -0
  80. package/lib/module/controllers/WebviewController.js.map +1 -0
  81. package/lib/module/index.js +7 -0
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/utils/ApiUtil.js +12 -0
  84. package/lib/module/utils/ApiUtil.js.map +1 -0
  85. package/lib/module/utils/ConstantsUtil.js +8 -1
  86. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  87. package/lib/module/utils/CoreHelperUtil.js +33 -0
  88. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  89. package/lib/module/utils/FetchUtil.js.map +1 -1
  90. package/lib/module/utils/StorageUtil.js +24 -0
  91. package/lib/module/utils/StorageUtil.js.map +1 -1
  92. package/lib/module/utils/SwapApiUtil.js +17 -0
  93. package/lib/module/utils/SwapApiUtil.js.map +1 -0
  94. package/lib/module/utils/SwapCalculationUtil.js +19 -0
  95. package/lib/module/utils/SwapCalculationUtil.js.map +1 -0
  96. package/lib/module/utils/TypeUtil.js +1 -1
  97. package/lib/typescript/controllers/AccountController.d.ts +9 -1
  98. package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
  99. package/lib/typescript/controllers/ApiController.d.ts +2 -1
  100. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  101. package/lib/typescript/controllers/BlockchainApiController.d.ts +6 -1
  102. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  103. package/lib/typescript/controllers/ConnectionController.d.ts +16 -1
  104. package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
  105. package/lib/typescript/controllers/ConnectorController.d.ts +1 -1
  106. package/lib/typescript/controllers/ConnectorController.d.ts.map +1 -1
  107. package/lib/typescript/controllers/EnsController.d.ts +10 -0
  108. package/lib/typescript/controllers/EnsController.d.ts.map +1 -0
  109. package/lib/typescript/controllers/EventsController.d.ts +0 -6
  110. package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
  111. package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
  112. package/lib/typescript/controllers/NetworkController.d.ts +5 -0
  113. package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
  114. package/lib/typescript/controllers/OptionsController.d.ts +6 -2
  115. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  116. package/lib/typescript/controllers/RouterController.d.ts +15 -1
  117. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  118. package/lib/typescript/controllers/SendController.d.ts +41 -0
  119. package/lib/typescript/controllers/SendController.d.ts.map +1 -0
  120. package/lib/typescript/controllers/SnackController.d.ts +7 -0
  121. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  122. package/lib/typescript/controllers/SwapController.d.ts +29 -0
  123. package/lib/typescript/controllers/SwapController.d.ts.map +1 -0
  124. package/lib/typescript/controllers/TransactionsController.d.ts +21 -0
  125. package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -0
  126. package/lib/typescript/controllers/WebviewController.d.ts +21 -0
  127. package/lib/typescript/controllers/WebviewController.d.ts.map +1 -0
  128. package/lib/typescript/index.d.ts +19 -26
  129. package/lib/typescript/index.d.ts.map +1 -1
  130. package/lib/typescript/utils/ApiUtil.d.ts +5 -0
  131. package/lib/typescript/utils/ApiUtil.d.ts.map +1 -0
  132. package/lib/typescript/utils/ConstantsUtil.d.ts +3 -0
  133. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  134. package/lib/typescript/utils/CoreHelperUtil.d.ts +6 -0
  135. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  136. package/lib/typescript/utils/FetchUtil.d.ts +4 -0
  137. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  138. package/lib/typescript/utils/StorageUtil.d.ts +5 -1
  139. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  140. package/lib/typescript/utils/SwapApiUtil.d.ts +4 -0
  141. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -0
  142. package/lib/typescript/utils/SwapCalculationUtil.d.ts +5 -0
  143. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -0
  144. package/lib/typescript/utils/TypeUtil.d.ts +242 -3
  145. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  146. package/package.json +5 -5
  147. package/readme.md +1 -1
  148. package/src/controllers/AccountController.ts +50 -2
  149. package/src/controllers/ApiController.ts +27 -23
  150. package/src/controllers/BlockchainApiController.ts +88 -1
  151. package/src/controllers/ConnectionController.ts +52 -8
  152. package/src/controllers/ConnectorController.ts +13 -1
  153. package/src/controllers/EnsController.ts +39 -0
  154. package/src/controllers/EventsController.ts +1 -13
  155. package/src/controllers/ModalController.ts +3 -1
  156. package/src/controllers/NetworkController.ts +34 -1
  157. package/src/controllers/OptionsController.ts +25 -4
  158. package/src/controllers/RouterController.ts +59 -10
  159. package/src/controllers/SendController.ts +234 -0
  160. package/src/controllers/SnackController.ts +28 -1
  161. package/src/controllers/SwapController.ts +108 -0
  162. package/src/controllers/TransactionsController.ts +142 -0
  163. package/src/controllers/WebviewController.ts +63 -0
  164. package/src/index.ts +43 -30
  165. package/src/utils/ApiUtil.ts +18 -0
  166. package/src/utils/ConstantsUtil.ts +13 -1
  167. package/src/utils/CoreHelperUtil.ts +38 -1
  168. package/src/utils/FetchUtil.ts +4 -0
  169. package/src/utils/StorageUtil.ts +31 -1
  170. package/src/utils/SwapApiUtil.ts +19 -0
  171. package/src/utils/SwapCalculationUtil.ts +21 -0
  172. package/src/utils/TypeUtil.ts +273 -3
@@ -1,3 +1,10 @@
1
+ import { type EventEmitter } from 'events';
2
+ import type { Balance, SocialProvider, Transaction } from '@reown/appkit-common-react-native';
3
+
4
+ export interface BaseError {
5
+ message?: string;
6
+ }
7
+
1
8
  export type CaipAddress = `${string}:${string}:${string}`;
2
9
 
3
10
  export type CaipNetworkId = `${string}:${string}`;
@@ -49,11 +56,31 @@ export type CaipNamespaces = Record<
49
56
  }
50
57
  >;
51
58
 
59
+ export type SdkType = 'appkit';
60
+
52
61
  export type SdkVersion =
53
62
  | `react-native-wagmi-${string}`
54
63
  | `react-native-ethers5-${string}`
55
64
  | `react-native-ethers-${string}`;
56
65
 
66
+ export type Features = {
67
+ /**
68
+ * @description Enable or disable the email feature. Enabled by default.
69
+ * @type {boolean}
70
+ */
71
+ email?: boolean;
72
+ /**
73
+ * @description Show or hide the regular wallet options when email is enabled. Enabled by default.
74
+ * @type {boolean}
75
+ */
76
+ emailShowWallets?: boolean;
77
+ /**
78
+ * @description Enable or disable the socials feature. Enabled by default.
79
+ * @type {FeaturesSocials[]}
80
+ */
81
+ socials?: SocialProvider[] | false;
82
+ };
83
+
57
84
  // -- ApiController Types -------------------------------------------------------
58
85
  export interface WcWallet {
59
86
  id: string;
@@ -98,6 +125,16 @@ export interface ApiGetAnalyticsConfigResponse {
98
125
  isAnalyticsEnabled: boolean;
99
126
  }
100
127
 
128
+ export type RequestCache =
129
+ | 'default'
130
+ | 'force-cache'
131
+ | 'no-cache'
132
+ | 'no-store'
133
+ | 'only-if-cached'
134
+ | 'reload';
135
+
136
+ // -- ThemeController Types ---------------------------------------------------
137
+
101
138
  export type ThemeMode = 'dark' | 'light';
102
139
 
103
140
  export interface ThemeVariables {
@@ -114,6 +151,74 @@ export interface BlockchainApiIdentityResponse {
114
151
  name: string;
115
152
  }
116
153
 
154
+ export interface BlockchainApiBalanceResponse {
155
+ balances: Balance[];
156
+ }
157
+
158
+ export interface BlockchainApiTransactionsRequest {
159
+ account: string;
160
+ projectId: string;
161
+ cursor?: string;
162
+ onramp?: 'coinbase';
163
+ signal?: AbortSignal;
164
+ cache?: RequestCache;
165
+ }
166
+
167
+ export interface BlockchainApiTransactionsResponse {
168
+ data: Transaction[];
169
+ next: string | null;
170
+ }
171
+
172
+ export interface BlockchainApiTokenPriceRequest {
173
+ projectId: string;
174
+ currency?: 'usd' | 'eur' | 'gbp' | 'aud' | 'cad' | 'inr' | 'jpy' | 'btc' | 'eth';
175
+ addresses: string[];
176
+ }
177
+
178
+ export interface BlockchainApiTokenPriceResponse {
179
+ fungibles: {
180
+ name: string;
181
+ symbol: string;
182
+ iconUrl: string;
183
+ price: number;
184
+ }[];
185
+ }
186
+
187
+ export interface BlockchainApiGasPriceRequest {
188
+ projectId: string;
189
+ chainId: string;
190
+ }
191
+
192
+ export interface BlockchainApiGasPriceResponse {
193
+ standard: string;
194
+ fast: string;
195
+ instant: string;
196
+ }
197
+
198
+ export interface BlockchainApiEnsError extends BaseError {
199
+ status: string;
200
+ reasons: { name: string; description: string }[];
201
+ }
202
+
203
+ export type ReownName = `${string}.reown.id` | `${string}.wcn.id`;
204
+
205
+ export interface BlockchainApiLookupEnsName {
206
+ name: ReownName;
207
+ registered: number;
208
+ updated: number;
209
+ addresses: Record<
210
+ string,
211
+ {
212
+ address: string;
213
+ created: string;
214
+ }
215
+ >;
216
+ attributes: {
217
+ avatar?: string;
218
+ bio?: string;
219
+ }[];
220
+ }
221
+
117
222
  // -- OptionsController Types ---------------------------------------------------
118
223
  export interface Token {
119
224
  address: string;
@@ -272,40 +377,190 @@ export type Event =
272
377
  | {
273
378
  type: 'track';
274
379
  event: 'CLICK_SIGN_SIWE_MESSAGE';
380
+ properties: {
381
+ network: string;
382
+ isSmartAccount: boolean;
383
+ };
275
384
  }
276
385
  | {
277
386
  type: 'track';
278
387
  event: 'CLICK_CANCEL_SIWE';
388
+ properties: {
389
+ network: string;
390
+ isSmartAccount: boolean;
391
+ };
279
392
  }
280
393
  | {
281
394
  type: 'track';
282
395
  event: 'SIWE_AUTH_SUCCESS';
396
+ properties: {
397
+ network: string;
398
+ isSmartAccount: boolean;
399
+ };
283
400
  }
284
401
  | {
285
402
  type: 'track';
286
403
  event: 'SIWE_AUTH_ERROR';
404
+ properties: {
405
+ network: string;
406
+ isSmartAccount: boolean;
407
+ };
408
+ }
409
+ | {
410
+ type: 'track';
411
+ event: 'CLICK_TRANSACTIONS';
412
+ properties: {
413
+ isSmartAccount: boolean;
414
+ };
415
+ }
416
+ | {
417
+ type: 'track';
418
+ event: 'ERROR_FETCH_TRANSACTIONS';
419
+ properties: {
420
+ address: string;
421
+ projectId: string;
422
+ cursor: string | undefined;
423
+ isSmartAccount: boolean;
424
+ };
425
+ }
426
+ | {
427
+ type: 'track';
428
+ event: 'LOAD_MORE_TRANSACTIONS';
429
+ properties: {
430
+ address: string | undefined;
431
+ projectId: string;
432
+ cursor: string | undefined;
433
+ isSmartAccount: boolean;
434
+ };
435
+ }
436
+ | {
437
+ type: 'track';
438
+ event: 'OPEN_SEND';
439
+ properties: {
440
+ isSmartAccount: boolean;
441
+ network: string;
442
+ };
443
+ }
444
+ | {
445
+ type: 'track';
446
+ event: 'SEND_INITIATED';
447
+ properties: {
448
+ isSmartAccount: boolean;
449
+ network: string;
450
+ token: string;
451
+ amount: number;
452
+ };
453
+ }
454
+ | {
455
+ type: 'track';
456
+ event: 'SEND_SUCCESS';
457
+ properties: {
458
+ isSmartAccount: boolean;
459
+ network: string;
460
+ token: string;
461
+ amount: number;
462
+ };
463
+ }
464
+ | {
465
+ type: 'track';
466
+ event: 'SEND_ERROR';
467
+ properties: {
468
+ isSmartAccount: boolean;
469
+ network: string;
470
+ token: string;
471
+ amount: number;
472
+ };
473
+ }
474
+ | {
475
+ type: 'track';
476
+ event: 'SOCIAL_LOGIN_STARTED';
477
+ properties: {
478
+ provider: SocialProvider;
479
+ };
480
+ }
481
+ | {
482
+ type: 'track';
483
+ event: 'SOCIAL_LOGIN_SUCCESS';
484
+ properties: {
485
+ provider: SocialProvider;
486
+ };
487
+ }
488
+ | {
489
+ type: 'track';
490
+ event: 'SOCIAL_LOGIN_ERROR';
491
+ properties: {
492
+ provider: SocialProvider;
493
+ };
494
+ }
495
+ | {
496
+ type: 'track';
497
+ event: 'SET_PREFERRED_ACCOUNT_TYPE';
498
+ properties: {
499
+ accountType: AppKitFrameAccountType;
500
+ network: string;
501
+ };
287
502
  };
288
503
 
504
+ // -- Send Controller Types -------------------------------------
505
+
506
+ export interface SendTransactionArgs {
507
+ to: `0x${string}`;
508
+ data: `0x${string}`;
509
+ value: bigint;
510
+ gas?: bigint;
511
+ gasPrice: bigint;
512
+ address: `0x${string}`;
513
+ }
514
+
515
+ export interface WriteContractArgs {
516
+ receiverAddress: `0x${string}`;
517
+ tokenAmount: bigint;
518
+ tokenAddress: `0x${string}`;
519
+ fromAddress: `0x${string}`;
520
+ method: 'send' | 'transfer' | 'call';
521
+ abi: any;
522
+ }
523
+
289
524
  // -- Email Types ------------------------------------------------
290
525
  /**
291
- * Matches type defined for packages/email/src/AppKitFrameProvider.ts
526
+ * Matches type defined for packages/wallet/src/AppKitFrameProvider.ts
292
527
  * It's duplicated in order to decouple scaffold from email package
293
528
  */
529
+
530
+ export type AppKitFrameAccountType = 'eoa' | 'smartAccount';
531
+
294
532
  export interface AppKitFrameProvider {
295
533
  readonly id: string;
296
534
  readonly name: string;
535
+ getEventEmitter(): EventEmitter;
297
536
  getSecureSiteURL(): string;
298
537
  getSecureSiteDashboardURL(): string;
299
538
  getSecureSiteIconURL(): string;
300
539
  getSecureSiteHeaders(): Record<string, string>;
301
- getLoginEmailUsed(): Promise<boolean>;
302
540
  getEmail(): string | undefined;
541
+ getUsername(): string | undefined;
542
+ getLastUsedChainId(): Promise<number | undefined>;
303
543
  rejectRpcRequest(): void;
304
544
  connectEmail(payload: { email: string }): Promise<{
305
545
  action: 'VERIFY_DEVICE' | 'VERIFY_OTP';
306
546
  }>;
307
547
  connectDevice(): Promise<unknown>;
548
+ connectSocial(uri: string): Promise<{
549
+ chainId: string | number;
550
+ email: string;
551
+ address: string;
552
+ accounts?: {
553
+ type: AppKitFrameAccountType;
554
+ address: string;
555
+ }[];
556
+ userName?: string;
557
+ }>;
558
+ getSocialRedirectUri(payload: { provider: SocialProvider }): Promise<{
559
+ uri: string;
560
+ }>;
308
561
  connectOtp(payload: { otp: string }): Promise<unknown>;
562
+ connectFarcaster: () => Promise<{ userName: string }>;
563
+ getFarcasterUri(): Promise<{ url: string }>;
309
564
  isConnected(): Promise<{
310
565
  isConnected: boolean;
311
566
  }>;
@@ -326,17 +581,32 @@ export interface AppKitFrameProvider {
326
581
  syncDappData(payload: {
327
582
  projectId: string;
328
583
  sdkVersion: SdkVersion;
584
+ sdkType: SdkType;
329
585
  metadata?: Metadata;
330
586
  }): Promise<unknown>;
331
587
  connect(payload?: { chainId: number | undefined }): Promise<{
332
588
  chainId: number;
333
- email: string;
589
+ email?: string | null;
334
590
  address: string;
591
+ smartAccountDeployed: boolean;
592
+ preferredAccountType: AppKitFrameAccountType;
335
593
  }>;
336
594
  switchNetwork(chainId: number): Promise<{
337
595
  chainId: number;
338
596
  }>;
597
+ setPreferredAccount(type: AppKitFrameAccountType): Promise<{
598
+ type: AppKitFrameAccountType;
599
+ address: string;
600
+ }>;
601
+ setOnTimeout(callback: () => void): void;
602
+ getSmartAccountEnabledNetworks(): Promise<{
603
+ smartAccountEnabledNetworks: number[];
604
+ }>;
339
605
  disconnect(): Promise<unknown>;
340
606
  request(req: any): Promise<any>;
341
607
  AuthView: () => JSX.Element | null;
608
+ Webview: () => JSX.Element | null;
609
+ onSetPreferredAccount: (
610
+ callback: (values: { type: AppKitFrameAccountType; address: string }) => void
611
+ ) => void;
342
612
  }