@reown/appkit-common-react-native 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (237) hide show
  1. package/lib/commonjs/adapters/BlockchainAdapter.js +25 -12
  2. package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -1
  3. package/lib/commonjs/adapters/EvmAdapter.js +0 -11
  4. package/lib/commonjs/adapters/EvmAdapter.js.map +1 -1
  5. package/lib/commonjs/index.js +4 -4
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/types/api/blockchain-api.js +15 -0
  8. package/lib/commonjs/types/api/blockchain-api.js.map +1 -0
  9. package/lib/commonjs/types/api/events.js +6 -0
  10. package/lib/commonjs/types/api/events.js.map +1 -0
  11. package/lib/commonjs/types/api/index.js +39 -0
  12. package/lib/commonjs/types/api/index.js.map +1 -0
  13. package/lib/commonjs/types/api/wallet-api.js +6 -0
  14. package/lib/commonjs/types/api/wallet-api.js.map +1 -0
  15. package/lib/commonjs/types/blockchain/adapter.js +6 -0
  16. package/lib/commonjs/types/blockchain/adapter.js.map +1 -0
  17. package/lib/commonjs/types/blockchain/balance.js +6 -0
  18. package/lib/commonjs/types/blockchain/balance.js.map +1 -0
  19. package/lib/commonjs/types/blockchain/index.js +50 -0
  20. package/lib/commonjs/types/blockchain/index.js.map +1 -0
  21. package/lib/commonjs/types/blockchain/network.js +6 -0
  22. package/lib/commonjs/types/blockchain/network.js.map +1 -0
  23. package/lib/commonjs/types/blockchain/transaction.js +2 -0
  24. package/lib/commonjs/types/blockchain/transaction.js.map +1 -0
  25. package/lib/commonjs/types/common.js +2 -0
  26. package/lib/commonjs/types/common.js.map +1 -0
  27. package/lib/commonjs/types/index.js +105 -0
  28. package/lib/commonjs/types/index.js.map +1 -0
  29. package/lib/commonjs/types/onramp/countries.js +2 -0
  30. package/lib/commonjs/types/onramp/countries.js.map +1 -0
  31. package/lib/commonjs/types/onramp/currencies.js +2 -0
  32. package/lib/commonjs/types/onramp/currencies.js.map +1 -0
  33. package/lib/commonjs/types/onramp/errors.js +22 -0
  34. package/lib/commonjs/types/onramp/errors.js.map +1 -0
  35. package/lib/commonjs/types/onramp/index.js +50 -0
  36. package/lib/commonjs/types/onramp/index.js.map +1 -0
  37. package/lib/commonjs/types/onramp/quotes.js +2 -0
  38. package/lib/commonjs/types/onramp/quotes.js.map +1 -0
  39. package/lib/commonjs/types/siwe/config.js +6 -0
  40. package/lib/commonjs/types/siwe/config.js.map +1 -0
  41. package/lib/commonjs/types/siwe/index.js +28 -0
  42. package/lib/commonjs/types/siwe/index.js.map +1 -0
  43. package/lib/commonjs/types/siwe/message.js +6 -0
  44. package/lib/commonjs/types/siwe/message.js.map +1 -0
  45. package/lib/commonjs/types/storage.js +2 -0
  46. package/lib/commonjs/types/storage.js.map +1 -0
  47. package/lib/commonjs/types/swap/index.js +17 -0
  48. package/lib/commonjs/types/swap/index.js.map +1 -0
  49. package/lib/commonjs/types/swap/tokens.js +6 -0
  50. package/lib/commonjs/types/swap/tokens.js.map +1 -0
  51. package/lib/commonjs/types/ui.js +6 -0
  52. package/lib/commonjs/types/ui.js.map +1 -0
  53. package/lib/commonjs/types/wallet/connection.js +6 -0
  54. package/lib/commonjs/types/wallet/connection.js.map +1 -0
  55. package/lib/commonjs/{utils/TypeUtil.js → types/wallet/connector.js} +1 -15
  56. package/lib/commonjs/types/wallet/connector.js.map +1 -0
  57. package/lib/commonjs/types/wallet/index.js +39 -0
  58. package/lib/commonjs/types/wallet/index.js.map +1 -0
  59. package/lib/commonjs/types/wallet/wallet-info.js +6 -0
  60. package/lib/commonjs/types/wallet/wallet-info.js.map +1 -0
  61. package/lib/commonjs/utils/ConstantsUtil.js +27 -7
  62. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  63. package/lib/commonjs/utils/NetworkUtil.js +3 -0
  64. package/lib/commonjs/utils/NetworkUtil.js.map +1 -1
  65. package/lib/module/adapters/BlockchainAdapter.js +25 -12
  66. package/lib/module/adapters/BlockchainAdapter.js.map +1 -1
  67. package/lib/module/adapters/EvmAdapter.js +0 -11
  68. package/lib/module/adapters/EvmAdapter.js.map +1 -1
  69. package/lib/module/index.js +1 -1
  70. package/lib/module/index.js.map +1 -1
  71. package/lib/module/types/api/blockchain-api.js +10 -0
  72. package/lib/module/types/api/blockchain-api.js.map +1 -0
  73. package/lib/module/types/api/events.js +4 -0
  74. package/lib/module/types/api/events.js.map +1 -0
  75. package/lib/module/types/api/index.js +7 -0
  76. package/lib/module/types/api/index.js.map +1 -0
  77. package/lib/module/types/api/wallet-api.js +4 -0
  78. package/lib/module/types/api/wallet-api.js.map +1 -0
  79. package/lib/module/types/blockchain/adapter.js +4 -0
  80. package/lib/module/types/blockchain/adapter.js.map +1 -0
  81. package/lib/module/types/blockchain/balance.js +4 -0
  82. package/lib/module/types/blockchain/balance.js.map +1 -0
  83. package/lib/module/types/blockchain/index.js +8 -0
  84. package/lib/module/types/blockchain/index.js.map +1 -0
  85. package/lib/module/types/blockchain/network.js +4 -0
  86. package/lib/module/types/blockchain/network.js.map +1 -0
  87. package/lib/module/types/blockchain/transaction.js +2 -0
  88. package/lib/module/types/blockchain/transaction.js.map +1 -0
  89. package/lib/module/types/common.js +2 -0
  90. package/lib/module/types/common.js.map +1 -0
  91. package/lib/module/types/index.js +31 -0
  92. package/lib/module/types/index.js.map +1 -0
  93. package/lib/module/types/onramp/countries.js +2 -0
  94. package/lib/module/types/onramp/countries.js.map +1 -0
  95. package/lib/module/types/onramp/currencies.js +2 -0
  96. package/lib/module/types/onramp/currencies.js.map +1 -0
  97. package/lib/module/types/onramp/errors.js +18 -0
  98. package/lib/module/types/onramp/errors.js.map +1 -0
  99. package/lib/module/types/onramp/index.js +8 -0
  100. package/lib/module/types/onramp/index.js.map +1 -0
  101. package/lib/module/types/onramp/quotes.js +2 -0
  102. package/lib/module/types/onramp/quotes.js.map +1 -0
  103. package/lib/module/types/siwe/config.js +4 -0
  104. package/lib/module/types/siwe/config.js.map +1 -0
  105. package/lib/module/types/siwe/index.js +6 -0
  106. package/lib/module/types/siwe/index.js.map +1 -0
  107. package/lib/module/types/siwe/message.js +4 -0
  108. package/lib/module/types/siwe/message.js.map +1 -0
  109. package/lib/module/types/storage.js +2 -0
  110. package/lib/module/types/storage.js.map +1 -0
  111. package/lib/module/types/swap/index.js +5 -0
  112. package/lib/module/types/swap/index.js.map +1 -0
  113. package/lib/module/types/swap/tokens.js +4 -0
  114. package/lib/module/types/swap/tokens.js.map +1 -0
  115. package/lib/module/types/ui.js +4 -0
  116. package/lib/module/types/ui.js.map +1 -0
  117. package/lib/module/types/wallet/connection.js +4 -0
  118. package/lib/module/types/wallet/connection.js.map +1 -0
  119. package/lib/module/{utils/TypeUtil.js → types/wallet/connector.js} +1 -16
  120. package/lib/module/types/wallet/connector.js.map +1 -0
  121. package/lib/module/types/wallet/index.js +7 -0
  122. package/lib/module/types/wallet/index.js.map +1 -0
  123. package/lib/module/types/wallet/wallet-info.js +4 -0
  124. package/lib/module/types/wallet/wallet-info.js.map +1 -0
  125. package/lib/module/utils/ConstantsUtil.js +27 -7
  126. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  127. package/lib/module/utils/NetworkUtil.js +3 -0
  128. package/lib/module/utils/NetworkUtil.js.map +1 -1
  129. package/lib/typescript/adapters/BlockchainAdapter.d.ts +5 -4
  130. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -1
  131. package/lib/typescript/adapters/EvmAdapter.d.ts +1 -2
  132. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -1
  133. package/lib/typescript/index.d.ts +1 -1
  134. package/lib/typescript/index.d.ts.map +1 -1
  135. package/lib/typescript/networks/bitcoin.d.ts +1 -1
  136. package/lib/typescript/networks/bitcoin.d.ts.map +1 -1
  137. package/lib/typescript/networks/solana.d.ts +1 -1
  138. package/lib/typescript/networks/solana.d.ts.map +1 -1
  139. package/lib/typescript/types/api/blockchain-api.d.ts +183 -0
  140. package/lib/typescript/types/api/blockchain-api.d.ts.map +1 -0
  141. package/lib/typescript/types/api/events.d.ts +304 -0
  142. package/lib/typescript/types/api/events.d.ts.map +1 -0
  143. package/lib/typescript/types/api/index.d.ts +4 -0
  144. package/lib/typescript/types/api/index.d.ts.map +1 -0
  145. package/lib/typescript/types/api/wallet-api.d.ts +50 -0
  146. package/lib/typescript/types/api/wallet-api.d.ts.map +1 -0
  147. package/lib/typescript/types/blockchain/adapter.d.ts +40 -0
  148. package/lib/typescript/types/blockchain/adapter.d.ts.map +1 -0
  149. package/lib/typescript/types/blockchain/balance.d.ts +28 -0
  150. package/lib/typescript/types/blockchain/balance.d.ts.map +1 -0
  151. package/lib/typescript/types/blockchain/index.d.ts +5 -0
  152. package/lib/typescript/types/blockchain/index.d.ts.map +1 -0
  153. package/lib/typescript/types/blockchain/network.d.ts +47 -0
  154. package/lib/typescript/types/blockchain/network.d.ts.map +1 -0
  155. package/lib/typescript/types/blockchain/transaction.d.ts +63 -0
  156. package/lib/typescript/types/blockchain/transaction.d.ts.map +1 -0
  157. package/lib/typescript/types/common.d.ts +24 -0
  158. package/lib/typescript/types/common.d.ts.map +1 -0
  159. package/lib/typescript/types/index.d.ts +10 -0
  160. package/lib/typescript/types/index.d.ts.map +1 -0
  161. package/lib/typescript/types/onramp/countries.d.ts +11 -0
  162. package/lib/typescript/types/onramp/countries.d.ts.map +1 -0
  163. package/lib/typescript/types/onramp/currencies.d.ts +30 -0
  164. package/lib/typescript/types/onramp/currencies.d.ts.map +1 -0
  165. package/lib/typescript/types/onramp/errors.d.ts +21 -0
  166. package/lib/typescript/types/onramp/errors.d.ts.map +1 -0
  167. package/lib/typescript/types/onramp/index.d.ts +5 -0
  168. package/lib/typescript/types/onramp/index.d.ts.map +1 -0
  169. package/lib/typescript/types/onramp/quotes.d.ts +45 -0
  170. package/lib/typescript/types/onramp/quotes.d.ts.map +1 -0
  171. package/lib/typescript/types/siwe/config.d.ts +31 -0
  172. package/lib/typescript/types/siwe/config.d.ts.map +1 -0
  173. package/lib/typescript/types/siwe/index.d.ts +3 -0
  174. package/lib/typescript/types/siwe/index.d.ts.map +1 -0
  175. package/lib/typescript/types/siwe/message.d.ts +57 -0
  176. package/lib/typescript/types/siwe/message.d.ts.map +1 -0
  177. package/lib/typescript/types/storage.d.ts +27 -0
  178. package/lib/typescript/types/storage.d.ts.map +1 -0
  179. package/lib/typescript/types/swap/index.d.ts +2 -0
  180. package/lib/typescript/types/swap/index.d.ts.map +1 -0
  181. package/lib/typescript/types/swap/tokens.d.ts +19 -0
  182. package/lib/typescript/types/swap/tokens.d.ts.map +1 -0
  183. package/lib/typescript/types/ui.d.ts +26 -0
  184. package/lib/typescript/types/ui.d.ts.map +1 -0
  185. package/lib/typescript/types/wallet/connection.d.ts +30 -0
  186. package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
  187. package/lib/typescript/types/wallet/connector.d.ts +61 -0
  188. package/lib/typescript/types/wallet/connector.d.ts.map +1 -0
  189. package/lib/typescript/types/wallet/index.d.ts +4 -0
  190. package/lib/typescript/types/wallet/index.d.ts.map +1 -0
  191. package/lib/typescript/types/wallet/wallet-info.d.ts +36 -0
  192. package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
  193. package/lib/typescript/utils/ConstantsUtil.d.ts +25 -5
  194. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  195. package/lib/typescript/utils/NetworkUtil.d.ts +2 -0
  196. package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
  197. package/package.json +1 -1
  198. package/src/adapters/BlockchainAdapter.ts +34 -15
  199. package/src/adapters/EvmAdapter.ts +1 -13
  200. package/src/adapters/__tests__/EvmAdapter.test.ts +2 -2
  201. package/src/index.ts +2 -1
  202. package/src/networks/bitcoin.ts +1 -1
  203. package/src/networks/solana.ts +1 -1
  204. package/src/types/api/blockchain-api.ts +213 -0
  205. package/src/types/api/events.ts +394 -0
  206. package/src/types/api/index.ts +4 -0
  207. package/src/types/api/wallet-api.ts +70 -0
  208. package/src/types/blockchain/adapter.ts +52 -0
  209. package/src/types/blockchain/balance.ts +31 -0
  210. package/src/types/blockchain/index.ts +5 -0
  211. package/src/types/blockchain/network.ts +39 -0
  212. package/src/types/blockchain/transaction.ts +71 -0
  213. package/src/types/common.ts +56 -0
  214. package/src/types/index.ts +28 -0
  215. package/src/types/onramp/countries.ts +11 -0
  216. package/src/types/onramp/currencies.ts +32 -0
  217. package/src/types/onramp/errors.ts +22 -0
  218. package/src/types/onramp/index.ts +5 -0
  219. package/src/types/onramp/quotes.ts +46 -0
  220. package/src/types/siwe/config.ts +44 -0
  221. package/src/types/siwe/index.ts +3 -0
  222. package/src/types/siwe/message.ts +62 -0
  223. package/src/types/storage.ts +30 -0
  224. package/src/types/swap/index.ts +2 -0
  225. package/src/types/swap/tokens.ts +21 -0
  226. package/src/types/ui.ts +26 -0
  227. package/src/types/wallet/connection.ts +33 -0
  228. package/src/types/wallet/connector.ts +85 -0
  229. package/src/types/wallet/index.ts +4 -0
  230. package/src/types/wallet/wallet-info.ts +41 -0
  231. package/src/utils/ConstantsUtil.ts +29 -9
  232. package/src/utils/NetworkUtil.ts +5 -0
  233. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  234. package/lib/module/utils/TypeUtil.js.map +0 -1
  235. package/lib/typescript/utils/TypeUtil.d.ts +0 -394
  236. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  237. package/src/utils/TypeUtil.ts +0 -493
