@reown/appkit-common-react-native 0.0.0-fix-approved-networks-20250822000414 → 0.0.0-fix-improvements-20250827190629

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 (292) hide show
  1. package/lib/commonjs/adapters/BlockchainAdapter.js +94 -0
  2. package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
  3. package/lib/commonjs/adapters/EvmAdapter.js +193 -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/contracts/erc20.js.map +1 -1
  8. package/lib/commonjs/contracts/usdt.js.map +1 -1
  9. package/lib/commonjs/index.js +66 -5
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/networks/bitcoin.js +40 -0
  12. package/lib/commonjs/networks/bitcoin.js.map +1 -0
  13. package/lib/commonjs/networks/solana.js +78 -0
  14. package/lib/commonjs/networks/solana.js.map +1 -0
  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/siwe/config.js +6 -0
  49. package/lib/commonjs/types/siwe/config.js.map +1 -0
  50. package/lib/commonjs/types/siwe/index.js +28 -0
  51. package/lib/commonjs/types/siwe/index.js.map +1 -0
  52. package/lib/commonjs/types/siwe/message.js +6 -0
  53. package/lib/commonjs/types/siwe/message.js.map +1 -0
  54. package/lib/commonjs/types/storage.js +2 -0
  55. package/lib/commonjs/types/storage.js.map +1 -0
  56. package/lib/commonjs/types/swap/index.js +17 -0
  57. package/lib/commonjs/types/swap/index.js.map +1 -0
  58. package/lib/commonjs/types/swap/tokens.js +6 -0
  59. package/lib/commonjs/types/swap/tokens.js.map +1 -0
  60. package/lib/commonjs/types/ui.js +6 -0
  61. package/lib/commonjs/{utils/TypeUtil.js.map → types/ui.js.map} +1 -1
  62. package/lib/commonjs/types/wallet/connection.js +6 -0
  63. package/lib/commonjs/types/wallet/connection.js.map +1 -0
  64. package/lib/commonjs/types/wallet/connector.js +30 -0
  65. package/lib/commonjs/types/wallet/connector.js.map +1 -0
  66. package/lib/commonjs/types/wallet/index.js +39 -0
  67. package/lib/commonjs/types/wallet/index.js.map +1 -0
  68. package/lib/commonjs/types/wallet/wallet-info.js +6 -0
  69. package/lib/commonjs/types/wallet/wallet-info.js.map +1 -0
  70. package/lib/commonjs/utils/ConstantsUtil.js +52 -6
  71. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  72. package/lib/commonjs/utils/ContractUtil.js.map +1 -1
  73. package/lib/commonjs/utils/DateUtil.js.map +1 -1
  74. package/lib/commonjs/utils/ErrorUtil.js.map +1 -1
  75. package/lib/commonjs/utils/NamesUtil.js.map +1 -1
  76. package/lib/commonjs/utils/NetworkUtil.js +3 -0
  77. package/lib/commonjs/utils/NetworkUtil.js.map +1 -1
  78. package/lib/commonjs/utils/NumberUtil.js +53 -13
  79. package/lib/commonjs/utils/NumberUtil.js.map +1 -1
  80. package/lib/commonjs/utils/PresetsUtil.js +34 -21
  81. package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
  82. package/lib/commonjs/utils/StringUtil.js +7 -0
  83. package/lib/commonjs/utils/StringUtil.js.map +1 -1
  84. package/lib/module/adapters/BlockchainAdapter.js +89 -0
  85. package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
  86. package/lib/module/adapters/EvmAdapter.js +189 -0
  87. package/lib/module/adapters/EvmAdapter.js.map +1 -0
  88. package/lib/module/adapters/SolanaBaseAdapter.js +5 -0
  89. package/lib/module/adapters/SolanaBaseAdapter.js.map +1 -0
  90. package/lib/module/contracts/erc20.js +2 -0
  91. package/lib/module/contracts/erc20.js.map +1 -1
  92. package/lib/module/contracts/usdt.js +2 -0
  93. package/lib/module/contracts/usdt.js.map +1 -1
  94. package/lib/module/index.js +8 -1
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/networks/bitcoin.js +36 -0
  97. package/lib/module/networks/bitcoin.js.map +1 -0
  98. package/lib/module/networks/solana.js +74 -0
  99. package/lib/module/networks/solana.js.map +1 -0
  100. package/lib/module/types/api/blockchain-api.js +10 -0
  101. package/lib/module/types/api/blockchain-api.js.map +1 -0
  102. package/lib/module/types/api/events.js +4 -0
  103. package/lib/module/types/api/events.js.map +1 -0
  104. package/lib/module/types/api/index.js +7 -0
  105. package/lib/module/types/api/index.js.map +1 -0
  106. package/lib/module/types/api/wallet-api.js +4 -0
  107. package/lib/module/types/api/wallet-api.js.map +1 -0
  108. package/lib/module/types/blockchain/adapter.js +4 -0
  109. package/lib/module/types/blockchain/adapter.js.map +1 -0
  110. package/lib/module/types/blockchain/balance.js +4 -0
  111. package/lib/module/types/blockchain/balance.js.map +1 -0
  112. package/lib/module/types/blockchain/index.js +8 -0
  113. package/lib/module/types/blockchain/index.js.map +1 -0
  114. package/lib/module/types/blockchain/network.js +4 -0
  115. package/lib/module/types/blockchain/network.js.map +1 -0
  116. package/lib/module/types/blockchain/transaction.js +2 -0
  117. package/lib/module/types/blockchain/transaction.js.map +1 -0
  118. package/lib/module/types/common.js +2 -0
  119. package/lib/module/types/common.js.map +1 -0
  120. package/lib/module/types/index.js +31 -0
  121. package/lib/module/types/index.js.map +1 -0
  122. package/lib/module/types/onramp/countries.js +2 -0
  123. package/lib/module/types/onramp/countries.js.map +1 -0
  124. package/lib/module/types/onramp/currencies.js +2 -0
  125. package/lib/module/types/onramp/currencies.js.map +1 -0
  126. package/lib/module/types/onramp/errors.js +18 -0
  127. package/lib/module/types/onramp/errors.js.map +1 -0
  128. package/lib/module/types/onramp/index.js +8 -0
  129. package/lib/module/types/onramp/index.js.map +1 -0
  130. package/lib/module/types/onramp/quotes.js +2 -0
  131. package/lib/module/types/onramp/quotes.js.map +1 -0
  132. package/lib/module/types/siwe/config.js +4 -0
  133. package/lib/module/types/siwe/config.js.map +1 -0
  134. package/lib/module/types/siwe/index.js +6 -0
  135. package/lib/module/types/siwe/index.js.map +1 -0
  136. package/lib/module/types/siwe/message.js +4 -0
  137. package/lib/module/types/siwe/message.js.map +1 -0
  138. package/lib/module/types/storage.js +2 -0
  139. package/lib/module/types/storage.js.map +1 -0
  140. package/lib/module/types/swap/index.js +5 -0
  141. package/lib/module/types/swap/index.js.map +1 -0
  142. package/lib/module/types/swap/tokens.js +4 -0
  143. package/lib/module/types/swap/tokens.js.map +1 -0
  144. package/lib/module/types/ui.js +4 -0
  145. package/lib/module/{utils/TypeUtil.js.map → types/ui.js.map} +1 -1
  146. package/lib/module/types/wallet/connection.js +4 -0
  147. package/lib/module/types/wallet/connection.js.map +1 -0
  148. package/lib/module/types/wallet/connector.js +25 -0
  149. package/lib/module/types/wallet/connector.js.map +1 -0
  150. package/lib/module/types/wallet/index.js +7 -0
  151. package/lib/module/types/wallet/index.js.map +1 -0
  152. package/lib/module/types/wallet/wallet-info.js +4 -0
  153. package/lib/module/types/wallet/wallet-info.js.map +1 -0
  154. package/lib/module/utils/ConstantsUtil.js +54 -6
  155. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  156. package/lib/module/utils/ContractUtil.js +2 -0
  157. package/lib/module/utils/ContractUtil.js.map +1 -1
  158. package/lib/module/utils/DateUtil.js +2 -0
  159. package/lib/module/utils/DateUtil.js.map +1 -1
  160. package/lib/module/utils/ErrorUtil.js +2 -0
  161. package/lib/module/utils/ErrorUtil.js.map +1 -1
  162. package/lib/module/utils/NamesUtil.js +2 -0
  163. package/lib/module/utils/NamesUtil.js.map +1 -1
  164. package/lib/module/utils/NetworkUtil.js +5 -0
  165. package/lib/module/utils/NetworkUtil.js.map +1 -1
  166. package/lib/module/utils/NumberUtil.js +54 -11
  167. package/lib/module/utils/NumberUtil.js.map +1 -1
  168. package/lib/module/utils/PresetsUtil.js +36 -21
  169. package/lib/module/utils/PresetsUtil.js.map +1 -1
  170. package/lib/module/utils/StringUtil.js +9 -0
  171. package/lib/module/utils/StringUtil.js.map +1 -1
  172. package/lib/typescript/adapters/BlockchainAdapter.d.ts +26 -0
  173. package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
  174. package/lib/typescript/adapters/EvmAdapter.d.ts +26 -0
  175. package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -0
  176. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +6 -0
  177. package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -0
  178. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts +2 -0
  179. package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts.map +1 -0
  180. package/lib/typescript/index.d.ts +6 -1
  181. package/lib/typescript/index.d.ts.map +1 -1
  182. package/lib/typescript/networks/bitcoin.d.ts +4 -0
  183. package/lib/typescript/networks/bitcoin.d.ts.map +1 -0
  184. package/lib/typescript/networks/solana.d.ts +5 -0
  185. package/lib/typescript/networks/solana.d.ts.map +1 -0
  186. package/lib/typescript/types/api/blockchain-api.d.ts +183 -0
  187. package/lib/typescript/types/api/blockchain-api.d.ts.map +1 -0
  188. package/lib/typescript/types/api/events.d.ts +304 -0
  189. package/lib/typescript/types/api/events.d.ts.map +1 -0
  190. package/lib/typescript/types/api/index.d.ts +4 -0
  191. package/lib/typescript/types/api/index.d.ts.map +1 -0
  192. package/lib/typescript/types/api/wallet-api.d.ts +50 -0
  193. package/lib/typescript/types/api/wallet-api.d.ts.map +1 -0
  194. package/lib/typescript/types/blockchain/adapter.d.ts +40 -0
  195. package/lib/typescript/types/blockchain/adapter.d.ts.map +1 -0
  196. package/lib/typescript/types/blockchain/balance.d.ts +28 -0
  197. package/lib/typescript/types/blockchain/balance.d.ts.map +1 -0
  198. package/lib/typescript/types/blockchain/index.d.ts +5 -0
  199. package/lib/typescript/types/blockchain/index.d.ts.map +1 -0
  200. package/lib/typescript/types/blockchain/network.d.ts +47 -0
  201. package/lib/typescript/types/blockchain/network.d.ts.map +1 -0
  202. package/lib/typescript/{utils/TypeUtil.d.ts → types/blockchain/transaction.d.ts} +1 -22
  203. package/lib/typescript/types/blockchain/transaction.d.ts.map +1 -0
  204. package/lib/typescript/types/common.d.ts +24 -0
  205. package/lib/typescript/types/common.d.ts.map +1 -0
  206. package/lib/typescript/types/index.d.ts +10 -0
  207. package/lib/typescript/types/index.d.ts.map +1 -0
  208. package/lib/typescript/types/onramp/countries.d.ts +11 -0
  209. package/lib/typescript/types/onramp/countries.d.ts.map +1 -0
  210. package/lib/typescript/types/onramp/currencies.d.ts +30 -0
  211. package/lib/typescript/types/onramp/currencies.d.ts.map +1 -0
  212. package/lib/typescript/types/onramp/errors.d.ts +21 -0
  213. package/lib/typescript/types/onramp/errors.d.ts.map +1 -0
  214. package/lib/typescript/types/onramp/index.d.ts +5 -0
  215. package/lib/typescript/types/onramp/index.d.ts.map +1 -0
  216. package/lib/typescript/types/onramp/quotes.d.ts +45 -0
  217. package/lib/typescript/types/onramp/quotes.d.ts.map +1 -0
  218. package/lib/typescript/types/siwe/config.d.ts +31 -0
  219. package/lib/typescript/types/siwe/config.d.ts.map +1 -0
  220. package/lib/typescript/types/siwe/index.d.ts +3 -0
  221. package/lib/typescript/types/siwe/index.d.ts.map +1 -0
  222. package/lib/typescript/types/siwe/message.d.ts +57 -0
  223. package/lib/typescript/types/siwe/message.d.ts.map +1 -0
  224. package/lib/typescript/types/storage.d.ts +27 -0
  225. package/lib/typescript/types/storage.d.ts.map +1 -0
  226. package/lib/typescript/types/swap/index.d.ts +2 -0
  227. package/lib/typescript/types/swap/index.d.ts.map +1 -0
  228. package/lib/typescript/types/swap/tokens.d.ts +19 -0
  229. package/lib/typescript/types/swap/tokens.d.ts.map +1 -0
  230. package/lib/typescript/types/ui.d.ts +26 -0
  231. package/lib/typescript/types/ui.d.ts.map +1 -0
  232. package/lib/typescript/types/wallet/connection.d.ts +30 -0
  233. package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
  234. package/lib/typescript/types/wallet/connector.d.ts +61 -0
  235. package/lib/typescript/types/wallet/connector.d.ts.map +1 -0
  236. package/lib/typescript/types/wallet/index.d.ts +4 -0
  237. package/lib/typescript/types/wallet/index.d.ts.map +1 -0
  238. package/lib/typescript/types/wallet/wallet-info.d.ts +36 -0
  239. package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
  240. package/lib/typescript/utils/ConstantsUtil.d.ts +48 -4
  241. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  242. package/lib/typescript/utils/NetworkUtil.d.ts +2 -0
  243. package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
  244. package/lib/typescript/utils/NumberUtil.d.ts +39 -11
  245. package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
  246. package/lib/typescript/utils/PresetsUtil.d.ts +1 -6
  247. package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
  248. package/lib/typescript/utils/StringUtil.d.ts +1 -0
  249. package/lib/typescript/utils/StringUtil.d.ts.map +1 -1
  250. package/package.json +6 -16
  251. package/src/adapters/BlockchainAdapter.ts +126 -0
  252. package/src/adapters/EvmAdapter.ts +247 -0
  253. package/src/adapters/SolanaBaseAdapter.ts +6 -0
  254. package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
  255. package/src/index.ts +7 -1
  256. package/src/networks/bitcoin.ts +32 -0
  257. package/src/networks/solana.ts +44 -0
  258. package/src/types/api/blockchain-api.ts +213 -0
  259. package/src/types/api/events.ts +394 -0
  260. package/src/types/api/index.ts +4 -0
  261. package/src/types/api/wallet-api.ts +70 -0
  262. package/src/types/blockchain/adapter.ts +52 -0
  263. package/src/types/blockchain/balance.ts +31 -0
  264. package/src/types/blockchain/index.ts +5 -0
  265. package/src/types/blockchain/network.ts +39 -0
  266. package/src/{utils/TypeUtil.ts → types/blockchain/transaction.ts} +0 -26
  267. package/src/types/common.ts +56 -0
  268. package/src/types/index.ts +28 -0
  269. package/src/types/onramp/countries.ts +11 -0
  270. package/src/types/onramp/currencies.ts +32 -0
  271. package/src/types/onramp/errors.ts +22 -0
  272. package/src/types/onramp/index.ts +5 -0
  273. package/src/types/onramp/quotes.ts +46 -0
  274. package/src/types/siwe/config.ts +44 -0
  275. package/src/types/siwe/index.ts +3 -0
  276. package/src/types/siwe/message.ts +62 -0
  277. package/src/types/storage.ts +30 -0
  278. package/src/types/swap/index.ts +2 -0
  279. package/src/types/swap/tokens.ts +21 -0
  280. package/src/types/ui.ts +26 -0
  281. package/src/types/wallet/connection.ts +33 -0
  282. package/src/types/wallet/connector.ts +85 -0
  283. package/src/types/wallet/index.ts +4 -0
  284. package/src/types/wallet/wallet-info.ts +41 -0
  285. package/src/utils/ConstantsUtil.ts +55 -8
  286. package/src/utils/NetworkUtil.ts +5 -0
  287. package/src/utils/NumberUtil.ts +54 -11
  288. package/src/utils/PresetsUtil.ts +34 -26
  289. package/src/utils/StringUtil.ts +7 -0
  290. package/lib/commonjs/utils/TypeUtil.js +0 -2
  291. package/lib/module/utils/TypeUtil.js +0 -2
  292. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
