@reown/appkit-core-react-native 0.0.0-feat-smart-account-20241017180406 → 0.0.0-feat-swaps-20241203153101
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 +6 -10
- 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 +576 -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/index.js +14 -0
- package/lib/commonjs/index.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/ConnectionUtil.js +34 -0
- package/lib/commonjs/utils/ConnectionUtil.js.map +1 -0
- package/lib/commonjs/utils/ConstantsUtil.js +30 -1
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +12 -12
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/NetworkUtil.js +46 -0
- package/lib/commonjs/utils/NetworkUtil.js.map +1 -0
- package/lib/commonjs/utils/RouterUtil.js +1 -1
- package/lib/commonjs/utils/RouterUtil.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 +6 -10
- 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 +576 -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/index.js +2 -0
- package/lib/module/index.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/ConnectionUtil.js +28 -0
- package/lib/module/utils/ConnectionUtil.js.map +1 -0
- package/lib/module/utils/ConstantsUtil.js +30 -1
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +12 -12
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/NetworkUtil.js +40 -0
- package/lib/module/utils/NetworkUtil.js.map +1 -0
- package/lib/module/utils/RouterUtil.js +1 -1
- package/lib/module/utils/RouterUtil.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/index.d.ts +2 -0
- package/lib/typescript/index.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/ConnectionUtil.d.ts +4 -0
- package/lib/typescript/utils/ConnectionUtil.d.ts.map +1 -0
- 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 +2 -2
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/NetworkUtil.d.ts +8 -0
- package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -0
- package/lib/typescript/utils/RouterUtil.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 +152 -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 +8 -10
- 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 +753 -6
- package/src/controllers/WebviewController.ts +16 -1
- package/src/index.ts +2 -0
- package/src/utils/ApiUtil.ts +14 -6
- package/src/utils/ConnectionUtil.ts +28 -0
- package/src/utils/ConstantsUtil.ts +121 -1
- package/src/utils/CoreHelperUtil.ts +20 -15
- package/src/utils/NetworkUtil.ts +33 -0
- package/src/utils/RouterUtil.ts +4 -1
- 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 +172 -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,51 @@ 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
|
+
message: string;
|
|
577
|
+
};
|
|
578
|
+
}
|
|
444
579
|
| {
|
|
445
580
|
type: 'track';
|
|
446
581
|
event: 'SEND_INITIATED';
|
|
@@ -502,6 +637,12 @@ export type Event =
|
|
|
502
637
|
};
|
|
503
638
|
|
|
504
639
|
// -- Send Controller Types -------------------------------------
|
|
640
|
+
export type EstimateGasTransactionArgs = {
|
|
641
|
+
chainNamespace?: undefined | 'eip155';
|
|
642
|
+
address: `0x${string}`;
|
|
643
|
+
to: `0x${string}`;
|
|
644
|
+
data: `0x${string}`;
|
|
645
|
+
};
|
|
505
646
|
|
|
506
647
|
export interface SendTransactionArgs {
|
|
507
648
|
to: `0x${string}`;
|
|
@@ -510,6 +651,7 @@ export interface SendTransactionArgs {
|
|
|
510
651
|
gas?: bigint;
|
|
511
652
|
gasPrice: bigint;
|
|
512
653
|
address: `0x${string}`;
|
|
654
|
+
chainNamespace?: 'eip155';
|
|
513
655
|
}
|
|
514
656
|
|
|
515
657
|
export interface WriteContractArgs {
|
|
@@ -521,6 +663,27 @@ export interface WriteContractArgs {
|
|
|
521
663
|
abi: any;
|
|
522
664
|
}
|
|
523
665
|
|
|
666
|
+
// -- Swap Controller Types -------------------------------------
|
|
667
|
+
export type SwapToken = {
|
|
668
|
+
name: string;
|
|
669
|
+
symbol: string;
|
|
670
|
+
address: CaipAddress;
|
|
671
|
+
decimals: number;
|
|
672
|
+
logoUri: string;
|
|
673
|
+
eip2612?: boolean;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
export type SwapTokenWithBalance = SwapToken & {
|
|
677
|
+
quantity: {
|
|
678
|
+
decimals: string;
|
|
679
|
+
numeric: string;
|
|
680
|
+
};
|
|
681
|
+
price: number;
|
|
682
|
+
value: number;
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
export type SwapInputTarget = 'sourceToken' | 'toToken';
|
|
686
|
+
|
|
524
687
|
// -- Email Types ------------------------------------------------
|
|
525
688
|
/**
|
|
526
689
|
* Matches type defined for packages/wallet/src/AppKitFrameProvider.ts
|
|
@@ -549,13 +712,11 @@ export interface AppKitFrameProvider {
|
|
|
549
712
|
chainId: string | number;
|
|
550
713
|
email: string;
|
|
551
714
|
address: string;
|
|
552
|
-
accounts?:
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
| undefined;
|
|
558
|
-
userName?: string | undefined;
|
|
715
|
+
accounts?: {
|
|
716
|
+
type: AppKitFrameAccountType;
|
|
717
|
+
address: string;
|
|
718
|
+
}[];
|
|
719
|
+
userName?: string;
|
|
559
720
|
}>;
|
|
560
721
|
getSocialRedirectUri(payload: { provider: SocialProvider }): Promise<{
|
|
561
722
|
uri: string;
|
|
@@ -588,7 +749,7 @@ export interface AppKitFrameProvider {
|
|
|
588
749
|
}): Promise<unknown>;
|
|
589
750
|
connect(payload?: { chainId: number | undefined }): Promise<{
|
|
590
751
|
chainId: number;
|
|
591
|
-
email?: string | null
|
|
752
|
+
email?: string | null;
|
|
592
753
|
address: string;
|
|
593
754
|
smartAccountDeployed: boolean;
|
|
594
755
|
preferredAccountType: AppKitFrameAccountType;
|
|
@@ -600,13 +761,14 @@ export interface AppKitFrameProvider {
|
|
|
600
761
|
type: AppKitFrameAccountType;
|
|
601
762
|
address: string;
|
|
602
763
|
}>;
|
|
764
|
+
setOnTimeout(callback: () => void): void;
|
|
603
765
|
getSmartAccountEnabledNetworks(): Promise<{
|
|
604
766
|
smartAccountEnabledNetworks: number[];
|
|
605
767
|
}>;
|
|
606
768
|
disconnect(): Promise<unknown>;
|
|
607
769
|
request(req: any): Promise<any>;
|
|
608
|
-
AuthView: () => JSX.Element | null;
|
|
609
|
-
Webview: () => JSX.Element | null;
|
|
770
|
+
AuthView: () => React.JSX.Element | null;
|
|
771
|
+
Webview: () => React.JSX.Element | null;
|
|
610
772
|
onSetPreferredAccount: (
|
|
611
773
|
callback: (values: { type: AppKitFrameAccountType; address: string }) => void
|
|
612
774
|
) => void;
|