allow fetching mango account by publickey

This commit is contained in:
tjs 2022-09-26 17:12:58 -04:00
parent 5b4a810c5e
commit 0def209608
1 changed files with 7 additions and 3 deletions

View File

@ -602,10 +602,14 @@ export class MangoClient {
); );
} }
public async getMangoAccount(mangoAccount: MangoAccount) { public async getMangoAccount(mangoAccount: MangoAccount | PublicKey) {
const mangoAccountPk =
mangoAccount instanceof MangoAccount
? mangoAccount.publicKey
: mangoAccount;
return MangoAccount.from( return MangoAccount.from(
mangoAccount.publicKey, mangoAccountPk,
await this.program.account.mangoAccount.fetch(mangoAccount.publicKey), await this.program.account.mangoAccount.fetch(mangoAccountPk),
); );
} }