Skip to content

Commit

Permalink
Merge pull request #2877 from IntersectMBO/fix/2680-cannot-communicat…
Browse files Browse the repository at this point in the history
…e-with-ledger-cardano-app-due-to-devicestatuserror

fix(#2680): remove redundant sentry reports an handled wallet exceptions
  • Loading branch information
MSzalowski authored Feb 3, 2025
2 parents c053055 + a132b76 commit e1831a9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 55 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ changes.

### Removed

-
- Remove redundant sentry reports on handled wallet exceptions [Issue 2680](https://github.com/IntersectMBO/govtool/issues/2680)

## [v2.0.10](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.10) 2025-01-29

Expand Down
52 changes: 22 additions & 30 deletions govtool/frontend/src/hooks/forms/useCreateGovernanceActionForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Dispatch, SetStateAction, useCallback, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useFormContext } from "react-hook-form";
import { blake2bHex } from "blakejs";
import * as Sentry from "@sentry/react";
import { useTranslation } from "react-i18next";
import { NodeObject } from "jsonld";

Expand Down Expand Up @@ -129,36 +128,31 @@ export const useCreateGovernanceActionForm = (
hash,
url: data.storingURL,
};
try {
switch (govActionType) {
case GovernanceActionType.InfoAction:
return await buildNewInfoGovernanceAction(commonGovActionDetails);
case GovernanceActionType.TreasuryWithdrawals: {
if (
data.amount === undefined ||
data.receivingAddress === undefined
) {
throw new Error(t("errors.invalidTreasuryGovernanceActionType"));
}
switch (govActionType) {
case GovernanceActionType.InfoAction:
return buildNewInfoGovernanceAction(commonGovActionDetails);
case GovernanceActionType.TreasuryWithdrawals: {
if (
data.amount === undefined ||
data.receivingAddress === undefined
) {
throw new Error(t("errors.invalidTreasuryGovernanceActionType"));
}

const treasuryActionDetails = {
...commonGovActionDetails,
withdrawals: [
{
amount: data.amount,
receivingAddress: data.receivingAddress,
},
],
};
const treasuryActionDetails = {
...commonGovActionDetails,
withdrawals: [
{
amount: data.amount,
receivingAddress: data.receivingAddress,
},
],
};

return await buildTreasuryGovernanceAction(treasuryActionDetails);
}
default:
throw new Error(t("errors.invalidGovernanceActionType"));
return buildTreasuryGovernanceAction(treasuryActionDetails);
}
} catch (error) {
Sentry.setTag("hook", "useCreateGovernanceActionForm");
Sentry.captureException(error);
default:
throw new Error(t("errors.invalidGovernanceActionType"));
}
},
[hash],
Expand Down Expand Up @@ -249,8 +243,6 @@ export const useCreateGovernanceActionForm = (
: undefined,
dataTestId: "create-governance-action-error-modal",
});
Sentry.setTag("hook", "useCreateGovernanceActionForm");
Sentry.captureException(error);
}
} finally {
setIsLoading(false);
Expand Down
4 changes: 0 additions & 4 deletions govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { useFormContext } from "react-hook-form";
import { blake2bHex } from "blakejs";
import * as Sentry from "@sentry/react";
import { NodeObject } from "jsonld";

import { DREP_CONTEXT, PATHS, storageInformationErrorModals } from "@consts";
Expand Down Expand Up @@ -172,9 +171,6 @@ export const useEditDRepInfoForm = (
},
});
} else {
Sentry.setTag("hook", "useEditDRepInfoForm");
Sentry.captureException(error);

openWalletErrorModal({
error: error?.message ? error.message : JSON.stringify(error),
onSumbit: () => backToDashboard(),
Expand Down
25 changes: 5 additions & 20 deletions govtool/frontend/src/hooks/forms/useVoteContextForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Dispatch, SetStateAction, useCallback, useState } from "react";
import { useFormContext } from "react-hook-form";
import { blake2bHex } from "blakejs";
import * as Sentry from "@sentry/react";
import { NodeObject } from "jsonld";

import { downloadJson, generateJsonld, generateMetadataBody } from "@utils";
Expand Down Expand Up @@ -60,16 +59,16 @@ export const useVoteContextForm = (
downloadJson(json, "Vote_Context");
};

const validateHash = useCallback(
async (url: string, localHash: string | null) => {
const onSubmit = useCallback(
async (data: VoteContextFormValues) => {
try {
if (!localHash) {
if (!hash) {
throw new Error(MetadataValidationStatus.INVALID_HASH);
}

const result = await validateMetadata({
hash: localHash,
url,
hash,
url: data.storingURL,
});

if (result.status) {
Expand All @@ -82,20 +81,6 @@ export const useVoteContextForm = (
if (setErrorMessage) setErrorMessage(error);
if (setStep) setStep(4);
}
throw error;
}
},
[],
);

const onSubmit = useCallback(
async (data: VoteContextFormValues) => {
try {
await validateHash(data.storingURL, hash);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
Sentry.setTag("hook", "useVoteContextForm");
Sentry.captureException(error);
} finally {
if (setSavedHash) setSavedHash(hash);
if (setStep) setStep(4);
Expand Down

0 comments on commit e1831a9

Please sign in to comment.