kodadot/nft-gallery

View on GitHub
composables/useAddress.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { isEthereumAddress } from '@polkadot/util-crypto'
import { type Prefix } from '@kodadot1/static'

export default function (urlPrefix: ComputedRef<Prefix> = usePrefix().urlPrefix) {
  const { isEvm, isSub } = useIsChain(urlPrefix)

  const getPrefixByAddress = (address: string) => {
    if (isEthereumAddress(address)) {
      return isEvm.value ? urlPrefix.value : 'base'
    }

    return isSub.value ? urlPrefix.value : 'ahp'
  }

  return {
    getPrefixByAddress,
  }
}