From 78ad376bcdcadef65a27a9155c94d78106e486be Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 23 May 2019 17:18:13 -0600 Subject: [PATCH] fix: Appease flow --- web3.js/src/transaction.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web3.js/src/transaction.js b/web3.js/src/transaction.js index b345cd695d..081ca78ba8 100644 --- a/web3.js/src/transaction.js +++ b/web3.js/src/transaction.js @@ -77,7 +77,7 @@ type SignaturePubkeyPair = {| * */ type TransactionCtorFields = {| - recentBlockhash?: Blockhash, + recentBlockhash?: Blockhash | null, signatures?: Array, |}; @@ -109,7 +109,7 @@ export class Transaction { /** * A recent transaction id. Must be populated by the caller */ - recentBlockhash: ?Blockhash; + recentBlockhash: Blockhash | null; /** * Construct an empty Transaction @@ -122,7 +122,9 @@ export class Transaction { * Add one or more instructions to this Transaction */ add( - ...items: Array + ...items: Array< + Transaction | TransactionInstruction | TransactionInstructionCtorFields, + > ): Transaction { if (items.length === 0) { throw new Error('No instructions'); @@ -131,6 +133,8 @@ export class Transaction { items.forEach(item => { if (item instanceof Transaction) { this.instructions = this.instructions.concat(item.instructions); + } else if (item instanceof TransactionInstruction) { + this.instructions.push(item); } else { this.instructions.push(new TransactionInstruction(item)); }