Skip to content

Commit 7de8d36

Browse files
authored
Prep to release v0.42.0 (#2003)
* Prep to release v0.42.0 * Remove test_context reference from example * standalone_crate for doc tests because codegen is expensive * fmt
1 parent 23c62f3 commit 7de8d36

File tree

27 files changed

+162
-61
lines changed

27 files changed

+162
-61
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ jobs:
253253
name: Check documentation and run doc tests
254254
runs-on: parity-large
255255
needs: [fmt, machete]
256+
timeout-minutes: 30
256257
steps:
257258
- name: Checkout sources
258259
uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,100 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.42.0] - 2025-05-09
8+
9+
The primary benefit of this release is introducing support for the [_about-to-be-stabilised-in-polkadot-sdk_](https://github.com/paritytech/polkadot-sdk/pull/8443) V16 metadata, and with that, support for calling Pallet View Functions on runtimes which will support this. Pallet View Functions are used much like Runtime APIs, except that they are declared in specific pallets and not declared at the runtime-wide level, allowing pallets to carry their own APIs with them.
10+
11+
### Pallet View Functions
12+
13+
Calling a Pallet View Function in this Subxt release will look like:
14+
15+
```rust
16+
use runtime::proxy::view_functions::check_permissions::{Call, ProxyType};
17+
18+
// Construct the call, providing the two arguments.
19+
let view_function_call = runtime::view_functions()
20+
.proxy()
21+
.check_permissions(
22+
Call::System(runtime::system::Call::remark { remark: b"hi".to_vec() }),
23+
ProxyType::Any
24+
);
25+
26+
// Submit the call and get back a result.
27+
let _is_call_allowed = api
28+
.view_functions()
29+
.at_latest()
30+
.await?
31+
.call(view_function_call)
32+
.await?;
33+
```
34+
35+
Like Runtime APIs and others, the dynamic API can also be used to call into Pallet View Functions, which has the advantage of not needing the statically generated interface, but the downside of not being strongly typed. This looks like the following:
36+
37+
```rust
38+
use scale_value::value;
39+
40+
let metadata = api.metadata();
41+
42+
// Look up the query ID for the View Function in the node metadata:
43+
let query_id = metadata
44+
.pallet_by_name("Proxy")
45+
.unwrap()
46+
.view_function_by_name("check_permissions")
47+
.unwrap()
48+
.query_id();
49+
50+
// Construct the call, providing the two arguments.
51+
let view_function_call = subxt::dynamic::view_function_call(
52+
*query_id,
53+
vec![
54+
value!(System(remark(b"hi".to_vec()))),
55+
value!(Any())
56+
],
57+
);
58+
59+
// Submit the call and get back a result.
60+
let _is_call_allowed = api
61+
.view_functions()
62+
.at_latest()
63+
.await?
64+
.call(view_function_call)
65+
.await?;
66+
```
67+
68+
### Updated `Config` trait
69+
70+
Another change to be aware of is that [our `Config` trait has been tweaked](https://github.com/paritytech/subxt/pull/1974). The `Hash` associated type is no longer needed, as it can be obtained via the `Hasher` associated type already, and `PolkadotConfig`/`SubstrateConfig` now set the hasher by default to be `DynamicHasher256`, which will (when V16 metadata is available for a runtime) automatically select between Keccak256 and BlakeTwo256 hashers depending on what the chain requires.
71+
72+
### Other changes
73+
74+
We also [solidify our support for V1 archive RPCs](https://github.com/paritytech/subxt/pull/1977), [upgrade the codebase to Rust 2024 edition](https://github.com/paritytech/subxt/pull/2001), and a bunch of other changes, the full list of which is here:
75+
76+
### Added
77+
78+
- Support v16 metadata and use it by default if it's available ([#1999](https://github.com/paritytech/subxt/pull/1999))
79+
- Metadata V16: Implement support for Pallet View Functions ([#1981](https://github.com/paritytech/subxt/pull/1981))
80+
- Metadata V16: Be more dynamic over which hasher is used. ([#1974](https://github.com/paritytech/subxt/pull/1974))
81+
82+
### Changed
83+
84+
- Update to 2024 edition ([#2001](https://github.com/paritytech/subxt/pull/2001))
85+
- Update Smoldot to latest version ([#1991](https://github.com/paritytech/subxt/pull/1991))
86+
- Update native test timeout to 45 mins ([#2002](https://github.com/paritytech/subxt/pull/2002))
87+
- chore(deps): tokio ^1.44.2 ([#1989](https://github.com/paritytech/subxt/pull/1989))
88+
- Add DefaultParams to allow more transaction extensions to be used when calling _default() methods ([#1979](https://github.com/paritytech/subxt/pull/1979))
89+
- Use wat instead of wabt to avoid CI cmake error (and use supported dep) ([#1980](https://github.com/paritytech/subxt/pull/1980))
90+
- Support v1 archive RPCs ([#1977](https://github.com/paritytech/subxt/pull/1977))
91+
- Support V16 metadata and refactor metadata code ([#1967](https://github.com/paritytech/subxt/pull/1967))
92+
- Allow submitting transactions ignoring follow events ([#1962](https://github.com/paritytech/subxt/pull/1962))
93+
- Improve error message regarding failure to extract metadata from WASM runtime ([#1961](https://github.com/paritytech/subxt/pull/1961))
94+
- Add docs for subxt-rpcs and fix example ([#1954](https://github.com/paritytech/subxt/pull/1954))
95+
96+
### Fixed
97+
98+
- Fix CLI storage diff ([#1958](https://github.com/paritytech/subxt/pull/1958))
99+
- chore: fix some typos ([#1997](https://github.com/paritytech/subxt/pull/1997))
100+
7101
## [0.41.0] - 2025-03-10
8102

9103
This release makes two main changes:

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/commands/diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use subxt_metadata::{
1818
/// Explore the differences between two nodes
1919
///
2020
/// # Example
21-
/// ```
21+
/// ```text
2222
/// subxt diff ./artifacts/polkadot_metadata_small.scale ./artifacts/polkadot_metadata_tiny.scale
2323
/// subxt diff ./artifacts/polkadot_metadata_small.scale wss://rpc.polkadot.io:443
2424
/// ```

cli/src/commands/explore/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mod runtime_apis;
2020
/// # Example
2121
///
2222
/// Show the pallets and runtime apis that are available:
23+
///
2324
/// ```text
2425
/// subxt explore --file=polkadot_metadata.scale
2526
/// ```

cli/src/commands/explore/runtime_apis/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use subxt_metadata::RuntimeApiMetadata;
1919

2020
/// Runs for a specified runtime API trait.
2121
/// Cases to consider:
22-
/// ```txt
22+
/// ```text
2323
/// method is:
2424
/// None => Show pallet docs + available methods
2525
/// Some (invalid) => Show Error + available methods

codegen/src/api/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::CodegenError;
1414
/// Generate constants from the provided pallet's metadata.
1515
///
1616
/// The function creates a new module named `constants` under the pallet's module.
17-
/// ```ignore
17+
/// ```rust,ignore
1818
/// pub mod PalletName {
1919
/// pub mod constants {
2020
/// ...

codegen/src/api/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use subxt_metadata::PalletMetadata;
1313
///
1414
/// The function creates a new module named `events` under the pallet's module.
1515
///
16-
/// ```ignore
16+
/// ```rust,ignore
1717
/// pub mod PalletName {
1818
/// pub mod events {
1919
/// ...
@@ -24,7 +24,7 @@ use subxt_metadata::PalletMetadata;
2424
/// The function generates the events as rust structs that implement the `subxt::event::StaticEvent` trait
2525
/// to uniquely identify the event's identity when creating the extrinsic.
2626
///
27-
/// ```ignore
27+
/// ```rust,ignore
2828
/// pub struct EventName {
2929
/// pub event_param: type,
3030
/// }

codegen/src/api/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,19 +410,24 @@ pub struct StructFromVariant {
410410
/// Returns the TokenStream of the type alias module.
411411
///
412412
/// E.g a struct like this:
413-
/// ```ignore
413+
///
414+
/// ```rust,ignore
414415
/// pub struct SetMaxCodeSize {
415416
/// pub new: ::core::primitive::u32,
416417
/// }
417418
/// ```
419+
///
418420
/// will be made into this:
419-
/// ```ignore
421+
///
422+
/// ```rust,ignore
420423
/// pub struct SetMaxCodeSize {
421424
/// pub new: set_max_code_size::New,
422425
/// }
423426
/// ```
427+
///
424428
/// And the type alias module will look like this:
425-
/// ```ignore
429+
///
430+
/// ```rust,ignore
426431
/// pub mod set_max_code_size {
427432
/// use super::runtime_types;
428433
/// pub type New = ::core::primitive::u32;

codegen/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub use syn;
4040
///
4141
/// Generating an interface using all of the defaults:
4242
///
43-
/// ```rust
43+
/// ```rust,standalone_crate
4444
/// use codec::Decode;
4545
/// use subxt_codegen::{ Metadata, CodegenBuilder };
4646
///

rpcs/src/client/rpc_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl std::ops::Deref for RpcClient {
106106
///
107107
/// # Example
108108
///
109-
/// ```rust
109+
/// ```rust,standalone_crate
110110
/// use subxt_rpcs::client::{ rpc_params, RpcParams };
111111
///
112112
/// // If you provide no params you get `None` back
@@ -138,7 +138,7 @@ pub use rpc_params;
138138
///
139139
/// # Example
140140
///
141-
/// ```rust
141+
/// ```rust,standalone_crate
142142
/// use subxt_rpcs::client::RpcParams;
143143
///
144144
/// let mut params = RpcParams::new();

signer/src/ecdsa.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Keypair {
4848
///
4949
/// # Example
5050
///
51-
/// ```rust
51+
/// ```rust,standalone_crate
5252
/// use subxt_signer::{ SecretUri, ecdsa::Keypair };
5353
/// use std::str::FromStr;
5454
///
@@ -84,7 +84,7 @@ impl Keypair {
8484
///
8585
/// # Example
8686
///
87-
/// ```rust
87+
/// ```rust,standalone_crate
8888
/// use subxt_signer::{ bip39::Mnemonic, ecdsa::Keypair };
8989
///
9090
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
@@ -122,7 +122,7 @@ impl Keypair {
122122
///
123123
/// # Example
124124
///
125-
/// ```rust
125+
/// ```rust,standalone_crate
126126
/// use subxt_signer::{ bip39::Mnemonic, ecdsa::Keypair, DeriveJunction };
127127
///
128128
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
@@ -178,7 +178,7 @@ impl Keypair {
178178

179179
/// Verify that some signature for a message was created by the owner of the [`PublicKey`].
180180
///
181-
/// ```rust
181+
/// ```rust,standalone_crate
182182
/// use subxt_signer::{ bip39::Mnemonic, ecdsa };
183183
///
184184
/// let keypair = ecdsa::dev::alice();

signer/src/eth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Keypair {
4646
///
4747
/// # Example
4848
///
49-
/// ```rust
49+
/// ```rust,standalone_crate
5050
/// use subxt_signer::{ bip39::Mnemonic, eth::{ Keypair, DerivationPath } };
5151
///
5252
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
@@ -175,7 +175,7 @@ impl AsRef<[u8; 65]> for Signature {
175175

176176
/// Verify that some signature for a message was created by the owner of the [`PublicKey`].
177177
///
178-
/// ```rust
178+
/// ```rust,standalone_crate
179179
/// use subxt_signer::{ bip39::Mnemonic, eth };
180180
///
181181
/// let keypair = eth::dev::alith();

signer/src/sr25519.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Keypair {
5858
///
5959
/// # Example
6060
///
61-
/// ```rust
61+
/// ```rust,standalone_crate
6262
/// use subxt_signer::{ SecretUri, sr25519::Keypair };
6363
/// use std::str::FromStr;
6464
///
@@ -94,7 +94,7 @@ impl Keypair {
9494
///
9595
/// # Example
9696
///
97-
/// ```rust
97+
/// ```rust,standalone_crate
9898
/// use subxt_signer::{ bip39::Mnemonic, sr25519::Keypair };
9999
///
100100
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
@@ -144,7 +144,7 @@ impl Keypair {
144144
///
145145
/// # Example
146146
///
147-
/// ```rust
147+
/// ```rust,standalone_crate
148148
/// use subxt_signer::{ bip39::Mnemonic, sr25519::Keypair, DeriveJunction };
149149
///
150150
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
@@ -186,7 +186,7 @@ impl Keypair {
186186

187187
/// Verify that some signature for a message was created by the owner of the [`PublicKey`].
188188
///
189-
/// ```rust
189+
/// ```rust,standalone_crate
190190
/// use subxt_signer::{ bip39::Mnemonic, sr25519 };
191191
///
192192
/// let keypair = sr25519::dev::alice();

subxt/src/backend/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub mod rpc {
2929
///
3030
/// # Example
3131
///
32-
/// ```rust,no_run
32+
/// ```rust,no_run,standalone_crate
3333
/// use std::time::Duration;
3434
/// use futures::StreamExt;
3535
/// use subxt::backend::rpc::reconnecting_rpc_client::{RpcClient, ExponentialBackoff};
@@ -541,7 +541,7 @@ mod test {
541541
/// - `current_runtime_version`
542542
/// - `call`
543543
/// The test covers them because they follow the simple pattern of:
544-
/// ```no_run
544+
/// ```rust,no_run,standalone_crate
545545
/// async fn THE_THING(&self) -> Result<HashFor<T>, Error> {
546546
/// retry(|| <DO THE THING> ).await
547547
/// }
@@ -572,7 +572,7 @@ mod test {
572572
/// - `stream_all_block_headers`
573573
/// - `stream_best_block_headers`
574574
/// The test covers them because they follow the simple pattern of:
575-
/// ```no_run
575+
/// ```rust,no_run,standalone_crate
576576
/// async fn stream_the_thing(
577577
/// &self,
578578
/// ) -> Result<StreamOfResults<(T::Header, BlockRef<HashFor<T>>)>, Error> {

0 commit comments

Comments
 (0)