@turtleclub/hooks 0.5.0-beta.21 → 0.5.0-beta.23
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.
- package/dist/index.cjs +98 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/v2/earn-actions/api.ts +118 -0
- package/src/v2/earn-actions/hooks.ts +111 -0
- package/src/v2/earn-actions/queries.ts +11 -0
- package/src/v2/{earn-interactions → earn-actions}/schema.ts +37 -8
- package/src/v2/index.ts +3 -3
- package/src/v2/streams/schemas.ts +1 -1
- package/src/v2/earn-interactions/api.ts +0 -70
- package/src/v2/earn-interactions/hooks.ts +0 -57
- package/src/v2/earn-interactions/queries.ts +0 -8
- /package/src/v2/{earn-interactions → earn-actions}/index.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -23,12 +23,15 @@ __export(index_exports, {
|
|
|
23
23
|
ApiError: () => ApiError,
|
|
24
24
|
BalanceSourcePriority: () => BalanceSourcePriority,
|
|
25
25
|
TurtleHooksProvider: () => TurtleHooksProvider,
|
|
26
|
+
actionResponseSchema: () => actionResponseSchema,
|
|
26
27
|
apiClient: () => apiClient,
|
|
27
28
|
approveStep: () => approveStep,
|
|
28
29
|
asset: () => asset,
|
|
29
30
|
assetData: () => assetData,
|
|
30
31
|
assetERC20Data: () => assetERC20Data,
|
|
31
32
|
assetImageData: () => assetImageData,
|
|
33
|
+
attributeAction: () => attributeAction,
|
|
34
|
+
attributeActionResponseSchema: () => attributeActionResponseSchema,
|
|
32
35
|
balanceQueries: () => balanceQueries,
|
|
33
36
|
balanceTokenSchema: () => balanceTokenSchema,
|
|
34
37
|
chainSchema: () => chainSchema,
|
|
@@ -37,16 +40,23 @@ __export(index_exports, {
|
|
|
37
40
|
coverRequestDataSchema: () => coverRequestDataSchema,
|
|
38
41
|
createAgreementRequestSchema: () => createAgreementRequestSchema,
|
|
39
42
|
createAgreementResponseSchema: () => createAgreementResponseSchema,
|
|
43
|
+
createCancelDepositAction: () => createCancelDepositAction,
|
|
44
|
+
createCancelWithdrawAction: () => createCancelWithdrawAction,
|
|
45
|
+
createClaimDepositAction: () => createClaimDepositAction,
|
|
46
|
+
createClaimWithdrawAction: () => createClaimWithdrawAction,
|
|
40
47
|
createClaimWithdrawInteraction: () => createClaimWithdrawInteraction,
|
|
48
|
+
createDepositAction: () => createDepositAction,
|
|
41
49
|
createDepositInteraction: () => createDepositInteraction,
|
|
42
50
|
createMembership: () => createMembership,
|
|
43
51
|
createMembershipAgreement: () => createMembershipAgreement,
|
|
44
52
|
createMembershipRequestSchema: () => createMembershipRequestSchema,
|
|
45
53
|
createMembershipResponseSchema: () => createMembershipResponseSchema,
|
|
54
|
+
createWithdrawAction: () => createWithdrawAction,
|
|
46
55
|
createWithdrawInteraction: () => createWithdrawInteraction,
|
|
47
56
|
depositSchema: () => depositSchema,
|
|
48
57
|
depositSubstep: () => depositSubstep,
|
|
49
58
|
depositsResponseSchema: () => depositsResponseSchema,
|
|
59
|
+
earnActionsQueries: () => earnActionsQueries,
|
|
50
60
|
earnDepositsQueries: () => earnDepositsQueries,
|
|
51
61
|
earnInteractionsQueries: () => earnInteractionsQueries,
|
|
52
62
|
earnMembershipQueries: () => earnMembershipQueries,
|
|
@@ -88,7 +98,6 @@ __export(index_exports, {
|
|
|
88
98
|
getWidgetOpportunities: () => getWidgetOpportunities,
|
|
89
99
|
holdingsDataSchema: () => holdingsDataSchema,
|
|
90
100
|
incentiveSchema: () => incentiveSchema,
|
|
91
|
-
interactionResponseSchema: () => interactionResponseSchema,
|
|
92
101
|
lendingConfigSchema: () => lendingConfigSchema,
|
|
93
102
|
mergeBalancesByPriority: () => mergeBalancesByPriority,
|
|
94
103
|
nftsQueries: () => nftsQueries,
|
|
@@ -126,8 +135,13 @@ __export(index_exports, {
|
|
|
126
135
|
tokenSchema: () => tokenSchema,
|
|
127
136
|
transactionSchema: () => transactionSchema,
|
|
128
137
|
txResponseItemSchema: () => txResponseItemSchema,
|
|
138
|
+
useAttributeAction: () => useAttributeAction,
|
|
129
139
|
useBalance: () => useBalance,
|
|
140
|
+
useCancelDepositAction: () => useCancelDepositAction,
|
|
141
|
+
useCancelWithdrawAction: () => useCancelWithdrawAction,
|
|
130
142
|
useCheckMembership: () => useCheckMembership,
|
|
143
|
+
useClaimDepositAction: () => useClaimDepositAction,
|
|
144
|
+
useClaimWithdrawAction: () => useClaimWithdrawAction,
|
|
131
145
|
useCreateClaimWithdrawInteraction: () => useCreateClaimWithdrawInteraction,
|
|
132
146
|
useCreateDepositInteraction: () => useCreateDepositInteraction,
|
|
133
147
|
useCreateMembership: () => useCreateMembership,
|
|
@@ -135,6 +149,7 @@ __export(index_exports, {
|
|
|
135
149
|
useCreateProduct: () => useCreateProduct,
|
|
136
150
|
useCreateWithdrawInteraction: () => useCreateWithdrawInteraction,
|
|
137
151
|
useDeleteProduct: () => useDeleteProduct,
|
|
152
|
+
useDepositAction: () => useDepositAction,
|
|
138
153
|
useDeposits: () => useDeposits,
|
|
139
154
|
useEarnOpportunities: () => useEarnOpportunities,
|
|
140
155
|
useEarnRoute: () => useEarnRoute,
|
|
@@ -161,6 +176,7 @@ __export(index_exports, {
|
|
|
161
176
|
useUserNfts: () => useUserNfts,
|
|
162
177
|
useUserPortfolio: () => useUserPortfolio,
|
|
163
178
|
useWidgetOpportunities: () => useWidgetOpportunities,
|
|
179
|
+
useWithdrawAction: () => useWithdrawAction,
|
|
164
180
|
userEarningsSchema: () => userEarningsSchema,
|
|
165
181
|
userWithDetailsSchema: () => userWithDetailsSchema,
|
|
166
182
|
usersQueries: () => usersQueries,
|
|
@@ -779,12 +795,13 @@ var earnDepositsQueries = (0, import_query_key_factory5.createQueryKeys)("earnDe
|
|
|
779
795
|
})
|
|
780
796
|
});
|
|
781
797
|
|
|
782
|
-
// src/v2/earn-
|
|
798
|
+
// src/v2/earn-actions/queries.ts
|
|
783
799
|
var import_query_key_factory6 = require("@lukemorales/query-key-factory");
|
|
784
|
-
var
|
|
800
|
+
var earnActionsQueries = (0, import_query_key_factory6.createQueryKeys)("earnActions", {
|
|
785
801
|
// Placeholder for potential future GET endpoints
|
|
786
|
-
// e.g., getting
|
|
802
|
+
// e.g., getting action history
|
|
787
803
|
});
|
|
804
|
+
var earnInteractionsQueries = earnActionsQueries;
|
|
788
805
|
|
|
789
806
|
// src/v2/products/queries.ts
|
|
790
807
|
var import_query_key_factory7 = require("@lukemorales/query-key-factory");
|
|
@@ -1072,7 +1089,7 @@ var customArgsAprSchema = import_zod10.z.object({
|
|
|
1072
1089
|
targetTokenAddress: import_zod10.z.string()
|
|
1073
1090
|
});
|
|
1074
1091
|
var chainSchema3 = import_zod10.z.object({
|
|
1075
|
-
chainId: import_zod10.z.number(),
|
|
1092
|
+
chainId: import_zod10.z.coerce.number(),
|
|
1076
1093
|
ecosystem: import_zod10.z.string(),
|
|
1077
1094
|
explorerUrl: import_zod10.z.string(),
|
|
1078
1095
|
id: import_zod10.z.string().uuid(),
|
|
@@ -1535,7 +1552,7 @@ function useDeposits({ params, enabled = true }) {
|
|
|
1535
1552
|
});
|
|
1536
1553
|
}
|
|
1537
1554
|
|
|
1538
|
-
// src/v2/earn-
|
|
1555
|
+
// src/v2/earn-actions/schema.ts
|
|
1539
1556
|
var import_zod14 = require("zod");
|
|
1540
1557
|
var transactionSchema = import_zod14.z.object({
|
|
1541
1558
|
chainId: import_zod14.z.number().int(),
|
|
@@ -1549,12 +1566,17 @@ var txResponseItemSchema = import_zod14.z.object({
|
|
|
1549
1566
|
description: import_zod14.z.string().optional(),
|
|
1550
1567
|
transaction: transactionSchema
|
|
1551
1568
|
});
|
|
1552
|
-
var
|
|
1569
|
+
var actionResponseSchema = import_zod14.z.object({
|
|
1570
|
+
actionId: import_zod14.z.string().uuid().optional(),
|
|
1553
1571
|
transactions: import_zod14.z.array(txResponseItemSchema).nullable()
|
|
1554
1572
|
});
|
|
1573
|
+
var attributeActionResponseSchema = import_zod14.z.object({
|
|
1574
|
+
success: import_zod14.z.boolean(),
|
|
1575
|
+
message: import_zod14.z.string().optional()
|
|
1576
|
+
});
|
|
1555
1577
|
|
|
1556
|
-
// src/v2/earn-
|
|
1557
|
-
function
|
|
1578
|
+
// src/v2/earn-actions/api.ts
|
|
1579
|
+
function buildActionQuery(params) {
|
|
1558
1580
|
const searchParams = new URLSearchParams({
|
|
1559
1581
|
userAddress: params.userAddress,
|
|
1560
1582
|
tokenIn: params.tokenIn,
|
|
@@ -1569,48 +1591,77 @@ function buildInteractionQuery(params) {
|
|
|
1569
1591
|
}
|
|
1570
1592
|
return searchParams.toString();
|
|
1571
1593
|
}
|
|
1572
|
-
async function
|
|
1594
|
+
async function createAction(actionType, params) {
|
|
1573
1595
|
const { opportunityId, ...queryParams } = params;
|
|
1574
|
-
const query =
|
|
1596
|
+
const query = buildActionQuery(queryParams);
|
|
1575
1597
|
const data = await apiClient.fetch(
|
|
1576
|
-
`/v1/
|
|
1598
|
+
`/v1/actions/${actionType}/${opportunityId}?${query}`,
|
|
1577
1599
|
{
|
|
1578
1600
|
method: "POST",
|
|
1579
1601
|
domain: "earn"
|
|
1580
1602
|
}
|
|
1581
1603
|
);
|
|
1582
|
-
const result =
|
|
1604
|
+
const result = actionResponseSchema.safeParse(data);
|
|
1583
1605
|
if (result.success === false) {
|
|
1584
1606
|
console.log("[ZOD ERROR]", result.error);
|
|
1585
1607
|
throw new Error(
|
|
1586
|
-
`Failed to parse ${
|
|
1608
|
+
`Failed to parse ${actionType} action: ${result.error.message}`
|
|
1587
1609
|
);
|
|
1588
1610
|
}
|
|
1589
1611
|
return result.data;
|
|
1590
1612
|
}
|
|
1591
|
-
var
|
|
1592
|
-
var
|
|
1593
|
-
var
|
|
1613
|
+
var createDepositAction = (params) => createAction("deposit", params);
|
|
1614
|
+
var createWithdrawAction = (params) => createAction("withdraw", params);
|
|
1615
|
+
var createClaimWithdrawAction = (params) => createAction("claim-withdraw", params);
|
|
1616
|
+
var createClaimDepositAction = (params) => createAction("claim-deposit", params);
|
|
1617
|
+
var createCancelDepositAction = (params) => createAction("cancel-deposit", params);
|
|
1618
|
+
var createCancelWithdrawAction = (params) => createAction("cancel-withdraw", params);
|
|
1619
|
+
async function attributeAction(params) {
|
|
1620
|
+
const { actionId, txHash } = params;
|
|
1621
|
+
const data = await apiClient.fetch(`/v1/actions/attribute/${actionId}`, {
|
|
1622
|
+
method: "POST",
|
|
1623
|
+
domain: "earn",
|
|
1624
|
+
body: JSON.stringify({ txHash }),
|
|
1625
|
+
headers: {
|
|
1626
|
+
"Content-Type": "application/json"
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
const result = attributeActionResponseSchema.safeParse(data);
|
|
1630
|
+
if (result.success === false) {
|
|
1631
|
+
console.log("[ZOD ERROR]", result.error);
|
|
1632
|
+
throw new Error(`Failed to parse attribute action: ${result.error.message}`);
|
|
1633
|
+
}
|
|
1634
|
+
return result.data;
|
|
1635
|
+
}
|
|
1636
|
+
var createDepositInteraction = createDepositAction;
|
|
1637
|
+
var createWithdrawInteraction = createWithdrawAction;
|
|
1638
|
+
var createClaimWithdrawInteraction = createClaimWithdrawAction;
|
|
1594
1639
|
|
|
1595
|
-
// src/v2/earn-
|
|
1640
|
+
// src/v2/earn-actions/hooks.ts
|
|
1596
1641
|
var import_react_query5 = require("@tanstack/react-query");
|
|
1597
|
-
function
|
|
1598
|
-
return function
|
|
1642
|
+
function createActionHook(mutationFn) {
|
|
1643
|
+
return function useAction(options) {
|
|
1599
1644
|
return (0, import_react_query5.useMutation)({
|
|
1600
1645
|
mutationFn,
|
|
1601
1646
|
...options
|
|
1602
1647
|
});
|
|
1603
1648
|
};
|
|
1604
1649
|
}
|
|
1605
|
-
var
|
|
1606
|
-
|
|
1607
|
-
);
|
|
1608
|
-
var
|
|
1609
|
-
|
|
1610
|
-
);
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1650
|
+
var useDepositAction = createActionHook(createDepositAction);
|
|
1651
|
+
var useWithdrawAction = createActionHook(createWithdrawAction);
|
|
1652
|
+
var useClaimWithdrawAction = createActionHook(createClaimWithdrawAction);
|
|
1653
|
+
var useClaimDepositAction = createActionHook(createClaimDepositAction);
|
|
1654
|
+
var useCancelDepositAction = createActionHook(createCancelDepositAction);
|
|
1655
|
+
var useCancelWithdrawAction = createActionHook(createCancelWithdrawAction);
|
|
1656
|
+
function useAttributeAction(options) {
|
|
1657
|
+
return (0, import_react_query5.useMutation)({
|
|
1658
|
+
mutationFn: attributeAction,
|
|
1659
|
+
...options
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
var useCreateDepositInteraction = useDepositAction;
|
|
1663
|
+
var useCreateWithdrawInteraction = useWithdrawAction;
|
|
1664
|
+
var useCreateClaimWithdrawInteraction = useClaimWithdrawAction;
|
|
1614
1665
|
|
|
1615
1666
|
// src/v2/enso-balances/hooks.ts
|
|
1616
1667
|
var import_react = require("react");
|
|
@@ -2490,7 +2541,7 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2490
2541
|
earnRouteQueries,
|
|
2491
2542
|
earnMembershipQueries,
|
|
2492
2543
|
earnDepositsQueries,
|
|
2493
|
-
|
|
2544
|
+
earnActionsQueries,
|
|
2494
2545
|
productsQueries,
|
|
2495
2546
|
ensoBalancesQueries,
|
|
2496
2547
|
widgetQueries,
|
|
@@ -2505,12 +2556,15 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2505
2556
|
ApiError,
|
|
2506
2557
|
BalanceSourcePriority,
|
|
2507
2558
|
TurtleHooksProvider,
|
|
2559
|
+
actionResponseSchema,
|
|
2508
2560
|
apiClient,
|
|
2509
2561
|
approveStep,
|
|
2510
2562
|
asset,
|
|
2511
2563
|
assetData,
|
|
2512
2564
|
assetERC20Data,
|
|
2513
2565
|
assetImageData,
|
|
2566
|
+
attributeAction,
|
|
2567
|
+
attributeActionResponseSchema,
|
|
2514
2568
|
balanceQueries,
|
|
2515
2569
|
balanceTokenSchema,
|
|
2516
2570
|
chainSchema,
|
|
@@ -2519,16 +2573,23 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2519
2573
|
coverRequestDataSchema,
|
|
2520
2574
|
createAgreementRequestSchema,
|
|
2521
2575
|
createAgreementResponseSchema,
|
|
2576
|
+
createCancelDepositAction,
|
|
2577
|
+
createCancelWithdrawAction,
|
|
2578
|
+
createClaimDepositAction,
|
|
2579
|
+
createClaimWithdrawAction,
|
|
2522
2580
|
createClaimWithdrawInteraction,
|
|
2581
|
+
createDepositAction,
|
|
2523
2582
|
createDepositInteraction,
|
|
2524
2583
|
createMembership,
|
|
2525
2584
|
createMembershipAgreement,
|
|
2526
2585
|
createMembershipRequestSchema,
|
|
2527
2586
|
createMembershipResponseSchema,
|
|
2587
|
+
createWithdrawAction,
|
|
2528
2588
|
createWithdrawInteraction,
|
|
2529
2589
|
depositSchema,
|
|
2530
2590
|
depositSubstep,
|
|
2531
2591
|
depositsResponseSchema,
|
|
2592
|
+
earnActionsQueries,
|
|
2532
2593
|
earnDepositsQueries,
|
|
2533
2594
|
earnInteractionsQueries,
|
|
2534
2595
|
earnMembershipQueries,
|
|
@@ -2570,7 +2631,6 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2570
2631
|
getWidgetOpportunities,
|
|
2571
2632
|
holdingsDataSchema,
|
|
2572
2633
|
incentiveSchema,
|
|
2573
|
-
interactionResponseSchema,
|
|
2574
2634
|
lendingConfigSchema,
|
|
2575
2635
|
mergeBalancesByPriority,
|
|
2576
2636
|
nftsQueries,
|
|
@@ -2608,8 +2668,13 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2608
2668
|
tokenSchema,
|
|
2609
2669
|
transactionSchema,
|
|
2610
2670
|
txResponseItemSchema,
|
|
2671
|
+
useAttributeAction,
|
|
2611
2672
|
useBalance,
|
|
2673
|
+
useCancelDepositAction,
|
|
2674
|
+
useCancelWithdrawAction,
|
|
2612
2675
|
useCheckMembership,
|
|
2676
|
+
useClaimDepositAction,
|
|
2677
|
+
useClaimWithdrawAction,
|
|
2613
2678
|
useCreateClaimWithdrawInteraction,
|
|
2614
2679
|
useCreateDepositInteraction,
|
|
2615
2680
|
useCreateMembership,
|
|
@@ -2617,6 +2682,7 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2617
2682
|
useCreateProduct,
|
|
2618
2683
|
useCreateWithdrawInteraction,
|
|
2619
2684
|
useDeleteProduct,
|
|
2685
|
+
useDepositAction,
|
|
2620
2686
|
useDeposits,
|
|
2621
2687
|
useEarnOpportunities,
|
|
2622
2688
|
useEarnRoute,
|
|
@@ -2643,6 +2709,7 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2643
2709
|
useUserNfts,
|
|
2644
2710
|
useUserPortfolio,
|
|
2645
2711
|
useWidgetOpportunities,
|
|
2712
|
+
useWithdrawAction,
|
|
2646
2713
|
userEarningsSchema,
|
|
2647
2714
|
userWithDetailsSchema,
|
|
2648
2715
|
usersQueries,
|