Skip to content

Commit

Permalink
CSV export of epoch transactions for address
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Nov 19, 2024
1 parent 8a5b65f commit e37d453
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/api/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,9 @@ export const RESOURCES = {
csv_export_logs: {
path: '/api/v1/logs-csv',
},
csv_export_epoch_rewards: {
path: '/api/v1/celo-election-rewards-csv',
},
graphql: {
path: '/api/v1/graphql',
},
Expand Down
8 changes: 7 additions & 1 deletion mocks/address/epochRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@ export const epochRewards: AddressEpochRewardsResponse = {
token: tokenInfo,
},
],
next_page_params: null,
next_page_params: {
amount: '71952055594478242556',
associated_account_address_hash: '0x30d060f129817c4de5fbc1366d53e19f43c8c64f',
block_number: 25954560,
items_count: 50,
type: 'delegated_payment',
},
};
4 changes: 4 additions & 0 deletions types/client/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ export type CsvExportParams = {
type: 'holders';
filterType?: undefined;
filterValue?: undefined;
} | {
type: 'epoch-rewards';
filterType?: undefined;
filterValue?: undefined;
};
9 changes: 8 additions & 1 deletion ui/address/AddressEpochRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import DataListDisplay from 'ui/shared/DataListDisplay';
import Pagination from 'ui/shared/pagination/Pagination';
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';

import AddressCsvExportLink from './AddressCsvExportLink';
import AddressEpochRewardsListItem from './epochRewards/AddressEpochRewardsListItem';

type Props = {
Expand Down Expand Up @@ -71,7 +72,13 @@ const AddressEpochRewards = ({ scrollRef, shouldRender = true, isQueryEnabled =

const actionBar = rewardsQuery.pagination.isVisible ? (
<ActionBar mt={ -6 }>
<Pagination ml="auto" { ...rewardsQuery.pagination }/>
<AddressCsvExportLink
address={ hash }
isLoading={ rewardsQuery.pagination.isLoading }
params={{ type: 'epoch-rewards' }}
ml={{ lg: 'auto' }}
/>
<Pagination ml={{ base: 0, lg: 8 }} { ...rewardsQuery.pagination }/>
</ActionBar>
) : null;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ui/pages/CsvExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const EXPORT_TYPES: Record<CsvExportParams['type'], ExportTypeEntity> = {
resource: 'csv_export_token_holders',
fileNameTemplate: 'holders',
},
'epoch-rewards': {
text: 'epoch rewards',
resource: 'csv_export_epoch_rewards',
fileNameTemplate: 'epoch_rewards',
},
};

const isCorrectExportType = (type: string): type is CsvExportParams['type'] => Object.keys(EXPORT_TYPES).includes(type);
Expand Down

0 comments on commit e37d453

Please sign in to comment.