@reown/appkit-core-react-native 1.1.1 → 1.2.0
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 +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +107 -21
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionController.js +4 -2
- package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
- package/lib/commonjs/controllers/NetworkController.js +6 -0
- package/lib/commonjs/controllers/NetworkController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SnackController.js +5 -0
- package/lib/commonjs/controllers/SnackController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +578 -6
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js +1 -1
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ConnectionUtil.js +33 -0
- package/lib/commonjs/utils/ConnectionUtil.js.map +1 -0
- package/lib/commonjs/utils/ConstantsUtil.js +29 -0
- 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/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 +1 -1
- package/lib/module/controllers/BlockchainApiController.js +107 -21
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionController.js +4 -2
- package/lib/module/controllers/ConnectionController.js.map +1 -1
- package/lib/module/controllers/NetworkController.js +6 -0
- package/lib/module/controllers/NetworkController.js.map +1 -1
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SnackController.js +5 -0
- package/lib/module/controllers/SnackController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +578 -6
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +1 -1
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ConnectionUtil.js +27 -0
- package/lib/module/utils/ConnectionUtil.js.map +1 -0
- package/lib/module/utils/ConstantsUtil.js +29 -0
- 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/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 +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/NetworkController.d.ts +1 -0
- package/lib/typescript/controllers/NetworkController.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 +2 -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/ThemeController.d.ts +2 -2
- package/lib/typescript/controllers/ThemeController.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/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/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 +146 -6
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/controllers/ApiController.ts +1 -1
- package/src/controllers/BlockchainApiController.ts +114 -17
- package/src/controllers/ConnectionController.ts +6 -2
- package/src/controllers/NetworkController.ts +8 -0
- package/src/controllers/RouterController.ts +6 -1
- package/src/controllers/SnackController.ts +7 -1
- package/src/controllers/SwapController.ts +759 -6
- package/src/controllers/ThemeController.ts +3 -3
- package/src/index.ts +2 -0
- package/src/utils/ConnectionUtil.ts +27 -0
- package/src/utils/ConstantsUtil.ts +120 -0
- package/src/utils/CoreHelperUtil.ts +20 -15
- package/src/utils/NetworkUtil.ts +33 -0
- package/src/utils/RouterUtil.ts +4 -1
- package/src/utils/SwapApiUtil.ts +89 -0
- package/src/utils/SwapCalculationUtil.ts +125 -0
- package/src/utils/TypeUtil.ts +169 -10
package/src/utils/TypeUtil.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type EventEmitter } from 'events';
|
|
2
|
-
import type {
|
|
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;
|
|
@@ -66,6 +71,11 @@ export type SdkVersion =
|
|
|
66
71
|
type EnabledSocials = Exclude<SocialProvider, 'farcaster'>;
|
|
67
72
|
|
|
68
73
|
export type Features = {
|
|
74
|
+
/**
|
|
75
|
+
* @description Enable or disable the swaps feature. Enabled by default.
|
|
76
|
+
* @type {boolean}
|
|
77
|
+
*/
|
|
78
|
+
swaps?: boolean;
|
|
69
79
|
/**
|
|
70
80
|
* @description Enable or disable the email feature. Enabled by default.
|
|
71
81
|
* @type {boolean}
|
|
@@ -135,14 +145,6 @@ export type RequestCache =
|
|
|
135
145
|
| 'only-if-cached'
|
|
136
146
|
| 'reload';
|
|
137
147
|
|
|
138
|
-
// -- ThemeController Types ---------------------------------------------------
|
|
139
|
-
|
|
140
|
-
export type ThemeMode = 'dark' | 'light';
|
|
141
|
-
|
|
142
|
-
export interface ThemeVariables {
|
|
143
|
-
accent?: string;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
148
|
// -- BlockchainApiController Types ---------------------------------------------
|
|
147
149
|
export interface BlockchainApiIdentityRequest {
|
|
148
150
|
address: string;
|
|
@@ -171,6 +173,56 @@ export interface BlockchainApiTransactionsResponse {
|
|
|
171
173
|
next: string | null;
|
|
172
174
|
}
|
|
173
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
|
+
|
|
174
226
|
export interface BlockchainApiTokenPriceRequest {
|
|
175
227
|
projectId: string;
|
|
176
228
|
currency?: 'usd' | 'eur' | 'gbp' | 'aud' | 'cad' | 'inr' | 'jpy' | 'btc' | 'eth';
|
|
@@ -186,6 +238,12 @@ export interface BlockchainApiTokenPriceResponse {
|
|
|
186
238
|
}[];
|
|
187
239
|
}
|
|
188
240
|
|
|
241
|
+
export interface BlockchainApiSwapAllowanceRequest {
|
|
242
|
+
projectId: string;
|
|
243
|
+
tokenAddress: string;
|
|
244
|
+
userAddress: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
189
247
|
export interface BlockchainApiGasPriceRequest {
|
|
190
248
|
projectId: string;
|
|
191
249
|
chainId: string;
|
|
@@ -221,6 +279,35 @@ export interface BlockchainApiLookupEnsName {
|
|
|
221
279
|
}[];
|
|
222
280
|
}
|
|
223
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
|
+
|
|
224
311
|
// -- OptionsController Types ---------------------------------------------------
|
|
225
312
|
export interface Token {
|
|
226
313
|
address: string;
|
|
@@ -443,6 +530,51 @@ export type Event =
|
|
|
443
530
|
network: string;
|
|
444
531
|
};
|
|
445
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
|
+
}
|
|
446
578
|
| {
|
|
447
579
|
type: 'track';
|
|
448
580
|
event: 'SEND_INITIATED';
|
|
@@ -518,6 +650,12 @@ export type Event =
|
|
|
518
650
|
};
|
|
519
651
|
|
|
520
652
|
// -- Send Controller Types -------------------------------------
|
|
653
|
+
export type EstimateGasTransactionArgs = {
|
|
654
|
+
chainNamespace?: 'eip155';
|
|
655
|
+
address: `0x${string}`;
|
|
656
|
+
to: `0x${string}`;
|
|
657
|
+
data: `0x${string}`;
|
|
658
|
+
};
|
|
521
659
|
|
|
522
660
|
export interface SendTransactionArgs {
|
|
523
661
|
to: `0x${string}`;
|
|
@@ -526,6 +664,7 @@ export interface SendTransactionArgs {
|
|
|
526
664
|
gas?: bigint;
|
|
527
665
|
gasPrice: bigint;
|
|
528
666
|
address: `0x${string}`;
|
|
667
|
+
chainNamespace?: 'eip155';
|
|
529
668
|
}
|
|
530
669
|
|
|
531
670
|
export interface WriteContractArgs {
|
|
@@ -537,6 +676,27 @@ export interface WriteContractArgs {
|
|
|
537
676
|
abi: any;
|
|
538
677
|
}
|
|
539
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
|
+
|
|
540
700
|
// -- Email Types ------------------------------------------------
|
|
541
701
|
/**
|
|
542
702
|
* Matches type defined for packages/wallet/src/AppKitFrameProvider.ts
|
|
@@ -552,7 +712,6 @@ export interface AppKitFrameProvider {
|
|
|
552
712
|
getSecureSiteURL(): string;
|
|
553
713
|
getSecureSiteDashboardURL(): string;
|
|
554
714
|
getSecureSiteIconURL(): string;
|
|
555
|
-
getSecureSiteHeaders(): Record<string, string>;
|
|
556
715
|
getEmail(): string | undefined;
|
|
557
716
|
getUsername(): string | undefined;
|
|
558
717
|
getLastUsedChainId(): Promise<number | undefined>;
|