Skip to content

Commit

Permalink
Don't error if proposal message fails to decode. (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso authored Jan 30, 2023
1 parent 732acb4 commit 77ad4f9
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions apps/dapp/components/ProposalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,33 @@ export function ProposalDetails({
<StatelessProposalDetails
loading={loading}
messageToDisplay={(message) => {
const data = messageTemplateAndValuesForDecodedCosmosMsg(
message,
fromCosmosMsgProps
)
if (data) {
const ThisIsAComponentBecauseReactIsAnnoying = () => {
// Can't call `useForm` in a callback.
const formMethods = useForm({ defaultValues: data.values })
return (
<FormProvider {...formMethods}>
<form>
<data.template.component
contractAddress={contractAddress}
getLabel={(field: string) => field}
multisig={multisig}
readOnly
/>
</form>
</FormProvider>
)
// If message fails to decode, just display the JSON.
try {
const data = messageTemplateAndValuesForDecodedCosmosMsg(
message,
fromCosmosMsgProps
)
if (data) {
const ThisIsAComponentBecauseReactIsAnnoying = () => {
// Can't call `useForm` in a callback.
const formMethods = useForm({ defaultValues: data.values })
return (
<FormProvider {...formMethods}>
<form>
<data.template.component
contractAddress={contractAddress}
getLabel={(field: string) => field}
multisig={multisig}
readOnly
/>
</form>
</FormProvider>
)
}
return <ThisIsAComponentBecauseReactIsAnnoying />
}
return <ThisIsAComponentBecauseReactIsAnnoying />
} catch (e) {
console.error(e)
}
return (
<CosmosMessageDisplay value={JSON.stringify(message, undefined, 2)} />
Expand Down

0 comments on commit 77ad4f9

Please sign in to comment.