foundry-rs / starknet-foundry

Blazing fast toolkit for developing Starknet contracts.
https://foundry-rs.github.io/starknet-foundry/
MIT License
324 stars 176 forks source link

Add precise information about mismatch in struct constructor to data transformer #2549

Open integraledelebesgue opened 1 month ago

integraledelebesgue commented 1 month ago

Component the issue is related to

Cast - data transformer

Issue

At the moment, data transformer returns quite undescriptive error message when processing struct constructor invocation. Suppose we have a struct:

struct MyStruct { a: felt252, b: felt252 }

When we pass wrong invocation to data transformer, for example:

sncast [...] --calldata "MyStruct { a: 0x2137 }"

or

sncast [...] --calldata "MyStruct { some_other_field: 0x2137, b: 0x420 }"

We get an error:

Error: Arguments in constructor invocation for struct MyStruct do not match struct arguments in ABI

A nice quality-of-life feature would be to display an exact mismatch.

Exaple output:

Error: Arguments in constructor invocation for struct MyStruct do not match struct arguments in ABI:
- a: felt252
+ some_other_field: felt252
| b: felt252