Feature implementation from commits 2cc3802..c365984#3
Feature implementation from commits 2cc3802..c365984#3codeOwlAI wants to merge 45 commits intofeature-base-branch-1from
Conversation
Deploy subgraph fix
merge dev to main for mainnet-fix
update mainnet subgraph
fix current balance decimals
deploy resolver fix
deploy subgraph update
fix time read from ipfs
ipfs-date-fix-attempt-02
merge kleros and new chain updates
updated subgraph versions
unified ui elements
fixed updatable escrow display
move latest website to prod
move dapp ux audit fixes to prod
fixed copy in payments form
fixed terms url + etherscan links
fixed project details form
push latest to main
move updatable-v2 to main
push v0.1.24 to prod
push latest to prod
move to prod v0.1.28
remove support for porters
fix + clean up invoice pdf
fixed base url env
…picker fix: ensure result is a Date object in sevenDaysFromDate function
…ross multiple components
…lidation in LockFunds, ResolveFunds, and VerifyInvoice components
…CreateInvoiceEscrow component
…nhance query structure in invoice components
| ], | ||
| }); | ||
|
|
||
| return results.map(({ result }) => result) as unknown as [ |
There was a problem hiding this comment.
🐛 Correctness Issue
Unsafe Type Casting Without Validation.
Results from blockchain contract calls are forcefully cast to specific types without validation, which will cause runtime exceptions if the contract returns unexpected data.
Current Code (Diff):
- return results.map(({ result }) => result) as unknown as [
- number,
- string,
- string,
- ];
+ try {
+ const [decimals, name, symbol] = results.map(({ result }) => result);
+ return [Number(decimals), String(name), String(symbol)] as [number, string, string];
+ } catch (error) {
+ console.error('Error processing token metadata:', error);
+ return undefined;
+ }📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| return results.map(({ result }) => result) as unknown as [ | |
| try { | |
| const [decimals, name, symbol] = results.map(({ result }) => result); | |
| return [Number(decimals), String(name), String(symbol)] as [number, string, string]; | |
| } catch (error) { | |
| console.error('Error processing token metadata:', error); | |
| return undefined; | |
| } |
| ], | ||
| }); | ||
|
|
||
| return results.map( |
There was a problem hiding this comment.
🐛 Correctness Issue
Unsafe Type Casting Without Validation.
Results from blockchain contract calls are forcefully cast to specific types without validation, which will cause runtime exceptions if the contract returns unexpected data.
Current Code (Diff):
- return results.map(
- ({ result }) => result,
- ) as unknown as InstantInvoiceContractData;
+ try {
+ const mappedResults = results.map(({ result }) => result);
+ return [
+ mappedResults[0] as bigint,
+ mappedResults[1] as bigint,
+ Boolean(mappedResults[2]),
+ mappedResults[3] as bigint,
+ Number(mappedResults[4]),
+ Number(mappedResults[5])
+ ] as InstantInvoiceContractData;
+ } catch (error) {
+ console.error('Error processing invoice data:', error);
+ return undefined;
+ }📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| return results.map( | |
| try { | |
| const mappedResults = results.map(({ result }) => result); | |
| return [ | |
| mappedResults[0] as bigint, | |
| mappedResults[1] as bigint, | |
| Boolean(mappedResults[2]), | |
| mappedResults[3] as bigint, | |
| Number(mappedResults[4]), | |
| Number(mappedResults[5]) | |
| ] as InstantInvoiceContractData; | |
| } catch (error) { | |
| console.error('Error processing invoice data:', error); | |
| return undefined; | |
| } |
| }: { | ||
| address: Hex | undefined; | ||
| chainId: number | undefined; | ||
| }) => ['tokenBalance', { address, chainId }] as QueryKey; |
There was a problem hiding this comment.
🐛 Correctness Issue
Cache key collision: incorrect query key identifier.
The query key uses 'tokenBalance' but this hook is for instant invoice details, causing cache collisions that will break data fetching.
Current Code (Diff):
- }) => ['tokenBalance', { address, chainId }] as QueryKey;
+ }) => ['instantDetails', { address, chainId }] as QueryKey;📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| }) => ['tokenBalance', { address, chainId }] as QueryKey; | |
| }) => ['instantDetails', { address, chainId }] as QueryKey; |
| ); | ||
|
|
||
| return { | ||
| data: _.isNil(data) ? undefined : BigInt(data as string), |
There was a problem hiding this comment.
🐛 Correctness Issue
Unsafe BigInt conversion may cause runtime exceptions.
The code attempts to convert data to BigInt without proper type validation, which could throw runtime exceptions if data is not a valid string representation of a number.
Current Code (Diff):
- data: _.isNil(data) ? undefined : BigInt(data as string),
+ data: _.isNil(data) ? undefined : (typeof data === 'string' || typeof data === 'number' || typeof data === 'bigint') ? BigInt(data) : undefined,📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| data: _.isNil(data) ? undefined : BigInt(data as string), | |
| data: _.isNil(data) ? undefined : (typeof data === 'string' || typeof data === 'number' || typeof data === 'bigint') ? BigInt(data) : undefined, |
PR Summary
Refactor Data Fetching with React Query and Add Server-Side Support
Overview
This PR refactors the data fetching approach across the application, moving from direct contract calls to React Query patterns. It adds server-side prefetching capabilities, implements new token-related hooks, and improves code organization while maintaining backward compatibility.
Change Types
Affected Modules
hooks/src/*.tshooks/src/useTokenBalance.tshooks/src/useTokenData.tshooks/src/useInstantDetails.tshooks/src/useInvoiceDetails.tsutils/src/invoice.tsutils/src/web3.tsdapp/next.config.jsgraphql/src/invoice.tsNotes for Reviewers