Skip to content

Commit

Permalink
fixup! fix(faucet): isValidAddress should accept all bech32 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Jun 26, 2024
1 parent a65fd8b commit cf48a81
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/faucet/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { fromBech32 } from "@cosmjs/encoding";
export function isValidAddress(input: string, requiredPrefix: string): boolean {
try {
const { prefix, data } = fromBech32(input);
return (
prefix === requiredPrefix && input.length >= 8 && input.length <= 90 && data.length >= 4 // 6 chars = 30 bits (3.75 bytes), rounded to whole byte
);
if (prefix !== requiredPrefix) {
return false;
}
return data.length >= 20 && data.length <= 32;
} catch {
return false;
}
Expand Down

0 comments on commit cf48a81

Please sign in to comment.