@reown/appkit-common-react-native 0.0.0-feat-onramp-20250718200617 → 0.0.0-feat-coinbase-20250722174423

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 (74) hide show
  1. package/lib/commonjs/adapters/BlockchainAdapter.js +81 -0
  2. package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
  3. package/lib/commonjs/adapters/EvmAdapter.js +208 -0
  4. package/lib/commonjs/adapters/EvmAdapter.js.map +1 -0
  5. package/lib/commonjs/adapters/SolanaBaseAdapter.js +10 -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 +11 -2
  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 -8
  18. package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
  19. package/lib/commonjs/utils/TypeUtil.js +42 -0
  20. package/lib/commonjs/utils/TypeUtil.js.map +1 -1
  21. package/lib/module/adapters/BlockchainAdapter.js +74 -0
  22. package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
  23. package/lib/module/adapters/EvmAdapter.js +202 -0
  24. package/lib/module/adapters/EvmAdapter.js.map +1 -0
  25. package/lib/module/adapters/SolanaBaseAdapter.js +3 -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 +11 -2
  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 -8
  38. package/lib/module/utils/PresetsUtil.js.map +1 -1
  39. package/lib/module/utils/TypeUtil.js +36 -0
  40. package/lib/module/utils/TypeUtil.js.map +1 -1
  41. package/lib/typescript/adapters/BlockchainAdapter.d.ts +25 -0
  42. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
  43. package/lib/typescript/adapters/EvmAdapter.d.ts +27 -0
  44. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -0
  45. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +6 -0
  46. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -0
  47. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts +2 -0
  48. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts.map +1 -0
  49. package/lib/typescript/index.d.ts +5 -0
  50. package/lib/typescript/index.d.ts.map +1 -1
  51. package/lib/typescript/networks/bitcoin.d.ts +4 -0
  52. package/lib/typescript/networks/bitcoin.d.ts.map +1 -0
  53. package/lib/typescript/networks/solana.d.ts +5 -0
  54. package/lib/typescript/networks/solana.d.ts.map +1 -0
  55. package/lib/typescript/utils/ConstantsUtil.d.ts +9 -0
  56. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  57. package/lib/typescript/utils/NumberUtil.d.ts +39 -11
  58. package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
  59. package/lib/typescript/utils/PresetsUtil.d.ts +1 -3
  60. package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
  61. package/lib/typescript/utils/TypeUtil.d.ts +296 -12
  62. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  63. package/package.json +2 -2
  64. package/src/adapters/BlockchainAdapter.ts +107 -0
  65. package/src/adapters/EvmAdapter.ts +260 -0
  66. package/src/adapters/SolanaBaseAdapter.ts +6 -0
  67. package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
  68. package/src/index.ts +5 -0
  69. package/src/networks/bitcoin.ts +32 -0
  70. package/src/networks/solana.ts +44 -0
  71. package/src/utils/ConstantsUtil.ts +12 -2
  72. package/src/utils/NumberUtil.ts +54 -11
  73. package/src/utils/PresetsUtil.ts +36 -10
  74. package/src/utils/TypeUtil.ts +379 -14
@@ -1,4 +1,3 @@
1
- import type { ConnectorType } from './TypeUtil';
2
1
  import { ConstantsUtil } from './ConstantsUtil';
3
2
 
