@reown/appkit-common-react-native 2.0.0 → 2.0.1

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 (312) hide show
  1. package/lib/commonjs/adapters/BitcoinBaseAdapter.js +10 -0
  2. package/lib/commonjs/adapters/BitcoinBaseAdapter.js.map +1 -0
  3. package/lib/commonjs/adapters/BlockchainAdapter.js +38 -14
  4. package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -1
  5. package/lib/commonjs/adapters/EvmAdapter.js +126 -16
  6. package/lib/commonjs/adapters/EvmAdapter.js.map +1 -1
  7. package/lib/commonjs/adapters/SolanaBaseAdapter.js +1 -3
  8. package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -1
  9. package/lib/commonjs/contracts/erc20.js.map +1 -1
  10. package/lib/commonjs/contracts/usdt.js.map +1 -1
  11. package/lib/commonjs/index.js +13 -5
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/networks/bitcoin.js.map +1 -1
  14. package/lib/commonjs/networks/solana.js.map +1 -1
  15. package/lib/commonjs/package.json +1 -0
  16. package/lib/commonjs/types/api/blockchain-api.js +15 -0
  17. package/lib/commonjs/types/api/blockchain-api.js.map +1 -0
  18. package/lib/commonjs/types/api/events.js +6 -0
  19. package/lib/commonjs/types/api/events.js.map +1 -0
  20. package/lib/commonjs/types/api/index.js +39 -0
  21. package/lib/commonjs/types/api/index.js.map +1 -0
  22. package/lib/commonjs/types/api/wallet-api.js +6 -0
  23. package/lib/commonjs/types/api/wallet-api.js.map +1 -0
  24. package/lib/commonjs/types/blockchain/adapter.js +6 -0
  25. package/lib/commonjs/types/blockchain/adapter.js.map +1 -0
  26. package/lib/commonjs/types/blockchain/balance.js +6 -0
  27. package/lib/commonjs/types/blockchain/balance.js.map +1 -0
  28. package/lib/commonjs/types/blockchain/index.js +50 -0
  29. package/lib/commonjs/types/blockchain/index.js.map +1 -0
  30. package/lib/commonjs/types/blockchain/network.js +6 -0
  31. package/lib/commonjs/types/blockchain/network.js.map +1 -0
  32. package/lib/commonjs/types/blockchain/transaction.js +2 -0
  33. package/lib/commonjs/types/blockchain/transaction.js.map +1 -0
  34. package/lib/commonjs/types/common.js +2 -0
  35. package/lib/commonjs/types/common.js.map +1 -0
  36. package/lib/commonjs/types/index.js +105 -0
  37. package/lib/commonjs/types/index.js.map +1 -0
  38. package/lib/commonjs/types/onramp/countries.js +2 -0
  39. package/lib/commonjs/types/onramp/countries.js.map +1 -0
  40. package/lib/commonjs/types/onramp/currencies.js +2 -0
  41. package/lib/commonjs/types/onramp/currencies.js.map +1 -0
  42. package/lib/commonjs/types/onramp/errors.js +22 -0
  43. package/lib/commonjs/types/onramp/errors.js.map +1 -0
  44. package/lib/commonjs/types/onramp/index.js +50 -0
  45. package/lib/commonjs/types/onramp/index.js.map +1 -0
  46. package/lib/commonjs/types/onramp/quotes.js +2 -0
  47. package/lib/commonjs/types/onramp/quotes.js.map +1 -0
  48. package/lib/commonjs/types/siwx/config.js +6 -0
  49. package/lib/commonjs/types/siwx/config.js.map +1 -0
  50. package/lib/commonjs/types/siwx/index.js +50 -0
  51. package/lib/commonjs/types/siwx/index.js.map +1 -0
  52. package/lib/commonjs/types/siwx/message.js +6 -0
  53. package/lib/commonjs/types/siwx/message.js.map +1 -0
  54. package/lib/commonjs/types/siwx/storage.js +6 -0
  55. package/lib/commonjs/types/siwx/storage.js.map +1 -0
  56. package/lib/commonjs/types/siwx/verifier.js +35 -0
  57. package/lib/commonjs/types/siwx/verifier.js.map +1 -0
  58. package/lib/commonjs/types/storage.js +24 -0
  59. package/lib/commonjs/types/storage.js.map +1 -0
  60. package/lib/commonjs/types/swap/index.js +17 -0
  61. package/lib/commonjs/types/swap/index.js.map +1 -0
  62. package/lib/commonjs/types/swap/tokens.js +6 -0
  63. package/lib/commonjs/types/swap/tokens.js.map +1 -0
  64. package/lib/commonjs/types/ui.js +6 -0
  65. package/lib/commonjs/types/ui.js.map +1 -0
  66. package/lib/commonjs/types/wallet/connection.js +6 -0
  67. package/lib/commonjs/types/wallet/connection.js.map +1 -0
  68. package/lib/commonjs/{utils/TypeUtil.js → types/wallet/connector.js} +7 -13
  69. package/lib/commonjs/types/wallet/connector.js.map +1 -0
  70. package/lib/commonjs/types/wallet/index.js +39 -0
  71. package/lib/commonjs/types/wallet/index.js.map +1 -0
  72. package/lib/commonjs/types/wallet/wallet-info.js +6 -0
  73. package/lib/commonjs/types/wallet/wallet-info.js.map +1 -0
  74. package/lib/commonjs/utils/ConstantsUtil.js +45 -6
  75. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  76. package/lib/commonjs/utils/ContractUtil.js.map +1 -1
  77. package/lib/commonjs/utils/DateUtil.js.map +1 -1
  78. package/lib/commonjs/utils/ErrorUtil.js +2 -2
  79. package/lib/commonjs/utils/ErrorUtil.js.map +1 -1
  80. package/lib/commonjs/utils/NamesUtil.js.map +1 -1
  81. package/lib/commonjs/utils/NetworkUtil.js +3 -0
  82. package/lib/commonjs/utils/NetworkUtil.js.map +1 -1
  83. package/lib/commonjs/utils/NumberUtil.js +1 -2
  84. package/lib/commonjs/utils/NumberUtil.js.map +1 -1
  85. package/lib/commonjs/utils/PresetsUtil.js +0 -18
  86. package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
  87. package/lib/commonjs/utils/StringUtil.js +7 -0
  88. package/lib/commonjs/utils/StringUtil.js.map +1 -1
  89. package/lib/module/adapters/BitcoinBaseAdapter.js +5 -0
  90. package/lib/module/adapters/BitcoinBaseAdapter.js.map +1 -0
  91. package/lib/module/adapters/BlockchainAdapter.js +40 -14
  92. package/lib/module/adapters/BlockchainAdapter.js.map +1 -1
  93. package/lib/module/adapters/EvmAdapter.js +129 -16
  94. package/lib/module/adapters/EvmAdapter.js.map +1 -1
  95. package/lib/module/adapters/SolanaBaseAdapter.js +3 -3
  96. package/lib/module/adapters/SolanaBaseAdapter.js.map +1 -1
  97. package/lib/module/contracts/erc20.js +2 -0
  98. package/lib/module/contracts/erc20.js.map +1 -1
  99. package/lib/module/contracts/usdt.js +2 -0
  100. package/lib/module/contracts/usdt.js.map +1 -1
  101. package/lib/module/index.js +4 -1
  102. package/lib/module/index.js.map +1 -1
  103. package/lib/module/networks/bitcoin.js +2 -0
  104. package/lib/module/networks/bitcoin.js.map +1 -1
  105. package/lib/module/networks/solana.js +2 -0
  106. package/lib/module/networks/solana.js.map +1 -1
  107. package/lib/module/types/api/blockchain-api.js +10 -0
  108. package/lib/module/types/api/blockchain-api.js.map +1 -0
  109. package/lib/module/types/api/events.js +4 -0
  110. package/lib/module/types/api/events.js.map +1 -0
  111. package/lib/module/types/api/index.js +7 -0
  112. package/lib/module/types/api/index.js.map +1 -0
  113. package/lib/module/types/api/wallet-api.js +4 -0
  114. package/lib/module/types/api/wallet-api.js.map +1 -0
  115. package/lib/module/types/blockchain/adapter.js +4 -0
  116. package/lib/module/types/blockchain/adapter.js.map +1 -0
  117. package/lib/module/types/blockchain/balance.js +4 -0
  118. package/lib/module/types/blockchain/balance.js.map +1 -0
  119. package/lib/module/types/blockchain/index.js +8 -0
  120. package/lib/module/types/blockchain/index.js.map +1 -0
  121. package/lib/module/types/blockchain/network.js +4 -0
  122. package/lib/module/types/blockchain/network.js.map +1 -0
  123. package/lib/module/types/blockchain/transaction.js +2 -0
  124. package/lib/module/types/blockchain/transaction.js.map +1 -0
  125. package/lib/module/types/common.js +2 -0
  126. package/lib/module/types/common.js.map +1 -0
  127. package/lib/module/types/index.js +31 -0
  128. package/lib/module/types/index.js.map +1 -0
  129. package/lib/module/types/onramp/countries.js +2 -0
  130. package/lib/module/types/onramp/countries.js.map +1 -0
  131. package/lib/module/types/onramp/currencies.js +2 -0
  132. package/lib/module/types/onramp/currencies.js.map +1 -0
  133. package/lib/module/types/onramp/errors.js +18 -0
  134. package/lib/module/types/onramp/errors.js.map +1 -0
  135. package/lib/module/types/onramp/index.js +8 -0
  136. package/lib/module/types/onramp/index.js.map +1 -0
  137. package/lib/module/types/onramp/quotes.js +2 -0
  138. package/lib/module/types/onramp/quotes.js.map +1 -0
  139. package/lib/module/types/siwx/config.js +4 -0
  140. package/lib/module/types/siwx/config.js.map +1 -0
  141. package/lib/module/types/siwx/index.js +7 -0
  142. package/lib/module/types/siwx/index.js.map +1 -0
  143. package/lib/module/types/siwx/message.js +4 -0
  144. package/lib/module/types/siwx/message.js.map +1 -0
  145. package/lib/module/types/siwx/storage.js +4 -0
  146. package/lib/module/types/siwx/storage.js.map +1 -0
  147. package/lib/module/types/siwx/verifier.js +30 -0
  148. package/lib/module/types/siwx/verifier.js.map +1 -0
  149. package/lib/module/types/storage.js +20 -0
  150. package/lib/module/types/storage.js.map +1 -0
  151. package/lib/module/types/swap/index.js +5 -0
  152. package/lib/module/types/swap/index.js.map +1 -0
  153. package/lib/module/types/swap/tokens.js +4 -0
  154. package/lib/module/types/swap/tokens.js.map +1 -0
  155. package/lib/module/types/ui.js +4 -0
  156. package/lib/module/types/ui.js.map +1 -0
  157. package/lib/module/types/wallet/connection.js +4 -0
  158. package/lib/module/types/wallet/connection.js.map +1 -0
  159. package/lib/module/{utils/TypeUtil.js → types/wallet/connector.js} +9 -14
  160. package/lib/module/types/wallet/connector.js.map +1 -0
  161. package/lib/module/types/wallet/index.js +7 -0
  162. package/lib/module/types/wallet/index.js.map +1 -0
  163. package/lib/module/types/wallet/wallet-info.js +4 -0
  164. package/lib/module/types/wallet/wallet-info.js.map +1 -0
  165. package/lib/module/utils/ConstantsUtil.js +47 -6
  166. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  167. package/lib/module/utils/ContractUtil.js +2 -0
  168. package/lib/module/utils/ContractUtil.js.map +1 -1
  169. package/lib/module/utils/DateUtil.js +2 -0
  170. package/lib/module/utils/DateUtil.js.map +1 -1
  171. package/lib/module/utils/ErrorUtil.js +4 -2
  172. package/lib/module/utils/ErrorUtil.js.map +1 -1
  173. package/lib/module/utils/NamesUtil.js +2 -0
  174. package/lib/module/utils/NamesUtil.js.map +1 -1
  175. package/lib/module/utils/NetworkUtil.js +5 -0
  176. package/lib/module/utils/NetworkUtil.js.map +1 -1
  177. package/lib/module/utils/NumberUtil.js +2 -0
  178. package/lib/module/utils/NumberUtil.js.map +1 -1
  179. package/lib/module/utils/PresetsUtil.js +2 -18
  180. package/lib/module/utils/PresetsUtil.js.map +1 -1
  181. package/lib/module/utils/StringUtil.js +9 -0
  182. package/lib/module/utils/StringUtil.js.map +1 -1
  183. package/lib/typescript/adapters/BitcoinBaseAdapter.d.ts +5 -0
  184. package/lib/typescript/adapters/BitcoinBaseAdapter.d.ts.map +1 -0
  185. package/lib/typescript/adapters/BlockchainAdapter.d.ts +6 -7
  186. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -1
  187. package/lib/typescript/adapters/EvmAdapter.d.ts +21 -1
  188. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -1
  189. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +3 -0
  190. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -1
  191. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts +2 -0
  192. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts.map +1 -0
  193. package/lib/typescript/index.d.ts +2 -1
  194. package/lib/typescript/index.d.ts.map +1 -1
  195. package/lib/typescript/networks/bitcoin.d.ts +1 -1
  196. package/lib/typescript/networks/bitcoin.d.ts.map +1 -1
  197. package/lib/typescript/networks/solana.d.ts +1 -1
  198. package/lib/typescript/networks/solana.d.ts.map +1 -1
  199. package/lib/typescript/types/api/blockchain-api.d.ts +183 -0
  200. package/lib/typescript/types/api/blockchain-api.d.ts.map +1 -0
  201. package/lib/typescript/types/api/events.d.ts +357 -0
  202. package/lib/typescript/types/api/events.d.ts.map +1 -0
  203. package/lib/typescript/types/api/index.d.ts +4 -0
  204. package/lib/typescript/types/api/index.d.ts.map +1 -0
  205. package/lib/typescript/types/api/wallet-api.d.ts +51 -0
  206. package/lib/typescript/types/api/wallet-api.d.ts.map +1 -0
  207. package/lib/typescript/types/blockchain/adapter.d.ts +40 -0
  208. package/lib/typescript/types/blockchain/adapter.d.ts.map +1 -0
  209. package/lib/typescript/types/blockchain/balance.d.ts +28 -0
  210. package/lib/typescript/types/blockchain/balance.d.ts.map +1 -0
  211. package/lib/typescript/types/blockchain/index.d.ts +5 -0
  212. package/lib/typescript/types/blockchain/index.d.ts.map +1 -0
  213. package/lib/typescript/types/blockchain/network.d.ts +47 -0
  214. package/lib/typescript/types/blockchain/network.d.ts.map +1 -0
  215. package/lib/typescript/types/blockchain/transaction.d.ts +63 -0
  216. package/lib/typescript/types/blockchain/transaction.d.ts.map +1 -0
  217. package/lib/typescript/types/common.d.ts +24 -0
  218. package/lib/typescript/types/common.d.ts.map +1 -0
  219. package/lib/typescript/types/index.d.ts +10 -0
  220. package/lib/typescript/types/index.d.ts.map +1 -0
  221. package/lib/typescript/types/onramp/countries.d.ts +11 -0
  222. package/lib/typescript/types/onramp/countries.d.ts.map +1 -0
  223. package/lib/typescript/types/onramp/currencies.d.ts +30 -0
  224. package/lib/typescript/types/onramp/currencies.d.ts.map +1 -0
  225. package/lib/typescript/types/onramp/errors.d.ts +21 -0
  226. package/lib/typescript/types/onramp/errors.d.ts.map +1 -0
  227. package/lib/typescript/types/onramp/index.d.ts +5 -0
  228. package/lib/typescript/types/onramp/index.d.ts.map +1 -0
  229. package/lib/typescript/types/onramp/quotes.d.ts +45 -0
  230. package/lib/typescript/types/onramp/quotes.d.ts.map +1 -0
  231. package/lib/typescript/types/siwx/config.d.ts +73 -0
  232. package/lib/typescript/types/siwx/config.d.ts.map +1 -0
  233. package/lib/typescript/types/siwx/index.d.ts +5 -0
  234. package/lib/typescript/types/siwx/index.d.ts.map +1 -0
  235. package/lib/typescript/types/siwx/message.d.ts +92 -0
  236. package/lib/typescript/types/siwx/message.d.ts.map +1 -0
  237. package/lib/typescript/types/siwx/storage.d.ts +41 -0
  238. package/lib/typescript/types/siwx/storage.d.ts.map +1 -0
  239. package/lib/typescript/types/siwx/verifier.d.ts +28 -0
  240. package/lib/typescript/types/siwx/verifier.d.ts.map +1 -0
  241. package/lib/typescript/types/storage.d.ts +59 -0
  242. package/lib/typescript/types/storage.d.ts.map +1 -0
  243. package/lib/typescript/types/swap/index.d.ts +2 -0
  244. package/lib/typescript/types/swap/index.d.ts.map +1 -0
  245. package/lib/typescript/types/swap/tokens.d.ts +19 -0
  246. package/lib/typescript/types/swap/tokens.d.ts.map +1 -0
  247. package/lib/typescript/types/ui.d.ts +26 -0
  248. package/lib/typescript/types/ui.d.ts.map +1 -0
  249. package/lib/typescript/types/wallet/connection.d.ts +31 -0
  250. package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
  251. package/lib/typescript/types/wallet/connector.d.ts +59 -0
  252. package/lib/typescript/types/wallet/connector.d.ts.map +1 -0
  253. package/lib/typescript/types/wallet/index.d.ts +4 -0
  254. package/lib/typescript/types/wallet/index.d.ts.map +1 -0
  255. package/lib/typescript/types/wallet/wallet-info.d.ts +37 -0
  256. package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
  257. package/lib/typescript/utils/ConstantsUtil.d.ts +43 -4
  258. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  259. package/lib/typescript/utils/NetworkUtil.d.ts +2 -0
  260. package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
  261. package/lib/typescript/utils/PresetsUtil.d.ts +0 -5
  262. package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
  263. package/lib/typescript/utils/StringUtil.d.ts +1 -0
  264. package/lib/typescript/utils/StringUtil.d.ts.map +1 -1
  265. package/package.json +10 -19
  266. package/src/adapters/BitcoinBaseAdapter.ts +5 -0
  267. package/src/adapters/BlockchainAdapter.ts +48 -21
  268. package/src/adapters/EvmAdapter.ts +186 -18
  269. package/src/adapters/SolanaBaseAdapter.ts +3 -1
  270. package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
  271. package/src/index.ts +3 -1
  272. package/src/networks/bitcoin.ts +1 -1
  273. package/src/networks/solana.ts +1 -1
  274. package/src/types/api/blockchain-api.ts +213 -0
  275. package/src/types/api/events.ts +462 -0
  276. package/src/types/api/index.ts +4 -0
  277. package/src/types/api/wallet-api.ts +71 -0
  278. package/src/types/blockchain/adapter.ts +52 -0
  279. package/src/types/blockchain/balance.ts +31 -0
  280. package/src/types/blockchain/index.ts +5 -0
  281. package/src/types/blockchain/network.ts +39 -0
  282. package/src/types/blockchain/transaction.ts +71 -0
  283. package/src/types/common.ts +56 -0
  284. package/src/types/index.ts +28 -0
  285. package/src/types/onramp/countries.ts +11 -0
  286. package/src/types/onramp/currencies.ts +32 -0
  287. package/src/types/onramp/errors.ts +22 -0
  288. package/src/types/onramp/index.ts +5 -0
  289. package/src/types/onramp/quotes.ts +46 -0
  290. package/src/types/siwx/config.ts +73 -0
  291. package/src/types/siwx/index.ts +4 -0
  292. package/src/types/siwx/message.ts +92 -0
  293. package/src/types/siwx/storage.ts +44 -0
  294. package/src/types/siwx/verifier.ts +32 -0
  295. package/src/types/storage.ts +64 -0
  296. package/src/types/swap/index.ts +2 -0
  297. package/src/types/swap/tokens.ts +21 -0
  298. package/src/types/ui.ts +26 -0
  299. package/src/types/wallet/connection.ts +34 -0
  300. package/src/types/wallet/connector.ts +83 -0
  301. package/src/types/wallet/index.ts +4 -0
  302. package/src/types/wallet/wallet-info.ts +42 -0
  303. package/src/utils/ConstantsUtil.ts +48 -7
  304. package/src/utils/ErrorUtil.ts +2 -2
  305. package/src/utils/NetworkUtil.ts +5 -0
  306. package/src/utils/PresetsUtil.ts +0 -25
  307. package/src/utils/StringUtil.ts +7 -0
  308. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  309. package/lib/module/utils/TypeUtil.js.map +0 -1
  310. package/lib/typescript/utils/TypeUtil.d.ts +0 -276
  311. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  312. package/src/utils/TypeUtil.ts +0 -336
@@ -1,336 +0,0 @@
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 interface CaipNetwork {
38
- id: CaipNetworkId;
39
- name?: string;
40
- imageId?: string;
41
- imageUrl?: string;
42
- }
43
-
44
- export interface Balance {
45
- name: string;
46
- symbol: string;
47
- chainId: string;
48
- address?: CaipAddress;
49
- value?: number;
50
- price: number;
51
- quantity: BalanceQuantity;
52
- iconUrl: string;
53
- }
54
-
55
- type BalanceQuantity = {
56
- decimals: string;
57
- numeric: string;
58
- };
59
-
60
- export type TransactionStatus = 'confirmed' | 'failed' | 'pending';
61
- export type TransactionDirection = 'in' | 'out' | 'self';
62
- export type TransactionImage = {
63
- type: 'FUNGIBLE' | 'NFT' | undefined;
64
- url: string | undefined;
65
- };
66
-
67
- export interface Transaction {
68
- id: string;
69
- metadata: TransactionMetadata;
70
- transfers: TransactionTransfer[];
71
- }
72
-
73
- export interface TransactionMetadata {
74
- application: {
75
- iconUrl: string | null;
76
- name: string | null;
77
- };
78
- operationType: string;
79
- hash: string;
80
- minedAt: string;
81
- sentFrom: string;
82
- sentTo: string;
83
- status: TransactionStatus;
84
- nonce: number;
85
- chain?: string;
86
- }
87
-
88
- export interface TransactionTransfer {
89
- fungible_info?: {
90
- name?: string;
91
- symbol?: string;
92
- icon?: {
93
- url: string;
94
- };
95
- };
96
- nft_info?: TransactionNftInfo;
97
- direction: TransactionDirection;
98
- quantity: TransactionQuantity;
99
- value?: number;
100
- price?: number;
101
- }
102
-
103
- export interface TransactionNftInfo {
104
- name?: string;
105
- content?: TransactionContent;
106
- flags: TransactionNftInfoFlags;
107
- }
108
-
109
- export interface TransactionNftInfoFlags {
110
- is_spam: boolean;
111
- }
112
-
113
- export interface TransactionContent {
114
- preview?: TransactionPreview;
115
- detail?: TransactionDetail;
116
- }
117
-
118
- export interface TransactionPreview {
119
- url: string;
120
- content_type?: null;
121
- }
122
-
123
- export interface TransactionDetail {
124
- url: string;
125
- content_type?: null;
126
- }
127
-
128
- export interface TransactionQuantity {
129
- numeric: string;
130
- }
131
-
132
- export type SocialProvider = 'apple' | 'x' | 'discord' | 'farcaster';
133
-
134
- export type ThemeMode = 'dark' | 'light';
135
-
136
- export interface ThemeVariables {
137
- accent?: string;
138
- }
139
-
140
- export interface Token {
141
- address: string;
142
- image?: string;
143
- }
144
-
145
- export type Tokens = Record<CaipNetworkId, Token>;
146
-
147
- export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
148
-
149
- export type Metadata = {
150
- name: string;
151
- description: string;
152
- url: string;
153
- icons: string[];
154
- redirect?: {
155
- native?: string;
156
- universal?: string;
157
- linkMode?: boolean;
158
- };
159
- };
160
-
161
- //********** Adapter Event Payloads **********//
162
- export type AccountsChangedEvent = {
163
- accounts: string[];
164
- };
165
-
166
- export type ChainChangedEvent = {
167
- chainId: string;
168
- };
169
-
170
- export type DisconnectEvent = {};
171
-
172
- export type BalanceChangedEvent = {
173
- address: CaipAddress;
174
- balance: {
175
- amount: string;
176
- symbol: string;
177
- contractAddress?: ContractAddress;
178
- };
179
- };
180
-
181
- //********** Adapter Event Map **********//
182
- export interface AdapterEvents {
183
- accountsChanged: (event: AccountsChangedEvent) => void;
184
- chainChanged: (event: ChainChangedEvent) => void;
185
- disconnect: (event: DisconnectEvent) => void;
186
- balanceChanged: (event: BalanceChangedEvent) => void;
187
- }
188
-
189
- export interface GetBalanceParams {
190
- address?: CaipAddress;
191
- network?: AppKitNetwork;
192
- tokens?: Tokens;
193
- }
194
-
195
- type ContractAddress = CaipAddress;
196
-
197
- export interface GetBalanceResponse {
198
- amount: string;
199
- symbol: string;
200
- contractAddress?: ContractAddress;
201
- }
202
-
203
- //********** Connector Types **********//
204
- interface BaseNamespace {
205
- chains?: CaipNetworkId[];
206
- accounts: CaipAddress[];
207
- methods: string[];
208
- events: string[];
209
- }
210
-
211
- type Namespace = BaseNamespace;
212
-
213
- export type Namespaces = Record<string, Namespace>;
214
-
215
- export type ProposalNamespaces = Record<
216
- string,
217
- Omit<Namespace, 'accounts'> &
218
- Required<Pick<Namespace, 'chains'>> & { rpcMap: Record<string, string> }
219
- >;
220
-
221
- export type ConnectOptions = {
222
- namespaces?: ProposalNamespaces;
223
- defaultChain?: CaipNetworkId;
224
- universalLink?: string;
225
- };
226
-
227
- export type ConnectorInitOptions = {
228
- storage: Storage;
229
- metadata: Metadata;
230
- };
231
-
232
- export abstract class WalletConnector extends EventEmitter {
233
- public type: New_ConnectorType;
234
- protected provider?: Provider;
235
- protected namespaces?: Namespaces;
236
- protected wallet?: WalletInfo;
237
- protected storage?: Storage;
238
- protected metadata?: Metadata;
239
-
240
- constructor({ type }: { type: New_ConnectorType }) {
241
- super();
242
- this.type = type;
243
- }
244
-
245
- public async init(ops: ConnectorInitOptions) {
246
- this.storage = ops.storage;
247
- this.metadata = ops.metadata;
248
- }
249
-
250
- public setProvider(provider: Provider) {
251
- this.provider = provider;
252
- }
253
-
254
- abstract connect(opts: ConnectOptions): Promise<Namespaces | undefined>;
255
- abstract disconnect(): Promise<void>;
256
- abstract getProvider(): Provider;
257
- abstract getNamespaces(): Namespaces;
258
- abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
259
- abstract getWalletInfo(): WalletInfo | undefined;
260
- abstract switchNetwork(network: AppKitNetwork): Promise<void>;
261
- }
262
-
263
- //********** Provider Types **********//
264
-
265
- export interface Provider {
266
- connect<T>(params?: any): Promise<T>;
267
- disconnect(): Promise<void>;
268
- request<T = unknown>(
269
- args: RequestArguments,
270
- chain?: string | undefined,
271
- expiry?: number | undefined
272
- ): Promise<T>;
273
- on(event: string, listener: (args?: any) => void): any;
274
- off(event: string, listener: (args?: any) => void): any;
275
- }
276
-
277
- export interface RequestArguments {
278
- method: string;
279
- params?: unknown[] | Record<string, unknown> | object | undefined;
280
- }
281
-
282
- //TODO: rename this and remove the old one ConnectorType
283
- export type New_ConnectorType = 'walletconnect' | 'coinbase' | 'auth' | 'phantom';
284
-
285
- //********** Others **********//
286
-
287
- export interface ConnectionResponse {
288
- accounts: string[];
289
- chainId: string;
290
- [key: string]: any;
291
- }
292
-
293
- export interface WalletInfo {
294
- name?: string;
295
- icon?: string;
296
- description?: string;
297
- url?: string;
298
- icons?: string[];
299
- redirect?: {
300
- native?: string;
301
- universal?: string;
302
- linkMode?: boolean;
303
- };
304
- [key: string]: unknown;
305
- }
306
-
307
- export interface Storage {
308
- /**
309
- * Returns all keys in storage.
310
- */
311
- getKeys(): Promise<string[]>;
312
-
313
- /**
314
- * Returns all key-value entries in storage.
315
- */
316
- getEntries<T = any>(): Promise<[string, T][]>;
317
-
318
- /**
319
- * Get an item from storage for a given key.
320
- * @param key The key to retrieve.
321
- */
322
- getItem<T = any>(key: string): Promise<T | undefined>;
323
-
324
- /**
325
- * Set an item in storage for a given key.
326
- * @param key The key to set.
327
- * @param value The value to set.
328
- */
329
- setItem<T = any>(key: string, value: T): Promise<void>;
330
-
331
- /**
332
- * Remove an item from storage for a given key.
333
- * @param key The key to remove.
334
- */
335
- removeItem(key: string): Promise<void>;
336
- }