filecoin-project / filecoin-solidity

Filecoin Solidity API Library
Other
17 stars 11 forks source link

Enabling the generation of Sol types in Rust #19

Closed wertikalk closed 10 months ago

wertikalk commented 11 months ago

Description

Closes: https://github.com/filecoin-project/filecoin-solidity/issues/6 - Compile params automatically from ABI on rust tests

Context: Currently all of the message calls to ref-fvm in rust integration tests contain hardcoded hex string making the readability of the code extremely difficult and its maintainability hard.

Approach

Using alloy-rs and its sol! macro we are generating Rust types for custom Solidity structs and functions. This gives us an opportunity to set all of their fields individually and to also use the provided abi_encode method which is enough to generate the needed ABI encoded hex string.

Note: functions are encoded with their selector and have Call added to the the of the function (see sol! examples).

This generated string is then CBOR encoded using the cbor crate to comply with the desired format.

maciejwitowski commented 10 months ago

LGTM. @bojinovic Can we merge this?