diff --git a/sway-core/src/abi_generation/abi_str.rs b/sway-core/src/abi_generation/abi_str.rs index 339a9453f81..2972c9cee0e 100644 --- a/sway-core/src/abi_generation/abi_str.rs +++ b/sway-core/src/abi_generation/abi_str.rs @@ -28,10 +28,12 @@ impl TypeId { &*type_engine.get(resolved_type_id), ) { (TypeInfo::Custom { .. }, TypeInfo::Struct { .. }) - | (TypeInfo::Custom { .. }, TypeInfo::Enum { .. }) - | (TypeInfo::Custom { .. }, TypeInfo::Alias { .. }) => type_engine + | (TypeInfo::Custom { .. }, TypeInfo::Enum { .. }) => type_engine .get(resolved_type_id) .abi_str(ctx, engines, true), + (_, TypeInfo::Alias { ty, .. }) => { + ty.type_id.get_abi_type_str(ctx, engines, ty.type_id) + } (TypeInfo::Tuple(fields), TypeInfo::Tuple(resolved_fields)) => { assert_eq!(fields.len(), resolved_fields.len()); let field_strs = resolved_fields diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/main_args/main_args_generics/json_abi_oracle_new_encoding.json b/test/src/e2e_vm_tests/test_programs/should_pass/language/main_args/main_args_generics/json_abi_oracle_new_encoding.json index 6d485af4964..64d80ab9878 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/main_args/main_args_generics/json_abi_oracle_new_encoding.json +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/main_args/main_args_generics/json_abi_oracle_new_encoding.json @@ -52,7 +52,7 @@ } ], "metadataTypeId": 0, - "type": "(struct TwoGenerics, struct OneGeneric)" + "type": "(_, _)" }, { "metadataTypeId": 1, diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.lock b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.lock new file mode 100644 index 00000000000..e85a8258d1c --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.lock @@ -0,0 +1,8 @@ +[[package]] +name = "abi_with_alias" +source = "member" +dependencies = ["core"] + +[[package]] +name = "core" +source = "path+from-root-DE4DCECD674C309C" diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.toml new file mode 100644 index 00000000000..402ce909bea --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/Forc.toml @@ -0,0 +1,9 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +implicit-std = false +license = "Apache-2.0" +name = "abi_with_alias" + +[dependencies] +core = { path = "../../../../../../../sway-lib-core" } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle.json new file mode 100644 index 00000000000..acc54cf39b3 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle.json @@ -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" +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle_new_encoding.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle_new_encoding.json new file mode 100644 index 00000000000..acc54cf39b3 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/json_abi_oracle_new_encoding.json @@ -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" +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/src/main.sw new file mode 100644 index 00000000000..c75439d8e82 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/src/main.sw @@ -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) { + } +} diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/test.toml new file mode 100644 index 00000000000..2bad8b530a0 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_alias/test.toml @@ -0,0 +1,3 @@ +category = "compile" +validate_abi = true +expected_warnings = 1