@reown/appkit-core-react-native 0.0.0-develop-20241121145434 → 0.0.0-develop-20250117202414

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 (110) hide show
  1. package/lib/commonjs/controllers/ApiController.js +1 -1
  2. package/lib/commonjs/controllers/BlockchainApiController.js +107 -21
  3. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  4. package/lib/commonjs/controllers/ConnectionController.js +8 -3
  5. package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
  6. package/lib/commonjs/controllers/NetworkController.js +6 -0
  7. package/lib/commonjs/controllers/NetworkController.js.map +1 -1
  8. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  9. package/lib/commonjs/controllers/SnackController.js +5 -0
  10. package/lib/commonjs/controllers/SnackController.js.map +1 -1
  11. package/lib/commonjs/controllers/SwapController.js +578 -6
  12. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  13. package/lib/commonjs/controllers/ThemeController.js +1 -1
  14. package/lib/commonjs/controllers/ThemeController.js.map +1 -1
  15. package/lib/commonjs/index.js +14 -0
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/utils/ConnectionUtil.js +33 -0
  18. package/lib/commonjs/utils/ConnectionUtil.js.map +1 -0
  19. package/lib/commonjs/utils/ConstantsUtil.js +30 -1
  20. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  21. package/lib/commonjs/utils/CoreHelperUtil.js +12 -12
  22. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  23. package/lib/commonjs/utils/NetworkUtil.js +46 -0
  24. package/lib/commonjs/utils/NetworkUtil.js.map +1 -0
  25. package/lib/commonjs/utils/RouterUtil.js +1 -1
  26. package/lib/commonjs/utils/RouterUtil.js.map +1 -1
  27. package/lib/commonjs/utils/SwapApiUtil.js +58 -0
  28. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
  29. package/lib/commonjs/utils/SwapCalculationUtil.js +73 -0
  30. package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
  31. package/lib/module/controllers/ApiController.js +1 -1
  32. package/lib/module/controllers/BlockchainApiController.js +107 -21
  33. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  34. package/lib/module/controllers/ConnectionController.js +8 -3
  35. package/lib/module/controllers/ConnectionController.js.map +1 -1
  36. package/lib/module/controllers/NetworkController.js +6 -0
  37. package/lib/module/controllers/NetworkController.js.map +1 -1
  38. package/lib/module/controllers/RouterController.js.map +1 -1
  39. package/lib/module/controllers/SnackController.js +5 -0
  40. package/lib/module/controllers/SnackController.js.map +1 -1
  41. package/lib/module/controllers/SwapController.js +578 -6
  42. package/lib/module/controllers/SwapController.js.map +1 -1
  43. package/lib/module/controllers/ThemeController.js +1 -1
  44. package/lib/module/controllers/ThemeController.js.map +1 -1
  45. package/lib/module/index.js +2 -0
  46. package/lib/module/index.js.map +1 -1
  47. package/lib/module/utils/ConnectionUtil.js +27 -0
  48. package/lib/module/utils/ConnectionUtil.js.map +1 -0
  49. package/lib/module/utils/ConstantsUtil.js +30 -1
  50. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  51. package/lib/module/utils/CoreHelperUtil.js +12 -12
  52. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  53. package/lib/module/utils/NetworkUtil.js +40 -0
  54. package/lib/module/utils/NetworkUtil.js.map +1 -0
  55. package/lib/module/utils/RouterUtil.js +1 -1
  56. package/lib/module/utils/RouterUtil.js.map +1 -1
  57. package/lib/module/utils/SwapApiUtil.js +58 -0
  58. package/lib/module/utils/SwapApiUtil.js.map +1 -1
  59. package/lib/module/utils/SwapCalculationUtil.js +73 -1
  60. package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
  61. package/lib/typescript/controllers/ApiController.d.ts +1 -1
  62. package/lib/typescript/controllers/BlockchainApiController.d.ts +6 -1
  63. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  64. package/lib/typescript/controllers/ConnectionController.d.ts +5 -1
  65. package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
  66. package/lib/typescript/controllers/NetworkController.d.ts +1 -0
  67. package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
  68. package/lib/typescript/controllers/RouterController.d.ts +3 -4
  69. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  70. package/lib/typescript/controllers/SnackController.d.ts +2 -1
  71. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  72. package/lib/typescript/controllers/SwapController.d.ts +87 -0
  73. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  74. package/lib/typescript/controllers/ThemeController.d.ts +2 -2
  75. package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
  76. package/lib/typescript/index.d.ts +2 -0
  77. package/lib/typescript/index.d.ts.map +1 -1
  78. package/lib/typescript/utils/ConnectionUtil.d.ts +4 -0
  79. package/lib/typescript/utils/ConnectionUtil.d.ts.map +1 -0
  80. package/lib/typescript/utils/ConstantsUtil.d.ts +4 -0
  81. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  82. package/lib/typescript/utils/CoreHelperUtil.d.ts +2 -2
  83. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  84. package/lib/typescript/utils/NetworkUtil.d.ts +8 -0
  85. package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -0
  86. package/lib/typescript/utils/RouterUtil.d.ts.map +1 -1
  87. package/lib/typescript/utils/SwapApiUtil.d.ts +8 -0
  88. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  89. package/lib/typescript/utils/SwapCalculationUtil.d.ts +19 -0
  90. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
  91. package/lib/typescript/utils/TypeUtil.d.ts +162 -8
  92. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  93. package/package.json +2 -2
  94. package/src/controllers/ApiController.ts +1 -1
  95. package/src/controllers/BlockchainApiController.ts +114 -17
  96. package/src/controllers/ConnectionController.ts +12 -3
  97. package/src/controllers/NetworkController.ts +8 -0
  98. package/src/controllers/RouterController.ts +6 -3
  99. package/src/controllers/SnackController.ts +7 -1
  100. package/src/controllers/SwapController.ts +759 -6
  101. package/src/controllers/ThemeController.ts +3 -3
  102. package/src/index.ts +2 -0
  103. package/src/utils/ConnectionUtil.ts +27 -0
  104. package/src/utils/ConstantsUtil.ts +121 -1
  105. package/src/utils/CoreHelperUtil.ts +20 -15
  106. package/src/utils/NetworkUtil.ts +33 -0
  107. package/src/utils/RouterUtil.ts +4 -1
  108. package/src/utils/SwapApiUtil.ts +89 -0
  109. package/src/utils/SwapCalculationUtil.ts +125 -0
  110. package/src/utils/TypeUtil.ts +187 -12
@@ -1,5 +1,10 @@
1
1
  import { type EventEmitter } from 'events';
2
- import type { Balance, SocialProvider, Transaction } from '@reown/appkit-common-react-native';
2
+ import type {
3
+ Balance,
4
+ SocialProvider,
5
+ ThemeMode,
6
+ Transaction
7
+ } from '@reown/appkit-common-react-native';
3
8
 
4
9
  export interface BaseError {
5
10
  message?: string;
@@ -63,7 +68,14 @@ export type SdkVersion =
63
68
  | `react-native-ethers5-${string}`
64
69
  | `react-native-ethers-${string}`;
65
70
 
71
+ type EnabledSocials = Exclude<SocialProvider, 'farcaster'>;
72
+
66
73
  export type Features = {
74
+ /**
75
+ * @description Enable or disable the swaps feature. Enabled by default.
76
+ * @type {boolean}
77
+ */
78
+ swaps?: boolean;
67
79
  /**
68
80
  * @description Enable or disable the email feature. Enabled by default.
69
81
  * @type {boolean}
@@ -76,9 +88,9 @@ export type Features = {
76
88
  emailShowWallets?: boolean;
77
89
  /**
78
90
  * @description Enable or disable the socials feature. Enabled by default.
79
- * @type {FeaturesSocials[]}
91
+ * @type {EnabledSocials[]}
80
92
  */
81
- socials?: SocialProvider[] | false;
93
+ socials?: EnabledSocials[] | false;
82
94
  };
83
95
 
84
96
  // -- ApiController Types -------------------------------------------------------
@@ -133,14 +145,6 @@ export type RequestCache =
133
145
  | 'only-if-cached'
134
146
  | 'reload';
135
147
 
136
- // -- ThemeController Types ---------------------------------------------------
137
-
138
- export type ThemeMode = 'dark' | 'light';
139
-
140
- export interface ThemeVariables {
141
- accent?: string;
142
- }
143
-
144
148
  // -- BlockchainApiController Types ---------------------------------------------
145
149
  export interface BlockchainApiIdentityRequest {
146
150
  address: string;
@@ -169,6 +173,56 @@ export interface BlockchainApiTransactionsResponse {
169
173
  next: string | null;
170
174
  }
171
175
 
176
+ export interface BlockchainApiSwapAllowanceResponse {
177
+ allowance: string;
178
+ }
179
+
180
+ export interface BlockchainApiGenerateSwapCalldataRequest {
181
+ projectId: string;
182
+ userAddress: string;
183
+ from: string;
184
+ to: string;
185
+ amount: string;
186
+ eip155?: {
187
+ slippage: string;
188
+ permit?: string;
189
+ };
190
+ }
191
+
192
+ export interface BlockchainApiGenerateSwapCalldataResponse {
193
+ tx: {
194
+ from: CaipAddress;
195
+ to: CaipAddress;
196
+ data: `0x${string}`;
197
+ amount: string;
198
+ eip155: {
199
+ gas: string;
200
+ gasPrice: string;
201
+ };
202
+ };
203
+ }
204
+
205
+ export interface BlockchainApiGenerateApproveCalldataRequest {
206
+ projectId: string;
207
+ userAddress: string;
208
+ from: string;
209
+ to: string;
210
+ amount?: number;
211
+ }
212
+
213
+ export interface BlockchainApiGenerateApproveCalldataResponse {
214
+ tx: {
215
+ from: CaipAddress;
216
+ to: CaipAddress;
217
+ data: `0x${string}`;
218
+ value: string;
219
+ eip155: {
220
+ gas: number;
221
+ gasPrice: string;
222
+ };
223
+ };
224
+ }
225
+
172
226
  export interface BlockchainApiTokenPriceRequest {
173
227
  projectId: string;
174
228
  currency?: 'usd' | 'eur' | 'gbp' | 'aud' | 'cad' | 'inr' | 'jpy' | 'btc' | 'eth';
@@ -184,6 +238,12 @@ export interface BlockchainApiTokenPriceResponse {
184
238
  }[];
185
239
  }
186
240
 
241
+ export interface BlockchainApiSwapAllowanceRequest {
242
+ projectId: string;
243
+ tokenAddress: string;
244
+ userAddress: string;
245
+ }
246
+
187
247
  export interface BlockchainApiGasPriceRequest {
188
248
  projectId: string;
189
249
  chainId: string;
@@ -219,6 +279,35 @@ export interface BlockchainApiLookupEnsName {
219
279
  }[];
220
280
  }
221
281
 
282
+ export interface BlockchainApiSwapQuoteRequest {
283
+ projectId: string;
284
+ chainId?: string;
285
+ amount: string;
286
+ userAddress: string;
287
+ from: string;
288
+ to: string;
289
+ gasPrice: string;
290
+ }
291
+
292
+ export interface BlockchainApiSwapQuoteResponse {
293
+ quotes: {
294
+ id: string | null;
295
+ fromAmount: string;
296
+ fromAccount: string;
297
+ toAmount: string;
298
+ toAccount: string;
299
+ }[];
300
+ }
301
+
302
+ export interface BlockchainApiSwapTokensRequest {
303
+ projectId: string;
304
+ chainId?: string;
305
+ }
306
+
307
+ export interface BlockchainApiSwapTokensResponse {
308
+ tokens: SwapToken[];
309
+ }
310
+
222
311
  // -- OptionsController Types ---------------------------------------------------
223
312
  export interface Token {
224
313
  address: string;
@@ -441,6 +530,51 @@ export type Event =
441
530
  network: string;
442
531
  };
443
532
  }
533
+ | {
534
+ type: 'track';
535
+ event: 'OPEN_SWAP';
536
+ properties: {
537
+ isSmartAccount: boolean;
538
+ network: string;
539
+ };
540
+ }
541
+ | {
542
+ type: 'track';
543
+ event: 'INITIATE_SWAP';
544
+ properties: {
545
+ isSmartAccount: boolean;
546
+ network: string;
547
+ swapFromToken: string;
548
+ swapToToken: string;
549
+ swapFromAmount: string;
550
+ swapToAmount: string;
551
+ };
552
+ }
553
+ | {
554
+ type: 'track';
555
+ event: 'SWAP_SUCCESS';
556
+ properties: {
557
+ isSmartAccount: boolean;
558
+ network: string;
559
+ swapFromToken: string;
560
+ swapToToken: string;
561
+ swapFromAmount: string;
562
+ swapToAmount: string;
563
+ };
564
+ }
565
+ | {
566
+ type: 'track';
567
+ event: 'SWAP_ERROR';
568
+ properties: {
569
+ isSmartAccount: boolean;
570
+ network: string;
571
+ swapFromToken: string;
572
+ swapToToken: string;
573
+ swapFromAmount: string;
574
+ swapToAmount: string;
575
+ message: string;
576
+ };
577
+ }
444
578
  | {
445
579
  type: 'track';
446
580
  event: 'SEND_INITIATED';
@@ -485,6 +619,20 @@ export type Event =
485
619
  provider: SocialProvider;
486
620
  };
487
621
  }
622
+ | {
623
+ type: 'track';
624
+ event: 'SOCIAL_LOGIN_REQUEST_USER_DATA';
625
+ properties: {
626
+ provider: SocialProvider;
627
+ };
628
+ }
629
+ | {
630
+ type: 'track';
631
+ event: 'SOCIAL_LOGIN_CANCELED';
632
+ properties: {
633
+ provider: SocialProvider;
634
+ };
635
+ }
488
636
  | {
489
637
  type: 'track';
490
638
  event: 'SOCIAL_LOGIN_ERROR';
@@ -502,6 +650,12 @@ export type Event =
502
650
  };
503
651
 
504
652
  // -- Send Controller Types -------------------------------------
653
+ export type EstimateGasTransactionArgs = {
654
+ chainNamespace?: 'eip155';
655
+ address: `0x${string}`;
656
+ to: `0x${string}`;
657
+ data: `0x${string}`;
658
+ };
505
659
 
506
660
  export interface SendTransactionArgs {
507
661
  to: `0x${string}`;
@@ -510,6 +664,7 @@ export interface SendTransactionArgs {
510
664
  gas?: bigint;
511
665
  gasPrice: bigint;
512
666
  address: `0x${string}`;
667
+ chainNamespace?: 'eip155';
513
668
  }
514
669
 
515
670
  export interface WriteContractArgs {
@@ -521,6 +676,27 @@ export interface WriteContractArgs {
521
676
  abi: any;
522
677
  }
523
678
 
679
+ // -- Swap Controller Types -------------------------------------
680
+ export type SwapToken = {
681
+ name: string;
682
+ symbol: string;
683
+ address: CaipAddress;
684
+ decimals: number;
685
+ logoUri: string;
686
+ eip2612?: boolean;
687
+ };
688
+
689
+ export type SwapTokenWithBalance = SwapToken & {
690
+ quantity: {
691
+ decimals: string;
692
+ numeric: string;
693
+ };
694
+ price: number;
695
+ value: number;
696
+ };
697
+
698
+ export type SwapInputTarget = 'sourceToken' | 'toToken';
699
+
524
700
  // -- Email Types ------------------------------------------------
525
701
  /**
526
702
  * Matches type defined for packages/wallet/src/AppKitFrameProvider.ts
@@ -536,7 +712,6 @@ export interface AppKitFrameProvider {
536
712
  getSecureSiteURL(): string;
537
713
  getSecureSiteDashboardURL(): string;
538
714
  getSecureSiteIconURL(): string;
539
- getSecureSiteHeaders(): Record<string, string>;
540
715
  getEmail(): string | undefined;
541
716
  getUsername(): string | undefined;
542
717
  getLastUsedChainId(): Promise<number | undefined>;