Closed re1ro closed 1 week ago
The issue here is the struct is encoded as a ScVal::Map. Unfortunately the issue is that XDR expects the keys in the map to be sorted, hence why weight must be second. This should be fixable in the JS code so that you don't need to worry about it.
I need to check since it's been a while since I was deep into the code, but the ContractClient might handle this when passing in init.
@willemneal thank you for getting back to it so quickly!
Describe the bug When encoding nested structs we ran into an issue where encoding would fail if
bytes
type is not passed first.What version are you on?
12.0.1
To Reproduce Here is example init function that takes struct as a param:
Now I am trying to encode data for this in JS. This works:
This doesn't work:
Seems like encoding breaks if I don't pass bytes as the first entry in the JS object... Regardless in which order it is defined in Rust or in encoding type description.
Expected behavior Encoding works regardless of entries order in the passed object