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: estimate_tx_dependencies doesn't work for logging of external contracts #771

Open
iqdecay opened this issue Jan 8, 2023 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@iqdecay
Copy link
Contributor

iqdecay commented Jan 8, 2023

This code works:

    let expected_logs: Vec<String> = vec![
        format!("{:?}", 64),
        format!("{:?}", 32),
        format!("{:?}", 16),
        format!("{:?}", 8),
    ];

    let logs = contract_caller_instance
        .methods()
        .logs_from_external_contract(contract_id)
        .set_contracts(&[contract_instance])
        .call()
        .await?
        .get_logs()?;

    assert_eq!(expected_logs, logs);

but this one doesn't:

    let logs = contract_caller_instance
        .methods()
        .logs_from_external_contract(contract_id)
        .estimate_tx_dependencies(None)
        .await?
        .call()
        .await?
        .get_logs()?;

    assert_eq!(expected_logs, logs);

As a user, I would expect estimate_tx_dependencies to estimate the logging dependencies for me. It is not the case.
This is because the estimate_tx_dependencies doesn't use the set_contracts method. The fix is not trivial: we would need the estimate_tx_dependencies method to have access to the abigen so the log_decoder can be instantiated.

@iqdecay iqdecay self-assigned this Jan 8, 2023
@iqdecay iqdecay added documentation Improvements or additions to documentation bug Something isn't working labels Jan 8, 2023
@iqdecay
Copy link
Contributor Author

iqdecay commented Jan 8, 2023

One possible solution would be to provide the path to the contract binaries when you want estimate_tx_dependencies to work with logging. And then the function would call the abigens and instantiate the contracts for you. A problem to know which bin path corresponds to which contract_id remains. This might turn out to be too dirty and annoying compared to just letting the user manage logging themselves though.

@iqdecay iqdecay removed their assignment May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant