-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal to initialize the contract on demand #1388
Comments
Some downsides of this are
Just a few alternatives for brainstorming purposes:
|
@ascjones Any updates on that matter? |
Not yet, this won't make it into the upcoming In the meantime you could investigate an approach similar to that outlined in |
Hi, are there any updates on this issue? |
Not yet, unfortunately. It may be something that @xgreenx will be able to pick up soon. |
With the introduction of
delegate_call
, we can have situations when one contractX
uses another contractY
as a blueprint. The blueprint may have totally another storage layout. Then theX
do the firstdelegate_call
toY
,Y
can't load the contract's storage from theX
's storage because it is not initialized(Y
's constructor was not called).It creates a situation when we need support initializing the storage during the execution of the
#[ink(message)]
. The user can always wrap his storage into another structure and implement theStorable
trait for this struct that supports initialization on demand. But we can add native support of it into the ink!.The proposal is to introduce the
OnCallInitialize
trait.If the contract implements
Default
andOnCallInitialize
traits, the ink! will try to load the contract from the storage, and in the case of fail, it will initialize it.This idea was implemented in #1331. But we decided to discuss it separately because it is an important API change. After implementation "initialization on demand" we need to return back
delegate-call
example, removed in the mentioned PR.The text was updated successfully, but these errors were encountered: