-
Notifications
You must be signed in to change notification settings - Fork 37
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
refactor: limit to 1M block transaction to get historical data in finance area #601
base: next
Are you sure you want to change the base?
Conversation
- Updated `use-get-smart-wallet-transactions.ts`: - Added logic to dynamically fetch the starting block number using `publicClient.getBlockNumber` with a configurable offset (`GLOBAL_CONSTANTS.FROM_BLOCK`). - Refactored fromBlock assignment to use the fetched block number instead of a hardcoded value. - Improved error handling for block number fetch failures. - Updated `config-global.ts`: - Introduced a new global constant `FROM_BLOCK` to configure the starting block for fetching transactions. This change improves flexibility and enables querying specific block ranges dynamically.
- Removed a debug `console.log` statement from `finance-transactions-history.tsx`. - The cleanup ensures no unnecessary logs are left in production code. ```
- Updated `fromBlock` in `use-get-smart-wallet-transactions.ts` to default to `0n` if undefined. - This ensures that the hook functions correctly even when `fromBlock` is not provided.
- Updated FROM_BLOCK key in `src/config-global.ts` to use `VITE_FROM_BLOCK` instead of `VITE_BLOCK_FROM`. - This ensures consistency with the defined environment variable naming conventions.
|
@@ -101,17 +101,26 @@ export default function useGetSmartWalletTransactions() { | |||
return; | |||
} | |||
|
|||
const fetchBlockNumber = async () => { | |||
try { | |||
return await publicClient.getBlockNumber().then((block) => BigInt(block - BigInt(GLOBAL_CONSTANTS.FROM_BLOCK))); |
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.
aca el await no es necesario..
import {useDispatch, useSelector} from 'react-redux' | ||
import {Address, formatUnits, parseAbiItem} from 'viem' | ||
import {publicClient} from '@src/clients/viem/publicClient.ts' | ||
import {GLOBAL_CONSTANTS} from '@src/config-global.ts' |
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.
constantes y abis moverlos al final de los imports por convention
This pull request includes several changes to enhance functionality and code quality in the project. The most important changes include adding a new constant to the global configuration, updating the smart wallet transactions hook to fetch the block number dynamically, and removing an unnecessary console log statement.
> Should Add VITE_BLOCK_FROM=1000000 to .env files.
Enhancements to global configuration and hooks:
src/config-global.ts
: AddedFROM_BLOCK
constant to handle block number configuration.src/hooks/protocol/use-get-smart-wallet-transactions.ts
: Updated import statements formatting for consistency.src/hooks/protocol/use-get-smart-wallet-transactions.ts
: Introduced a new functionfetchBlockNumber
to dynamically fetch the block number and used it in the main function to set thefromBlock
parameter.Code quality improvements:
src/sections/finance/components/finance-transactions-history.tsx
: Removed an unnecessary console log statement for cleaner code.