Skip to content

Commit

Permalink
sol coding string length
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Jan 21, 2024
1 parent 68792be commit 2a25538
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/coin/sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ const coinType = 501;
export const encodeSolAddress = (source: Uint8Array) => {
if (source.length !== 32) throw new Error("Unrecognised address format");

return base58UncheckedEncode(source);
const encoded = base58UncheckedEncode(source);
if (encoded.length < 32 || encoded.length > 44)
throw new Error("Unrecognised address format");

return encoded;
};
export const decodeSolAddress = (source: string) => {
if (source.length < 32 || source.length > 44)
throw new Error("Unrecognised address format");

const decoded = base58UncheckedDecode(source);
if (decoded.length !== 32) throw new Error("Unrecognised address format");

Expand Down

0 comments on commit 2a25538

Please sign in to comment.