-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add script to un-nest strategies #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b20700f
to
a0d715c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR adds a new script to un-nest nested strategies from a top-level multichain configuration, moving them one level up and cleaning up the nested entry.
- Added a script (unest_strategy.ts) that queries the database for spaces with nested multichain strategies
- Processes the space settings and updates them accordingly
Reviewed Changes
File | Description |
---|---|
scripts/unest_strategy.ts | New script to move nested strategies to the root of the settings |
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
scripts/unest_strategy.ts:9
- The SQL query uses JSON_CONTAINS with the JSON path '$.strategies[*].name' which may not capture all nested strategies if the JSON structure is more complex. Consider confirming that this path matches all cases of nested strategies as expected.
SELECT settings->'$.strategies[*].name', id, settings
scripts/unest_strategy.ts:26
- Ensure that 'strategy.params.strategies' is always an array to avoid potential runtime errors if the data structure changes. Adding explicit type validation or logging unexpected structures could help catch such issues early.
...(strategy.params?.strategies ?? [])
a0d715c
to
abbc033
Compare
DO NOT MERGE UNTIL RELEASE DAY |
const spaces = await db.queryAsync( | ||
`SELECT settings->'$.strategies[*].name', id, settings | ||
FROM spaces | ||
WHERE JSON_CONTAINS(settings->'$.strategies[*].name', ?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if someone is using multichain inside delegation related strategies, you know the query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we have around 20 spaces using it in innes strategies. This PR will only target top level strategies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang, whats the query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, they are the leftover after running the script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You see any multichain
inside multichain
? I mean multichain
left overs after running the script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's inside other strategies, like Math
Toward https://github.com/snapshot-labs/workflow/issues/227
Add script to move nested strategies one level up.
This will move strategies inside top level multichain to the root, and delete them.
Run the script with
Still have 19 spaces left, using multichain in nested strategies