From 3e13cde988489791c547e2ad7ae58698ff7b3e9b Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Wed, 2 Jun 2021 12:39:59 -0700 Subject: [PATCH] fix: allow messages to be compiled without instructions (#17621) * fix: allow messages to be compiled without instructions * chore: fix tests --- web3.js/src/transaction.ts | 2 +- web3.js/test/transaction.test.ts | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/web3.js/src/transaction.ts b/web3.js/src/transaction.ts index 972227ce0..1a91cb5bc 100644 --- a/web3.js/src/transaction.ts +++ b/web3.js/src/transaction.ts @@ -214,7 +214,7 @@ export class Transaction { } if (this.instructions.length < 1) { - throw new Error('No instructions provided'); + console.warn('No instructions provided'); } let feePayer: PublicKey; diff --git a/web3.js/test/transaction.test.ts b/web3.js/test/transaction.test.ts index c1e0a2501..35f484eff 100644 --- a/web3.js/test/transaction.test.ts +++ b/web3.js/test/transaction.test.ts @@ -65,9 +65,7 @@ describe('Transaction', () => { it('validation', () => { const payer = Keypair.generate(); - const other = Keypair.generate(); const recentBlockhash = Keypair.generate().publicKey.toBase58(); - const programId = Keypair.generate().publicKey; const transaction = new Transaction(); expect(() => { @@ -76,18 +74,6 @@ describe('Transaction', () => { transaction.recentBlockhash = recentBlockhash; - expect(() => { - transaction.compileMessage(); - }).to.throw('No instructions provided'); - - transaction.add({ - keys: [ - {pubkey: other.publicKey, isSigner: true, isWritable: true}, - {pubkey: payer.publicKey, isSigner: true, isWritable: true}, - ], - programId, - }); - expect(() => { transaction.compileMessage(); }).to.throw('Transaction fee payer required');