You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a follow up for #1446 which added support for fallible constructors with with a custom error type: Result<Self, T>. Please note that constructors are still allowed to return only Self in case of them being infallible.
Current behaviour
The data returned by a constructor is not mentioned in the metadata. All constructors return nothing according to metadata. This was fine before #1446 because they never wrote anything into the output buffer. However, now the Err will be written to the output buffer but only when an error is returned (nothing is written on Ok).
Changes Needed
The fact that constructors write data into the output buffer needs to be mentioned in metadata. It is necessary for callers so that they can decode the output buffer. Any constructor returning Result<Self, T> should have the following return type in metadata Result<(), T>. Self is replaced by () because ink! constructors do not return any data from successful constructors.
Encode Ok(()) into the output buffer in case of a successful construction. This is redundant information but it is necessary to make the constructor behave as advertised in the metadata. This will allow us to emit data from a constructor in the future while being backwards compatible.
Infallible constructors ( -> Self) will continue do not return anything. So they don't have a return type in metadata and never copy anything to the output buffer.
This is a follow up for #1446 which added support for fallible constructors with with a custom error type:
Result<Self, T>
. Please note that constructors are still allowed to return onlySelf
in case of them being infallible.Current behaviour
The data returned by a constructor is not mentioned in the metadata. All constructors return nothing according to metadata. This was fine before #1446 because they never wrote anything into the output buffer. However, now the
Err
will be written to the output buffer but only when an error is returned (nothing is written onOk
).Changes Needed
Result<Self, T>
should have the following return type in metadataResult<(), T>
.Self
is replaced by()
because ink! constructors do not return any data from successful constructors.Ok(())
into the output buffer in case of a successful construction. This is redundant information but it is necessary to make the constructor behave as advertised in the metadata. This will allow us to emit data from a constructor in the future while being backwards compatible.Infallible constructors (
-> Self
) will continue do not return anything. So they don't have a return type in metadata and never copy anything to the output buffer.cc @SkymanOne @xermicus @HCastano
The text was updated successfully, but these errors were encountered: