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

Cannot construct Wallet #1397

Closed
acheroncrypto opened this issue Feb 5, 2022 · 3 comments
Closed

Cannot construct Wallet #1397

acheroncrypto opened this issue Feb 5, 2022 · 3 comments

Comments

@acheroncrypto
Copy link
Collaborator

import { web3, Wallet } from "@project-serum/anchor";

const wallet = new Wallet(web3.Keypair.generate());

The error I get is: This expression is not constructable. Type 'NodeWallet' has no construct signatures.

"@project-serum/anchor": "^0.20.1"

@fanatid
Copy link
Contributor

fanatid commented Feb 5, 2022

Try this:

const { Wallet } = require("@project-serum/anchor");
const wallet = new Wallet(web3.Keypair.generate());

@acheroncrypto
Copy link
Collaborator Author

Thank you, it used to work on previous versions of anchor. Is there an important reason why require works but import doesn't? Or is it one of those weird JS things?

@acheroncrypto
Copy link
Collaborator Author

#1363 fixes this backwards compatibility issue but packages haven't been updated yet.

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