diff --git a/packages/app/src/components/TheFooter.vue b/packages/app/src/components/TheFooter.vue index 2347db302..e5577f4bc 100644 --- a/packages/app/src/components/TheFooter.vue +++ b/packages/app/src/components/TheFooter.vue @@ -24,7 +24,7 @@ const config = useRuntimeConfig(); const navigation = reactive([ { label: computed(() => t("footer.nav.docs")), - url: "https://docs.zksync.io/build/tooling/zksync-block-explorers", + url: "https://docs.zksync.io/zksync-era/tooling/block-explorers", }, { label: computed(() => t("footer.nav.terms")), diff --git a/packages/app/src/components/header/TheHeader.vue b/packages/app/src/components/header/TheHeader.vue index a311e4dd0..f92cc6592 100644 --- a/packages/app/src/components/header/TheHeader.vue +++ b/packages/app/src/components/header/TheHeader.vue @@ -159,7 +159,7 @@ const { currentNetwork } = useContext(); const navigation = reactive([ { label: computed(() => t("header.nav.documentation")), - url: "https://docs.zksync.io/build/tooling/zksync-block-explorers", + url: "https://docs.zksync.io/zksync-era/tooling/block-explorers", }, ]); diff --git a/packages/app/src/components/transactions/Table.vue b/packages/app/src/components/transactions/Table.vue index fab1c6245..f7814219d 100644 --- a/packages/app/src/components/transactions/Table.vue +++ b/packages/app/src/components/transactions/Table.vue @@ -58,9 +58,13 @@ -
- {{ item.methodName }} -
+ +
+ {{ item.methodName }} +
+ + +
{ +const methodNames = ref>({}); + +const loadMethodNames = async () => { + if (!data.value) return; + + const uniqueSighashes = [ + ...new Set( + data.value?.map((transaction) => transaction.data.slice(0, 10)).filter((sighash) => sighash !== "0x") ?? [] + ), + ]; + const fetchedMethodNames = await fetchMethodNames(uniqueSighashes); + methodNames.value = { ...methodNames.value, ...fetchedMethodNames }; +}; + +watch( + data, + async (newData) => { + if (!newData) return; + + await loadMethodNames(); + }, + { immediate: true } +); + +const getTransactionMethod = (transaction: TransactionListItem, methodNames: Record) => { if (transaction.data === "0x") { return t("transactions.table.transferMethodName"); } const sighash = transaction.data.slice(0, 10); if (props.contractAbi) { - return ( - decodeDataWithABI( - { - calldata: transaction.data, - value: transaction.value, - }, - props.contractAbi - )?.name ?? sighash + const decodedMethod = decodeDataWithABI( + { calldata: transaction.data, value: transaction.value }, + props.contractAbi ); + if (decodedMethod?.name) { + return decodedMethod.name; + } } - return sighash; + + return methodNames[sighash] ?? sighash; }; type TransactionListItemMapped = TransactionListItem & { @@ -301,7 +330,7 @@ type TransactionListItemMapped = TransactionListItem & { const transactions = computed(() => { return data.value?.map((transaction) => ({ ...transaction, - methodName: getTransactionMethod(transaction), + methodName: getTransactionMethod(transaction, methodNames.value), fromNetwork: transaction.isL1Originated ? "L1" : "L2", toNetwork: "L2", // even withdrawals go through L2 addresses (800A or bridge addresses) statusColor: transaction.status === "failed" ? "danger" : "dark-success", @@ -432,7 +461,7 @@ function getDirection(item: TransactionListItem): Direction { } } .transactions-data-method { - @apply w-[200px] truncate sm:w-auto; + @apply w-36 truncate border-slate-200 rounded border py-0.5 px-2 text-center bg-slate-400/10 text-xs text-slate-600 sm:w-28; } .transactions-data-transaction-amount, .transactions-data-age { diff --git a/packages/app/src/composables/useOpenChain.ts b/packages/app/src/composables/useOpenChain.ts new file mode 100644 index 000000000..c84067feb --- /dev/null +++ b/packages/app/src/composables/useOpenChain.ts @@ -0,0 +1,42 @@ +import { $fetch } from "ohmyfetch"; + +interface OpenChainMethod { + name: string; + filtered: boolean; +} +interface OpenChainResponse { + ok: boolean; + result: { + function: Record; + }; +} +export async function fetchMethodNames(sighashes: string[]): Promise> { + try { + const response = await $fetch("https://api.openchain.xyz/signature-database/v1/lookup", { + method: "GET", + params: { + function: sighashes.join(","), + filter: true, + }, + headers: { + accept: "application/json", + }, + }); + const result = response?.result?.function ?? {}; + const methodNames: Record = {}; + Object.entries(result).forEach(([sighash, methods]) => { + // Ensure methods is an array of the expected shape + if (Array.isArray(methods)) { + methods.forEach((method) => { + if (typeof method === "object" && method.name && method.name.split("(").length > 1) { + methodNames[sighash] = method.name.split("(")[0]; + } + }); + } + }); + return methodNames; + } catch (error) { + console.error("Error fetching method names:", error); + return {}; + } +} diff --git a/packages/app/tests/components/TheFooter.spec.ts b/packages/app/tests/components/TheFooter.spec.ts index e48c3a721..265b0f123 100644 --- a/packages/app/tests/components/TheFooter.spec.ts +++ b/packages/app/tests/components/TheFooter.spec.ts @@ -24,7 +24,7 @@ describe("TheFooter:", () => { }, }); const links = wrapper.findAll("a"); - expect(links[0].attributes("href")).toBe("https://docs.zksync.io/build/tooling/zksync-block-explorers"); + expect(links[0].attributes("href")).toBe("https://docs.zksync.io/zksync-era/tooling/block-explorers"); expect(links[1].attributes("href")).toBe("https://zksync.io/terms"); expect(links[2].attributes("href")).toBe("https://zksync.io/contact"); }); diff --git a/packages/app/tests/components/TheHeader.spec.ts b/packages/app/tests/components/TheHeader.spec.ts index aa31d1562..e46d56079 100644 --- a/packages/app/tests/components/TheHeader.spec.ts +++ b/packages/app/tests/components/TheHeader.spec.ts @@ -62,7 +62,7 @@ describe("TheHeader:", () => { expect(toolsLinks[2].attributes("href")).toBe("https://bridge.zksync.io/"); expect(wrapper.findAll(".navigation-container > .navigation-link")[0].attributes("href")).toBe( - "https://docs.zksync.io/build/tooling/zksync-block-explorers" + "https://docs.zksync.io/zksync-era/tooling/block-explorers" ); }); it("renders social links", () => { diff --git a/packages/app/tests/e2e/features/redirection/redirectionSet1.feature b/packages/app/tests/e2e/features/redirection/redirectionSet1.feature index cbd494841..3cf0dadec 100644 --- a/packages/app/tests/e2e/features/redirection/redirectionSet1.feature +++ b/packages/app/tests/e2e/features/redirection/redirectionSet1.feature @@ -13,7 +13,7 @@ Feature: Redirection Examples: | Extra button name | url | - | Docs | https://docs.zksync.io/build/tooling/zksync-block-explorers | + | Docs | https://docs.zksync.io/zksync-era/tooling/block-explorers | | Terms | https://zksync.io/terms | | Contact | https://zksync.io/contact | @@ -32,7 +32,7 @@ Feature: Redirection @id251 Scenario: Verify redirection for Documentation link Given I click by text "Documentation" - Then New page have "https://docs.zksync.io/build/tooling/zksync-block-explorers" address + Then New page have "https://docs.zksync.io/zksync-era/tooling/block-explorers" address @id252 Scenario Outline: Verify redirection for "" in BE menu