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

@@ -3,11 +3,11 @@ import {Buffer} from 'buffer';
import {expect} from 'chai';
import {
Account,
Connection,
SystemProgram,
Transaction,
PublicKey,
Keypair,
} from '../src';
import {NONCE_ACCOUNT_LENGTH} from '../src/nonce-account';
import {MOCK_PORT, url} from './url';
@@ -19,7 +19,7 @@ const expectedData = (authorizedPubkey: PublicKey): [string, string] => {
expectedData.writeInt32LE(0, 0); // Version, 4 bytes
expectedData.writeInt32LE(1, 4); // State, 4 bytes
authorizedPubkey.toBuffer().copy(expectedData, 8); // authorizedPubkey, 32 bytes
const mockNonce = new Account();
const mockNonce = Keypair.generate();
mockNonce.publicKey.toBuffer().copy(expectedData, 40); // Hash, 32 bytes
expectedData.writeUInt16LE(5000, 72); // feeCalculator, 8 bytes
return [expectedData.toString('base64'), 'base64'];
@@ -45,8 +45,8 @@ describe('Nonce', () => {
}
it('create and query nonce account', async () => {
const from = new Account();
const nonceAccount = new Account();
const from = Keypair.generate();
const nonceAccount = Keypair.generate();
await mockRpcResponse({
method: 'getMinimumBalanceForRentExemption',
@@ -109,7 +109,7 @@ describe('Nonce', () => {
});
it('create and query nonce account with seed', async () => {
const from = new Account();
const from = Keypair.generate();
const seed = 'seed';
const noncePubkey = await PublicKey.createWithSeed(
from.publicKey,