Skip to content

Commit

Permalink
update function
Browse files Browse the repository at this point in the history
  • Loading branch information
Lavinia Talpas authored and Lavinia Talpas committed May 17, 2024
1 parent c640272 commit 99afb5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/base58ToHex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Buffer } from 'buffer';
import { base58 } from '@scure/base';

/**
* Converts a base58check string to a hex string.
* Converts a base58 string to a hex string.
* @param {string} base58Str - The base58 string to be converted.
* @returns {string} - The hex string.
* @throws {Error} - If the conversion fails.
*/
export const base58ToHex = (base58Str: string): string => {
try {
const decoded = base58.decode(base58Str);
return '0x' + Buffer.from(decoded).toString('hex');
return `0x${Buffer.from(decoded).toString('hex')}`;
} catch (error) {
throw new Error('Failed to convert base58 to hex.');
}
Expand Down

0 comments on commit 99afb5f

Please sign in to comment.