diff --git a/sway-core/src/type_engine/type_id.rs b/sway-core/src/type_engine/type_id.rs index a19fc2fd7b6..0333eb140ee 100644 --- a/sway-core/src/type_engine/type_id.rs +++ b/sway-core/src/type_engine/type_id.rs @@ -67,7 +67,9 @@ impl ToJsonAbi for TypeId { name: "__array_element".to_string(), type_field: type_id.json_abi_str(), components: type_id.generate_json_abi(), - type_arguments: None, + type_arguments: type_id + .get_type_parameters() + .map(|v| v.iter().map(TypeParameter::generate_json_abi).collect()), }]), TypeInfo::Enum { variant_types, .. } => Some( variant_types diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/json_abi_oracle.json index 010f4162470..adaecf5a7b6 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/json_abi_oracle.json +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/json_abi_oracle.json @@ -106,7 +106,20 @@ ], "name": "__array_element", "type": "struct MyStruct", - "typeArguments": null + "typeArguments": [ + { + "components": null, + "name": "T", + "type": "u64", + "typeArguments": null + }, + { + "components": null, + "name": "U", + "type": "bool", + "typeArguments": null + } + ] } ], "name": "arg2", @@ -156,5 +169,111 @@ } ], "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "components": null, + "name": "__array_element", + "type": "u8", + "typeArguments": null + } + ], + "name": "tim", + "type": "[u8; 3]", + "typeArguments": null + }, + { + "components": [ + { + "components": [ + { + "components": null, + "name": "bim", + "type": "u8", + "typeArguments": null + }, + { + "components": [ + { + "components": null, + "name": "Foo", + "type": "u64", + "typeArguments": null + }, + { + "components": null, + "name": "Bar", + "type": "bool", + "typeArguments": null + } + ], + "name": "bam", + "type": "enum MyEnum", + "typeArguments": [ + { + "components": null, + "name": "V", + "type": "u64", + "typeArguments": null + } + ] + } + ], + "name": "__array_element", + "type": "struct MyStruct", + "typeArguments": [ + { + "components": null, + "name": "T", + "type": "u8", + "typeArguments": null + }, + { + "components": null, + "name": "U", + "type": "u16", + "typeArguments": null + } + ] + } + ], + "name": "tam", + "type": "[struct MyStruct; 5]", + "typeArguments": null + } + ], + "name": "arg", + "type": "struct MyArrayStruct", + "typeArguments": [ + { + "components": null, + "name": "V", + "type": "u8", + "typeArguments": null + }, + { + "components": null, + "name": "W", + "type": "u16", + "typeArguments": null + } + ] + } + ], + "name": "take_generic_array", + "outputs": [ + { + "components": null, + "name": "", + "type": "u64", + "typeArguments": null + } + ], + "type": "function" } ] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/src/main.sw index f8765bd4e19..24654c3fdda 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/abi_with_generic_types/src/main.sw @@ -12,10 +12,19 @@ struct MyOtherStruct { bom: u64, } +struct MyArrayStruct { + tim: [V; + 3], + tam: [MyStruct; + 5], +} + abi MyContract { fn complex_function(arg1: MyStruct<[b256; 3], u8>, arg2: [MyStruct; 4], arg3: (str[5], bool), arg3: MyOtherStruct, ) -> str[6]; + fn take_generic_array(arg: MyArrayStruct) -> u64; } impl MyContract for Contract { @@ -24,4 +33,7 @@ impl MyContract for Contract { 4], arg3: (str[5], bool), arg4: MyOtherStruct, ) -> str[6] { "fuel42" } + fn take_generic_array(arg: MyArrayStruct) -> u64 { + 0 + } }