solana.js: added OracleAccount fetchBalanceBN method
This commit is contained in:
parent
809efaa016
commit
13a70f716b
|
@ -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<types.OracleAccountData> {
|
|||
return amount;
|
||||
}
|
||||
|
||||
async fetchBalanceBN(stakingWallet?: PublicKey): Promise<BN> {
|
||||
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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue