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

refactoring gauges data fetch calls #851

Merged
merged 3 commits into from
Sep 2, 2024
Merged

refactoring gauges data fetch calls #851

merged 3 commits into from
Sep 2, 2024

Conversation

gmbronco
Copy link
Collaborator

@gmbronco gmbronco commented Aug 26, 2024

closes #835

Copy link

changeset-bot bot commented Aug 26, 2024

🦋 Changeset detected

Latest commit: d5ad7b2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
backend Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gmbronco gmbronco marked this pull request as ready for review August 27, 2024 13:09
const result = results[index];
const cap = result.status === 'success' ? result.result : undefined;
if (!cap) {
// Too many know errors to log
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does that mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to explain what was already mentioned in the the function doc. getRelativeWeightCap isn't widely supported, so most of the calls with fail and we don't need to log that, because it's expected. I'll just remove the comment.

const types = gaugeAddresses.map((address, index) => {
const result = results[index];
const type = result.status === 'success' ? result.result : undefined;
if (!address) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should check for type instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, corrected

const weigths = gaugeAddresses.map((address, index) => {
const result = results[index];
const weight = result.status === 'success' ? result.result : undefined;
if (!address) {
Copy link
Collaborator

@franzns franzns Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should check for weight instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the logic to allowFailure: false

if (!address) {
console.error(`Failed to fetch gauge address at index ${index}`);
}
return [address, Number(formatEther(weight as bigint))] as [string, number];
Copy link
Collaborator

@franzns franzns Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess this throws when weight is undefined

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the logic to allowFailure: false

if (!address) {
console.error(`Failed to fetch gauge type for ${address}`);
}
return [address, typeNames[Number(type)]] as [string, string];
Copy link
Collaborator

@franzns franzns Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this throws when type is undefined

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the logic to allowFailure: false

if (result === undefined) {
console.error(`Failed to fetch isKilled for ${address}`);
}
return [address, result as boolean];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this set to if result is undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the logic to allowFailure: false

Copy link
Collaborator

@franzns franzns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer!

@franzns franzns merged commit 420ff5f into v3-canary Sep 2, 2024
1 check passed
@franzns franzns deleted the refactor-gauges branch September 2, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Querying veBalVotingGauges fails with chainId header
2 participants