sbv2-utils: cleaned up loading token account for test env
wip wip
This commit is contained in:
parent
d3a3645662
commit
81fe56023d
|
@ -37,7 +37,7 @@
|
|||
"@project-serum/anchor": "^0.24.2",
|
||||
"@saberhq/token-utils": "^1.13.32",
|
||||
"@solana/spl-token": "^0.2.0",
|
||||
"@solana/web3.js": "^1.47.3",
|
||||
"@solana/web3.js": "^1.43.5",
|
||||
"@switchboard-xyz/switchboard-v2": "^0.0.121",
|
||||
"big.js": "^6.1.1",
|
||||
"bn.js": "^5.2.1",
|
||||
|
|
|
@ -8,7 +8,7 @@ export * from "./feed.js";
|
|||
export * from "./json.js";
|
||||
export * from "./nonce.js";
|
||||
export * from "./print.js";
|
||||
export * from "./state.js";
|
||||
export * from "./switchboard.js";
|
||||
export * from "./test/index.js";
|
||||
export * from "./token.js";
|
||||
export * from "./transaction.js";
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import type * as anchor from "@project-serum/anchor";
|
||||
import * as spl from "@solana/spl-token";
|
||||
import type { PublicKey } from "@solana/web3.js";
|
||||
import {
|
||||
ProgramStateAccount,
|
||||
programWallet,
|
||||
} from "@switchboard-xyz/switchboard-v2";
|
||||
|
||||
export const getOrCreateSwitchboardTokenAccount = async (
|
||||
program: anchor.Program,
|
||||
switchboardMint?: spl.Mint,
|
||||
payer = programWallet(program)
|
||||
): Promise<PublicKey> => {
|
||||
const getAssociatedAddress = async (mint: spl.Mint): Promise<PublicKey> => {
|
||||
const tokenAccount = await spl.getOrCreateAssociatedTokenAccount(
|
||||
program.provider.connection,
|
||||
payer,
|
||||
mint.address,
|
||||
payer.publicKey,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
spl.TOKEN_PROGRAM_ID,
|
||||
spl.ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
);
|
||||
return tokenAccount.address;
|
||||
};
|
||||
|
||||
let mint = switchboardMint;
|
||||
if (mint) {
|
||||
return getAssociatedAddress(mint);
|
||||
}
|
||||
const [programState] = ProgramStateAccount.fromSeed(program);
|
||||
mint = await programState.getTokenMint();
|
||||
if (mint) {
|
||||
return getAssociatedAddress(mint);
|
||||
}
|
||||
|
||||
throw new Error(`failed to get associated token account`);
|
||||
};
|
|
@ -8,6 +8,7 @@ import Big from "big.js";
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { awaitOpenRound, createAggregator } from "../feed.js";
|
||||
import { transferWrappedSol } from "../token.js";
|
||||
|
||||
export interface ISwitchboardTestContext {
|
||||
program: anchor.Program;
|
||||
|
@ -36,26 +37,61 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
this.oracle = ctx.oracle;
|
||||
}
|
||||
|
||||
// Switchboard currently uses wrapped SOL for mint
|
||||
private static async createSwitchboardWallet(
|
||||
/** Load the associated token wallet for the given payer with a prefunded balance
|
||||
* @param program anchor program
|
||||
* @param mint the switchboard mint address
|
||||
* @param tokenAmount number of tokens to populate in switchboard mint's associated token account
|
||||
*/
|
||||
static async getOrCreateSwitchboardWallet(
|
||||
program: anchor.Program,
|
||||
amount = 1_000_000
|
||||
mint: spl.Mint,
|
||||
tokenAmount: number
|
||||
): Promise<PublicKey> {
|
||||
const payerKeypair = sbv2.programWallet(program);
|
||||
return spl.createWrappedNativeAccount(
|
||||
const balance = await program.provider.connection.getBalance(
|
||||
payerKeypair.publicKey
|
||||
);
|
||||
|
||||
const associatedTokenAccount = await spl.getOrCreateAssociatedTokenAccount(
|
||||
program.provider.connection,
|
||||
payerKeypair,
|
||||
payerKeypair.publicKey,
|
||||
amount,
|
||||
undefined,
|
||||
undefined,
|
||||
spl.TOKEN_PROGRAM_ID
|
||||
mint.address,
|
||||
payerKeypair.publicKey
|
||||
);
|
||||
|
||||
if (tokenAmount <= 0 || tokenAmount <= associatedTokenAccount.amount) {
|
||||
return associatedTokenAccount.address;
|
||||
}
|
||||
|
||||
const amountNeeded = tokenAmount - Number(associatedTokenAccount.amount);
|
||||
if (amountNeeded <= 0) {
|
||||
return associatedTokenAccount.address;
|
||||
}
|
||||
|
||||
if (amountNeeded > balance) {
|
||||
throw new Error(
|
||||
`Payer account does not enough balance to fund new token account, need ${amountNeeded}, have ${balance}`
|
||||
);
|
||||
}
|
||||
|
||||
const finalBalance = await transferWrappedSol(
|
||||
program.provider.connection,
|
||||
payerKeypair,
|
||||
amountNeeded
|
||||
);
|
||||
|
||||
return associatedTokenAccount.address;
|
||||
}
|
||||
|
||||
/** Load SwitchboardTestContext using a specified queue
|
||||
* @param provider anchor Provider containing connection and payer Keypair
|
||||
* @param queueKey the oracle queue to load
|
||||
* @param tokenAmount number of tokens to populate in switchboard mint's associated token account
|
||||
*/
|
||||
static async loadDevnetQueue(
|
||||
provider: anchor.AnchorProvider,
|
||||
queueKey = "F8ce7MsckeZAbAGmxjJNetxYXQa9mKr9nnrC3qKubyYy"
|
||||
queueKey = "F8ce7MsckeZAbAGmxjJNetxYXQa9mKr9nnrC3qKubyYy",
|
||||
tokenAmount = 0
|
||||
) {
|
||||
const payerKeypair = (provider.wallet as sbv2.AnchorWallet).payer;
|
||||
let program: anchor.Program;
|
||||
|
@ -94,26 +130,14 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
`Failed to load the SBV2 mint for the given cluster, ${error.message}`
|
||||
);
|
||||
}
|
||||
let payerTokenWallet: PublicKey;
|
||||
try {
|
||||
payerTokenWallet = (
|
||||
await spl.getOrCreateAssociatedTokenAccount(
|
||||
provider.connection,
|
||||
payerKeypair,
|
||||
mint.address,
|
||||
payerKeypair.publicKey,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
spl.TOKEN_PROGRAM_ID,
|
||||
spl.ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
)
|
||||
).address;
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Failed to load the token wallet for SBV2 mint on the given cluster, ${error.message}`
|
||||
|
||||
const payerTokenWallet =
|
||||
await SwitchboardTestContext.getOrCreateSwitchboardWallet(
|
||||
program,
|
||||
mint,
|
||||
tokenAmount
|
||||
);
|
||||
}
|
||||
|
||||
return new SwitchboardTestContext({
|
||||
program,
|
||||
queue,
|
||||
|
@ -134,6 +158,14 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
|
||||
let currentDirectory = process.cwd();
|
||||
while (retryCount > 0) {
|
||||
// look for switchboard.env
|
||||
try {
|
||||
const currentPath = path.join(currentDirectory, envFileName);
|
||||
if (fs.existsSync(currentPath)) {
|
||||
return currentPath;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
// look for .switchboard directory
|
||||
try {
|
||||
const localSbvPath = path.join(currentDirectory, ".switchboard");
|
||||
|
@ -145,16 +177,7 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
}
|
||||
} catch {}
|
||||
|
||||
// look for switchboard.env
|
||||
try {
|
||||
const currentPath = path.join(currentDirectory, envFileName);
|
||||
if (fs.existsSync(currentPath)) {
|
||||
return currentPath;
|
||||
}
|
||||
currentDirectory = path.join(currentDirectory, "../");
|
||||
} catch {
|
||||
throw NotFoundError;
|
||||
}
|
||||
currentDirectory = path.join(currentDirectory, "../");
|
||||
|
||||
retryCount--;
|
||||
}
|
||||
|
@ -165,10 +188,12 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
/** Load SwitchboardTestContext from an env file containing $SWITCHBOARD_PROGRAM_ID, $ORACLE_QUEUE, $AGGREGATOR
|
||||
* @param provider anchor Provider containing connection and payer Keypair
|
||||
* @param filePath filesystem path to env file
|
||||
* @param tokenAmount number of tokens to populate in switchboard mint's associated token account
|
||||
*/
|
||||
public static async loadFromEnv(
|
||||
provider: anchor.AnchorProvider,
|
||||
filePath = SwitchboardTestContext.findSwitchboardEnv()
|
||||
filePath = SwitchboardTestContext.findSwitchboardEnv(),
|
||||
tokenAmount = 0
|
||||
): Promise<SwitchboardTestContext> {
|
||||
require("dotenv").config({ path: filePath });
|
||||
if (!process.env.SWITCHBOARD_PROGRAM_ID) {
|
||||
|
@ -219,26 +244,13 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
`Failed to load the SBV2 mint for the given cluster, ${error.message}`
|
||||
);
|
||||
}
|
||||
let payerTokenWallet: PublicKey;
|
||||
try {
|
||||
payerTokenWallet = (
|
||||
await spl.getOrCreateAssociatedTokenAccount(
|
||||
provider.connection,
|
||||
payerKeypair,
|
||||
mint.address,
|
||||
payerKeypair.publicKey,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
spl.TOKEN_PROGRAM_ID,
|
||||
spl.ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
)
|
||||
).address;
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Failed to load the token wallet for SBV2 mint on the given cluster, ${error.message}`
|
||||
|
||||
const payerTokenWallet =
|
||||
await SwitchboardTestContext.getOrCreateSwitchboardWallet(
|
||||
switchboardProgram,
|
||||
mint,
|
||||
tokenAmount
|
||||
);
|
||||
}
|
||||
|
||||
const context: ISwitchboardTestContext = {
|
||||
program: switchboardProgram,
|
||||
|
@ -256,7 +268,6 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
value: number,
|
||||
timeout = 30
|
||||
): Promise<sbv2.AggregatorAccount> {
|
||||
const queue = await this.queue.loadData();
|
||||
const payerKeypair = sbv2.programWallet(this.program);
|
||||
|
||||
const staticJob = await sbv2.JobAccount.create(this.program, {
|
||||
|
|
|
@ -13,7 +13,7 @@ import path from "path";
|
|||
import { getIdlAddress, getProgramDataAddress } from "../anchor.js";
|
||||
import { anchorBNtoDateString } from "../date.js";
|
||||
import { createQueue } from "../queue.js";
|
||||
import { getOrCreateSwitchboardTokenAccount } from "../state.js";
|
||||
import { getOrCreateSwitchboardTokenAccount } from "../token.js";
|
||||
|
||||
const LATEST_DOCKER_VERSION = "dev-v2-07-11-22";
|
||||
|
||||
|
@ -323,87 +323,6 @@ secrets:
|
|||
);
|
||||
const idlAddress = await getIdlAddress(switchboardProgram.programId);
|
||||
|
||||
// const [switchboardProgramState] =
|
||||
// sbv2.ProgramStateAccount.fromSeed(switchboardProgram);
|
||||
// let programState: any;
|
||||
// try {
|
||||
// programState = await switchboardProgramState.loadData();
|
||||
// } catch {
|
||||
// await sbv2.ProgramStateAccount.create(switchboardProgram, {
|
||||
// mint: spl.NATIVE_MINT,
|
||||
// daoMint: spl.NATIVE_MINT,
|
||||
// });
|
||||
// programState = await switchboardProgramState.loadData();
|
||||
// }
|
||||
|
||||
// const mint = await switchboardProgramState.getTokenMint();
|
||||
|
||||
// const payerSwitchboardWallet = (
|
||||
// await spl.getOrCreateAssociatedTokenAccount(
|
||||
// connection,
|
||||
// payerKeypair,
|
||||
// mint.address,
|
||||
// payerKeypair.publicKey,
|
||||
// undefined,
|
||||
// undefined,
|
||||
// undefined,
|
||||
// spl.TOKEN_PROGRAM_ID,
|
||||
// spl.ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
// )
|
||||
// ).address;
|
||||
|
||||
// // create queue with unpermissioned VRF accounts enabled
|
||||
// const queueAccount = await sbv2.OracleQueueAccount.create(
|
||||
// switchboardProgram,
|
||||
// {
|
||||
// name: Buffer.from("My Test Queue"),
|
||||
// mint: spl.NATIVE_MINT,
|
||||
// authority: payerKeypair.publicKey, // Approve new participants
|
||||
// minStake: new anchor.BN(0), // Oracle minStake to heartbeat
|
||||
// reward: new anchor.BN(0), // Oracle rewards per request (non-VRF)
|
||||
// queueSize: 10, // Number of active oracles a queue can support
|
||||
// unpermissionedFeeds: true, // Whether feeds need PERMIT_ORACLE_QUEUE_USAGE permissions
|
||||
// unpermissionedVrf: true, // Whether VRF accounts need PERMIT_VRF_REQUESTS permissions
|
||||
// enableBufferRelayers: true,
|
||||
// }
|
||||
// );
|
||||
// await queueAccount.setVrfSettings({
|
||||
// authority: payerKeypair,
|
||||
// unpermissionedVrf: true,
|
||||
// });
|
||||
// const queue = await queueAccount.loadData();
|
||||
|
||||
// // create a crank for the queue
|
||||
// const crankAccount = await sbv2.CrankAccount.create(switchboardProgram, {
|
||||
// name: Buffer.from("My Crank"),
|
||||
// maxRows: 100,
|
||||
// queueAccount,
|
||||
// });
|
||||
// const crank = await crankAccount.loadData();
|
||||
|
||||
// // create oracle to run locally
|
||||
// const oracleAccount = await sbv2.OracleAccount.create(switchboardProgram, {
|
||||
// name: Buffer.from("My Oracle"),
|
||||
// oracleAuthority: payerKeypair,
|
||||
// queueAccount,
|
||||
// });
|
||||
// const oracle = await oracleAccount.loadData();
|
||||
|
||||
// // grant oracle heartbeat permissions
|
||||
// const oraclePermissionAccount = await sbv2.PermissionAccount.create(
|
||||
// switchboardProgram,
|
||||
// {
|
||||
// authority: queue.authority,
|
||||
// granter: queueAccount.publicKey,
|
||||
// grantee: oracleAccount.publicKey,
|
||||
// }
|
||||
// );
|
||||
// await oraclePermissionAccount.set({
|
||||
// authority: payerKeypair,
|
||||
// enable: true,
|
||||
// permission: sbv2.SwitchboardPermission.PERMIT_ORACLE_HEARTBEAT,
|
||||
// });
|
||||
|
||||
const queueResponse = await createQueue(
|
||||
switchboardProgram,
|
||||
{
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
import type * as anchor from "@project-serum/anchor";
|
||||
import * as spl from "@solana/spl-token";
|
||||
import {
|
||||
Connection,
|
||||
Keypair,
|
||||
PublicKey,
|
||||
sendAndConfirmTransaction,
|
||||
SystemProgram,
|
||||
Transaction,
|
||||
} from "@solana/web3.js";
|
||||
import {
|
||||
ProgramStateAccount,
|
||||
programWallet,
|
||||
} from "@switchboard-xyz/switchboard-v2";
|
||||
|
||||
export const getOrCreateSwitchboardTokenAccount = async (
|
||||
program: anchor.Program,
|
||||
switchboardMint?: spl.Mint,
|
||||
payer = programWallet(program)
|
||||
): Promise<PublicKey> => {
|
||||
const getAssociatedAddress = async (mint: spl.Mint): Promise<PublicKey> => {
|
||||
const tokenAccount = await spl.getOrCreateAssociatedTokenAccount(
|
||||
program.provider.connection,
|
||||
payer,
|
||||
mint.address,
|
||||
payer.publicKey,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
spl.TOKEN_PROGRAM_ID,
|
||||
spl.ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
);
|
||||
return tokenAccount.address;
|
||||
};
|
||||
|
||||
let mint = switchboardMint;
|
||||
if (mint) {
|
||||
return getAssociatedAddress(mint);
|
||||
}
|
||||
const [programState] = ProgramStateAccount.fromSeed(program);
|
||||
mint = await programState.getTokenMint();
|
||||
if (mint) {
|
||||
return getAssociatedAddress(mint);
|
||||
}
|
||||
|
||||
throw new Error(`failed to get associated token account`);
|
||||
};
|
||||
|
||||
export async function transferWrappedSol(
|
||||
connection: Connection,
|
||||
payerKeypair: Keypair,
|
||||
amount: number
|
||||
): Promise<number> {
|
||||
const payerBalance = await connection.getBalance(payerKeypair.publicKey);
|
||||
const payerAssociatedWallet = (
|
||||
await spl.getOrCreateAssociatedTokenAccount(
|
||||
connection,
|
||||
payerKeypair,
|
||||
spl.NATIVE_MINT,
|
||||
payerKeypair.publicKey
|
||||
)
|
||||
).address;
|
||||
|
||||
// create new account to temporarily hold wrapped funds
|
||||
const ephemeralAccount = Keypair.generate();
|
||||
const ephemeralWallet = await spl.getAssociatedTokenAddress(
|
||||
spl.NATIVE_MINT,
|
||||
ephemeralAccount.publicKey
|
||||
);
|
||||
|
||||
const tx = new Transaction().add(
|
||||
spl.createAssociatedTokenAccountInstruction(
|
||||
payerKeypair.publicKey,
|
||||
ephemeralWallet,
|
||||
payerKeypair.publicKey,
|
||||
spl.NATIVE_MINT,
|
||||
spl.TOKEN_PROGRAM_ID,
|
||||
spl.ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
),
|
||||
SystemProgram.transfer({
|
||||
fromPubkey: payerKeypair.publicKey,
|
||||
toPubkey: ephemeralWallet,
|
||||
lamports: amount,
|
||||
}),
|
||||
spl.createSyncNativeInstruction(ephemeralWallet, spl.TOKEN_PROGRAM_ID),
|
||||
spl.createTransferInstruction(
|
||||
ephemeralWallet,
|
||||
payerAssociatedWallet,
|
||||
payerKeypair.publicKey,
|
||||
amount,
|
||||
[payerKeypair, ephemeralAccount],
|
||||
spl.TOKEN_PROGRAM_ID
|
||||
),
|
||||
spl.createCloseAccountInstruction(
|
||||
ephemeralWallet,
|
||||
payerKeypair.publicKey,
|
||||
payerKeypair.publicKey,
|
||||
[payerKeypair, ephemeralAccount],
|
||||
spl.TOKEN_PROGRAM_ID
|
||||
)
|
||||
);
|
||||
|
||||
const txn = await sendAndConfirmTransaction(connection, tx, [
|
||||
payerKeypair,
|
||||
ephemeralAccount,
|
||||
]);
|
||||
|
||||
const finalBalance = await spl.getAccount(connection, payerAssociatedWallet);
|
||||
return Number(finalBalance.amount);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import * as anchor from "@project-serum/anchor";
|
||||
import {
|
||||
promiseWithTimeout,
|
||||
sleep,
|
||||
SwitchboardTestContext,
|
||||
} from "@switchboard-xyz/sbv2-utils";
|
||||
import {
|
||||
|
@ -17,11 +18,6 @@ import {
|
|||
} from "../../../target/types/anchor_buffer_parser";
|
||||
import { PROGRAM_ID } from "../client/programId";
|
||||
|
||||
const sleep = (ms: number): Promise<any> =>
|
||||
new Promise((s) => setTimeout(s, ms));
|
||||
|
||||
// Anchor.toml will copy this to localnet when we start our tests
|
||||
|
||||
describe("anchor-buffer-parser test", () => {
|
||||
const provider = anchor.AnchorProvider.env();
|
||||
anchor.setProvider(provider);
|
||||
|
@ -51,7 +47,7 @@ describe("anchor-buffer-parser test", () => {
|
|||
}
|
||||
// If fails, throw error
|
||||
throw new Error(
|
||||
`Failed to load the SwitchboardTestContext from devnet or from a switchboard.env file`
|
||||
`Failed to load the SwitchboardTestContext from a switchboard.env file`
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"paths": {
|
||||
"@switchboard-xyz/switchboard-v2": ["../../libraries/ts"]
|
||||
"@switchboard-xyz/switchboard-v2": ["../../libraries/ts"],
|
||||
"@switchboard-xyz/sbv2-utils": ["../../libraries/sbv2-utils"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
|
@ -15,5 +16,8 @@
|
|||
"client/**/*",
|
||||
"../../target/types/anchor_feed_parser"
|
||||
],
|
||||
"references": [{ "path": "../../libraries/ts" }]
|
||||
"references": [
|
||||
{ "path": "../../libraries/ts" },
|
||||
{ "path": "../../libraries/sbv2-utils" }
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as anchor from "@project-serum/anchor";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { SwitchboardTestContext } from "@switchboard-xyz/sbv2-utils";
|
||||
import { sleep, SwitchboardTestContext } from "@switchboard-xyz/sbv2-utils";
|
||||
import type { AnchorWallet } from "@switchboard-xyz/switchboard-v2";
|
||||
import assert from "assert";
|
||||
import {
|
||||
|
@ -9,9 +9,6 @@ import {
|
|||
} from "../../../target/types/anchor_feed_parser";
|
||||
import { PROGRAM_ID } from "../client/programId";
|
||||
|
||||
const sleep = (ms: number): Promise<any> =>
|
||||
new Promise((s) => setTimeout(s, ms));
|
||||
|
||||
// Anchor.toml will copy this to localnet when we start our tests
|
||||
const DEFAULT_SOL_USD_FEED = new PublicKey(
|
||||
"GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR"
|
||||
|
@ -35,12 +32,14 @@ describe("anchor-feed-parser test", () => {
|
|||
|
||||
let switchboard: SwitchboardTestContext;
|
||||
let aggregatorKey: PublicKey;
|
||||
let localnet = false;
|
||||
|
||||
before(async () => {
|
||||
// First, attempt to load the switchboard devnet PID
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(provider);
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(
|
||||
provider,
|
||||
"F8ce7MsckeZAbAGmxjJNetxYXQa9mKr9nnrC3qKubyYy"
|
||||
);
|
||||
aggregatorKey = DEFAULT_SOL_USD_FEED;
|
||||
console.log("devnet detected");
|
||||
return;
|
||||
|
@ -52,8 +51,7 @@ describe("anchor-feed-parser test", () => {
|
|||
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
||||
const aggregatorAccount = await switchboard.createStaticFeed(100);
|
||||
aggregatorKey = aggregatorAccount.publicKey ?? PublicKey.default;
|
||||
localnet = true;
|
||||
console.log("localnet detected");
|
||||
console.log("local env detected");
|
||||
return;
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"paths": {
|
||||
"@switchboard-xyz/switchboard-v2": ["../../libraries/ts"]
|
||||
"@switchboard-xyz/switchboard-v2": ["../../libraries/ts"],
|
||||
"@switchboard-xyz/sbv2-utils": ["../../libraries/sbv2-utils"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
|
@ -15,5 +16,8 @@
|
|||
"client/**/*",
|
||||
"../../target/types/anchor_feed_parser"
|
||||
],
|
||||
"references": [{ "path": "../../libraries/ts" }]
|
||||
"references": [
|
||||
{ "path": "../../libraries/ts" },
|
||||
{ "path": "../../libraries/sbv2-utils" }
|
||||
]
|
||||
}
|
||||
|
|
|
@ -66,7 +66,10 @@ describe("anchor-vrf-parser test", () => {
|
|||
before(async () => {
|
||||
// First, attempt to load the switchboard devnet PID
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(provider);
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(
|
||||
provider,
|
||||
"F8ce7MsckeZAbAGmxjJNetxYXQa9mKr9nnrC3qKubyYy"
|
||||
);
|
||||
console.log("devnet detected");
|
||||
return;
|
||||
} catch (error: any) {
|
||||
|
|
|
@ -40,12 +40,14 @@ describe("native-feed-parser test", () => {
|
|||
|
||||
let switchboard: SwitchboardTestContext;
|
||||
let aggregatorKey: PublicKey;
|
||||
let localnet = false;
|
||||
|
||||
before(async () => {
|
||||
// First, attempt to load the switchboard devnet PID
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(provider);
|
||||
switchboard = await SwitchboardTestContext.loadDevnetQueue(
|
||||
provider,
|
||||
"F8ce7MsckeZAbAGmxjJNetxYXQa9mKr9nnrC3qKubyYy"
|
||||
);
|
||||
aggregatorKey = DEFAULT_SOL_USD_FEED;
|
||||
console.log("devnet detected");
|
||||
return;
|
||||
|
@ -57,8 +59,7 @@ describe("native-feed-parser test", () => {
|
|||
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
||||
const aggregatorAccount = await switchboard.createStaticFeed(100);
|
||||
aggregatorKey = aggregatorAccount.publicKey ?? PublicKey.default;
|
||||
localnet = true;
|
||||
console.log("localnet detected");
|
||||
console.log("local env detected");
|
||||
return;
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
||||
|
|
|
@ -9,10 +9,14 @@
|
|||
"esModuleInterop": true,
|
||||
"noEmit": true,
|
||||
"paths": {
|
||||
"@switchboard-xyz/switchboard-v2": ["../../libraries/ts"]
|
||||
"@switchboard-xyz/switchboard-v2": ["../../libraries/ts"],
|
||||
"@switchboard-xyz/sbv2-utils": ["../../libraries/sbv2-utils"]
|
||||
}
|
||||
},
|
||||
// "include": ["oldtests/**/**/*"],
|
||||
"exclude": ["target"],
|
||||
"references": [{ "path": "../../libraries/ts" }]
|
||||
"references": [
|
||||
{ "path": "../../libraries/ts" },
|
||||
{ "path": "../../libraries/sbv2-utils" }
|
||||
]
|
||||
}
|
||||
|
|
57
yarn.lock
57
yarn.lock
|
@ -3942,29 +3942,6 @@
|
|||
superstruct "^0.14.2"
|
||||
tweetnacl "^1.0.0"
|
||||
|
||||
"@solana/web3.js@^1.47.3":
|
||||
version "1.48.0"
|
||||
resolved "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.48.0.tgz#331281b2d80640431fb3b6fdc6b704ec325917aa"
|
||||
integrity sha512-Gb6XvdhGjGI7CdAXLmlMIEvEYvrwqc78JOtwCsSrTqzz7Ek/BhJpZ/Cv89gxRDrWxf6kHegAfaN2FxwuYMmDZQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.12.5"
|
||||
"@ethersproject/sha2" "^5.5.0"
|
||||
"@solana/buffer-layout" "^4.0.0"
|
||||
bigint-buffer "^1.1.5"
|
||||
bn.js "^5.0.0"
|
||||
borsh "^0.7.0"
|
||||
bs58 "^4.0.1"
|
||||
buffer "6.0.1"
|
||||
fast-stable-stringify "^1.0.0"
|
||||
jayson "^3.4.4"
|
||||
js-sha3 "^0.8.0"
|
||||
node-fetch "2"
|
||||
react-native-url-polyfill "^1.3.0"
|
||||
rpc-websockets "^7.5.0"
|
||||
secp256k1 "^4.0.2"
|
||||
superstruct "^0.14.2"
|
||||
tweetnacl "^1.0.0"
|
||||
|
||||
"@svgr/babel-plugin-add-jsx-attribute@^5.4.0":
|
||||
version "5.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-5.4.0.tgz#81ef61947bb268eb9d50523446f9c638fb355906"
|
||||
|
@ -13974,13 +13951,6 @@ react-loadable-ssr-addon-v5-slorber@^1.0.1:
|
|||
dependencies:
|
||||
"@babel/runtime" "^7.10.3"
|
||||
|
||||
react-native-url-polyfill@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.npmjs.org/react-native-url-polyfill/-/react-native-url-polyfill-1.3.0.tgz#c1763de0f2a8c22cc3e959b654c8790622b6ef6a"
|
||||
integrity sha512-w9JfSkvpqqlix9UjDvJjm1EjSt652zVQ6iwCIj1cVVkwXf4jQhQgTNXY6EVTwuAmUjg6BC6k9RHCBynoLFo3IQ==
|
||||
dependencies:
|
||||
whatwg-url-without-unicode "8.0.0-3"
|
||||
|
||||
react-player@^2.10.1:
|
||||
version "2.10.1"
|
||||
resolved "https://registry.yarnpkg.com/react-player/-/react-player-2.10.1.tgz#f2ee3ec31393d7042f727737545414b951ffc7e4"
|
||||
|
@ -14657,19 +14627,6 @@ rpc-websockets@^7.4.2:
|
|||
bufferutil "^4.0.1"
|
||||
utf-8-validate "^5.0.2"
|
||||
|
||||
rpc-websockets@^7.5.0:
|
||||
version "7.5.0"
|
||||
resolved "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.5.0.tgz#bbeb87572e66703ff151e50af1658f98098e2748"
|
||||
integrity sha512-9tIRi1uZGy7YmDjErf1Ax3wtqdSSLIlnmL5OtOzgd5eqPKbsPpwDP5whUDO2LQay3Xp0CcHlcNSGzacNRluBaQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.17.2"
|
||||
eventemitter3 "^4.0.7"
|
||||
uuid "^8.3.2"
|
||||
ws "^8.5.0"
|
||||
optionalDependencies:
|
||||
bufferutil "^4.0.1"
|
||||
utf-8-validate "^5.0.2"
|
||||
|
||||
rtl-detect@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.0.4.tgz#40ae0ea7302a150b96bc75af7d749607392ecac6"
|
||||
|
@ -16730,11 +16687,6 @@ webidl-conversions@^3.0.0:
|
|||
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz"
|
||||
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=
|
||||
|
||||
webidl-conversions@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
|
||||
integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==
|
||||
|
||||
webidl-conversions@^6.1.0:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514"
|
||||
|
@ -16868,15 +16820,6 @@ websocket-extensions@>=0.1.1:
|
|||
resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42"
|
||||
integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==
|
||||
|
||||
whatwg-url-without-unicode@8.0.0-3:
|
||||
version "8.0.0-3"
|
||||
resolved "https://registry.npmjs.org/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b"
|
||||
integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig==
|
||||
dependencies:
|
||||
buffer "^5.4.3"
|
||||
punycode "^2.1.1"
|
||||
webidl-conversions "^5.0.0"
|
||||
|
||||
whatwg-url@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz"
|
||||
|
|
Loading…
Reference in New Issue