Skip to content

Commit 4201b8f

Browse files
committed
Ellipsize long nonces and addresses
1 parent 48adabe commit 4201b8f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/pages/Op.vue

+14-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Operation
2424
<BlockInfo
2525
:value="userOpData.nonce.toString()"
26-
:label="`#${userOpData.nonce}`"
26+
:label="`#${formatNonce(userOpData.nonce)}`"
2727
type="regular"
2828
:chain="userOpData.chainId"
2929
/>
@@ -272,7 +272,19 @@ function formatEntryPoint(value: Address): string {
272272
}
273273
274274
function getAddressLabel(chain: Chain, address: Address): string {
275-
return getLabelText(chain, address) || address;
275+
return getLabelText(chain, address) || formatAddress(address);
276+
}
277+
278+
function formatAddress(address: Address): string {
279+
return address.slice(0, 8) + '' + address.slice(-6);
280+
}
281+
282+
function formatNonce(nonce: bigint): string {
283+
const nonceString = nonce.toString();
284+
if (nonceString.length <= 10) {
285+
return nonce.toString();
286+
}
287+
return `${nonceString.slice(0, 5)}…${nonceString.slice(-5)}`;
276288
}
277289
</script>
278290

0 commit comments

Comments
 (0)