mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 07:11:06 +00:00
Merge remote-tracking branch 'origin/master' into lexnv/metadata_v15
This commit is contained in:
Generated
+30
-30
@@ -94,42 +94,51 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.2.6"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f"
|
||||
checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"concolor-override",
|
||||
"concolor-query",
|
||||
"colorchoice",
|
||||
"is-terminal",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "0.3.5"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2"
|
||||
checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116"
|
||||
checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "0.2.0"
|
||||
name = "anstyle-query"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa"
|
||||
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys 0.45.0",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -461,9 +470,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.2.1"
|
||||
version = "4.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3"
|
||||
checksum = "9b802d85aaf3a1cdb02b224ba472ebdea62014fccfcb269b95a4d76443b5ee5a"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -472,9 +481,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.2.1"
|
||||
version = "4.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f"
|
||||
checksum = "14a1a858f532119338887a4b8e1af9c60de8249cd7bafd68036a489e261e37b6"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -558,19 +567,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "concolor-override"
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f"
|
||||
|
||||
[[package]]
|
||||
name = "concolor-query"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf"
|
||||
dependencies = [
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
@@ -2901,9 +2901,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.95"
|
||||
version = "1.0.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744"
|
||||
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@@ -3528,7 +3528,7 @@ dependencies = [
|
||||
name = "subxt-cli"
|
||||
version = "0.28.0"
|
||||
dependencies = [
|
||||
"clap 4.2.1",
|
||||
"clap 4.2.2",
|
||||
"color-eyre",
|
||||
"frame-metadata",
|
||||
"hex",
|
||||
|
||||
+2
-2
@@ -22,13 +22,13 @@ subxt-codegen = { version = "0.28.0", path = "../codegen" }
|
||||
# perform node compatibility
|
||||
subxt-metadata = { version = "0.28.0", path = "../metadata" }
|
||||
# parse command line args
|
||||
clap = { version = "4.1.11", features = ["derive", "cargo"] }
|
||||
clap = { version = "4.2.2", features = ["derive", "cargo"] }
|
||||
# colourful error reports
|
||||
color-eyre = "0.6.1"
|
||||
# serialize the metadata
|
||||
serde = { version = "1.0.159", features = ["derive"] }
|
||||
# serialize as json
|
||||
serde_json = "1.0.95"
|
||||
serde_json = "1.0.96"
|
||||
# hex encoded metadata to bytes
|
||||
hex = "0.4.3"
|
||||
# actual metadata types
|
||||
|
||||
@@ -93,12 +93,17 @@ impl Derives {
|
||||
derives.insert(syn::parse_quote!(#crate_path::ext::scale_encode::EncodeAsType));
|
||||
let encode_crate_path = quote::quote! { #crate_path::ext::scale_encode }.to_string();
|
||||
attributes.insert(syn::parse_quote!(#[encode_as_type(crate_path = #encode_crate_path)]));
|
||||
|
||||
derives.insert(syn::parse_quote!(#crate_path::ext::scale_decode::DecodeAsType));
|
||||
let decode_crate_path = quote::quote! { #crate_path::ext::scale_decode }.to_string();
|
||||
attributes.insert(syn::parse_quote!(#[decode_as_type(crate_path = #decode_crate_path)]));
|
||||
|
||||
derives.insert(syn::parse_quote!(#crate_path::ext::codec::Encode));
|
||||
attributes.insert(syn::parse_quote!(#[codec(crate = #crate_path::ext::codec)]));
|
||||
|
||||
derives.insert(syn::parse_quote!(#crate_path::ext::codec::Decode));
|
||||
attributes.insert(syn::parse_quote!(#[codec(crate = #crate_path::ext::codec)]));
|
||||
|
||||
derives.insert(syn::parse_quote!(Debug));
|
||||
|
||||
Self {
|
||||
|
||||
@@ -53,6 +53,7 @@ fn generate_struct_with_primitives() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -104,6 +105,7 @@ fn generate_struct_with_a_struct_field() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Child {
|
||||
@@ -111,6 +113,7 @@ fn generate_struct_with_a_struct_field() {
|
||||
}
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Parent {
|
||||
@@ -156,11 +159,13 @@ fn generate_tuple_struct() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Child(pub ::core::primitive::i32,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Parent(pub ::core::primitive::bool, pub root::subxt_codegen::types::tests::Child,);
|
||||
@@ -245,51 +250,61 @@ fn derive_compact_as_for_uint_wrapper_structs() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Su128 { pub a: ::core::primitive::u128, }
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Su16 { pub a: ::core::primitive::u16, }
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Su32 { pub a: ::core::primitive::u32, }
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Su64 { pub a: ::core::primitive::u64, }
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Su8 { pub a: ::core::primitive::u8, }
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct TSu128(pub ::core::primitive::u128,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct TSu16(pub ::core::primitive::u16,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct TSu32(pub ::core::primitive::u32,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct TSu64(pub ::core::primitive::u64,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct TSu8(pub ::core::primitive::u8,);
|
||||
@@ -331,6 +346,7 @@ fn generate_enum() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub enum E {
|
||||
@@ -394,6 +410,7 @@ fn compact_fields() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub enum E {
|
||||
@@ -407,6 +424,7 @@ fn compact_fields() {
|
||||
}
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -414,6 +432,7 @@ fn compact_fields() {
|
||||
}
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct TupleStruct(#[codec(compact)] pub ::core::primitive::u32,);
|
||||
@@ -460,6 +479,7 @@ fn compact_generic_parameter() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -505,6 +525,7 @@ fn generate_array_field() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -547,6 +568,7 @@ fn option_fields() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -592,6 +614,7 @@ fn box_fields_struct() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -637,6 +660,7 @@ fn box_fields_enum() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub enum E {
|
||||
@@ -682,6 +706,7 @@ fn range_fields() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -731,6 +756,7 @@ fn generics() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Bar {
|
||||
@@ -738,6 +764,7 @@ fn generics() {
|
||||
pub c: root::subxt_codegen::types::tests::Foo<::core::primitive::u8>,
|
||||
}
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Foo<_0> {
|
||||
@@ -786,6 +813,7 @@ fn generics_nested() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Bar<_0> {
|
||||
@@ -793,6 +821,7 @@ fn generics_nested() {
|
||||
}
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Foo<_0, _1> {
|
||||
@@ -841,6 +870,7 @@ fn generate_bitvec() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct S {
|
||||
@@ -899,6 +929,7 @@ fn generics_with_alias_adds_phantom_data_marker() {
|
||||
pub mod tests {
|
||||
use super::root;
|
||||
#[derive(::subxt_path::ext::codec::CompactAs, ::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct NamedFields<_0> {
|
||||
@@ -907,6 +938,7 @@ fn generics_with_alias_adds_phantom_data_marker() {
|
||||
pub __subxt_unused_type_params: ::core::marker::PhantomData<_0>
|
||||
}
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct UnnamedFields<_0, _1> (
|
||||
@@ -976,6 +1008,7 @@ fn modules() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Bar {
|
||||
@@ -984,6 +1017,7 @@ fn modules() {
|
||||
}
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Foo;
|
||||
@@ -993,6 +1027,7 @@ fn modules() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct Foo {
|
||||
@@ -1035,6 +1070,7 @@ fn dont_force_struct_names_camel_case() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct AB;
|
||||
@@ -1081,11 +1117,13 @@ fn apply_user_defined_derives_for_all_types() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Clone, Debug, Eq)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct A(pub root :: subxt_codegen :: types :: tests :: B,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Clone, Debug, Eq)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct B;
|
||||
@@ -1153,16 +1191,19 @@ fn apply_user_defined_derives_for_specific_types() {
|
||||
use super::root;
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug, Eq)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct A(pub root :: subxt_codegen :: types :: tests :: B,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug, Eq, Hash)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct B(pub root :: subxt_codegen :: types :: tests :: C,);
|
||||
|
||||
#[derive(::subxt_path::ext::codec::Decode, ::subxt_path::ext::codec::Encode, ::subxt_path::ext::scale_decode::DecodeAsType, ::subxt_path::ext::scale_encode::EncodeAsType, Debug, Eq, Ord, PartialOrd)]
|
||||
#[codec(crate = ::subxt_path::ext::codec)]
|
||||
#[decode_as_type(crate_path = ":: subxt_path :: ext :: scale_decode")]
|
||||
#[encode_as_type(crate_path = ":: subxt_path :: ext :: scale_encode")]
|
||||
pub struct C;
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ futures = { version = "0.3.27", default-features = false, features = ["std"] }
|
||||
hex = "0.4.3"
|
||||
jsonrpsee = { version = "0.16", optional = true, features = ["jsonrpsee-types"] }
|
||||
serde = { version = "1.0.159", features = ["derive"] }
|
||||
serde_json = { version = "1.0.95", features = ["raw_value"] }
|
||||
serde_json = { version = "1.0.96", features = ["raw_value"] }
|
||||
thiserror = "1.0.40"
|
||||
tracing = "0.1.34"
|
||||
parking_lot = "0.12.0"
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::{
|
||||
tx::TxClient,
|
||||
Config, Metadata,
|
||||
};
|
||||
use codec::{Compact, Decode};
|
||||
use codec::Compact;
|
||||
use derivative::Derivative;
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
use futures::future;
|
||||
@@ -136,10 +136,9 @@ impl<T: Config> OnlineClient<T> {
|
||||
|
||||
/// Fetch the metadata from substrate using the runtime API.
|
||||
async fn fetch_metadata(rpc: &Rpc<T>) -> Result<Metadata, Error> {
|
||||
let bytes = rpc.state_call("Metadata_metadata", None, None).await?;
|
||||
let cursor = &mut &*bytes;
|
||||
let _ = <Compact<u32>>::decode(cursor)?;
|
||||
let meta: RuntimeMetadataPrefixed = Decode::decode(cursor)?;
|
||||
let (_, meta) = rpc
|
||||
.state_call::<(Compact<u32>, RuntimeMetadataPrefixed)>("Metadata_metadata", None, None)
|
||||
.await?;
|
||||
Ok(meta.try_into()?)
|
||||
}
|
||||
|
||||
|
||||
+13
-28
@@ -31,16 +31,19 @@
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{error::Error, utils::PhantomDataSendSync, Config, Metadata};
|
||||
|
||||
use super::{
|
||||
rpc_params,
|
||||
types::{self, ChainHeadEvent, FollowEvent},
|
||||
RpcClient, RpcClientT, Subscription,
|
||||
};
|
||||
use crate::{error::Error, utils::PhantomDataSendSync, Config, Metadata};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
use serde::Serialize;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Client for substrate rpc interfaces
|
||||
pub struct Rpc<T: Config> {
|
||||
@@ -151,25 +154,6 @@ impl<T: Config> Rpc<T> {
|
||||
Ok(metadata)
|
||||
}
|
||||
|
||||
/// Execute a runtime API call.
|
||||
pub async fn call(
|
||||
&self,
|
||||
function: String,
|
||||
call_parameters: Option<&[u8]>,
|
||||
at: Option<T::Hash>,
|
||||
) -> Result<types::Bytes, Error> {
|
||||
let call_parameters = call_parameters.unwrap_or_default();
|
||||
|
||||
let bytes: types::Bytes = self
|
||||
.client
|
||||
.request(
|
||||
"state_call",
|
||||
rpc_params![function, to_hex(call_parameters), at],
|
||||
)
|
||||
.await?;
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
/// Fetch system properties
|
||||
pub async fn system_properties(&self) -> Result<types::SystemProperties, Error> {
|
||||
self.client
|
||||
@@ -364,14 +348,13 @@ impl<T: Config> Rpc<T> {
|
||||
}
|
||||
|
||||
/// Execute a runtime API call.
|
||||
pub async fn state_call(
|
||||
pub async fn state_call<Res: Decode>(
|
||||
&self,
|
||||
function: &str,
|
||||
call_parameters: Option<&[u8]>,
|
||||
at: Option<T::Hash>,
|
||||
) -> Result<types::Bytes, Error> {
|
||||
) -> Result<Res, Error> {
|
||||
let call_parameters = call_parameters.unwrap_or_default();
|
||||
|
||||
let bytes: types::Bytes = self
|
||||
.client
|
||||
.request(
|
||||
@@ -379,7 +362,9 @@ impl<T: Config> Rpc<T> {
|
||||
rpc_params![function, to_hex(call_parameters), at],
|
||||
)
|
||||
.await?;
|
||||
Ok(bytes)
|
||||
let cursor = &mut &bytes[..];
|
||||
let res: Res = Decode::decode(cursor)?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// Create and submit an extrinsic and return a subscription to the events triggered.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{client::OnlineClientT, error::Error, Config};
|
||||
use codec::Decode;
|
||||
use derivative::Derivative;
|
||||
use std::{future::Future, marker::PhantomData};
|
||||
|
||||
@@ -32,21 +33,21 @@ where
|
||||
Client: OnlineClientT<T>,
|
||||
{
|
||||
/// Execute a raw runtime API call.
|
||||
pub fn call_raw<'a>(
|
||||
pub fn call_raw<'a, Res: Decode>(
|
||||
&self,
|
||||
function: &'a str,
|
||||
call_parameters: Option<&'a [u8]>,
|
||||
) -> impl Future<Output = Result<Vec<u8>, Error>> + 'a {
|
||||
) -> impl Future<Output = Result<Res, Error>> + 'a {
|
||||
let client = self.client.clone();
|
||||
let block_hash = self.block_hash;
|
||||
// Ensure that the returned future doesn't have a lifetime tied to api.runtime_api(),
|
||||
// which is a temporary thing we'll be throwing away quickly:
|
||||
async move {
|
||||
let data = client
|
||||
let data: Res = client
|
||||
.rpc()
|
||||
.state_call(function, call_parameters, Some(block_hash))
|
||||
.await?;
|
||||
Ok(data.0)
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::TxPayload;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use codec::{Compact, Encode};
|
||||
use derivative::Derivative;
|
||||
|
||||
use crate::{
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
config::{Config, ExtrinsicParams, Hasher},
|
||||
error::Error,
|
||||
tx::{Signer as SignerT, TxProgress},
|
||||
tx::{Signer as SignerT, TxPayload, TxProgress},
|
||||
utils::{Encoded, PhantomDataSendSync},
|
||||
};
|
||||
use codec::{Compact, Encode};
|
||||
use derivative::Derivative;
|
||||
use std::borrow::Cow;
|
||||
|
||||
// This is returned from an API below, so expose it here.
|
||||
pub use crate::rpc::types::DryRunResult;
|
||||
@@ -465,4 +466,23 @@ where
|
||||
let dry_run_bytes = self.client.rpc().dry_run(self.encoded(), at).await?;
|
||||
dry_run_bytes.into_dry_run_result(&self.client.metadata())
|
||||
}
|
||||
|
||||
/// This returns an estimate for what the extrinsic is expected to cost to execute, less any tips.
|
||||
/// The actual amount paid can vary from block to block based on node traffic and other factors.
|
||||
pub async fn partial_fee_estimate(&self) -> Result<u128, Error> {
|
||||
let mut params = self.encoded().to_vec();
|
||||
(self.encoded().len() as u32).encode_to(&mut params);
|
||||
// destructuring RuntimeDispatchInfo, see type information <https://paritytech.github.io/substrate/master/pallet_transaction_payment_rpc_runtime_api/struct.RuntimeDispatchInfo.html>
|
||||
// data layout: {weight_ref_time: Compact<u64>, weight_proof_size: Compact<u64>, class: u8, partial_fee: u128}
|
||||
let (_, _, _, partial_fee) = self
|
||||
.client
|
||||
.rpc()
|
||||
.state_call::<(Compact<u64>, Compact<u64>, u8, u128)>(
|
||||
"TransactionPaymentApi_query_info",
|
||||
Some(¶ms),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
Ok(partial_fee)
|
||||
}
|
||||
}
|
||||
|
||||
+13
-16
@@ -416,11 +416,7 @@ mod test {
|
||||
|
||||
use crate::{
|
||||
client::{OfflineClientT, OnlineClientT},
|
||||
config::{
|
||||
extrinsic_params::BaseExtrinsicParams,
|
||||
polkadot::{PlainTip, PolkadotConfig},
|
||||
WithExtrinsicParams,
|
||||
},
|
||||
config::{extrinsic_params::BaseExtrinsicParams, polkadot::PlainTip, WithExtrinsicParams},
|
||||
error::RpcError,
|
||||
rpc::{types::SubstrateTxStatus, RpcSubscription, Subscription},
|
||||
tx::TxProgress,
|
||||
@@ -429,15 +425,23 @@ mod test {
|
||||
|
||||
use serde_json::value::RawValue;
|
||||
|
||||
type MockTxProgress = TxProgress<SubstrateConfig, MockClient>;
|
||||
type MockHash = <WithExtrinsicParams<
|
||||
SubstrateConfig,
|
||||
BaseExtrinsicParams<SubstrateConfig, PlainTip>,
|
||||
> as Config>::Hash;
|
||||
type MockSubstrateTxStatus = SubstrateTxStatus<MockHash, MockHash>;
|
||||
|
||||
/// a mock client to satisfy trait bounds in tests
|
||||
#[derive(Clone, Debug)]
|
||||
struct MockClient;
|
||||
|
||||
impl OfflineClientT<PolkadotConfig> for MockClient {
|
||||
impl OfflineClientT<SubstrateConfig> for MockClient {
|
||||
fn metadata(&self) -> crate::Metadata {
|
||||
panic!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
|
||||
fn genesis_hash(&self) -> <PolkadotConfig as crate::Config>::Hash {
|
||||
fn genesis_hash(&self) -> <SubstrateConfig as crate::Config>::Hash {
|
||||
panic!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
|
||||
@@ -446,15 +450,8 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
type MockTxProgress = TxProgress<PolkadotConfig, MockClient>;
|
||||
type MockHash = <WithExtrinsicParams<
|
||||
SubstrateConfig,
|
||||
BaseExtrinsicParams<SubstrateConfig, PlainTip>,
|
||||
> as Config>::Hash;
|
||||
type MockSubstrateTxStatus = SubstrateTxStatus<MockHash, MockHash>;
|
||||
|
||||
impl OnlineClientT<PolkadotConfig> for MockClient {
|
||||
fn rpc(&self) -> &crate::rpc::Rpc<PolkadotConfig> {
|
||||
impl OnlineClientT<SubstrateConfig> for MockClient {
|
||||
fn rpc(&self) -> &crate::rpc::Rpc<SubstrateConfig> {
|
||||
panic!("just a mock impl to satisfy trait bounds")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::test_context;
|
||||
use codec::{Compact, Decode};
|
||||
use codec::Compact;
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
use futures::StreamExt;
|
||||
|
||||
@@ -101,10 +101,9 @@ async fn runtime_api_call() -> Result<(), subxt::Error> {
|
||||
let block = sub.next().await.unwrap()?;
|
||||
let rt = block.runtime_api().await?;
|
||||
|
||||
let bytes = rt.call_raw("Metadata_metadata", None).await?;
|
||||
let cursor = &mut &*bytes;
|
||||
let _ = <Compact<u32>>::decode(cursor)?;
|
||||
let meta: RuntimeMetadataPrefixed = Decode::decode(cursor)?;
|
||||
let (_, meta) = rt
|
||||
.call_raw::<(Compact<u32>, RuntimeMetadataPrefixed)>("Metadata_metadata", None)
|
||||
.await?;
|
||||
let metadata_call = match meta.1 {
|
||||
frame_metadata::RuntimeMetadata::V14(metadata) => {
|
||||
subxt_metadata::metadata_v14_to_latest(metadata)
|
||||
|
||||
@@ -388,15 +388,11 @@ async fn rpc_state_call() {
|
||||
let api = ctx.client();
|
||||
|
||||
// Call into the runtime of the chain to get the Metadata.
|
||||
let metadata_bytes = api
|
||||
let (_, meta) = api
|
||||
.rpc()
|
||||
.state_call("Metadata_metadata", None, None)
|
||||
.state_call::<(Compact<u32>, RuntimeMetadataPrefixed)>("Metadata_metadata", None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let cursor = &mut &*metadata_bytes;
|
||||
let _ = <Compact<u32>>::decode(cursor).unwrap();
|
||||
let meta: RuntimeMetadataPrefixed = Decode::decode(cursor).unwrap();
|
||||
let metadata_call = match meta.1 {
|
||||
frame_metadata::RuntimeMetadata::V14(metadata) => {
|
||||
subxt_metadata::metadata_v14_to_latest(metadata)
|
||||
@@ -584,3 +580,75 @@ async fn chainhead_unstable_unpin() {
|
||||
.await
|
||||
.is_err());
|
||||
}
|
||||
|
||||
/// taken from original type <https://docs.rs/pallet-transaction-payment/latest/pallet_transaction_payment/struct.FeeDetails.html>
|
||||
#[derive(Encode, Decode, Debug, Clone, Eq, PartialEq)]
|
||||
pub struct FeeDetails {
|
||||
/// The minimum fee for a transaction to be included in a block.
|
||||
pub inclusion_fee: Option<InclusionFee>,
|
||||
/// tip
|
||||
pub tip: u128,
|
||||
}
|
||||
|
||||
/// taken from original type <https://docs.rs/pallet-transaction-payment/latest/pallet_transaction_payment/struct.InclusionFee.html>
|
||||
/// The base fee and adjusted weight and length fees constitute the _inclusion fee_.
|
||||
#[derive(Encode, Decode, Debug, Clone, Eq, PartialEq)]
|
||||
pub struct InclusionFee {
|
||||
/// minimum amount a user pays for a transaction.
|
||||
pub base_fee: u128,
|
||||
/// amount paid for the encoded length (in bytes) of the transaction.
|
||||
pub len_fee: u128,
|
||||
///
|
||||
/// - `targeted_fee_adjustment`: This is a multiplier that can tune the final fee based on the
|
||||
/// congestion of the network.
|
||||
/// - `weight_fee`: This amount is computed based on the weight of the transaction. Weight
|
||||
/// accounts for the execution time of a transaction.
|
||||
///
|
||||
/// adjusted_weight_fee = targeted_fee_adjustment * weight_fee
|
||||
pub adjusted_weight_fee: u128,
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn partial_fee_estimate_correct() {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let hans = pair_signer(Sr25519Pair::generate().0);
|
||||
|
||||
let tx = node_runtime::tx()
|
||||
.balances()
|
||||
.transfer(hans.account_id().clone().into(), 1_000_000_000_000);
|
||||
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Method I: TransactionPaymentApi_query_info
|
||||
let partial_fee_1 = signed_extrinsic.partial_fee_estimate().await.unwrap();
|
||||
|
||||
// Method II: TransactionPaymentApi_query_fee_details + calculations
|
||||
let len_bytes: [u8; 4] = (signed_extrinsic.encoded().len() as u32).to_le_bytes();
|
||||
let encoded_with_len = [signed_extrinsic.encoded(), &len_bytes[..]].concat();
|
||||
let InclusionFee {
|
||||
base_fee,
|
||||
len_fee,
|
||||
adjusted_weight_fee,
|
||||
} = api
|
||||
.rpc()
|
||||
.state_call::<FeeDetails>(
|
||||
"TransactionPaymentApi_query_fee_details",
|
||||
Some(&encoded_with_len),
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.inclusion_fee
|
||||
.unwrap();
|
||||
let partial_fee_2 = base_fee + len_fee + adjusted_weight_fee;
|
||||
|
||||
// Both methods should yield the same fee
|
||||
assert_eq!(partial_fee_1, partial_fee_2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user