From e42a39024d07a8101ac4806849e370910362e6e6 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Fri, 9 Sep 2022 17:06:54 -0400 Subject: [PATCH] feat: add source field to parsed account key responses (#27702) --- web3.js/src/connection.ts | 5 +++++ web3.js/test/connection.test.ts | 26 ++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index 5789b27f24..d92ba1545e 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -1029,6 +1029,8 @@ export type ParsedMessageAccount = { signer: boolean; /** Indicates if the account is writable for this transaction */ writable: boolean; + /** Indicates if the account key came from the transaction or a lookup table */ + source?: 'transaction' | 'lookupTable'; }; /** @@ -1966,6 +1968,9 @@ const ParsedConfirmedTransactionResult = pick({ pubkey: PublicKeyFromString, signer: boolean(), writable: boolean(), + source: optional( + union([literal('transaction'), literal('lookupTable')]), + ), }), ), instructions: array(ParsedOrRawInstruction), diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts index c36798b25f..a5f8724a2c 100644 --- a/web3.js/test/connection.test.ts +++ b/web3.js/test/connection.test.ts @@ -4564,15 +4564,33 @@ describe('Connection', function () { ); expect(parsedTransaction).to.not.be.null; expect(parsedTransaction?.version).to.eq(0); - expect(parsedTransaction?.meta?.loadedAddresses).to.eql({ - readonly: [], - writable: [lookupTableAddresses[0]], - }); + // loaded addresses are not returned for parsed transactions + expect(parsedTransaction?.meta?.loadedAddresses).to.be.undefined; expect(parsedTransaction?.meta?.computeUnitsConsumed).to.not.be .undefined; expect( parsedTransaction?.transaction.message.addressTableLookups, ).to.eql(addressTableLookups); + expect(parsedTransaction?.transaction.message.accountKeys).to.eql([ + { + pubkey: payer.publicKey, + signer: true, + writable: true, + source: 'transaction', + }, + { + pubkey: SystemProgram.programId, + signer: false, + writable: false, + source: 'transaction', + }, + { + pubkey: lookupTableAddresses[0], + signer: false, + writable: true, + source: 'lookupTable', + }, + ]); }); it('getBlock (failure)', async () => {