Skip to content

Commit

Permalink
Merge pull request #1 from agryaznov/4.1.1-ethink-dev
Browse files Browse the repository at this point in the history
customize `v4` to work with contracts @ ethink
  • Loading branch information
agryaznov authored Jun 26, 2024
2 parents 7810bda + fb1ea11 commit 44c7d74
Show file tree
Hide file tree
Showing 15 changed files with 1,409 additions and 1,238 deletions.
2,412 changes: 1,284 additions & 1,128 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/analyze/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contract-analyze"
version = "4.1.1"
version = "4.1.1+ethink"
authors = ["Use Ink <ink@r0gue.io>"]
edition = "2021"

Expand All @@ -14,7 +14,7 @@ keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
include = ["Cargo.toml", "*.rs", "LICENSE"]

[dependencies]
contract-metadata = { version = "4.1.1", path = "../metadata" }
contract-metadata = { version = "4.1.1+ethink", path = "../metadata" }
wasmparser = "0.207.0"
anyhow = "1.0.83"

Expand Down
8 changes: 4 additions & 4 deletions crates/build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contract-build"
version = "4.1.1"
version = "4.1.1+ethink"
authors = ["Use Ink <ink@r0gue.io>"]
edition = "2021"

Expand Down Expand Up @@ -38,22 +38,22 @@ term_size = "0.3.2"
url = { version = "2.5.0", features = ["serde"] }
wasm-opt = { version = "=0.116.1", default-features = false }
which = "6.0.1"
zip = { version = "1.2.3", default-features = false }
zip = { version = "2.1.3", default-features = false }
strum = { version = "0.26", features = ["derive"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1"
bollard = "0.16"
crossterm = "0.27.0"

contract-metadata = { version = "4.1.1", path = "../metadata" }
contract-metadata = { version = "4.1.1+ethink", path = "../metadata" }

[target.'cfg(unix)'.dependencies]
uzers = "0.12"

[build-dependencies]
anyhow = "1.0.83"
walkdir = "2.5.0"
zip = { version = "1.2.3", default-features = false }
zip = { version = "2.1.3", default-features = false }

[dev-dependencies]
pretty_assertions = "1.4.0"
Expand Down
26 changes: 15 additions & 11 deletions crates/cargo-contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-contract"
version = "4.1.1"
version = "4.1.1+ethink"
authors = ["Use Ink <ink@r0gue.io>"]
build = "build.rs"
edition = "2021"
Expand All @@ -18,11 +18,11 @@ include = [
]

[dependencies]
contract-build = { version = "4.1.1", path = "../build" }
contract-extrinsics = { version = "4.1.1", path = "../extrinsics" }
contract-transcode = { version = "4.1.1", path = "../transcode" }
contract-metadata = { version = "4.1.1", path = "../metadata" }
contract-analyze = { version = "4.1.1", path = "../analyze" }
contract-build = { version = "4.1.1+ethink", path = "../build" }
contract-extrinsics = { version = "4.1.1+ethink", path = "../extrinsics" }
contract-transcode = { version = "4.1.1+ethink", path = "../transcode" }
contract-metadata = { version = "4.1.1+ethink", path = "../metadata" }
contract-analyze = { version = "4.1.1+ethink", path = "../analyze" }

anyhow = "1.0.83"
clap = { version = "4.5.4", features = ["derive", "env"] }
Expand All @@ -37,17 +37,21 @@ url = { version = "2.5.0", features = ["serde"] }
semver = "1.0"
jsonschema = "0.18"
schemars = "0.8"
ink_metadata = "5.0.0"
ink_env = "5.0.0"
ink_env = {git = "https://github.com/use-ink/ink", rev = "0cd2b89"}
ink_metadata = {git = "https://github.com/use-ink/ink", rev = "0cd2b89"}
comfy-table = "7.1.1"

# dependencies for extrinsics (deploying and calling a contract)
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
subxt = { version = "0.35.3", features = ["substrate-compat"] }
sp-core = "31.0.0"
sp-weights = "30.0.0"
subxt = { git = "https://github.com/agryaznov/subxt.git", tag = "v0.35.3+ethink", features = ["substrate-compat"] }
subxt-signer = { git = "https://github.com/agryaznov/subxt.git", tag = "v0.35.3+ethink", features = ["ecdsa"] }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0" }
hex = "0.4.3"

# ethink
ep-eth = { git = "https://github.com/agryaznov/ethink.git", tag = "v0.3.0" }

[build-dependencies]
anyhow = "1.0.83"
substrate-build-script-utils = "11.0.0"
Expand Down
52 changes: 27 additions & 25 deletions crates/cargo-contract/src/cmd/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::{
};
use subxt::{
config::{
substrate::MultiAddress,
PolkadotExtrinsicParams,
SubstrateExtrinsicParams,
},
Expand All @@ -35,26 +36,33 @@ use subxt::{
PairSigner,
Signer as SignerT,
},
utils::AccountId20,
Config,
PolkadotConfig,
SubstrateConfig,
};

use subxt_signer::{
ecdsa,
SecretUri,
};

use ep_eth::EthereumSignature;

/// Configuration for signer
pub trait SignerConfig<C: Config + Environment> {
type Signer: SignerT<C> + FromStr + Clone;
}

/// A runtime configuration for the ecdsa test chain.
/// This thing is not meant to be instantiated; it is just a collection of types.
/// A runtime configuration for a Ethink chain.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Ecdsachain {}

impl Config for Ecdsachain {
type Hash = <SubstrateConfig as Config>::Hash;
type AccountId = <SubstrateConfig as Config>::AccountId;
type Address = <SubstrateConfig as Config>::Address;
type Signature = <SubstrateConfig as Config>::Signature;
type AccountId = AccountId20;
type Address = MultiAddress<Self::AccountId, u32>;
type Signature = EthereumSignature;
type Hasher = <SubstrateConfig as Config>::Hasher;
type Header = <SubstrateConfig as Config>::Header;
type ExtrinsicParams = SubstrateExtrinsicParams<Self>;
Expand All @@ -71,11 +79,8 @@ impl Environment for Ecdsachain {
type ChainExtension = <DefaultEnvironment as Environment>::ChainExtension;
}

impl SignerConfig<Self> for Ecdsachain
where
<Self as Config>::Signature: From<sp_core::ecdsa::Signature>,
{
type Signer = SignerEcdsa<Self>;
impl SignerConfig<Self> for Ecdsachain {
type Signer = SignerEcdsa;
}

/// A runtime configuration for the Substrate based chain.
Expand Down Expand Up @@ -175,38 +180,35 @@ where

/// Struct representing the implementation of the ecdsa signer
#[derive(Clone)]
pub struct SignerEcdsa<C: Config>(pub PairSigner<C, sp_core::ecdsa::Pair>);
pub struct SignerEcdsa(pub ecdsa::Keypair);

impl<C: Config> FromStr for SignerEcdsa<C>
where
// Requirements of the `PairSigner where:
// T::AccountId: From<SpAccountId32>`
<C as Config>::AccountId: From<sp_core::crypto::AccountId32>,
{
impl FromStr for SignerEcdsa {
type Err = anyhow::Error;

/// Attempts to parse the Signer suri string
fn from_str(input: &str) -> Result<SignerEcdsa<C>, Self::Err> {
let keypair = sp_core::ecdsa::Pair::from_string(input, None)?;
let signer = PairSigner::<C, _>::new(keypair);
fn from_str(input: &str) -> Result<SignerEcdsa, Self::Err> {
let suri = SecretUri::from_str(input)?;
let signer = ecdsa::Keypair::from_uri(&suri)?;
Ok(Self(signer))
}
}

impl<C: Config> SignerT<C> for SignerEcdsa<C>
impl<C: Config> SignerT<C> for SignerEcdsa
where
<C as Config>::Signature: From<sp_core::ecdsa::Signature>,
<C as Config>::AccountId: From<ecdsa::PublicKey>,
<C as Config>::Address: From<ecdsa::PublicKey>,
<C as Config>::Signature: From<ecdsa::Signature>,
{
fn account_id(&self) -> <C as Config>::AccountId {
self.0.account_id().clone()
<ecdsa::Keypair as SignerT<C>>::account_id(&self.0).clone()
}

fn address(&self) -> C::Address {
self.0.address()
<ecdsa::Keypair as SignerT<C>>::address(&self.0)
}

fn sign(&self, signer_payload: &[u8]) -> C::Signature {
self.0.sign(signer_payload)
<ecdsa::Keypair as SignerT<C>>::sign(&self.0, signer_payload)
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/cargo-contract/src/cmd/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl InstantiateCommand {
.salt(self.salt.clone())
.done()
.await?;
tracing::debug!("HAVE BUILT COMMAND");

if !self.extrinsic_cli_opts.execute {
let result = instantiate_exec.instantiate_dry_run().await?;
Expand Down
27 changes: 14 additions & 13 deletions crates/extrinsics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contract-extrinsics"
version = "4.1.1"
version = "4.1.1+ethink"
authors = ["Use Ink <ink@r0gue.io>"]
edition = "2021"
rust-version = "1.70"
Expand All @@ -15,9 +15,9 @@ keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
include = ["Cargo.toml", "*.rs", "LICENSE",]

[dependencies]
contract-build = { version = "4.1.1", path = "../build" }
contract-metadata = { version = "4.1.1", path = "../metadata" }
contract-transcode = { version = "4.1.1", path = "../transcode" }
contract-build = { version = "4.1.1+ethink", path = "../build" }
contract-metadata = { version = "4.1.1+ethink", path = "../metadata" }
contract-transcode = { version = "4.1.1+ethink", path = "../transcode" }

anyhow = "1.0.83"
blake2 = { version = "0.10.6", default-features = false }
Expand All @@ -31,25 +31,26 @@ serde_json = "1.0.117"
url = { version = "2.5.0", features = ["serde"] }
rust_decimal = "1.35"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
sp-core = "31.0.0"
sp-runtime = "34.0.0"
sp-weights = "30.0.0"
pallet-contracts-uapi = { package = "pallet-contracts-uapi-next", version = "=6.0.3", features = ["scale"] }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0" }
pallet-contracts-uapi = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0", features = ["scale"] }
scale-info = "2.11.3"
subxt = "0.35.3"
#subxt = { git = "https://github.com/agryaznov/subxt", branch = "0.35.3-ethink" }
subxt = { git = "https://github.com/agryaznov/subxt.git", tag = "v0.35.3+ethink" }
hex = "0.4.3"
derivative = "2.2.0"
ink_metadata = "5.0.0"
ink_env = "5.0.0"
ink_env = { git = "https://github.com/use-ink/ink", rev = "0cd2b89" }
ink_metadata = { git = "https://github.com/use-ink/ink", rev = "0cd2b89" }

[dev-dependencies]
ink = "5.0.0"
ink = { git = "https://github.com/use-ink/ink", rev = "0cd2b89" }
assert_cmd = "2.0.14"
regex = "1.10.4"
predicates = "3.1.0"
tempfile = "3.10.1"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
subxt-signer = { version = "0.35.3", features = ["subxt", "sr25519"] }
subxt-signer = { git = "https://github.com/agryaznov/subxt.git", branch = "0.35.3-ethink-dev", features = ["subxt", "sr25519"] }

[features]
integration-tests = []
Expand Down
4 changes: 2 additions & 2 deletions crates/extrinsics/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use std::str::FromStr;

use contract_transcode::AccountId32;
use contract_transcode::AccountId20;
use subxt::{
backend::rpc::{
RawValue,
Expand Down Expand Up @@ -157,7 +157,7 @@ fn custom_ss58_parse(s: &mut &str) -> Option<Result<Value<()>, ParseError>> {
let end_idx = s
.find(|c: char| !c.is_ascii_alphanumeric())
.unwrap_or(s.len());
let account = AccountId32::from_str(&s[..end_idx]).ok()?;
let account = AccountId20::from_str(&s[..end_idx]).ok()?;

*s = &s[end_idx..];
Some(Ok(Value::string(format!("0x{}", hex::encode(account.0)))))
Expand Down
2 changes: 1 addition & 1 deletion crates/metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contract-metadata"
version = "4.1.1"
version = "4.1.1+ethink"
authors = ["Use Ink <ink@r0gue.io>"]
edition = "2021"

Expand Down
7 changes: 7 additions & 0 deletions crates/metadata/compatibility_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
">=5.0.0-rc.2",
"5.0.0"
]
},
"4.1.1-ethink": {
"ink": [
">=5.0.0-rc.2",
"5.0.0"
]
}

}
}
14 changes: 7 additions & 7 deletions crates/transcode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contract-transcode"
version = "4.1.1"
version = "4.1.1+ethink"
authors = ["Use Ink <ink@r0gue.io>"]
edition = "2021"

Expand All @@ -20,12 +20,12 @@ path = "src/lib.rs"
anyhow = "1.0.83"
base58 = { version = "0.2.0" }
blake2 = { version = "0.10.6", default-features = false }
contract-metadata = { version = "4.1.1", path = "../metadata" }
contract-metadata = { version = "4.1.1+ethink", path = "../metadata" }
escape8259 = "0.5.2"
hex = "0.4.3"
indexmap = "2.2.6"
ink_env = "5.0.0"
ink_metadata = "5.0.0"
ink_env = { git = "https://github.com/use-ink/ink", rev = "0cd2b89" }
ink_metadata = { git = "https://github.com/use-ink/ink", rev = "0cd2b89" }
itertools = "0.12.1"
tracing = "0.1.40"
nom = "7.1.3"
Expand All @@ -40,9 +40,9 @@ strsim = "0.11.1"

[dev-dependencies]
assert_matches = "1.5.0"
ink = "5.0.0"
sp-core = "31.0.0"
sp-keyring = "34.0.0"
ink = { git = "https://github.com/use-ink/ink", rev = "0cd2b89" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0" }
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.12.0" }

[features]
# This `std` feature is required for testing using an inline contract's metadata, because `ink!` annotates the metadata
Expand Down
Loading

0 comments on commit 44c7d74

Please sign in to comment.