UNPKG

@shogun-sdk/money-legos

Version:

Shogun Money Legos: clients and types for quotes, memes, prices, balances, fees, validations, etc.

25 lines (21 loc) 858 B
import { PublicKey } from '@solana/web3.js'; import { isEVMChain, SOLANA_CHAIN_ID } from '../config/chains.js'; import { getEvmJsonRpcProvider, getSolanaProvider } from './rpc.js'; export const getNativeBalanceRpc = async (walletAddress: string, network: number): Promise<bigint> => { let balance = BigInt(0); if (network === SOLANA_CHAIN_ID) { const provider = await getSolanaProvider(); balance = BigInt(await provider.getBalance(new PublicKey(walletAddress))); } else if (isEVMChain(network)) { const provider = getEvmJsonRpcProvider(network); balance = await provider.getBalance({ address: walletAddress as `0x${string}`, // ...(txReceipt // ? { // blockNumber: (txReceipt as EthTransactionResponse).blockNumber, // } // : {}), }); } return BigInt(balance); };