Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add compute units to jsonrpc parser #27554

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions web3.js/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ export type ParsedTransactionMeta = {
err: TransactionError | null;
/** The collection of addresses loaded using address lookup tables */
loadedAddresses?: LoadedAddresses;
/** The compute units consumed after processing the transaction */
computeUnitsConsumed?: number;
};

export type CompiledInnerInstruction = {
Expand Down Expand Up @@ -917,6 +919,8 @@ export type ConfirmedTransactionMeta = {
err: TransactionError | null;
/** The collection of addresses loaded using address lookup tables */
loadedAddresses?: LoadedAddresses;
/** The compute units consumed after processing the transaction */
computeUnitsConsumed?: number;
};

/**
Expand Down Expand Up @@ -1993,6 +1997,7 @@ const ConfirmedTransactionMetaResult = pick({
preTokenBalances: optional(nullable(array(TokenBalanceResult))),
postTokenBalances: optional(nullable(array(TokenBalanceResult))),
loadedAddresses: optional(LoadedAddressesResult),
computeUnitsConsumed: optional(number()),
});

/**
Expand All @@ -2017,6 +2022,7 @@ const ParsedConfirmedTransactionMetaResult = pick({
preTokenBalances: optional(nullable(array(TokenBalanceResult))),
postTokenBalances: optional(nullable(array(TokenBalanceResult))),
loadedAddresses: optional(LoadedAddressesResult),
computeUnitsConsumed: optional(number()),
});

const TransactionVersionStruct = union([literal(0), literal('legacy')]);
Expand Down
4 changes: 4 additions & 0 deletions web3.js/test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4460,6 +4460,8 @@ describe('Connection', function () {
readonly: [],
writable: [lookupTableAddresses[0]],
});
expect(fetchedTransaction.meta?.computeUnitsConsumed).to.not.be
.undefined;
expect(
fetchedTransaction.transaction.message.addressTableLookups,
).to.eql(addressTableLookups);
Expand Down Expand Up @@ -4489,6 +4491,8 @@ describe('Connection', function () {
readonly: [],
writable: [lookupTableAddresses[0]],
});
expect(parsedTransaction?.meta?.computeUnitsConsumed).to.not.be
.undefined;
expect(
parsedTransaction?.transaction.message.addressTableLookups,
).to.eql(addressTableLookups);
Expand Down