4
3
  export const PresetsUtil = {
@@ -7,11 +6,11 @@ export const PresetsUtil = {
7
6
  'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
8
7
  } as Record<string, string>,
9
8
 
10
- EIP155NetworkImageIds: {
9
+ NetworkImageIds: {
11
10
  // Ethereum
12
11
  1: 'ba0ba0cd-17c6-4806-ad93-f9d174f17900',
13
12
  // Arbitrum
14
- 42161: '600a9a04-c1b9-42ca-6785-9b4b6ff85200',
13
+ 42161: '3bff954d-5cb0-47a0-9a23-d20192e74600',
15
14
  // Avalanche
16
15
  43114: '30c46e53-e989-45fb-4549-be3bd4eb3b00',
17
16
  // Binance Smart Chain
@@ -22,6 +21,20 @@ export const PresetsUtil = {
22
21
  10: 'ab9c186a-c52f-464b-2906-ca59d760a400',
23
22
  // Polygon
24
23
  137: '41d04d42-da3b-4453-8506-668cc0727900',
24
+ // Mantle
25
+ 5000: 'e86fae9b-b770-4eea-e520-150e12c81100',
26
+ // Hedera Mainnet
27
+ 295: '6a97d510-cac8-4e58-c7ce-e8681b044c00',
28
+ // Sepolia
29
+ 11_155_111: 'e909ea0a-f92a-4512-c8fc-748044ea6800',
30
+ // Base Sepolia
31
+ 84532: 'a18a7ecd-e307-4360-4746-283182228e00',
32
+ // Unichain Sepolia
33
+ 1301: '4eeea7ef-0014-4649-5d1d-07271a80f600',
34
+ // Unichain Mainnet
35
+ 130: '2257980a-3463-48c6-cbac-a42d2a956e00',
36
+ // Monad Testnet
37
+ 10_143: '0a728e83-bacb-46db-7844-948f05434900',
25
38
  // Gnosis
26
39
  100: '02b53f6a-e3d4-479e-1cb4-21178987d100',
27
40
  // EVMos
@@ -45,7 +58,26 @@ export const PresetsUtil = {
45
58
  // Base
46
59
  8453: '7289c336-3981-4081-c5f4-efc26ac64a00',
47
60
  // Aurora
48
- 1313161554: '3ff73439-a619-4894-9262-4470c773a100'
61
+ 1313161554: '3ff73439-a619-4894-9262-4470c773a100',
62
+ // Ronin Mainnet
63
+ 2020: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
64
+ // Saigon Testnet (a.k.a. Ronin)
65
+ 2021: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
66
+ // Berachain Mainnet
67
+ 80094: 'e329c2c9-59b0-4a02-83e4-212ff3779900',
68
+ // Abstract Mainnet
69
+ 2741: 'fc2427d1-5af9-4a9c-8da5-6f94627cd900',
70
+
71
+ // Solana networks
72
+ /// Mainnet
73
+ '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
74
+ /// Testnet
75
+ '4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
76
+
77
+ // Bitcoin
78
+ '000000000019d6689c085ae165831e93': '0b4838db-0161-4ffe-022d-532bf03dba00',
79
+ // Bitcoin Testnet
80
+ '000000000933ea01ad0ee984209779ba': '39354064-d79b-420b-065d-f980c4b78200'
49
81
  } as Record<string, string>,
50
82
 
51
83
  ConnectorNamesMap: {
@@ -59,12 +91,6 @@ export const PresetsUtil = {
59
91
  [ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400'
60
92
  } as Record<string, string>,
61
93
 
62
- ConnectorTypesMap: {
63
- [ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'WALLET_CONNECT',
64
- [ConstantsUtil.COINBASE_CONNECTOR_ID]: 'COINBASE',
65
- [ConstantsUtil.AUTH_CONNECTOR_ID]: 'AUTH'
66
- } as Record<string, ConnectorType>,
67
-
68
94
  RpcChainIds: [
69
95
  // Ethereum
70
96
  1,
@@ -1,19 +1,68 @@
1
- export interface Balance {
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 AdapterType = 'solana' | 'wagmi' | 'ethers' | 'universal' | 'bip122';
10
+
11
+ export type Network = {
12
+ // Core viem/chain properties
13
+ id: number | string;
2
14
  name: string;
3
- symbol: string;
4
- chainId: string;
5
- address?: string;
6
- value?: number;
7
- price: number;
8
- quantity: BalanceQuantity;
9
- iconUrl: string;
10
- }
15
+ nativeCurrency: { name: string; symbol: string; decimals: number };
16
+ rpcUrls: {
17
+ default: { http: readonly string[] };
18
+ [key: string]: { http: readonly string[] } | undefined;
19
+ };
20
+ blockExplorers?: {
21
+ default: { name: string; url: string };
22
+ [key: string]: { name: string; url: string } | undefined;
23
+ };
11
24
 
12
- type BalanceQuantity = {
13
- decimals: string;
14
- numeric: string;
25
+ // AppKit specific / CAIP properties (Optional in type, but needed in practice)
26
+ chainNamespace?: ChainNamespace; // e.g., 'eip155'
27
+ caipNetworkId?: CaipNetworkId; // e.g., 'eip155:1'
28
+ testnet?: boolean;
29
+ deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
15
30
  };
16
31
 
32
+ export type AppKitNetwork = Network & {
33
+ chainNamespace: ChainNamespace; // e.g., 'eip155'
34
+ caipNetworkId: CaipNetworkId; // e.g., 'eip155:1'
35
+ testnet?: boolean;
36
+ deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
37
+ };
38
+
39
+ export type AppKitConnectOptions = Pick<
40
+ ConnectOptions,
41
+ 'namespaces' | 'defaultChain' | 'universalLink'
42
+ >;
43
+
44
+ export interface CaipNetwork {
45
+ id: CaipNetworkId;
46
+ name?: string;
47
+ imageId?: string;
48
+ imageUrl?: string;
49
+ }
50
+
51
+ export interface Balance {
52
+ name?: string;
53
+ amount: string;
54
+ symbol: string;
55
+ quantity?: {
56
+ decimals: string;
57
+ numeric: string;
58
+ };
59
+ chainId?: string;
60
+ address?: CaipAddress; // contract address
61
+ value?: number; //total value of the amount in currency
62
+ price?: number; //price of the token in currency
63
+ iconUrl?: string;
64
+ }
65
+
17
66
  export type TransactionStatus = 'confirmed' | 'failed' | 'pending';
18
67
  export type TransactionDirection = 'in' | 'out' | 'self';
19
68
  export type TransactionImage = {
@@ -86,7 +135,15 @@ export interface TransactionQuantity {
86
135
  numeric: string;
87
136
  }
88
137
 
89
- export type SocialProvider = 'apple' | 'x' | 'discord' | 'farcaster';
138
+ export type SocialProvider =
139
+ | 'google'
140
+ | 'facebook'
141
+ | 'github'
142
+ | 'apple'
143
+ | 'x'
144
+ | 'discord'
145
+ | 'email'
146
+ | 'farcaster';
90
147
 
91
148
  export type ThemeMode = 'dark' | 'light';
92
149
 
@@ -94,4 +151,312 @@ export interface ThemeVariables {
94
151
  accent?: string;
95
152
  }
96
153
 
97
- export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
154
+ export interface Token {
155
+ address: string;
156
+ image?: string;
157
+ }
158
+
159
+ export type Tokens = Record<CaipNetworkId, Token>;
160
+
161
+ export type Metadata = {
162
+ name: string;
163
+ description: string;
164
+ url: string;
165
+ icons: string[];
166
+ redirect?: {
167
+ native?: string;
168
+ universal?: string;
169
+ linkMode?: boolean;
170
+ };
171
+ };
172
+
173
+ export type BlockchainAdapterConfig = {
174
+ projectId: string;
175
+ supportedNamespace: ChainNamespace;
176
+ adapterType: AdapterType;
177
+ };
178
+
179
+ //********** Adapter Event Payloads **********//
180
+ export type AccountsChangedEvent = {
181
+ accounts: string[];
182
+ };
183
+
184
+ export type ChainChangedEvent = {
185
+ chainId: string;
186
+ };
187
+
188
+ export type DisconnectEvent = {};
189
+
190
+ export type BalanceChangedEvent = {
191
+ address: CaipAddress;
192
+ balance: Balance;
193
+ };
194
+
195
+ //********** Adapter Event Map **********//
196
+ export interface AdapterEvents {
197
+ accountsChanged: (event: AccountsChangedEvent) => void;
198
+ chainChanged: (event: ChainChangedEvent) => void;
199
+ disconnect: (event: DisconnectEvent) => void;
200
+ balanceChanged: (event: BalanceChangedEvent) => void;
201
+ }
202
+
203
+ export interface GetBalanceParams {
204
+ network: AppKitNetwork;
205
+ address?: CaipAddress;
206
+ tokens?: Tokens;
207
+ }
208
+
209
+ export type GetBalanceResponse = Balance;
210
+
211
+ //********** Connector Types **********//
212
+ interface BaseNamespace {
213
+ chains?: CaipNetworkId[];
214
+ accounts: CaipAddress[];
215
+ methods: string[];
216
+ events: string[];
217
+ }
218
+
219
+ type Namespace = BaseNamespace;
220
+
221
+ export type Namespaces = Record<string, Namespace>;
222
+
223
+ export type ProposalNamespaces = Record<
224
+ string,
225
+ Omit<Namespace, 'accounts'> &
226
+ Required<Pick<Namespace, 'chains'>> & { rpcMap: Record<string, string> }
227
+ >;
228
+
229
+ export type ConnectOptions = {
230
+ namespaces?: ProposalNamespaces;
231
+ defaultChain?: CaipNetworkId;
232
+ universalLink?: string;
233
+ siweConfig?: AppKitSIWEClient;
234
+ };
235
+
236
+ export type ConnectorInitOptions = {
237
+ storage: Storage;
238
+ metadata: Metadata;
239
+ };
240
+
241
+ export abstract class WalletConnector extends EventEmitter {
242
+ public type: ConnectorType;
243
+ protected provider?: Provider;
244
+ protected namespaces?: Namespaces;
245
+ protected wallet?: WalletInfo;
246
+ protected storage?: Storage;
247
+ protected metadata?: Metadata;
248
+ protected properties?: ConnectionProperties;
249
+
250
+ constructor({ type }: { type: ConnectorType }) {
251
+ super();
252
+ this.type = type;
253
+ }
254
+
255
+ public async init(ops: ConnectorInitOptions) {
256
+ this.storage = ops.storage;
257
+ this.metadata = ops.metadata;
258
+ }
259
+
260
+ public setProvider(provider: Provider) {
261
+ this.provider = provider;
262
+ }
263
+
264
+ public async disconnect() {
265
+ await this.getProvider().disconnect();
266
+ this.namespaces = undefined;
267
+ this.wallet = undefined;
268
+ this.properties = undefined;
269
+ }
270
+
271
+ abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
272
+ abstract getProvider(): Provider;
273
+ abstract getNamespaces(): Namespaces;
274
+ abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
275
+ abstract getWalletInfo(): WalletInfo | undefined;
276
+ abstract getProperties(): ConnectionProperties | undefined;
277
+ abstract switchNetwork(network: AppKitNetwork): Promise<void>;
278
+ abstract restoreSession(): Promise<boolean>;
279
+ }
280
+
281
+ //********** Provider Types **********//
282
+
283
+ export interface Provider {
284
+ connect<T>(params?: any): Promise<T>;
285
+ disconnect(): Promise<void>;
286
+ request<T = unknown>(
287
+ args: RequestArguments,
288
+ chain?: string | undefined,
289
+ expiry?: number | undefined
290
+ ): Promise<T>;
291
+ on(event: string, listener: (args?: any) => void): any;
292
+ off(event: string, listener: (args?: any) => void): any;
293
+ }
294
+
295
+ export interface RequestArguments {
296
+ method: string;
297
+ params?: unknown[] | Record<string, unknown> | object | undefined;
298
+ }
299
+
300
+ export type ConnectorType = 'walletconnect' | 'coinbase' | 'auth' | 'phantom';
301
+
302
+ //********** Others **********//
303
+
304
+ export interface ConnectionResponse {
305
+ accounts: string[];
306
+ chainId: string;
307
+ [key: string]: any;
308
+ }
309
+
310
+ export interface WalletInfo {
311
+ name?: string;
312
+ icon?: string;
313
+ description?: string;
314
+ url?: string;
315
+ icons?: string[];
316
+ redirect?: {
317
+ native?: string;
318
+ universal?: string;
319
+ linkMode?: boolean;
320
+ };
321
+ [key: string]: unknown;
322
+ }
323
+
324
+ export interface ConnectionProperties {
325
+ email?: string;
326
+ username?: string;
327
+ smartAccounts?: CaipAddress[];
328
+ provider?: SocialProvider;
329
+ sessionTopic?: string;
330
+ }
331
+
332
+ export type AccountType = 'eoa' | 'smartAccount';
333
+
334
+ export interface Storage {
335
+ /**
336
+ * Returns all keys in storage.
337
+ */
338
+ getKeys(): Promise<string[]>;
339
+
340
+ /**
341
+ * Returns all key-value entries in storage.
342
+ */
343
+ getEntries<T = any>(): Promise<[string, T][]>;
344
+
345
+ /**
346
+ * Get an item from storage for a given key.
347
+ * @param key The key to retrieve.
348
+ */
349
+ getItem<T = any>(key: string): Promise<T | undefined>;
350
+
351
+ /**
352
+ * Set an item in storage for a given key.
353
+ * @param key The key to set.
354
+ * @param value The value to set.
355
+ */
356
+ setItem<T = any>(key: string, value: T): Promise<void>;
357
+
358
+ /**
359
+ * Remove an item from storage for a given key.
360
+ * @param key The key to remove.
361
+ */
362
+ removeItem(key: string): Promise<void>;
363
+ }
364
+
365
+ //********** SIWE Types **********//
366
+ export interface SIWESession {
367
+ address: string;
368
+ chainId: number;
369
+ }
370
+
371
+ interface CacaoHeader {
372
+ t: 'caip122';
373
+ }
374
+
375
+ export interface SIWECreateMessageArgs {
376
+ domain: string;
377
+ nonce: string;
378
+ uri: string;
379
+ address: CaipAddress;
380
+ version: '1';
381
+ type?: CacaoHeader['t'];
382
+ nbf?: string;
383
+ exp?: string;
384
+ statement?: string;
385
+ requestId?: string;
386
+ resources?: string[];
387
+ expiry?: number;
388
+ iat?: string;
389
+ }
390
+ export type SIWEMessageArgs = {
391
+ chains: CaipNetworkId[];
392
+ methods?: string[];
393
+ } & Omit<SIWECreateMessageArgs, 'address' | 'nonce' | 'version'>;
394
+ // Signed Cacao (CAIP-74)
395
+ interface CacaoPayload {
396
+ domain: string;
397
+ aud: string;
398
+ nonce: string;
399
+ iss: string;
400
+ version?: string;
401
+ iat?: string;
402
+ nbf?: string;
403
+ exp?: string;
404
+ statement?: string;
405
+ requestId?: string;
406
+ resources?: string[];
407
+ type?: string;
408
+ }
409
+
410
+ interface Cacao {
411
+ h: CacaoHeader;
412
+ p: CacaoPayload;
413
+ s: {
414
+ t: 'eip191' | 'eip1271';
415
+ s: string;
416
+ m?: string;
417
+ };
418
+ }
419
+
420
+ export interface SIWEVerifyMessageArgs {
421
+ message: string;
422
+ signature: string;
423
+ cacao?: Cacao;
424
+ }
425
+
426
+ export interface SIWEClientMethods {
427
+ getNonce: (address?: string) => Promise<string>;
428
+ createMessage: (args: SIWECreateMessageArgs) => string;
429
+ verifyMessage: (args: SIWEVerifyMessageArgs) => Promise<boolean>;
430
+ getSession: () => Promise<SIWESession | null>;
431
+ signOut: () => Promise<boolean>;
432
+ getMessageParams?: () => Promise<SIWEMessageArgs>;
433
+ onSignIn?: (session?: SIWESession) => void;
434
+ onSignOut?: () => void;
435
+ }
436
+
437
+ export interface SIWEConfig extends SIWEClientMethods {
438
+ // Defaults to true
439
+ enabled?: boolean;
440
+ // In milliseconds, defaults to 5 minutes
441
+ nonceRefetchIntervalMs?: number;
442
+ // In milliseconds, defaults to 5 minutes
443
+ sessionRefetchIntervalMs?: number;
444
+ // Defaults to true
445
+ signOutOnDisconnect?: boolean;
446
+ // Defaults to true
447
+ signOutOnAccountChange?: boolean;
448
+ // Defaults to true
449
+ signOutOnNetworkChange?: boolean;
450
+ }
451
+
452
+ export interface AppKitSIWEClient extends SIWEClientMethods {
453
+ signIn: () => Promise<SIWESession | undefined>;
454
+ options: {
455
+ enabled: boolean;
456
+ nonceRefetchIntervalMs: number;
457
+ sessionRefetchIntervalMs: number;
458
+ signOutOnDisconnect: boolean;
459
+ signOutOnAccountChange: boolean;
460
+ signOutOnNetworkChange: boolean;
461
+ };
462
+ }