@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.
- package/lib/commonjs/controllers/ApiController.js +19 -7
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +163 -1
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionController.js +5 -8
- package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectorController.js +9 -1
- package/lib/commonjs/controllers/ConnectorController.js.map +1 -1
- package/lib/commonjs/controllers/NetworkController.js +9 -0
- package/lib/commonjs/controllers/NetworkController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +5 -1
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SnackController.js +26 -1
- package/lib/commonjs/controllers/SnackController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +580 -6
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/WebviewController.js +13 -1
- package/lib/commonjs/controllers/WebviewController.js.map +1 -1
- package/lib/commonjs/utils/ApiUtil.js +9 -2
- package/lib/commonjs/utils/ApiUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +30 -1
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +0 -12
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js +58 -0
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapCalculationUtil.js +73 -0
- package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/module/controllers/ApiController.js +19 -7
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/BlockchainApiController.js +163 -1
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionController.js +5 -8
- package/lib/module/controllers/ConnectionController.js.map +1 -1
- package/lib/module/controllers/ConnectorController.js +9 -1
- package/lib/module/controllers/ConnectorController.js.map +1 -1
- package/lib/module/controllers/NetworkController.js +9 -0
- package/lib/module/controllers/NetworkController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +5 -1
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SnackController.js +26 -1
- package/lib/module/controllers/SnackController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +579 -6
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/WebviewController.js +13 -1
- package/lib/module/controllers/WebviewController.js.map +1 -1
- package/lib/module/utils/ApiUtil.js +9 -2
- package/lib/module/utils/ApiUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +30 -1
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +0 -12
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js +58 -0
- package/lib/module/utils/SwapApiUtil.js.map +1 -1
- package/lib/module/utils/SwapCalculationUtil.js +73 -1
- package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/typescript/controllers/ApiController.d.ts +3 -1
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts +6 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionController.d.ts +3 -1
- package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectorController.d.ts +1 -1
- package/lib/typescript/controllers/ConnectorController.d.ts.map +1 -1
- package/lib/typescript/controllers/NetworkController.d.ts +2 -0
- package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +2 -0
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +3 -2
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- package/lib/typescript/controllers/SnackController.d.ts +9 -1
- package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
- package/lib/typescript/controllers/SwapController.d.ts +87 -0
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
- package/lib/typescript/controllers/WebviewController.d.ts +3 -0
- package/lib/typescript/controllers/WebviewController.d.ts.map +1 -1
- package/lib/typescript/utils/ApiUtil.d.ts +1 -0
- package/lib/typescript/utils/ApiUtil.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +4 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +0 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapApiUtil.d.ts +8 -0
- package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapCalculationUtil.d.ts +19 -0
- package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +151 -5
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/controllers/ApiController.ts +32 -17
- package/src/controllers/BlockchainApiController.ts +153 -1
- package/src/controllers/ConnectionController.ts +7 -8
- package/src/controllers/ConnectorController.ts +13 -1
- package/src/controllers/NetworkController.ts +15 -0
- package/src/controllers/OptionsController.ts +7 -1
- package/src/controllers/RouterController.ts +6 -1
- package/src/controllers/SnackController.ts +35 -2
- package/src/controllers/SwapController.ts +750 -6
- package/src/controllers/WebviewController.ts +16 -1
- package/src/utils/ApiUtil.ts +14 -6
- package/src/utils/ConstantsUtil.ts +121 -1
- package/src/utils/CoreHelperUtil.ts +0 -14
- package/src/utils/StorageUtil.ts +1 -1
- package/src/utils/SwapApiUtil.ts +89 -0
- package/src/utils/SwapCalculationUtil.ts +125 -0
- package/src/utils/TypeUtil.ts +171 -10
package/src/utils/TypeUtil.ts
CHANGED
|
@@ -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
|
-
|
|
555
|
-
|
|
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
|
|
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;
|