orca-so / orca-sdks

Open-sourced typescript SDKs for Orca
MIT License
43 stars 10 forks source link

Introduce AccountFetcher to common-sdk #45

Closed odcheung closed 1 year ago

odcheung commented 1 year ago

Verification

odcheung commented 1 year ago

Thanks @yugure-orca.

I've made the following amendments:

I think the ability to fetch multiple types at once is a reasonable responsibility for this class. Of course, since this class depends on the account-request utilities layer, that layer would have to support it as well. Can you elaborate more on the "some accounts may be updated more recently"? I'd imagine if only accounts that exceeds the maxAge will be filtered, fetched and updated. We'll reconstruct the result purely based off of cached values just like we do for getAccounts / getAccountsAsArray today.

Also, I think given this PR is more for porting and no new feature depends on the get multiple types in 1 request just yet, I think that new feature should be left in a separate PR. what do you think?

odcheung commented 1 year ago

gotcha. Yeah that edge case would be an issue even for the current getAccounts calls. I'll leave a comment in the code.

An efficient solution is also not exactly clear if we must enforce all gMA calls to be returned on a consistent slot. But the good thing is this use-case isn't present (yet) for the UI, so we still have some time to figure it out.