@@ -0,0 +1,126 @@
1
+ import { EVMAdapter } from '../EvmAdapter';
2
+ import type { AppKitNetwork, CaipAddress } from '../../types';
3
+
4
+ const network: AppKitNetwork = {
5
+ id: 1,
6
+ name: 'Ethereum',
7
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
8
+ rpcUrls: {
9
+ default: {
10
+ http: ['https://eth.merkle.io']
11
+ }
12
+ },
13
+ blockExplorers: {
14
+ default: {
15
+ name: 'Etherscan',
16
+ url: 'https://etherscan.io'
17
+ }
18
+ },
19
+ chainNamespace: 'eip155',
20
+ caipNetworkId: 'eip155:1'
21
+ };
22
+
23
+ // Mock implementation for testing
24
+ class MockEVMAdapter extends EVMAdapter {
25
+ private mockProvider: any;
26
+
27
+ constructor() {
28
+ super({ supportedNamespace: 'eip155', adapterType: 'ethers' });
29
+ this.mockProvider = {
30
+ request: jest.fn(),
31
+ on: jest.fn(),
32
+ off: jest.fn()
33
+ };
34
+ }
35
+
36
+ setMockProvider(provider: any) {
37
+ this.mockProvider = provider;
38
+ }
39
+
40
+ override getProvider() {
41
+ return this.mockProvider;
42
+ }
43
+
44
+ async disconnect(): Promise<void> {}
45
+ getSupportedNamespace() {
46
+ return 'eip155' as const;
47
+ }
48
+ async getBalance() {
49
+ return { amount: '0', symbol: 'ETH' };
50
+ }
51
+ getAccounts(): CaipAddress[] | undefined {
52
+ return ['eip155:1:0x1234567890123456789012345678901234567890'];
53
+ }
54
+ async switchNetwork() {}
55
+ }
56
+
57
+ describe('EVMAdapter', () => {
58
+ let adapter: MockEVMAdapter;
59
+
60
+ beforeEach(() => {
61
+ adapter = new MockEVMAdapter();
62
+ });
63
+
64
+ describe('writeContract', () => {
65
+ it('should encode transfer function correctly', async () => {
66
+ const mockProvider = {
67
+ request: jest.fn().mockResolvedValueOnce('0x1234567890abcdef') // eth_sendTransaction
68
+ };
69
+ adapter.setMockProvider(mockProvider);
70
+
71
+ const result = await adapter.writeContract({
72
+ tokenAddress: '0x1234567890123456789012345678901234567890',
73
+ receiverAddress: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
74
+ tokenAmount: BigInt(1000000000000000000), // 1 token with 18 decimals
75
+ fromAddress: '0x1234567890123456789012345678901234567890',
76
+ method: 'transfer',
77
+ network
78
+ });
79
+
80
+ expect(result).toBe('0x1234567890abcdef');
81
+ expect(mockProvider.request).toHaveBeenCalledWith(
82
+ {
83
+ method: 'eth_sendTransaction',
84
+ params: [
85
+ {
86
+ from: '0x1234567890123456789012345678901234567890',
87
+ to: '0x1234567890123456789012345678901234567890',
88
+ data: '0xa9059cbb000000000000000000000000abcdefabcdefabcdefabcdefabcdefabcdefabcd0000000000000000000000000000000000000000000000000de0b6b3a7640000',
89
+ value: '0x0',
90
+ type: '0x0'
91
+ }
92
+ ]
93
+ },
94
+ 'eip155:1'
95
+ );
96
+ });
97
+
98
+ it('should throw error for unsupported method', async () => {
99
+ await expect(
100
+ adapter.writeContract({
101
+ tokenAddress: '0x1234567890123456789012345678901234567890',
102
+ receiverAddress: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
103
+ tokenAmount: BigInt(1000000000000000000),
104
+ fromAddress: '0x1234567890123456789012345678901234567890',
105
+ method: 'unsupported' as any,
106
+ network
107
+ })
108
+ ).rejects.toThrow("method 'unsupported' is not supported");
109
+ });
110
+
111
+ it('should throw error when provider is undefined', async () => {
112
+ adapter.setMockProvider(undefined);
113
+
114
+ await expect(
115
+ adapter.writeContract({
116
+ tokenAddress: '0x1234567890123456789012345678901234567890',
117
+ receiverAddress: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
118
+ tokenAmount: BigInt(1000000000000000000),
119
+ fromAddress: '0x1234567890123456789012345678901234567890',
120
+ method: 'transfer',
121
+ network
122
+ })
123
+ ).rejects.toThrow('provider is undefined');
124
+ });
125
+ });
126
+ });
package/src/index.ts CHANGED
@@ -8,4 +8,10 @@ export { PresetsUtil } from './utils/PresetsUtil';
8
8
  export { StringUtil } from './utils/StringUtil';
