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

The delegationsAndRewards handler crashes on an empty response #125

Closed
vsubhuman opened this issue Sep 24, 2021 · 0 comments
Closed

The delegationsAndRewards handler crashes on an empty response #125

vsubhuman opened this issue Sep 24, 2021 · 0 comments
Assignees
Labels
bug Something isn't working client/TypeScript Issues which regard the TypeScript client

Comments

@vsubhuman
Copy link

vsubhuman commented Sep 24, 2021

What Git revision are you using?

4416988

What operating system are you using, and which version?

Unrelated

Describe what the problem is?

The delegationsAndRewards query in the client assumes at least one entry must be in the response by calling this function:

const isDelegationsAndRewardsByAccounts = (result: Ogmios['QueryResponse[delegationsAndRewards]']['result']): result is DelegationsAndRewardsByAccounts => {
const sample = Object.entries(result as DelegationsAndRewards)[0]
return typeof sample[0] === 'string' && (sample[1].delegate !== undefined || sample[1].rewards !== undefined)

In case if the requested address has no rewards and has no delegation - the response is an empty object. In this case the entry variable in the function is undefined and then the call entry[0] fails with an exception.

What should be the expected behavior?

Expecting that it will return the empty response object with no entry for that address, or insert an empty entry, idk.

Workaround

Working around that by just doing the query manually atm and doing the handling on our side.

@KtorZ KtorZ added bug Something isn't working client/TypeScript Issues which regard the TypeScript client labels Sep 24, 2021
@KtorZ KtorZ self-assigned this Sep 25, 2021
@KtorZ KtorZ closed this as completed in bc8b844 Sep 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working client/TypeScript Issues which regard the TypeScript client
Projects
None yet
Development

No branches or pull requests

2 participants