timelock-sdk 0.0.64 → 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.js CHANGED
@@ -236,7 +236,7 @@ const useMarketData = (marketAddr) => {
236
236
  const { graphqlClient } = useTimelockConfig();
237
237
  const { timelockLens } = useLens();
238
238
  const { data } = useQuery({
239
- queryKey: ["marketData", marketAddr || "--"],
239
+ queryKey: ["marketData", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
240
240
  queryFn: async () => {
241
241
  const result = await graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() });
242
242
  return {
@@ -560,7 +560,7 @@ const useUserOptions = (user, active = false) => {
560
560
  const { data,...rest } = useQuery({
561
561
  queryKey: [
562
562
  "userOptions",
563
- user || "--",
563
+ (user === null || user === void 0 ? void 0 : user.toLowerCase()) || "--",
564
564
  active
565
565
  ],
566
566
  queryFn: async () => {
@@ -656,8 +656,8 @@ const useUserOperators = (userAddr, marketAddr) => {
656
656
  const { data,...rest } = useQuery({
657
657
  queryKey: [
658
658
  "userOperators",
659
- userAddr || "--",
660
- marketAddr || "--"
659
+ (userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase()) || "--",
660
+ (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"
661
661
  ],
662
662
  queryFn: async () => {
663
663
  if (!userAddr || !marketAddr) return void 0;
@@ -678,6 +678,49 @@ const useUserOperators = (userAddr, marketAddr) => {
678
678
  };
679
679
  };
680
680
 
681
+ //#endregion
682
+ //#region src/hooks/market/useSetOperatorPerms.ts
683
+ const useSetOperatorPerms = (marketAddr) => {
684
+ const queryClient = useQueryClient();
685
+ const client = useClient();
686
+ const { address } = useAccount();
687
+ const { writeContractAsync, data: hash, isPending, error } = useWriteContract();
688
+ const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({ hash });
689
+ const setOperatorPerms = async (operator, canExtend, canExercise, canTransfer, canMint, spendingApproval) => {
690
+ if (!client || !address) throw new Error("Wallet not connected");
691
+ if (!marketAddr) throw new Error("Market address not available");
692
+ const hash$1 = await writeContractAsync({
693
+ address: marketAddr,
694
+ abi: optionsMarketAbi,
695
+ functionName: "setOperatorPerms",
696
+ args: [
697
+ operator,
698
+ canExtend,
699
+ canExercise,
700
+ canTransfer,
701
+ canMint,
702
+ spendingApproval
703
+ ]
704
+ });
705
+ await waitForTransactionReceipt(client, { hash: hash$1 });
706
+ await queryClient.invalidateQueries({ queryKey: [
707
+ "userOperators",
708
+ address.toLowerCase(),
709
+ marketAddr.toLowerCase()
710
+ ] });
711
+ return hash$1;
712
+ };
713
+ return {
714
+ setOperatorPerms,
715
+ hash,
716
+ isPending,
717
+ isConfirming,
718
+ isSuccess,
719
+ error,
720
+ isLoading: isPending || isConfirming
721
+ };
722
+ };
723
+
681
724
  //#endregion
682
725
  //#region src/hooks/pool/usePriceAtTick.ts
683
726
  const usePriceAtTick = (tick, poolAddr) => {
@@ -1049,5 +1092,5 @@ const useVaultTVL = (vaultAddr) => {
1049
1092
  };
1050
1093
 
1051
1094
  //#endregion
1052
- export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
1095
+ export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
1053
1096
  //# sourceMappingURL=client.js.map