Skip to content

Conversation

GitGuru7
Copy link
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
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
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?

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