Skip to content
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

Update solanaUtils.ts #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

macfly-base
Copy link

Avoid Multiple Imports:
By directly importing everything from @solana/web3.js, we avoid importing it in two different ways (both require and import).

Connection Caching:
Created a single connection instance that will be reused across function calls. This saves on unnecessary instantiation and network overhead.

Error Handling and Input Validation:
Wrapped PublicKey instantiation in a try-catch block to handle invalid addresses. Improved error messages for clarity during debugging. Lamports to SOL Conversion:

Use LAMPORTS_PER_SOL directly instead of referring to it via solanaWeb3. LAMPORTS_PER_SOL to make the code more concise.

TypeScript Typing:
Ensured that publicKey is typed correctly as a string in getWalletBalance and solanaAddress is typed as PublicKeyInitData in solanaToBytes32.

Avoid Multiple Imports: 
By directly importing everything from @solana/web3.js, we avoid importing it in two different ways (both require and import).

Connection Caching:
Created a single connection instance that will be reused across function calls. This saves on unnecessary instantiation and network overhead.

Error Handling and Input Validation:
Wrapped PublicKey instantiation in a try-catch block to handle invalid addresses.
Improved error messages for clarity during debugging.
Lamports to SOL Conversion:

Use LAMPORTS_PER_SOL directly instead of referring to it via solanaWeb3. LAMPORTS_PER_SOL to make the code more concise.

TypeScript Typing:
Ensured that publicKey is typed correctly as a string in getWalletBalance and solanaAddress is typed as PublicKeyInitData in solanaToBytes32.
Copy link

vercel bot commented Oct 3, 2024

@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.

@macfly-base macfly-base closed this Oct 9, 2024
@macfly-base macfly-base reopened this Oct 9, 2024
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