Skip to content

Commit bb0cf02

Browse files
committed
refactor: declare hexToBase58 separately and export
1 parent 6d9e8bb commit bb0cf02

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

packages/devtools/src/transactions/format.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ import { formatEid } from '@/omnigraph/format'
33
import { ChainType, endpointIdToChainType } from '@layerzerolabs/lz-definitions'
44
import bs58 from 'bs58'
55

6-
/**
7-
* Helper to check if an endpoint ID is for Solana
8-
*/
9-
const isSolanaEid = (eid: number): boolean => endpointIdToChainType(eid) === ChainType.SOLANA
10-
116
/**
127
* Format transaction data for display.
138
* Converts hex to base58 for Solana transactions.
149
*/
1510
const formatTransactionData = (data: string, eid: number): string => {
16-
if (!isSolanaEid(eid)) {
17-
return data
11+
const chainType = endpointIdToChainType(eid)
12+
13+
switch (chainType) {
14+
case ChainType.SOLANA:
15+
return hexToBase58(data)
16+
default:
17+
return data // default to hex string
1818
}
19+
}
1920

20-
// Convert hex string to base58 for Solana
21+
export const hexToBase58 = (hexString: string): string => {
2122
// Remove '0x' prefix if present
22-
const hexData = data.startsWith('0x') ? data.slice(2) : data
23+
const hexData = hexString.startsWith('0x') ? hexString.slice(2) : hexString
2324
const bytes = Uint8Array.from(Buffer.from(hexData, 'hex'))
2425
return bs58.encode(bytes)
2526
}

0 commit comments

Comments
 (0)