Conversation
There was a problem hiding this comment.
Pull Request Overview
Introduce protocol-aware address filtering and validation to ensure strategies and validators only process supported address types.
- Add
supportedProtocolsand avalidateAddressTypemethod to the Validation class and invoke it in existing validators. - Implement
getFormattedAddressesByProtocolin 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 checkinglengthor using nullish coalescing (??) so that fallback applies whensupportedProtocolsis empty or undefined.
supportedProtocols: validationInstance.supportedProtocols || DEFAULT_SUPPORTED_PROTOCOLS
src/validations/validation.ts:36
- The new
validateAddressTypemethod introduces protocol-specific validation logic but has no unit tests. Adding targeted tests will help prevent regressions when address‐formatting rules change.
validateAddressType(): boolean {
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
d0c05a0 to
bae8ddc
Compare
There was a problem hiding this comment.
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)
|
@wa0x6e any idea why build fail? |
it's depending on a snapshot.js pr |
|
Tests are now passing thanks to the dependency update |
Co-authored-by: Chaitanya <yourchaitu@gmail.com>
6e23e55 to
574839e
Compare
|
I've also added unit test run on CI. Seems to fail on a |
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>
ChaituVR
left a comment
There was a problem hiding this comment.
looking good, just the test case is failing
|
Tests pass now |
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 (
evmand/orstarknet).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