Skip to content

Commit

Permalink
feat: add source field to parsed account key responses (#27702)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Sep 9, 2022
1 parent c876761 commit 08b0a20
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};

/**
Expand Down Expand Up @@ -1966,6 +1968,9 @@ const ParsedConfirmedTransactionResult = pick({
pubkey: PublicKeyFromString,
signer: boolean(),
writable: boolean(),
source: optional(
union([literal('transaction'), literal('lookupTable')]),
),
}),
),
instructions: array(ParsedOrRawInstruction),
Expand Down
26 changes: 22 additions & 4 deletions test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 08b0a20

Please sign in to comment.