Skip to content

Commit

Permalink
Merge pull request #951 from telosnetwork/946-display-the-function-na…
Browse files Browse the repository at this point in the history
…mes-when-possible-on-transactions-table

#946 | Display the function names when possible on transactions table
  • Loading branch information
pmjanus authored Jan 27, 2025
2 parents 338c136 + a10ab70 commit 4ec3ce1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/components/TransactionTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import TransactionFeeField from 'components/TransactionFeeField.vue';
import { PaginationByKey } from 'src/types';
import { useStore } from 'vuex';
import { useChainStore } from 'src/core';
import { BigNumber } from 'ethers';

const $q = useQuasar();
const route = useRoute();
Expand Down Expand Up @@ -209,18 +210,30 @@ async function parseTransactions() {
if (transaction.input === '0x' || !transaction.to) {
continue;
}

const contract = await useChainStore().currentChain.settings.getContractManager().getContract(transaction.to);

if (!contract) {
continue;
}

const parsedTransaction = await useChainStore().currentChain.settings.getContractManager().parseContractTransaction(
transaction, transaction.input, contract, true,
);
if (parsedTransaction) {
transaction.parsedTransaction = parsedTransaction;
} else {
if (response.data.abi) {
const abi = response.data.abi as {[sighash: string]: string};
const value_str: string = transaction.value === '0x0' ? '0' : transaction.value ?? '0';
const value = BigNumber.from(value_str);
const sighash = transaction.input.slice(0, 10);
const signature = abi[sighash] as string;
const name = signature.split('(')[0].replace('function ', '');
transaction.parsedTransaction = {
name,
sighash,
signature,
value,
};
}
}
transaction.contract = contract;
} catch (e: any) {
Expand Down

0 comments on commit 4ec3ce1

Please sign in to comment.