Failure of Contact Data to display

Hello Rust Devs,
I am using alloy.rs to query my Solidity contract data but I get a display issue with the variable holding the results, with a warning that the variable can not be formatted with the default formatter, even the debug formatter doesn't work

use alloy::{providers::{Provider,ProviderBuilder}, primitives::address, sol};
use eyre::Result;

sol!(
    #[sol(rpc)]
    XFI_Safe_Binding,
    "XFI_Safe_ABI.json"
);

#[tokio::main]
async fn main() -> Result<()>{
    println!("Im querying XFI");

    let XFI_Provider = ProviderBuilder::new().connect_http("https://rpc.mainnet.ms".parse()?);
    let XFI_Chain_ID =  XFI_Provider.get_chain_id().await?;

    let XFI_Safe_Inst = XFI_Safe_Binding::new(
        address!("0x1b5bbc25f41cbb4f77852c35e5bd422a7eb061aa"),
        XFI_Provider,
    );

    let UnloadedData =  XFI_Safe_Inst.unloadData().call().await?;

    println!("The Chain ID is {}",XFI_Chain_ID);
    
    // println!("This is the unloaded Data {:?}",UnloadedData);

    Ok(())
}

UnloadedData over there, the println!() statement fails and the program panics with the error I mentioned earlier, otherwise when its commented out the compilation completes successfully.

unloadData method returns a tuple

function unloadData() external view returns(uint, uint, uint, uint, bool) {
        if(withdrawInits[msg.sender] > 0 && int(withdrawThreshold-(block.timestamp + withdrawInits[msg.sender])) > 0){
            return (
        deposits[msg.sender], 
        withdrawnToInvest, 
        returnedfromInvestment,
        withdrawThreshold-(block.timestamp + withdrawInits[msg.sender]),
        true
        );
        } else {
                  return (
        deposits[msg.sender], 
        withdrawnToInvest, 
        returnedfromInvestment,
        0,
        false
        );
        }
    }

When I query a method that returns a singular value however, the value does display.
So i can't figure out when the issue is, I thought it might be a type mismatch with the binding for a tuple, but I can't resolve it. Someone help me understand why the tuple fails to display with all the formatters.

Here is the execution result, when the println statement is commented. first, and when its an active statement

Working result

Error results

I'm not familiar with the alloy crate, but looking at the documentation for the sol! macro (see the slot0Return example) it seems like you may need to define a the struct that contains fields matching types? I'm not sure why it wouldn't define this for you...

cargo-expand could also be helpful in figuring out what code the macro generated (but it is likely to be hard to read)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.