timelock-sdk 0.0.96 → 0.0.98

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
@@ -803,7 +803,7 @@ const useOptionTimeline = (marketAddr, optionId) => {
803
803
  //#region src/lib/perpsOperator.ts
804
804
  var PerpsOperator = class {
805
805
  #baseUrl;
806
- #auth;
806
+ auth;
807
807
  constructor(baseUrl) {
808
808
  this.#baseUrl = baseUrl;
809
809
  }
@@ -850,7 +850,7 @@ var PerpsOperator = class {
850
850
  };
851
851
  }
852
852
  setAuth(authMessage, signature) {
853
- this.#auth = {
853
+ this.auth = {
854
854
  authMessage,
855
855
  signature
856
856
  };
@@ -869,10 +869,10 @@ var PerpsOperator = class {
869
869
  }));
870
870
  }
871
871
  async mintPerp(body) {
872
- if (!this.#auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
872
+ if (!this.auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
873
873
  const { txHash, optionId } = await this.#request("api/positions/mint", {
874
874
  ...body,
875
- ...this.#auth,
875
+ ...this.auth,
876
876
  amount: body.amount.toString()
877
877
  });
878
878
  return {
@@ -881,10 +881,10 @@ var PerpsOperator = class {
881
881
  };
882
882
  }
883
883
  async exercisePerp(body) {
884
- if (!this.#auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
884
+ if (!this.auth) throw new Error("Authentication required. Call setAuth() with authMessage and signature before exercising perps.");
885
885
  const { txHash, optionId } = await this.#request("api/positions/exercise", {
886
886
  ...body,
887
- ...this.#auth,
887
+ ...this.auth,
888
888
  optionId: body.optionId.toString(),
889
889
  liquidities: body.liquidities.map((l) => l.toString())
890
890
  });
@@ -1038,7 +1038,7 @@ const useMintPerp = (marketAddr) => {
1038
1038
  const queryClient = (0, __tanstack_react_query.useQueryClient)();
1039
1039
  const client = (0, wagmi.useClient)();
1040
1040
  const { address } = (0, wagmi.useAccount)();
1041
- const { operator, address: operatorAddr } = usePerpsOperator();
1041
+ const { operator, address: operatorAddr, signMessage: { mutateAsync: signMessage } } = usePerpsOperator();
1042
1042
  const { askForApproval } = useApproval();
1043
1043
  const { data: operators } = useUserOperators(address, marketAddr);
1044
1044
  const { mutateAsync: setOperatorPerms } = useSetOperatorPerms(marketAddr);
@@ -1054,6 +1054,7 @@ const useMintPerp = (marketAddr) => {
1054
1054
  if (!operator || !operatorAddr) throw new Error("Operator address not found");
1055
1055
  if (!tickSpacing || currentTick === void 0) throw new Error("Pool data not found");
1056
1056
  if (optionAssetIsToken0 === void 0 || !payoutAsset) throw new Error("Market data not found");
1057
+ if (!operator.auth) await signMessage();
1057
1058
  if (!hasEnoughPerms) await setOperatorPerms({
1058
1059
  operator: operatorAddr,
1059
1060
  canMint: true,
@@ -1088,10 +1089,11 @@ const useMintPerp = (marketAddr) => {
1088
1089
  //#endregion
1089
1090
  //#region src/hooks/perps/useClosePerp.ts
1090
1091
  const useClosePerp = () => {
1091
- const { operator } = usePerpsOperator();
1092
- return (0, __tanstack_react_query.useMutation)({ mutationFn: (body) => {
1092
+ const { operator, signMessage: { mutateAsync: signMessage } } = usePerpsOperator();
1093
+ return (0, __tanstack_react_query.useMutation)({ mutationFn: async (body) => {
1093
1094
  if (!operator) throw new Error("Operator not connected");
1094
- return operator.exercisePerp(body);
1095
+ if (!operator.auth) await signMessage();
1096
+ return await operator.exercisePerp(body);
1095
1097
  } });
1096
1098
  };
1097
1099