fix: add type def for NonceAccount.fromAccountData
This commit is contained in:
parent
02a278b3b2
commit
a112d9cedf
|
@ -285,6 +285,9 @@ declare module '@solana/web3.js' {
|
|||
authorizedPubkey: PublicKey;
|
||||
nonce: Blockhash;
|
||||
feeCalculator: FeeCalculator;
|
||||
static fromAccountData(
|
||||
buffer: Buffer | Uint8Array | Array<number>,
|
||||
): NonceAccount;
|
||||
}
|
||||
|
||||
export const NONCE_ACCOUNT_LENGTH: number;
|
||||
|
|
|
@ -298,6 +298,9 @@ declare module '@solana/web3.js' {
|
|||
authorizedPubkey: PublicKey;
|
||||
nonce: Blockhash;
|
||||
feeCalculator: FeeCalculator;
|
||||
static fromAccountData(
|
||||
buffer: Buffer | Uint8Array | Array<number>,
|
||||
): NonceAccount;
|
||||
}
|
||||
|
||||
declare export var NONCE_ACCOUNT_LENGTH: number;
|
||||
|
|
|
@ -6,6 +6,7 @@ import * as Layout from './layout';
|
|||
import {PublicKey} from './publickey';
|
||||
import type {FeeCalculator} from './fee-calculator';
|
||||
import {FeeCalculatorLayout} from './fee-calculator';
|
||||
import {toBuffer} from './util/to-buffer';
|
||||
|
||||
/**
|
||||
* See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32
|
||||
|
@ -36,8 +37,10 @@ export class NonceAccount {
|
|||
* @param buffer account data
|
||||
* @return NonceAccount
|
||||
*/
|
||||
static fromAccountData(buffer: Buffer): NonceAccount {
|
||||
const nonceAccount = NonceAccountLayout.decode(buffer, 0);
|
||||
static fromAccountData(
|
||||
buffer: Buffer | Uint8Array | Array<number>,
|
||||
): NonceAccount {
|
||||
const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
|
||||
nonceAccount.authorizedPubkey = new PublicKey(
|
||||
nonceAccount.authorizedPubkey,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue