Skip to content

Make the return type of AccountClient.fetchMultiple consistent#2390

Merged
Henry-E merged 2 commits intosolana-foundation:masterfrom
quellen-sol:fix-fetch-multiple-type
Feb 7, 2023
Merged

Make the return type of AccountClient.fetchMultiple consistent#2390
Henry-E merged 2 commits intosolana-foundation:masterfrom
quellen-sol:fix-fetch-multiple-type

Conversation

@quellen-sol
Copy link
Copy Markdown
Contributor

@quellen-sol quellen-sol commented Feb 6, 2023

fetchMultiple currently returns (Object | null)[], but it should return the account type similarly to fetch and fetchNullable, which would be (T | null)[]

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 6, 2023

@quellen-sol is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@quellen-sol quellen-sol force-pushed the fix-fetch-multiple-type branch from 58d67cb to b11f259 Compare February 6, 2023 23:18
@quellen-sol quellen-sol marked this pull request as ready for review February 6, 2023 23:20
@Henry-E
Copy link
Copy Markdown
Collaborator

Henry-E commented Feb 7, 2023

Makes sense to me, fixes an inconsistency between the return types. Unless there was some reason for the difference of return types between fetch and fetchMultiple in the first place? Though it doesn't seem likely.

Probably will merge soon

@quellen-sol
Copy link
Copy Markdown
Contributor Author

quellen-sol commented Feb 7, 2023

Makes sense to me, fixes an inconsistency between the return types. Unless there was some reason for the difference of return types between fetch and fetchMultiple in the first place? Though it doesn't seem likely.

Probably will merge soon

Was curious about this too, so I looked back in the history a bit and saw that when fetchMultiple was created in #761, T was equal to any at the time, hence no explicit typing on the return type
https://github.com/glacial-engineering/anchor/blob/2bd4bb349abde32b25ceef8c1a0833206109cb1e/ts/src/program/namespace/account.ts#L71

When more typing to AccountClient was introduced afterward, it appears that fetchMultiple was most likely just overlooked and not changed.
https://github.com/coral-xyz/anchor/pull/795/files#diff-0e2c48e520eafaabcd0d9de371c7d2e74f5bbb4eba766216bb24efb265c0e5c3R82

Also one thing to note: This resolves #1580 and #1521 can be closed

May also resolve #1465

@Henry-E
Copy link
Copy Markdown
Collaborator

Henry-E commented Feb 7, 2023

Thanks very much for looking into that.

I can see almost the exact same PR was made here #1521 .

@Henry-E Henry-E merged commit 37cc99c into solana-foundation:master Feb 7, 2023
@quellen-sol quellen-sol deleted the fix-fetch-multiple-type branch February 7, 2023 21:53
Otter-0x4ka5h pushed a commit to Otter-0x4ka5h/anchor that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants