-
Notifications
You must be signed in to change notification settings - Fork 17
/
utils.ts
46 lines (41 loc) · 1.28 KB
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import * as fs from "fs";
import {
OpenBookV2Client,
IDL,
type OpenbookV2,
} from "@openbook-dex/openbook-v2";
import {
Connection,
Keypair,
PublicKey,
ComputeBudgetProgram,
SystemProgram,
Transaction,
} from "@solana/web3.js";
import { AnchorProvider, BN, Program, getProvider } from "@coral-xyz/anchor";
import * as os from "os";
import { createAccount } from "./solana_utils";
import { MintUtils } from "./mint_utils";
// export const RPC = "http://127.0.0.1:8899";
// export const RPC = "https://api.devnet.solana.com";
// export const RPC= "https://api.testnet.solana.com";
export const RPC= "https://api.mainnet-beta.solana.com";
export const programId = new PublicKey(
"opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb"
);
export const authorityFile = `${os.homedir()}/.config/solana/id.json`;
export const authority = getKeypairFromFile(authorityFile);
export const connection = new Connection(RPC, {
commitment: "finalized",
confirmTransactionInitialTimeout: 30000,
});
export const program = new Program<OpenbookV2>(IDL, programId, getProvider());
export function getKeypairFromFile(filePath: String): Keypair {
return Keypair.fromSecretKey(
Uint8Array.from(
JSON.parse(
process.env.KEYPAIR || fs.readFileSync(filePath.toString(), "utf-8")
)
)
);
}