From 935d520ec9bad2ef86b02106d465043f12dc3095 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 28 Sep 2018 22:51:52 -0700 Subject: [PATCH] refactor: AccountInfo userdata is now never null --- web3.js/module.flow.js | 2 +- web3.js/src/connection.js | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 4685f12d68..921c002653 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -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'; diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index 14338ba1b4..fd4bef99eb 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -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), }; }