paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

contracts: Simplify `instantiate_with_code` logic #14494

Closed athei closed 1 year ago

athei commented 1 year ago

Right now, we implement some optimizations when a code is uploaded and instantiation at the same time. That adds a lot of complexity to our code. The right move would be to only support instantiate and upload_code and let users use batch_all if they want to bundle them. It would massively simplify our code.

That said, we can't remove the instantiate_with_code dispatchable for backwards compatibility. But we can refactor it to just emulate batch_all by doing upload_code and instantiate back to back in a storage transaction.