@reown/appkit-common-react-native 0.0.0-feat-onramp-20250626195202 → 0.0.0-feat-multi-social-20250630195637

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 (71) hide show
  1. package/lib/commonjs/adapters/BlockchainAdapter.js +79 -0
  2. package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
  3. package/lib/commonjs/adapters/EvmAdapter.js +94 -0
  4. package/lib/commonjs/adapters/EvmAdapter.js.map +1 -0
  5. package/lib/commonjs/adapters/SolanaBaseAdapter.js +12 -0
  6. package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -0
  7. package/lib/commonjs/index.js +62 -1
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/networks/bitcoin.js +40 -0
  10. package/lib/commonjs/networks/bitcoin.js.map +1 -0
  11. package/lib/commonjs/networks/solana.js +78 -0
  12. package/lib/commonjs/networks/solana.js.map +1 -0
  13. package/lib/commonjs/utils/ConstantsUtil.js +2 -1
  14. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  15. package/lib/commonjs/utils/NumberUtil.js +52 -11
  16. package/lib/commonjs/utils/NumberUtil.js.map +1 -1
  17. package/lib/commonjs/utils/PresetsUtil.js +34 -3
  18. package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
  19. package/lib/commonjs/utils/TypeUtil.js +38 -0
  20. package/lib/commonjs/utils/TypeUtil.js.map +1 -1
  21. package/lib/module/adapters/BlockchainAdapter.js +72 -0
  22. package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
  23. package/lib/module/adapters/EvmAdapter.js +87 -0
  24. package/lib/module/adapters/EvmAdapter.js.map +1 -0
  25. package/lib/module/adapters/SolanaBaseAdapter.js +5 -0
  26. package/lib/module/adapters/SolanaBaseAdapter.js.map +1 -0
  27. package/lib/module/index.js +5 -0
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/networks/bitcoin.js +34 -0
  30. package/lib/module/networks/bitcoin.js.map +1 -0
  31. package/lib/module/networks/solana.js +72 -0
  32. package/lib/module/networks/solana.js.map +1 -0
  33. package/lib/module/utils/ConstantsUtil.js +2 -1
  34. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  35. package/lib/module/utils/NumberUtil.js +52 -11
  36. package/lib/module/utils/NumberUtil.js.map +1 -1
  37. package/lib/module/utils/PresetsUtil.js +34 -3
  38. package/lib/module/utils/PresetsUtil.js.map +1 -1
  39. package/lib/module/utils/TypeUtil.js +32 -0
  40. package/lib/module/utils/TypeUtil.js.map +1 -1
  41. package/lib/typescript/adapters/BlockchainAdapter.d.ts +27 -0
  42. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
  43. package/lib/typescript/adapters/EvmAdapter.d.ts +7 -0
  44. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -0
  45. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +4 -0
  46. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -0
  47. package/lib/typescript/index.d.ts +5 -0
  48. package/lib/typescript/index.d.ts.map +1 -1
  49. package/lib/typescript/networks/bitcoin.d.ts +4 -0
  50. package/lib/typescript/networks/bitcoin.d.ts.map +1 -0
  51. package/lib/typescript/networks/solana.d.ts +5 -0
  52. package/lib/typescript/networks/solana.d.ts.map +1 -0
  53. package/lib/typescript/utils/ConstantsUtil.d.ts +1 -0
  54. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  55. package/lib/typescript/utils/NumberUtil.d.ts +39 -11
  56. package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
  57. package/lib/typescript/utils/PresetsUtil.d.ts +1 -1
  58. package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
  59. package/lib/typescript/utils/TypeUtil.d.ts +280 -2
  60. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  61. package/package.json +2 -2
  62. package/src/adapters/BlockchainAdapter.ts +109 -0
  63. package/src/adapters/EvmAdapter.ts +96 -0
  64. package/src/adapters/SolanaBaseAdapter.ts +5 -0
  65. package/src/index.ts +5 -0
  66. package/src/networks/bitcoin.ts +32 -0
  67. package/src/networks/solana.ts +44 -0
  68. package/src/utils/ConstantsUtil.ts +2 -1
  69. package/src/utils/NumberUtil.ts +54 -11
  70. package/src/utils/PresetsUtil.ts +36 -3
  71. package/src/utils/TypeUtil.ts +355 -2
@@ -1,8 +1,56 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ export type CaipAddress = `${string}:${string}:${string}`;
4
+
5
+ export type CaipNetworkId = `${string}:${string}`;
6
+
7
+ export type ChainNamespace = 'eip155' | 'solana' | 'polkadot' | 'bip122';
8
+
9
+ export type Network = {
10
+ // Core viem/chain properties
11
+ id: number | string;
12
+ name: string;
13
+ nativeCurrency: { name: string; symbol: string; decimals: number };
14
+ rpcUrls: {
15
+ default: { http: readonly string[] };
16
+ [key: string]: { http: readonly string[] } | undefined;
17
+ };
18
+ blockExplorers?: {
19
+ default: { name: string; url: string };
20
+ [key: string]: { name: string; url: string } | undefined;
21
+ };
22
+
23
+ // AppKit specific / CAIP properties (Optional in type, but needed in practice)
24
+ chainNamespace?: ChainNamespace; // e.g., 'eip155'
25
+ caipNetworkId?: CaipNetworkId; // e.g., 'eip155:1'
26
+ testnet?: boolean;
27
+ deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
28
+ };
29
+
30
+ export type AppKitNetwork = Network & {
31
+ chainNamespace: ChainNamespace; // e.g., 'eip155'
32
+ caipNetworkId: CaipNetworkId; // e.g., 'eip155:1'
33
+ testnet?: boolean;
34
+ deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
35
+ };
36
+
37
+ export type AppKitConnectOptions = Pick<
38
+ ConnectOptions,
39
+ 'namespaces' | 'defaultChain' | 'universalLink'
40
+ >;
41
+
42
+ export interface CaipNetwork {
43
+ id: CaipNetworkId;
44
+ name?: string;
45
+ imageId?: string;
46
+ imageUrl?: string;
47
+ }
48
+
1
49
  export interface Balance {
2
50
  name: string;
3
51
  symbol: string;
4
52
  chainId: string;
5
- address?: string;
53
+ address?: CaipAddress;
6
54
  value?: number;
7
55
  price: number;
8
56
  quantity: BalanceQuantity;
@@ -86,7 +134,15 @@ export interface TransactionQuantity {
86
134
  numeric: string;
87
135
  }
88
136
 
89
- export type SocialProvider = 'apple' | 'x' | 'discord' | 'farcaster';
137
+ export type SocialProvider =
138
+ | 'google'
139
+ | 'facebook'
140
+ | 'github'
141
+ | 'apple'
142
+ | 'x'
143
+ | 'discord'
144
+ | 'email'
145
+ | 'farcaster';
90
146
 
91
147
  export type ThemeMode = 'dark' | 'light';
92
148
 
@@ -94,4 +150,301 @@ export interface ThemeVariables {
94
150
  accent?: string;
95
151
  }
96
152
 
153
+ export interface Token {
154
+ address: string;
155
+ image?: string;
156
+ }
157
+
158
+ export type Tokens = Record<CaipNetworkId, Token>;
159
+
97
160
  export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
161
+
162
+ export type Metadata = {
163
+ name: string;
164
+ description: string;
165
+ url: string;
166
+ icons: string[];
167
+ redirect?: {
168
+ native?: string;
169
+ universal?: string;
170
+ linkMode?: boolean;
171
+ };
172
+ };
173
+
174
+ //********** Adapter Event Payloads **********//
175
+ export type AccountsChangedEvent = {
176
+ accounts: string[];
177
+ };
178
+
179
+ export type ChainChangedEvent = {
180
+ chainId: string;
181
+ };
182
+
183
+ export type DisconnectEvent = {};
184
+
185
+ export type BalanceChangedEvent = {
186
+ address: CaipAddress;
187
+ balance: {
188
+ amount: string;
189
+ symbol: string;
190
+ contractAddress?: ContractAddress;
191
+ };
192
+ };
193
+
194
+ //********** Adapter Event Map **********//
195
+ export interface AdapterEvents {
196
+ accountsChanged: (event: AccountsChangedEvent) => void;
197
+ chainChanged: (event: ChainChangedEvent) => void;
198
+ disconnect: (event: DisconnectEvent) => void;
199
+ balanceChanged: (event: BalanceChangedEvent) => void;
200
+ }
201
+
202
+ export interface GetBalanceParams {
203
+ address?: CaipAddress;
204
+ network?: AppKitNetwork;
205
+ tokens?: Tokens;
206
+ }
207
+
208
+ type ContractAddress = CaipAddress;
209
+
210
+ export interface GetBalanceResponse {
211
+ amount: string;
212
+ symbol: string;
213
+ contractAddress?: ContractAddress;
214
+ }
215
+
216
+ //********** Connector Types **********//
217
+ interface BaseNamespace {
218
+ chains?: CaipNetworkId[];
219
+ accounts: CaipAddress[];
220
+ methods: string[];
221
+ events: string[];
222
+ }
223
+
224
+ type Namespace = BaseNamespace;
225
+
226
+ export type Namespaces = Record<string, Namespace>;
227
+
228
+ export type ProposalNamespaces = Record<
229
+ string,
230
+ Omit<Namespace, 'accounts'> &
231
+ Required<Pick<Namespace, 'chains'>> & { rpcMap: Record<string, string> }
232
+ >;
233
+
234
+ export type ConnectOptions = {
235
+ namespaces?: ProposalNamespaces;
236
+ defaultChain?: CaipNetworkId;
237
+ universalLink?: string;
238
+ siweConfig?: AppKitSIWEClient;
239
+ };
240
+
241
+ export type ConnectorInitOptions = {
242
+ storage: Storage;
243
+ metadata: Metadata;
244
+ };
245
+
246
+ export abstract class WalletConnector extends EventEmitter {
247
+ public type: New_ConnectorType;
248
+ protected provider?: Provider;
249
+ protected namespaces?: Namespaces;
250
+ protected wallet?: WalletInfo;
251
+ protected storage?: Storage;
252
+ protected metadata?: Metadata;
253
+
254
+ constructor({ type }: { type: New_ConnectorType }) {
255
+ super();
256
+ this.type = type;
257
+ }
258
+
259
+ public async init(ops: ConnectorInitOptions) {
260
+ this.storage = ops.storage;
261
+ this.metadata = ops.metadata;
262
+ }
263
+
264
+ public setProvider(provider: Provider) {
265
+ this.provider = provider;
266
+ }
267
+
268
+ abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
269
+ abstract disconnect(): Promise<void>;
270
+ abstract getProvider(): Provider;
271
+ abstract getNamespaces(): Namespaces;
272
+ abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
273
+ abstract getWalletInfo(): WalletInfo | undefined;
274
+ abstract switchNetwork(network: AppKitNetwork): Promise<void>;
275
+ }
276
+
277
+ //********** Provider Types **********//
278
+
279
+ export interface Provider {
280
+ connect<T>(params?: any): Promise<T>;
281
+ disconnect(): Promise<void>;
282
+ request<T = unknown>(
283
+ args: RequestArguments,
284
+ chain?: string | undefined,
285
+ expiry?: number | undefined
286
+ ): Promise<T>;
287
+ on(event: string, listener: (args?: any) => void): any;
288
+ off(event: string, listener: (args?: any) => void): any;
289
+ }
290
+
291
+ export interface RequestArguments {
292
+ method: string;
293
+ params?: unknown[] | Record<string, unknown> | object | undefined;
294
+ }
295
+
296
+ //TODO: rename this and remove the old one ConnectorType
297
+ export type New_ConnectorType = 'walletconnect' | 'coinbase' | 'auth' | 'phantom';
298
+
299
+ //********** Others **********//
300
+
301
+ export interface ConnectionResponse {
302
+ accounts: string[];
303
+ chainId: string;
304
+ [key: string]: any;
305
+ }
306
+
307
+ export interface WalletInfo {
308
+ name?: string;
309
+ icon?: string;
310
+ description?: string;
311
+ url?: string;
312
+ icons?: string[];
313
+ redirect?: {
314
+ native?: string;
315
+ universal?: string;
316
+ linkMode?: boolean;
317
+ };
318
+ [key: string]: unknown;
319
+ }
320
+
321
+ export interface Storage {
322
+ /**
323
+ * Returns all keys in storage.
324
+ */
325
+ getKeys(): Promise<string[]>;
326
+
327
+ /**
328
+ * Returns all key-value entries in storage.
329
+ */
330
+ getEntries<T = any>(): Promise<[string, T][]>;
331
+
332
+ /**
333
+ * Get an item from storage for a given key.
334
+ * @param key The key to retrieve.
335
+ */
336
+ getItem<T = any>(key: string): Promise<T | undefined>;
337
+
338
+ /**
339
+ * Set an item in storage for a given key.
340
+ * @param key The key to set.
341
+ * @param value The value to set.
342
+ */
343
+ setItem<T = any>(key: string, value: T): Promise<void>;
344
+
345
+ /**
346
+ * Remove an item from storage for a given key.
347
+ * @param key The key to remove.
348
+ */
349
+ removeItem(key: string): Promise<void>;
350
+ }
351
+
352
+ //********** SIWE Types **********//
353
+ export interface SIWESession {
354
+ address: string;
355
+ chainId: number;
356
+ }
357
+
358
+ interface CacaoHeader {
359
+ t: 'caip122';
360
+ }
361
+
362
+ export interface SIWECreateMessageArgs {
363
+ chainId: number;
364
+ domain: string;
365
+ nonce: string;
366
+ uri: string;
367
+ address: string;
368
+ version: '1';
369
+ type?: CacaoHeader['t'];
370
+ nbf?: string;
371
+ exp?: string;
372
+ statement?: string;
373
+ requestId?: string;
374
+ resources?: string[];
375
+ expiry?: number;
376
+ iat?: string;
377
+ }
378
+ export type SIWEMessageArgs = {
379
+ chains: CaipNetworkId[];
380
+ methods?: string[];
381
+ } & Omit<SIWECreateMessageArgs, 'address' | 'chainId' | 'nonce' | 'version'>;
382
+ // Signed Cacao (CAIP-74)
383
+ interface CacaoPayload {
384
+ domain: string;
385
+ aud: string;
386
+ nonce: string;
387
+ iss: string;
388
+ version?: string;
389
+ iat?: string;
390
+ nbf?: string;
391
+ exp?: string;
392
+ statement?: string;
393
+ requestId?: string;
394
+ resources?: string[];
395
+ type?: string;
396
+ }
397
+
398
+ interface Cacao {
399
+ h: CacaoHeader;
400
+ p: CacaoPayload;
401
+ s: {
402
+ t: 'eip191' | 'eip1271';
403
+ s: string;
404
+ m?: string;
405
+ };
406
+ }
407
+
408
+ export interface SIWEVerifyMessageArgs {
409
+ message: string;
410
+ signature: string;
411
+ cacao?: Cacao;
412
+ }
413
+
414
+ export interface SIWEClientMethods {
415
+ getNonce: (address?: string) => Promise<string>;
416
+ createMessage: (args: SIWECreateMessageArgs) => string;
417
+ verifyMessage: (args: SIWEVerifyMessageArgs) => Promise<boolean>;
418
+ getSession: () => Promise<SIWESession | null>;
419
+ signOut: () => Promise<boolean>;
420
+ getMessageParams?: () => Promise<SIWEMessageArgs>;
421
+ onSignIn?: (session?: SIWESession) => void;
422
+ onSignOut?: () => void;
423
+ }
424
+
425
+ export interface SIWEConfig extends SIWEClientMethods {
426
+ // Defaults to true
427
+ enabled?: boolean;
428
+ // In milliseconds, defaults to 5 minutes
429
+ nonceRefetchIntervalMs?: number;
430
+ // In milliseconds, defaults to 5 minutes
431
+ sessionRefetchIntervalMs?: number;
432
+ // Defaults to true
433
+ signOutOnDisconnect?: boolean;
434
+ // Defaults to true
435
+ signOutOnAccountChange?: boolean;
436
+ // Defaults to true
437
+ signOutOnNetworkChange?: boolean;
438
+ }
439
+
440
+ export interface AppKitSIWEClient extends SIWEClientMethods {
441
+ signIn: () => Promise<SIWESession | undefined>;
442
+ options: {
443
+ enabled: boolean;
444
+ nonceRefetchIntervalMs: number;
445
+ sessionRefetchIntervalMs: number;
446
+ signOutOnDisconnect: boolean;
447
+ signOutOnAccountChange: boolean;
448
+ signOutOnNetworkChange: boolean;
449
+ };
450
+ }