wallet-connect-web-examples/wallets/react-wallet-v2/src/lib/Solana.ts

20 lines
401 B
TypeScript

import { Keypair } from '@solana/web3.js'
export class Solana {
keypair: Keypair
constructor(keypair: Keypair) {
this.keypair = keypair
}
static init(secretKey?: Uint8Array) {
const keypair = secretKey ? Keypair.fromSecretKey(secretKey) : Keypair.generate()
return new Solana(keypair)
}
public async getAccount() {
return await this.keypair.publicKey.toBase58()
}
}