use-ink / contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
https://contracts-ui.substrate.io/
GNU General Public License v3.0
62 stars 47 forks source link

Swapping contract's metadata without having to do forget+reimport #383

Closed h4nsu closed 1 year ago

h4nsu commented 1 year ago

Is your feature request related to a problem? Please describe. Deploying upgradable contract implementing the popular proxy pattern requires having a proxy contract (P) with fallback selector (_) which redirects all calls to target contract (T). Currently this needs to be done by deploying P, setting T's address in P's storage, then forgetting P from Contracts UI and reimporting it using P's address with T's metadata (to be able to call T's methods on P's instance)

Then, when an upgrade of T is needed, one needs to do the same forget+reimport trick twice:

  1. forget contract, import again using P's address and P's metadata, to be able to do the call updating the address used as a proxy target
  2. forget contract, import again using P's address and (updated T)'s metadata

This is not a big issue, just a slight annoyance, but it seems like the solution described below is quick and easy to implement.

Describe the solution you'd like A button in "Metadata" tab on the contract's page which allows uploading new metadata.

Describe alternatives you've considered An alternative would be to have a mechanism that allows to "merge" two pieces of metadata into one, so that the proxy contract's metadata has both calls for updating target address and target's calls. In other words, having something like an "additive contract API composer". Sound like much bigger project though, and still requires doing one forget+reimport trick when updating the target contract.

statictype commented 1 year ago

duplicate of https://github.com/paritytech/contracts-ui/issues/19

statictype commented 1 year ago

@h4nsu I will handle this in https://github.com/paritytech/contracts-ui/pull/393