@reown/appkit-core-react-native 0.0.0-feat-smart-account-20241017180406 → 0.0.0-feat-swaps-20241129153709

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 (112) hide show
  1. package/lib/commonjs/controllers/ApiController.js +19 -7
  2. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  3. package/lib/commonjs/controllers/BlockchainApiController.js +163 -1
  4. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  5. package/lib/commonjs/controllers/ConnectionController.js +5 -8
  6. package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectorController.js +9 -1
  8. package/lib/commonjs/controllers/ConnectorController.js.map +1 -1
  9. package/lib/commonjs/controllers/NetworkController.js +9 -0
  10. package/lib/commonjs/controllers/NetworkController.js.map +1 -1
  11. package/lib/commonjs/controllers/OptionsController.js +5 -1
  12. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  13. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  14. package/lib/commonjs/controllers/SnackController.js +26 -1
  15. package/lib/commonjs/controllers/SnackController.js.map +1 -1
  16. package/lib/commonjs/controllers/SwapController.js +580 -6
  17. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  18. package/lib/commonjs/controllers/WebviewController.js +13 -1
  19. package/lib/commonjs/controllers/WebviewController.js.map +1 -1
  20. package/lib/commonjs/utils/ApiUtil.js +9 -2
  21. package/lib/commonjs/utils/ApiUtil.js.map +1 -1
  22. package/lib/commonjs/utils/ConstantsUtil.js +30 -1
  23. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  24. package/lib/commonjs/utils/CoreHelperUtil.js +0 -12
  25. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  26. package/lib/commonjs/utils/StorageUtil.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 +19 -7
  32. package/lib/module/controllers/ApiController.js.map +1 -1
  33. package/lib/module/controllers/BlockchainApiController.js +163 -1
  34. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  35. package/lib/module/controllers/ConnectionController.js +5 -8
  36. package/lib/module/controllers/ConnectionController.js.map +1 -1
  37. package/lib/module/controllers/ConnectorController.js +9 -1
  38. package/lib/module/controllers/ConnectorController.js.map +1 -1
  39. package/lib/module/controllers/NetworkController.js +9 -0
  40. package/lib/module/controllers/NetworkController.js.map +1 -1
  41. package/lib/module/controllers/OptionsController.js +5 -1
  42. package/lib/module/controllers/OptionsController.js.map +1 -1
  43. package/lib/module/controllers/RouterController.js.map +1 -1
  44. package/lib/module/controllers/SnackController.js +26 -1
  45. package/lib/module/controllers/SnackController.js.map +1 -1
  46. package/lib/module/controllers/SwapController.js +579 -6
  47. package/lib/module/controllers/SwapController.js.map +1 -1
  48. package/lib/module/controllers/WebviewController.js +13 -1
  49. package/lib/module/controllers/WebviewController.js.map +1 -1
  50. package/lib/module/utils/ApiUtil.js +9 -2
  51. package/lib/module/utils/ApiUtil.js.map +1 -1
  52. package/lib/module/utils/ConstantsUtil.js +30 -1
  53. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  54. package/lib/module/utils/CoreHelperUtil.js +0 -12
  55. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  56. package/lib/module/utils/StorageUtil.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 +3 -1
  62. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  63. package/lib/typescript/controllers/BlockchainApiController.d.ts +6 -1
  64. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  65. package/lib/typescript/controllers/ConnectionController.d.ts +3 -1
  66. package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
  67. package/lib/typescript/controllers/ConnectorController.d.ts +1 -1
  68. package/lib/typescript/controllers/ConnectorController.d.ts.map +1 -1
  69. package/lib/typescript/controllers/NetworkController.d.ts +2 -0
  70. package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
  71. package/lib/typescript/controllers/OptionsController.d.ts +2 -0
  72. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  73. package/lib/typescript/controllers/RouterController.d.ts +3 -2
  74. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  75. package/lib/typescript/controllers/SnackController.d.ts +9 -1
  76. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  77. package/lib/typescript/controllers/SwapController.d.ts +87 -0
  78. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  79. package/lib/typescript/controllers/WebviewController.d.ts +3 -0
  80. package/lib/typescript/controllers/WebviewController.d.ts.map +1 -1
  81. package/lib/typescript/utils/ApiUtil.d.ts +1 -0
  82. package/lib/typescript/utils/ApiUtil.d.ts.map +1 -1
  83. package/lib/typescript/utils/ConstantsUtil.d.ts +4 -0
  84. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  85. package/lib/typescript/utils/CoreHelperUtil.d.ts +0 -1
  86. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  87. package/lib/typescript/utils/StorageUtil.d.ts +1 -1
  88. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  89. package/lib/typescript/utils/SwapApiUtil.d.ts +8 -0
  90. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  91. package/lib/typescript/utils/SwapCalculationUtil.d.ts +19 -0
  92. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
  93. package/lib/typescript/utils/TypeUtil.d.ts +151 -5
  94. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  95. package/package.json +2 -2
  96. package/src/controllers/ApiController.ts +32 -17
  97. package/src/controllers/BlockchainApiController.ts +153 -1
  98. package/src/controllers/ConnectionController.ts +7 -8
  99. package/src/controllers/ConnectorController.ts +13 -1
  100. package/src/controllers/NetworkController.ts +15 -0
  101. package/src/controllers/OptionsController.ts +7 -1
  102. package/src/controllers/RouterController.ts +6 -1
  103. package/src/controllers/SnackController.ts +35 -2
  104. package/src/controllers/SwapController.ts +750 -6
  105. package/src/controllers/WebviewController.ts +16 -1
  106. package/src/utils/ApiUtil.ts +14 -6
  107. package/src/utils/ConstantsUtil.ts +121 -1
  108. package/src/utils/CoreHelperUtil.ts +0 -14
  109. package/src/utils/StorageUtil.ts +1 -1
  110. package/src/utils/SwapApiUtil.ts +89 -0
  111. package/src/utils/SwapCalculationUtil.ts +125 -0
  112. package/src/utils/TypeUtil.ts +171 -10
@@ -64,6 +64,11 @@ export type SdkVersion =
64
64
  | `react-native-ethers-${string}`;
65
65
 
66
66
  export type Features = {
67
+ /**
68
+ * @description Enable or disable the swaps feature. Enabled by default.
69
+ * @type {boolean}
70
+ */
71
+ swaps?: boolean;
67
72
  /**
68
73
  * @description Enable or disable the email feature. Enabled by default.
69
74
  * @type {boolean}
@@ -169,6 +174,56 @@ export interface BlockchainApiTransactionsResponse {
169
174
  next: string | null;
170
175
  }
171
176
 
177
+ export interface BlockchainApiSwapAllowanceResponse {
178
+ allowance: string;
179
+ }
180
+
181
+ export interface BlockchainApiGenerateSwapCalldataRequest {
182
+ projectId: string;
183
+ userAddress: string;
184
+ from: string;
185
+ to: string;
186
+ amount: string;
187
+ eip155?: {
188
+ slippage: string;
189
+ permit?: string;
190
+ };
191
+ }
192
+
193
+ export interface BlockchainApiGenerateSwapCalldataResponse {
194
+ tx: {
195
+ from: CaipAddress;
196
+ to: CaipAddress;
197
+ data: `0x${string}`;
198
+ amount: string;
199
+ eip155: {
200
+ gas: string;
201
+ gasPrice: string;
202
+ };
203
+ };
204
+ }
205
+
206
+ export interface BlockchainApiGenerateApproveCalldataRequest {
207
+ projectId: string;
208
+ userAddress: string;
209
+ from: string;
210
+ to: string;
211
+ amount?: number;
212
+ }
213
+
214
+ export interface BlockchainApiGenerateApproveCalldataResponse {
215
+ tx: {
216
+ from: CaipAddress;
217
+ to: CaipAddress;
218
+ data: `0x${string}`;
219
+ value: string;
220
+ eip155: {
221
+ gas: number;
222
+ gasPrice: string;
223
+ };
224
+ };
225
+ }
226
+
172
227
  export interface BlockchainApiTokenPriceRequest {
173
228
  projectId: string;
174
229
  currency?: 'usd' | 'eur' | 'gbp' | 'aud' | 'cad' | 'inr' | 'jpy' | 'btc' | 'eth';
@@ -184,6 +239,12 @@ export interface BlockchainApiTokenPriceResponse {
184
239
  }[];
185
240
  }
186
241
 
242
+ export interface BlockchainApiSwapAllowanceRequest {
243
+ projectId: string;
244
+ tokenAddress: string;
245
+ userAddress: string;
246
+ }
247
+
187
248
  export interface BlockchainApiGasPriceRequest {
188
249
  projectId: string;
189
250
  chainId: string;
@@ -219,6 +280,35 @@ export interface BlockchainApiLookupEnsName {
219
280
  }[];
220
281
  }
221
282
 
283
+ export interface BlockchainApiSwapQuoteRequest {
284
+ projectId: string;
285
+ chainId?: string;
286
+ amount: string;
287
+ userAddress: string;
288
+ from: string;
289
+ to: string;
290
+ gasPrice: string;
291
+ }
292
+
293
+ export interface BlockchainApiSwapQuoteResponse {
294
+ quotes: {
295
+ id: string | null;
296
+ fromAmount: string;
297
+ fromAccount: string;
298
+ toAmount: string;
299
+ toAccount: string;
300
+ }[];
301
+ }
302
+
303
+ export interface BlockchainApiSwapTokensRequest {
304
+ projectId: string;
305
+ chainId?: string;
306
+ }
307
+
308
+ export interface BlockchainApiSwapTokensResponse {
309
+ tokens: SwapToken[];
310
+ }
311
+
222
312
  // -- OptionsController Types ---------------------------------------------------
223
313
  export interface Token {
224
314
  address: string;
@@ -441,6 +531,50 @@ export type Event =
441
531
  network: string;
442
532
  };
443
533
  }
534
+ | {
535
+ type: 'track';
536
+ event: 'OPEN_SWAP';
537
+ properties: {
538
+ isSmartAccount: boolean;
539
+ network: string;
540
+ };
541
+ }
542
+ | {
543
+ type: 'track';
544
+ event: 'INITIATE_SWAP';
545
+ properties: {
546
+ isSmartAccount: boolean;
547
+ network: string;
548
+ swapFromToken: string;
549
+ swapToToken: string;
550
+ swapFromAmount: string;
551
+ swapToAmount: string;
552
+ };
553
+ }
554
+ | {
555
+ type: 'track';
556
+ event: 'SWAP_SUCCESS';
557
+ properties: {
558
+ isSmartAccount: boolean;
559
+ network: string;
560
+ swapFromToken: string;
561
+ swapToToken: string;
562
+ swapFromAmount: string;
563
+ swapToAmount: string;
564
+ };
565
+ }
566
+ | {
567
+ type: 'track';
568
+ event: 'SWAP_ERROR';
569
+ properties: {
570
+ isSmartAccount: boolean;
571
+ network: string;
572
+ swapFromToken: string;
573
+ swapToToken: string;
574
+ swapFromAmount: string;
575
+ swapToAmount: string;
576
+ };
577
+ }
444
578
  | {
445
579
  type: 'track';
446
580
  event: 'SEND_INITIATED';
@@ -502,6 +636,12 @@ export type Event =
502
636
  };
503
637
 
504
638
  // -- Send Controller Types -------------------------------------
639
+ export type EstimateGasTransactionArgs = {
640
+ chainNamespace?: undefined | 'eip155';
641
+ address: `0x${string}`;
642
+ to: `0x${string}`;
643
+ data: `0x${string}`;
644
+ };
505
645
 
506
646
  export interface SendTransactionArgs {
507
647
  to: `0x${string}`;
@@ -510,6 +650,7 @@ export interface SendTransactionArgs {
510
650
  gas?: bigint;
511
651
  gasPrice: bigint;
512
652
  address: `0x${string}`;
653
+ chainNamespace?: 'eip155';
513
654
  }
514
655
 
515
656
  export interface WriteContractArgs {
@@ -521,6 +662,27 @@ export interface WriteContractArgs {
521
662
  abi: any;
522
663
  }
523
664
 
665
+ // -- Swap Controller Types -------------------------------------
666
+ export type SwapToken = {
667
+ name: string;
668
+ symbol: string;
669
+ address: CaipAddress;
670
+ decimals: number;
671
+ logoUri: string;
672
+ eip2612?: boolean;
673
+ };
674
+
675
+ export type SwapTokenWithBalance = SwapToken & {
676
+ quantity: {
677
+ decimals: string;
678
+ numeric: string;
679
+ };
680
+ price: number;
681
+ value: number;
682
+ };
683
+
684
+ export type SwapInputTarget = 'sourceToken' | 'toToken';
685
+
524
686
  // -- Email Types ------------------------------------------------
525
687
  /**
526
688
  * Matches type defined for packages/wallet/src/AppKitFrameProvider.ts
@@ -549,13 +711,11 @@ export interface AppKitFrameProvider {
549
711
  chainId: string | number;
550
712
  email: string;
551
713
  address: string;
552
- accounts?:
553
- | {
554
- type: AppKitFrameAccountType;
555
- address: string;
556
- }[]
557
- | undefined;
558
- userName?: string | undefined;
714
+ accounts?: {
715
+ type: AppKitFrameAccountType;
716
+ address: string;
717
+ }[];
718
+ userName?: string;
559
719
  }>;
560
720
  getSocialRedirectUri(payload: { provider: SocialProvider }): Promise<{
561
721
  uri: string;
@@ -588,7 +748,7 @@ export interface AppKitFrameProvider {
588
748
  }): Promise<unknown>;
589
749
  connect(payload?: { chainId: number | undefined }): Promise<{
590
750
  chainId: number;
591
- email?: string | null | undefined;
751
+ email?: string | null;
592
752
  address: string;
593
753
  smartAccountDeployed: boolean;
594
754
  preferredAccountType: AppKitFrameAccountType;
@@ -600,13 +760,14 @@ export interface AppKitFrameProvider {
600
760
  type: AppKitFrameAccountType;
601
761
  address: string;
602
762
  }>;
763
+ setOnTimeout(callback: () => void): void;
603
764
  getSmartAccountEnabledNetworks(): Promise<{
604
765
  smartAccountEnabledNetworks: number[];
605
766
  }>;
606
767
  disconnect(): Promise<unknown>;
607
768
  request(req: any): Promise<any>;
608
- AuthView: () => JSX.Element | null;
609
- Webview: () => JSX.Element | null;
769
+ AuthView: () => React.JSX.Element | null;
770
+ Webview: () => React.JSX.Element | null;
610
771
  onSetPreferredAccount: (
611
772
  callback: (values: { type: AppKitFrameAccountType; address: string }) => void
612
773
  ) => void;