Get WASM example compiling via 'trunk serve'

This commit is contained in:
James Wilson
2025-12-16 18:28:16 +00:00
parent c1d30da488
commit 4819b00655
17 changed files with 33145 additions and 33772 deletions
Generated
+2 -2
View File
@@ -4410,9 +4410,9 @@ dependencies = [
[[package]]
name = "scale-encode"
version = "0.10.0"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64901733157f9d25ef86843bd783eda439fac7efb0ad5a615d12d2cf3a29464b"
checksum = "f2a976d73564a59e482b74fd5d95f7518b79ca8c8ca5865398a4d629dd15ee50"
dependencies = [
"parity-scale-codec",
"primitive-types",
+1 -1
View File
@@ -100,7 +100,7 @@ scale-info = { version = "2.11.4", default-features = false }
scale-value = { version = "0.18.1", default-features = false }
scale-bits = { version = "0.7.0", default-features = false }
scale-decode = { version = "0.16.2", default-features = false }
scale-encode = { version = "0.10.0", default-features = false }
scale-encode = { version = "0.10.1", default-features = false }
scale-type-resolver = { version = "0.2.0" }
scale-info-legacy = { version = "0.4.0", default-features = false }
scale-typegen = "0.12.0"
+123 -58
View File
@@ -872,6 +872,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "foldhash"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
@@ -883,16 +889,18 @@ dependencies = [
[[package]]
name = "frame-decode"
version = "0.11.0"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0acacffe60911b0d57a55c0b323fc08ccd88659dc52056bb39dfeb5cedafb59"
checksum = "e63257bb5f8d7a707d626aa1b4e464c3b9720edd168b73cee98f48f0dd6386e4"
dependencies = [
"frame-metadata",
"parity-scale-codec",
"scale-decode",
"scale-encode",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"serde_yaml",
"sp-crypto-hashing",
"thiserror 2.0.12",
]
@@ -1067,10 +1075,23 @@ checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash",
"foldhash 0.1.5",
"serde",
]
[[package]]
name = "hashbrown"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.2.0",
"serde",
"serde_core",
]
[[package]]
name = "heck"
version = "0.5.0"
@@ -2196,9 +2217,9 @@ dependencies = [
[[package]]
name = "scale-decode"
version = "0.16.0"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d78196772d25b90a98046794ce0fe2588b39ebdfbdc1e45b4c6c85dd43bebad"
checksum = "8d6ed61699ad4d54101ab5a817169259b5b0efc08152f8632e61482d8a27ca3d"
dependencies = [
"parity-scale-codec",
"primitive-types",
@@ -2211,9 +2232,9 @@ dependencies = [
[[package]]
name = "scale-decode-derive"
version = "0.16.0"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4b54a1211260718b92832b661025d1f1a4b6930fbadd6908e00edd265fa5f7"
checksum = "65cb245f7fdb489e7ba43a616cbd34427fe3ba6fe0edc1d0d250085e6c84f3ec"
dependencies = [
"darling",
"proc-macro2",
@@ -2223,9 +2244,9 @@ dependencies = [
[[package]]
name = "scale-encode"
version = "0.10.0"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64901733157f9d25ef86843bd783eda439fac7efb0ad5a615d12d2cf3a29464b"
checksum = "f2a976d73564a59e482b74fd5d95f7518b79ca8c8ca5865398a4d629dd15ee50"
dependencies = [
"parity-scale-codec",
"primitive-types",
@@ -2238,9 +2259,9 @@ dependencies = [
[[package]]
name = "scale-encode-derive"
version = "0.10.0"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78a3993a13b4eafa89350604672c8757b7ea84c7c5947d4b3691e3169c96379b"
checksum = "17020f2d59baabf2ddcdc20a4e567f8210baf089b8a8d4785f5fd5e716f92038"
dependencies = [
"darling",
"proc-macro-crate",
@@ -2275,6 +2296,21 @@ dependencies = [
"syn",
]
[[package]]
name = "scale-info-legacy"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afb76e1b2cb589b97278e2f1e2e290c9b7c51d6ac69afab9e1d7d1e136a9276"
dependencies = [
"hashbrown 0.16.1",
"scale-type-resolver",
"serde",
"smallstr",
"smallvec",
"thiserror 2.0.12",
"yap",
]
[[package]]
name = "scale-type-resolver"
version = "0.2.0"
@@ -2287,9 +2323,9 @@ dependencies = [
[[package]]
name = "scale-typegen"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c61b6b706a3eaad63b506ab50a1d2319f817ae01cf753adcc3f055f9f0fcd6"
checksum = "642d2f13f3fc9a34ea2c1e36142984eba78cd2405a61632492f8b52993e98879"
dependencies = [
"proc-macro2",
"quote",
@@ -2423,10 +2459,11 @@ checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
[[package]]
name = "serde"
version = "1.0.219"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
@@ -2440,10 +2477,19 @@ dependencies = [
]
[[package]]
name = "serde_derive"
version = "1.0.219"
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
@@ -2462,6 +2508,19 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap",
"itoa",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]]
name = "sha1"
version = "0.10.6"
@@ -2540,6 +2599,15 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589"
[[package]]
name = "smallstr"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "862077b1e764f04c251fe82a2ef562fd78d7cadaeb072ca7c2bcaf7217b1ff3b"
dependencies = [
"smallvec",
]
[[package]]
name = "smallvec"
version = "1.15.1"
@@ -2734,42 +2802,46 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "subxt"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"async-trait",
"derive-where",
"either",
"frame-decode",
"frame-metadata",
"futures",
"hex",
"impl-serde",
"jsonrpsee",
"keccak-hash",
"parity-scale-codec",
"primitive-types",
"scale-bits",
"scale-decode",
"scale-encode",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"scale-value",
"serde",
"serde_json",
"sp-crypto-hashing",
"subxt-core",
"subxt-lightclient",
"subxt-macro",
"subxt-metadata",
"subxt-rpcs",
"subxt-utils-accountid32",
"thiserror 2.0.12",
"tokio",
"tokio-util",
"tracing",
"url",
"wasm-bindgen-futures",
"web-time",
]
[[package]]
name = "subxt-codegen"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"heck",
"parity-scale-codec",
@@ -2782,34 +2854,6 @@ dependencies = [
"thiserror 2.0.12",
]
[[package]]
name = "subxt-core"
version = "0.44.0"
dependencies = [
"base58",
"blake2",
"derive-where",
"frame-decode",
"frame-metadata",
"hashbrown 0.14.5",
"hex",
"impl-serde",
"keccak-hash",
"parity-scale-codec",
"primitive-types",
"scale-bits",
"scale-decode",
"scale-encode",
"scale-info",
"scale-value",
"serde",
"serde_json",
"sp-crypto-hashing",
"subxt-metadata",
"thiserror 2.0.12",
"tracing",
]
[[package]]
name = "subxt-ffi"
version = "0.1.0"
@@ -2822,7 +2866,7 @@ dependencies = [
[[package]]
name = "subxt-lightclient"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"futures",
"futures-util",
@@ -2837,7 +2881,7 @@ dependencies = [
[[package]]
name = "subxt-macro"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"darling",
"parity-scale-codec",
@@ -2852,20 +2896,22 @@ dependencies = [
[[package]]
name = "subxt-metadata"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"frame-decode",
"frame-metadata",
"hashbrown 0.14.5",
"parity-scale-codec",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"sp-crypto-hashing",
"thiserror 2.0.12",
]
[[package]]
name = "subxt-rpcs"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"derive-where",
"frame-metadata",
@@ -2877,7 +2923,6 @@ dependencies = [
"primitive-types",
"serde",
"serde_json",
"subxt-core",
"subxt-lightclient",
"thiserror 2.0.12",
"tokio-util",
@@ -2887,7 +2932,7 @@ dependencies = [
[[package]]
name = "subxt-signer"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"base64",
"bip39",
@@ -2906,14 +2951,28 @@ dependencies = [
"serde_json",
"sha2 0.10.9",
"sp-crypto-hashing",
"subxt-core",
"subxt",
"thiserror 2.0.12",
"zeroize",
]
[[package]]
name = "subxt-utils-accountid32"
version = "0.50.0"
dependencies = [
"base58",
"blake2",
"parity-scale-codec",
"scale-decode",
"scale-encode",
"scale-info",
"serde",
"thiserror 2.0.12",
]
[[package]]
name = "subxt-utils-fetchmetadata"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"hex",
"parity-scale-codec",
@@ -3209,6 +3268,12 @@ dependencies = [
"subtle",
]
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "untrusted"
version = "0.9.0"
+1 -1
View File
@@ -6,7 +6,7 @@ edition = "2024"
[dependencies]
hex = "0.4.3"
subxt = { path = "../../subxt" }
subxt-signer = { path = "../../signer" }
subxt-signer = { path = "../../signer", features = ["subxt"] }
tokio = { version = "1", features = ["full"] }
[lib]
+6 -3
View File
@@ -35,7 +35,8 @@ pub extern "C" fn do_transfer(dest_hex: *const c_char, amount: u64) -> i32 {
// Spin up (or reuse) our Tokio runtime and connect:
let client = tokio_rt().block_on(async {
OnlineClient::<PolkadotConfig>::from_url("ws://127.0.0.1:8000")
let config = PolkadotConfig::new();
OnlineClient::from_url(config, "ws://127.0.0.1:8000")
.await
.unwrap()
});
@@ -54,11 +55,13 @@ pub extern "C" fn do_transfer(dest_hex: *const c_char, amount: u64) -> i32 {
// Submit and wait for finalize
let res: Result<(), subxt::Error> = tokio_rt().block_on(async {
let progress = client
client
.tx()
.await?
.sign_and_submit_then_watch_default(&tx, &signer)
.await?
.wait_for_finalized_success()
.await?;
progress.wait_for_finalized_success().await?;
Ok(())
});
+121 -56
View File
@@ -928,6 +928,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "foldhash"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
@@ -939,16 +945,18 @@ dependencies = [
[[package]]
name = "frame-decode"
version = "0.11.0"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0acacffe60911b0d57a55c0b323fc08ccd88659dc52056bb39dfeb5cedafb59"
checksum = "e63257bb5f8d7a707d626aa1b4e464c3b9720edd168b73cee98f48f0dd6386e4"
dependencies = [
"frame-metadata",
"parity-scale-codec",
"scale-decode",
"scale-encode",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"serde_yaml",
"sp-crypto-hashing",
"thiserror 2.0.11",
]
@@ -1123,10 +1131,23 @@ checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash",
"foldhash 0.1.5",
"serde",
]
[[package]]
name = "hashbrown"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.2.0",
"serde",
"serde_core",
]
[[package]]
name = "heck"
version = "0.5.0"
@@ -2272,9 +2293,9 @@ dependencies = [
[[package]]
name = "scale-decode"
version = "0.16.0"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d78196772d25b90a98046794ce0fe2588b39ebdfbdc1e45b4c6c85dd43bebad"
checksum = "8d6ed61699ad4d54101ab5a817169259b5b0efc08152f8632e61482d8a27ca3d"
dependencies = [
"parity-scale-codec",
"primitive-types",
@@ -2287,9 +2308,9 @@ dependencies = [
[[package]]
name = "scale-decode-derive"
version = "0.16.0"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4b54a1211260718b92832b661025d1f1a4b6930fbadd6908e00edd265fa5f7"
checksum = "65cb245f7fdb489e7ba43a616cbd34427fe3ba6fe0edc1d0d250085e6c84f3ec"
dependencies = [
"darling",
"proc-macro2",
@@ -2299,9 +2320,9 @@ dependencies = [
[[package]]
name = "scale-encode"
version = "0.10.0"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64901733157f9d25ef86843bd783eda439fac7efb0ad5a615d12d2cf3a29464b"
checksum = "f2a976d73564a59e482b74fd5d95f7518b79ca8c8ca5865398a4d629dd15ee50"
dependencies = [
"parity-scale-codec",
"primitive-types",
@@ -2351,6 +2372,21 @@ dependencies = [
"syn",
]
[[package]]
name = "scale-info-legacy"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afb76e1b2cb589b97278e2f1e2e290c9b7c51d6ac69afab9e1d7d1e136a9276"
dependencies = [
"hashbrown 0.16.1",
"scale-type-resolver",
"serde",
"smallstr",
"smallvec",
"thiserror 2.0.11",
"yap",
]
[[package]]
name = "scale-type-resolver"
version = "0.2.0"
@@ -2363,9 +2399,9 @@ dependencies = [
[[package]]
name = "scale-typegen"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c61b6b706a3eaad63b506ab50a1d2319f817ae01cf753adcc3f055f9f0fcd6"
checksum = "642d2f13f3fc9a34ea2c1e36142984eba78cd2405a61632492f8b52993e98879"
dependencies = [
"proc-macro2",
"quote",
@@ -2500,10 +2536,11 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
[[package]]
name = "serde"
version = "1.0.219"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
@@ -2517,10 +2554,19 @@ dependencies = [
]
[[package]]
name = "serde_derive"
version = "1.0.219"
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
@@ -2539,6 +2585,19 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap",
"itoa",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]]
name = "sha1"
version = "0.10.6"
@@ -2620,6 +2679,15 @@ dependencies = [
"autocfg",
]
[[package]]
name = "smallstr"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "862077b1e764f04c251fe82a2ef562fd78d7cadaeb072ca7c2bcaf7217b1ff3b"
dependencies = [
"smallvec",
]
[[package]]
name = "smallvec"
version = "1.13.2"
@@ -2814,42 +2882,46 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "subxt"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"async-trait",
"derive-where",
"either",
"frame-decode",
"frame-metadata",
"futures",
"hex",
"impl-serde",
"jsonrpsee",
"keccak-hash",
"parity-scale-codec",
"primitive-types",
"scale-bits",
"scale-decode",
"scale-encode",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"scale-value",
"serde",
"serde_json",
"sp-crypto-hashing",
"subxt-core",
"subxt-lightclient",
"subxt-macro",
"subxt-metadata",
"subxt-rpcs",
"subxt-utils-accountid32",
"thiserror 2.0.11",
"tokio",
"tokio-util",
"tracing",
"url",
"wasm-bindgen-futures",
"web-time",
]
[[package]]
name = "subxt-codegen"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"heck",
"parity-scale-codec",
@@ -2862,37 +2934,9 @@ dependencies = [
"thiserror 2.0.11",
]
[[package]]
name = "subxt-core"
version = "0.44.0"
dependencies = [
"base58",
"blake2",
"derive-where",
"frame-decode",
"frame-metadata",
"hashbrown 0.14.5",
"hex",
"impl-serde",
"keccak-hash",
"parity-scale-codec",
"primitive-types",
"scale-bits",
"scale-decode",
"scale-encode",
"scale-info",
"scale-value",
"serde",
"serde_json",
"sp-crypto-hashing",
"subxt-metadata",
"thiserror 2.0.11",
"tracing",
]
[[package]]
name = "subxt-lightclient"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"futures",
"futures-util",
@@ -2907,7 +2951,7 @@ dependencies = [
[[package]]
name = "subxt-macro"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"darling",
"parity-scale-codec",
@@ -2922,20 +2966,22 @@ dependencies = [
[[package]]
name = "subxt-metadata"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"frame-decode",
"frame-metadata",
"hashbrown 0.14.5",
"parity-scale-codec",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"sp-crypto-hashing",
"thiserror 2.0.11",
]
[[package]]
name = "subxt-rpcs"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"derive-where",
"frame-metadata",
@@ -2947,7 +2993,6 @@ dependencies = [
"primitive-types",
"serde",
"serde_json",
"subxt-core",
"subxt-lightclient",
"thiserror 2.0.11",
"tokio-util",
@@ -2957,7 +3002,7 @@ dependencies = [
[[package]]
name = "subxt-signer"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"base64 0.22.1",
"bip39",
@@ -2976,14 +3021,28 @@ dependencies = [
"serde_json",
"sha2 0.10.8",
"sp-crypto-hashing",
"subxt-core",
"subxt",
"thiserror 2.0.11",
"zeroize",
]
[[package]]
name = "subxt-utils-accountid32"
version = "0.50.0"
dependencies = [
"base58",
"blake2",
"parity-scale-codec",
"scale-decode",
"scale-encode",
"scale-info",
"serde",
"thiserror 2.0.11",
]
[[package]]
name = "subxt-utils-fetchmetadata"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"hex",
"parity-scale-codec",
@@ -3274,6 +3333,12 @@ dependencies = [
"subtle",
]
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "untrusted"
version = "0.9.0"
+1 -1
View File
@@ -7,5 +7,5 @@ edition = "2021"
[dependencies]
subxt = { path = "../../subxt" }
subxt-signer = { path = "../../signer" }
subxt-signer = { path = "../../signer", features = ["subxt"] }
tokio = { version = "1.44.2", features = ["macros", "time", "rt-multi-thread"] }
+7 -5
View File
@@ -1,7 +1,6 @@
use subxt::{
PolkadotConfig,
utils::{AccountId32, MultiAddress},
OnlineClient,
OnlineClient, PolkadotConfig,
};
use subxt_signer::sr25519::dev::{self};
@@ -21,7 +20,8 @@ pub async fn main() {
async fn run() -> Result<(), Box<dyn std::error::Error>> {
// (the port 42069 is specified in the asset-hub-zombienet.toml)
let api = OnlineClient::<StatemintConfig>::from_url("ws://127.0.0.1:42069").await?;
let config = StatemintConfig::new();
let api = OnlineClient::<StatemintConfig>::from_url(config, "ws://127.0.0.1:42069").await?;
println!("Connection with parachain established.");
let alice: MultiAddress<AccountId32, ()> = dev::alice().public_key().into();
@@ -36,6 +36,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
.create(COLLECTION_ID, alice.clone());
let _collection_creation_events = api
.tx()
.await?
.sign_and_submit_then_watch_default(&collection_creation_tx, &alice_pair_signer)
.await
.map(|e| {
@@ -52,6 +53,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
.mint(COLLECTION_ID, NTF_ID, alice.clone());
let _nft_creation_events = api
.tx()
.await?
.sign_and_submit_then_watch_default(&nft_creation_tx, &alice_pair_signer)
.await
.map(|e| {
@@ -65,9 +67,9 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
// check in storage, that alice is the official owner of the NFT:
let nft_owner_storage_query = statemint::storage().uniques().asset();
let nft_storage_details = api
.storage()
.at_latest()
.at_current_block()
.await?
.storage()
.fetch(nft_owner_storage_query, (COLLECTION_ID, NTF_ID))
.await?
.decode()?;
+214 -82
View File
@@ -151,6 +151,12 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "base64ct"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e050f626429857a27ddccb31e0aca21356bfa709c04041aefddac081a8f068a"
[[package]]
name = "bincode"
version = "1.3.3"
@@ -336,6 +342,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "const-oid"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
[[package]]
name = "const_format"
version = "0.2.34"
@@ -370,9 +382,9 @@ checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
[[package]]
name = "convert_case"
version = "0.6.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9"
dependencies = [
"unicode-segmentation",
]
@@ -490,6 +502,17 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "der"
version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
dependencies = [
"const-oid",
"pem-rfc7468",
"zeroize",
]
[[package]]
name = "derive-where"
version = "1.2.7"
@@ -507,7 +530,16 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05"
dependencies = [
"derive_more-impl",
"derive_more-impl 1.0.0",
]
[[package]]
name = "derive_more"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10b768e943bed7bf2cab53df09f4bc34bfd217cdb57d971e769874c9a6710618"
dependencies = [
"derive_more-impl 2.1.0",
]
[[package]]
@@ -515,10 +547,22 @@ name = "derive_more-impl"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "derive_more-impl"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d286bfdaf75e988b4a78e013ecd79c581e06399ab53fbacd2d916c2f904f30b"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"rustc_version",
"syn 2.0.100",
"unicode-xid",
]
@@ -566,21 +610,23 @@ version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53"
dependencies = [
"pkcs8",
"signature",
]
[[package]]
name = "ed25519-zebra"
version = "4.0.3"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9"
checksum = "0017d969298eec91e3db7a2985a8cab4df6341d86e6f3a6f5878b13fb7846bc9"
dependencies = [
"curve25519-dalek",
"ed25519",
"hashbrown 0.14.5",
"hex",
"hashbrown 0.15.2",
"pkcs8",
"rand_core",
"sha2 0.10.8",
"subtle",
"zeroize",
]
@@ -656,6 +702,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "foldhash"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
@@ -667,16 +719,18 @@ dependencies = [
[[package]]
name = "frame-decode"
version = "0.11.0"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0acacffe60911b0d57a55c0b323fc08ccd88659dc52056bb39dfeb5cedafb59"
checksum = "e63257bb5f8d7a707d626aa1b4e464c3b9720edd168b73cee98f48f0dd6386e4"
dependencies = [
"frame-metadata",
"parity-scale-codec",
"scale-decode",
"scale-encode",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"serde_yaml",
"sp-crypto-hashing",
"thiserror 2.0.12",
]
@@ -1073,10 +1127,23 @@ checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash",
"foldhash 0.1.5",
"serde",
]
[[package]]
name = "hashbrown"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash 0.2.0",
"serde",
"serde_core",
]
[[package]]
name = "heck"
version = "0.5.0"
@@ -1373,9 +1440,9 @@ dependencies = [
[[package]]
name = "itertools"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
dependencies = [
"either",
]
@@ -1583,12 +1650,6 @@ dependencies = [
"zeroize",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.8.8"
@@ -1612,12 +1673,11 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "nom"
version = "7.1.3"
version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
@@ -1727,6 +1787,15 @@ dependencies = [
"digest 0.10.7",
]
[[package]]
name = "pem-rfc7468"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
dependencies = [
"base64ct",
]
[[package]]
name = "percent-encoding"
version = "2.3.1"
@@ -1776,6 +1845,16 @@ dependencies = [
"thiserror 1.0.69",
]
[[package]]
name = "pkcs8"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
dependencies = [
"der",
"spki",
]
[[package]]
name = "poly1305"
version = "0.8.0"
@@ -1986,9 +2065,9 @@ checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
[[package]]
name = "ruzstd"
version = "0.7.3"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f"
checksum = "e5ff0cc5e135c8870a775d3320910cd9b564ec036b4dc0b8741629020be63f01"
[[package]]
name = "ryu"
@@ -2010,9 +2089,9 @@ dependencies = [
[[package]]
name = "scale-decode"
version = "0.16.0"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d78196772d25b90a98046794ce0fe2588b39ebdfbdc1e45b4c6c85dd43bebad"
checksum = "8d6ed61699ad4d54101ab5a817169259b5b0efc08152f8632e61482d8a27ca3d"
dependencies = [
"parity-scale-codec",
"primitive-types",
@@ -2025,9 +2104,9 @@ dependencies = [
[[package]]
name = "scale-decode-derive"
version = "0.16.0"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4b54a1211260718b92832b661025d1f1a4b6930fbadd6908e00edd265fa5f7"
checksum = "65cb245f7fdb489e7ba43a616cbd34427fe3ba6fe0edc1d0d250085e6c84f3ec"
dependencies = [
"darling",
"proc-macro2",
@@ -2037,9 +2116,9 @@ dependencies = [
[[package]]
name = "scale-encode"
version = "0.10.0"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64901733157f9d25ef86843bd783eda439fac7efb0ad5a615d12d2cf3a29464b"
checksum = "f2a976d73564a59e482b74fd5d95f7518b79ca8c8ca5865398a4d629dd15ee50"
dependencies = [
"parity-scale-codec",
"primitive-types",
@@ -2071,7 +2150,7 @@ checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b"
dependencies = [
"bitvec",
"cfg-if",
"derive_more",
"derive_more 1.0.0",
"parity-scale-codec",
"scale-info-derive",
"serde",
@@ -2089,6 +2168,21 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "scale-info-legacy"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afb76e1b2cb589b97278e2f1e2e290c9b7c51d6ac69afab9e1d7d1e136a9276"
dependencies = [
"hashbrown 0.16.1",
"scale-type-resolver",
"serde",
"smallstr",
"smallvec",
"thiserror 2.0.12",
"yap",
]
[[package]]
name = "scale-type-resolver"
version = "0.2.0"
@@ -2101,9 +2195,9 @@ dependencies = [
[[package]]
name = "scale-typegen"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c61b6b706a3eaad63b506ab50a1d2319f817ae01cf753adcc3f055f9f0fcd6"
checksum = "642d2f13f3fc9a34ea2c1e36142984eba78cd2405a61632492f8b52993e98879"
dependencies = [
"proc-macro2",
"quote",
@@ -2170,10 +2264,11 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]]
name = "serde"
version = "1.0.219"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
@@ -2198,10 +2293,19 @@ dependencies = [
]
[[package]]
name = "serde_derive"
version = "1.0.219"
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
@@ -2232,6 +2336,19 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap 2.9.0",
"itoa",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]]
name = "sha1"
version = "0.10.6"
@@ -2298,6 +2415,15 @@ dependencies = [
"autocfg",
]
[[package]]
name = "smallstr"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "862077b1e764f04c251fe82a2ef562fd78d7cadaeb072ca7c2bcaf7217b1ff3b"
dependencies = [
"smallvec",
]
[[package]]
name = "smallvec"
version = "1.15.0"
@@ -2306,9 +2432,9 @@ checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
[[package]]
name = "smoldot"
version = "0.19.3"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6664ea2d3d3c1d77b8f24032aca6462dc0da8378d25c5bdde6130699b6740fe"
checksum = "724ab10d6485cccb4bab080ce436c0b361295274aec7847d7ba84ab1a79a5132"
dependencies = [
"arrayvec 0.7.6",
"async-lock",
@@ -2319,7 +2445,7 @@ dependencies = [
"bs58",
"chacha20",
"crossbeam-queue",
"derive_more",
"derive_more 2.1.0",
"ed25519-zebra",
"either",
"event-listener",
@@ -2360,16 +2486,16 @@ dependencies = [
[[package]]
name = "smoldot-light"
version = "0.17.1"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bad7762a41b43cc95e5253214ca8f85a2308a048f4fe8217927888065bafd30c"
checksum = "e8b4d4971f06f2471f4e57a662dbe8047fa0cc020957764a6211f3fad371f7bd"
dependencies = [
"async-channel",
"async-lock",
"base64",
"blake2-rfc",
"bs58",
"derive_more",
"derive_more 2.1.0",
"either",
"event-listener",
"fnv",
@@ -2426,6 +2552,16 @@ version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "spki"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
dependencies = [
"base64ct",
"der",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
@@ -2452,41 +2588,45 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "subxt"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"async-trait",
"derive-where",
"either",
"frame-decode",
"frame-metadata",
"futures",
"hex",
"impl-serde",
"jsonrpsee",
"keccak-hash",
"parity-scale-codec",
"primitive-types",
"scale-bits",
"scale-decode",
"scale-encode",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"scale-value",
"serde",
"serde_json",
"sp-crypto-hashing",
"subxt-core",
"subxt-lightclient",
"subxt-macro",
"subxt-metadata",
"subxt-rpcs",
"subxt-utils-accountid32",
"thiserror 2.0.12",
"tokio",
"tracing",
"url",
"wasm-bindgen-futures",
"web-time",
]
[[package]]
name = "subxt-codegen"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"getrandom",
"heck",
@@ -2500,37 +2640,9 @@ dependencies = [
"thiserror 2.0.12",
]
[[package]]
name = "subxt-core"
version = "0.44.0"
dependencies = [
"base58",
"blake2",
"derive-where",
"frame-decode",
"frame-metadata",
"hashbrown 0.14.5",
"hex",
"impl-serde",
"keccak-hash",
"parity-scale-codec",
"primitive-types",
"scale-bits",
"scale-decode",
"scale-encode",
"scale-info",
"scale-value",
"serde",
"serde_json",
"sp-crypto-hashing",
"subxt-metadata",
"thiserror 2.0.12",
"tracing",
]
[[package]]
name = "subxt-lightclient"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"futures",
"futures-timer",
@@ -2555,7 +2667,7 @@ dependencies = [
[[package]]
name = "subxt-macro"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"darling",
"parity-scale-codec",
@@ -2570,20 +2682,22 @@ dependencies = [
[[package]]
name = "subxt-metadata"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"frame-decode",
"frame-metadata",
"hashbrown 0.14.5",
"parity-scale-codec",
"scale-info",
"scale-info-legacy",
"scale-type-resolver",
"sp-crypto-hashing",
"thiserror 2.0.12",
]
[[package]]
name = "subxt-rpcs"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"derive-where",
"finito",
@@ -2597,7 +2711,6 @@ dependencies = [
"primitive-types",
"serde",
"serde_json",
"subxt-core",
"subxt-lightclient",
"thiserror 2.0.12",
"tokio-util",
@@ -2606,9 +2719,23 @@ dependencies = [
"wasm-bindgen-futures",
]
[[package]]
name = "subxt-utils-accountid32"
version = "0.50.0"
dependencies = [
"base58",
"blake2",
"parity-scale-codec",
"scale-decode",
"scale-encode",
"scale-info",
"serde",
"thiserror 2.0.12",
]
[[package]]
name = "subxt-utils-fetchmetadata"
version = "0.44.0"
version = "0.50.0"
dependencies = [
"hex",
"parity-scale-codec",
@@ -2831,7 +2958,6 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if",
"digest 0.10.7",
"rand",
"static_assertions",
]
@@ -2887,6 +3013,12 @@ dependencies = [
"subtle",
]
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]]
name = "url"
version = "2.5.4"
+39 -26
View File
@@ -1,7 +1,7 @@
use anyhow::anyhow;
use futures::FutureExt;
use subxt::{OnlineClient, PolkadotConfig};
use subxt::{client::OnlineClientAtBlockImpl, OnlineClient, OnlineClientAtBlock, PolkadotConfig};
use subxt::config::DefaultExtrinsicParamsBuilder;
use subxt::ext::codec::{Decode, Encode};
@@ -16,7 +16,7 @@ use yew::prelude::*;
pub struct SigningExamplesComponent {
message: String,
remark_call_bytes: Vec<u8>,
online_client: Option<OnlineClient<PolkadotConfig>>,
online_client: Option<OnlineClientAtBlock<PolkadotConfig>>,
stage: SigningStage,
}
@@ -25,9 +25,9 @@ impl SigningExamplesComponent {
/// panics if self.online_client is None.
fn set_message(&mut self, message: String) {
let remark_call = polkadot::tx().system().remark(message.as_bytes().to_vec());
let online_client = self.online_client.as_ref().unwrap();
let online_client_at_block = self.online_client.as_ref().unwrap();
let remark_call_bytes = remark_call
.encode_call_data(&online_client.metadata())
.encode_call_data(online_client_at_block.metadata_ref())
.unwrap();
self.remark_call_bytes = remark_call_bytes;
self.message = message;
@@ -51,7 +51,8 @@ pub enum SigningStage {
pub enum SubmittingStage {
Initial {
signed_extrinsic: SubmittableTransaction<PolkadotConfig, OnlineClient<PolkadotConfig>>,
signed_extrinsic:
SubmittableTransaction<PolkadotConfig, OnlineClientAtBlockImpl<PolkadotConfig>>,
},
Submitting,
Success {
@@ -62,7 +63,7 @@ pub enum SubmittingStage {
pub enum Message {
Error(anyhow::Error),
OnlineClientCreated(OnlineClient<PolkadotConfig>),
OnlineClientCreated(OnlineClientAtBlock<PolkadotConfig>),
ChangeMessage(String),
RequestAccounts,
ReceivedAccounts(Vec<Account>),
@@ -70,7 +71,7 @@ pub enum Message {
SignWithAccount(usize),
ReceivedSignature(
MultiSignature,
SubmittableTransaction<PolkadotConfig, OnlineClient<PolkadotConfig>>,
SubmittableTransaction<PolkadotConfig, OnlineClientAtBlockImpl<PolkadotConfig>>,
),
SubmitSigned,
ExtrinsicFinalized {
@@ -85,12 +86,20 @@ impl Component for SigningExamplesComponent {
type Properties = ();
fn create(ctx: &Context<Self>) -> Self {
ctx.link().send_future(OnlineClient::<PolkadotConfig>::new().map(|res| {
match res {
Ok(online_client) => Message::OnlineClientCreated(online_client),
Err(err) => Message::Error(anyhow!("Online Client could not be created. Make sure you have a local node running:\n{err}")),
}
}));
ctx.link().send_future(async {
let conf = PolkadotConfig::new();
let Ok(client) = OnlineClient::new(conf).await else {
return Message::Error(anyhow!(
"OnlineClient could not be created. Make sure you have a local node running\n"
));
};
let Ok(at_block) = client.at_current_block().await else {
return Message::Error(anyhow!(
"OnlineClient could not obtain current block details\n"
));
};
Message::OnlineClientCreated(at_block)
});
SigningExamplesComponent {
message: "".to_string(),
stage: SigningStage::CreatingOnlineClient,
@@ -101,8 +110,8 @@ impl Component for SigningExamplesComponent {
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
match msg {
Message::OnlineClientCreated(online_client) => {
self.online_client = Some(online_client);
Message::OnlineClientCreated(online_client_at_block) => {
self.online_client = Some(online_client_at_block);
self.stage = SigningStage::EnterMessage;
self.set_message("Hello".into());
}
@@ -135,20 +144,21 @@ impl Component for SigningExamplesComponent {
.system()
.remark(self.message.as_bytes().to_vec());
let api = self.online_client.as_ref().unwrap().clone();
let at_block = self.online_client.clone().unwrap();
ctx.link().send_future(async move {
let Ok(account_nonce) = api.tx().account_nonce(&account_id).await else {
let Ok(account_nonce) = at_block.tx().account_nonce(&account_id).await
else {
return Message::Error(anyhow!("Fetching account nonce failed"));
};
let Ok(call_data) = api.tx().call_data(&remark_call) else {
let Ok(call_data) = at_block.tx().call_data(&remark_call) else {
return Message::Error(anyhow!("could not encode call data"));
};
let Ok(signature) = extension_signature_for_extrinsic(
&call_data,
&api,
&at_block,
account_nonce,
account_source,
account_address,
@@ -166,15 +176,15 @@ impl Component for SigningExamplesComponent {
let params = DefaultExtrinsicParamsBuilder::new()
.nonce(account_nonce)
.build();
let Ok(mut partial_signed) =
api.tx().create_partial_offline(&remark_call, params)
let Ok(mut signable) =
at_block.tx().create_signable_offline(&remark_call, params)
else {
return Message::Error(anyhow!("PartialTransaction creation failed"));
};
// Apply the signature
let signed_extrinsic = partial_signed
.sign_with_account_and_signature(&account_id, &multi_signature);
let signed_extrinsic =
signable.sign_with_account_and_signature(&account_id, &multi_signature);
// check the TX validity (to debug in the js console if the extrinsic would work)
let dry_res = signed_extrinsic.validate().await;
@@ -394,7 +404,7 @@ impl Component for SigningExamplesComponent {
}
async fn submit_wait_finalized_and_get_extrinsic_success_event(
extrinsic: SubmittableTransaction<PolkadotConfig, OnlineClient<PolkadotConfig>>,
extrinsic: SubmittableTransaction<PolkadotConfig, OnlineClientAtBlockImpl<PolkadotConfig>>,
) -> Result<polkadot::system::events::ExtrinsicSuccess, anyhow::Error> {
let events = extrinsic
.submit_and_watch()
@@ -408,6 +418,9 @@ async fn submit_wait_finalized_and_get_extrinsic_success_event(
web_sys::console::log_1(&format!("{:?}", event).into());
}
let success = events.find_first::<polkadot::system::events::ExtrinsicSuccess>()?;
success.ok_or(anyhow!("ExtrinsicSuccess not found in events"))
let success = events
.find_first::<polkadot::system::events::ExtrinsicSuccess>()
.ok_or(anyhow!("ExtrinsicSuccess not found in events"))??;
Ok(success)
}
+32 -18
View File
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use serde_json::json;
use std::fmt::Write;
use subxt::ext::codec::{Compact, Encode};
use subxt::{self, OnlineClient, PolkadotConfig};
use subxt::{self, OnlineClient, OnlineClientAtBlock, PolkadotConfig};
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;
use yew::{AttrValue, Callback};
@@ -13,22 +13,28 @@ use yew::{AttrValue, Callback};
pub mod polkadot {}
pub(crate) async fn fetch_constant_block_length() -> Result<String, subxt::Error> {
let api = OnlineClient::<PolkadotConfig>::new().await?;
let config = PolkadotConfig::new();
let api = OnlineClient::new(config).await?;
let constant_query = polkadot::constants().system().block_length();
let value = api.constants().at(&constant_query)?;
let value = api
.at_current_block()
.await?
.constants()
.entry(&constant_query)?;
Ok(format!("{value:?}"))
}
pub(crate) async fn fetch_events_dynamically() -> Result<Vec<String>, subxt::Error> {
let api = OnlineClient::<PolkadotConfig>::new().await?;
let events = api.events().at_latest().await?;
let config = PolkadotConfig::new();
let api = OnlineClient::new(config).await?;
let events = api.at_current_block().await?.events().fetch().await?;
let mut event_strings = Vec::<String>::new();
for event in events.iter() {
let event = event?;
let pallet = event.pallet_name();
let variant = event.variant_name();
let field_values = event.decode_as_fields::<subxt::dynamic::Value>()?;
let variant = event.event_name();
let field_values = event.decode_fields_unchecked_as::<subxt::dynamic::Value>()?;
event_strings.push(format!("{pallet}::{variant}: {field_values}"));
}
Ok(event_strings)
@@ -38,23 +44,28 @@ pub(crate) async fn fetch_events_dynamically() -> Result<Vec<String>, subxt::Err
pub(crate) async fn subscribe_to_finalized_blocks(
cb: Callback<AttrValue>,
) -> Result<(), subxt::Error> {
let api = OnlineClient::<PolkadotConfig>::new().await?;
let config = PolkadotConfig::new();
let api = OnlineClient::new(config).await?;
// Subscribe to all finalized blocks:
let mut blocks_sub = api.blocks().subscribe_finalized().await?;
let mut blocks_sub = api.stream_blocks().await?;
while let Some(block) = blocks_sub.next().await {
let block = block?;
let mut output = String::new();
writeln!(output, "Block #{}:", block.header().number).ok();
writeln!(output, " Hash: {}", block.hash()).ok();
writeln!(output, " Extrinsics:").ok();
let extrinsics = block.extrinsics().await?;
let at_block = block.at().await?;
let extrinsics = at_block.extrinsics().fetch().await?;
for ext in extrinsics.iter() {
let ext = ext?;
let idx = ext.index();
let events = ext.events().await?;
let bytes_hex = format!("0x{}", hex::encode(ext.bytes()));
// See the API docs for more ways to decode extrinsics:
let decoded_ext = ext.as_root_extrinsic::<polkadot::Call>();
let decoded_ext = ext.decode_call_data_as::<polkadot::Call>();
writeln!(output, " Extrinsic #{idx}:").ok();
writeln!(output, " Bytes: {bytes_hex}").ok();
@@ -65,8 +76,8 @@ pub(crate) async fn subscribe_to_finalized_blocks(
let evt = evt?;
let pallet_name = evt.pallet_name();
let event_name = evt.variant_name();
let event_values = evt.decode_as_fields::<subxt::dynamic::Value>()?;
let event_name = evt.event_name();
let event_values = evt.decode_fields_unchecked_as::<subxt::dynamic::Value>()?;
writeln!(output, " {pallet_name}_{event_name}").ok();
writeln!(output, " {}", event_values).ok();
@@ -122,15 +133,18 @@ fn encode_then_hex<E: Encode>(input: &E) -> String {
/// Some parameters are hard-coded here and not taken from the partial_extrinsic itself (mortality_checkpoint, era, tip).
pub async fn extension_signature_for_extrinsic(
call_data: &[u8],
api: &OnlineClient<PolkadotConfig>,
api: &OnlineClientAtBlock<PolkadotConfig>,
account_nonce: u64,
account_source: String,
account_address: String,
) -> Result<Vec<u8>, anyhow::Error> {
let genesis_hash = encode_then_hex(&api.genesis_hash());
let genesis_hash = encode_then_hex(
&api.genesis_hash()
.expect("Should always exist via OnlineClient"),
);
// These numbers aren't SCALE encoded; their bytes are just converted to hex:
let spec_version = to_hex(&api.runtime_version().spec_version.to_be_bytes());
let transaction_version = to_hex(&api.runtime_version().transaction_version.to_be_bytes());
let spec_version = to_hex(&api.spec_version().to_be_bytes());
let transaction_version = to_hex(&api.transaction_version().to_be_bytes());
let nonce = to_hex(&account_nonce.to_be_bytes());
// If you construct a mortal transaction, then this block hash needs to correspond
// to the block number passed to `Era::mortal()`.
@@ -138,7 +152,7 @@ pub async fn extension_signature_for_extrinsic(
let era = encode_then_hex(&subxt::utils::Era::Immortal);
let method = to_hex(call_data);
let signed_extensions: Vec<String> = api
.metadata()
.metadata_ref()
.extrinsic()
.transaction_extensions_by_version(0)
.unwrap()
+26 -4
View File
@@ -60,13 +60,13 @@ where
{
/// Construct and submit transactions. This is a
/// shorthand to [`Self::transactions()`].
pub fn tx(&self) -> TransactionsClient<'_, T, Client> {
TransactionsClient::new(&self.client)
pub fn tx(&self) -> TransactionsClient<T, Client> {
self.transactions()
}
/// Construct and submit transactions.
pub fn transactions(&self) -> TransactionsClient<'_, T, Client> {
TransactionsClient::new(&self.client)
pub fn transactions(&self) -> TransactionsClient<T, Client> {
TransactionsClient::new(self.client.clone())
}
/// Access storage at this block.
@@ -113,6 +113,23 @@ where
pub fn block_number(&self) -> u64 {
self.client.block_number()
}
/// The spec version at this block.
pub fn spec_version(&self) -> u32 {
self.client.spec_version()
}
/// The transaction version at this block.
/// Note: This is different from the value encoded at the start of extrinsics.
pub fn transaction_version(&self) -> u32 {
self.client.transaction_version()
}
/// Return the genesis hash, if it is available. if you're using an
/// [`OnlineClientAtBlock`], this will always be present.
pub fn genesis_hash(&self) -> Option<HashFor<T>> {
self.client.genesis_hash()
}
}
impl<T, Client> ClientAtBlock<T, Client>
@@ -120,6 +137,11 @@ where
T: Config,
Client: OnlineClientAtBlockT<T>,
{
/// Return the [`OnlineClient`] behind this.
pub fn online_client(&self) -> OnlineClient<T> {
self.client.client()
}
/// The current block hash.
pub fn block_hash(&self) -> HashFor<T> {
self.client.block_hash()
+21 -11
View File
@@ -7,13 +7,13 @@ use crate::backend::{Backend, BlockRef, CombinedBackend};
use crate::config::{Config, HashFor, Hasher, Header};
use crate::error::{BlocksError, OnlineClientAtBlockError};
use crate::metadata::{ArcMetadata, Metadata};
use crate::transactions::TransactionsClient;
use blocks::Blocks;
use codec::{Compact, Decode, Encode};
use core::marker::PhantomData;
use frame_decode::helpers::ToTypeRegistry;
use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
use scale_info_legacy::TypeRegistrySet;
use std::future::Future;
use std::sync::Arc;
use subxt_rpcs::RpcClient;
@@ -125,6 +125,22 @@ impl<T: Config> OnlineClient<T> {
})
}
/// Return the genesis hash of the connected chain.
pub fn genesis_hash(&self) -> HashFor<T> {
self.inner.genesis_hash
}
/// Construct, sign and submit transactions. This is an alias for `self.at_current_block().await?.transactions()`.
pub async fn transactions(&self) -> Result<TransactionsClient<T, OnlineClientAtBlockImpl<T>>, OnlineClientAtBlockError> {
let at_block = self.at_current_block().await?;
Ok(at_block.transactions())
}
/// Construct, sign and submit transactions. This is an alias for `self.transactions()`.
pub async fn tx(&self) -> Result<TransactionsClient<T, OnlineClientAtBlockImpl<T>>, OnlineClientAtBlockError> {
self.transactions().await
}
/// Obtain a stream of all blocks imported by the node.
///
/// **Note:** You probably want to use [`Self::stream_blocks()`] most of
@@ -438,11 +454,8 @@ pub trait OnlineClientAtBlockT<T: Config>: OfflineClientAtBlockT<T> {
fn backend(&self) -> &dyn Backend<T>;
/// Return the block hash for the current block.
fn block_hash(&self) -> HashFor<T>;
/// Point at a new block.
fn at_block(
&self,
number_or_hash: BlockNumberOrRef<T>,
) -> impl Future<Output = Result<ClientAtBlock<T, Self>, OnlineClientAtBlockError>>;
/// Return the inner [`OnlineClient`].
fn client(&self) -> OnlineClient<T>;
}
/// An implementation of the [`OnlineClientAtBlockImpl`] trait, which is used in conjunction
@@ -466,11 +479,8 @@ impl<T: Config> OnlineClientAtBlockT<T> for OnlineClientAtBlockImpl<T> {
fn block_hash(&self) -> HashFor<T> {
self.block_ref.hash()
}
async fn at_block(
&self,
number_or_hash: BlockNumberOrRef<T>,
) -> Result<ClientAtBlock<T, Self>, OnlineClientAtBlockError> {
self.client.at_block(number_or_hash).await
fn client(&self) -> OnlineClient<T> {
self.client.clone()
}
}
+42 -41
View File
@@ -41,13 +41,13 @@ pub use validation_result::{
/// A client for working with transactions. See [the module docs](crate::transactions) for more.
#[derive(Clone)]
pub struct TransactionsClient<'atblock, T, Client> {
client: &'atblock Client,
pub struct TransactionsClient<T, Client> {
client: Client,
marker: PhantomData<T>,
}
impl<'atblock, T, Client> TransactionsClient<'atblock, T, Client> {
pub(crate) fn new(client: &'atblock Client) -> Self {
impl<T, Client> TransactionsClient<T, Client> {
pub(crate) fn new(client: Client) -> Self {
TransactionsClient {
client,
marker: PhantomData,
@@ -55,8 +55,8 @@ impl<'atblock, T, Client> TransactionsClient<'atblock, T, Client> {
}
}
impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
TransactionsClient<'atblock, T, Client>
impl<T: Config, Client: OfflineClientAtBlockT<T>>
TransactionsClient<T, Client>
{
/// Run the validation logic against some transaction you'd like to submit. Returns `Ok(())`
/// if the call is valid (or if it's not possible to check since the call has no validation hash).
@@ -95,11 +95,11 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
/// transaction bytes, and some client (anything implementing [`OfflineClientAtBlockT`]
/// or [`OnlineClientAtBlockT`]).
pub fn from_bytes(
client: &'atblock Client,
&self,
tx_bytes: Vec<u8>,
) -> SubmittableTransaction<'atblock, T, Client> {
) -> SubmittableTransaction<T, Client> {
SubmittableTransaction {
client,
client: self.client.clone(),
encoded: tx_bytes,
marker: PhantomData,
}
@@ -122,7 +122,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
pub fn create_unsigned<Call>(
&self,
call: &Call,
) -> Result<SubmittableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SubmittableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -138,7 +138,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
pub fn create_v4_unsigned<Call>(
&self,
call: &Call,
) -> Result<SubmittableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SubmittableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -149,7 +149,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
pub fn create_v5_unsigned<Call>(
&self,
call: &Call,
) -> Result<SubmittableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SubmittableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -166,7 +166,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
&self,
call: &Call,
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SignableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SignableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -187,7 +187,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
&self,
call: &Call,
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SignableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SignableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -205,7 +205,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
&self,
call: &Call,
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SignableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SignableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -237,7 +237,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
&self,
call: &Call,
tx_version: SupportedTransactionVersion,
) -> Result<SubmittableTransaction<'atblock, T, Client>, ExtrinsicError> {
) -> Result<SubmittableTransaction<T, Client>, ExtrinsicError> {
let metadata = self.client.metadata_ref();
// 1. Validate this call against the current node metadata if the call comes
@@ -263,7 +263,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
// Wrap in Encoded to ensure that any more "encode" calls leave it in the right state.
Ok(SubmittableTransaction {
client: self.client,
client: self.client.clone(),
encoded: extrinsic,
marker: PhantomData,
})
@@ -275,7 +275,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
call: &Call,
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
tx_version: SupportedTransactionVersion,
) -> Result<SignableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SignableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -314,7 +314,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
// Return these details, ready to construct a signed extrinsic from.
Ok(SignableTransaction {
client: self.client,
client: self.client.clone(),
call_data,
additional_and_extra_params,
tx_extension_version,
@@ -322,10 +322,10 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
}
}
impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<'atblock, T, Client> {
impl<T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<T, Client> {
/// Get the account nonce for a given account ID.
pub async fn account_nonce(&self, account_id: &T::AccountId) -> Result<u64, ExtrinsicError> {
account_nonce::get_account_nonce(self.client, account_id)
account_nonce::get_account_nonce(&self.client, account_id)
.await
.map_err(|e| ExtrinsicError::AccountNonceError {
block_hash: self.client.block_hash().into(),
@@ -340,7 +340,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<'a
call: &Call,
account_id: &T::AccountId,
mut params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SignableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SignableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -358,7 +358,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<'a
call: &Call,
account_id: &T::AccountId,
mut params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SignableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SignableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -376,7 +376,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<'a
call: &Call,
account_id: &T::AccountId,
mut params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SignableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SignableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
{
@@ -391,7 +391,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<'a
call: &Call,
signer: &S,
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<SubmittableTransaction<'atblock, T, Client>, ExtrinsicError>
) -> Result<SubmittableTransaction<T, Client>, ExtrinsicError>
where
Call: Payload,
S: Signer<T>,
@@ -412,7 +412,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<'a
&mut self,
call: &Call,
signer: &S,
) -> Result<TransactionProgress<'atblock, T, Client>, ExtrinsicError>
) -> Result<TransactionProgress<T, Client>, ExtrinsicError>
where
Call: Payload,
S: Signer<T>,
@@ -431,7 +431,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>> TransactionsClient<'a
call: &Call,
signer: &S,
params: <T::ExtrinsicParams as ExtrinsicParams<T>>::Params,
) -> Result<TransactionProgress<'atblock, T, Client>, ExtrinsicError>
) -> Result<TransactionProgress<T, Client>, ExtrinsicError>
where
Call: Payload,
S: Signer<T>,
@@ -534,16 +534,16 @@ pub enum SupportedTransactionVersion {
}
/// This is a transaction that requires signing before it can be submitted.
pub struct SignableTransaction<'atblock, T: Config, Client> {
client: &'atblock Client,
pub struct SignableTransaction<T: Config, Client> {
client: Client,
call_data: Vec<u8>,
additional_and_extra_params: <T as Config>::ExtrinsicParams,
// For V4 transactions this doesn't exist, and for V5 it does.
tx_extension_version: Option<u8>,
}
impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
SignableTransaction<'atblock, T, Client>
impl<T: Config, Client: OfflineClientAtBlockT<T>>
SignableTransaction<T, Client>
{
/// Return the bytes representing the call data for this partially constructed
/// transaction.
@@ -563,7 +563,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
pub fn sign<S: Signer<T>>(
&mut self,
signer: &S,
) -> SubmittableTransaction<'atblock, T, Client> {
) -> SubmittableTransaction<T, Client> {
// Given our signer, we can sign the payload representing this extrinsic.
let signature = signer.sign(&self.signer_payload());
// Now, use the signature and "from" account to build the extrinsic.
@@ -578,7 +578,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
&mut self,
account_id: &T::AccountId,
signature: &T::Signature,
) -> SubmittableTransaction<'atblock, T, Client> {
) -> SubmittableTransaction<T, Client> {
let encoded = if let Some(tx_extensions_version) = self.tx_extension_version {
let mut encoded_inner = Vec::new();
// Pass account and signature to extensions to be added.
@@ -626,7 +626,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
};
SubmittableTransaction {
client: self.client,
client: self.client.clone(),
encoded,
marker: PhantomData,
}
@@ -660,13 +660,14 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
}
/// This is a transaction that is ready to submit.
pub struct SubmittableTransaction<'atblock, T, Client> {
client: &'atblock Client,
#[derive(Debug, Clone)]
pub struct SubmittableTransaction<T, Client> {
client: Client,
encoded: Vec<u8>,
marker: PhantomData<T>,
}
impl<'atblock, T, Client> SubmittableTransaction<'atblock, T, Client>
impl<T, Client> SubmittableTransaction<T, Client>
where
T: Config,
Client: OfflineClientAtBlockT<T>,
@@ -688,8 +689,8 @@ where
}
}
impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>>
SubmittableTransaction<'atblock, T, Client>
impl<T: Config, Client: OnlineClientAtBlockT<T>>
SubmittableTransaction<T, Client>
{
/// Submits the transaction to the chain.
///
@@ -697,7 +698,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>>
/// and obtain details about it, once it has made it into a block.
pub async fn submit_and_watch(
&self,
) -> Result<TransactionProgress<'atblock, T, Client>, ExtrinsicError> {
) -> Result<TransactionProgress<T, Client>, ExtrinsicError> {
// Get a hash of the transaction (we'll need this later).
let ext_hash = self.hash();
@@ -709,7 +710,7 @@ impl<'atblock, T: Config, Client: OnlineClientAtBlockT<T>>
.await
.map_err(ExtrinsicError::ErrorSubmittingTransaction)?;
Ok(TransactionProgress::new(sub, self.client, ext_hash))
Ok(TransactionProgress::new(sub, self.client.clone(), ext_hash))
}
/// Submits the transaction to the chain for block inclusion.
+26 -25
View File
@@ -1,6 +1,6 @@
use crate::backend::BlockRef;
use crate::backend::{StreamOfResults, TransactionStatus as BackendTransactionStatus};
use crate::client::{BlockNumberOrRef, OnlineClientAtBlockT};
use crate::client::{BlockNumberOrRef, OfflineClientAtBlockT, OnlineClientAtBlockT};
use crate::config::{Config, HashFor};
use crate::error::{
DispatchError, TransactionEventsError, TransactionFinalizedSuccessError,
@@ -17,22 +17,22 @@ use std::task::{Context, Poll};
/// [`TransactionProgress::wait_for_finalized_success`] can be used to wait
/// for completion.
#[derive(Debug)]
pub struct TransactionProgress<'atblock, T: Config, C> {
pub struct TransactionProgress<T: Config, C> {
sub: Option<StreamOfResults<BackendTransactionStatus<HashFor<T>>>>,
ext_hash: HashFor<T>,
client: &'atblock C,
client: C,
}
// The above type is not `Unpin` by default unless the generic param `T` is,
// so we manually make it clear that Unpin is actually fine regardless of `T`
// (we don't care if this moves around in memory while it's "pinned").
impl<'atblock, T: Config, C> Unpin for TransactionProgress<'atblock, T, C> {}
impl<T: Config, C> Unpin for TransactionProgress<T, C> {}
impl<'atblock, T: Config, C> TransactionProgress<'atblock, T, C> {
impl<T: Config, C> TransactionProgress<T, C> {
/// Instantiate a new [`TransactionProgress`] from a custom subscription.
pub fn new(
pub(crate) fn new(
sub: StreamOfResults<BackendTransactionStatus<HashFor<T>>>,
client: &'atblock C,
client: C,
ext_hash: HashFor<T>,
) -> Self {
Self {
@@ -48,7 +48,7 @@ impl<'atblock, T: Config, C> TransactionProgress<'atblock, T, C> {
}
}
impl<'atblock, T, C> TransactionProgress<'atblock, T, C>
impl<T, C> TransactionProgress<T, C>
where
T: Config,
C: OnlineClientAtBlockT<T>,
@@ -58,7 +58,7 @@ where
/// avoid importing that trait if you don't otherwise need it.
pub async fn next(
&mut self,
) -> Option<Result<TransactionStatus<'atblock, T, C>, TransactionProgressError>> {
) -> Option<Result<TransactionStatus<T, C>, TransactionProgressError>> {
StreamExt::next(self).await
}
@@ -74,7 +74,7 @@ where
/// out if they finally made it into a block or not.
pub async fn wait_for_finalized(
mut self,
) -> Result<TransactionInBlock<'atblock, T, C>, TransactionProgressError> {
) -> Result<TransactionInBlock<T, C>, TransactionProgressError> {
while let Some(status) = self.next().await {
match status? {
// Finalized! Return.
@@ -116,8 +116,8 @@ where
}
// TransactionProgress is a stream of transaction events
impl<'atblock, T: Config, C: Clone> Stream for TransactionProgress<'atblock, T, C> {
type Item = Result<TransactionStatus<'atblock, T, C>, TransactionProgressError>;
impl<T: Config, C: Clone> Stream for TransactionProgress<T, C> {
type Item = Result<TransactionStatus<T, C>, TransactionProgressError>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let sub = match self.sub.as_mut() {
@@ -138,7 +138,7 @@ impl<'atblock, T: Config, C: Clone> Stream for TransactionProgress<'atblock, T,
TransactionStatus::InBestBlock(TransactionInBlock::new(
hash,
self.ext_hash,
self.client,
self.client.clone(),
))
}
// These stream events mean that nothing further will be sent:
@@ -147,7 +147,7 @@ impl<'atblock, T: Config, C: Clone> Stream for TransactionProgress<'atblock, T,
TransactionStatus::InFinalizedBlock(TransactionInBlock::new(
hash,
self.ext_hash,
self.client,
self.client.clone(),
))
}
BackendTransactionStatus::Error { message } => {
@@ -169,7 +169,7 @@ impl<'atblock, T: Config, C: Clone> Stream for TransactionProgress<'atblock, T,
/// Possible transaction statuses returned from our [`TransactionProgress::next()`] call.
#[derive(Debug)]
pub enum TransactionStatus<'atblock, T: Config, C> {
pub enum TransactionStatus<T: Config, C> {
/// Transaction is part of the future queue.
Validated,
/// The transaction has been broadcast to other nodes.
@@ -177,9 +177,9 @@ pub enum TransactionStatus<'atblock, T: Config, C> {
/// Transaction is no longer in a best block.
NoLongerInBestBlock,
/// Transaction has been included in block with given hash.
InBestBlock(TransactionInBlock<'atblock, T, C>),
InBestBlock(TransactionInBlock<T, C>),
/// Transaction has been finalized by a finality-gadget, e.g GRANDPA
InFinalizedBlock(TransactionInBlock<'atblock, T, C>),
InFinalizedBlock(TransactionInBlock<T, C>),
/// Something went wrong in the node.
Error {
/// Human readable message; what went wrong.
@@ -197,10 +197,10 @@ pub enum TransactionStatus<'atblock, T: Config, C> {
},
}
impl<'atblock, T: Config, C> TransactionStatus<'atblock, T, C> {
impl<T: Config, C> TransactionStatus<T, C> {
/// A convenience method to return the finalized details. Returns
/// [`None`] if the enum variant is not [`TransactionStatus::InFinalizedBlock`].
pub fn as_finalized(&self) -> Option<&TransactionInBlock<'atblock, T, C>> {
pub fn as_finalized(&self) -> Option<&TransactionInBlock<T, C>> {
match self {
Self::InFinalizedBlock(val) => Some(val),
_ => None,
@@ -209,7 +209,7 @@ impl<'atblock, T: Config, C> TransactionStatus<'atblock, T, C> {
/// A convenience method to return the best block details. Returns
/// [`None`] if the enum variant is not [`TransactionStatus::InBestBlock`].
pub fn as_in_block(&self) -> Option<&TransactionInBlock<'atblock, T, C>> {
pub fn as_in_block(&self) -> Option<&TransactionInBlock<T, C>> {
match self {
Self::InBestBlock(val) => Some(val),
_ => None,
@@ -219,17 +219,17 @@ impl<'atblock, T: Config, C> TransactionStatus<'atblock, T, C> {
/// This struct represents a transaction that has made it into a block.
#[derive(Debug)]
pub struct TransactionInBlock<'atblock, T: Config, C> {
pub struct TransactionInBlock<T: Config, C> {
block_ref: BlockRef<HashFor<T>>,
ext_hash: HashFor<T>,
client: &'atblock C,
client: C,
}
impl<'atblock, T: Config, C> TransactionInBlock<'atblock, T, C> {
impl<T: Config, C> TransactionInBlock<T, C> {
pub(crate) fn new(
block_ref: BlockRef<HashFor<T>>,
ext_hash: HashFor<T>,
client: &'atblock C,
client: C,
) -> Self {
Self {
block_ref,
@@ -249,7 +249,7 @@ impl<'atblock, T: Config, C> TransactionInBlock<'atblock, T, C> {
}
}
impl<'atblock, T: Config, C: OnlineClientAtBlockT<T>> TransactionInBlock<'atblock, T, C> {
impl<T: Config, C: OnlineClientAtBlockT<T>> TransactionInBlock<T, C> {
/// Fetch the events associated with this transaction. If the transaction
/// was successful (ie no `ExtrinsicFailed`) events were found, then we return
/// the events associated with it. If the transaction was not successful, or
@@ -300,6 +300,7 @@ impl<'atblock, T: Config, C: OnlineClientAtBlockT<T>> TransactionInBlock<'atbloc
let tx_block_ref = BlockNumberOrRef::BlockRef(self.block_ref.clone());
let at_tx_block = self
.client
.client()
.at_block(tx_block_ref)
.await
.map_err(TransactionEventsError::CannotInstantiateClientAtBlock)?;
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -180,12 +180,12 @@ mod test {
let local_account = AccountId32(substrate_account.clone().into());
// Both should encode to ss58 the same way:
let substrate_ss58 = substrate_account.ss58();
let substrate_ss58 = substrate_account.to_ss58check();
assert_eq!(substrate_ss58, local_account.ss58());
// Both should decode from ss58 back to the same:
assert_eq!(
sp_core::crypto::AccountId32::from_ss58(&substrate_ss58).unwrap(),
sp_core::crypto::AccountId32::from_ss58check(&substrate_ss58).unwrap(),
substrate_account
);
assert_eq!(