sol-wallet-adapter icon indicating copy to clipboard operation
sol-wallet-adapter copied to clipboard

Working example with Anchor SDK

Open callensm opened this issue 3 years ago • 3 comments

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

callensm avatar Aug 26 '21 15:08 callensm

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.

armaniferrante avatar Aug 26 '21 16:08 armaniferrante

@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.

callensm avatar Aug 26 '21 16:08 callensm