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

Type mismatch with sol-wallet-adapter and anchor/dist/provider. #71

Open
lieuzhenghong opened this issue Jul 20, 2021 · 3 comments
Open
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@lieuzhenghong
Copy link

Not sure where to put this, but trying to build the example page with sol-wallet-adapter 0.2.5 and anchor 0.11.1 gives a type mismatch.

Argument of type 'import("..../node_modules/@project-serum/sol-wallet-adapter/dist/cjs/index").default' is not assignable to parameter of type 'import(".../node_modules/@project-serum/anchor/dist/provider").Wallet'.
  Types of property 'publicKey' are incompatible.
    Type 'PublicKey | null' is not assignable to type 'PublicKey'.
      Type 'null' is not assignable to type 'PublicKey'.  TS2345

    139 |     onTransaction: (tx: TransactionSignature | undefined, err?: Error) => void
    140 |   ) {
  > 141 |     super(connection, wallet, opts);
        |                       ^
    142 |     this.onTransaction = onTransaction;
    143 |   }
    144 |

I believe this migration to Typescript in sol-wallet-adapter was the one that broke it: here.

We can see the export interface Wallet in anchor/ts/provider.ts still uses PublicKey instead of PublicKey | null here.

@armaniferrante
Copy link
Contributor

Not sure where to put this, but trying to build the example page with sol-wallet-adapter 0.2.5 and anchor 0.11.1 gives a type mismatch.

Argument of type 'import("..../node_modules/@project-serum/sol-wallet-adapter/dist/cjs/index").default' is not assignable to parameter of type 'import(".../node_modules/@project-serum/anchor/dist/provider").Wallet'.
  Types of property 'publicKey' are incompatible.
    Type 'PublicKey | null' is not assignable to type 'PublicKey'.
      Type 'null' is not assignable to type 'PublicKey'.  TS2345

    139 |     onTransaction: (tx: TransactionSignature | undefined, err?: Error) => void
    140 |   ) {
  > 141 |     super(connection, wallet, opts);
        |                       ^
    142 |     this.onTransaction = onTransaction;
    143 |   }
    144 |

I believe this migration to Typescript in sol-wallet-adapter was the one that broke it: here.

We can see the export interface Wallet in anchor/ts/provider.ts still uses PublicKey instead of PublicKey | null here.

As a workaround, you can use // @ts-ignore.

@armaniferrante armaniferrante added good first issue Good for newcomers help wanted Extra attention is needed labels Jul 20, 2021
@thevenice
Copy link

I am Facing the same issue here, any working solutions ?

@TheXienator
Copy link

TheXienator commented Feb 15, 2022

I have the same issue here as well I fixed it by doing:

    const { publicKey, wallet, signTransaction, signAllTransactions } = useWallet();
    if (!wallet || !publicKey || !signTransaction || !signAllTransactions) {
      return;
    }
    const signerWallet = {
      publicKey: publicKey,
      signTransaction: signTransaction,
      signAllTransactions: signAllTransactions,
    };

    const provider = new Provider(connection, signerWallet, {
      preflightCommitment: "recent",
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants