Skip to content

Commit

Permalink
depplionk is working on transaction history page
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterbo committed Feb 15, 2024
1 parent 99cf7de commit 74859d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
47 changes: 28 additions & 19 deletions src/antelope/stores/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const transfers_filter_limit = 10000;

export interface HistoryState {
__evm_filter: IndexerTransactionsFilter;
__evm_last_filter_used: IndexerTransactionsFilter | null;
__evm_transactions: {
[label: Label]: {
transactions: EvmTransaction[],
Expand Down Expand Up @@ -146,30 +147,37 @@ export const useHistoryStore = defineStore(store_name, {
await this.fetchEvmNftTransfersForAccount(label, this.__evm_filter.address);
}

const transactionsResponse = await chainSettings.getEVMTransactions(toRaw(this.__evm_filter));
const contracts = transactionsResponse.contracts;
const transactions = transactionsResponse.results;
const lastFilterUsedStr = JSON.stringify(this.__evm_last_filter_used);
const currentFilterStr = JSON.stringify(this.__evm_filter);
if (lastFilterUsedStr !== currentFilterStr) {
this.__evm_last_filter_used = { ... toRaw(this.__evm_filter) };

this.setEvmTransactionsRowCount(label, transactionsResponse.total_count);
const transactionsResponse = await chainSettings.getEVMTransactions(toRaw(this.__evm_filter));
const contracts = transactionsResponse.contracts;
const transactions = transactionsResponse.results;

const contractAddresses = Object.keys(contracts);
const parsedContracts: Record<string, ParsedIndexerAccountTransactionsContract> = {};
contractAddresses.forEach((address: string) => {
const extraInfo = JSON.parse(contracts[address]?.calldata ?? '{}');
parsedContracts[address] = {
...contracts[address],
...extraInfo,
};
});
this.setEvmTransactionsRowCount(label, transactionsResponse.total_count);

// cache contracts
contractAddresses.forEach((address) => {
contractStore.createAndStoreContract(label, address, parsedContracts[address]);
});
const contractAddresses = Object.keys(contracts);
const parsedContracts: Record<string, ParsedIndexerAccountTransactionsContract> = {};
contractAddresses.forEach((address: string) => {
const extraInfo = JSON.parse(contracts[address]?.calldata ?? '{}');
parsedContracts[address] = {
...contracts[address],
...extraInfo,
};
});

// cache contracts
contractAddresses.forEach((address) => {
contractStore.createAndStoreContract(label, address, parsedContracts[address]);
});

this.setEVMTransactions(label, transactions);
this.setEVMTransactions(label, transactions);

await this.shapeTransactions(label, transactions);
await this.shapeTransactions(label, transactions);
} else {
}
} catch (error) {
console.error(error);
throw new AntelopeError('antelope.history.error_fetching_transactions');
Expand Down Expand Up @@ -488,6 +496,7 @@ const historyInitialState: HistoryState = {
__evm_filter: {
address: '',
},
__evm_last_filter_used: null,
__shaped_evm_transaction_rows: {
},
__evm_transactions_pagination_data: {},
Expand Down
12 changes: 2 additions & 10 deletions src/pages/evm/wallet/WalletTransactionsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ export default defineComponent({
const txLoading = feedbackStore.isLoading('history.fetchEVMTransactionsForAccount');
const transfersLoading = feedbackStore.isLoading('history.fetchEvmNftTransfersForAccount');
const actionsInProgress = txLoading || transfersLoading;
const hideLoadingState = this.pagination.page === 1 && this.initialLoadComplete && !this.rowsPerPageUpdating;
// don't show the loading state if we're on the first page and transactions are already present
// this covers two scenarios, 1. the user came to the page from the balances page, meaning we prefetched transactions
// or 2. the user is on the first page and we are re-fetching transactions on an interval
return actionsInProgress && !hideLoadingState;
return actionsInProgress;
},
address() {
return accountStore.loggedEvmAccount?.address ?? '';
Expand Down Expand Up @@ -85,7 +80,6 @@ export default defineComponent({
}
const { rowsPerPage, page } = newPagination;
console.log('watch(pagination) - We replace route: ', { rowsPerPage, page });
this.$router.replace({
name: 'evm-wallet',
query: {
Expand All @@ -112,10 +106,10 @@ export default defineComponent({
rowsCurrentPage: rowsPerPage,
rowsNumber,
};
console.log('watch(totalRows) - We set pagination: ', { rowsPerPage, page });
} else {
this.pagination.rowsNumber = newValue;
}
},
},
$route(newRoute) {
Expand All @@ -130,7 +124,6 @@ export default defineComponent({
rowsNumber: this.pagination.rowsNumber,
};
console.log('watch($route) - We set pagination: ', this.pagination);
this.getTransactions().finally(() => {
this.rowsPerPageUpdating = false;
Expand All @@ -156,7 +149,6 @@ export default defineComponent({
methods: {
async getTransactions() {
console.log('getTransactions() - pagination: ', this.pagination);
const offset = (this.pagination.page - 1) * this.pagination.rowsPerPage;
let limit = this.pagination.rowsPerPage;
Expand Down

0 comments on commit 74859d4

Please sign in to comment.