Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Comments

fix: add validations to getVp and getScoresDirect#1772

Merged
wa0x6e merged 4 commits intorefactor-use-score-direct-from-getvpfrom
fix-add-address-validations-to-get-vp
Jul 3, 2025
Merged

fix: add validations to getVp and getScoresDirect#1772
wa0x6e merged 4 commits intorefactor-use-score-direct-from-getvpfrom
fix-add-address-validations-to-get-vp

Conversation

@wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Jul 2, 2025

Continuing on #1771

This PR:

  • adds back the address validation to getVp
  • send only relevant addresses to strategies, depending on supported protocols
  • throws an error on empty strategies in getVp (it allows empty on getScoresDirect

@wa0x6e wa0x6e marked this pull request as draft July 2, 2025 17:08
@wa0x6e wa0x6e requested a review from Copilot July 2, 2025 17:08
@wa0x6e wa0x6e changed the title Fix-add-address-validations-to-get-vp fix: add addresses validation to getVp and getScoresDirect Jul 2, 2025

This comment was marked as outdated.

@wa0x6e wa0x6e changed the title fix: add addresses validation to getVp and getScoresDirect fix: add validations to getVp and getScoresDirect Jul 2, 2025
@wa0x6e wa0x6e force-pushed the fix-add-address-validations-to-get-vp branch from 5b050ff to a9c81c8 Compare July 2, 2025 21:25
@wa0x6e wa0x6e marked this pull request as ready for review July 2, 2025 21:31
@wa0x6e wa0x6e requested a review from Copilot July 2, 2025 21:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 getFormattedAddressesByProtocol and protocol‐validation logic with detectProtocol, categorizeAddressesByProtocol, and filterAddressesForStrategy.
  • Introduced validateStrategies in both getScoresDirect and getVp, 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 getScoresDirect when addresses is 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 categorizeAddressesByProtocol describing its parameters, return shape, and error cases (e.g. invalid address format).
function categorizeAddressesByProtocol(

@wa0x6e wa0x6e requested review from ChaituVR and bonustrack July 2, 2025 21:35
@wa0x6e wa0x6e requested a review from ChaituVR July 3, 2025 12:22
Copy link
Member

@ChaituVR ChaituVR left a comment

Choose a reason for hiding this comment

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

tAck

@wa0x6e wa0x6e merged commit a0ef444 into refactor-use-score-direct-from-getvp Jul 3, 2025
10 checks passed
@wa0x6e wa0x6e deleted the fix-add-address-validations-to-get-vp branch July 3, 2025 12:40
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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants