mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-13 23:16:55 +00:00
fix: type for get_balance
This commit is contained in:
@@ -84,7 +84,7 @@ export class SolanaAgentKit {
|
||||
return deploy_collection(this, options);
|
||||
}
|
||||
|
||||
async getBalance(token_address?: PublicKey): Promise<number | null> {
|
||||
async getBalance(token_address?: PublicKey): Promise<number> {
|
||||
return get_balance(this, token_address);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { SolanaAgentKit } from "../index";
|
||||
export async function get_balance(
|
||||
agent: SolanaAgentKit,
|
||||
token_address?: PublicKey,
|
||||
): Promise<number | null> {
|
||||
): Promise<number> {
|
||||
if (!token_address)
|
||||
return (
|
||||
(await agent.connection.getBalance(agent.wallet_address)) /
|
||||
@@ -19,5 +19,5 @@ export async function get_balance(
|
||||
|
||||
const token_account =
|
||||
await agent.connection.getTokenAccountBalance(token_address);
|
||||
return token_account.value.uiAmount;
|
||||
return token_account.value.uiAmount || 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user