From a26a3c605cfa702e42d901536ed80a1d77fc781c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 30 Aug 2024 13:22:53 +0200 Subject: [PATCH] fix(#1871): make payment address validation optional --- CHANGELOG.md | 1 + .../frontend/src/hooks/forms/useEditDRepInfoForm.ts | 11 ++++++++--- .../src/hooks/forms/useRegisterAsdRepForm.tsx | 2 -- govtool/frontend/src/utils/isValidFormat.ts | 5 ++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bddf1842a..276038b3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ changes. - Fix displaying non relevant data in protocol parameter change Governance Action [Issue 1601](https://github.com/IntersectMBO/govtool/issues/1601) - Fix voting on info actions in bootstrapping phase [Issue 1876](https://github.com/IntersectMBO/govtool/issues/1876) - Fix missing DRep name whitespace validation [Issue 1873](https://github.com/IntersectMBO/govtool/issues/1873) +- Make payment address optional in DRep registration and edit form [Issue 1871](https://github.com/IntersectMBO/govtool/issues/1871) ### Changed diff --git a/govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts b/govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts index aa4d5b8e8..d1b920f84 100644 --- a/govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts +++ b/govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts @@ -68,7 +68,6 @@ export const useEditDRepInfoForm = ( handleSubmit, formState: { errors, isValid }, register, - resetField, reset, watch, } = useFormContext(); @@ -91,7 +90,14 @@ export const useEditDRepInfoForm = ( const generateMetadata = useCallback(async () => { const body = generateMetadataBody({ data: getValues(), - acceptedKeys: ["givenName", "objectives", "motivations", "qualifications", "paymentAddress", "references"], + acceptedKeys: [ + "givenName", + "objectives", + "motivations", + "qualifications", + "paymentAddress", + "references", + ], standardReference: CIP_119, }); @@ -204,7 +210,6 @@ export const useEditDRepInfoForm = ( onClickDownloadJson, register, editDRepInfo: handleSubmit(onSubmit), - resetField, watch, reset, }; diff --git a/govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx b/govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx index 51b46e943..d2f639aee 100644 --- a/govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx +++ b/govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx @@ -81,7 +81,6 @@ export const useRegisterAsdRepForm = ( handleSubmit, formState: { errors, isValid }, register, - resetField, watch, } = useFormContext(); @@ -250,7 +249,6 @@ export const useRegisterAsdRepForm = ( onClickDownloadJson, register, registerAsDrep: handleSubmit(onSubmit), - resetField, watch, }; }; diff --git a/govtool/frontend/src/utils/isValidFormat.ts b/govtool/frontend/src/utils/isValidFormat.ts index 9d23b4548..f192e7885 100644 --- a/govtool/frontend/src/utils/isValidFormat.ts +++ b/govtool/frontend/src/utils/isValidFormat.ts @@ -39,8 +39,11 @@ export async function isRewardAddress(address: string) { } } -export async function isReceivingAddress(address: string) { +export async function isReceivingAddress(address?: string) { try { + if (!address) { + return true; + } const receivingAddress = Address.from_bech32(address); return receivingAddress ? true