Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Mar 10, 2025

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

yarn ts-node scripts/unest_strategy.ts

Still have 19 spaces left, using multichain in nested strategies

@wa0x6e wa0x6e force-pushed the feat-migrate-from-multichain-strategy branch from b20700f to a0d715c Compare March 10, 2025 13:35
@wa0x6e wa0x6e requested a review from Copilot March 10, 2025 13:35
@wa0x6e wa0x6e marked this pull request as ready for review March 10, 2025 13:35
Copy link

@Copilot 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.

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 ?? [])

@wa0x6e wa0x6e force-pushed the feat-migrate-from-multichain-strategy branch from a0d715c to abbc033 Compare March 10, 2025 13:39
@wa0x6e wa0x6e requested a review from ChaituVR March 10, 2025 17:50
@wa0x6e
Copy link
Contributor Author

wa0x6e commented Mar 10, 2025

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', ?)
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Dang, whats the query?

Copy link
Contributor Author

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

Copy link
Member

@ChaituVR ChaituVR Mar 12, 2025

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

Copy link
Contributor Author

@wa0x6e wa0x6e Mar 12, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants