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

Chore/ethabi mainline #1266

Closed
wants to merge 4 commits into from
Closed
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
32 changes: 10 additions & 22 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion state-chain/chains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -56,6 +56,7 @@ default = ['std']
std = [
'codec/std',
'ethabi/std',
'ethabi/full-serde',
'ethereum/std',
'frame-support/std',
'frame-system/std',
Expand Down
15 changes: 15 additions & 0 deletions state-chain/chains/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ pub trait Tokenizable {
fn tokenize(self) -> Token;
}

#[allow(deprecated)]
fn ethabi_function(name: &'static str, params: Vec<ethabi::Param>) -> 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)]
Expand Down
22 changes: 11 additions & 11 deletions state-chain/chains/src/eth/register_claim.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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
Expand All @@ -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,
)
}
}
Expand Down
16 changes: 8 additions & 8 deletions state-chain/chains/src/eth/set_agg_key_with_agg_key.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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),
Expand All @@ -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,
)
}
}
Expand Down
17 changes: 8 additions & 9 deletions state-chain/chains/src/eth/update_flip_supply.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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),
Expand All @@ -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,
)
}
}
Expand Down
3 changes: 0 additions & 3 deletions state-chain/pallets/cf-witnesser-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down