Skip to content

Commit

Permalink
Merge branch 'main' into deploy/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
juandavidkincaid committed Mar 27, 2024
2 parents 239e955 + d3593d8 commit 15b167a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/api/block-explorer/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const useGetAddressBalance = (address: string) => {

export const useGetAddressTotalRewards = (address: string, network: Exclude<Network, 'mainnet1'>) => {
return useFetch<{ totalAmount: number; isValidator: boolean }>(
REACT_APP_DAG_EXPLORER_API_URL + '/' + network + '/addresses/' + address + '/rewards'
REACT_APP_DAG_EXPLORER_API_URL + '/' + network + '/addresses/' + address + '/total-rewards'
);
};

Expand All @@ -56,8 +56,8 @@ export const useGetAddressRewards = (
offset?: number
) => {
const response = useFetch<{ data: AddressRewardsResponse[]; meta: { limit: number; offset: number; total: number } }>(
REACT_APP_DAG_EXPLORER_API_URL + '/' + network + '/addresses/' + address + '/rewardss',
{ limit, offset },
REACT_APP_DAG_EXPLORER_API_URL + '/' + network + '/addresses/' + address + '/rewards',
{ limit, offset, groupingMode: 'day' },
undefined,
false
);
Expand All @@ -81,7 +81,7 @@ export const useGetAddressMetagraphRewards = (
'/metagraphs/' +
metagraphId +
'/rewards',
{ limit, offset },
{ limit, offset, groupingMode: 'day' },
undefined,
false
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/RewardsTable/HeaderRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export const HeaderRow = ({ headerCols }: { headerCols?: string[] }) => {
</div>

<div className={`${styles.headerColumn}`}>
<p className={styles.headerText}>ORDINAL</p>
<p className={styles.headerText}>REWARDS TXNS</p>
</div>

<div className={clsx(styles.headerColumn, styles.topRightBorder)}>
<p className={styles.headerText}>AMOUNT</p>
<p className={styles.headerText}>DAILY TOTAL</p>
</div>

<div className={clsx(styles.headerColumn, styles.timestamp)}>
<p className={styles.headerText}>TIMESTAMP</p>
<p className={styles.headerText}>DATE</p>
</div>
</>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/RewardsTable/RewardRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const RewardRow = ({
let txRow = undefined;

if (reward) {
const date = formatTime(reward.accruedAt, 'relative');
const date = formatTime(reward.accruedAt, 'date');
const fullDate = formatTime(reward.accruedAt, 'full');
txRow = (
<>
Expand Down Expand Up @@ -63,7 +63,9 @@ export const RewardRow = ({
</div>
</div>
<div className={clsx(isLastRow ? styles.txnCellLastRow : styles.txnCell)}>
{reward.metagraphId ? (
{reward.ordinal === -1 ? (
reward.rewardsCount
) : reward.metagraphId ? (
<Link to={`/metagraphs/${reward.metagraphId}/snapshots/${reward.ordinal}`}>{reward.ordinal}</Link>
) : (
<Link to={'/snapshots/' + reward.ordinal}>{reward.ordinal}</Link>
Expand Down
8 changes: 5 additions & 3 deletions src/components/RewardsTable/RewardsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const RewardsTable = ({
}) => {
const { dagInfo } = useContext(PricesContext) as PricesContextType;

const titles = ['SENT TO', 'ORDINAL', 'AMOUNT', 'TIMESTAMP'];
const titles = ['SENT TO', 'REWARDS TXNS', 'DAILY TOTAL', 'DATE'];

const needDagInfo = rewards && rewards.length > 0;
const mql = window.matchMedia('(max-width: 580px)');
Expand Down Expand Up @@ -87,13 +87,15 @@ export const RewardsTable = ({
toCopy: reward.address,
});
txCard.push({
value: reward.ordinal,
value: reward.ordinal === -1 ? reward.rewardsCount : reward.ordinal,
linkTo: reward.metagraphId
? `/metagraphs/${reward.metagraphId}/snapshots/${reward.ordinal}`
: reward.ordinal === -1
? undefined
: '/snapshots/' + reward.ordinal,
});
txCard.push({ value: formatAmount(reward.amount, 8, false, reward.symbol) });
txCard.push({ value: formatTime(reward.accruedAt, 'relative'), dataTip: formatTime(reward.accruedAt, 'full') });
txCard.push({ value: formatTime(reward.accruedAt, 'date'), dataTip: formatTime(reward.accruedAt, 'full') });

cardsSet.add(txCard);
});
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export type AddressRewardsResponse = {
amount: number;
accruedAt: string;
ordinal: number;
rewardsCount?: number;
metagraphId?: string;
symbol?: string;
};
4 changes: 2 additions & 2 deletions src/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ const formatRelativeString = (date: string) => {
return formatedDate;
};

export const formatTime = (timestamp: string | number, format: 'full' | 'relative') => {
export const formatTime = (timestamp: string | number, format: 'full' | 'relative' | 'date') => {
return format === 'full'
? dayjs(timestamp).utc().format('YYYY-MM-DD h:mm A +UTC')
: formatRelativeString(dayjs().to(dayjs(timestamp)));
: format === 'date' ? dayjs(timestamp).utc().format('YYYY/MM/DD') : formatRelativeString(dayjs().to(dayjs(timestamp)));
};

export const formatNumber = (number: number | string | undefined | null, format: NumberFormat): string => {
Expand Down
20 changes: 9 additions & 11 deletions src/views/AddressView/AddressDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const AddressDetails = ({ network }: { network: Exclude<Network, 'mainnet
const [limitAddressRewards, setLimitAddressRewards] = useState<number>(10);
const [offsetAddressRewards, setOffsetAddressRewards] = useState<number>(0);

//const addressRewards = useGetAddressRewards(addressId, network, limitAddressRewards, offsetAddressRewards);
const addressRewards = useGetAddressRewards(addressId, network, limitAddressRewards, offsetAddressRewards);
const addressMetagraphRewards = useGetAddressMetagraphRewards(
addressId,
selectedMetagraph && selectedMetagraph.metagraphId,
Expand Down Expand Up @@ -335,13 +335,11 @@ export const AddressDetails = ({ network }: { network: Exclude<Network, 'mainnet
? 'DAG Transactions'
: `${selectedMetagraph.metagraphSymbol} Transactions`}
</Tabs.Tab>
{!(!selectedMetagraph || selectedMetagraph.metagraphId === 'ALL_METAGRAPHS') && (
<Tabs.Tab id="rewards">
{!selectedMetagraph || selectedMetagraph.metagraphId === 'ALL_METAGRAPHS'
? 'DAG Rewards'
: `${selectedMetagraph.metagraphSymbol} Rewards`}
</Tabs.Tab>
)}
<Tabs.Tab id="rewards">
{!selectedMetagraph || selectedMetagraph.metagraphId === 'ALL_METAGRAPHS'
? 'DAG Rewards'
: `${selectedMetagraph.metagraphSymbol} Rewards`}
</Tabs.Tab>
<Tabs.Tab id="tokens">Tokens list</Tabs.Tab>
</Tabs>
</div>
Expand All @@ -358,7 +356,7 @@ export const AddressDetails = ({ network }: { network: Exclude<Network, 'mainnet
{selectedTable === 'tokens' && (
<TokensTable metagraphTokens={metagraphTokensTable} amount={1} loading={!metagraphTokensTable} />
)}
{/* selectedTable === 'rewards' && (!selectedMetagraph || selectedMetagraph.metagraphId === 'ALL_METAGRAPHS') && (
{selectedTable === 'rewards' && (!selectedMetagraph || selectedMetagraph.metagraphId === 'ALL_METAGRAPHS') && (
<RewardsTable
skeleton={{ showSkeleton: addressRewards.isFetching }}
limit={addressRewards.data && addressRewards.data.length > 0 ? addressRewards.data.length : 1}
Expand All @@ -370,7 +368,7 @@ export const AddressDetails = ({ network }: { network: Exclude<Network, 'mainnet
}
icon={<AddressShape />}
/>
) */}
)}
{selectedTable === 'rewards' &&
!(!selectedMetagraph || selectedMetagraph.metagraphId === 'ALL_METAGRAPHS') && (
<RewardsTable
Expand Down Expand Up @@ -429,7 +427,7 @@ export const AddressDetails = ({ network }: { network: Exclude<Network, 'mainnet
disabled={
offsetAddressRewards + limitAddressRewards >
(!selectedMetagraph || selectedMetagraph.metagraphId === 'ALL_METAGRAPHS'
? /* addressRewards?.meta?.total ?? */ 0
? addressRewards?.meta?.total ?? 0
: addressMetagraphRewards?.meta?.total ?? 0)
}
/>
Expand Down

0 comments on commit 15b167a

Please sign in to comment.