timelock-sdk 0.0.232 → 0.0.234

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
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- const require_numberUtils = require('./numberUtils-DYC2nVsT.cjs');
3
+ const require_numberUtils = require('./numberUtils-B-inHOvt.cjs');
4
4
  const require_stateView = require('./stateView-BMkpa0rT.cjs');
5
5
  const require_factory = require('./factory-5hUk9F0p.cjs');
6
6
  let viem = require("viem");
@@ -12,7 +12,6 @@ graphql_tag = require_numberUtils.__toESM(graphql_tag);
12
12
  let wagmi = require("wagmi");
13
13
  let _tanstack_react_query = require("@tanstack/react-query");
14
14
  let viem_actions = require("viem/actions");
15
- let zod = require("zod");
16
15
 
17
16
  //#region src/generated/timelock.ts
18
17
  const UserOptionFieldsFragmentDoc = graphql_tag.default`
@@ -1101,7 +1100,8 @@ const useMintOption = (marketAddr) => {
1101
1100
  amount,
1102
1101
  strikeTick,
1103
1102
  duration,
1104
- 0
1103
+ 0,
1104
+ "0x"
1105
1105
  ]);
1106
1106
  const maxPremium = (premium + protocolFee) * 11n / 10n;
1107
1107
  await askForApproval(payoutAsset, marketAddr, maxPremium);
@@ -1117,7 +1117,8 @@ const useMintOption = (marketAddr) => {
1117
1117
  duration,
1118
1118
  maxPremium,
1119
1119
  maxSteps,
1120
- await timelockLens.read.getRefTick([vault, strikeTick])
1120
+ await timelockLens.read.getRefTick([vault, strikeTick]),
1121
+ "0x"
1121
1122
  ]
1122
1123
  });
1123
1124
  await (0, viem_actions.waitForTransactionReceipt)(client, { hash });
@@ -1457,7 +1458,7 @@ const useExtendOption = (marketAddr) => {
1457
1458
  //#endregion
1458
1459
  //#region src/hooks/options/useOptionTimeline.ts
1459
1460
  const useOptionTimeline = (marketAddr, optionId) => {
1460
- const { graphqlClient } = useTimelockConfig();
1461
+ const { timelockGraphqlClient } = useTimelockConfig();
1461
1462
  marketAddr = marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase();
1462
1463
  return (0, _tanstack_react_query.useQuery)({
1463
1464
  queryKey: [
@@ -1466,8 +1467,8 @@ const useOptionTimeline = (marketAddr, optionId) => {
1466
1467
  (optionId === null || optionId === void 0 ? void 0 : optionId.toString()) || "--"
1467
1468
  ],
1468
1469
  queryFn: async () => {
1469
- if (!graphqlClient || !marketAddr || optionId === void 0) return [];
1470
- const result = await graphqlClient.GetOptionEvents({
1470
+ if (!timelockGraphqlClient || !marketAddr || optionId === void 0) return [];
1471
+ const result = await timelockGraphqlClient.GetOptionEvents({
1471
1472
  marketAddr,
1472
1473
  optionId: optionId.toString()
1473
1474
  });
@@ -1518,23 +1519,29 @@ const useOptionTimeline = (marketAddr, optionId) => {
1518
1519
  }))
1519
1520
  ].sort((a, b) => a.data.timestamp.getTime() - b.data.timestamp.getTime());
1520
1521
  },
1521
- enabled: !!marketAddr && optionId !== void 0 && !!graphqlClient
1522
+ enabled: !!marketAddr && optionId !== void 0 && !!timelockGraphqlClient
1522
1523
  });
1523
1524
  };
1524
1525
 
1525
1526
  //#endregion
1526
1527
  //#region src/hooks/perps/usePerpsOperator.ts
1527
- const ZHex = zod.z.string().regex(/^0x[a-fA-F0-9]+$/, "Invalid hex string").transform((v) => v);
1528
- const ZSavedSignature = zod.z.object({
1529
- signature: ZHex,
1530
- message: zod.z.string()
1531
- });
1528
+ const isValidHex = (value) => {
1529
+ return typeof value === "string" && /^0x[a-fA-F0-9]+$/.test(value);
1530
+ };
1531
+ const isValidSavedSignature = (data) => {
1532
+ return typeof data === "object" && data !== null && "signature" in data && "message" in data && isValidHex(data.signature) && typeof data.message === "string";
1533
+ };
1532
1534
  const getSavedSignature = (userAddr) => {
1533
1535
  const key = `perps-auth-${userAddr.toLowerCase()}`;
1534
1536
  const raw = localStorage.getItem(key);
1535
1537
  if (!raw) return;
1536
1538
  try {
1537
- return ZSavedSignature.parse(JSON.parse(raw));
1539
+ const parsed = JSON.parse(raw);
1540
+ if (!isValidSavedSignature(parsed)) {
1541
+ clearSignature(userAddr);
1542
+ throw new Error("Invalid stored signature: " + raw);
1543
+ }
1544
+ return parsed;
1538
1545
  } catch (error) {
1539
1546
  clearSignature(userAddr);
1540
1547
  throw new Error("Invalid stored signature: " + raw);
@@ -1555,7 +1562,7 @@ const clearSignature = (userAddr) => {
1555
1562
  const usePerpsOperator = () => {
1556
1563
  const { address: userAddr } = (0, wagmi.useConnection)();
1557
1564
  const { perpsOperatorUrl, perpsOperator: operator } = useTimelockConfig();
1558
- const { signMessageAsync } = (0, wagmi.useSignMessage)();
1565
+ const { mutateAsync: signMessageAsync } = (0, wagmi.useSignMessage)();
1559
1566
  const { data: address } = (0, _tanstack_react_query.useQuery)({
1560
1567
  queryKey: ["perpsOperatorAddr", perpsOperatorUrl || "--"],
1561
1568
  queryFn: () => operator === null || operator === void 0 ? void 0 : operator.getOperatorAddr(),