Skip to content

Commit

Permalink
chore: correctly map type
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Jun 3, 2024
1 parent 31806de commit daa85fa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/dojo-bindgen/src/plugins/unity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,14 @@ public class {} : ModelInstance {{
token: &Token,
handled_tokens: &[Composite],
) -> String {
let mapped_type = UnityPlugin::map_type(token);

match handled_tokens.iter().find(|t| t.type_name() == token.type_name()) {
Some(t) => {
// Need to flatten the struct members.
match t.r#type {
CompositeType::Struct if t.type_name() == "ByteArray" => format!(
"calldata.AddRange(ByteArray.Serialize({}));",
"calldata.AddRange(ByteArray.Serialize({}).Select(f => f.Inner));",
type_name
),
CompositeType::Struct => t
Expand All @@ -264,7 +266,7 @@ public class {} : ModelInstance {{
}
}
}
None => match UnityPlugin::map_type(token).as_str() {
None => match mapped_type.as_str() {
"FieldElement" => format!("calldata.Add({}.Inner);", type_name),
_ => format!("calldata.Add(new FieldElement({}).Inner);", type_name),
}
Expand Down Expand Up @@ -293,8 +295,7 @@ public class {} : ModelInstance {{
// Returns the transaction hash. Use `WaitForTransaction` to wait for the transaction to be \
confirmed.
public async Task<FieldElement> {system_name}(Account account{arg_sep}{args}) {{
List<FieldElement> calldata = new List<FieldElement>();
List<dojo.FieldElement> calldata = new List<dojo.FieldElement>();
{calldata}
return await account.ExecuteRaw(new dojo.Call[] {{
Expand Down Expand Up @@ -339,6 +340,7 @@ public class {} : ModelInstance {{
out += "using Dojo.Starknet;\n";
out += "using UnityEngine;\n";
out += "using dojo_bindings;\n";
out += "using System.Collections.Generic;\n";

let systems = contract
.systems
Expand Down

0 comments on commit daa85fa

Please sign in to comment.