From a6918aed2b0081837c6ef9af56d14fc4d59beae6 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Mon, 13 Sep 2021 20:43:54 +0300 Subject: [PATCH] fix(ethabi): breaking changes and force enable serialize for eth-types (#448) * fix(ethabi): breaking changes and force enable serialize for eth-types * chore(ethereum-types) enable rlp --- Cargo.lock | 3 ++- ethers-contract/src/base.rs | 9 +++++++-- ethers-core/Cargo.toml | 1 + ethers-core/src/abi/human_readable.rs | 6 +++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a6d3a1b..2876be1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -805,7 +805,7 @@ dependencies = [ [[package]] name = "ethabi" version = "14.1.0" -source = "git+https://github.com/rust-ethereum/ethabi/?branch=master#506f6cc364cdb458ac09f2be4f300779da256b08" +source = "git+https://github.com/rust-ethereum/ethabi/?branch=master#8bd90d13956edf18bb47c6e39dcf7ab99bf264c7" dependencies = [ "anyhow", "ethereum-types", @@ -923,6 +923,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "ethabi", + "ethereum-types", "futures-util", "generic-array 0.14.4", "glob", diff --git a/ethers-contract/src/base.rs b/ethers-contract/src/base.rs index f030e507..a98b9b14 100644 --- a/ethers-contract/src/base.rs +++ b/ethers-contract/src/base.rs @@ -8,7 +8,12 @@ use ethers_core::{ }; use ethers_providers::Middleware; -use std::{collections::HashMap, fmt::Debug, hash::Hash, sync::Arc}; +use std::{ + collections::{BTreeMap, HashMap}, + fmt::Debug, + hash::Hash, + sync::Arc, +}; use thiserror::Error; #[derive(Error, Debug)] @@ -175,7 +180,7 @@ pub fn decode_function_data>( /// Utility function for creating a mapping between a unique signature and a /// name-index pair for accessing contract ABI items. fn create_mapping( - elements: &HashMap>, + elements: &BTreeMap>, signature: F, ) -> HashMap where diff --git a/ethers-core/Cargo.toml b/ethers-core/Cargo.toml index 0ed84d52..a4854069 100644 --- a/ethers-core/Cargo.toml +++ b/ethers-core/Cargo.toml @@ -13,6 +13,7 @@ keywords = ["ethereum", "web3", "celo", "ethers"] rlp = { version = "0.5.0", default-features = false } # ethabi = { version = "14.1.0", default-features = false } ethabi = { git = "https://github.com/rust-ethereum/ethabi/", branch = "master" } +ethereum-types = { version = "0.12.0", default-features = false, features = ["serialize", "rlp"] } arrayvec = { version = "0.7.1", default-features = false } rlp-derive = { version = "0.1.0", default-features = false } diff --git a/ethers-core/src/abi/human_readable.rs b/ethers-core/src/abi/human_readable.rs index 11f41a63..55b36da1 100644 --- a/ethers-core/src/abi/human_readable.rs +++ b/ethers-core/src/abi/human_readable.rs @@ -1,4 +1,4 @@ -use std::collections::{HashMap, VecDeque}; +use std::collections::{BTreeMap, HashMap, VecDeque}; use crate::abi::error::{bail, format_err, ParseError, Result}; use crate::abi::struct_def::{FieldType, StructFieldType}; @@ -52,8 +52,8 @@ impl AbiParser { // parse struct first let mut abi = Abi { constructor: None, - functions: HashMap::new(), - events: HashMap::new(), + functions: BTreeMap::new(), + events: BTreeMap::new(), receive: false, fallback: false, };