Skip to content

Commit

Permalink
fix(cast): use new raw abi api (#3417)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Sep 29, 2022
1 parent b25f321 commit 5c01493
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions cast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
use crate::rlp_converter::Item;
use base::{Base, NumberWithBase, ToBase};
use chrono::NaiveDateTime;
use ethers_contract::RawAbi;
use ethers_core::{
abi::{
token::{LenientTokenizer, Tokenizer},
Function, HumanReadableParser, Token,
Function, HumanReadableParser, RawAbi, Token,
},
types::{Chain, *},
utils::{
Expand Down Expand Up @@ -1274,8 +1273,7 @@ impl SimpleCast {
.map(|item| item.contract_name.clone())
.collect::<Vec<String>>();

// TODO: Abi to RawAbi ?
let abis = source.abis().iter().cloned().map(|_| todo!()).collect();
let abis = source.raw_abis()?;

(abis, names)
}
Expand Down
8 changes: 4 additions & 4 deletions common/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ pub async fn get_func_etherscan(
let source = find_source(client, contract).await?;
let metadata = source.items.first().wrap_err("etherscan returned empty metadata")?;

let empty = vec![];
let funcs = metadata.abi.functions.get(function_name).unwrap_or(&empty);
let mut abi = metadata.abi()?;
let funcs = abi.functions.remove(function_name).unwrap_or_default();

for func in funcs {
let res = encode_args(func, args);
let res = encode_args(&func, args);
if res.is_ok() {
return Ok(func.clone())
return Ok(func)
}
}

Expand Down
4 changes: 2 additions & 2 deletions evm/src/trace/identifier/etherscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ impl TraceIdentifier for EtherscanIdentifier {
let fut = fetcher
.map(|(address, metadata)| {
let label = metadata.contract_name.clone();
let abi = metadata.abi.clone();
let abi = metadata.abi().ok().map(Cow::Owned);
self.contracts.insert(address, metadata);

AddressIdentity {
address,
label: Some(label.clone()),
contract: Some(label),
abi: Some(Cow::Owned(abi)),
abi,
artifact_id: None,
}
})
Expand Down
6 changes: 2 additions & 4 deletions utils/src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Convert a json abi into solidity inerface
use ethers_contract::{InternalStructs, RawAbi};
use ethers_contract::InternalStructs;
use ethers_core::{
abi,
abi::{
struct_def::{FieldType, StructFieldType},
Contract as Abi, Event, EventParam, Function, Param, ParamType, SolStruct,
Contract as Abi, Event, EventParam, Function, Param, ParamType, RawAbi, SolStruct,
},
};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -339,8 +339,6 @@ fn struct_field_to_type(ty: &StructFieldType) -> String {
mod tests {
use super::*;

use ethers_contract::RawAbi;

#[test]
#[cfg(any(target_os = "linux", target_os = "macos"))]
fn abi2solidity() {
Expand Down

0 comments on commit 5c01493

Please sign in to comment.