@reown/appkit-common-react-native 0.0.0-feat-coinbase-20250722184953 → 0.0.0-feat-onramp-20250722205908

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/index.js +1 -62
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/utils/ConstantsUtil.js +3 -12
  4. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  5. package/lib/commonjs/utils/NumberUtil.js +11 -52
  6. package/lib/commonjs/utils/NumberUtil.js.map +1 -1
  7. package/lib/commonjs/utils/PresetsUtil.js +10 -35
  8. package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
  9. package/lib/commonjs/utils/TypeUtil.js +0 -42
  10. package/lib/commonjs/utils/TypeUtil.js.map +1 -1
  11. package/lib/module/index.js +0 -5
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/module/utils/ConstantsUtil.js +3 -12
  14. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  15. package/lib/module/utils/NumberUtil.js +11 -52
  16. package/lib/module/utils/NumberUtil.js.map +1 -1
  17. package/lib/module/utils/PresetsUtil.js +10 -35
  18. package/lib/module/utils/PresetsUtil.js.map +1 -1
  19. package/lib/module/utils/TypeUtil.js +0 -36
  20. package/lib/module/utils/TypeUtil.js.map +1 -1
  21. package/lib/typescript/index.d.ts +0 -5
  22. package/lib/typescript/index.d.ts.map +1 -1
  23. package/lib/typescript/utils/ConstantsUtil.d.ts +1 -9
  24. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  25. package/lib/typescript/utils/NumberUtil.d.ts +11 -39
  26. package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
  27. package/lib/typescript/utils/PresetsUtil.d.ts +3 -1
  28. package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
  29. package/lib/typescript/utils/TypeUtil.d.ts +12 -296
  30. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  31. package/package.json +2 -2
  32. package/src/index.ts +0 -5
  33. package/src/utils/ConstantsUtil.ts +3 -13
  34. package/src/utils/NumberUtil.ts +11 -54
  35. package/src/utils/PresetsUtil.ts +12 -37
  36. package/src/utils/TypeUtil.ts +14 -379
  37. package/lib/commonjs/adapters/BlockchainAdapter.js +0 -81
  38. package/lib/commonjs/adapters/BlockchainAdapter.js.map +0 -1
  39. package/lib/commonjs/adapters/EvmAdapter.js +0 -208
  40. package/lib/commonjs/adapters/EvmAdapter.js.map +0 -1
  41. package/lib/commonjs/adapters/SolanaBaseAdapter.js +0 -10
  42. package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +0 -1
  43. package/lib/commonjs/networks/bitcoin.js +0 -40
  44. package/lib/commonjs/networks/bitcoin.js.map +0 -1
  45. package/lib/commonjs/networks/solana.js +0 -78
  46. package/lib/commonjs/networks/solana.js.map +0 -1
  47. package/lib/module/adapters/BlockchainAdapter.js +0 -74
  48. package/lib/module/adapters/BlockchainAdapter.js.map +0 -1
  49. package/lib/module/adapters/EvmAdapter.js +0 -202
  50. package/lib/module/adapters/EvmAdapter.js.map +0 -1
  51. package/lib/module/adapters/SolanaBaseAdapter.js +0 -3
  52. package/lib/module/adapters/SolanaBaseAdapter.js.map +0 -1
  53. package/lib/module/networks/bitcoin.js +0 -34
  54. package/lib/module/networks/bitcoin.js.map +0 -1
  55. package/lib/module/networks/solana.js +0 -72
  56. package/lib/module/networks/solana.js.map +0 -1
  57. package/lib/typescript/adapters/BlockchainAdapter.d.ts +0 -25
  58. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +0 -1
  59. package/lib/typescript/adapters/EvmAdapter.d.ts +0 -27
  60. package/lib/typescript/adapters/EvmAdapter.d.ts.map +0 -1
  61. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +0 -6
  62. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +0 -1
  63. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts +0 -2
  64. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts.map +0 -1
  65. package/lib/typescript/networks/bitcoin.d.ts +0 -4
  66. package/lib/typescript/networks/bitcoin.d.ts.map +0 -1
  67. package/lib/typescript/networks/solana.d.ts +0 -5
  68. package/lib/typescript/networks/solana.d.ts.map +0 -1
  69. package/src/adapters/BlockchainAdapter.ts +0 -107
  70. package/src/adapters/EvmAdapter.ts +0 -260
  71. package/src/adapters/SolanaBaseAdapter.ts +0 -6
  72. package/src/adapters/__tests__/EvmAdapter.test.ts +0 -126
  73. package/src/networks/bitcoin.ts +0 -32
  74. package/src/networks/solana.ts +0 -44
@@ -1,5 +1,5 @@
1
1
  export const ConstantsUtil = {
2
- VERSION: '0.0.0-feat-coinbase-20250722184953',
2
+ VERSION: '0.0.0-feat-onramp-20250722205908',
3
3
 
4
4
  EIP155: 'eip155',
5
5
  ADD_CHAIN_METHOD: 'wallet_addEthereumChain',
@@ -11,13 +11,10 @@ export const ConstantsUtil = {
11
11
  BLOCKCHAIN_API_RPC_URL_STAGING: 'https://staging.rpc.walletconnect.org',
12
12
  PULSE_API_URL: 'https://pulse.walletconnect.org',
13
13
  API_URL: 'https://api.web3modal.org',
14
- WEB_WALLET_URL: 'https://web-wallet.walletconnect.org',
15
- SECURE_SITE_DASHBOARD: `https://secure.reown.com/dashboard`,
16
- SECURE_SITE_ICON: `https://secure.reown.com/images/favicon.png`,
17
14
 
18
- //TODO: remove this
19
15
  WALLET_CONNECT_CONNECTOR_ID: 'walletConnect',
20
16
  COINBASE_CONNECTOR_ID: 'coinbaseWallet',
17
+ AUTH_CONNECTOR_ID: 'appKitAuth',
21
18
 
22
19
  COINBASE_EXPLORER_ID: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
23
20
 
@@ -36,12 +33,5 @@ export const ConstantsUtil = {
36
33
  '0x55d398326f99059fF775485246999027B3197955',
37
34
  // Arbitrum
38
35
  '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9'
39
- ],
40
-
41
- PHANTOM_CUSTOM_WALLET: {
42
- id: 'phantom-wallet',
43
- name: 'Phantom',
44
- image_id: 'b6ec7b81-bb4f-427d-e290-7631e6e50d00',
45
- mobile_link: 'phantom://'
46
- }
36
+ ]
47
37
  };
@@ -1,12 +1,6 @@
1
1
  import * as BigNumber from 'bignumber.js';
2
2
 
3
3
  export const NumberUtil = {
4
- /**
5
- * Creates a BigNumber instance from a given value.
6
- * If the value is a string, commas are removed before conversion.
7
- * @param value - The input value (string, number, or BigNumber) to convert to a BigNumber.
8
- * @returns A BigNumber instance.
9
- */
10
4
  bigNumber(value: BigNumber.BigNumber.Value) {
11
5
  if (typeof value === 'string') {
12
6
  return new BigNumber.BigNumber(value.replace(/,/g, ''));
@@ -16,11 +10,10 @@ export const NumberUtil = {
16
10
  },
17
11
 
18
12
  /**
19
- * Multiplies two numbers using BigNumber for precision, especially with decimals.
20
- * Handles undefined inputs by returning BigNumber(0).
21
- * @param a - The first multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
22
- * @param b - The second multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
23
- * @returns The product as a BigNumber instance, or BigNumber(0) if either input is undefined.
13
+ * Multiply two numbers represented as strings with BigNumber to handle decimals correctly
14
+ * @param a string
15
+ * @param b string
16
+ * @returns
24
17
  */
25
18
  multiply(a: BigNumber.BigNumber.Value | undefined, b: BigNumber.BigNumber.Value | undefined) {
26
19
  if (a === undefined || b === undefined) {
@@ -33,13 +26,6 @@ export const NumberUtil = {
33
26
  return aBigNumber.multipliedBy(bBigNumber);
34
27
  },
35
28
 
36
- /**
37
- * Rounds a number to a specified number of decimal places if its string representation meets a certain length threshold.
38
- * @param number - The number to potentially round.
39
- * @param threshold - The minimum string length of the number to trigger rounding.
40
- * @param fixed - The number of decimal places to round to.
41
- * @returns The rounded number (as a string if rounded, otherwise the original number) or the original number.
42
- */
43
29
  roundNumber(number: number, threshold: number, fixed: number) {
44
30
  const roundedNumber =
45
31
  number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
@@ -47,12 +33,6 @@ export const NumberUtil = {
47
33
  return roundedNumber;
48
34
  },
49
35
 
50
- /**
51
- * Calculates the next multiple of ten greater than or equal to the given amount.
52
- * Defaults to 10 if no amount is provided or if the calculated multiple is less than 10.
53
- * @param amount - The number for which to find the next multiple of ten. Optional.
54
- * @returns The next multiple of ten, at least 10.
55
- */
56
36
  nextMultipleOfTen(amount?: number) {
57
37
  if (!amount) return 10;
58
38
 
@@ -60,10 +40,10 @@ export const NumberUtil = {
60
40
  },
61
41
 
62
42
  /**
63
- * Formats a number or string to a human-readable string with a specified number of decimal places, using US locale formatting.
64
- * @param value - The value to format (string, number, or undefined). If undefined, returns '0.00'.
65
- * @param decimals - The number of decimal places to display. Defaults to 2.
66
- * @returns A locale-formatted string representation of the number.
43
+ * Format the given number or string to human readable numbers with the given number of decimals
44
+ * @param value - The value to format. It could be a number or string. If it's a string, it will be parsed to a float then formatted.
45
+ * @param decimals - number of decimals after dot
46
+ * @returns
67
47
  */
68
48
  formatNumberToLocalString(value: string | number | undefined, decimals = 2) {
69
49
  if (value === undefined) {
@@ -82,11 +62,10 @@ export const NumberUtil = {
82
62
  minimumFractionDigits: decimals
83
63
  });
84
64
  },
85
-
86
65
  /**
87
- * Parses a locale-formatted numeric string (e.g., with commas) back into a number.
88
- * @param value - The formatted string to parse. If undefined, returns 0.
89
- * @returns The parsed number, or 0 if the input is undefined.
66
+ * Parse a formatted local string back to a number
67
+ * @param value - The formatted string to parse
68
+ * @returns
90
69
  */
91
70
  parseLocalStringToNumber(value: string | undefined) {
92
71
  if (value === undefined) {
@@ -95,27 +74,5 @@ export const NumberUtil = {
95
74
 
96
75
  // Remove any commas used as thousand separators and parse the float
97
76
  return parseFloat(value.replace(/,/gu, ''));
98
- },
99
-
100
- /**
101
- * Converts a numeric value (BigInt, number, or string representation of a number) to a 0x-prefixed hexadecimal string.
102
- * This is often required for Ethereum RPC parameters like value, gas, gasPrice.
103
- * @param value - The value to convert. Can be BigInt, number, or a string (decimal or hex).
104
- * @returns A 0x-prefixed hexadecimal string, or undefined if the input is undefined or null.
105
- * @throws Error if the value cannot be converted to BigInt.
106
- */
107
- convertNumericToHexString: (value: any): string | undefined => {
108
- if (value === undefined || value === null) {
109
- return undefined;
110
- }
111
- try {
112
- // This handles BigInt, number, or string representation of a number (decimal or hex)
113
- const bigIntValue = BigInt(value);
114
- // Ethereum RPC spec requires "0x0" for zero, and other values to be 0x-prefixed hex.
115
-
116
- return '0x' + bigIntValue.toString(16);
117
- } catch (error) {
118
- throw new Error(`NumberUtil: Invalid parameter, cannot convert to hex: ${value}`);
119
- }
120
77
  }
121
78
  };
@@ -1,3 +1,4 @@
1
+ import type { ConnectorType } from './TypeUtil';
1
2
  import { ConstantsUtil } from './ConstantsUtil';
2
3
 
3
4
  export const PresetsUtil = {
@@ -6,11 +7,11 @@ export const PresetsUtil = {
6
7
  'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
7
8
  } as Record<string, string>,
8
9
 
9
- NetworkImageIds: {
10
+ EIP155NetworkImageIds: {
10
11
  // Ethereum
11
12
  1: 'ba0ba0cd-17c6-4806-ad93-f9d174f17900',
12
13
  // Arbitrum
13
- 42161: '3bff954d-5cb0-47a0-9a23-d20192e74600',
14
+ 42161: '600a9a04-c1b9-42ca-6785-9b4b6ff85200',
14
15
  // Avalanche
15
16
  43114: '30c46e53-e989-45fb-4549-be3bd4eb3b00',
16
17
  // Binance Smart Chain
@@ -21,20 +22,6 @@ export const PresetsUtil = {
21
22
  10: 'ab9c186a-c52f-464b-2906-ca59d760a400',
22
23
  // Polygon
23
24
  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',
38
25
  // Gnosis
39
26
  100: '02b53f6a-e3d4-479e-1cb4-21178987d100',
40
27
  // EVMos
@@ -58,31 +45,13 @@ export const PresetsUtil = {
58
45
  // Base
59
46
  8453: '7289c336-3981-4081-c5f4-efc26ac64a00',
60
47
  // Aurora
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'
48
+ 1313161554: '3ff73439-a619-4894-9262-4470c773a100'
81
49
  } as Record<string, string>,
82
50
 
83
51
  ConnectorNamesMap: {
84
52
  [ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'WalletConnect',
85
- [ConstantsUtil.COINBASE_CONNECTOR_ID]: 'Coinbase Wallet'
53
+ [ConstantsUtil.COINBASE_CONNECTOR_ID]: 'Coinbase Wallet',
54
+ [ConstantsUtil.AUTH_CONNECTOR_ID]: 'AppKit Universal Wallet'
86
55
  } as Record<string, string>,
87
56
 
88
57
  ConnectorImageIds: {
@@ -90,6 +59,12 @@ export const PresetsUtil = {
90
59
  [ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400'
91
60
  } as Record<string, string>,
92
61
 
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
+
93
68
  RpcChainIds: [
94
69
  // Ethereum
95
70
  1,
@@ -1,68 +1,19 @@
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;
14
- name: string;
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
- };
24
-
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
30
- };
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
1
  export interface Balance {
52
- name?: string;
53
- amount: string;
2
+ name: string;
54
3
  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;
4
+ chainId: string;
5
+ address?: string;
6
+ value?: number;
7
+ price: number;
8
+ quantity: BalanceQuantity;
9
+ iconUrl: string;
64
10
  }
65
11
 
12
+ type BalanceQuantity = {
13
+ decimals: string;
14
+ numeric: string;
15
+ };
16
+
66
17
  export type TransactionStatus = 'confirmed' | 'failed' | 'pending';
67
18
  export type TransactionDirection = 'in' | 'out' | 'self';
68
19
  export type TransactionImage = {
@@ -135,15 +86,7 @@ export interface TransactionQuantity {
135
86
  numeric: string;
136
87
  }
137
88
 
138
- export type SocialProvider =
139
- | 'google'
140
- | 'facebook'
141
- | 'github'
142
- | 'apple'
143
- | 'x'
144
- | 'discord'
145
- | 'email'
146
- | 'farcaster';
89
+ export type SocialProvider = 'apple' | 'x' | 'discord' | 'farcaster';
147
90
 
148
91
  export type ThemeMode = 'dark' | 'light';
149
92
 
@@ -151,312 +94,4 @@ export interface ThemeVariables {
151
94
  accent?: string;
152
95
  }
153
96
 
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
- }
97
+ export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';