@pear-protocol/symmio-client 0.2.49 → 0.3.0
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/react/index.d.mts +20 -3
- package/dist/react/index.d.ts +20 -3
- package/dist/react/index.js +42 -21
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +42 -21
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react/index.mjs
CHANGED
|
@@ -743,8 +743,8 @@ var symmKeys = {
|
|
|
743
743
|
fundingPayments: (params) => ["symm", "fundingPayments", params],
|
|
744
744
|
fundingHistory: (params) => ["symm", "fundingHistory", params],
|
|
745
745
|
portfolio: (params) => ["symm", "portfolio", params],
|
|
746
|
-
notifications: (
|
|
747
|
-
unreadCount: (
|
|
746
|
+
notifications: (params) => ["symm", "notifications", params],
|
|
747
|
+
unreadCount: (params) => ["symm", "unreadCount", params],
|
|
748
748
|
availableMargin: (address, chainId) => ["symm", "availableMargin", address, chainId],
|
|
749
749
|
pendingIds: (address, chainId) => ["symm", "pendingIds", address, chainId],
|
|
750
750
|
pendingInstantOpens: (accountAddress, chainId) => ["symm", "pendingInstantOpens", accountAddress, chainId],
|
|
@@ -25474,13 +25474,14 @@ function useSymmUpdatePositionMutation(paramsOrOptions, maybeOptions) {
|
|
|
25474
25474
|
typedRequest.authToken,
|
|
25475
25475
|
typedRequest.accountAddress
|
|
25476
25476
|
);
|
|
25477
|
-
|
|
25478
|
-
throw new Error("auth token is required to update a position");
|
|
25479
|
-
}
|
|
25480
|
-
return symmCoreClient.positions.update(positionId, {
|
|
25477
|
+
const requestWithOptionalAuth = authToken ? {
|
|
25481
25478
|
...request,
|
|
25482
25479
|
authToken
|
|
25483
|
-
}
|
|
25480
|
+
} : request;
|
|
25481
|
+
return symmCoreClient.positions.update(
|
|
25482
|
+
positionId,
|
|
25483
|
+
requestWithOptionalAuth
|
|
25484
|
+
);
|
|
25484
25485
|
}
|
|
25485
25486
|
});
|
|
25486
25487
|
}
|
|
@@ -26038,61 +26039,81 @@ function useSymmPortfolio(params) {
|
|
|
26038
26039
|
function useResolvedNotificationsParams(params) {
|
|
26039
26040
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26040
26041
|
const chainId = params.chainId ?? ctxChainId;
|
|
26042
|
+
const accountAddress = params.accountAddress;
|
|
26043
|
+
const address = accountAddress ? void 0 : params.address;
|
|
26041
26044
|
return {
|
|
26042
26045
|
symmCoreClient,
|
|
26043
26046
|
chainId,
|
|
26044
|
-
|
|
26047
|
+
accountAddress,
|
|
26048
|
+
address,
|
|
26045
26049
|
query: params.query
|
|
26046
26050
|
};
|
|
26047
26051
|
}
|
|
26048
26052
|
function useSymmNotificationsQuery(params) {
|
|
26049
|
-
const { symmCoreClient, chainId,
|
|
26050
|
-
const internalEnabled = !!symmCoreClient && !!
|
|
26053
|
+
const { symmCoreClient, chainId, accountAddress, address, query } = useResolvedNotificationsParams(params);
|
|
26054
|
+
const internalEnabled = !!symmCoreClient && !!(accountAddress || address);
|
|
26055
|
+
const queryParams = {
|
|
26056
|
+
accountAddress,
|
|
26057
|
+
address,
|
|
26058
|
+
chainId
|
|
26059
|
+
};
|
|
26051
26060
|
return useQuery({
|
|
26052
26061
|
...query,
|
|
26053
|
-
queryKey: symmKeys.notifications(
|
|
26062
|
+
queryKey: symmKeys.notifications(queryParams),
|
|
26054
26063
|
queryFn: () => symmCoreClient.notifications.list({
|
|
26055
|
-
|
|
26064
|
+
accountAddress,
|
|
26065
|
+
address,
|
|
26056
26066
|
chainId
|
|
26057
26067
|
}),
|
|
26058
26068
|
enabled: internalEnabled && (query?.enabled ?? true)
|
|
26059
26069
|
});
|
|
26060
26070
|
}
|
|
26061
26071
|
function useSymmUnreadCountQuery(params) {
|
|
26062
|
-
const { symmCoreClient, chainId,
|
|
26063
|
-
const internalEnabled = !!symmCoreClient && !!
|
|
26072
|
+
const { symmCoreClient, chainId, accountAddress, address, query } = useResolvedNotificationsParams(params);
|
|
26073
|
+
const internalEnabled = !!symmCoreClient && !!(accountAddress || address);
|
|
26074
|
+
const queryParams = {
|
|
26075
|
+
accountAddress,
|
|
26076
|
+
address,
|
|
26077
|
+
chainId
|
|
26078
|
+
};
|
|
26064
26079
|
return useQuery({
|
|
26065
26080
|
...query,
|
|
26066
|
-
queryKey: symmKeys.unreadCount(
|
|
26081
|
+
queryKey: symmKeys.unreadCount(queryParams),
|
|
26067
26082
|
queryFn: () => symmCoreClient.notifications.getUnreadCount({
|
|
26068
|
-
|
|
26083
|
+
accountAddress,
|
|
26084
|
+
address,
|
|
26069
26085
|
chainId
|
|
26070
26086
|
}),
|
|
26071
26087
|
enabled: internalEnabled && (query?.enabled ?? true)
|
|
26072
26088
|
});
|
|
26073
26089
|
}
|
|
26074
26090
|
function useSymmMarkReadNotificationMutation(params, options) {
|
|
26075
|
-
const { symmCoreClient, chainId,
|
|
26091
|
+
const { symmCoreClient, chainId, accountAddress, address } = useResolvedNotificationsParams(params);
|
|
26076
26092
|
const queryClient = useQueryClient();
|
|
26093
|
+
const queryParams = {
|
|
26094
|
+
accountAddress,
|
|
26095
|
+
address,
|
|
26096
|
+
chainId
|
|
26097
|
+
};
|
|
26077
26098
|
return useMutation({
|
|
26078
26099
|
...withSymmMutationConfig(options?.mutation, {
|
|
26079
26100
|
onSuccess: () => {
|
|
26080
26101
|
queryClient.invalidateQueries({
|
|
26081
|
-
queryKey: symmKeys.notifications(
|
|
26102
|
+
queryKey: symmKeys.notifications(queryParams)
|
|
26082
26103
|
});
|
|
26083
26104
|
queryClient.invalidateQueries({
|
|
26084
|
-
queryKey: symmKeys.unreadCount(
|
|
26105
|
+
queryKey: symmKeys.unreadCount(queryParams)
|
|
26085
26106
|
});
|
|
26086
26107
|
}
|
|
26087
26108
|
}),
|
|
26088
26109
|
mutationFn: async ({ id, timestamp }) => {
|
|
26089
|
-
if (!symmCoreClient || !
|
|
26110
|
+
if (!symmCoreClient || !accountAddress) {
|
|
26090
26111
|
throw new Error("symm-core client not available");
|
|
26091
26112
|
}
|
|
26092
26113
|
return symmCoreClient.notifications.markRead({
|
|
26093
26114
|
id,
|
|
26094
26115
|
timestamp,
|
|
26095
|
-
|
|
26116
|
+
accountAddress,
|
|
26096
26117
|
chainId
|
|
26097
26118
|
});
|
|
26098
26119
|
}
|