Skip to content

Commit cf25453

Browse files
authored
Merge pull request #3171 from IntersectMBO/fix/fix-network-issues-with-images-and-adahandle
fix: network issues with drep images and adahandle
2 parents 349220e + eac6b50 commit cf25453

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

govtool/frontend/src/utils/drepSearchPhraseProcessor.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ export const dRepSearchPhraseProcessor = async (phrase: string) => {
1515
let drepIDPhrase = phrase;
1616

1717
try {
18-
const adaHandleCIP105DRepId =
19-
await adaHandleService.getAdaHandleCIP105DRepId(phrase);
20-
if (adaHandleCIP105DRepId) {
21-
return adaHandleCIP105DRepId;
22-
}
23-
2418
if (
2519
drepIDPhrase.startsWith("drep_script") ||
2620
drepIDPhrase.startsWith("drep")
@@ -33,6 +27,12 @@ export const dRepSearchPhraseProcessor = async (phrase: string) => {
3327
return drepIDPhrase.slice(2);
3428
}
3529

30+
const adaHandleCIP105DRepId =
31+
await adaHandleService.getAdaHandleCIP105DRepId(phrase);
32+
if (adaHandleCIP105DRepId) {
33+
return adaHandleCIP105DRepId;
34+
}
35+
3636
return drepIDPhrase;
3737
} catch (e) {
3838
return phrase;

govtool/frontend/src/utils/getImageSha.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
*/
77
export const getImageSha = async (imageUrl: string) => {
88
try {
9-
const response = await fetch(imageUrl);
9+
const response = await fetch(imageUrl, {
10+
// Required to not being blocked by APIs that require a User-Agent
11+
headers: {
12+
"User-Agent": "GovTool/image-sha",
13+
},
14+
});
1015
if (!response.ok)
1116
throw new Error(`Failed to fetch image: ${response.statusText}`);
1217

govtool/frontend/src/utils/isValidFormat.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,18 @@ export async function isReceivingAddress(address?: string) {
4848
if (!address) {
4949
return true;
5050
}
51+
52+
const receivingAddress = Address.from_bech32(address);
53+
if (receivingAddress) {
54+
return true;
55+
}
5156
const isValidAdaHandle = await adaHandleService.isValidAdaHandle(address);
5257

5358
if (isValidAdaHandle) {
5459
return true;
5560
}
5661

57-
const receivingAddress = Address.from_bech32(address);
58-
return receivingAddress
59-
? true
60-
: i18n.t("forms.errors.mustBeReceivingAddress");
62+
return i18n.t("forms.errors.mustBeReceivingAddress");
6163
} catch (e) {
6264
return i18n.t("forms.errors.mustBeReceivingAddress");
6365
}

0 commit comments

Comments
 (0)