Skip to content

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

Description

@Merrick17

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions