Merge remote-tracking branch 'origin/master' into na-jsonrpsee-core-client

This commit is contained in:
Niklas
2021-12-03 10:33:40 +01:00
10 changed files with 55 additions and 22 deletions
@@ -2,4 +2,6 @@
title: Subxt integration tests failed against latest Substrate build.
---
The nightly CI run which downloads the latest version of Substrate ran into test failures, which likely means that there are breaking changes that need fixing in Subxt.
The nightly CI run which downloads the latest version of Substrate ran into test failures, which likely means that there are breaking changes that need fixing in Subxt.
Go to https://github.com/paritytech/subxt/actions/workflows/nightly.yml to see details about the failure.
+1 -1
View File
@@ -3,7 +3,7 @@ name: Daily compatibility check against latest substrate
on:
schedule:
# Run at 8am every day
- cron: "* 8 * * *"
- cron: "0 8 * * *"
env:
+2 -2
View File
@@ -120,7 +120,7 @@ fn main() -> color_eyre::Result<()> {
});
let (_, bytes) = fetch_metadata(&url)?;
codegen(&mut &bytes[..])?;
return Ok(())
Ok(())
}
}
}
@@ -139,7 +139,7 @@ fn fetch_metadata(url: &url::Url) -> color_eyre::Result<(String, Vec<u8>)> {
let hex_data = json["result"]
.as_str()
.map(ToString::to_string)
.ok_or(eyre::eyre!("metadata result field should be a string"))?;
.ok_or_else(|| eyre::eyre!("metadata result field should be a string"))?;
let bytes = hex::decode(hex_data.trim_start_matches("0x"))?;
Ok((hex_data, bytes))
+1
View File
@@ -73,6 +73,7 @@ impl ItemMod {
}
#[derive(Debug, PartialEq, Eq)]
#[allow(clippy::large_enum_variant)]
pub enum Item {
Rust(syn::Item),
Subxt(SubxtItem),
+6 -6
View File
@@ -22,7 +22,7 @@ use scale_info::{
TypeInfo,
};
const MOD_PATH: &'static [&'static str] = &["subxt_codegen", "types", "tests"];
const MOD_PATH: &[&str] = &["subxt_codegen", "types", "tests"];
fn get_mod<'a>(module: &'a Module, path_segs: &[&'static str]) -> Option<&'a Module<'a>> {
let (mod_name, rest) = path_segs.split_first()?;
@@ -790,7 +790,7 @@ fn generics_with_alias_adds_phantom_data_marker() {
#[test]
fn modules() {
mod modules {
mod m {
pub mod a {
#[allow(unused)]
#[derive(scale_info::TypeInfo)]
@@ -815,7 +815,7 @@ fn modules() {
}
let mut registry = Registry::new();
registry.register_type(&meta_type::<modules::c::Foo>());
registry.register_type(&meta_type::<m::c::Foo>());
let portable_types: PortableRegistry = registry.into();
let type_gen = TypeGenerator::new(
@@ -832,7 +832,7 @@ fn modules() {
quote! {
pub mod tests {
use super::root;
pub mod modules {
pub mod m {
use super::root;
pub mod a {
use super::root;
@@ -842,7 +842,7 @@ fn modules() {
#[derive(::subxt::codec::Encode, ::subxt::codec::Decode)]
pub struct Bar {
pub a: root::subxt_codegen::types::tests::modules::a::Foo,
pub a: root::subxt_codegen::types::tests::m::a::Foo,
}
}
@@ -855,7 +855,7 @@ fn modules() {
#[derive(::subxt::codec::Encode, ::subxt::codec::Decode)]
pub struct Foo {
pub a: root::subxt_codegen::types::tests::modules::a::b::Bar,
pub a: root::subxt_codegen::types::tests::m::a::b::Bar,
}
}
}
+8 -1
View File
@@ -157,7 +157,14 @@ impl<T: Config> Client<T> {
&self.metadata
}
/// Returns the system properties
/// Returns the properties defined in the chain spec as a JSON object.
///
/// # Note
///
/// Many chains use this to define common properties such as `token_decimals` and `token_symbol`
/// required for UIs, but this is merely a convention. It is up to the library user to
/// deserialize the JSON into the appropriate type or otherwise extract the properties defined
/// in the target chain's spec.
pub fn properties(&self) -> &SystemProperties {
&self.properties
}
+5
View File
@@ -143,6 +143,11 @@ pub struct PalletMetadata {
}
impl PalletMetadata {
/// Get the name of the pallet.
pub fn name(&self) -> &str {
&self.name
}
/// Encode a call based on this pallet metadata.
pub fn encode_call<C>(&self, call: &C) -> Result<Encoded, MetadataError>
where
+2 -11
View File
@@ -145,17 +145,8 @@ impl From<u32> for BlockNumber {
}
}
/// System properties for a Substrate-based runtime
#[derive(serde::Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct SystemProperties {
/// The address format
pub ss58_format: u8,
/// The number of digits after the decimal point in the native token
pub token_decimals: u8,
/// The symbol of the native token
pub token_symbol: String,
}
/// Arbitrary properties defined in the chain spec as a JSON object.
pub type SystemProperties = serde_json::Map<String, serde_json::Value>;
/// Possible transaction status events.
///
+1
View File
@@ -21,3 +21,4 @@ mod contracts;
mod staking;
mod sudo;
mod system;
mod timestamp;
+26
View File
@@ -0,0 +1,26 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// subxt is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// subxt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use crate::test_context;
#[async_std::test]
async fn storage_get_current_timestamp() {
let cxt = test_context().await;
let timestamp = cxt.api.storage().timestamp().now(None).await;
assert!(timestamp.is_ok())
}