-
Notifications
You must be signed in to change notification settings - Fork 226
Open
Description
Whenever I run anchor --skip-local-validator
I get this the following error:
TypeError: Cannot read properties of null (reading 'account')
at node_modules/@switchboard-xyz/on-demand/src/accounts/queue.ts:798:60
at Array.map (<anonymous>)
at Queue.<anonymous> (node_modules/@switchboard-xyz/on-demand/src/accounts/queue.ts:798:8)
at fulfilled (node_modules/@switchboard-xyz/on-demand/dist/cjs/accounts/queue.js:38:58)
Relevant test snippet code
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import * as sb from "@switchboard-xyz/on-demand";
import { TokenLottery } from "../target/types/token_lottery";
import SwitchboardIDL from "./switchboard.json";
describe("Lottery", () => {
const provider = anchor.AnchorProvider.env();
const wallet = provider.wallet as anchor.Wallet;
anchor.setProvider(provider);
const program = anchor.workspace.TokenLottery as Program<TokenLottery>;
const switchboardProgram = new anchor.Program(
SwitchboardIDL as anchor.Idl,
provider,
);
const rngKp = anchor.web3.Keypair.generate();
it("should test token lottery", async () => {
await buyTicket();
const queue = new anchor.web3.PublicKey(
"A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w",
);
const queueAccount = new sb.Queue(switchboardProgram, queue);
try {
await queueAccount.loadData();
} catch (err) {
console.log("Error", err);
process.exit(1);
}
const [randomness, createRandomnessIx] = await sb.Randomness.create(
switchboardProgram,
rngKp,
queue,
);
const createRandomnessTx = await sb.asV0Tx({
connection: provider.connection,
ixs: [createRandomnessIx],
payer: wallet.publicKey,
signers: [wallet.payer, rngKp],
});
const createRandomnessSignature = await provider.connection.sendTransaction(
createRandomnessTx,
);
console.log("Create Randomness Signature: ", createRandomnessSignature);
const sbCommitIx = await randomness.commitIx(queue);
const commitIx = await program.methods
.commitRandomness()
.accounts({
randomnessAccount: randomness.pubkey,
})
.instruction();
const commitComputeIx =
anchor.web3.ComputeBudgetProgram.setComputeUnitLimit({
units: 100_000,
});
const commitPriorityIx =
anchor.web3.ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 1,
});
const commitBlockhashWithContext =
await provider.connection.getLatestBlockhash();
const commitTx = new anchor.web3.Transaction({
feePayer: provider.wallet.publicKey,
blockhash: commitBlockhashWithContext.blockhash,
lastValidBlockHeight: commitBlockhashWithContext.lastValidBlockHeight,
})
.add(commitComputeIx)
.add(commitPriorityIx)
.add(sbCommitIx)
.add(commitIx);
const commitSignature = await anchor.web3.sendAndConfirmTransaction(
provider.connection,
commitTx,
[wallet.payer],
);
console.log("Commit Signature: ", commitSignature);
}, 3000000);
});
I am on the following dependencies for switchboard:
- Cargo package: switchboard-on-demand = "0.3.5"
- NPM package: "@switchboard-xyz/on-demand": "^1.2.66",
Metadata
Metadata
Assignees
Labels
No labels