Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unable to decode variable length types #366

Closed
asdfcrypto opened this issue Oct 12, 2023 · 2 comments · Fixed by #367
Closed

[Bug] Unable to decode variable length types #366

asdfcrypto opened this issue Oct 12, 2023 · 2 comments · Fixed by #367
Labels
bug Something isn't working

Comments

@asdfcrypto
Copy link

asdfcrypto commented Oct 12, 2023

Component

sol-types

What version of Alloy are you on?

https://github.com/alloy-rs/core.git#8b33e7fe

Operating System

Linux

Describe the bug

Example code doesnt work, when I expect that it should. Happens for strings and other variable length types as well.

#[cfg(test)]
mod tests {
    use alloy_primitives::hex::{decode, encode};
    use alloy_sol_types::{sol, SolCall};
    sol! {
        interface Test {
            function test() returns (uint256[]);
        }
    }
    #[test]
    fn test_decode_var_length() {
        Test::testCall::abi_decode_returns(
            &decode(format!(
                "{}000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
                encode(Test::testCall::SELECTOR)
            ))
            .unwrap(),
            true,
        )
        .expect("Should be able to decode");
    }
}

Error

TypeCheckFail { expected_type: "Solidity pointer (uint32)", data: "f8a8fd6d00000000000000000000000000000000000000000000000000000000" }
@DaniPopes
Copy link
Member

Selectors aren't part of return data, only call data, but there's another bug which is fixed in #367

@asdfcrypto
Copy link
Author

Ah, derp. My fault! Closing this then, thanks for the swift response. Thank you for your fantastic work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants