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

[Feature] Add call_with_overrides method on CallBuilder returning decoded output, not raw #517

Closed
zerosnacks opened this issue Apr 12, 2024 · 1 comment · Fixed by #570
Closed
Labels
enhancement New feature or request

Comments

@zerosnacks
Copy link
Member

zerosnacks commented Apr 12, 2024

Component

contract, provider, pubsub

Describe the feature you would like

In order to make calling with state overrides from contract instances easier I propose we add a new method call_with_overrides. This would have the same behavior as call_raw with a state override and then decoding the output.

/// Queries the blockchain via an `eth_call` without submitting a transaction to the network.
///
/// Returns the decoded the output by using the provided decoder.
/// If this is not desired, use [`call_raw`](Self::call_raw) to get the raw output data.
pub async fn call(&self) -> Result<D::CallOutput> {
let data = self.call_raw().await?;
self.decode_output(data, false)
}
/// Queries the blockchain via an `eth_call` without submitting a transaction to the network.
///
/// Does not decode the output of the call, returning the raw output data instead.
///
/// See [`call`](Self::call) for more information.
pub async fn call_raw(&self) -> Result<Bytes> {
if let Some(state) = &self.state {
self.provider.call_with_overrides(&self.request, self.block, state.clone()).await
} else {
self.provider.call(&self.request, self.block).await
}
.map_err(Into::into)
}

Additional context

No response

@zerosnacks
Copy link
Member Author

zerosnacks commented Apr 18, 2024

PR is redundant, resolved by better documenting how state overrides are applied. Will be closed by #570.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant