Skip to content

Commit

Permalink
feat: add dataSlice param to account fetching config (#28389)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Oct 14, 2022
1 parent f627b7d commit 36e5f33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions web3.js/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ export type GetAccountInfoConfig = {
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
/** Optional data slice to limit the returned account data */
dataSlice?: DataSlice;
};

/**
Expand Down Expand Up @@ -2396,6 +2398,8 @@ export type GetMultipleAccountsConfig = {
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
/** Optional data slice to limit the returned account data */
dataSlice?: DataSlice;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion web3.js/test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4505,8 +4505,9 @@ describe('Connection', function () {
const transferToKey = lookupTableAddresses[0];
const transferToAccount = await connection.getAccountInfo(
transferToKey,
'confirmed',
{commitment: 'confirmed', dataSlice: {length: 0, offset: 0}},
);
expect(transferToAccount?.data.length).to.be.eq(0);
expect(transferToAccount?.lamports).to.be.eq(LAMPORTS_PER_SOL);
});

Expand Down

0 comments on commit 36e5f33

Please sign in to comment.