diff --git a/Cargo.lock b/Cargo.lock index b7bb70c2fb..3414e789e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -782,7 +782,7 @@ dependencies = [ name = "cf-chains" version = "0.1.0" dependencies = [ - "ethabi 14.1.0 (git+https://github.com/chainflip-io/ethabi?rev=87ea2a3)", + "ethabi 16.0.0", "ethereum", "frame-support", "frame-system", @@ -1847,20 +1847,9 @@ dependencies = [ [[package]] name = "ethabi" -version = "14.1.0" -source = "git+https://github.com/chainflip-io/ethabi?rev=114a29d#114a29de12b8b2d5af4de17c44634dd006b9997a" -dependencies = [ - "anyhow", - "ethereum-types", - "hex", - "sha3", - "uint", -] - -[[package]] -name = "ethabi" -version = "14.1.0" -source = "git+https://github.com/chainflip-io/ethabi?rev=87ea2a3#87ea2a3270c5cdd18b829e901a9c1d3424bff491" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f76ef192b63e8a44b3d08832acebbb984c3fba154b5c26f70037c860202a0d4b" dependencies = [ "anyhow", "ethereum-types", @@ -1874,13 +1863,13 @@ dependencies = [ [[package]] name = "ethabi" -version = "15.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76ef192b63e8a44b3d08832acebbb984c3fba154b5c26f70037c860202a0d4b" +version = "16.0.0" +source = "git+https://github.com/rust-ethereum/ethabi.git?rev=321a65#321a651e767d7dbe81e8606cbf42f08dedf58c2b" dependencies = [ - "anyhow", "ethereum-types", "hex", + "once_cell", + "regex", "serde 1.0.130", "serde_json", "sha3", @@ -4794,9 +4783,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "opaque-debug" @@ -5167,7 +5156,6 @@ version = "0.1.0" dependencies = [ "cf-chains", "cf-traits", - "ethabi 14.1.0 (git+https://github.com/chainflip-io/ethabi?rev=114a29d)", "frame-benchmarking", "frame-support", "frame-system", diff --git a/state-chain/chains/Cargo.toml b/state-chain/chains/Cargo.toml index 7eca817084..14fde29830 100644 --- a/state-chain/chains/Cargo.toml +++ b/state-chain/chains/Cargo.toml @@ -10,7 +10,7 @@ description = "Shared Chain-specific functionality for use in the substrate runt libsecp256k1 = { default-features = false, version = '0.7', features = ['static-context'] } # Ethereum -ethabi = {default-features = false, features = ['codec', 'serialize'], git = 'https://github.com/chainflip-io/ethabi', rev = '87ea2a3'} +ethabi = {default-features = false, features = ['parity-codec'], git = 'https://github.com/rust-ethereum/ethabi.git', rev = '321a65'} ethereum = {default-features = false, version = "0.10"} hex = {default-features = false, version = "0.4"} rlp = {default-features = false, version = "0.5"} @@ -56,6 +56,7 @@ default = ['std'] std = [ 'codec/std', 'ethabi/std', + 'ethabi/full-serde', 'ethereum/std', 'frame-support/std', 'frame-system/std', diff --git a/state-chain/chains/src/eth.rs b/state-chain/chains/src/eth.rs index 944fccb39e..64631f8278 100644 --- a/state-chain/chains/src/eth.rs +++ b/state-chain/chains/src/eth.rs @@ -36,6 +36,21 @@ pub trait Tokenizable { fn tokenize(self) -> Token; } +#[allow(deprecated)] +fn ethabi_function(name: &'static str, params: Vec) -> ethabi::Function { + ethabi::Function { + name: name.into(), + inputs: params, + outputs: vec![], + constant: None, + state_mutability: ethabi::StateMutability::NonPayable, + } +} + +fn ethabi_param(name: &'static str, param_type: ethabi::ParamType) -> ethabi::Param { + ethabi::Param { name: name.into(), kind: param_type, internal_type: None } +} + /// The `SigData` struct used for threshold signatures in the smart contracts. /// See [here](https://github.com/chainflip-io/chainflip-eth-contracts/blob/master/contracts/interfaces/IShared.sol). #[derive(Encode, Decode, Copy, Clone, RuntimeDebug, Default, PartialEq, Eq)] diff --git a/state-chain/chains/src/eth/register_claim.rs b/state-chain/chains/src/eth/register_claim.rs index b621311f80..741f1d87e6 100644 --- a/state-chain/chains/src/eth/register_claim.rs +++ b/state-chain/chains/src/eth/register_claim.rs @@ -1,9 +1,12 @@ //! Definitions for the "registerClaim" transaction. -use super::{ChainflipContractCall, SchnorrVerificationComponents, SigData, Tokenizable}; +use super::{ + ethabi_function, ethabi_param, ChainflipContractCall, SchnorrVerificationComponents, SigData, + Tokenizable, +}; use codec::{Decode, Encode}; -use ethabi::{ethereum_types::H256, Address, Param, ParamType, StateMutability, Token, Uint}; +use ethabi::{ethereum_types::H256, Address, ParamType, Token, Uint}; use sp_runtime::RuntimeDebug; use sp_std::{prelude::*, vec}; @@ -80,10 +83,10 @@ impl RegisterClaim { /// the json abi definition is currently not supported in no-std, so instead swe hard-code it /// here and verify against the abi in a unit test. fn get_function(&self) -> ethabi::Function { - ethabi::Function::new( + ethabi_function( "registerClaim", vec![ - Param::new( + ethabi_param( "sigData", ParamType::Tuple(vec![ // msgHash @@ -96,14 +99,11 @@ impl RegisterClaim { ParamType::Address, ]), ), - Param::new("nodeID", ParamType::FixedBytes(32)), - Param::new("amount", ParamType::Uint(256)), - Param::new("staker", ParamType::Address), - Param::new("expiryTime", ParamType::Uint(48)), + ethabi_param("nodeID", ParamType::FixedBytes(32)), + ethabi_param("amount", ParamType::Uint(256)), + ethabi_param("staker", ParamType::Address), + ethabi_param("expiryTime", ParamType::Uint(48)), ], - vec![], - false, - StateMutability::NonPayable, ) } } diff --git a/state-chain/chains/src/eth/set_agg_key_with_agg_key.rs b/state-chain/chains/src/eth/set_agg_key_with_agg_key.rs index 62d98566e5..e97a016db5 100644 --- a/state-chain/chains/src/eth/set_agg_key_with_agg_key.rs +++ b/state-chain/chains/src/eth/set_agg_key_with_agg_key.rs @@ -1,9 +1,12 @@ //! Definitions for the "registerClaim" transaction. -use super::{AggKey, ChainflipContractCall, SchnorrVerificationComponents, SigData, Tokenizable}; +use super::{ + ethabi_function, ethabi_param, AggKey, ChainflipContractCall, SchnorrVerificationComponents, + SigData, Tokenizable, +}; use codec::{Decode, Encode}; -use ethabi::{ethereum_types::H256, Param, ParamType, StateMutability, Uint}; +use ethabi::{ethereum_types::H256, ParamType, Uint}; use sp_runtime::RuntimeDebug; use sp_std::{prelude::*, vec}; @@ -57,10 +60,10 @@ impl SetAggKeyWithAggKey { /// from the json abi definition is currently not supported in no-std, so instead we hard-code /// it here and verify against the abi in a unit test. fn get_function(&self) -> ethabi::Function { - ethabi::Function::new( + ethabi_function( "setAggKeyWithAggKey", vec![ - Param::new( + ethabi_param( "sigData", ParamType::Tuple(vec![ ParamType::Uint(256), @@ -69,14 +72,11 @@ impl SetAggKeyWithAggKey { ParamType::Address, ]), ), - Param::new( + ethabi_param( "newKey", ParamType::Tuple(vec![ParamType::Uint(256), ParamType::Uint(8)]), ), ], - vec![], - false, - StateMutability::NonPayable, ) } } diff --git a/state-chain/chains/src/eth/update_flip_supply.rs b/state-chain/chains/src/eth/update_flip_supply.rs index d6699ded14..30d5f74326 100644 --- a/state-chain/chains/src/eth/update_flip_supply.rs +++ b/state-chain/chains/src/eth/update_flip_supply.rs @@ -1,10 +1,12 @@ use crate::eth::Tokenizable; use codec::{Decode, Encode}; -use ethabi::{ethereum_types::H256, Param, ParamType, StateMutability, Token, Uint}; +use ethabi::{ethereum_types::H256, ParamType, Token, Uint}; use frame_support::RuntimeDebug; use sp_std::{vec, vec::Vec}; -use super::{ChainflipContractCall, SchnorrVerificationComponents, SigData}; +use super::{ + ethabi_function, ethabi_param, ChainflipContractCall, SchnorrVerificationComponents, SigData, +}; #[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] pub struct UpdateFlipSupply { @@ -67,10 +69,10 @@ impl UpdateFlipSupply { /// from the json abi definition is currently not supported in no-std, so instead we hard-code /// it here and verify against the abi in a unit test. fn get_function(&self) -> ethabi::Function { - ethabi::Function::new( + ethabi_function( "updateFlipSupply", vec![ - Param::new( + ethabi_param( "sigData", ParamType::Tuple(vec![ ParamType::Uint(256), @@ -79,12 +81,9 @@ impl UpdateFlipSupply { ParamType::Address, ]), ), - Param::new("newTotalSupply", ParamType::Uint(256)), - Param::new("stateChainBlockNumber", ParamType::Uint(256)), + ethabi_param("newTotalSupply", ParamType::Uint(256)), + ethabi_param("stateChainBlockNumber", ParamType::Uint(256)), ], - vec![], - false, - StateMutability::NonPayable, ) } } diff --git a/state-chain/pallets/cf-witnesser-api/Cargo.toml b/state-chain/pallets/cf-witnesser-api/Cargo.toml index 955252ed89..4acfed275f 100644 --- a/state-chain/pallets/cf-witnesser-api/Cargo.toml +++ b/state-chain/pallets/cf-witnesser-api/Cargo.toml @@ -22,9 +22,6 @@ pallet-cf-threshold-signature = {path = '../cf-threshold-signature', default-fea pallet-cf-broadcast = {path = '../cf-broadcast', default-features = false} pallet-cf-witnesser = {path = '../cf-witnesser', default-features = false} -# External dependencies -ethabi = {default-features = false, git = 'https://github.com/chainflip-io/ethabi', rev = '114a29d'} - # Parity deps [dependencies.codec] default-features = false