fix: add type def for NonceAccount.fromAccountData
This commit is contained in:
committed by
Michael Vines
parent
02a278b3b2
commit
a112d9cedf
3
web3.js/module.d.ts
vendored
3
web3.js/module.d.ts
vendored
@ -285,6 +285,9 @@ declare module '@solana/web3.js' {
|
|||||||
authorizedPubkey: PublicKey;
|
authorizedPubkey: PublicKey;
|
||||||
nonce: Blockhash;
|
nonce: Blockhash;
|
||||||
feeCalculator: FeeCalculator;
|
feeCalculator: FeeCalculator;
|
||||||
|
static fromAccountData(
|
||||||
|
buffer: Buffer | Uint8Array | Array<number>,
|
||||||
|
): NonceAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NONCE_ACCOUNT_LENGTH: number;
|
export const NONCE_ACCOUNT_LENGTH: number;
|
||||||
|
@ -298,6 +298,9 @@ declare module '@solana/web3.js' {
|
|||||||
authorizedPubkey: PublicKey;
|
authorizedPubkey: PublicKey;
|
||||||
nonce: Blockhash;
|
nonce: Blockhash;
|
||||||
feeCalculator: FeeCalculator;
|
feeCalculator: FeeCalculator;
|
||||||
|
static fromAccountData(
|
||||||
|
buffer: Buffer | Uint8Array | Array<number>,
|
||||||
|
): NonceAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare export var NONCE_ACCOUNT_LENGTH: number;
|
declare export var NONCE_ACCOUNT_LENGTH: number;
|
||||||
|
@ -6,6 +6,7 @@ import * as Layout from './layout';
|
|||||||
import {PublicKey} from './publickey';
|
import {PublicKey} from './publickey';
|
||||||
import type {FeeCalculator} from './fee-calculator';
|
import type {FeeCalculator} from './fee-calculator';
|
||||||
import {FeeCalculatorLayout} 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
|
* 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
|
* @param buffer account data
|
||||||
* @return NonceAccount
|
* @return NonceAccount
|
||||||
*/
|
*/
|
||||||
static fromAccountData(buffer: Buffer): NonceAccount {
|
static fromAccountData(
|
||||||
const nonceAccount = NonceAccountLayout.decode(buffer, 0);
|
buffer: Buffer | Uint8Array | Array<number>,
|
||||||
|
): NonceAccount {
|
||||||
|
const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);
|
||||||
nonceAccount.authorizedPubkey = new PublicKey(
|
nonceAccount.authorizedPubkey = new PublicKey(
|
||||||
nonceAccount.authorizedPubkey,
|
nonceAccount.authorizedPubkey,
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user