Skip to content

Commit

Permalink
fix createOpenOrdersIx when passing indexerAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbridges authored Feb 19, 2024
1 parent b6b3174 commit c60c11c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions ts/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,25 +465,25 @@ export class OpenBookV2Client {
): Promise<[TransactionInstruction[], PublicKey]> {
const ixs: TransactionInstruction[] = [];
let accountIndex = new BN(1);

if (openOrdersIndexer == null) {
if (openOrdersIndexer == null)
openOrdersIndexer = this.findOpenOrdersIndexer(owner);
try {
const storedIndexer = await this.deserializeOpenOrdersIndexerAccount(
openOrdersIndexer,
);
if (storedIndexer == null) {
ixs.push(
await this.createOpenOrdersIndexerIx(openOrdersIndexer, owner),
);
} else {
accountIndex = new BN(storedIndexer.createdCounter + 1);
}
} catch {

try {
const storedIndexer = await this.deserializeOpenOrdersIndexerAccount(
openOrdersIndexer,
);
if (storedIndexer == null) {
ixs.push(
await this.createOpenOrdersIndexerIx(openOrdersIndexer, owner),
);
} else {
accountIndex = new BN(storedIndexer.createdCounter + 1);
}
} catch {
ixs.push(
await this.createOpenOrdersIndexerIx(openOrdersIndexer, owner),
);
}

const openOrdersAccount = this.findOpenOrderAtIndex(owner, accountIndex);
Expand Down

0 comments on commit c60c11c

Please sign in to comment.