From d582479367d4c912e86fb5077523d0faacce8cc9 Mon Sep 17 00:00:00 2001 From: Squirrel Date: Mon, 20 Sep 2021 09:33:33 +0100 Subject: [PATCH] Updated to later version of substrate so that it compiles. (#295) * Updated to later version of substrate so that it compiles. (Referencing substrate this way you only have to search and replace one string to upgrade) * cargo fmt --- Cargo.toml | 31 +++++++++++++++++-------------- client/Cargo.toml | 17 +++++++++++------ proc-macro/Cargo.toml | 11 ++++++++--- src/error.rs | 6 +++++- src/events.rs | 4 ++-- src/metadata.rs | 2 +- 6 files changed, 44 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9db2aa202b..e121a91d3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,10 @@ tokio1 = ["jsonrpsee-http-client/tokio1", "jsonrpsee-ws-client/tokio1"] [dependencies] async-trait = "0.1.49" -codec = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] } +codec = { package = "parity-scale-codec", version = "2.1", default-features = false, features = [ + "derive", + "full", +] } dyn-clone = "1.0.4" futures = "0.3.13" hex = "0.4.3" @@ -43,17 +46,17 @@ url = "2.2.1" substrate-subxt-client = { version = "0.7.0", path = "client", optional = true } substrate-subxt-proc-macro = { version = "0.15.0", path = "proc-macro" } -sp-application-crypto = "3.0.0" -sp-core = "3.0.0" -sp-rpc = "3.0.0" -sp-runtime = "3.0.0" -sp-std = "3.0.0" -sp-version = "3.0.0" +sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +sp-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } -frame-metadata = "13.0.0" -frame-support = "3.0.0" -pallet-indices = "3.0.0" -pallet-staking = "3.0.0" +frame-metadata = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +pallet-indices = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +pallet-staking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } [dev-dependencies] assert_matches = "1.5.0" @@ -62,6 +65,6 @@ env_logger = "0.8.3" tempdir = "0.3.7" wabt = "0.10.0" which = "4.0.2" -sp-keyring = "3.0.0" -frame-system = "3.0.0" -pallet-balances = "3.0.0" +sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } diff --git a/client/Cargo.toml b/client/Cargo.toml index 1db0387241..5ed4cfb3cc 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,7 +1,10 @@ [package] name = "substrate-subxt-client" version = "0.7.0" -authors = ["David Craven ", "Parity Technologies "] +authors = [ + "David Craven ", + "Parity Technologies ", +] edition = "2018" license = "GPL-3.0" @@ -20,13 +23,15 @@ log = "0.4.13" serde_json = "1.0.61" thiserror = "1.0.23" -sc-client-db = "0.9.0" -sp-keyring = "3.0.0" -sc-network = { version = "0.9.0", default-features = false } -sc-service = { version = "0.9.0", default-features = false } +sc-client-db = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } +sc-network = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10", default-features = false } +sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10", default-features = false } [target.'cfg(target_arch="x86_64")'.dependencies] -sc-service = { version = "0.9.0", default-features = false, features = ["wasmtime"] } +sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10", default-features = false, features = [ + "wasmtime", +] } [dev-dependencies] async-std = { version = "1.8.0", features = ["attributes"] } diff --git a/proc-macro/Cargo.toml b/proc-macro/Cargo.toml index 721291be29..3ee914577b 100644 --- a/proc-macro/Cargo.toml +++ b/proc-macro/Cargo.toml @@ -1,7 +1,10 @@ [package] name = "substrate-subxt-proc-macro" version = "0.15.0" -authors = ["David Craven ", "Parity Technologies "] +authors = [ + "David Craven ", + "Parity Technologies ", +] edition = "2018" autotests = false @@ -26,13 +29,15 @@ synstructure = "0.12.4" [dev-dependencies] async-std = { version = "1.8.0", features = ["attributes"] } -codec = { package = "parity-scale-codec", version = "2.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "2.0.0", features = [ + "derive", +] } env_logger = "0.8.2" pretty_assertions = "0.6.1" substrate-subxt = { path = ".." } trybuild = "1.0.38" -sp-keyring = "3.0.0" +sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.10" } [[test]] name = "balances" diff --git a/src/error.rs b/src/error.rs index 4f5e3a1db7..9e60fc1557 100644 --- a/src/error.rs +++ b/src/error.rs @@ -139,7 +139,11 @@ impl RuntimeError { DispatchError::CannotLookup => Ok(Self::CannotLookup), DispatchError::ConsumerRemaining => Ok(Self::ConsumerRemaining), DispatchError::NoProviders => Ok(Self::NoProviders), - DispatchError::Other(msg) => Ok(Self::Other(msg.into())), + DispatchError::Arithmetic(_math_error) => { + Ok(Self::Other("math_error".into())) + } + DispatchError::Token(_token_error) => Ok(Self::Other("token error".into())), + DispatchError::Other(msg) => Ok(Self::Other(msg.to_string())), } } } diff --git a/src/events.rs b/src/events.rs index 2cda82f0fe..95d530d14c 100644 --- a/src/events.rs +++ b/src/events.rs @@ -361,7 +361,7 @@ mod tests { ModuleMetadata, RuntimeMetadata, RuntimeMetadataPrefixed, - RuntimeMetadataV12, + RuntimeMetadataV13, META_RESERVED, }; use std::convert::TryFrom; @@ -399,7 +399,7 @@ mod tests { let decoder = EventsDecoder::::new( Metadata::try_from(RuntimeMetadataPrefixed( META_RESERVED, - RuntimeMetadata::V12(RuntimeMetadataV12 { + RuntimeMetadata::V13(RuntimeMetadataV13 { modules: DecodeDifferent::Decoded(vec![ModuleMetadata { name: DecodeDifferent::Decoded("System".to_string()), storage: None, diff --git a/src/metadata.rs b/src/metadata.rs index 9e4b992e0a..c3c3645bbe 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -529,7 +529,7 @@ impl TryFrom for Metadata { return Err(ConversionError::InvalidPrefix.into()) } let meta = match metadata.1 { - RuntimeMetadata::V12(meta) => meta, + RuntimeMetadata::V13(meta) => meta, _ => return Err(ConversionError::InvalidVersion.into()), }; let mut modules = HashMap::new();