-
Notifications
You must be signed in to change notification settings - Fork 31
feat: pagination on wallet UI #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/sf-815-pagination-on-snap
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,8 @@ import { | |
| updateAccount, | ||
| updateCurrentAccount, | ||
| setWalletConnection, | ||
| setTransactionCursor, | ||
| appendTransactions, | ||
| } from 'slices/walletSlice'; | ||
| import { setNetworksAndActiveNetwork } from 'slices/networkSlice'; | ||
| import { disableLoading, enableLoadingWithMessage } from 'slices/UISlice'; | ||
|
|
@@ -60,6 +62,9 @@ export const useStarkNetSnap = () => { | |
| (state) => state.wallet.erc20TokenBalances, | ||
| ); | ||
| const accounts = useAppSelector((state) => state.wallet.accounts); | ||
| const transactionDeploy = useAppSelector( | ||
| (state) => state.wallet.transactionDeploy, | ||
| ); | ||
|
|
||
| const connectToSnap = async () => { | ||
| dispatch(enableLoadingWithMessage('Connecting...')); | ||
|
|
@@ -236,6 +241,7 @@ export const useStarkNetSnap = () => { | |
|
|
||
| const setErc20TokenBalance = (erc20TokenBalance: Erc20TokenBalance) => { | ||
| dispatch(setErc20TokenBalanceSelected(erc20TokenBalance)); | ||
| dispatch(setTransactionDeploy(null)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Token Change Incorrectly Resets Deploy TransactionSetting |
||
| }; | ||
|
|
||
| const initTokensAndBalances = async (chainId: string, address: string) => { | ||
|
|
@@ -443,38 +449,49 @@ export const useStarkNetSnap = () => { | |
| const getTransactions = async ( | ||
| senderAddress: string, | ||
| contractAddress: string, | ||
| txnsInLastNumOfDays: number, | ||
| chainId: string, | ||
| showLoading: boolean = true, | ||
| onlyFromState: boolean = false, | ||
| cursor?: { blockNumber: number; txnHash: string }, | ||
| ) => { | ||
| if (transactionDeploy) { | ||
| return; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: State Persistence Blocks Transaction FetchingThe |
||
| if (showLoading) { | ||
| dispatch(enableLoadingWithMessage('Retrieving transactions...')); | ||
| } | ||
|
|
||
| try { | ||
| const data = await invokeSnap<Array<Transaction>>({ | ||
| const response = await invokeSnap<{ | ||
| transactions: Transaction[]; | ||
| cursor: { txnHash: string; blockNumber: number }; | ||
| }>({ | ||
| method: 'starkNet_getTransactions', | ||
| params: { | ||
| senderAddress, | ||
| contractAddress, | ||
| txnsInLastNumOfDays, | ||
| cursor, | ||
| chainId, | ||
| }, | ||
| }); | ||
|
|
||
| const data = response.transactions; | ||
| const newCursor = response.cursor; | ||
|
|
||
| let storedTxns = data; | ||
|
|
||
| if (cursor) { | ||
| dispatch(appendTransactions(storedTxns)); | ||
| } else { | ||
| dispatch(setTransactions(storedTxns)); | ||
| } | ||
| //Set the deploy transaction | ||
| const deployTransaction = storedTxns.find( | ||
| (txn: Transaction) => | ||
| txn.txnType === TransactionType.DEPLOY || | ||
| txn.txnType === TransactionType.DEPLOY_ACCOUNT, | ||
| ); | ||
| dispatch(setTransactionDeploy(deployTransaction)); | ||
|
|
||
| dispatch(setTransactions(storedTxns)); | ||
|
|
||
| dispatch(setTransactionCursor(newCursor)); | ||
| return data; | ||
| } catch (error) { | ||
| dispatch(setTransactions([])); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Set Comparison Fails for Object References
The
seenCursorsSet uses object references, but JavaScript Sets compare objects by reference, not by value. This meanshas()always returns false for new object instances, leading to duplicate transaction fetches for the same cursor.