Skip to content

Commit cd7b57b

Browse files
2xburntcursoragent
andcommitted
feat(account): add copy actions for pubkey and address details
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0cb51c3 commit cd7b57b

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

src/modules/[chain]/account/[address].vue

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const unbonding = ref([] as UnbondingResponses[]);
2929
const unbondingTotal = ref(0);
3030
const addressQrModal = ref(false);
3131
const addressCopied = ref(false);
32+
const publicKeyCopied = ref(false);
3233
const copiedTxHash = ref('');
3334
const chart = {};
3435
onMounted(() => {
@@ -122,6 +123,12 @@ async function copyAddress() {
122123
window.setTimeout(() => (addressCopied.value = false), 1200);
123124
}
124125
126+
async function copyPublicKey(value: string) {
127+
await navigator.clipboard.writeText(value);
128+
publicKeyCopied.value = true;
129+
window.setTimeout(() => (publicKeyCopied.value = false), 1200);
130+
}
131+
125132
async function copyTxHash(hash: string) {
126133
await navigator.clipboard.writeText(hash);
127134
copiedTxHash.value = hash;
@@ -613,7 +620,58 @@ function mapAmount(events: { type: string; attributes: { key: string; value: str
613620
<!-- Account -->
614621
<div class="bg-base-100 px-4 pt-3 pb-4 rounded mb-4 shadow">
615622
<h2 class="card-title mb-4">{{ $t('account.acc') }}</h2>
616-
<DynamicComponent :value="account" />
623+
<div class="overflow-x-auto">
624+
<table class="table w-full text-sm">
625+
<tbody>
626+
<template v-for="(value, key) in account" :key="key">
627+
<template v-if="key === 'pub_key' && value && typeof value === 'object'">
628+
<tr>
629+
<td class="w-1/5 capitalize">Pub Key Type</td>
630+
<td>{{ value['@type'] }}</td>
631+
</tr>
632+
<tr>
633+
<td class="w-1/5 capitalize">Pub Key</td>
634+
<td>
635+
<div class="flex items-center gap-2">
636+
<span class="break-all">{{ value.key }}</span>
637+
<button
638+
type="button"
639+
class="btn btn-ghost btn-xs shrink-0"
640+
:aria-label="publicKeyCopied ? 'Public key copied' : 'Copy public key'"
641+
:title="publicKeyCopied ? 'Copied' : 'Copy public key'"
642+
@click="copyPublicKey(value.key)"
643+
>
644+
<Icon :icon="publicKeyCopied ? 'mdi-check' : 'mdi-content-copy'" class="h-4 w-4" />
645+
</button>
646+
</div>
647+
</td>
648+
</tr>
649+
</template>
650+
<tr v-else-if="key === 'address'">
651+
<td class="w-1/5 capitalize">Address</td>
652+
<td>
653+
<div class="flex items-center gap-2">
654+
<span class="break-all">{{ value }}</span>
655+
<button
656+
type="button"
657+
class="btn btn-ghost btn-xs shrink-0"
658+
:aria-label="addressCopied ? 'Address copied' : 'Copy address'"
659+
:title="addressCopied ? 'Copied' : 'Copy address'"
660+
@click="copyAddress"
661+
>
662+
<Icon :icon="addressCopied ? 'mdi-check' : 'mdi-content-copy'" class="h-4 w-4" />
663+
</button>
664+
</div>
665+
</td>
666+
</tr>
667+
<tr v-else>
668+
<td class="w-1/5 capitalize">{{ String(key).replaceAll('_', ' ') }}</td>
669+
<td><DynamicComponent :value="value" /></td>
670+
</tr>
671+
</template>
672+
</tbody>
673+
</table>
674+
</div>
617675
</div>
618676
</div>
619677
<div v-else class="text-no text-sm">{{ $t('account.error') }}</div>

0 commit comments

Comments
 (0)