From c72e3bb23bf5591e4cd3243986a07f1ed65c8317 Mon Sep 17 00:00:00 2001 From: yugure <98769788+everlastingsong@users.noreply.github.com> Date: Sat, 20 Jan 2024 13:21:34 +0900 Subject: [PATCH] Update 00b_base_without_env_vars.ts --- .../00b_base_without_env_vars.ts | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/orca/whirlpool/whirlpools_sdk/00b_base_without_env_vars.ts b/orca/whirlpool/whirlpools_sdk/00b_base_without_env_vars.ts index 96a4fbd..26c616d 100644 --- a/orca/whirlpool/whirlpools_sdk/00b_base_without_env_vars.ts +++ b/orca/whirlpool/whirlpools_sdk/00b_base_without_env_vars.ts @@ -1,16 +1,25 @@ -import { WhirlpoolContext, AccountFetcher, ORCA_WHIRLPOOL_PROGRAM_ID, buildWhirlpoolClient } from "@orca-so/whirlpools-sdk"; -const { Wallet } = require("@project-serum/anchor"); // v0.20.1 bug, import for Wallet is not possible +import { WhirlpoolContext, ORCA_WHIRLPOOL_PROGRAM_ID, buildWhirlpoolClient } from "@orca-so/whirlpools-sdk"; +import { Wallet } from "@coral-xyz/anchor"; import { Keypair, Connection } from "@solana/web3.js"; -const RPC_ENDPOINT_URL="https://ssc-dao.genesysgo.net" +// bash$ ts-node this_script.ts + +// you need to use your RPC endpoint (Public RPC is just for example) +const RPC_ENDPOINT_URL= "https://api.mainnet-beta.solana.com"; const COMMITMENT = "confirmed"; -const connection = new Connection(RPC_ENDPOINT_URL, COMMITMENT); -const wallet = new Wallet(Keypair.generate()); // dummy +async function main() { + const connection = new Connection(RPC_ENDPOINT_URL, COMMITMENT); -const ctx = WhirlpoolContext.from(connection, wallet, ORCA_WHIRLPOOL_PROGRAM_ID); -const fetcher = new AccountFetcher(ctx.connection); -const client = buildWhirlpoolClient(ctx, fetcher); + // create dummy wallet with temporary keypair + const wallet = new Wallet(Keypair.generate()); + + const ctx = WhirlpoolContext.from(connection, wallet, ORCA_WHIRLPOOL_PROGRAM_ID); + const fetcher = ctx.fetcher; + const client = buildWhirlpoolClient(ctx); + + console.log("connection endpoint", ctx.connection.rpcEndpoint); + console.log("wallet", ctx.wallet.publicKey.toBase58()); +} -console.log("connection endpoint", ctx.connection.rpcEndpoint); -console.log("wallet", ctx.wallet.publicKey.toBase58()); +main();