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

TypeError: Cannot read properties of undefined (reading 'address') #22

Open
Merrick17 opened this issue Jan 18, 2022 · 1 comment
Open

Comments

@Merrick17
Copy link

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);
}`

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
@Merrick17 and others