diff --git a/src/components/AccountLink.vue b/src/components/AccountLink.vue index 3a28b9c..ce4fa4d 100644 --- a/src/components/AccountLink.vue +++ b/src/components/AccountLink.vue @@ -13,17 +13,18 @@ v-if="noLink" class="text-monospace text-truncate" > - {{ address | abbr }} + {{ resolvedName }} + {{ address | abbr }} {{ address | checksum }} - ({{ vetName }}) - {{ (vetName || address) | abbr }} - {{ (vetName || address | checksum) }} + {{ resolvedName }} + {{ address | abbr }} + {{ address | checksum }} { + async resolvedName(): Promise { if (genesisIdToNetwork(this.$connex.thor.genesis.id) !== 'main') { return null } - try { - const { decoded: { names } } = await this.$connex.thor - .account(vetResolverUtilsAddress) - .method(getNamesJsonAbi) - .call([this.address]) - - return names[0] || null - } catch { - return null - } + return resolveDomainName(this.address, this.$connex) } }, computed: { @@ -67,25 +60,4 @@ export default Vue.extend({ } }) -const vetResolverUtilsAddress = '0xA11413086e163e41901bb81fdc5617c975Fa5a1A' -const getNamesJsonAbi = { - "inputs": [ - { - "internalType": "address[]", - "name": "addresses", - "type": "address[]" - } - ], - "name": "getNames", - "outputs": [ - { - "internalType": "string[]", - "name": "names", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" -} - \ No newline at end of file diff --git a/src/resolver.ts b/src/resolver.ts new file mode 100644 index 0000000..b58d254 --- /dev/null +++ b/src/resolver.ts @@ -0,0 +1,36 @@ + +// vet.domain resolver +const vet_domainResolver = '0xA11413086e163e41901bb81fdc5617c975Fa5a1A' +const getNamesJsonAbi = { + "inputs": [ + { + "internalType": "address[]", + "name": "addresses", + "type": "address[]" + } + ], + "name": "getNames", + "outputs": [ + { + "internalType": "string[]", + "name": "names", + "type": "string[]" + } + ], + "stateMutability": "view", + "type": "function" +} + +export const resolveDomainName = async (address: string, connex: Connex) => { + try { + const { decoded: { names } } = await connex.thor + .account(vet_domainResolver) + .method(getNamesJsonAbi) + .cache([address, vet_domainResolver]) + .call([address]) + + return names[0] || null + } catch { + return null + } +} \ No newline at end of file diff --git a/src/views/Account.vue b/src/views/Account.vue index 73fee97..8077676 100644 --- a/src/views/Account.vue +++ b/src/views/Account.vue @@ -4,16 +4,24 @@ Account - - + + + + + {{ address|checksum }} + + + {{ resolvedName }} + + +