Skip to content
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

feat: Add attributes to ABIFunction #744

Merged
merged 7 commits into from
Dec 16, 2022

Conversation

anton-trunov
Copy link
Contributor

@anton-trunov anton-trunov commented Dec 15, 2022

This is needed for FuelLabs/sway#3450 and for #742 eventually.

Spec issue: FuelLabs/fuel-specs#446
Compiler change: FuelLabs/sway#3450

Correction: the explanation below is only true at the parser level, the distinction between foo and foo() disappears later in the pipeline, so I changed the type of arguments field to Vec<String>.

The Option<Vec<String>> in

pub struct Attribute {
     pub name: String,
     pub arguments: Option<Vec<String>>,
 }

is needed because in Sway a parameterless attribute foo and an attribute with empty parameter list foo() are not the same.

@anton-trunov anton-trunov force-pushed the anton-trunov/function-attributes branch from 5510d2f to 9f2ac17 Compare December 15, 2022 11:22
@segfault-magnet
Copy link
Contributor

segfault-magnet commented Dec 15, 2022

This seems to be a breaking change. The CI is complaining:

SerdeJson(Error("missing field attributes", line: 43, column: 5))

I haven't checked more closely but it seems that the way we're adding this is breaking backward compatibility -- i.e. we won't be able to release until the compiler starts providing the attribute field. Do you have an ETA this?

If it's too long we should probably look into guiding serde to default-populate the field if it is not present in the json file and still remain backward compatible.

Also, unless deserialization is altered, you'll probably need a feature flag in forc so that it may generate the appropriate json files with the attributes present, otherwise the CI can't generate the abi json files needed for our e2e tests.

@anton-trunov
Copy link
Contributor Author

@segfault-magnet I made the function attributes optional -- it turns out to be too hard to introduce a breaking change like an obligatory field because of close coupling of the Sway and Fuels-rs repos.

Copy link
Contributor

@iqdecay iqdecay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@anton-trunov anton-trunov merged commit 28026e2 into master Dec 16, 2022
@anton-trunov anton-trunov deleted the anton-trunov/function-attributes branch December 16, 2022 06:26
iqdecay pushed a commit that referenced this pull request Dec 26, 2022
This is needed for FuelLabs/sway#3450 and for
#742 eventually.

Spec issue: FuelLabs/fuel-specs#446
Compiler change: FuelLabs/sway#3450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants