hardhat-ignition icon indicating copy to clipboard operation
hardhat-ignition copied to clipboard

Support for Diamond-like contract patterns

Open alcuadrado opened this issue 5 months ago • 1 comments

Describe the feature

Some contracts use a pattern similar to an upgradeable proxy, but where the implementation doesn't exist in a single contract but in multiple contracts instead. One of the reasons for doing this is to avoid the contract size limit.

The most well-known pattern that does this is the Diamond pattern, but there are systems with their implementation of something similar (e.g., The Graph and Synthetix).

You can now deploy such a system with Ignition, but you can't express a contractAt that combines all the different implementations.

I think this snippet illustrates the problem:

const proxy = m.contract('DiamondLikeProxy');
const implementation1 = m.contract('Implementation1');
const implementation2 = m.contract('Implementation2');

// Somehow set the implementations

const proxyWithCombinedAbi = m.contractAt(?????, proxy) // Which contract name do we use?

As a workaround, you can do multiple contractAts, depending on how you need to interact with the contact, but that's really inconvenient.

Search terms

modules, diamond, proxy

alcuadrado avatar Sep 23 '24 22:09 alcuadrado