9
9
  export { ErrorUtil } from './utils/ErrorUtil';
10
10
  export { erc20ABI } from './contracts/erc20';
11
- export * from './utils/TypeUtil';
11
+ export { solana, solanaDevnet, solanaTestnet } from './networks/solana';
12
+ export { bitcoin, bitcoinTestnet } from './networks/bitcoin';
13
+ export { BlockchainAdapter } from './adapters/BlockchainAdapter';
14
+ export { EVMAdapter } from './adapters/EvmAdapter';
15
+ export { SolanaBaseAdapter } from './adapters/SolanaBaseAdapter';
16
+
17
+ export * from './types';
@@ -0,0 +1,32 @@
1
+ import type { AppKitNetwork } from '../types';
2
+
3
+ export const bitcoin: AppKitNetwork = {
4
+ id: '000000000019d6689c085ae165831e93',
5
+ caipNetworkId: 'bip122:000000000019d6689c085ae165831e93',
6
+ chainNamespace: 'bip122',
7
+ name: 'Bitcoin',
8
+ nativeCurrency: {
9
+ name: 'Bitcoin',
10
+ symbol: 'BTC',
11
+ decimals: 8
12
+ },
13
+ rpcUrls: {
14
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
15
+ }
16
+ };
17
+
18
+ export const bitcoinTestnet: AppKitNetwork = {
19
+ id: '000000000933ea01ad0ee984209779ba',
20
+ caipNetworkId: 'bip122:000000000933ea01ad0ee984209779ba',
21
+ chainNamespace: 'bip122',
22
+ name: 'Bitcoin Testnet',
23
+ nativeCurrency: {
24
+ name: 'Bitcoin',
25
+ symbol: 'BTC',
26
+ decimals: 8
27
+ },
28
+ rpcUrls: {
29
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
30
+ },
31
+ testnet: true
32
+ };
@@ -0,0 +1,44 @@
1
+ import type { AppKitNetwork } from '../types';
2
+
3
+ export const solana: AppKitNetwork = {
4
+ id: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
5
+ name: 'Solana',
6
+ nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.walletconnect.org/v1']
10
+ }
11
+ },
12
+ blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
13
+ chainNamespace: 'solana',
14
+ caipNetworkId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
15
+ deprecatedCaipNetworkId: 'solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ',
16
+ testnet: false
17
+ };
18
+
19
+ export const solanaDevnet: AppKitNetwork = {
20
+ id: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
21
+ name: 'Solana Devnet',
22
+ nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
23
+ rpcUrls: {
24
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
25
+ },
26
+ blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
27
+ chainNamespace: 'solana',
28
+ caipNetworkId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
29
+ deprecatedCaipNetworkId: 'solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K',
30
+ testnet: true
31
+ };
32
+
33
+ export const solanaTestnet: AppKitNetwork = {
34
+ id: '4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
35
+ name: 'Solana Testnet',
36
+ nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
37
+ rpcUrls: {
38
+ default: { http: ['https://rpc.walletconnect.org/v1'] }
39
+ },
40
+ blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
41
+ chainNamespace: 'solana',
42
+ caipNetworkId: 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
43
+ testnet: true
44
+ };
@@ -0,0 +1,213 @@
1
+ import type { CaipAddress, CaipNetworkId, BaseError, RequestCache } from '../common';
2
+ import type { Transaction } from '../blockchain/transaction';
3
+ import type { SwapToken } from '../swap';
4
+
5
+ export interface BlockchainApiIdentityRequest {
6
+ address: `0x${string}`;
7
+ }
8
+
9
+ export interface BlockchainApiIdentityResponse {
10
+ avatar: string;
11
+ name: string;
12
+ }
13
+
14
+ export interface BlockchainApiBalance {
15
+ name: string;
16
+ symbol: string;
17
+ chainId: string;
18
+ address?: CaipAddress;
19
+ value?: number;
20
+ price: number;
21
+ quantity: {
22
+ decimals: string;
23
+ numeric: string;
24
+ };
25
+ iconUrl: string;
26
+ }
27
+
28
+ export interface BlockchainApiBalanceResponse {
29
+ balances: BlockchainApiBalance[];
30
+ }
31
+
32
+ export interface BlockchainApiTransactionsRequest {
33
+ account: string;
34
+ projectId: string;
35
+ cursor?: string;
36
+ signal?: AbortSignal;
37
+ cache?: RequestCache;
38
+ chainId: CaipNetworkId;
39
+ }
40
+
41
+ export interface BlockchainApiTransactionsResponse {
42
+ data: Transaction[];
43
+ next: string | null;
44
+ }
45
+
46
+ export interface BlockchainApiSwapAllowanceResponse {
47
+ allowance: string;
48
+ }
49
+
50
+ export interface BlockchainApiGenerateSwapCalldataRequest {
51
+ projectId: string;
52
+ userAddress: CaipAddress;
53
+ from: CaipAddress;
54
+ to: CaipAddress;
55
+ amount: string;
56
+ eip155?: {
57
+ slippage: string;
58
+ permit?: string;
59
+ };
60
+ }
61
+
62
+ export interface BlockchainApiGenerateSwapCalldataResponse {
63
+ tx: {
64
+ from: CaipAddress;
65
+ to: CaipAddress;
66
+ data: `0x${string}`;
67
+ amount: string;
68
+ eip155: {
69
+ gas: string;
70
+ gasPrice: string;
71
+ };
72
+ };
73
+ }
74
+
75
+ export interface BlockchainApiGenerateApproveCalldataRequest {
76
+ projectId: string;
77
+ userAddress: CaipAddress;
78
+ from: CaipAddress;
79
+ to: CaipAddress;
80
+ amount?: number;
81
+ }
82
+
83
+ export interface BlockchainApiGenerateApproveCalldataResponse {
84
+ tx: {
85
+ from: CaipAddress;
86
+ to: CaipAddress;
87
+ data: `0x${string}`;
88
+ value: string;
89
+ eip155: {
90
+ gas: number;
91
+ gasPrice: string;
92
+ };
93
+ };
94
+ }
95
+
96
+ export interface BlockchainApiTokenPriceRequest {
97
+ projectId: string;
98
+ currency?: 'usd' | 'eur' | 'gbp' | 'aud' | 'cad' | 'inr' | 'jpy' | 'btc' | 'eth';
99
+ addresses: CaipAddress[];
100
+ }
101
+
102
+ export interface BlockchainApiTokenPriceResponse {
103
+ fungibles: {
104
+ name: string;
105
+ symbol: string;
106
+ iconUrl: string;
107
+ price: number;
108
+ }[];
109
+ }
110
+
111
+ export interface BlockchainApiSwapAllowanceRequest {
112
+ projectId: string;
113
+ tokenAddress: CaipAddress;
114
+ userAddress: CaipAddress;
115
+ }
116
+
117
+ export interface BlockchainApiGasPriceRequest {
118
+ projectId: string;
119
+ chainId: CaipNetworkId;
120
+ }
121
+
122
+ export interface BlockchainApiGasPriceResponse {
123
+ standard: string;
124
+ fast: string;
125
+ instant: string;
126
+ }
127
+
128
+ export interface BlockchainApiEnsError extends BaseError {
129
+ status: string;
130
+ reasons: { name: string; description: string }[];
131
+ }
132
+
133
+ export type ReownName = `${string}.reown.id` | `${string}.wcn.id`;
134
+
135
+ export interface BlockchainApiLookupEnsName {
136
+ name: ReownName;
137
+ registered: number;
138
+ updated: number;
139
+ addresses: Record<
140
+ string,
141
+ {
142
+ address: string;
143
+ created: string;
144
+ }
145
+ >;
146
+ attributes: {
147
+ avatar?: string;
148
+ bio?: string;
149
+ }[];
150
+ }
151
+
152
+ export interface BlockchainApiSwapQuoteRequest {
153
+ projectId: string;
154
+ chainId?: CaipNetworkId;
155
+ amount: string;
156
+ userAddress: CaipAddress;
157
+ from: CaipAddress;
158
+ to: CaipAddress;
159
+ gasPrice: string;
160
+ }
161
+
162
+ export interface BlockchainApiSwapQuoteResponse {
163
+ quotes: {
164
+ id: string | null;
165
+ fromAmount: string;
166
+ fromAccount: string;
167
+ toAmount: string;
168
+ toAccount: string;
169
+ }[];
170
+ }
171
+
172
+ export interface BlockchainApiSwapTokensRequest {
173
+ projectId: string;
174
+ chainId: CaipNetworkId;
175
+ }
176
+
177
+ export interface BlockchainApiOnRampQuotesRequest {
178
+ countryCode: string;
179
+ paymentMethodType?: string;
180
+ destinationCurrencyCode: string;
181
+ sourceAmount: number;
182
+ sourceCurrencyCode: string;
183
+ walletAddress: string;
184
+ excludeProviders?: string[];
185
+ }
186
+
187
+ export interface BlockchainApiSwapTokensResponse {
188
+ tokens: SwapToken[];
189
+ }
190
+
191
+ export interface BlockchainApiOnRampWidgetRequest {
192
+ countryCode: string;
193
+ destinationCurrencyCode: string;
194
+ paymentMethodType: string;
195
+ serviceProvider: string;
196
+ sourceAmount: number;
197
+ sourceCurrencyCode: string;
198
+ walletAddress: string;
199
+ redirectUrl?: string;
200
+ }
201
+
202
+ export type BlockchainApiOnRampWidgetResponse = {
203
+ widgetUrl: string;
204
+ };
205
+
206
+ export class BlockchainOnRampError extends Error {
207
+ code: string;
208
+ constructor(code: string, message: string) {
209
+ super(message);
210
+ this.code = code;
211
+ this.message = message;
212
+ }
213
+ }