diff --git a/javascript/solana.js/src/accounts/oracleAccount.ts b/javascript/solana.js/src/accounts/oracleAccount.ts index c3c9b08..b9426ab 100644 --- a/javascript/solana.js/src/accounts/oracleAccount.ts +++ b/javascript/solana.js/src/accounts/oracleAccount.ts @@ -16,6 +16,7 @@ import { PermissionAccount } from './permissionAccount'; import { QueueAccount } from './queueAccount'; import * as spl from '@solana/spl-token'; import { TransactionObject } from '../transaction'; +import BN from 'bn.js'; /** * Account type holding an oracle's configuration including the authority and the reward/slashing wallet along with a set of metrics tracking its reliability. @@ -118,6 +119,15 @@ export class OracleAccount extends Account { return amount; } + async fetchBalanceBN(stakingWallet?: PublicKey): Promise { + const tokenAccount = stakingWallet ?? (await this.loadData()).tokenAccount; + const amount = await this.program.mint.fetchBalanceBN(tokenAccount); + if (amount === null) { + throw new Error(`Failed to fetch oracle staking wallet balance`); + } + return amount; + } + /** * Retrieve and decode the {@linkcode types.OracleAccountData} stored in this account. */