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

Commits on Oct 3, 2024

  1. Update solanaUtils.ts

    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.
    macfly-base authored Oct 3, 2024
    Configuration menu
    Copy the full SHA
    ba0fa70 View commit details
    Browse the repository at this point in the history