Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions govtool/frontend/src/utils/drepSearchPhraseProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ export const dRepSearchPhraseProcessor = async (phrase: string) => {
let drepIDPhrase = phrase;

try {
const adaHandleCIP105DRepId =
await adaHandleService.getAdaHandleCIP105DRepId(phrase);
if (adaHandleCIP105DRepId) {
return adaHandleCIP105DRepId;
}

if (
drepIDPhrase.startsWith("drep_script") ||
drepIDPhrase.startsWith("drep")
Expand All @@ -33,6 +27,12 @@ export const dRepSearchPhraseProcessor = async (phrase: string) => {
return drepIDPhrase.slice(2);
}

const adaHandleCIP105DRepId =
await adaHandleService.getAdaHandleCIP105DRepId(phrase);
if (adaHandleCIP105DRepId) {
return adaHandleCIP105DRepId;
}

return drepIDPhrase;
} catch (e) {
return phrase;
Expand Down
7 changes: 6 additions & 1 deletion govtool/frontend/src/utils/getImageSha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
*/
export const getImageSha = async (imageUrl: string) => {
try {
const response = await fetch(imageUrl);
const response = await fetch(imageUrl, {
// Required to not being blocked by APIs that require a User-Agent
headers: {
"User-Agent": "GovTool/image-sha",
},
});
if (!response.ok)
throw new Error(`Failed to fetch image: ${response.statusText}`);

Expand Down
10 changes: 6 additions & 4 deletions govtool/frontend/src/utils/isValidFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ export async function isReceivingAddress(address?: string) {
if (!address) {
return true;
}

const receivingAddress = Address.from_bech32(address);
if (receivingAddress) {
return true;
}
const isValidAdaHandle = await adaHandleService.isValidAdaHandle(address);

if (isValidAdaHandle) {
return true;
}

const receivingAddress = Address.from_bech32(address);
return receivingAddress
? true
: i18n.t("forms.errors.mustBeReceivingAddress");
return i18n.t("forms.errors.mustBeReceivingAddress");
} catch (e) {
return i18n.t("forms.errors.mustBeReceivingAddress");
}
Expand Down