@coinbase/cdp-hooks 0.0.62 → 0.0.64

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 (275) hide show
  1. package/README.md +229 -0
  2. package/dist/esm/index.js +11 -9
  3. package/dist/esm/index10.js +1 -1
  4. package/dist/esm/index100.js +215 -32
  5. package/dist/esm/index101.js +32 -22
  6. package/dist/esm/index102.js +21 -5
  7. package/dist/esm/index103.js +5 -73
  8. package/dist/esm/index104.js +73 -5
  9. package/dist/esm/index105.js +4 -4
  10. package/dist/esm/index106.js +5 -35
  11. package/dist/esm/index107.js +29 -69
  12. package/dist/esm/index108.js +76 -3
  13. package/dist/esm/index109.js +3 -24
  14. package/dist/esm/index11.js +1 -1
  15. package/dist/esm/index110.js +16 -444
  16. package/dist/esm/index111.js +444 -23
  17. package/dist/esm/index112.js +24 -20
  18. package/dist/esm/index113.js +18 -25
  19. package/dist/esm/index114.js +31 -32
  20. package/dist/esm/index115.js +32 -191
  21. package/dist/esm/index116.js +191 -6
  22. package/dist/esm/index117.js +9 -2
  23. package/dist/esm/index118.js +2 -13
  24. package/dist/esm/index119.js +11 -17
  25. package/dist/esm/index12.js +1 -1
  26. package/dist/esm/index120.js +13 -22
  27. package/dist/esm/index121.js +27 -8
  28. package/dist/esm/index122.js +8 -55
  29. package/dist/esm/index123.js +50 -40
  30. package/dist/esm/index124.js +45 -8
  31. package/dist/esm/index125.js +8 -7
  32. package/dist/esm/index126.js +7 -16
  33. package/dist/esm/index127.js +16 -18
  34. package/dist/esm/index128.js +18 -24
  35. package/dist/esm/index129.js +24 -16
  36. package/dist/esm/index13.js +1 -1
  37. package/dist/esm/index130.js +16 -54
  38. package/dist/esm/index131.js +53 -10
  39. package/dist/esm/index132.js +11 -160
  40. package/dist/esm/index133.js +160 -21
  41. package/dist/esm/index134.js +21 -127
  42. package/dist/esm/index135.js +127 -38
  43. package/dist/esm/index136.js +38 -6
  44. package/dist/esm/index137.js +6 -27
  45. package/dist/esm/index138.js +27 -191
  46. package/dist/esm/index139.js +192 -4
  47. package/dist/esm/index14.js +4 -8
  48. package/dist/esm/index140.js +4 -65
  49. package/dist/esm/index141.js +65 -3
  50. package/dist/esm/index142.js +3 -21
  51. package/dist/esm/index143.js +19 -15
  52. package/dist/esm/index144.js +16 -23
  53. package/dist/esm/index145.js +23 -11
  54. package/dist/esm/index146.js +11 -34
  55. package/dist/esm/index147.js +35 -3
  56. package/dist/esm/index148.js +3 -19
  57. package/dist/esm/index149.js +18 -27
  58. package/dist/esm/index15.js +9 -34
  59. package/dist/esm/index150.js +25 -33
  60. package/dist/esm/index151.js +35 -7
  61. package/dist/esm/index152.js +7 -25
  62. package/dist/esm/index153.js +20 -23
  63. package/dist/esm/index154.js +27 -63
  64. package/dist/esm/index155.js +64 -9
  65. package/dist/esm/index156.js +9 -33
  66. package/dist/esm/index157.js +33 -27
  67. package/dist/esm/index158.js +26 -23
  68. package/dist/esm/index159.js +24 -3
  69. package/dist/esm/index16.js +33 -17
  70. package/dist/esm/index160.js +3 -14
  71. package/dist/esm/index161.js +14 -103
  72. package/dist/esm/index162.js +99 -60
  73. package/dist/esm/index163.js +64 -5
  74. package/dist/esm/index164.js +5 -6
  75. package/dist/esm/index165.js +6 -27
  76. package/dist/esm/index166.js +27 -38
  77. package/dist/esm/index167.js +38 -13
  78. package/dist/esm/index168.js +13 -42
  79. package/dist/esm/index169.js +42 -5
  80. package/dist/esm/index17.js +18 -12
  81. package/dist/esm/index170.js +5 -11
  82. package/dist/esm/index171.js +11 -19
  83. package/dist/esm/index172.js +18 -77
  84. package/dist/esm/index173.js +79 -2
  85. package/dist/esm/index174.js +2 -38
  86. package/dist/esm/index175.js +32 -105
  87. package/dist/esm/index176.js +105 -43
  88. package/dist/esm/index177.js +47 -31
  89. package/dist/esm/index178.js +32 -8
  90. package/dist/esm/index179.js +8 -6
  91. package/dist/esm/index18.js +11 -11
  92. package/dist/esm/index180.js +6 -6
  93. package/dist/esm/index181.js +6 -11
  94. package/dist/esm/index182.js +11 -10
  95. package/dist/esm/index183.js +10 -13
  96. package/dist/esm/index184.js +12 -31
  97. package/dist/esm/index185.js +33 -5
  98. package/dist/esm/index186.js +5 -9
  99. package/dist/esm/index187.js +8 -19
  100. package/dist/esm/index188.js +19 -31
  101. package/dist/esm/index189.js +31 -20
  102. package/dist/esm/index19.js +12 -54
  103. package/dist/esm/index190.js +20 -3
  104. package/dist/esm/index191.js +3 -17
  105. package/dist/esm/index192.js +17 -10
  106. package/dist/esm/index193.js +10 -21
  107. package/dist/esm/index194.js +21 -22
  108. package/dist/esm/index195.js +22 -5
  109. package/dist/esm/index196.js +5 -5
  110. package/dist/esm/index197.js +5 -8
  111. package/dist/esm/index198.js +8 -104
  112. package/dist/esm/index199.js +105 -3
  113. package/dist/esm/index2.js +2 -2
  114. package/dist/esm/index20.js +54 -58
  115. package/dist/esm/index200.js +3 -19
  116. package/dist/esm/index201.js +17 -170
  117. package/dist/esm/index202.js +170 -16
  118. package/dist/esm/index203.js +18 -10
  119. package/dist/esm/index204.js +10 -39
  120. package/dist/esm/index205.js +8 -2
  121. package/dist/esm/index206.js +6 -69
  122. package/dist/esm/index207.js +35 -33
  123. package/dist/esm/index208.js +15 -14
  124. package/dist/esm/index21.js +58 -56
  125. package/dist/esm/index218.js +1 -1
  126. package/dist/esm/index22.js +56 -5
  127. package/dist/esm/index225.js +8 -7
  128. package/dist/esm/index226.js +12 -6
  129. package/dist/esm/index227.js +9 -36
  130. package/dist/esm/index228.js +16 -15
  131. package/dist/esm/index229.js +22 -8
  132. package/dist/esm/index23.js +5 -48
  133. package/dist/esm/index230.js +26 -8
  134. package/dist/esm/index231.js +2 -10
  135. package/dist/esm/index232.js +13 -16
  136. package/dist/esm/index233.js +11 -21
  137. package/dist/esm/index234.js +47 -30
  138. package/dist/esm/index235.js +10 -2
  139. package/dist/esm/index236.js +10 -10
  140. package/dist/esm/index237.js +13 -11
  141. package/dist/esm/index238.js +8 -47
  142. package/dist/esm/index239.js +15 -9
  143. package/dist/esm/index24.js +46 -31
  144. package/dist/esm/index240.js +23 -12
  145. package/dist/esm/index241.js +11 -14
  146. package/dist/esm/index242.js +24 -8
  147. package/dist/esm/index243.js +51 -15
  148. package/dist/esm/index244.js +17 -24
  149. package/dist/esm/index245.js +14 -11
  150. package/dist/esm/index246.js +11 -24
  151. package/dist/esm/index247.js +101 -49
  152. package/dist/esm/index248.js +5 -17
  153. package/dist/esm/index249.js +222 -13
  154. package/dist/esm/index25.js +32 -3
  155. package/dist/esm/index250.js +6 -11
  156. package/dist/esm/index251.js +7 -104
  157. package/dist/esm/index252.js +26 -5
  158. package/dist/esm/index253.js +18 -222
  159. package/dist/esm/index254.js +145 -6
  160. package/dist/esm/index255.js +12 -6
  161. package/dist/esm/index256.js +35 -26
  162. package/dist/esm/index257.js +40 -18
  163. package/dist/esm/index258.js +38 -145
  164. package/dist/esm/index259.js +2 -13
  165. package/dist/esm/index26.js +3 -9
  166. package/dist/esm/index260.js +70 -36
  167. package/dist/esm/index261.js +34 -41
  168. package/dist/esm/index262.js +15 -2
  169. package/dist/esm/index263.js +2 -69
  170. package/dist/esm/index264.js +68 -3
  171. package/dist/esm/index265.js +3 -136
  172. package/dist/esm/index266.js +125 -144
  173. package/dist/esm/index267.js +155 -9
  174. package/dist/esm/index268.js +9 -16
  175. package/dist/esm/index269.js +16 -113
  176. package/dist/esm/index27.js +8 -67
  177. package/dist/esm/index270.js +95 -116
  178. package/dist/esm/index271.js +126 -70
  179. package/dist/esm/index272.js +79 -2
  180. package/dist/esm/index273.js +2 -698
  181. package/dist/esm/index274.js +685 -126
  182. package/dist/esm/index275.js +137 -41
  183. package/dist/esm/index276.js +40 -198
  184. package/dist/esm/index277.js +200 -3
  185. package/dist/esm/index278.js +1 -1
  186. package/dist/esm/index28.js +66 -7
  187. package/dist/esm/index280.js +1 -1
  188. package/dist/esm/index281.js +3 -3
  189. package/dist/esm/index283.js +2 -2
  190. package/dist/esm/index285.js +2 -2
  191. package/dist/esm/index286.js +3 -63
  192. package/dist/esm/index287.js +59 -40
  193. package/dist/esm/index288.js +44 -4
  194. package/dist/esm/index289.js +5 -5
  195. package/dist/esm/index29.js +8 -27
  196. package/dist/esm/index290.js +5 -2
  197. package/dist/esm/index291.js +2 -22
  198. package/dist/esm/index292.js +24 -0
  199. package/dist/esm/index30.js +25 -67
  200. package/dist/esm/index31.js +68 -17
  201. package/dist/esm/index32.js +17 -108
  202. package/dist/esm/index33.js +110 -60
  203. package/dist/esm/index34.js +56 -20
  204. package/dist/esm/index35.js +22 -38
  205. package/dist/esm/index36.js +37 -34
  206. package/dist/esm/index37.js +34 -55
  207. package/dist/esm/index38.js +55 -160
  208. package/dist/esm/index39.js +156 -32
  209. package/dist/esm/index40.js +39 -9
  210. package/dist/esm/index41.js +8 -30
  211. package/dist/esm/index42.js +21 -26
  212. package/dist/esm/index43.js +35 -8
  213. package/dist/esm/index44.js +8 -28
  214. package/dist/esm/index45.js +27 -44
  215. package/dist/esm/index46.js +44 -86
  216. package/dist/esm/index47.js +83 -35
  217. package/dist/esm/index48.js +40 -8
  218. package/dist/esm/index49.js +7 -5
  219. package/dist/esm/index5.js +3 -3
  220. package/dist/esm/index50.js +6 -16
  221. package/dist/esm/index51.js +16 -8
  222. package/dist/esm/index52.js +8 -13
  223. package/dist/esm/index53.js +13 -7
  224. package/dist/esm/index54.js +7 -9
  225. package/dist/esm/index55.js +9 -16
  226. package/dist/esm/index56.js +16 -46
  227. package/dist/esm/index57.js +46 -13
  228. package/dist/esm/index58.js +13 -16
  229. package/dist/esm/index59.js +14 -11
  230. package/dist/esm/index6.js +2 -2
  231. package/dist/esm/index60.js +13 -6
  232. package/dist/esm/index61.js +5 -34
  233. package/dist/esm/index62.js +34 -8
  234. package/dist/esm/index63.js +8 -7
  235. package/dist/esm/index64.js +8 -25
  236. package/dist/esm/index65.js +25 -10
  237. package/dist/esm/index66.js +10 -14
  238. package/dist/esm/index67.js +14 -11
  239. package/dist/esm/index68.js +11 -116
  240. package/dist/esm/index69.js +114 -31
  241. package/dist/esm/index7.js +1 -1
  242. package/dist/esm/index70.js +30 -76
  243. package/dist/esm/index71.js +78 -176
  244. package/dist/esm/index72.js +174 -41
  245. package/dist/esm/index73.js +44 -6
  246. package/dist/esm/index74.js +5 -12
  247. package/dist/esm/index75.js +12 -12
  248. package/dist/esm/index76.js +13 -99
  249. package/dist/esm/index77.js +96 -69
  250. package/dist/esm/index78.js +61 -76
  251. package/dist/esm/index79.js +74 -135
  252. package/dist/esm/index8.js +2 -2
  253. package/dist/esm/index80.js +108 -96
  254. package/dist/esm/index81.js +113 -45
  255. package/dist/esm/index82.js +68 -23
  256. package/dist/esm/index83.js +23 -105
  257. package/dist/esm/index84.js +105 -6
  258. package/dist/esm/index85.js +6 -131
  259. package/dist/esm/index86.js +130 -274
  260. package/dist/esm/index87.js +276 -3
  261. package/dist/esm/index88.js +3 -4
  262. package/dist/esm/index89.js +4 -9
  263. package/dist/esm/index9.js +1 -1
  264. package/dist/esm/index90.js +9 -2
  265. package/dist/esm/index91.js +2 -2
  266. package/dist/esm/index92.js +2 -3
  267. package/dist/esm/index93.js +3 -327
  268. package/dist/esm/index94.js +324 -11
  269. package/dist/esm/index95.js +13 -4
  270. package/dist/esm/index96.js +4 -55
  271. package/dist/esm/index97.js +56 -2
  272. package/dist/esm/index98.js +2 -8
  273. package/dist/esm/index99.js +6 -213
  274. package/dist/types/index.d.ts +8 -0
  275. package/package.json +3 -3
