Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sworzen1 committed Mar 25, 2024
1 parent 0f6ca65 commit 51e1e22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const StorageInformation = ({ setStep }: StorageInformationProps) => {
const openGuideAboutStoringInformation = () =>
openInNewTab("https://sancho.network/");

const isActionButtonDisabled = !watch("storingURL") || !!errors["storingURL"];
const isActionButtonDisabled = !watch("storingURL") || !!errors.storingURL;

const onClickBack = () => setStep(5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const DRepStorageInformation = ({
const openGuideAboutStoringInformation = () =>
openInNewTab("https://sancho.network/");

const isActionButtonDisabled = !watch("storingURL") || !!errors["storingURL"];
const isActionButtonDisabled = !watch("storingURL") || !!errors.storingURL;

const onClickBack = () => setStep(3);

Expand Down
25 changes: 13 additions & 12 deletions govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export const useRegisterAsdRepForm = (
const jsonld = await generateJsonld(body, DREP_CONTEXT, CIP_QQQ);

const canonizedJson = await canonizeJSON(jsonld);
const hash = blake2bHex(canonizedJson, undefined, 32);
const canonizedJsonHash = blake2bHex(canonizedJson, undefined, 32);

setHash(hash);
setHash(canonizedJsonHash);
setJson(jsonld);

return jsonld;
Expand All @@ -116,11 +116,12 @@ export const useRegisterAsdRepForm = (
};

const validateHash = useCallback(
async (storingUrl: string, hash: string | null) => {
async (storingUrl: string) => {
try {
if (!hash) throw new Error(MetadataHashValidationErrors.INVALID_HASH);

await validateMetadataHash(storingUrl, hash);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (
Object.values(MetadataHashValidationErrors).includes(error.message)
Expand All @@ -141,7 +142,7 @@ export const useRegisterAsdRepForm = (
throw error;
}
},
[backToForm],
[backToForm, hash],
);

const createRegistrationCert = useCallback(
Expand All @@ -150,14 +151,14 @@ export const useRegisterAsdRepForm = (
const url = data.storingURL;

try {
let certBuilder;
if (voter?.isRegisteredAsSoleVoter) {
certBuilder = await buildDRepUpdateCert(url, hash);
} else {
certBuilder = await buildDRepRegCert(url, hash);
return await buildDRepUpdateCert(url, hash);
}
return certBuilder;

return await buildDRepRegCert(url, hash);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
// eslint-disable-next-line no-console
console.error(error);
throw error;
}
Expand Down Expand Up @@ -189,22 +190,22 @@ export const useRegisterAsdRepForm = (
try {
setIsLoading(true);

await validateHash(data.storingURL, hash);
await validateHash(data.storingURL);
const registerAsDRepCert = await createRegistrationCert(data);
await buildSignSubmitConwayCertTx({
certBuilder: registerAsDRepCert,
type: "registerAsDrep",
});

showSuccessModal();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
captureException(error);
console.error(error);
} finally {
setIsLoading(false);
}
},
[buildSignSubmitConwayCertTx, createRegistrationCert, hash],
[buildSignSubmitConwayCertTx, createRegistrationCert, hash, validateHash],
);

return {
Expand Down

0 comments on commit 51e1e22

Please sign in to comment.