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

Make the return type of AccountClient.fetchMultiple consistent #2390

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

quellen-sol
Copy link
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

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 marked this pull request as ready for review February 6, 2023 23:20
@Henry-E
Copy link

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
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

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 coral-xyz:master Feb 7, 2023
@quellen-sol quellen-sol deleted the fix-fetch-multiple-type branch February 7, 2023 21:53
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