feat: add Keypair class and deprecate Account (#17098)

* feat: add Keypair class and deprecate Account

* chore: fix lint issues

* chore: rename TransactionSigner to Signer
This commit is contained in:
Justin Starry
2021-05-07 16:59:51 +08:00
committed by GitHub
parent 0b5167bf51
commit f43f0afa55
20 changed files with 339 additions and 213 deletions

View File

@ -4,7 +4,7 @@ import {privateKeyVerify, ecdsaSign, publicKeyCreate} from 'secp256k1';
import {
Connection,
Account,
Keypair,
sendAndConfirmTransaction,
LAMPORTS_PER_SOL,
Transaction,
@ -15,7 +15,7 @@ import {url} from './url';
const randomPrivateKey = () => {
let privateKey;
do {
privateKey = new Account().secretKey.slice(0, 32);
privateKey = Keypair.generate().secretKey.slice(0, 32);
} while (!privateKeyVerify(privateKey));
return privateKey;
};
@ -25,7 +25,7 @@ if (process.env.TEST_LIVE) {
const privateKey = randomPrivateKey();
const publicKey = publicKeyCreate(privateKey, false).slice(1);
const ethAddress = Secp256k1Program.publicKeyToEthAddress(publicKey);
const from = new Account();
const from = Keypair.generate();
const connection = new Connection(url, 'confirmed');
before(async function () {