-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes ABI alias metadata types. (#6494)
## Description Before this push, using an alias in a contract would produce an ABI with two distinct metadata types for tuples: one for `(_,_)` and another for `(u64,u64)`. With this change, aliases are bypassed and we only produce metadata for the string type of the inner alias type. If alias is `(u64, u64)` we will produce a metadatatype for `(_,_)`. Fixes #6488 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: IGI-111 <[email protected]>
- Loading branch information
Showing
8 changed files
with
166 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[[package]] | ||
name = "abi_with_alias" | ||
source = "member" | ||
dependencies = ["core"] | ||
|
||
[[package]] | ||
name = "core" | ||
source = "path+from-root-DE4DCECD674C309C" |
9 changes: 9 additions & 0 deletions
9
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
implicit-std = false | ||
license = "Apache-2.0" | ||
name = "abi_with_alias" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } |
63 changes: 63 additions & 0 deletions
63
...e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"concreteTypes": [ | ||
{ | ||
"concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", | ||
"type": "()" | ||
}, | ||
{ | ||
"concreteTypeId": "41bd1a98f0a59642d8f824c805b798a5f268d1f7d05808eb05c4189c493f1be0", | ||
"metadataTypeId": 0, | ||
"type": "(u64, u64)" | ||
} | ||
], | ||
"configurables": [], | ||
"encodingVersion": "1", | ||
"functions": [ | ||
{ | ||
"attributes": null, | ||
"inputs": [ | ||
{ | ||
"concreteTypeId": "41bd1a98f0a59642d8f824c805b798a5f268d1f7d05808eb05c4189c493f1be0", | ||
"name": "arg1" | ||
} | ||
], | ||
"name": "aliased_tuple", | ||
"output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" | ||
}, | ||
{ | ||
"attributes": null, | ||
"inputs": [ | ||
{ | ||
"concreteTypeId": "41bd1a98f0a59642d8f824c805b798a5f268d1f7d05808eb05c4189c493f1be0", | ||
"name": "_arg1" | ||
} | ||
], | ||
"name": "tuple", | ||
"output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" | ||
} | ||
], | ||
"loggedTypes": [], | ||
"messagesTypes": [], | ||
"metadataTypes": [ | ||
{ | ||
"components": [ | ||
{ | ||
"name": "__tuple_element", | ||
"typeId": 1 | ||
}, | ||
{ | ||
"name": "__tuple_element", | ||
"typeId": 1 | ||
} | ||
], | ||
"metadataTypeId": 0, | ||
"type": "(_, _)" | ||
}, | ||
{ | ||
"metadataTypeId": 1, | ||
"type": "u64" | ||
} | ||
], | ||
"programType": "contract", | ||
"specVersion": "1" | ||
} |
63 changes: 63 additions & 0 deletions
63
...test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle_new_encoding.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"concreteTypes": [ | ||
{ | ||
"concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", | ||
"type": "()" | ||
}, | ||
{ | ||
"concreteTypeId": "41bd1a98f0a59642d8f824c805b798a5f268d1f7d05808eb05c4189c493f1be0", | ||
"metadataTypeId": 0, | ||
"type": "(u64, u64)" | ||
} | ||
], | ||
"configurables": [], | ||
"encodingVersion": "1", | ||
"functions": [ | ||
{ | ||
"attributes": null, | ||
"inputs": [ | ||
{ | ||
"concreteTypeId": "41bd1a98f0a59642d8f824c805b798a5f268d1f7d05808eb05c4189c493f1be0", | ||
"name": "arg1" | ||
} | ||
], | ||
"name": "aliased_tuple", | ||
"output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" | ||
}, | ||
{ | ||
"attributes": null, | ||
"inputs": [ | ||
{ | ||
"concreteTypeId": "41bd1a98f0a59642d8f824c805b798a5f268d1f7d05808eb05c4189c493f1be0", | ||
"name": "_arg1" | ||
} | ||
], | ||
"name": "tuple", | ||
"output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" | ||
} | ||
], | ||
"loggedTypes": [], | ||
"messagesTypes": [], | ||
"metadataTypes": [ | ||
{ | ||
"components": [ | ||
{ | ||
"name": "__tuple_element", | ||
"typeId": 1 | ||
}, | ||
{ | ||
"name": "__tuple_element", | ||
"typeId": 1 | ||
} | ||
], | ||
"metadataTypeId": 0, | ||
"type": "(_, _)" | ||
}, | ||
{ | ||
"metadataTypeId": 1, | ||
"type": "u64" | ||
} | ||
], | ||
"programType": "contract", | ||
"specVersion": "1" | ||
} |
15 changes: 15 additions & 0 deletions
15
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
contract; | ||
|
||
type AliasedTuple = (u64, u64); | ||
|
||
abi MyContract { | ||
fn tuple(arg1: (u64, u64)); // Inline | ||
fn aliased_tuple(arg1: AliasedTuple); // Alias | ||
} | ||
|
||
impl MyContract for Contract { | ||
fn tuple(_arg1: (u64, u64)) { | ||
} | ||
fn aliased_tuple(arg1: AliasedTuple) { | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "compile" | ||
validate_abi = true | ||
expected_warnings = 1 |