0

I'm working on a Solana project using Anchor, and I'm encountering two issues when trying to run a test with ts-mocha.

  1. TypeError: The first error message I'm getting is:

    TypeError: Expected the input to be string | string[] at camelCase (/root/solana/solana-signer-auth/node_modules/camelcase/index.js:34:9) at /root/solana/solana-signer-auth/node_modules/@project-serum/anchor/src/workspace.ts:57:33 at Array.forEach (<anonymous>) at Object.get (/root/solana/solana-signer-auth/node_modules/@project-serum/anchor/src/workspace.ts:52:10) at Suite.<anonymous> (/root/solana/solana-signer-auth/tests/signer-authorization.ts:11:6)

  2. IDL Constraint Issue: Additionally, I’m seeing another error related to the IDL constraint:

    Type 'SignerAuthorization' does not satisfy the constraint 'Idl'. Type 'SignerAuthorization' is missing the following properties from type 'Idl': version, name

Here’s what my SignerAuthorization type looks like:

`(alias) type SignerAuthorization = { address: "BDBPunrccQsC62PsST1iTXVVrFzkrB8hdpWPvTpiNzpy"; metadata: {
name: "signerAuthorization";
version: "0.1.0";
spec: "0.1.0";
description: "Created with Anchor"; }; instructions: [...]; }`

Here's the relevant part of my test code:

 import * as anchor from "@project-serum/anchor"; 
 import { Program } from "@project-serum/anchor";
 import { SignerAuthorization } from "../target/types/signer_authorization";
 import { findProgramAddressSync } from "@project-serum/anchor/dist/cjs/utils/pubkey";
 import { expect } from "chai";

 describe("signer-authorization", () => {
   anchor.setProvider(anchor.AnchorProvider.env());

 const program = anchor.workspace
.SignerAuthorization as Program<SignerAuthorization>;

 const connection = anchor.getProvider().connection;
 const wallet = anchor.workspace.SignerAuthorization.provider.wallet;
 const walletFake = anchor.web3.Keypair.generate();
 const tokenAccount = anchor.web3.Keypair.generate();

 const [vaultPDA] = findProgramAddressSync(
 [Buffer.from("vault")],
 program.programId
 );

 let mint: anchor.web3.PublicKey;
 // ...rest of the test code
 });

I suspect the issues might be related to how I’m trying to access the SignerAuthorization program IDL or the way camelCase is being used internally by Anchor?

The IDL file for SignerAuthorization exists in the target/types directory. I've tried downgrading to previous versions of Anchor (0.29.0) as suggested by some posts online, but the issue persists. Has anyone encountered similar issues, or does anyone know how to resolve these errors?

1
  • Did you find a solution to this?
    – SQRCAT
    Commented Oct 16 at 21:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.