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

Comments

feat: filter out addresses not supported by strategies and validation#1738

Merged
wa0x6e merged 18 commits intomasterfrom
feat-add-selective-support-for-evm-and-starknet-addresses
Jun 23, 2025
Merged

feat: filter out addresses not supported by strategies and validation#1738
wa0x6e merged 18 commits intomasterfrom
feat-add-selective-support-for-evm-and-starknet-addresses

Conversation

@wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented May 28, 2025

Toward https://github.com/snapshot-labs/workflow/issues/562

This PR adds a new property to the strategy and validation object, to define the list of protocols supported (evm and/or starknet).

It will default to ['evm'] by default, for backward compatibility with existing strategies.

Address not supported will be filtered out before processing the strategy/validation

Note

@wa0x6e wa0x6e requested a review from Copilot May 28, 2025 14:00
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

Introduce protocol-aware address filtering and validation to ensure strategies and validators only process supported address types.

  • Add supportedProtocols and a validateAddressType method to the Validation class and invoke it in existing validators.
  • Implement getFormattedAddressesByProtocol in core utils and apply it to normalize addresses according to each strategy’s supported protocols.
  • Define DEFAULT_SUPPORTED_PROTOCOLS (['evm']) and propagate default protocol support in validations and strategies indexes.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/validations/validation.ts Add supportedProtocols property and validateAddressType
src/validations/index.ts Fallback to DEFAULT_SUPPORTED_PROTOCOLS for validators
src/utils.ts Introduce getFormattedAddressesByProtocol helper
src/utils/vp.ts Apply protocol-based formatting in VP calculations
src/strategies/index.ts Fallback to DEFAULT_SUPPORTED_PROTOCOLS for strategies
src/index.ts Define DEFAULT_SUPPORTED_PROTOCOLS
Comments suppressed due to low confidence (2)

src/validations/index.ts:64

  • Using || will treat an empty array as truthy, causing validators without explicit protocols to end up with an empty list. Consider checking length or using nullish coalescing (??) so that fallback applies when supportedProtocols is empty or undefined.
supportedProtocols: validationInstance.supportedProtocols || DEFAULT_SUPPORTED_PROTOCOLS

src/validations/validation.ts:36

  • The new validateAddressType method introduces protocol-specific validation logic but has no unit tests. Adding targeted tests will help prevent regressions when address‐formatting rules change.
validateAddressType(): boolean {

@wa0x6e wa0x6e changed the title feat: fliter out addresses not supported by strategies and validation feat: filter out addresses not supported by strategies and validation May 28, 2025
@wa0x6e wa0x6e marked this pull request as draft May 28, 2025 14:20
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
@wa0x6e wa0x6e force-pushed the feat-add-selective-support-for-evm-and-starknet-addresses branch from d0c05a0 to bae8ddc Compare May 28, 2025 15:58
@wa0x6e wa0x6e requested a review from Copilot May 28, 2025 15:58

This comment was marked as outdated.

@wa0x6e wa0x6e marked this pull request as ready for review June 4, 2025 10:35
@wa0x6e wa0x6e requested a review from Copilot June 12, 2025 21:34

This comment was marked as outdated.

@wa0x6e wa0x6e requested a review from Copilot June 12, 2025 22:20
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 introduces protocol filtering for strategies and validations by adding a new property to specify supported protocols, ensuring that addresses unsupported by the chosen protocols are filtered out before processing. Key changes include updating validations and strategies to use the new supportedProtocols property, refactoring snapshot types to use the unified Snapshot type, and adding utility functions for protocol-based address formatting.

Reviewed Changes

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

Show a summary per file
File Description
test/strategy-with-params.test.ts Cast snapshot to Snapshot type for more explicit typing.
src/validations/* Update validation classes with supportedProtocols and refactor validate methods.
src/utils/* Replace direct getAddress calls with protocol-based address formatting.
src/types.ts Add new type definitions including Protocol and Snapshot.
src/strategies/* Add supportedProtocols property and update snapshot type usage.
package.json Update test scripts to run unit tests.
Comments suppressed due to low confidence (1)

src/utils/vp.ts:85

  • The use of 'i' in strategies[i].supportedProtocols is unclear because no index variable 'i' is defined in this context. Consider using the already provided iteration variable (e.g. 'strategy') to reference the supportedProtocols property.
addresses = getFormattedAddressesByProtocol(addresses, strategies[i].supportedProtocols)

@ChaituVR ChaituVR self-requested a review June 17, 2025 16:38
@ChaituVR
Copy link
Member

@wa0x6e any idea why build fail?

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jun 17, 2025

@wa0x6e any idea why build fail?

it's depending on a snapshot.js pr

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jun 18, 2025

Tests are now passing thanks to the dependency update

ChaituVR and others added 2 commits June 20, 2025 22:30
Co-authored-by: Chaitanya <yourchaitu@gmail.com>
@wa0x6e wa0x6e force-pushed the feat-add-selective-support-for-evm-and-starknet-addresses branch from 6e23e55 to 574839e Compare June 20, 2025 17:40
@wa0x6e wa0x6e requested a review from ChaituVR June 20, 2025 17:47
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.

Everything else looks good

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jun 21, 2025

I've also added unit test run on CI.

Seems to fail on a sha256 import, I have the same issue on local. Not sure what's wrong with export from utils ...

wa0x6e and others added 2 commits June 21, 2025 21:20
Added sha256, customFetch, and getFormattedAddressesByProtocol to the default export object to ensure consistency between named exports and default export.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

looking good, just the test case is failing

@ChaituVR
Copy link
Member

Tests pass now

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.

utAck

@wa0x6e wa0x6e merged commit 3837ea1 into master Jun 23, 2025
8 checks passed
@wa0x6e wa0x6e deleted the feat-add-selective-support-for-evm-and-starknet-addresses branch June 23, 2025 11:56
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