Skip to content

Conversation

macfly-base
Copy link

1-Removed Unused Imports

Eliminated decodeAbiParameters as it was not used anywhere. Removed solanaWeb3 = require("@solana/web3.js") since you're already importing PublicKey directly.

2-Improved Error Handling & Safety Checks

Used optional chaining (?.) to prevent crashes in case transaction, receipt, or block are null or undefined. Defaulted values to "0" if missing (transaction?.value ?? "0", etc.). Wrapped fetch calls with .catch(() => []) to avoid unhandled errors.

3-Optimized timeAgo and timeLeft Functions

Reduced redundancy by using an array of time units instead of multiple if-else statements. Used division logic to simplify conversions (e.g., secondsPast / (unit / 60)). Used await Promise.all() for Parallel Requests

Fetching the transaction receipt and transaction details at the same time for better performance.

4-Ensured Proper Return Values

getEclipseTransaction() and checkDepositWithPDA() now return null explicitly if no data is found instead of being undefined.

1-Removed Unused Imports

Eliminated decodeAbiParameters as it was not used anywhere.
Removed solanaWeb3 = require("@solana/web3.js") since you're already importing PublicKey directly.

2-Improved Error Handling & Safety Checks

Used optional chaining (?.) to prevent crashes in case transaction, receipt, or block are null or undefined.
Defaulted values to "0" if missing (transaction?.value ?? "0", etc.).
Wrapped fetch calls with .catch(() => []) to avoid unhandled errors.

3-Optimized timeAgo and timeLeft Functions

Reduced redundancy by using an array of time units instead of multiple if-else statements.
Used division logic to simplify conversions (e.g., secondsPast / (unit / 60)).
Used await Promise.all() for Parallel Requests

Fetching the transaction receipt and transaction details at the same time for better performance.

4-Ensured Proper Return Values

getEclipseTransaction() and checkDepositWithPDA() now return null explicitly if no data is found instead of being undefined.
Copy link

vercel bot commented Mar 16, 2025

@macfly-base is attempting to deploy a commit to the Eclipse Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant