project-serum / sol-wallet-adapter

Other
185 stars 93 forks source link

Working example with Anchor SDK #43

Open callensm opened 2 years ago

callensm commented 2 years ago

Are there any working examples of integrating the @project-serum/anchor library with this adapter or with the @solana/wallet-adapter components?

There seems to be a misalignment in the type definitions for the interface of a wallet adapter/provider and can't get them to work together properly.

image

armaniferrante commented 2 years ago

Are there any working examples of integrating the @project-serum/anchor library with this adapter or with the @solana/wallet-adapter components?

There seems to be a misalignment in the type definitions for the interface of a wallet adapter/provider and can't get them to work together properly.

image

I think this issue is in the wrong repo :).

But the anchor wallet has the following interface

export interface Wallet {
  signTransaction(tx: Transaction): Promise<Transaction>;
  signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
  publicKey: PublicKey;
}

So you can just make a new class that implements it and wraps your adapter. An adapter for the adapter.

callensm commented 2 years ago

@armaniferrante but the @solana/wallet-adapter package includes classes that do the exact same thing, there's just a tiny typing conflict between them but aim to accomplish the same thing.

I'm trying to avoid writing my own adapter implementations for the wallet we want to support and use the ones that the Solana Labs team has already built and bundled with their library.