Skip to content

Commit a6a1cbf

Browse files
committed
migrate from ethabi to alloy
1 parent 1642eaf commit a6a1cbf

File tree

32 files changed

+1934
-372
lines changed

32 files changed

+1934
-372
lines changed

Cargo.lock

Lines changed: 1268 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ repository = "https://github.com/graphprotocol/graph-node"
2626
license = "MIT OR Apache-2.0"
2727

2828
[workspace.dependencies]
29+
alloy = { version = "0.5.4", features = ["dyn-abi", "json-abi"] }
2930
anyhow = "1.0"
3031
async-graphql = { version = "7.0.11", features = ["chrono", "uuid"] }
3132
async-graphql-axum = "7.0.11"

chain/ethereum/src/adapter.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use anyhow::Error;
2-
use ethabi::{Error as ABIError, Function, ParamType, Token};
32
use graph::blockchain::ChainIdentifier;
43
use graph::components::subgraph::MappingError;
54
use graph::data::store::ethereum::call;
@@ -98,8 +97,8 @@ pub struct ContractCall {
9897
pub contract_name: String,
9998
pub address: Address,
10099
pub block_ptr: BlockPtr,
101-
pub function: Function,
102-
pub args: Vec<Token>,
100+
pub function: graph::abi::Function,
101+
pub args: Vec<graph::abi::DynSolValue>,
103102
pub gas: Option<u32>,
104103
}
105104

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

114113
#[derive(Error, Debug)]
115114
pub enum ContractCallError {
116-
#[error("ABI error: {0}")]
117-
ABIError(#[from] ABIError),
118-
/// `Token` is not of expected `ParamType`
119-
#[error("type mismatch, token {0:?} is not of kind {1:?}")]
120-
TypeError(Token, ParamType),
121-
#[error("error encoding input call data: {0}")]
122-
EncodingError(ethabi::Error),
115+
#[error("ABI error: {0:#}")]
116+
ABIError(anyhow::Error),
117+
#[error("type mismatch, decoded value {0:?} is not of kind {1:?}")]
118+
TypeError(graph::abi::DynSolValue, graph::abi::DynSolType),
119+
#[error("error encoding input call data: {0:#}")]
120+
EncodingError(anyhow::Error),
123121
#[error("call error: {0}")]
124122
Web3Error(web3::Error),
125123
#[error("ethereum node took too long to perform call")]
@@ -1174,7 +1172,7 @@ pub trait EthereumAdapter: Send + Sync + 'static {
11741172
logger: &Logger,
11751173
call: &ContractCall,
11761174
cache: Arc<dyn EthereumCallCache>,
1177-
) -> Result<(Option<Vec<Token>>, call::Source), ContractCallError>;
1175+
) -> Result<(Option<Vec<graph::abi::DynSolValue>>, call::Source), ContractCallError>;
11781176

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

11891187
fn get_balance(
11901188
&self,
@@ -1213,9 +1211,9 @@ mod tests {
12131211
use graph::blockchain::TriggerFilter as _;
12141212
use graph::firehose::{CallToFilter, CombinedFilter, LogFilter, MultiLogFilter};
12151213
use graph::petgraph::graphmap::GraphMap;
1216-
use graph::prelude::ethabi::ethereum_types::H256;
12171214
use graph::prelude::web3::types::Address;
12181215
use graph::prelude::web3::types::Bytes;
1216+
use graph::prelude::web3::types::H256;
12191217
use graph::prelude::EthereumCall;
12201218
use hex::ToHex;
12211219
use itertools::Itertools;

0 commit comments

Comments
 (0)