import { normalize } from '@utils' ; export interface ITLDCollection { [ key ] : boolean ; } export function getENSTLDForChain ( chainId ) { if ( chainId === 30 ) { return 'rsk' ; } return 'eth' ; } export function getValidTLDsForChain ( chainId ) { if ( chainId === 30 ) { return { rsk : true } ; } return { eth : true , test : true , reverse : true , xyz : true } ; } export function isValidENSName ( str ) { try { return str . includes ( '.' ) && normalize ( str ) !== '' ; } catch ( e ) { return false ; } } export function isValidENSAddress ( address , validTLDs ) { try { const normalized = normalize ( address ) ; const tld = normalized . substr ( normalized . lastIndexOf ( '.' ) + 1 ) ; if ( validTLDs [ tld ] ) { return true ; } } catch ( e ) { return false ; } return false ; } export function getIsValidENSAddressFunction ( chainId ) { const validTLDs = getValidTLDsForChain ( chainId ) ; return ( address ) => isValidENSAddress ( address , validTLDs ) ; }