@@ -0,0 +1,56 @@
1
+ // Common types used across the AppKit ecosystem
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 AccountType = 'eoa' | 'smartAccount';
12
+
13
+ export type SocialProvider =
14
+ | 'google'
15
+ | 'facebook'
16
+ | 'github'
17
+ | 'apple'
18
+ | 'x'
19
+ | 'discord'
20
+ | 'email'
21
+ | 'farcaster';
22
+
23
+ export type ThemeMode = 'dark' | 'light';
24
+
25
+ export interface ThemeVariables {
26
+ accent?: string;
27
+ }
28
+
29
+ export interface BaseError {
30
+ message?: string;
31
+ }
32
+
33
+ export type ProjectId = string;
34
+
35
+ export type Platform = 'mobile' | 'web' | 'qrcode' | 'email' | 'unsupported';
36
+
37
+ export type SdkType = 'appkit';
38
+
39
+ export type SdkVersion = `react-native-${string}-${string}`;
40
+
41
+ export type RequestCache =
42
+ | 'default'
43
+ | 'force-cache'
44
+ | 'no-cache'
45
+ | 'no-store'
46
+ | 'only-if-cached'
47
+ | 'reload';
48
+
49
+ export type CaipNamespaces = Record<
50
+ string,
51
+ {
52
+ chains: CaipNetworkId[];
53
+ methods: string[];
54
+ events: string[];
55
+ }
56
+ >;
@@ -0,0 +1,28 @@
1
+ // Main types barrel export - re-exports all types from all domains
2
+
3
+ // Common types
4
+ export * from './common';
5
+
6
+ // Blockchain types
7
+ export * from './blockchain';
8
+
9
+ // Wallet types
10
+ export * from './wallet';
11
+
12
+ // API types
13
+ export * from './api';
14
+
15
+ // Swap types
16
+ export * from './swap';
17
+
18
+ // OnRamp types
19
+ export * from './onramp';
20
+
21
+ // SIWE types
22
+ export * from './siwe';
23
+
24
+ // Storage types
25
+ export * from './storage';
26
+
27
+ // UI types
28
+ export * from './ui';
@@ -0,0 +1,11 @@
1
+ export type OnRampCountry = {
2
+ countryCode: string;
3
+ flagImageUrl: string;
4
+ name: string;
5
+ };
6
+
7
+ export type OnRampCountryDefaults = {
8
+ countryCode: string;
9
+ defaultCurrencyCode: string;
10
+ defaultPaymentMethods: string[];
11
+ };
@@ -0,0 +1,32 @@
1
+ export type OnRampFiatCurrency = {
2
+ currencyCode: string;
3
+ name: string;
4
+ symbolImageUrl: string;
5
+ };
6
+
7
+ export type OnRampCryptoCurrency = {
8
+ currencyCode: string;
9
+ name: string;
10
+ chainCode: string;
11
+ chainName: string;
12
+ chainId: string;
13
+ contractAddress: string | null;
14
+ symbolImageUrl: string;
15
+ };
16
+
17
+ export type OnRampFiatLimit = {
18
+ currencyCode: string;
19
+ defaultAmount: number | null;
20
+ minimumAmount: number;
21
+ maximumAmount: number;
22
+ };
23
+
24
+ export type OnRampTransactionResult = {
25
+ purchaseCurrency: string | null;
26
+ purchaseAmount: string | null;
27
+ purchaseImageUrl: string | null;
28
+ paymentCurrency: string | null;
29
+ paymentAmount: string | null;
30
+ status: string | null;
31
+ network: string | null;
32
+ };
@@ -0,0 +1,22 @@
1
+ export const OnRampErrorType = {
2
+ AMOUNT_TOO_LOW: 'INVALID_AMOUNT_TOO_LOW',
3
+ AMOUNT_TOO_HIGH: 'INVALID_AMOUNT_TOO_HIGH',
4
+ INVALID_AMOUNT: 'INVALID_AMOUNT',
5
+ INCOMPATIBLE_REQUEST: 'INCOMPATIBLE_REQUEST',
6
+ BAD_REQUEST: 'BAD_REQUEST',
7
+ NO_VALID_QUOTES: 'NO_VALID_QUOTES',
8
+ FAILED_TO_LOAD: 'FAILED_TO_LOAD',
9
+ FAILED_TO_LOAD_COUNTRIES: 'FAILED_TO_LOAD_COUNTRIES',
10
+ FAILED_TO_LOAD_PROVIDERS: 'FAILED_TO_LOAD_PROVIDERS',
11
+ FAILED_TO_LOAD_METHODS: 'FAILED_TO_LOAD_METHODS',
12
+ FAILED_TO_LOAD_CURRENCIES: 'FAILED_TO_LOAD_CURRENCIES',
13
+ FAILED_TO_LOAD_LIMITS: 'FAILED_TO_LOAD_LIMITS',
14
+ UNKNOWN: 'UNKNOWN_ERROR'
15
+ } as const;
16
+
17
+ export type OnRampErrorTypeValues = (typeof OnRampErrorType)[keyof typeof OnRampErrorType];
18
+
19
+ export interface OnRampError {
20
+ type: OnRampErrorTypeValues;
21
+ message: string;
22
+ }
@@ -0,0 +1,5 @@
1
+ // OnRamp types barrel export
2
+ export * from './countries';
3
+ export * from './currencies';
4
+ export * from './quotes';
5
+ export * from './errors';
@@ -0,0 +1,46 @@
1
+ export type OnRampPaymentMethod = {
2
+ logos: {
3
+ dark: string;
4
+ light: string;
5
+ };
6
+ name: string;
7
+ paymentMethod: string;
8
+ paymentType: string;
9
+ };
10
+
11
+ export type OnRampQuote = {
12
+ countryCode: string;
13
+ customerScore: number;
14
+ destinationAmount: number;
15
+ destinationAmountWithoutFees: number;
16
+ destinationCurrencyCode: string;
17
+ exchangeRate: number;
18
+ fiatAmountWithoutFees: number;
19
+ lowKyc: boolean;
20
+ networkFee: number;
21
+ paymentMethodType: string;
22
+ serviceProvider: string;
23
+ sourceAmount: number;
24
+ sourceAmountWithoutFees: number;
25
+ sourceCurrencyCode: string;
26
+ totalFee: number;
27
+ transactionFee: number;
28
+ transactionType: string;
29
+ };
30
+
31
+ export type OnRampServiceProvider = {
32
+ categories: string[];
33
+ categoryStatuses: {
34
+ additionalProp: string;
35
+ };
36
+ logos: {
37
+ dark: string;
38
+ darkShort: string;
39
+ light: string;
40
+ lightShort: string;
41
+ };
42
+ name: string;
43
+ serviceProvider: string;
44
+ status: string;
45
+ websiteUrl: string;
46
+ };
@@ -0,0 +1,44 @@
1
+ import type {
2
+ SIWESession,
3
+ SIWECreateMessageArgs,
4
+ SIWEMessageArgs,
5
+ SIWEVerifyMessageArgs
6
+ } from './message';
7
+
8
+ export interface SIWEClientMethods {
9
+ getNonce: (address?: string) => Promise<string>;
10
+ createMessage: (args: SIWECreateMessageArgs) => string;
11
+ verifyMessage: (args: SIWEVerifyMessageArgs) => Promise<boolean>;
12
+ getSession: () => Promise<SIWESession | null>;
13
+ signOut: () => Promise<boolean>;
14
+ getMessageParams?: () => Promise<SIWEMessageArgs>;
15
+ onSignIn?: (session?: SIWESession) => void;
16
+ onSignOut?: () => void;
17
+ }
18
+
19
+ export interface SIWEConfig extends SIWEClientMethods {
20
+ // Defaults to true
21
+ enabled?: boolean;
22
+ // In milliseconds, defaults to 5 minutes
23
+ nonceRefetchIntervalMs?: number;
24
+ // In milliseconds, defaults to 5 minutes
25
+ sessionRefetchIntervalMs?: number;
26
+ // Defaults to true
27
+ signOutOnDisconnect?: boolean;
28
+ // Defaults to true
29
+ signOutOnAccountChange?: boolean;
30
+ // Defaults to true
31
+ signOutOnNetworkChange?: boolean;
32
+ }
33
+
34
+ export interface AppKitSIWEClient extends SIWEClientMethods {
35
+ signIn: () => Promise<SIWESession | undefined>;
36
+ options: {
37
+ enabled: boolean;
38
+ nonceRefetchIntervalMs: number;
39
+ sessionRefetchIntervalMs: number;
40
+ signOutOnDisconnect: boolean;
41
+ signOutOnAccountChange: boolean;
42
+ signOutOnNetworkChange: boolean;
43
+ };
44
+ }
@@ -0,0 +1,3 @@
1
+ // SIWE types barrel export
2
+ export * from './config';
3
+ export * from './message';
@@ -0,0 +1,62 @@
1
+ import type { CaipAddress, CaipNetworkId } from '../common';
2
+
3
+ export interface SIWESession {
4
+ address: string;
5
+ chainId: number;
6
+ }
7
+
8
+ interface CacaoHeader {
9
+ t: 'caip122';
10
+ }
11
+
12
+ export interface SIWECreateMessageArgs {
13
+ domain: string;
14
+ nonce: string;
15
+ uri: string;
16
+ address: CaipAddress;
17
+ version: '1';
18
+ type?: CacaoHeader['t'];
19
+ nbf?: string;
20
+ exp?: string;
21
+ statement?: string;
22
+ requestId?: string;
23
+ resources?: string[];
24
+ expiry?: number;
25
+ iat?: string;
26
+ }
27
+
28
+ export type SIWEMessageArgs = {
29
+ chains: CaipNetworkId[];
30
+ methods?: string[];
31
+ } & Omit<SIWECreateMessageArgs, 'address' | 'nonce' | 'version'>;
32
+
33
+ interface CacaoPayload {
34
+ domain: string;
35
+ aud: string;
36
+ nonce: string;
37
+ iss: string;
38
+ version?: string;
39
+ iat?: string;
40
+ nbf?: string;
41
+ exp?: string;
42
+ statement?: string;
43
+ requestId?: string;
44
+ resources?: string[];
45
+ type?: string;
46
+ }
47
+
48
+ interface Cacao {
49
+ h: CacaoHeader;
50
+ p: CacaoPayload;
51
+ s: {
52
+ t: 'eip191' | 'eip1271';
53
+ s: string;
54
+ m?: string;
55
+ };
56
+ }
57
+
58
+ export interface SIWEVerifyMessageArgs {
59
+ message: string;
60
+ signature: string;
61
+ cacao?: Cacao;
62
+ }
@@ -0,0 +1,30 @@
1
+ export interface Storage {
2
+ /**
3
+ * Returns all keys in storage.
4
+ */
5
+ getKeys(): Promise<string[]>;
6
+
7
+ /**
8
+ * Returns all key-value entries in storage.
9
+ */
10
+ getEntries<T = any>(): Promise<[string, T][]>;
11
+
12
+ /**
13
+ * Get an item from storage for a given key.
14
+ * @param key The key to retrieve.
15
+ */
16
+ getItem<T = any>(key: string): Promise<T | undefined>;
17
+
18
+ /**
19
+ * Set an item in storage for a given key.
20
+ * @param key The key to set.
21
+ * @param value The value to set.
22
+ */
23
+ setItem<T = any>(key: string, value: T): Promise<void>;
24
+
25
+ /**
26
+ * Remove an item from storage for a given key.
27
+ * @param key The key to remove.
28
+ */
29
+ removeItem(key: string): Promise<void>;
30
+ }
@@ -0,0 +1,2 @@
1
+ // Swap types barrel export
2
+ export * from './tokens';
@@ -0,0 +1,21 @@
1
+ import type { CaipAddress } from '../common';
2
+
3
+ export type SwapToken = {
4
+ name: string;
5
+ symbol: string;
6
+ address: CaipAddress;
7
+ decimals: number;
8
+ logoUri: string;
9
+ eip2612?: boolean;
10
+ };
11
+
12
+ export type SwapTokenWithBalance = SwapToken & {
13
+ quantity: {
14
+ decimals: string;
15
+ numeric: string;
16
+ };
17
+ price: number;
18
+ value: number;
19
+ };
20
+
21
+ export type SwapInputTarget = 'sourceToken' | 'toToken';
@@ -0,0 +1,26 @@
1
+ import type { SocialProvider } from './common';
2
+
3
+ type EnabledSocials = SocialProvider;
4
+
5
+ export type Features = {
6
+ /**
7
+ * @description Enable or disable the swaps feature. Enabled by default.
8
+ * @type {boolean}
9
+ */
10
+ swaps?: boolean;
11
+ /**
12
+ * @description Enable or disable the onramp feature. Enabled by default.
13
+ * @type {boolean}
14
+ */
15
+ onramp?: boolean;
16
+ /**
17
+ * @description Show or hide the regular wallet options when socials are enabled. Enabled by default.
18
+ * @type {boolean}
19
+ */
20
+ showWallets?: boolean;
21
+ /**
22
+ * @description Enable or disable the socials feature. Enabled by default.
23
+ * @type {EnabledSocials[]}
24
+ */
25
+ socials?: EnabledSocials[] | false;
26
+ };
@@ -0,0 +1,33 @@
1
+ import type { CaipAddress, CaipNetworkId, SocialProvider, AccountType } from '../common';
2
+ import type { Balance } from '../blockchain/balance';
3
+ import type { WalletInfo, Identity } from './wallet-info';
4
+ import type { BlockchainAdapter } from '../../adapters/BlockchainAdapter';
5
+
6
+ export interface Connection {
7
+ accounts: CaipAddress[];
8
+ balances: Map<CaipAddress, Balance[]>;
9
+ adapter: BlockchainAdapter;
10
+ caipNetwork: CaipNetworkId;
11
+ wallet?: WalletInfo;
12
+ properties?: ConnectionProperties;
13
+ type?: AccountType;
14
+ identities?: Map<CaipAddress, Identity>;
15
+ }
16
+
17
+ export interface ConnectionProperties {
18
+ email?: string;
19
+ username?: string;
20
+ smartAccounts?: CaipAddress[];
21
+ provider?: SocialProvider;
22
+ sessionTopic?: string;
23
+ }
24
+
25
+ export interface LinkingRecord {
26
+ redirect: string;
27
+ href: string;
28
+ }
29
+
30
+ export interface WalletDeepLink {
31
+ href: string;
32
+ name: string;
33
+ }
@@ -0,0 +1,85 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { ChainNamespace, CaipAddress, CaipNetworkId } from '../common';
3
+ import type { AppKitNetwork } from '../blockchain/network';
4
+ import type { Provider } from '../blockchain/adapter';
5
+ import type { WalletInfo, Metadata } from './wallet-info';
6
+ import type { ConnectionProperties } from './connection';
7
+ import type { AppKitSIWEClient } from '../siwe';
8
+ import type { Storage } from '../storage';
9
+ import type { WcWallet } from '../api/wallet-api';
10
+
11
+ export type ConnectorType = 'walletconnect' | 'coinbase' | 'phantom' | 'solflare';
12
+
13
+ export interface BaseNamespace {
14
+ chains?: CaipNetworkId[];
15
+ accounts: CaipAddress[];
16
+ methods: string[];
17
+ events: string[];
18
+ }
19
+
20
+ type Namespace = BaseNamespace;
21
+
22
+ export type Namespaces = Record<string, Namespace>;
23
+
24
+ export type ProposalNamespaces = Record<
25
+ string,
26
+ Omit<Namespace, 'accounts'> &
27
+ Required<Pick<Namespace, 'chains'>> & { rpcMap: Record<string, string> }
28
+ >;
29
+
30
+ export type ConnectOptions = {
31
+ namespaces?: ProposalNamespaces;
32
+ defaultNetwork?: AppKitNetwork;
33
+ universalLink?: string;
34
+ siweConfig?: AppKitSIWEClient;
35
+ };
36
+
37
+ export type ConnectorInitOptions = {
38
+ storage: Storage;
39
+ metadata: Metadata;
40
+ };
41
+
42
+ export abstract class WalletConnector extends EventEmitter {
43
+ public type: ConnectorType;
44
+ protected provider?: Provider;
45
+ protected namespaces?: Namespaces;
46
+ protected wallet?: WalletInfo;
47
+ protected storage?: Storage;
48
+ protected metadata?: Metadata;
49
+ protected properties?: ConnectionProperties;
50
+
51
+ constructor({ type }: { type: ConnectorType }) {
52
+ super();
53
+ this.type = type;
54
+ }
55
+
56
+ public async init(ops: ConnectorInitOptions) {
57
+ this.storage = ops.storage;
58
+ this.metadata = ops.metadata;
59
+ }
60
+
61
+ public setProvider(provider: Provider) {
62
+ this.provider = provider;
63
+ }
64
+
65
+ public async disconnect() {
66
+ await this.provider?.disconnect();
67
+ this.namespaces = undefined;
68
+ this.wallet = undefined;
69
+ this.properties = undefined;
70
+ }
71
+
72
+ abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
73
+ abstract getProvider(namespace?: ChainNamespace): Provider;
74
+ abstract getNamespaces(): Namespaces;
75
+ abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
76
+ abstract getWalletInfo(): WalletInfo | undefined;
77
+ abstract getProperties(): ConnectionProperties | undefined;
78
+ abstract switchNetwork(network: AppKitNetwork): Promise<void>;
79
+ abstract restoreSession(): Promise<boolean>;
80
+ }
81
+
82
+ export type AppKitConnectOptions = {
83
+ walletId?: string;
84
+ wallet?: WcWallet;
85
+ };
@@ -0,0 +1,4 @@
1
+ // Wallet types barrel export
2
+ export * from './connector';
3
+ export * from './connection';
4
+ export * from './wallet-info';
@@ -0,0 +1,41 @@
1
+ import type { CaipNetworkId } from '../common';
2
+
3
+ export interface WalletInfo {
4
+ name?: string;
5
+ icon?: string;
6
+ description?: string;
7
+ url?: string;
8
+ icons?: string[];
9
+ redirect?: {
10
+ native?: string;
11
+ universal?: string;
12
+ linkMode?: boolean;
13
+ };
14
+ [key: string]: unknown;
15
+ }
16
+
17
+ export type Metadata = {
18
+ name: string;
19
+ description: string;
20
+ url: string;
21
+ icons: string[];
22
+ redirect?: {
23
+ native?: string;
24
+ universal?: string;
25
+ linkMode?: boolean;
26
+ };
27
+ };
28
+
29
+ export interface Token {
30
+ address: string;
31
+ image?: string;
32
+ }
33
+
34
+ export type Tokens = Record<CaipNetworkId, Token>;
35
+
36
+ export interface Identity {
37
+ name: string;
38
+ avatar?: string;
39
+ }
40
+
41
+ export type ConnectedWalletInfo = WalletInfo | undefined;
@@ -1,5 +1,5 @@
1
1
  export const ConstantsUtil = {
2
- VERSION: '2.0.0-alpha.2',
2
+ VERSION: '2.0.0-alpha.4',
3
3
 
4
4
  EIP155: 'eip155',
5
5
  ADD_CHAIN_METHOD: 'wallet_addEthereumChain',
@@ -14,11 +14,7 @@ export const ConstantsUtil = {
14
14
  WEB_WALLET_URL: 'https://web-wallet.walletconnect.org',
15
15
  SECURE_SITE_DASHBOARD: `https://secure.reown.com/dashboard`,
16
16
  SECURE_SITE_ICON: `https://secure.reown.com/images/favicon.png`,
17
-
18
- COINBASE_EXPLORER_ID: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
19
- PHANTOM_EXPLORER_ID: 'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393',
20
-
21
- WALLET_CONNECT_IMAGE_ID: 'ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400',
17
+ REOWN_URL: `https://reown.com`,
22
18
 
23
19
  USDT_CONTRACT_ADDRESSES: [
24
20
  // Mainnet
@@ -41,16 +37,40 @@ export const ConstantsUtil = {
41
37
  id: 'a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393',
42
38
  name: 'Phantom Wallet',
43
39
  image_id: 'b6ec7b81-bb4f-427d-e290-7631e6e50d00',
44
- mobile_link: 'phantom://'
40
+ mobile_link: 'phantom://',
41
+ play_store: 'https://play.google.com/store/apps/details?id=app.phantom',
42
+ app_store: 'https://apps.apple.com/app/id1598432977',
43
+ android_app_id: 'app.phantom',
44
+ ios_schema: 'phantom://'
45
+ },
46
+
47
+ COINBASE_CUSTOM_WALLET: {
48
+ id: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
49
+ name: 'Coinbase Wallet',
50
+ image_id: 'a5ebc364-8f91-4200-fcc6-be81310a0000',
51
+ mobile_link: 'https://wallet.coinbase.com/wsegue',
52
+ play_store: 'https://play.google.com/store/apps/details?id=org.toshi',
53
+ app_store: 'https://apps.apple.com/app/id1278383455',
54
+ android_app_id: 'org.toshi',
55
+ ios_schema: 'cbwallet://'
56
+ },
57
+
58
+ SOLFLARE_CUSTOM_WALLET: {
59
+ id: '1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79',
60
+ name: 'Solflare Wallet',
61
+ image_id: '34c0e38d-66c4-470e-1aed-a6fabe2d1e00',
62
+ mobile_link: 'solflare://',
63
+ play_store: 'https://play.google.com/store/apps/details?id=com.solflare.mobile',
64
+ app_store: 'https://apps.apple.com/app/id1580902717',
65
+ android_app_id: 'com.solflare.mobile',
66
+ ios_schema: 'solflare://'
45
67
  },
46
68
 
47
69
  // Storage Keys
48
70
  STORAGE_KEYS: {
49
71
  WC_DEEPLINK: 'WALLETCONNECT_DEEPLINK_CHOICE', //dont change this one
50
72
  RECENT_WALLET: '@appkit/recent_wallet',
51
- CONNECTED_WALLET_IMAGE_URL: '@appkit/connected_wallet_image_url',
52
73
  CONNECTED_CONNECTORS: '@appkit/connected_connectors',
53
- CONNECTED_SOCIAL: '@appkit/connected_social',
54
74
  ONRAMP_PREFERRED_COUNTRY: '@appkit/onramp_preferred_country',
55
75
  ONRAMP_COUNTRIES: '@appkit/onramp_countries',
56
76
  ONRAMP_SERVICE_PROVIDERS: '@appkit/onramp_service_providers',
@@ -1,5 +1,10 @@
1
+ import type { CaipAddress } from '../types';
2
+
1
3
  export const NetworkUtil = {
2
4
  caipNetworkIdToNumber(caipnetworkId?: `${string}:${string}`) {
3
5
  return caipnetworkId ? Number(caipnetworkId.split(':')[1]) : undefined;
6
+ },
7
+ getPlainAddress(caipAddress?: CaipAddress) {
8
+ return caipAddress?.split(':')[2];
4
9
  }
5
10
  };
@@ -1 +0,0 @@
1
- {"version":3,"names":["_events","require","WalletConnector","EventEmitter","constructor","type","init","ops","storage","metadata","setProvider","provider","disconnect","namespaces","undefined","wallet","properties","exports"],"sourceRoot":"../../../src","sources":["utils/TypeUtil.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAuMA;;AAgBA;;AAgBA;;AA8BO,MAAeC,eAAe,SAASC,oBAAY,CAAC;EASzDC,WAAWA,CAAC;IAAEC;EAA8B,CAAC,EAAE;IAC7C,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,IAAI,GAAGA,IAAI;EAClB;EAEA,MAAaC,IAAIA,CAACC,GAAyB,EAAE;IAC3C,IAAI,CAACC,OAAO,GAAGD,GAAG,CAACC,OAAO;IAC1B,IAAI,CAACC,QAAQ,GAAGF,GAAG,CAACE,QAAQ;EAC9B;EAEOC,WAAWA,CAACC,QAAkB,EAAE;IACrC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;EAEA,MAAaC,UAAUA,CAAA,EAAG;IACxB,MAAM,IAAI,CAACD,QAAQ,EAAEC,UAAU,CAAC,CAAC;IACjC,IAAI,CAACC,UAAU,GAAGC,SAAS;IAC3B,IAAI,CAACC,MAAM,GAAGD,SAAS;IACvB,IAAI,CAACE,UAAU,GAAGF,SAAS;EAC7B;AAUF;;AAIA;;AAmBA;;AAyEA;;AA6BA;AAAAG,OAAA,CAAAf,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["EventEmitter","WalletConnector","constructor","type","init","ops","storage","metadata","setProvider","provider","disconnect","namespaces","undefined","wallet","properties"],"sourceRoot":"../../../src","sources":["utils/TypeUtil.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,QAAQ;;AAuMrC;;AAgBA;;AAgBA;;AA8BA,OAAO,MAAeC,eAAe,SAASD,YAAY,CAAC;EASzDE,WAAWA,CAAC;IAAEC;EAA8B,CAAC,EAAE;IAC7C,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,IAAI,GAAGA,IAAI;EAClB;EAEA,MAAaC,IAAIA,CAACC,GAAyB,EAAE;IAC3C,IAAI,CAACC,OAAO,GAAGD,GAAG,CAACC,OAAO;IAC1B,IAAI,CAACC,QAAQ,GAAGF,GAAG,CAACE,QAAQ;EAC9B;EAEOC,WAAWA,CAACC,QAAkB,EAAE;IACrC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;EAEA,MAAaC,UAAUA,CAAA,EAAG;IACxB,MAAM,IAAI,CAACD,QAAQ,EAAEC,UAAU,CAAC,CAAC;IACjC,IAAI,CAACC,UAAU,GAAGC,SAAS;IAC3B,IAAI,CAACC,MAAM,GAAGD,SAAS;IACvB,IAAI,CAACE,UAAU,GAAGF,SAAS;EAC7B;AAUF;;AAIA;;AAmBA;;AAyEA;;AA6BA","ignoreList":[]}