forked from cerc-io/cosmos-explorer
add IBC name/star name resolve
This commit is contained in:
@@ -114,7 +114,14 @@
|
||||
>
|
||||
<div class="d-flex flex-column">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="font-weight-bolder">{{ item.wallet }}
|
||||
<span class="font-weight-bolder">
|
||||
{{ item.wallet }}
|
||||
<b-badge
|
||||
v-for="(name, i) in names[item.address.addr]"
|
||||
:key="i"
|
||||
v-b-tooltip.hover.top="name.provider"
|
||||
variant="primary"
|
||||
>{{ name.name }}</b-badge>
|
||||
<b-avatar
|
||||
v-if="item.wallet===walletName"
|
||||
variant="success"
|
||||
@@ -187,7 +194,7 @@
|
||||
<script>
|
||||
import {
|
||||
BLink, BNavbarNav, BMedia, BMediaAside, BAvatar, BMediaBody, VBTooltip, BButton,
|
||||
BDropdown, BDropdownItem, BDropdownDivider,
|
||||
BDropdown, BDropdownItem, BDropdownDivider, BBadge,
|
||||
} from 'bootstrap-vue'
|
||||
import Ripple from 'vue-ripple-directive'
|
||||
import DarkToggler from '@core/layouts/components/app-navbar/components/DarkToggler.vue'
|
||||
@@ -195,11 +202,13 @@ import Locale from '@core/layouts/components/app-navbar/components/Locale.vue'
|
||||
import SearchBar from '@core/layouts/components/app-navbar/components/SearchBar.vue'
|
||||
// import CartDropdown from '@core/layouts/components/app-navbar/components/CartDropdown.vue'
|
||||
import { getLocalAccounts, timeIn, toDay } from '@/libs/utils'
|
||||
import { resolvePrimaryDomainByAddress } from 'ibc-domains-sdk'
|
||||
// import UserDropdown from '@core/layouts/components/app-navbar/components/UserDropdown.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BLink,
|
||||
BBadge,
|
||||
BNavbarNav,
|
||||
BAvatar,
|
||||
BMedia,
|
||||
@@ -233,6 +242,7 @@ export default {
|
||||
tips: 'Synced',
|
||||
index: 0,
|
||||
chainid: '',
|
||||
names: {},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -276,6 +286,30 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
formatAddr(v) {
|
||||
this.$http.resolveStarName(v).then(res => {
|
||||
const name = {
|
||||
name: res.data,
|
||||
provider: 'Stargaze',
|
||||
}
|
||||
if (this.names[v]) {
|
||||
this.names[v].push(name)
|
||||
} else {
|
||||
this.names[v] = [name]
|
||||
}
|
||||
})
|
||||
resolvePrimaryDomainByAddress(this.address).then(result => {
|
||||
if (result.isOk()) {
|
||||
const name = {
|
||||
name: result.value,
|
||||
provider: 'IBC Domain',
|
||||
}
|
||||
if (this.names[v]) {
|
||||
this.names[v].push(name)
|
||||
} else {
|
||||
this.names[v] = [name]
|
||||
}
|
||||
}
|
||||
})
|
||||
return v.substring(0, 10).concat('...', v.substring(v.length - 10))
|
||||
},
|
||||
updateDefaultWallet(v) {
|
||||
|
||||
@@ -630,6 +630,13 @@ export default class ChainFetch {
|
||||
return index < conf.api.length ? index : 0
|
||||
}
|
||||
|
||||
async resolveStarName(address) {
|
||||
const endpoint = 'https://rest.stargaze-apis.com'
|
||||
const query = toBase64(Buffer.from(JSON.stringify({ name: { address } })))
|
||||
const contract = 'stars1fx74nkqkw2748av8j7ew7r3xt9cgjqduwn8m0ur5lhe49uhlsasszc5fhr'
|
||||
return this.getUrl(`${endpoint}/cosmwasm/wasm/v1/contract/${contract}/smart/${query}`)
|
||||
}
|
||||
|
||||
async getUrl(url) {
|
||||
this.getSelectedConfig()
|
||||
return fetch(url).then(res => res.json())
|
||||
|
||||
@@ -29,7 +29,14 @@
|
||||
@click="copy()"
|
||||
/>
|
||||
</h3>
|
||||
{{ address }}
|
||||
{{ address }} <b-badge
|
||||
v-for="name in names"
|
||||
:key="name.name"
|
||||
v-b-tooltip.hover.top="name.provider"
|
||||
variant="primary"
|
||||
>
|
||||
{{ name.name }}
|
||||
</b-badge>
|
||||
<span v-if="isEthAddr"> - {{ ethaddress() }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -427,7 +434,7 @@ import { $themeColors } from '@themeConfig'
|
||||
import dayjs from 'dayjs'
|
||||
import {
|
||||
BCard, BAvatar, BPopover, BTable, BRow, BCol, BTableSimple, BTr, BTd, BTbody, BCardHeader, BCardTitle, BButton, BCardBody, VBModal,
|
||||
BButtonGroup, VBTooltip, BPagination,
|
||||
BButtonGroup, VBTooltip, BPagination, BBadge,
|
||||
} from 'bootstrap-vue'
|
||||
import FeatherIcon from '@/@core/components/feather-icon/FeatherIcon.vue'
|
||||
import ToastificationContent from '@core/components/toastification/ToastificationContent.vue'
|
||||
@@ -438,12 +445,20 @@ import {
|
||||
toDuration, abbrMessage, abbrAddress, getUserCurrency, getUserCurrencySign, numberWithCommas, toETHAddress,
|
||||
} from '@/libs/utils'
|
||||
import OperationModal from '@/views/components/OperationModal/index.vue'
|
||||
import {
|
||||
convertAddress,
|
||||
resolveDomainDetails,
|
||||
resolveDomainIntoAddresses,
|
||||
resolvePrimaryDomainByAddress,
|
||||
resolveDomainIntoChainAddress,
|
||||
} from 'ibc-domains-sdk'
|
||||
import ObjectFieldComponent from './components/ObjectFieldComponent.vue'
|
||||
import ChartComponentDoughnut from './components/charts/ChartComponentDoughnut.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BRow,
|
||||
BBadge,
|
||||
BCol,
|
||||
BCard,
|
||||
BAvatar,
|
||||
@@ -507,6 +522,7 @@ export default {
|
||||
stakingParameters: {},
|
||||
operationModalType: '',
|
||||
error: null,
|
||||
names: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -675,6 +691,20 @@ export default {
|
||||
}).catch(err => {
|
||||
this.error = err
|
||||
})
|
||||
this.$http.resolveStarName(this.address).then(x => {
|
||||
this.names.push({
|
||||
provider: 'Stargaze',
|
||||
name: x.data,
|
||||
})
|
||||
})
|
||||
resolvePrimaryDomainByAddress(this.address).then(result => {
|
||||
if (result.isOk()) {
|
||||
this.names.push({
|
||||
provider: 'IBC Domain',
|
||||
name: result.value,
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
const elem = document.getElementById('txevent')
|
||||
|
||||
Reference in New Issue
Block a user