timelock-sdk 0.0.63 → 0.0.65

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/client.cjs CHANGED
@@ -243,7 +243,7 @@ const useMarketData = (marketAddr) => {
243
243
  const { graphqlClient } = useTimelockConfig();
244
244
  const { timelockLens } = useLens();
245
245
  const { data } = (0, __tanstack_react_query.useQuery)({
246
- queryKey: ["marketData", marketAddr || "--"],
246
+ queryKey: ["marketData", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
247
247
  queryFn: async () => {
248
248
  const result = await graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() });
249
249
  return {
@@ -567,7 +567,7 @@ const useUserOptions = (user, active = false) => {
567
567
  const { data,...rest } = (0, __tanstack_react_query.useQuery)({
568
568
  queryKey: [
569
569
  "userOptions",
570
- user || "--",
570
+ (user === null || user === void 0 ? void 0 : user.toLowerCase()) || "--",
571
571
  active
572
572
  ],
573
573
  queryFn: async () => {
@@ -663,8 +663,8 @@ const useUserOperators = (userAddr, marketAddr) => {
663
663
  const { data,...rest } = (0, __tanstack_react_query.useQuery)({
664
664
  queryKey: [
665
665
  "userOperators",
666
- userAddr || "--",
667
- marketAddr || "--"
666
+ (userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase()) || "--",
667
+ (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"
668
668
  ],
669
669
  queryFn: async () => {
670
670
  if (!userAddr || !marketAddr) return void 0;
@@ -681,7 +681,50 @@ const useUserOperators = (userAddr, marketAddr) => {
681
681
  });
682
682
  return {
683
683
  ...rest,
684
- data: data || {}
684
+ data: data || []
685
+ };
686
+ };
687
+
688
+ //#endregion
689
+ //#region src/hooks/market/useSetOperatorPerms.ts
690
+ const useSetOperatorPerms = (marketAddr) => {
691
+ const queryClient = (0, __tanstack_react_query.useQueryClient)();
692
+ const client = (0, wagmi.useClient)();
693
+ const { address } = (0, wagmi.useAccount)();
694
+ const { writeContractAsync, data: hash, isPending, error } = (0, wagmi.useWriteContract)();
695
+ const { isLoading: isConfirming, isSuccess } = (0, wagmi.useWaitForTransactionReceipt)({ hash });
696
+ const setOperatorPerms = async (operator, canExtend, canExercise, canTransfer, canMint, spendingApproval) => {
697
+ if (!client || !address) throw new Error("Wallet not connected");
698
+ if (!marketAddr) throw new Error("Market address not available");
699
+ const hash$1 = await writeContractAsync({
700
+ address: marketAddr,
701
+ abi: require_optionsMarket.optionsMarketAbi,
702
+ functionName: "setOperatorPerms",
703
+ args: [
704
+ operator,
705
+ canExtend,
706
+ canExercise,
707
+ canTransfer,
708
+ canMint,
709
+ spendingApproval
710
+ ]
711
+ });
712
+ await (0, viem_actions.waitForTransactionReceipt)(client, { hash: hash$1 });
713
+ await queryClient.invalidateQueries({ queryKey: [
714
+ "userOperators",
715
+ address.toLowerCase(),
716
+ marketAddr.toLowerCase()
717
+ ] });
718
+ return hash$1;
719
+ };
720
+ return {
721
+ setOperatorPerms,
722
+ hash,
723
+ isPending,
724
+ isConfirming,
725
+ isSuccess,
726
+ error,
727
+ isLoading: isPending || isConfirming
685
728
  };
686
729
  };
687
730
 
@@ -1077,6 +1120,7 @@ exports.useOptionPremium = useOptionPremium;
1077
1120
  exports.usePoolData = usePoolData;
1078
1121
  exports.usePriceAtTick = usePriceAtTick;
1079
1122
  exports.usePriceHistory = usePriceHistory;
1123
+ exports.useSetOperatorPerms = useSetOperatorPerms;
1080
1124
  exports.useTimelockConfig = useTimelockConfig;
1081
1125
  exports.useUserOperators = useUserOperators;
1082
1126
  exports.useVaultData = useVaultData;