Skip to content

Commit

Permalink
Show proper message to user and don't move forward, when proposal fun…
Browse files Browse the repository at this point in the history
…ction encoding doesn't work
  • Loading branch information
adamgall committed May 3, 2024
1 parent 3ccc908 commit d344644
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/ProposalBuilder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Formik, FormikProps } from 'formik';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
import { BACKGROUND_SEMI_TRANSPARENT } from '../../constants/common';
import { DAO_ROUTES, BASE_ROUTES } from '../../constants/routes';
import useSubmitProposal from '../../hooks/DAO/proposal/useSubmitProposal';
Expand Down Expand Up @@ -61,7 +62,11 @@ export default function ProposalBuilder({
initialValues={initialValues}
enableReinitialize
onSubmit={async values => {
if (canUserCreateProposal) {
if (!false) {
toast(t('errorNotProposer', { ns: 'common' }));
}

try {
const proposalData = await prepareProposalData(values);
if (proposalData) {
submitProposal({
Expand All @@ -73,6 +78,8 @@ export default function ProposalBuilder({
successCallback,
});
}
} catch {
toast(t('encodingFailedMessage', { ns: 'proposal' }));
}
}}
>
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en/proposal.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"multisigMetadataMessage": "This transaction contains the proposal's encoded metadata.",
"multisigMetadataWarning": "Adding metadata (title, description, url) to a multisig proposal will add execution cost.",
"decodingFailedMessage": "Unable to decode transaction's data.",
"encodingFailedMessage": "Unable to encode proposal data.",
"customNonce": "Custom Nonce",
"customNonceTooltip": "Set a custom proposal nonce if necessary to prevent nonce collisions",
"nonce": "Nonce",
Expand Down

0 comments on commit d344644

Please sign in to comment.