Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENOENT: no such file or directory #3472

Open
cxp-13 opened this issue Jan 9, 2025 · 5 comments
Open

ENOENT: no such file or directory #3472

cxp-13 opened this issue Jan 9, 2025 · 5 comments

Comments

@cxp-13
Copy link

cxp-13 commented Jan 9, 2025

error log:

Error in anchor framework provider: Error: ENOENT: no such file or directory, open 'my wallet private key'
    at Object.readFileSync (node:fs:443:20)
    at NodeWallet.local (/home/cxp/solana_learn/AI/eliza-starter/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@coral-xyz/anchor/dist/cjs/nodewallet.js:18:101)

relate code:

  static local() {
        const process = require("process");
        if (!process.env.ANCHOR_WALLET || process.env.ANCHOR_WALLET === "") {
            throw new Error("expected environment variable `ANCHOR_WALLET` is not set.");
        }
        const payer = web3_js_1.Keypair.fromSecretKey(buffer_1.Buffer.from(JSON.parse(require("fs").readFileSync(process.env.ANCHOR_WALLET, {
            encoding: "utf-8",
        }))));
        return new NodeWallet(payer);
    }

I want to use anchor client on Eliza ai agent, I don't understand the process.env.ANCHOR_WALLET should fit the file path or secret key.

@cxp-13
Copy link
Author

cxp-13 commented Jan 9, 2025

export class AnchorFrameworkProvider {
  private cache: NodeCache;

  public conn: Connection;
  public nodeWallet: NodeWallet;
  public anchorProvider: AnchorProvider;
  public orbitlenProgram: Program<OrbitLen>;

  constructor(rpcUrl: string, userKeypair: Keypair) {
    anchor.setProvider(this.anchorProvider);

    this.conn = new Connection(rpcUrl);
    // this.nodeWallet = new NodeWallet(userKeypair);
    // this.anchorProvider = new AnchorProvider(this.conn, this.nodeWallet);
    this.anchorProvider = AnchorProvider.local(rpcUrl);
    this.orbitlenProgram = anchor.workspace.OrbitLen as Program<OrbitLen>;

    this.cache = new NodeCache({ stdTTL: 300 }); // Cache TTL set to 5 minutes
  }
}

I wrote a class to manage the object of anchor, where codes cause the problem?

@cxp-13
Copy link
Author

cxp-13 commented Jan 9, 2025

===anchorFrameworkProvider.get===
Error in anchor framework provider: Error: ENOENT: no such file or directory, open 'Anchor.toml'
    at Object.openSync (node:fs:563:18)
    at Object.readFileSync (node:fs:447:35)
    at Object.get (/home/cxp/solana_learn/AI/eliza-starter/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@coral-xyz/anchor/dist/cjs/workspace.js:69:42)

@cxp-13
Copy link
Author

cxp-13 commented Jan 9, 2025

let borrowAmountBN = new anchor.BN(borrowAmount);

why the code get the error

Error in buiding borrow token ix: TypeError: anchor2.BN is not a constructor

@badalya1
Copy link

badalya1 commented Jan 9, 2025

@cxp-13 this is not stack overflow, if you think the library has a problem then make an issue, if not, please post it on stack overflow.

@cxp-13
Copy link
Author

cxp-13 commented Jan 10, 2025

@cxp-13 this is not stack overflow, if you think the library has a problem then make an issue, if not, please post it on stack overflow.

that is an issue, right? I don't got you meaning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants