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

Comments

refactor: use getScoresDirect to get scores in getVp#1771

Merged
wa0x6e merged 3 commits intofix-remove-delegation-from-getvpfrom
refactor-use-score-direct-from-getvp
Jul 3, 2025
Merged

refactor: use getScoresDirect to get scores in getVp#1771
wa0x6e merged 3 commits intofix-remove-delegation-from-getvpfrom
refactor-use-score-direct-from-getvp

Conversation

@wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Jul 2, 2025

Continuing on #1770


Since the delegation support dropping from getVp, the core logic to get scores from strategies is the same as getScoresDirect

This PR refactors getVp to re-use getScoresDirect as much as possible to retrieve score, and avoid duplication.

Changes

  • re-use getScoresDirect to get score
  • move getVp to utils.ts (file is becoming too small to warrant its own file)
  • move vp.test.ts to integration/utils.test.ts
  • since getScoresDirect do not validate the addresses, we lose this feature also on getVp (temporary)

The next PR will focus on adding back the address validation to getScoresDirect

@wa0x6e wa0x6e requested a review from Copilot July 2, 2025 16:29
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 refactors the getVp function to use the existing getScoresDirect helper, removes the old standalone implementation, and updates tests and snapshots accordingly.

  • Remove legacy getVp in src/utils/vp.ts and replace it with a new implementation in src/utils.ts using getScoresDirect.
  • Update import paths and test descriptions in integration tests.
  • Adjust snapshots to match the revised describe block naming.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/integration/utils.test.ts Changed import to the new getVp location and updated test title
test/integration/snapshots/utils.test.ts.snap Renamed snapshot key to match the updated describe block
src/utils/vp.ts Removed legacy getVp implementation
src/utils.ts Added new getVp implementation, updated imports and types
Comments suppressed due to low confidence (2)

src/utils.ts:88

  • The function getProvider is used here but not imported in this file, which will cause a reference error. Please add an import, for example:
import { getProvider } from './utils';
    getProvider(network),

src/utils.ts:77

  • [nitpick] The parameter name snapshot shadows the imported snapshot module from @snapshot-labs/snapshot.js. Consider renaming the parameter (e.g., to snapshotTag) to avoid confusion.
export async function getVp(

Copy link
Member

@bonustrack bonustrack left a comment

Choose a reason for hiding this comment

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

utACK

@wa0x6e wa0x6e changed the title Refactor-use-score-direct-from-getvp refactor: use `` Jul 2, 2025
@wa0x6e wa0x6e changed the title refactor: use `` refactor: use getScoresDirect to get scores in getVp Jul 2, 2025
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

* fix: add address validation to getvp

* fix: add addresses validations when getting scores

* perf:

---------

Co-authored-by: Chaitanya <yourchaitu@gmail.com>
@wa0x6e wa0x6e merged commit d65c52c into fix-remove-delegation-from-getvp Jul 3, 2025
8 checks passed
@wa0x6e wa0x6e deleted the refactor-use-score-direct-from-getvp branch July 3, 2025 12:42
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.

3 participants