Skip to content

Update facet-cut-params-generator to handle add and replace selectors dynamically#629

Merged
GitGuru7 merged 2 commits intofeat/vpd-893-bounded-price-oraclefrom
feat/facet-cut-script
Apr 30, 2026
Merged

Update facet-cut-params-generator to handle add and replace selectors dynamically#629
GitGuru7 merged 2 commits intofeat/vpd-893-bounded-price-oraclefrom
feat/facet-cut-script

Conversation

@GitGuru7
Copy link
Copy Markdown
Contributor

Description

This PR updates the facet-cut-params-generator script to improve how diamond cut parameters are generated:

  • The script now fetches the current function selectors from the deployed diamond contract.

  • It generates the final cut-params array, considering both Add and Replace operations dynamically.

  • For IFacetBase selectors:

    • If there are no new selectors, the resulting cut-params JSON can be used directly.
    • If there are new selectors, they need to be manually assigned to the appropriate facet addresses before using the cut-params.

    Note: Now onwards when running the script, please use the --network flag to specify the target network.

const newFacetAddress = newFacetAddresses[facetName];

// Current facet selectors (from diamond, assuming the facet addresses in the same order as newFacetAddresses)
const currentSelectors: string[] = facetName === "FacetBase" ? [] : currentFacets[i].functionSelectors;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if the diamond's facet order differs from FacetNames?


// New facet selectors (from interface)
const newFacetInterface = await ethers.getContractAt(FacetsInterfaces[facetName], newFacetAddress);
const newSelectors: string[] = getSelectors(newFacetInterface);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there any chances that getSelectors could fail?

@GitGuru7 GitGuru7 changed the base branch from feat/VEN-3361 to feat/vpd-893-bounded-price-oracle April 30, 2026 09:21
@GitGuru7 GitGuru7 merged commit a4d345e into feat/vpd-893-bounded-price-oracle Apr 30, 2026
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