11import { Input , type Suggestion } from './Input' ;
22import { useMemo , useState , useEffect } from 'react' ;
3- import { cb58ToHex , hexToCB58 } from '../console/utilities/format-converter/FormatConverter ' ;
3+ import { CB58ToHex , hexToCB58 } from '@avalanche-sdk/client/utils ' ;
44import { L1ValidatorDetailsFull } from '@avalabs/avacloud-sdk/models/components' ;
55import { formatAvaxBalance } from '../coreViem/utils/format' ;
66import { useAvalancheSDKChainkit } from '../stores/useAvalancheSDKChainkit' ;
@@ -108,7 +108,7 @@ export default function SelectValidationID({
108108 mapping [ v . validationId ] = v . nodeId ;
109109 // Also add hex format for easy lookup
110110 try {
111- const hexId = '0x' + cb58ToHex ( v . validationId ) ;
111+ const hexId = CB58ToHex ( v . validationId ) ;
112112 mapping [ hexId ] = v . nodeId ;
113113 } catch {
114114 // Skip if conversion fails
@@ -136,7 +136,7 @@ export default function SelectValidationID({
136136
137137 // Build multicall contracts array
138138 const contracts = validatorsWithId . map ( ( v ) => {
139- const hexId = '0x' + cb58ToHex ( v . validationId ) ;
139+ const hexId = CB58ToHex ( v . validationId ) ;
140140 return {
141141 address : vmcAddr ,
142142 abi : ValidatorManagerAbi . abi ,
@@ -166,7 +166,7 @@ export default function SelectValidationID({
166166 // Store by both cb58 and hex IDs for easy lookup
167167 statusMap [ v . validationId ] = data . status ;
168168 try {
169- const hexId = '0x' + cb58ToHex ( v . validationId ) ;
169+ const hexId = CB58ToHex ( v . validationId ) ;
170170 statusMap [ hexId ] = data . status ;
171171 } catch {
172172 // skip
@@ -187,7 +187,7 @@ export default function SelectValidationID({
187187 return (
188188 validationIdToNodeId [ value ] ||
189189 ( value && value . startsWith ( '0x' ) && validationIdToNodeId [ value ] ) ||
190- ( value && ! value . startsWith ( '0x' ) && validationIdToNodeId [ '0x' + cb58ToHex ( value ) ] ) ||
190+ ( value && ! value . startsWith ( '0x' ) && validationIdToNodeId [ CB58ToHex ( value ) ] ) ||
191191 ''
192192 ) ;
193193 } , [ value , validationIdToNodeId ] ) ;
@@ -214,7 +214,7 @@ export default function SelectValidationID({
214214 // Add just one version based on the format prop
215215 if ( format === 'hex' ) {
216216 try {
217- const hexId = '0x' + cb58ToHex ( validator . validationId ) ;
217+ const hexId = CB58ToHex ( validator . validationId ) ;
218218 result . push ( {
219219 title : `${ nodeId } ${ isSelected ? ' ✓' : '' } ` ,
220220 value : hexId ,
@@ -245,10 +245,10 @@ export default function SelectValidationID({
245245 try {
246246 if ( format === 'hex' && ! newValue . startsWith ( '0x' ) ) {
247247 // Convert CB58 to hex
248- formattedValue = '0x' + cb58ToHex ( newValue ) ;
248+ formattedValue = CB58ToHex ( newValue ) ;
249249 } else if ( format === 'cb58' && newValue . startsWith ( '0x' ) ) {
250250 // Convert hex to CB58
251- formattedValue = hexToCB58 ( newValue . slice ( 2 ) ) ;
251+ formattedValue = hexToCB58 ( newValue as `0x${ string } ` ) ;
252252 }
253253 } catch {
254254 // If conversion fails, use the original value
@@ -260,7 +260,7 @@ export default function SelectValidationID({
260260
261261 // If not found directly, try the alternate format
262262 if ( ! nodeId ) {
263- const alternateFormat = format === 'hex' ? hexToCB58 ( formattedValue . slice ( 2 ) ) : '0x' + cb58ToHex ( formattedValue ) ;
263+ const alternateFormat = format === 'hex' ? hexToCB58 ( formattedValue as `0x${ string } ` ) : CB58ToHex ( formattedValue ) ;
264264 nodeId = validationIdToNodeId [ alternateFormat ] || '' ;
265265 }
266266
0 commit comments