feat: add name resovle

This commit is contained in:
liangping 2023-06-12 15:50:09 +08:00
parent 724ba72a71
commit b03bbfd860
3 changed files with 53 additions and 11 deletions

View File

@ -17,6 +17,7 @@
"@cosmjs/encoding": "^0.29.5",
"@iconify/vue": "^4.1.0",
"@intlify/unplugin-vue-i18n": "^0.8.2",
"@leapwallet/name-matcha": "^1.1.0",
"@osmonauts/lcd": "^0.8.0",
"@ping-pub/chain-registry-client": "^0.0.25",
"@vitejs/plugin-vue-jsx": "^3.0.0",

View File

@ -2,7 +2,8 @@
import { isBech32Address } from '@/libs/utils';
import { useBlockchain, useFormatter } from '@/stores';
import MdEditor from 'md-editor-v3';
import { computed } from 'vue';
import { computed, onMounted, ref } from 'vue';
import nameMatcha from '@leapwallet/name-matcha'
const chainStore = useBlockchain()
const props = defineProps(['value']);
@ -36,6 +37,13 @@ const text = computed(() => {
return v
})
const names = ref([] as {name?: string | null, provider?: string}[])
onMounted(() => {
if(isAddress()) nameMatcha.lookupAll(props.value).then(re => {
names.value = Object.keys(re).map(key => ({name: re[key], provider: key})).filter( x => x.name)
})
})
</script>
<template>
@ -45,7 +53,15 @@ const text = computed(() => {
previewOnly
class="md-editor-recover"
></MdEditor>
<RouterLink v-else-if="isAddress()" :to="`/${chainStore.chainName}/account/${text}`">{{ text }}</RouterLink>
<span v-else-if="isAddress()" class="flex">
<RouterLink :to="`/${chainStore.chainName}/account/${text}`">{{ text }}</RouterLink>
<div v-for="{name, provider} in names">
<span class="text-xs truncate relative py-1 px-2 p2-4 w-fit ml-2 rounded text-success tooltip" :data-tip="provider" :title="provider">
<span class="inset-x-0 inset-y-0 opacity-10 absolute bg-success"></span>
<button>{{ name }}</button>
</span>
</div>
</span>
<span v-else>{{ text }}</span>
</template>

View File

@ -1277,7 +1277,7 @@
"@cosmjs/math" "^0.29.3"
"@cosmjs/utils" "^0.29.3"
"@cosmjs/amino@^0.30.1":
"@cosmjs/amino@^0.30.0", "@cosmjs/amino@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.30.1.tgz#7c18c14627361ba6c88e3495700ceea1f76baace"
integrity sha512-yNHnzmvAlkETDYIpeCTdVqgvrdt1qgkOXwuRVi8s27UKI5hfqyE9fJ/fuunXE6ZZPnKkjIecDznmuUOMrMvw4w==
@ -1287,6 +1287,23 @@
"@cosmjs/math" "^0.30.1"
"@cosmjs/utils" "^0.30.1"
"@cosmjs/cosmwasm-stargate@0.30.0":
version "0.30.0"
resolved "https://registry.yarnpkg.com/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.30.0.tgz#b03c6c1383ef658695fcb02e6e1f4df2ddbd4710"
integrity sha512-nPJWpwSGpc15K88/9uxZmolEbixkeGzmxpTv6IbMAH23LXeJs7P+tXtgPe41ZjUw8Lt9Zc7ZOaOAqVveqqRktQ==
dependencies:
"@cosmjs/amino" "^0.30.0"
"@cosmjs/crypto" "^0.30.0"
"@cosmjs/encoding" "^0.30.0"
"@cosmjs/math" "^0.30.0"
"@cosmjs/proto-signing" "^0.30.0"
"@cosmjs/stargate" "^0.30.0"
"@cosmjs/tendermint-rpc" "^0.30.0"
"@cosmjs/utils" "^0.30.0"
cosmjs-types "^0.7.1"
long "^4.0.0"
pako "^2.0.2"
"@cosmjs/cosmwasm-stargate@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.30.1.tgz#6f9ca310f75433a3e30d683bc6aa24eadb345d79"
@ -1317,7 +1334,7 @@
elliptic "^6.5.4"
libsodium-wrappers "^0.7.6"
"@cosmjs/crypto@^0.30.1":
"@cosmjs/crypto@^0.30.0", "@cosmjs/crypto@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.30.1.tgz#21e94d5ca8f8ded16eee1389d2639cb5c43c3eb5"
integrity sha512-rAljUlake3MSXs9xAm87mu34GfBLN0h/1uPPV6jEwClWjNkAMotzjC0ab9MARy5FFAvYHL3lWb57bhkbt2GtzQ==
@ -1339,7 +1356,7 @@
bech32 "^1.1.4"
readonly-date "^1.0.0"
"@cosmjs/encoding@^0.30.1":
"@cosmjs/encoding@^0.30.0", "@cosmjs/encoding@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.30.1.tgz#b5c4e0ef7ceb1f2753688eb96400ed70f35c6058"
integrity sha512-rXmrTbgqwihORwJ3xYhIgQFfMSrwLu1s43RIK9I8EBudPx3KmnmyAKzMOVsRDo9edLFNuZ9GIvysUCwQfq3WlQ==
@ -1384,7 +1401,7 @@
dependencies:
bn.js "^5.2.0"
"@cosmjs/math@^0.30.1":
"@cosmjs/math@^0.30.0", "@cosmjs/math@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.30.1.tgz#8b816ef4de5d3afa66cb9fdfb5df2357a7845b8a"
integrity sha512-yaoeI23pin9ZiPHIisa6qqLngfnBR/25tSaWpkTm8Cy10MX70UF5oN4+/t1heLaM6SSmRrhk3psRkV4+7mH51Q==
@ -1404,7 +1421,7 @@
cosmjs-types "^0.5.2"
long "^4.0.0"
"@cosmjs/proto-signing@^0.30.1":
"@cosmjs/proto-signing@^0.30.0", "@cosmjs/proto-signing@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.30.1.tgz#f0dda372488df9cd2677150b89b3e9c72b3cb713"
integrity sha512-tXh8pPYXV4aiJVhTKHGyeZekjj+K9s2KKojMB93Gcob2DxUjfKapFYBMJSgfKPuWUPEmyr8Q9km2hplI38ILgQ==
@ -1455,7 +1472,7 @@
protobufjs "~6.11.3"
xstream "^11.14.0"
"@cosmjs/stargate@^0.30.1":
"@cosmjs/stargate@^0.30.0", "@cosmjs/stargate@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/stargate/-/stargate-0.30.1.tgz#e1b22e1226cffc6e93914a410755f1f61057ba04"
integrity sha512-RdbYKZCGOH8gWebO7r6WvNnQMxHrNXInY/gPHPzMjbQF6UatA6fNM2G2tdgS5j5u7FTqlCI10stNXrknaNdzog==
@ -1503,7 +1520,7 @@
readonly-date "^1.0.0"
xstream "^11.14.0"
"@cosmjs/tendermint-rpc@^0.30.1":
"@cosmjs/tendermint-rpc@^0.30.0", "@cosmjs/tendermint-rpc@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.30.1.tgz#c16378892ba1ac63f72803fdf7567eab9d4f0aa0"
integrity sha512-Z3nCwhXSbPZJ++v85zHObeUggrEHVfm1u18ZRwXxFE9ZMl5mXTybnwYhczuYOl7KRskgwlB+rID0WYACxj4wdQ==
@ -1524,7 +1541,7 @@
resolved "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.29.5.tgz"
integrity sha512-m7h+RXDUxOzEOGt4P+3OVPX7PuakZT3GBmaM/Y2u+abN3xZkziykD/NvedYFvvCCdQo714XcGl33bwifS9FZPQ==
"@cosmjs/utils@^0.30.1":
"@cosmjs/utils@^0.30.0", "@cosmjs/utils@^0.30.1":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.30.1.tgz#6d92582341be3c2ec8d82090253cfa4b7f959edb"
integrity sha512-KvvX58MGMWh7xA+N+deCfunkA/ZNDvFLw4YbOmX3f/XBIkqrVY7qlotfy2aNb1kgp6h4B6Yc8YawJPDTfvWX7g==
@ -2042,6 +2059,14 @@
resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz"
integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==
"@leapwallet/name-matcha@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@leapwallet/name-matcha/-/name-matcha-1.1.0.tgz#d06ed4fb1fba78553b6d6a304ac728f01e977952"
integrity sha512-KzjPon2WKgEmdrJdrWlaS9OXF9uKVBXZB00/VHA7bCRbZffnbxQXASvhpiRWEylINLNvWfBtftgg2s1g9jC46w==
dependencies:
"@cosmjs/cosmwasm-stargate" "0.30.0"
bech32 "1.1.4"
"@ledgerhq/devices@^5.51.1":
version "5.51.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-5.51.1.tgz#d741a4a5d8f17c2f9d282fd27147e6fe1999edb7"
@ -3133,7 +3158,7 @@ base64-js@^1.3.0, base64-js@^1.3.1:
resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
bech32@^1.1.4:
bech32@1.1.4, bech32@^1.1.4:
version "1.1.4"
resolved "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz"
integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==