refactor: AccountInfo userdata is now never null

This commit is contained in:
Michael Vines 2018-09-28 22:51:52 -07:00
parent 0cc621887b
commit 935d520ec9
2 changed files with 3 additions and 7 deletions

View File

@ -27,7 +27,7 @@ declare module '@solana/web3.js' {
declare export type AccountInfo = {
tokens: number,
programId: PublicKey,
userdata: Buffer | null,
userdata: Buffer,
}
declare export type SignatureStatus = 'Confirmed' | 'SignatureNotFound' | 'ProgramRuntimeError' | 'GenericFailure';

View File

@ -140,7 +140,7 @@ const SendTokensRpcResult = jsonRpcResult('string');
type AccountInfo = {
tokens: number,
programId: PublicKey,
userdata: Buffer | null,
userdata: Buffer,
}
/**
@ -200,14 +200,10 @@ export class Connection {
const {result} = res;
assert(typeof result !== 'undefined');
let userdata = null;
if (result.userdata.length > 0) {
userdata = Buffer.from(result.userdata);
}
return {
tokens: result.tokens,
programId: bs58.encode(result.program_id),
userdata,
userdata: Buffer.from(result.userdata),
};
}