Skip to content

Commit

Permalink
fix compile error by moving node-wallet anchor usage into not-exporte…
Browse files Browse the repository at this point in the history
…d file (#257)
  • Loading branch information
mschneider authored Apr 21, 2024
1 parent 77bc5b7 commit 67f0e92
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion ts/client/src/test/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
OPENBOOK_PROGRAM_ID,
findAccountsByMints,
findAllMarkets,
initReadOnlyOpenbookClient,
Watcher,
sleep,
} from '..';
import { initReadOnlyOpenbookClient } from './util';

async function testFindAccountsByMints(): Promise<void> {
const client = initReadOnlyOpenbookClient();
Expand Down
9 changes: 2 additions & 7 deletions ts/client/src/test/openOrders.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { PublicKey } from '@solana/web3.js';
import {
Market,
OpenOrders,
SideUtils,
initOpenbookClient,
initReadOnlyOpenbookClient,
} from '..';
import { Market, OpenOrders, SideUtils } from '..';
import { OpenOrdersIndexer } from '../accounts/openOrdersIndexer';
import { initOpenbookClient, initReadOnlyOpenbookClient } from './util';

async function testLoadIndexerNonExistent(): Promise<void> {
const client = initReadOnlyOpenbookClient();
Expand Down
21 changes: 21 additions & 0 deletions ts/client/src/test/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Connection, Keypair } from '@solana/web3.js';
import { OpenBookV2Client } from '..';
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';

export function initReadOnlyOpenbookClient(): OpenBookV2Client {
const conn = new Connection(process.env.SOL_RPC_URL!);
const stubWallet = new Wallet(Keypair.generate());
const provider = new AnchorProvider(conn, stubWallet, {});
return new OpenBookV2Client(provider);
}

export function initOpenbookClient(): OpenBookV2Client {
const conn = new Connection(process.env.SOL_RPC_URL!, 'processed');
const wallet = new Wallet(
Keypair.fromSecretKey(Uint8Array.from(JSON.parse(process.env.KEYPAIR!))),
);
const provider = new AnchorProvider(conn, wallet, {});
return new OpenBookV2Client(provider, undefined, {
prioritizationFee: 10_000,
});
}
22 changes: 0 additions & 22 deletions ts/client/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
Connection,
Keypair,
PublicKey,
SystemProgram,
TransactionInstruction,
Expand All @@ -10,8 +8,6 @@ import {
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
} from '@solana/spl-token';
import { OpenBookV2Client } from '..';
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';

export const SideUtils = {
Bid: { bid: {} },
Expand Down Expand Up @@ -115,24 +111,6 @@ export async function createAssociatedTokenAccountIdempotentInstruction(
});
}

export function initReadOnlyOpenbookClient(): OpenBookV2Client {
const conn = new Connection(process.env.SOL_RPC_URL!);
const stubWallet = new Wallet(Keypair.generate());
const provider = new AnchorProvider(conn, stubWallet, {});
return new OpenBookV2Client(provider);
}

export function initOpenbookClient(): OpenBookV2Client {
const conn = new Connection(process.env.SOL_RPC_URL!, 'processed');
const wallet = new Wallet(
Keypair.fromSecretKey(Uint8Array.from(JSON.parse(process.env.KEYPAIR!))),
);
const provider = new AnchorProvider(conn, wallet, {});
return new OpenBookV2Client(provider, undefined, {
prioritizationFee: 10_000,
});
}

export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

0 comments on commit 67f0e92

Please sign in to comment.