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

Migrate from ethabi to alloy #5692

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,346 changes: 1,268 additions & 78 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repository = "https://github.com/graphprotocol/graph-node"
license = "MIT OR Apache-2.0"

[workspace.dependencies]
alloy = { version = "0.5.4", features = ["dyn-abi", "json-abi"] }
anyhow = "1.0"
async-graphql = { version = "7.0.11", features = ["chrono", "uuid"] }
async-graphql-axum = "7.0.11"
Expand Down
24 changes: 11 additions & 13 deletions chain/ethereum/src/adapter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::Error;
use ethabi::{Error as ABIError, Function, ParamType, Token};
use graph::blockchain::ChainIdentifier;
use graph::components::subgraph::MappingError;
use graph::data::store::ethereum::call;
Expand Down Expand Up @@ -98,8 +97,8 @@ pub struct ContractCall {
pub contract_name: String,
pub address: Address,
pub block_ptr: BlockPtr,
pub function: Function,
pub args: Vec<Token>,
pub function: graph::abi::Function,
pub args: Vec<graph::abi::DynSolValue>,
pub gas: Option<u32>,
}

Expand All @@ -113,13 +112,12 @@ pub enum EthereumRpcError {

#[derive(Error, Debug)]
pub enum ContractCallError {
#[error("ABI error: {0}")]
ABIError(#[from] ABIError),
/// `Token` is not of expected `ParamType`
#[error("type mismatch, token {0:?} is not of kind {1:?}")]
TypeError(Token, ParamType),
#[error("error encoding input call data: {0}")]
EncodingError(ethabi::Error),
#[error("ABI error: {0:#}")]
ABIError(anyhow::Error),
#[error("type mismatch, decoded value {0:?} is not of kind {1:?}")]
TypeError(graph::abi::DynSolValue, graph::abi::DynSolType),
#[error("error encoding input call data: {0:#}")]
EncodingError(anyhow::Error),
#[error("call error: {0}")]
Web3Error(web3::Error),
#[error("ethereum node took too long to perform call")]
Expand Down Expand Up @@ -1174,7 +1172,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
logger: &Logger,
call: &ContractCall,
cache: Arc<dyn EthereumCallCache>,
) -> Result<(Option<Vec<Token>>, call::Source), ContractCallError>;
) -> Result<(Option<Vec<graph::abi::DynSolValue>>, call::Source), ContractCallError>;

/// Make multiple contract calls in a single batch. The returned `Vec`
/// has results in the same order as the calls in `calls` on input. The
Expand All @@ -1184,7 +1182,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
logger: &Logger,
calls: &[&ContractCall],
cache: Arc<dyn EthereumCallCache>,
) -> Result<Vec<(Option<Vec<Token>>, call::Source)>, ContractCallError>;
) -> Result<Vec<(Option<Vec<graph::abi::DynSolValue>>, call::Source)>, ContractCallError>;

fn get_balance(
&self,
Expand Down Expand Up @@ -1213,9 +1211,9 @@ mod tests {
use graph::blockchain::TriggerFilter as _;
use graph::firehose::{CallToFilter, CombinedFilter, LogFilter, MultiLogFilter};
use graph::petgraph::graphmap::GraphMap;
use graph::prelude::ethabi::ethereum_types::H256;
use graph::prelude::web3::types::Address;
use graph::prelude::web3::types::Bytes;
use graph::prelude::web3::types::H256;
use graph::prelude::EthereumCall;
use hex::ToHex;
use itertools::Itertools;
Expand Down
Loading
Loading