-
Notifications
You must be signed in to change notification settings - Fork 137
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
Allow removing type declarations from contracts #3210
Allow removing type declarations from contracts #3210
Comments
Not breaking, does not make sense to do this post C1.0 migration, |
Implementing Suggestion 1 would unblock staging of the FiatToken contract, which is now a blocker for Crescendo launch. Increasing priority to urgent. |
@dsainati1 Could you please document this? Both in the language reference, as well as a short update to the forum post https://forum.flow.com/t/update-on-cadence-1-0/5197 |
Issue to be solved
Currently, the contract update validator prevents removing type declarations from a contract, to prevent it from getting re-added with a different structure. However, it would be useful to have a way to remove type definitions and force users of those contracts to start using a new type instead. This could be even more useful with cadence 1.0.
Suggested Solution
Suggestion I:
One possible solution is to introduce a pragma to tombstone a type definition. e.g:
#removedType(T)
.One can remove a type and add this pragma to indicate that this type was removed. It will prevent re-adding a new type with the same name in future. The pragma itself is not removable once it is aded.
Cons:
Suggestion II:
Alternatively, it is possible to provide a way to remove and replace a type with another, particularly during the Cadence 1.0 upgrades. e.g:
#replacedType(T, R)
, whereR
is the new type to replace with. Similar to the suggestedremovedType
pragma, this will prevent any re-additions of a new type with the same name.T
would be replaced with typeR
, including static types of values, conformances, etc.This would be only supported if
T
andR
satisfy particular conditions, such as:T
andR
has to be of the same kind. i.e: both are resources / both are resource-interfaces / etc.R
should have at-most the set of fields as the old typeT
. It's ok to have less number of fields, but no any additional fields. The filed names and types of the fields should be the same. (This is similar to the existing field update restrictions during contract updates).The text was updated successfully, but these errors were encountered: