Skip to content

v0.42.0

Choose a tag to compare

@jsdw jsdw released this 12 May 12:21
· 81 commits to master since this release
v0.42.0
77f8355

[0.42.0] - 2025-05-09

The primary benefit of this release is introducing support for the about-to-be-stabilised-in-polkadot-sdk 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.

Pallet View Functions

Calling a Pallet View Function in this Subxt release will look like:

use runtime::proxy::view_functions::check_permissions::{Call, ProxyType};

// Construct the call, providing the two arguments.
let view_function_call = runtime::view_functions()
    .proxy()
    .check_permissions(
        Call::System(runtime::system::Call::remark { remark: b"hi".to_vec() }),
        ProxyType::Any
    );

// Submit the call and get back a result.
let _is_call_allowed = api
    .view_functions()
    .at_latest()
    .await?
    .call(view_function_call)
    .await?;

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:

use scale_value::value;

let metadata = api.metadata();

// Look up the query ID for the View Function in the node metadata:
let query_id = metadata
    .pallet_by_name("Proxy")
    .unwrap()
    .view_function_by_name("check_permissions")
    .unwrap()
    .query_id();

// Construct the call, providing the two arguments.
let view_function_call = subxt::dynamic::view_function_call(
    *query_id,
    vec![
        value!(System(remark(b"hi".to_vec()))), 
        value!(Any())
    ],
);

// Submit the call and get back a result.
let _is_call_allowed = api
    .view_functions()
    .at_latest()
    .await?
    .call(view_function_call)
    .await?;

Updated Config trait

Another change to be aware of is that our Config trait has been tweaked. 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.

Other changes

We also solidify our support for V1 archive RPCs, upgrade the codebase to Rust 2024 edition, and a bunch of other changes, the full list of which is here:

Added

  • Support v16 metadata and use it by default if it's available (#1999)
  • Metadata V16: Implement support for Pallet View Functions (#1981)
  • Metadata V16: Be more dynamic over which hasher is used. (#1974)

Changed

  • Update to 2024 edition (#2001)
  • Update Smoldot to latest version (#1991)
  • Update native test timeout to 45 mins (#2002)
  • chore(deps): tokio ^1.44.2 (#1989)
  • Add DefaultParams to allow more transaction extensions to be used when calling _default() methods (#1979)
  • Use wat instead of wabt to avoid CI cmake error (and use supported dep) (#1980)
  • Support v1 archive RPCs (#1977)
  • Support V16 metadata and refactor metadata code (#1967)
  • Allow submitting transactions ignoring follow events (#1962)
  • Improve error message regarding failure to extract metadata from WASM runtime (#1961)
  • Add docs for subxt-rpcs and fix example (#1954)

Fixed

  • Fix CLI storage diff (#1958)
  • chore: fix some typos (#1997)