fix: update NonceAccount to upstream changes
This commit is contained in:
committed by
Michael Vines
parent
3b55087a86
commit
890e21c451
@@ -1,4 +1,12 @@
|
||||
// @flow
|
||||
import * as BufferLayout from 'buffer-layout';
|
||||
|
||||
/**
|
||||
* https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
export const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');
|
||||
|
||||
/**
|
||||
* @typedef {Object} FeeCalculator
|
||||
|
@@ -4,6 +4,8 @@ import * as BufferLayout from 'buffer-layout';
|
||||
import type {Blockhash} from './blockhash';
|
||||
import * as Layout from './layout';
|
||||
import {PublicKey} from './publickey';
|
||||
import type {FeeCalculator} from './fee-calculator';
|
||||
import {FeeCalculatorLayout} from './fee-calculator';
|
||||
|
||||
/**
|
||||
* See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
|
||||
@@ -11,17 +13,22 @@ import {PublicKey} from './publickey';
|
||||
* @private
|
||||
*/
|
||||
const NonceAccountLayout = BufferLayout.struct([
|
||||
BufferLayout.u32('version'),
|
||||
BufferLayout.u32('state'),
|
||||
Layout.publicKey('authorizedPubkey'),
|
||||
Layout.publicKey('nonce'),
|
||||
BufferLayout.struct([FeeCalculatorLayout], 'feeCalculator'),
|
||||
]);
|
||||
|
||||
export const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
|
||||
|
||||
/**
|
||||
* NonceAccount class
|
||||
*/
|
||||
export class NonceAccount {
|
||||
authorizedPubkey: PublicKey;
|
||||
nonce: Blockhash;
|
||||
feeCalculator: FeeCalculator;
|
||||
|
||||
/**
|
||||
* Deserialize NonceAccount from the account data.
|
||||
|
@@ -4,6 +4,7 @@ import * as BufferLayout from 'buffer-layout';
|
||||
|
||||
import {encodeData, decodeData} from './instruction';
|
||||
import * as Layout from './layout';
|
||||
import {NONCE_ACCOUNT_LENGTH} from './nonce-account';
|
||||
import {PublicKey} from './publickey';
|
||||
import {SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY} from './sysvar';
|
||||
import {Transaction, TransactionInstruction} from './transaction';
|
||||
@@ -437,13 +438,6 @@ export class SystemProgram {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Max space of a Nonce account
|
||||
*/
|
||||
static get nonceSpace(): number {
|
||||
return 68;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a Transaction that creates a new account
|
||||
*/
|
||||
@@ -530,7 +524,7 @@ export class SystemProgram {
|
||||
fromPubkey: params.fromPubkey,
|
||||
newAccountPubkey: params.noncePubkey,
|
||||
lamports: params.lamports,
|
||||
space: this.nonceSpace,
|
||||
space: NONCE_ACCOUNT_LENGTH,
|
||||
programId: this.programId,
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user