Skip to content

Commit

Permalink
fix: 3/n review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhikumar98 committed Sep 25, 2023
1 parent e66f899 commit e6f4c24
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/wallet-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/experimental": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@lifi/sdk": "^2.4.0",
"@lifi/sdk": "^2.4.1",
"@safe-global/safe-apps-provider": "^0.18.0",
"@safe-global/safe-apps-sdk": "^8.1.0",
"@walletconnect/ethereum-provider": "^2.10.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget-embedded/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author": "Eugene Chybisov <[email protected]>",
"dependencies": {
"@ethersproject/abstract-signer": "^5.7.0",
"@lifi/sdk": "^2.4.0",
"@lifi/sdk": "^2.4.1",
"@lifi/wallet-management": "^2.3.4",
"@lifi/widget": "^2.4.5",
"@mui/icons-material": "^5.14.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"author": "Eugene Chybisov <[email protected]>",
"dependencies": {
"@lifi/sdk": "^2.4.0",
"@lifi/sdk": "^2.4.1",
"@lifi/wallet-management": "^2.3.4",
"@lifi/widget": "^2.4.5",
"@mui/icons-material": "^5.14.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@ethersproject/address": "^5.7.0",
"@ethersproject/experimental": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@lifi/sdk": "^2.4.0",
"@lifi/sdk": "^2.4.1",
"@lifi/wallet-management": "^2.3.4",
"@mui/icons-material": "^5.14.9",
"@mui/lab": "^5.0.0-alpha.145",
Expand Down
14 changes: 7 additions & 7 deletions packages/widget/src/hooks/useTransactionHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { useLiFi } from '../providers';
import { useQuery } from '@tanstack/react-query';

export const transactionHistoryCacheKey = 'transaction-history';
interface TransactionHistoryResponse {
transactions: StatusResponse[];
walletAddress: string;

interface TransactionHistoryQueryParams {
data: StatusResponse[];
isLoading: boolean;
refetch: () => void;
}

export const useTransactionHistory = (
address?: string,
): { data: StatusResponse[]; isLoading: boolean; refetch: () => void } => {
): TransactionHistoryQueryParams => {
const lifi = useLiFi();

const { data, isLoading, refetch } = useQuery(
Expand All @@ -20,9 +22,7 @@ export const useTransactionHistory = (

const response = await lifi.getTransactionHistory(address);

const filteredTransactions = (
(response as any).transactions as StatusResponse[]
).filter(
const filteredTransactions = response.transactions.filter(
(transaction) =>
!!transaction.receiving.chainId && !!transaction.sending.chainId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ import type { FullStatusData } from '@lifi/sdk';

export const TransactionHistoryItem: React.FC<{
transaction: StatusResponse;
startAdornment?: React.ReactNode;
endAdornment?: React.ReactNode;
size: number;
start: number;
}> = ({ transaction, size, start, startAdornment, endAdornment }) => {
}> = ({ transaction, size, start }) => {
const { i18n } = useTranslation();
const navigate = useNavigate();

Expand Down Expand Up @@ -74,7 +72,6 @@ export const TransactionHistoryItem: React.FC<{
top: 0,
}}
>
{startAdornment}
<Box
sx={{
display: 'flex',
Expand All @@ -100,7 +97,6 @@ export const TransactionHistoryItem: React.FC<{
<TokenDivider />
<Token token={toToken} px={2} pt={0.5} pb={1} />
</Box>
{endAdornment}
</Card>
);
};
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
import { Box, Container, Stack } from '@mui/material';
import { useLayoutEffect, useRef, useState } from 'react';
import { useRef } from 'react';
import { useWallet } from '../../providers';
import { TransactionHistoryEmpty } from './TransactionHistoryEmpty';
import { useTransactionHistory } from '../../hooks/useTransactionHistory';
import { VirtualizedTransactionHistory } from './VirtualizedTransactionHistoryPage';
import { useContentHeight } from '../../hooks';

const minTransactionListHeight = 680;

export const TransactionHistoryPage: React.FC = () => {
const parentRef = useRef<HTMLUListElement | null>(null);
const [tokenListHeight, setTokenListHeight] = useState(0);
const contentHeight = useContentHeight();
const { account } = useWallet();
const { data: transactions, isLoading } = useTransactionHistory(
account.address,
);

useLayoutEffect(() => {
setTokenListHeight(Math.max(contentHeight, minTransactionListHeight));
}, [contentHeight]);

if (!transactions.length && !isLoading) {
return <TransactionHistoryEmpty />;
}
Expand All @@ -33,7 +26,7 @@ export const TransactionHistoryPage: React.FC = () => {
>
<Box
ref={parentRef}
style={{ height: tokenListHeight, overflow: 'auto' }}
style={{ height: minTransactionListHeight, overflow: 'auto' }}
>
<Stack spacing={2} mt={1}>
<VirtualizedTransactionHistory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export const VirtualizedTransactionHistory: FC<
size={item.size}
start={item.start}
transaction={transaction}
startAdornment={null}
endAdornment={null}
/>
);
})}
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2993,26 +2993,26 @@ __metadata:
languageName: node
linkType: hard

"@lifi/sdk@npm:^2.4.0":
version: 2.4.0
resolution: "@lifi/sdk@npm:2.4.0"
"@lifi/sdk@npm:^2.4.1":
version: 2.4.1
resolution: "@lifi/sdk@npm:2.4.1"
dependencies:
"@ethersproject/abi": ^5.7.0
"@ethersproject/contracts": ^5.7.0
"@lifi/types": ^8.7.1
"@lifi/types": ^9.0.2
bignumber.js: ^9.1.2
eth-rpc-errors: ^4.0.3
ethers: ^5.7.2
checksum: 12f163352b65918b3ec296d133eb7676a49eea9b87dca45813b92750ac5e32c8343999a590f5ef90070b2910073d1875c18c6688503c9ec14f95930700abfd97
checksum: f723f5f15f9ab59500e4bda29ee94ffb039c9880277aac40829cbcce2b20d7c8c72752f3f47454ef3d30b15f083d25c1a55bc83f4d2f7036dea74450bac5d71d
languageName: node
linkType: hard

"@lifi/types@npm:^8.7.1":
version: 8.7.1
resolution: "@lifi/types@npm:8.7.1"
"@lifi/types@npm:^9.0.2":
version: 9.0.2
resolution: "@lifi/types@npm:9.0.2"
dependencies:
ethers: ^5.7.2
checksum: 2f3c5e047a794f23edada0930b6eabd9066c65bbdaf4ecf106cef2c0454fa42a95b3175eed401873c68c555c98455b85de050ce7d4e495edb4440798faccddc7
checksum: 2b8bab6ab00270d3608f8e303ad2a34233fb60c6bc9eda3e42403ce5a14b7d6648042cf400e630f62791fc55477831236e6e2f8137077b9878eee2648acef38b
languageName: node
linkType: hard

Expand All @@ -3024,7 +3024,7 @@ __metadata:
"@ethersproject/abstract-signer": ^5.7.0
"@ethersproject/experimental": ^5.7.0
"@ethersproject/providers": ^5.7.2
"@lifi/sdk": ^2.4.0
"@lifi/sdk": ^2.4.1
"@safe-global/safe-apps-provider": ^0.18.0
"@safe-global/safe-apps-sdk": ^8.1.0
"@walletconnect/ethereum-provider": ^2.10.1
Expand All @@ -3042,7 +3042,7 @@ __metadata:
dependencies:
"@esbuild-plugins/node-globals-polyfill": ^0.2.3
"@ethersproject/abstract-signer": ^5.7.0
"@lifi/sdk": ^2.4.0
"@lifi/sdk": ^2.4.1
"@lifi/wallet-management": ^2.3.4
"@lifi/widget": ^2.4.5
"@mui/icons-material": ^5.14.9
Expand Down Expand Up @@ -3072,7 +3072,7 @@ __metadata:
resolution: "@lifi/widget-playground@workspace:packages/widget-playground"
dependencies:
"@esbuild-plugins/node-globals-polyfill": ^0.2.3
"@lifi/sdk": ^2.4.0
"@lifi/sdk": ^2.4.1
"@lifi/wallet-management": ^2.3.4
"@lifi/widget": ^2.4.5
"@mui/icons-material": ^5.14.9
Expand Down Expand Up @@ -3103,7 +3103,7 @@ __metadata:
"@ethersproject/address": ^5.7.0
"@ethersproject/experimental": ^5.7.0
"@ethersproject/providers": ^5.7.2
"@lifi/sdk": ^2.4.0
"@lifi/sdk": ^2.4.1
"@lifi/wallet-management": ^2.3.4
"@mui/icons-material": ^5.14.9
"@mui/lab": ^5.0.0-alpha.145
Expand Down

0 comments on commit e6f4c24

Please sign in to comment.