Hello i used the the secret key to recover the keyPair and generate a wallet , when triying i get this error ,
TypeError: Cannot read properties of undefined (reading 'address')
this is my Wallet Class :
`import { Buffer } from "buffer";
import { Keypair, PublicKey, Transaction } from "@solana/web3.js";
get publicKey(): PublicKey {
return this.payer.publicKey;
}
}
`
and this is the implementation of my client
`import { Provider, BN } from "@project-serum/anchor";
import { Connection, PublicKey, Transaction, Keypair } from "@solana/web3.js";
import { TokenListProvider } from "@solana/spl-token-registry";
import { Swap } from "@project-serum/swap";
const DECIMALS = 6;
import Wallet from "../types/Wallet";
async function swapClient(wallet: Wallet) {
const provider = new Provider(
new Connection("https://api.mainnet-beta.solana.com", "recent"),
wallet,
Provider.defaultOptions()
);
const tokenList = await new TokenListProvider().resolve();
return new Swap(provider, tokenList);
}`
Hello i used the the secret key to recover the keyPair and generate a wallet , when triying i get this error , TypeError: Cannot read properties of undefined (reading 'address') this is my Wallet Class : `import { Buffer } from "buffer"; import { Keypair, PublicKey, Transaction } from "@solana/web3.js";
export default class Wallet { private payer: Keypair; constructor(payer: Keypair) { this.payer = payer; }
async signTransaction(tx: Transaction): Promise {
tx.partialSign(this.payer);
return tx;
}
async signAllTransactions(txs: Transaction[]): Promise<Transaction[]> { return txs.map((t) => { t.partialSign(this.payer); return t; }); }
get publicKey(): PublicKey { return this.payer.publicKey; } } `
and this is the implementation of my client `import { Provider, BN } from "@project-serum/anchor"; import { Connection, PublicKey, Transaction, Keypair } from "@solana/web3.js"; import { TokenListProvider } from "@solana/spl-token-registry"; import { Swap } from "@project-serum/swap";
const DECIMALS = 6; import Wallet from "../types/Wallet";
async function swapClient(wallet: Wallet) { const provider = new Provider( new Connection("https://api.mainnet-beta.solana.com", "recent"), wallet, Provider.defaultOptions() ); const tokenList = await new TokenListProvider().resolve(); return new Swap(provider, tokenList); }`