This repository was archived by the owner on Aug 22, 2025. It is now read-only.
fix: add validations to getVp and getScoresDirect#1772
Merged
wa0x6e merged 4 commits intorefactor-use-score-direct-from-getvpfrom Jul 3, 2025
Merged
fix: add validations to getVp and getScoresDirect#1772wa0x6e merged 4 commits intorefactor-use-score-direct-from-getvpfrom
getVp and getScoresDirect#1772wa0x6e merged 4 commits intorefactor-use-score-direct-from-getvpfrom
Conversation
getVp and getScoresDirect
getVp and getScoresDirectgetVp and getScoresDirect
5b050ff to
a9c81c8
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR restores address validations in getVp, refines getScoresDirect to only send relevant addresses to each strategy based on supported protocols, and enforces an error when getVp is called with an empty strategy list.
- Replaced the old
getFormattedAddressesByProtocoland protocol‐validation logic withdetectProtocol,categorizeAddressesByProtocol, andfilterAddressesForStrategy. - Introduced
validateStrategiesin bothgetScoresDirectandgetVp, and throw an error on empty strategy arrays. - Updated integration tests, fixtures, and snapshots to cover new validation behaviors and error messages.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/utils.test.ts | Remove outdated tests for getFormattedAddressesByProtocol. |
| test/integration/validation/basic.test.ts | Adjust expected error message from singular to plural “Invalid strategies”. |
| test/integration/utils.test.ts | Expand integration tests for getVp covering invalid addresses and strategy errors. |
| test/integration/fixtures/vp-fixtures.ts | Add fixture definitions for network, addresses, and strategy sets. |
| test/integration/snapshots/utils.test.ts.snap | Update snapshot keys and contents to match new test descriptions. |
| src/utils.ts | Remove old protocol‐formatting export; add new protocol detection, categorization, strategy filtering, and validations. |
Comments suppressed due to low confidence (2)
src/utils.ts:58
- Consider adding a direct unit or integration test for
getScoresDirectwhenaddressesis empty to verify it returns an array of empty score objects as intended.
if (addresses.length === 0) return strategies.map(() => ({}));
src/utils.ts:148
- [nitpick] It would improve maintainability to add a JSDoc comment above
categorizeAddressesByProtocoldescribing its parameters, return shape, and error cases (e.g. invalid address format).
function categorizeAddressesByProtocol(
…ess-validations-to-get-vp
ChaituVR
reviewed
Jul 3, 2025
ChaituVR
reviewed
Jul 3, 2025
wa0x6e
added a commit
that referenced
this pull request
Jul 3, 2025
* refactor: use getScoresDirect to fech getVp score * fix: add validations to `getVp` and `getScoresDirect` (#1772) * fix: add address validation to getvp * fix: add addresses validations when getting scores * perf: --------- Co-authored-by: Chaitanya <yourchaitu@gmail.com> --------- Co-authored-by: Chaitanya <yourchaitu@gmail.com>
wa0x6e
added a commit
that referenced
this pull request
Jul 3, 2025
* fix: remove delegation support from getVp * refactor: use `getScoresDirect` to get scores in `getVp` (#1771) * refactor: use getScoresDirect to fech getVp score * fix: add validations to `getVp` and `getScoresDirect` (#1772) * fix: add address validation to getvp * fix: add addresses validations when getting scores * perf: --------- Co-authored-by: Chaitanya <yourchaitu@gmail.com> --------- Co-authored-by: Chaitanya <yourchaitu@gmail.com> * fix: add back optional parameter for backward compatibility --------- Co-authored-by: Chaitanya <yourchaitu@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continuing on #1771
This PR:
getVpgetVp(it allows empty ongetScoresDirect