package/README.md CHANGED
@@ -1402,3 +1402,232 @@ function ConditionalWaitForUserOperation() {
1402
1402
  );
1403
1403
  }
1404
1404
  ```
1405
+
1406
+ ### X402 Payment Protocol Support
1407
+
1408
+ The SDK includes built-in support for the X402 payment protocol through the `useX402` hook. This enables HTTP requests with micropayments, allowing access to paid APIs and services that require payment for each request.
1409
+
1410
+ #### Installation
1411
+
1412
+ Ensure you have separately installed the `x402-fetch` package:
1413
+
1414
+ ```bash
1415
+ npm install x402-fetch
1416
+ ```
1417
+
1418
+ #### Basic Usage
1419
+
1420
+ The `useX402` hook provides a wrapped fetch API that automatically handles X402 payment requests:
1421
+
1422
+ ```tsx lines
1423
+ import { useX402, useCurrentUser } from "@coinbase/cdp-hooks";
1424
+
1425
+ function X402Example() {
1426
+ const { currentUser } = useCurrentUser();
1427
+ const { fetchWithPayment } = useX402();
1428
+ const [data, setData] = useState(null);
1429
+ const [loading, setLoading] = useState(false);
1430
+ const [error, setError] = useState(null);
1431
+
1432
+ const handleFetchPaidResource = async () => {
1433
+ if (!currentUser) {
1434
+ setError("Please sign in first");
1435
+ return;
1436
+ }
1437
+
1438
+ setLoading(true);
1439
+ setError(null);
1440
+
1441
+ try {
1442
+ const response = await fetchWithPayment("https://api.example.com/paid-endpoint", {
1443
+ method: "GET",
1444
+ headers: {
1445
+ "Content-Type": "application/json"
1446
+ }
1447
+ });
1448
+
1449
+ const result = await response.json();
1450
+ setData(result);
1451
+ console.log("Paid API response:", result);
1452
+ } catch (err) {
1453
+ setError(err instanceof Error ? err.message : "Failed to fetch resource");
1454
+ console.error("X402 payment failed:", err);
1455
+ } finally {
1456
+ setLoading(false);
1457
+ }
1458
+ };
1459
+
1460
+ return (
1461
+ <div>
1462
+ <h3>X402 Payment Example</h3>
1463
+
1464
+ {!currentUser && <p>Please sign in to use X402 payments</p>}
1465
+
1466
+ <button
1467
+ onClick={handleFetchPaidResource}
1468
+ disabled={!currentUser || loading}
1469
+ >
1470
+ {loading ? "Processing..." : "Fetch Paid Resource"}
1471
+ </button>
1472
+
1473
+ {error && <p style={{ color: 'red' }}>Error: {error}</p>}
1474
+
1475
+ {data && (
1476
+ <div>
1477
+ <h4>Response:</h4>
1478
+ <pre>{JSON.stringify(data, null, 2)}</pre>
1479
+ </div>
1480
+ )}
1481
+ </div>
1482
+ );
1483
+ }
1484
+ ```
1485
+
1486
+ #### Advanced Configuration
1487
+
1488
+ You can customize the X402 behavior with options:
1489
+
1490
+ ```tsx lines
1491
+ import { useX402 } from "@coinbase/cdp-hooks";
1492
+
1493
+ function X402AdvancedExample() {
1494
+ // Use a specific address for payments (instead of the user's default)
1495
+ const { fetchWithPayment: fetchWithSpecificAddress } = useX402({
1496
+ address: "0x1234567890123456789012345678901234567890"
1497
+ });
1498
+
1499
+ // Use a custom fetch implementation
1500
+ const customFetch = (url, options) => {
1501
+ console.log("Making request to:", url);
1502
+ return fetch(url, options);
1503
+ };
1504
+
1505
+ const { fetchWithPayment: fetchWithCustomImpl } = useX402({
1506
+ fetch: customFetch
1507
+ });
1508
+
1509
+ // Combine both options
1510
+ const { fetchWithPayment: fetchWithBothOptions } = useX402({
1511
+ address: "0x1234567890123456789012345678901234567890",
1512
+ fetch: customFetch
1513
+ });
1514
+
1515
+ return (
1516
+ <div>
1517
+ <p>Multiple X402 configurations available</p>
1518
+ </div>
1519
+ );
1520
+ }
1521
+ ```
1522
+
1523
+ #### How It Works
1524
+
1525
+ 1. When you make a request to an X402-protected resource, the server responds with a `402 Payment Required` status
1526
+ 2. The wrapped fetch function automatically:
1527
+ - Extracts payment details from the server's response
1528
+ - Creates and signs a payment transaction using the user's wallet
1529
+ - Includes the payment proof in a retry request
1530
+ 3. The server validates the payment and returns the requested resource
1531
+
1532
+ #### Smart Account Support
1533
+
1534
+ By default, `useX402` will use the user's Smart Account if available, falling back to their regular EVM account:
1535
+
1536
+ ```tsx lines
1537
+ import { useX402, useCurrentUser } from "@coinbase/cdp-hooks";
1538
+
1539
+ function X402SmartAccountExample() {
1540
+ const { currentUser } = useCurrentUser();
1541
+ const { fetchWithPayment } = useX402();
1542
+
1543
+ // The hook automatically uses the appropriate account type
1544
+ const accountUsed = currentUser?.evmSmartAccounts?.[0] || currentUser?.evmAccounts?.[0];
1545
+
1546
+ return (
1547
+ <div>
1548
+ <p>X402 will use account: {accountUsed}</p>
1549
+ <p>Account type: {currentUser?.evmSmartAccounts?.[0] ? "Smart Account" : "EOA"}</p>
1550
+ </div>
1551
+ );
1552
+ }
1553
+ ```
1554
+
1555
+ #### Solana Support
1556
+
1557
+ Solana support is supported out of the box with `useX402`. If your end user has both an EVM and Solana account, the EVM account will be used by defualt. You can pass a Solana address to `useX402` to use the Solana account instead.
1558
+
1559
+ ```tsx lines
1560
+ import { useX402, useCurrentUser } from "@coinbase/cdp-hooks";
1561
+
1562
+ const { currentUser } = useCurrentUser();
1563
+ const { fetchWithPayment } = useX402({
1564
+ address: currentUser?.solanaAccounts?.[0]
1565
+ });
1566
+
1567
+ await fetchWithPayment("https://api.example.com/paid-endpoint", {
1568
+ method: "GET",
1569
+ headers: {
1570
+ "Content-Type": "application/json"
1571
+ }
1572
+ });
1573
+ ```
1574
+
1575
+ #### React Native Support
1576
+
1577
+ The `useX402` hook works seamlessly in React Native applications:
1578
+
1579
+ ```tsx lines
1580
+ import React, { useState } from "react";
1581
+ import { View, Text, TouchableOpacity, ActivityIndicator } from "react-native";
1582
+ import { useX402, useCurrentUser } from "@coinbase/cdp-hooks";
1583
+
1584
+ function X402ReactNativeExample() {
1585
+ const { currentUser } = useCurrentUser();
1586
+ const { fetchWithPayment } = useX402();
1587
+ const [loading, setLoading] = useState(false);
1588
+ const [data, setData] = useState(null);
1589
+
1590
+ const handleFetchPaidResource = async () => {
1591
+ setLoading(true);
1592
+ try {
1593
+ const response = await fetchWithPayment("https://api.example.com/paid-endpoint");
1594
+ const result = await response.json();
1595
+ setData(result);
1596
+ } catch (error) {
1597
+ console.error("Failed to fetch paid resource:", error);
1598
+ } finally {
1599
+ setLoading(false);
1600
+ }
1601
+ };
1602
+
1603
+ return (
1604
+ <View style={{ padding: 20 }}>
1605
+ <TouchableOpacity
1606
+ onPress={handleFetchPaidResource}
1607
+ disabled={!currentUser || loading}
1608
+ style={{
1609
+ backgroundColor: "#007AFF",
1610
+ padding: 15,
1611
+ borderRadius: 8,
1612
+ alignItems: "center",
1613
+ opacity: !currentUser || loading ? 0.6 : 1,
1614
+ }}
1615
+ >
1616
+ {loading ? (
1617
+ <ActivityIndicator color="white" />
1618
+ ) : (
1619
+ <Text style={{ color: "white", fontSize: 16, fontWeight: "600" }}>
1620
+ Fetch X402 Resource
1621
+ </Text>
1622
+ )}
1623
+ </TouchableOpacity>
1624
+
1625
+ {data && (
1626
+ <View style={{ marginTop: 20, padding: 10, backgroundColor: "#f0f0f0" }}>
1627
+ <Text>{JSON.stringify(data, null, 2)}</Text>
1628
+ </View>
1629
+ )}
1630
+ </View>
1631
+ );
1632
+ }
1633
+ ```
package/dist/esm/index.js CHANGED
@@ -4,14 +4,15 @@ import "react";
4
4
  import { VERSION as s } from "./index3.js";
5
5
  import { CDPContext as S, CDPHooksProvider as p } from "./index4.js";
6
6
  import { useAuthenticateWithJWT as c, useConfig as d, useCurrentUser as g, useEnforceAuthenticated as E, useEnforceUnauthenticated as x, useEvmAddress as A, useExportEvmAccount as h, useExportSolanaAccount as l, useGetAccessToken as P, useIsInitialized as k, useIsSignedIn as v, useOAuthState as O, useSendEvmTransaction as T, useSendSolanaTransaction as I, useSendUserOperation as C, useSignEvmHash as L, useSignEvmMessage as W, useSignEvmTransaction as y, useSignEvmTypedData as U, useSignInWithEmail as V, useSignInWithOAuth as D, useSignInWithSms as G, useSignOut as H, useSignSolanaMessage as M, useSignSolanaTransaction as R, useSolanaAddress as z, useVerifyEmailOTP as F, useVerifySmsOTP as J, useWaitForUserOperation as N } from "./index5.js";
7
- import { useCreateSpendPermission as j } from "./index6.js";
8
- import { useListSpendPermissions as w } from "./index7.js";
9
- import { useRevokeSpendPermission as K } from "./index8.js";
10
- import { useLinkGoogle as X } from "./index9.js";
7
+ import { useCreateSpendPermission as b } from "./index6.js";
8
+ import { useListSpendPermissions as q } from "./index7.js";
9
+ import { useRevokeSpendPermission as B } from "./index8.js";
10
+ import { useLinkGoogle as Q } from "./index9.js";
11
11
  import { useLinkApple as Z } from "./index10.js";
12
12
  import { useLinkSms as $ } from "./index11.js";
13
13
  import { useLinkEmail as se } from "./index12.js";
14
14
  import { useLinkOAuth as re } from "./index13.js";
15
+ import { useX402 as te } from "./index14.js";
15
16
  e.registerPackageVersion("hooks", s);
16
17
  export {
17
18
  u as APIError,
@@ -20,7 +21,7 @@ export {
20
21
  a as OAuth2ProviderType,
21
22
  c as useAuthenticateWithJWT,
22
23
  d as useConfig,
23
- j as useCreateSpendPermission,
24
+ b as useCreateSpendPermission,
24
25
  g as useCurrentUser,
25
26
  E as useEnforceAuthenticated,
26
27
  x as useEnforceUnauthenticated,
@@ -32,12 +33,12 @@ export {
32
33
  v as useIsSignedIn,
33
34
  Z as useLinkApple,
34
35
  se as useLinkEmail,
35
- X as useLinkGoogle,
36
+ Q as useLinkGoogle,
36
37
  re as useLinkOAuth,
37
38
  $ as useLinkSms,
38
- w as useListSpendPermissions,
39
+ q as useListSpendPermissions,
39
40
  O as useOAuthState,
40
- K as useRevokeSpendPermission,
41
+ B as useRevokeSpendPermission,
41
42
  T as useSendEvmTransaction,
42
43
  I as useSendSolanaTransaction,
43
44
  C as useSendUserOperation,
@@ -54,5 +55,6 @@ export {
54
55
  z as useSolanaAddress,
55
56
  F as useVerifyEmailOTP,
56
57
  J as useVerifySmsOTP,
57
- N as useWaitForUserOperation
58
+ N as useWaitForUserOperation,
59
+ te as useX402
58
60
  };
@@ -1,5 +1,5 @@
1
1
  import "./index2.js";
2
- import { useSendHookCallOnce as t } from "./index14.js";
2
+ import { useSendHookCallOnce as t } from "./index15.js";
3
3
  import "react";
4
4
  import { useLinkOAuth as o } from "./index13.js";
5
5
  function u() {
@@ -1,34 +1,217 @@
1
- const e = {
2
- 1: "An `assert` condition failed.",
3
- 17: "Arithmetic operation resulted in underflow or overflow.",
4
- 18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",
5
- 33: "Attempted to convert to an invalid type.",
6
- 34: "Attempted to access a storage byte array that is incorrectly encoded.",
7
- 49: "Performed `.pop()` on an empty array",
8
- 50: "Array index is out of bounds.",
9
- 65: "Allocated too much memory or created an array which is too large.",
10
- 81: "Attempted to call a zero-initialized variable of internal function type."
11
- }, o = {
12
- inputs: [
13
- {
14
- name: "message",
15
- type: "string"
16
- }
17
- ],
18
- name: "Error",
19
- type: "error"
20
- }, t = {
21
- inputs: [
22
- {
23
- name: "reason",
24
- type: "uint256"
25
- }
26
- ],
27
- name: "Panic",
28
- type: "error"
29
- };
1
+ import { parseAccount as E } from "./index26.js";
2
+ import { panicReasons as $ } from "./index101.js";
3
+ import { decodeErrorResult as A } from "./index102.js";
4
+ import { formatAbiItem as y } from "./index95.js";
5
+ import { formatAbiItemWithArgs as v } from "./index103.js";
6
+ import { getAbiItem as C } from "./index104.js";
7
+ import { formatEther as P } from "./index105.js";
8
+ import { formatGwei as p } from "./index106.js";
9
+ import { AbiErrorSignatureNotFoundError as j } from "./index94.js";
10
+ import { BaseError as m } from "./index97.js";
11
+ import { prettyStateOverride as x } from "./index107.js";
12
+ import { prettyPrint as w } from "./index108.js";
13
+ import { getContractAddress as O } from "./index109.js";
14
+ class z extends m {
15
+ constructor(e, { account: o, docsPath: u, chain: s, data: c, gas: a, gasPrice: i, maxFeePerGas: r, maxPriorityFeePerGas: t, nonce: n, to: l, value: d, stateOverride: f }) {
16
+ const h = o ? E(o) : void 0;
17
+ let g = w({
18
+ from: h?.address,
19
+ to: l,
20
+ value: typeof d < "u" && `${P(d)} ${s?.nativeCurrency?.symbol || "ETH"}`,
21
+ data: c,
22
+ gas: a,
23
+ gasPrice: typeof i < "u" && `${p(i)} gwei`,
24
+ maxFeePerGas: typeof r < "u" && `${p(r)} gwei`,
25
+ maxPriorityFeePerGas: typeof t < "u" && `${p(t)} gwei`,
26
+ nonce: n
27
+ });
28
+ f && (g += `
29
+ ${x(f)}`), super(e.shortMessage, {
30
+ cause: e,
31
+ docsPath: u,
32
+ metaMessages: [
33
+ ...e.metaMessages ? [...e.metaMessages, " "] : [],
34
+ "Raw Call Arguments:",
35
+ g
36
+ ].filter(Boolean),
37
+ name: "CallExecutionError"
38
+ }), Object.defineProperty(this, "cause", {
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0,
42
+ value: void 0
43
+ }), this.cause = e;
44
+ }
45
+ }
46
+ class G extends m {
47
+ constructor(e, { abi: o, args: u, contractAddress: s, docsPath: c, functionName: a, sender: i }) {
48
+ const r = C({ abi: o, args: u, name: a }), t = r ? v({
49
+ abiItem: r,
50
+ args: u,
51
+ includeFunctionName: !1,
52
+ includeName: !1
53
+ }) : void 0, n = r ? y(r, { includeName: !0 }) : void 0, l = w({
54
+ address: s && O(s),
55
+ function: n,
56
+ args: t && t !== "()" && `${[...Array(a?.length ?? 0).keys()].map(() => " ").join("")}${t}`,
57
+ sender: i
58
+ });
59
+ super(e.shortMessage || `An unknown error occurred while executing the contract function "${a}".`, {
60
+ cause: e,
61
+ docsPath: c,
62
+ metaMessages: [
63
+ ...e.metaMessages ? [...e.metaMessages, " "] : [],
64
+ l && "Contract Call:",
65
+ l
66
+ ].filter(Boolean),
67
+ name: "ContractFunctionExecutionError"
68
+ }), Object.defineProperty(this, "abi", {
69
+ enumerable: !0,
70
+ configurable: !0,
71
+ writable: !0,
72
+ value: void 0
73
+ }), Object.defineProperty(this, "args", {
74
+ enumerable: !0,
75
+ configurable: !0,
76
+ writable: !0,
77
+ value: void 0
78
+ }), Object.defineProperty(this, "cause", {
79
+ enumerable: !0,
80
+ configurable: !0,
81
+ writable: !0,
82
+ value: void 0
83
+ }), Object.defineProperty(this, "contractAddress", {
84
+ enumerable: !0,
85
+ configurable: !0,
86
+ writable: !0,
87
+ value: void 0
88
+ }), Object.defineProperty(this, "formattedArgs", {
89
+ enumerable: !0,
90
+ configurable: !0,
91
+ writable: !0,
92
+ value: void 0
93
+ }), Object.defineProperty(this, "functionName", {
94
+ enumerable: !0,
95
+ configurable: !0,
96
+ writable: !0,
97
+ value: void 0
98
+ }), Object.defineProperty(this, "sender", {
99
+ enumerable: !0,
100
+ configurable: !0,
101
+ writable: !0,
102
+ value: void 0
103
+ }), this.abi = o, this.args = u, this.cause = e, this.contractAddress = s, this.functionName = a, this.sender = i;
104
+ }
105
+ }
106
+ class H extends m {
107
+ constructor({ abi: e, data: o, functionName: u, message: s }) {
108
+ let c, a, i, r;
109
+ if (o && o !== "0x")
110
+ try {
111
+ a = A({ abi: e, data: o });
112
+ const { abiItem: n, errorName: l, args: d } = a;
113
+ if (l === "Error")
114
+ r = d[0];
115
+ else if (l === "Panic") {
116
+ const [f] = d;
117
+ r = $[f];
118
+ } else {
119
+ const f = n ? y(n, { includeName: !0 }) : void 0, h = n && d ? v({
120
+ abiItem: n,
121
+ args: d,
122
+ includeFunctionName: !1,
123
+ includeName: !1
124
+ }) : void 0;
125
+ i = [
126
+ f ? `Error: ${f}` : "",
127
+ h && h !== "()" ? ` ${[...Array(l?.length ?? 0).keys()].map(() => " ").join("")}${h}` : ""
128
+ ];
129
+ }
130
+ } catch (n) {
131
+ c = n;
132
+ }
133
+ else s && (r = s);
134
+ let t;
135
+ c instanceof j && (t = c.signature, i = [
136
+ `Unable to decode signature "${t}" as it was not found on the provided ABI.`,
137
+ "Make sure you are using the correct ABI and that the error exists on it.",
138
+ `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${t}.`
139
+ ]), super(r && r !== "execution reverted" || t ? [
140
+ `The contract function "${u}" reverted with the following ${t ? "signature" : "reason"}:`,
141
+ r || t
142
+ ].join(`
143
+ `) : `The contract function "${u}" reverted.`, {
144
+ cause: c,
145
+ metaMessages: i,
146
+ name: "ContractFunctionRevertedError"
147
+ }), Object.defineProperty(this, "data", {
148
+ enumerable: !0,
149
+ configurable: !0,
150
+ writable: !0,
151
+ value: void 0
152
+ }), Object.defineProperty(this, "raw", {
153
+ enumerable: !0,
154
+ configurable: !0,
155
+ writable: !0,
156
+ value: void 0
157
+ }), Object.defineProperty(this, "reason", {
158
+ enumerable: !0,
159
+ configurable: !0,
160
+ writable: !0,
161
+ value: void 0
162
+ }), Object.defineProperty(this, "signature", {
163
+ enumerable: !0,
164
+ configurable: !0,
165
+ writable: !0,
166
+ value: void 0
167
+ }), this.data = a, this.raw = o, this.reason = r, this.signature = t;
168
+ }
169
+ }
170
+ class U extends m {
171
+ constructor({ functionName: e }) {
172
+ super(`The contract function "${e}" returned no data ("0x").`, {
173
+ metaMessages: [
174
+ "This could be due to any of the following:",
175
+ ` - The contract does not have the function "${e}",`,
176
+ " - The parameters passed to the contract function may be invalid, or",
177
+ " - The address is not a contract."
178
+ ],
179
+ name: "ContractFunctionZeroDataError"
180
+ });
181
+ }
182
+ }
183
+ class Y extends m {
184
+ constructor({ factory: e }) {
185
+ super(`Deployment for counterfactual contract call failed${e ? ` for factory "${e}".` : ""}`, {
186
+ metaMessages: [
187
+ "Please ensure:",
188
+ "- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).",
189
+ "- The `factoryData` is a valid encoded function call for contract deployment function on the factory."
190
+ ],
191
+ name: "CounterfactualDeploymentFailedError"
192
+ });
193
+ }
194
+ }
195
+ class J extends m {
196
+ constructor({ data: e, message: o }) {
197
+ super(o || "", { name: "RawContractError" }), Object.defineProperty(this, "code", {
198
+ enumerable: !0,
199
+ configurable: !0,
200
+ writable: !0,
201
+ value: 3
202
+ }), Object.defineProperty(this, "data", {
203
+ enumerable: !0,
204
+ configurable: !0,
205
+ writable: !0,
206
+ value: void 0
207
+ }), this.data = e;
208
+ }
209
+ }
30
210
  export {
31
- e as panicReasons,
32
- o as solidityError,
33
- t as solidityPanic
211
+ z as CallExecutionError,
212
+ G as ContractFunctionExecutionError,
213
+ H as ContractFunctionRevertedError,
214
+ U as ContractFunctionZeroDataError,
215
+ Y as CounterfactualDeploymentFailedError,
216
+ J as RawContractError
34
217
  };
@@ -1,24 +1,34 @@
1
- import { solidityError as m, solidityPanic as s } from "./index100.js";
2
- import { AbiDecodingZeroDataError as c, AbiErrorSignatureNotFoundError as d } from "./index93.js";
3
- import { slice as e } from "./index135.js";
4
- import { toFunctionSelector as u } from "./index139.js";
5
- import { decodeAbiParameters as f } from "./index132.js";
6
- import { formatAbiItem as p } from "./index94.js";
7
- function y(n) {
8
- const { abi: a, data: t } = n, o = e(t, 0, 4);
9
- if (o === "0x")
10
- throw new c();
11
- const r = [...a || [], m, s].find((i) => i.type === "error" && o === u(p(i)));
12
- if (!r)
13
- throw new d(o, {
14
- docsPath: "/docs/contract/decodeErrorResult"
15
- });
16
- return {
17
- abiItem: r,
18
- args: "inputs" in r && r.inputs && r.inputs.length > 0 ? f(r.inputs, e(t, 4)) : void 0,
19
- errorName: r.name
20
- };
21
- }
1
+ const e = {
2
+ 1: "An `assert` condition failed.",
3
+ 17: "Arithmetic operation resulted in underflow or overflow.",
4
+ 18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",
5
+ 33: "Attempted to convert to an invalid type.",
6
+ 34: "Attempted to access a storage byte array that is incorrectly encoded.",
7
+ 49: "Performed `.pop()` on an empty array",
8
+ 50: "Array index is out of bounds.",
9
+ 65: "Allocated too much memory or created an array which is too large.",
10
+ 81: "Attempted to call a zero-initialized variable of internal function type."
11
+ }, o = {
12
+ inputs: [
13
+ {
14
+ name: "message",
15
+ type: "string"
16
+ }
17
+ ],
18
+ name: "Error",
19
+ type: "error"
20
+ }, t = {
21
+ inputs: [
22
+ {
23
+ name: "reason",
24
+ type: "uint256"
25
+ }
26
+ ],
27
+ name: "Panic",
28
+ type: "error"
29
+ };
22
30
  export {
23
- y as decodeErrorResult
31
+ e as panicReasons,
32
+ o as solidityError,
33
+ t as solidityPanic
24
34
  };
@@ -1,8 +1,24 @@
1
- import { stringify as o } from "./index117.js";
2
- function p({ abiItem: n, args: r, includeFunctionName: f = !0, includeName: i = !1 }) {
3
- if ("name" in n && "inputs" in n && n.inputs)
4
- return `${f ? n.name : ""}(${n.inputs.map((e, t) => `${i && e.name ? `${e.name}: ` : ""}${typeof r[t] == "object" ? o(r[t]) : r[t]}`).join(", ")})`;
1
+ import { solidityError as m, solidityPanic as s } from "./index101.js";
2
+ import { AbiDecodingZeroDataError as c, AbiErrorSignatureNotFoundError as d } from "./index94.js";
3
+ import { slice as e } from "./index136.js";
4
+ import { toFunctionSelector as u } from "./index140.js";
5
+ import { decodeAbiParameters as f } from "./index133.js";
6
+ import { formatAbiItem as p } from "./index95.js";
7
+ function y(n) {
8
+ const { abi: a, data: t } = n, o = e(t, 0, 4);
9
+ if (o === "0x")
10
+ throw new c();
11
+ const r = [...a || [], m, s].find((i) => i.type === "error" && o === u(p(i)));
12
+ if (!r)
13
+ throw new d(o, {
14
+ docsPath: "/docs/contract/decodeErrorResult"
15
+ });
16
+ return {
17
+ abiItem: r,
18
+ args: "inputs" in r && r.inputs && r.inputs.length > 0 ? f(r.inputs, e(t, 4)) : void 0,
19
+ errorName: r.name
20
+ };
5
21
  }
6
22
  export {
7
- p as formatAbiItemWithArgs
23
+ y as decodeErrorResult
8
24
  };