Skip to content

Commit bf48afb

Browse files
committed
Request and display address labels
1 parent 7b35f27 commit bf48afb

File tree

3 files changed

+73
-8
lines changed

3 files changed

+73
-8
lines changed

src/components/TableOpFeed.vue

+14-4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import { Address, Hex, zeroAddress } from 'viem';
9393
import { computed, watch } from 'vue';
9494
9595
import IconArrowRight from '@/components/IconArrowRight.vue';
96+
import useLabels from '@/composables/useLabels';
9697
import { Chain, getChainName } from '@/utils/chains';
9798
import { toRelativeTime } from '@/utils/conversion';
9899
import {
@@ -101,6 +102,8 @@ import {
101102
} from '@/utils/entryPoint';
102103
import { formatRelativeTime } from '@/utils/formatting';
103104
105+
const { getLabelText } = useLabels();
106+
104107
const props = defineProps<{
105108
ops: UserOp[];
106109
page: number;
@@ -131,17 +134,20 @@ const columns = computed(() => [
131134
}),
132135
columnHelper.accessor('sender', {
133136
header: 'Sender',
134-
cell: (cell) => cell.getValue(),
137+
cell: (cell) =>
138+
getAddressLabel(cell.row.getValue('chain'), cell.getValue()),
135139
}),
136140
columnHelper.accessor('bundler', {
137141
header: 'Bundler',
138-
cell: (cell) => cell.getValue(),
142+
cell: (cell) =>
143+
getAddressLabel(cell.row.getValue('chain'), cell.getValue()),
139144
}),
140145
columnHelper.accessor('paymaster', {
141146
header: 'Paymaster',
142147
cell: (cell) => {
143-
const value = cell.getValue();
144-
return value === zeroAddress ? '' : value;
148+
const address = cell.getValue();
149+
const value = getAddressLabel(cell.row.getValue('chain'), address);
150+
return address === zeroAddress ? '' : value;
145151
},
146152
}),
147153
columnHelper.accessor('entryPoint', {
@@ -188,6 +194,10 @@ watch(
188194
table.setPageIndex(props.page);
189195
},
190196
);
197+
198+
function getAddressLabel(chain: Chain, address: Address): string {
199+
return getLabelText(chain, address) || address;
200+
}
191201
</script>
192202

193203
<script lang="ts">

src/pages/Home.vue

+26-1
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@
1818

1919
<script setup lang="ts">
2020
import { useIntervalFn } from '@vueuse/core';
21-
import { computed, onMounted, ref } from 'vue';
21+
import { Address } from 'viem';
22+
import { computed, onMounted, ref, watch } from 'vue';
2223
import { useRouter } from 'vue-router';
2324
2425
import TableOpFeed, { UserOp as UserOpRow } from '@/components/TableOpFeed.vue';
2526
import useEnv from '@/composables/useEnv';
27+
import useLabels from '@/composables/useLabels';
2628
import IndexerService, { FeedUserOp } from '@/services/indexer';
29+
import { CHAINS, Chain } from '@/utils/chains';
2730
import { isUserOpHash } from '@/utils/validation/pattern';
2831
2932
const router = useRouter();
33+
const { requestLabels } = useLabels();
3034
const { indexerEndpoint } = useEnv();
3135
3236
onMounted(() => {
@@ -70,6 +74,27 @@ function handleSubmit(): void {
7074
}
7175
router.push({ name: 'op', params: { hash: query.value } });
7276
}
77+
78+
const addresses = computed<Record<Chain, Address[]>>(() => {
79+
return Object.fromEntries(
80+
CHAINS.map((chain) => {
81+
return [
82+
chain,
83+
ops.value
84+
.filter((op) => op.chainId === chain)
85+
.map((op) => [op.sender, op.bundler, op.paymaster])
86+
.flat(),
87+
];
88+
}),
89+
) as Record<Chain, Address[]>;
90+
});
91+
92+
watch(addresses, () => {
93+
for (const chain of CHAINS) {
94+
const chainAddresses = addresses.value[chain];
95+
requestLabels(chain, chainAddresses);
96+
}
97+
});
7398
</script>
7499

75100
<style scoped>

src/pages/Op.vue

+33-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
of account
3131
<BlockInfo
3232
:value="userOpData.sender"
33-
:label="userOpData.sender"
33+
:label="
34+
getAddressLabel(userOpData.chainId, userOpData.sender)
35+
"
3436
type="address"
3537
:chain="userOpData.chainId"
3638
/>
@@ -46,7 +48,9 @@
4648
via
4749
<BlockInfo
4850
:value="userOpData.paymaster"
49-
:label="userOpData.paymaster"
51+
:label="
52+
getAddressLabel(userOpData.chainId, userOpData.paymaster)
53+
"
5054
type="address"
5155
:chain="userOpData.chainId"
5256
/>
@@ -55,7 +59,9 @@
5559
Bundled by
5660
<BlockInfo
5761
:value="userOpData.bundler"
58-
:label="userOpData.bundler"
62+
:label="
63+
getAddressLabel(userOpData.chainId, userOpData.bundler)
64+
"
5965
type="address"
6066
:chain="userOpData.chainId"
6167
/>
@@ -117,6 +123,7 @@ import BlockInfo from '@/components/BlockInfo.vue';
117123
import IconCheckCircled from '@/components/IconCheckCircled.vue';
118124
import IconCrossCircled from '@/components/IconCrossCircled.vue';
119125
import useEnv from '@/composables/useEnv';
126+
import useLabels from '@/composables/useLabels';
120127
import EvmService, { Transaction, TransactionReceipt } from '@/services/evm';
121128
import IndexerService, { TransactionUserOp } from '@/services/indexer';
122129
import {
@@ -134,6 +141,7 @@ import {
134141
import { formatRelativeTime } from '@/utils/formatting';
135142
136143
const { alchemyApiKey, indexerEndpoint } = useEnv();
144+
const { requestLabels, getLabelText } = useLabels();
137145
const route = useRoute();
138146
139147
const hash = computed(() => route.params.hash as Hex);
@@ -203,6 +211,24 @@ const actualGasCost = computed<bigint | null>(() =>
203211
userOpEvent.value ? userOpEvent.value.actualGasCost : null,
204212
);
205213
214+
const addresses = computed<Address[]>(() => {
215+
if (!userOpData.value) {
216+
return [];
217+
}
218+
return [
219+
userOpData.value.sender,
220+
userOpData.value.bundler,
221+
userOpData.value.paymaster,
222+
];
223+
});
224+
225+
watch(addresses, () => {
226+
if (!userOpData.value) {
227+
return;
228+
}
229+
requestLabels(userOpData.value.chainId, addresses.value);
230+
});
231+
206232
function formatEther(value: bigint): string {
207233
return `${formatNumber(fromWei(value, 18))} ETH`;
208234
}
@@ -232,6 +258,10 @@ function fromWei(value: bigint | number, decimals: number): number {
232258
}
233259
return parseFloat(formatUnits(BigInt(value.toString()), decimals));
234260
}
261+
262+
function getAddressLabel(chain: Chain, address: Address): string {
263+
return getLabelText(chain, address) || address;
264+
}
235265
</script>
236266

237267
<style scoped>

0 commit comments

Comments
 (0)