max accounts error margin fcn (#905)
* add error for max accounts limit * fix
This commit is contained in:
parent
8aff0fb8c5
commit
1a6a544ecd
|
@ -226,9 +226,26 @@ export class MangoClient {
|
|||
ixs: TransactionInstruction[],
|
||||
opts: SendTransactionOpts = {},
|
||||
): Promise<MangoSignatureStatus> {
|
||||
const alts =
|
||||
opts?.alts && opts?.alts?.length
|
||||
? opts.alts
|
||||
: group.addressLookupTablesList;
|
||||
|
||||
const uniqueAccountsCount = [
|
||||
...new Set([
|
||||
...ixs.flatMap((x) => x.keys.map((x) => x.pubkey.toBase58())),
|
||||
...ixs.flatMap((x) => x.programId.toBase58()),
|
||||
...alts.map((x) => x.key.toBase58()),
|
||||
]),
|
||||
].length;
|
||||
|
||||
if (uniqueAccountsCount > 64) {
|
||||
throw new Error(`Max accounts limit exceeded`);
|
||||
}
|
||||
|
||||
return await this.sendAndConfirmTransaction(ixs, {
|
||||
alts: group.addressLookupTablesList,
|
||||
...opts,
|
||||
alts: alts,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue