Concordium / concordium-rust-smart-contracts

Libraries and tools for writing and testing smart contracts on Concordium
https://docs.rs/concordium-std/latest/concordium_std/
Mozilla Public License 2.0
57 stars 35 forks source link

Contract parameter parsing error! #93

Closed keienWang closed 2 years ago

keienWang commented 2 years ago

Description image image It can be seen that my parameter is a structure, and the parsing in the contract is an address, but I don't understand why the parsing can be successful, it feels like the first 32 bytes taken directly can be converted into an address, then the following elements are directly discarded , which is unreasonable.

Expected Result It should return an error in time or fail to execute!

Versions

abizjak commented 2 years ago

The get method is designed for incremental parsing from byte sources, which is what HasParameter in particular is. This in particular means that it does not ensure that all of the input is consumed.

I see that there is no direct way of ensuring that all of the input has been consumed at the moment.

I suggest we add a way of ensuring that to the HasParameter trait, and perhaps a helper method that would then combine .get and ensure-we-are-at-the-end.

Would this work for you as well?

abizjak commented 2 years ago

This is related to #64

abizjak commented 2 years ago

HasParameter now implies Seek as a result of #137 So I am closing this as resolved.