Skip to content

Commit

Permalink
💄 Shorten wallet address on display
Browse files Browse the repository at this point in the history
  • Loading branch information
nwingt committed Nov 14, 2023
1 parent 5983391 commit 8476436
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 32 deletions.
17 changes: 10 additions & 7 deletions components/WalletHeader.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<template>
<div class="flex flex-wrap items-center gap-2">
<template v-if="wallet">
<UButton
class="text-xs font-mono"
:label="wallet"
:to="portfolioURL"
variant="soft"
target="_blank"
/>
<UTooltip :text="wallet">
<UButton
class="text-xs font-mono"
:label="shortenWalletAddress(wallet)"
:to="portfolioURL"
variant="soft"
target="_blank"
/>
</UTooltip>
<UButton
label="Disconnect Wallet"
icon="i-heroicons-arrow-left-on-rectangle"
Expand All @@ -30,6 +32,7 @@
import { storeToRefs } from 'pinia'
import { useWalletStore } from '~/stores/wallet'
import { getPortfolioURL } from '~/utils'
import { shortenWalletAddress } from '~/utils/cosmos'
const store = useWalletStore()
const { wallet } = storeToRefs(store)
Expand Down
23 changes: 14 additions & 9 deletions pages/authz/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@
:sort="{ column: 'expiration', direction: 'desc' }"
>
<template #wallet-data="{ row }">
<UButton
class="font-mono"
:label="row.wallet"
:to="getPortfolioURL(row.wallet)"
variant="link"
:padded="false"
target="_blank"
/>
<UTooltip :text="row.wallet">
<UButton
class="font-mono"
:label="row.shortenWallet"
:to="getPortfolioURL(row.wallet)"
variant="link"
:padded="false"
size="xs"
target="_blank"
/>
</UTooltip>
</template>
<template #actions-data="{ row }">
<div class="flex items-center gap-2">
Expand Down Expand Up @@ -134,7 +137,8 @@ import { useWalletStore } from '~/stores/wallet'
import {
getNFTAuthzGranterGrants,
signGrantNFTSendAuthz,
signRevokeNFTSendAuthz
signRevokeNFTSendAuthz,
shortenWalletAddress
} from '~/utils/cosmos'
const walletStore = useWalletStore()
Expand All @@ -149,6 +153,7 @@ const isLoading = ref(false)
const tableRows = computed(() => grants.value.map((grant: any) => ({
wallet: grant.grantee,
shortenWallet: shortenWalletAddress(grant.grantee),
expiration: new Date(grant.expiration.seconds.toNumber() * 1000)
})))
Expand Down
41 changes: 25 additions & 16 deletions pages/nft-book-store/status/[classId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@
/>
</template>
<template #wallet-data="{ row }">
<UButton
class="font-mono"
:label="row.wallet"
:to="getPortfolioURL(row.wallet)"
variant="link"
:padded="false"
target="_blank"
/>
<UTooltip :text="row.wallet">
<UButton
class="font-mono"
:label="row.shortenWallet"
:to="row.walletLink"
variant="link"
:padded="false"
size="xs"
target="_blank"
/>
</UTooltip>
</template>
<template #status-data="{ row }">
<UBadge
Expand Down Expand Up @@ -318,13 +321,16 @@
:rows="moderatorWalletsTableRows"
>
<template #wallet-data="{ row }">
<UButton
class="font-mono"
:label="row.wallet"
:to="row.walletLink"
variant="link"
:padded="false"
/>
<UTooltip :text="row.wallet">
<UButton
class="font-mono"
:label="row.shortenWallet"
:to="row.walletLink"
variant="link"
:padded="false"
size="xs"
/>
</UTooltip>
</template>
<template #authz-data="{ row }">
<UButton
Expand Down Expand Up @@ -496,7 +502,7 @@ import { useBookStoreApiStore } from '~/stores/book-store-api'
import { useNftStore } from '~/stores/nft'
import { useWalletStore } from '~/stores/wallet'
import { getPortfolioURL } from '~/utils'
import { getNFTAuthzGrants } from '~/utils/cosmos'
import { getNFTAuthzGrants, shortenWalletAddress } from '~/utils/cosmos'
const store = useWalletStore()
const bookStoreApiStore = useBookStoreApiStore()
Expand Down Expand Up @@ -694,6 +700,8 @@ const ordersTableRows = computed(() => purchaseList.value?.map((p: any, index: n
orderDate: p.formattedDate,
shippingStatus: p.shippingStatus,
wallet: p.wallet || '',
walletLink: getPortfolioURL(p.wallet),
shortenWallet: shortenWalletAddress(p.wallet),
priceName: p.priceName,
price: p.price || 0,
message: p.message || '',
Expand Down Expand Up @@ -730,6 +738,7 @@ const moderatorWalletsTableRows = computed(() => moderatorWallets.value.map((wal
return {
index,
wallet,
shortenWallet: shortenWalletAddress(wallet),
walletLink: getPortfolioURL(wallet),
isGranted,
grantLabel: isGranted ? 'Granted' : 'Grant',
Expand Down
5 changes: 5 additions & 0 deletions utils/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,8 @@ export async function signRevokeNFTSendAuthz (
const res = await signingClient.revokeGenericGrant(address, grantee, '/cosmos.nft.v1beta1.MsgSend', { memo })
return res
}

export function shortenWalletAddress (address: string) {
if (!address) { return '-' }
return `${address.slice(0, 10)}...${address.slice(-6)}`
}

0 comments on commit 8476436

Please sign in to comment.