timelock-sdk 0.0.257 → 0.0.258

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
@@ -1199,22 +1199,21 @@ const useSetOperatorPerms = (marketAddr) => {
1199
1199
  const client = (0, wagmi.useClient)();
1200
1200
  const { address } = (0, wagmi.useConnection)();
1201
1201
  const { mutateAsync: writeContractAsync } = (0, wagmi.useWriteContract)();
1202
- const setOperatorPerms = async ({ operators, perms }) => {
1202
+ const setOperatorsPerms = async (perms) => {
1203
1203
  if (!client || !address) throw new Error("Wallet not connected");
1204
1204
  if (!marketAddr) throw new Error("Market address not available");
1205
- if (operators.length !== perms.length) throw new Error("Operators and perms arrays must have the same length");
1206
1205
  const hash = await writeContractAsync({
1207
1206
  address: marketAddr,
1208
1207
  abi: require_stateView.optionsMarketAbi,
1209
1208
  functionName: "setOperatorsPerms",
1210
- args: [operators, perms]
1209
+ args: [perms.map((perm) => perm.operator), perms]
1211
1210
  });
1212
1211
  await (0, viem_actions.waitForTransactionReceipt)(client, { hash });
1213
1212
  queryClient.invalidateQueries({ queryKey: ["userOperators"] });
1214
1213
  queryClient.invalidateQueries({ queryKey: ["readContract"] });
1215
1214
  return hash;
1216
1215
  };
1217
- return (0, _tanstack_react_query.useMutation)({ mutationFn: setOperatorPerms });
1216
+ return (0, _tanstack_react_query.useMutation)({ mutationFn: setOperatorsPerms });
1218
1217
  };
1219
1218
 
1220
1219
  //#endregion
@@ -1233,25 +1232,19 @@ const useMintPerp = (marketAddr) => {
1233
1232
  const updateOperatorPermsIfNeeded = async (requiredSpendingApproval) => {
1234
1233
  if (!operatorAddresses) return;
1235
1234
  const { data: operators = [] } = await refetchOperators();
1236
- const operatorsToUpdate = [];
1237
1235
  const permsToUpdate = [];
1238
1236
  for (const operatorAddr of operatorAddresses) {
1239
1237
  const userPerms = operators.find((o) => o.operatorAddr.toLowerCase() === operatorAddr.toLowerCase());
1240
- if (!(userPerms && userPerms.canMint && userPerms.canExtend && userPerms.canExercise && userPerms.spendingApproval > requiredSpendingApproval)) {
1241
- operatorsToUpdate.push(operatorAddr);
1242
- permsToUpdate.push({
1243
- canMint: true,
1244
- canExtend: true,
1245
- canExercise: true,
1246
- canTransfer: (userPerms === null || userPerms === void 0 ? void 0 : userPerms.canTransfer) ?? false,
1247
- spendingApproval: viem.maxUint256
1248
- });
1249
- }
1238
+ if (!(userPerms && userPerms.canMint && userPerms.canExtend && userPerms.canExercise && userPerms.spendingApproval > requiredSpendingApproval)) permsToUpdate.push({
1239
+ operator: operatorAddr,
1240
+ canMint: true,
1241
+ canExtend: true,
1242
+ canExercise: true,
1243
+ canTransfer: (userPerms === null || userPerms === void 0 ? void 0 : userPerms.canTransfer) ?? false,
1244
+ spendingApproval: viem.maxUint256
1245
+ });
1250
1246
  }
1251
- if (operatorsToUpdate.length > 0) await setOperatorPerms({
1252
- operators: operatorsToUpdate,
1253
- perms: permsToUpdate
1254
- });
1247
+ if (permsToUpdate.length > 0) await setOperatorPerms(permsToUpdate);
1255
1248
  };
1256
1249
  const mintPerp = async (data) => {
1257
1250
  const { optionType, amount, duration, strikeTick } = data;