#Broken custom type in 0.4.3

4 messages · Page 1 of 1 (latest)

patent perch
#

I have a custom type defined as

#[contracttype]
pub struct Rectangle {
    pub height: u32,
    pub width: u32, 
}

which I am trying to pass to an contract function using the cli.
Previously I was able to pass the parameter using --arg '{"object":{"map":[{"key":{"symbol":"width"},"val":{"u32":5}},{"key":{"symbol":"height"},"val":{"u32":8}}]}}' but since this update this command will result in an Status(HostValueError(UnknownError)) during the transaction simulation.
When looking at the https://soroban.stellar.org/docs/learn/custom-types example I don't see anything changed that would explain this behaviour.
What am I missing here?

patent perch
#

So it turns out that it is apparently no longer indifferent in what order the arguments are given.
When using --arg '{"object":{"map":[{"key":{"symbol":"height"},"val":{"u32":5}},{"key":{"symbol":"width"},"val":{"u32":8}}]}}' (i.e. mirror the same order of key->value pairs as in the given struct) the call succeeds.

#

On a slightly different node tho:
given ```rust
pub enum Animal {
Cat,
Dog,
}
pub struct User {
pub name: Bytes,
pub age: u32,
pub pet: Animal,
}

and using
 ```json
--arg \
'{"object":{"map":[ \
    {"key":{"symbol":"name"},"val":{"object":{"bytes":"00"}}}, \
    {"key":{"symbol":"age"},"val":{"u32":8}}, \
    {"key":{"symbol":"pet"},"val":{"object":{"vec":[{"symbol":"Dog"}]}}} \
]}}'

will also result in Status(HostValueError(UnknownError)) since the new update.
Here the order is the same as in the struct definition and an call only using the Animal struct succeeds using --arg '{"object": {"vec": [{"symbol": "Dog"}]}}' so I am somewhat lost again

thorny nimbus