mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 09:07:57 +00:00
Remove substrate-compat default feature flag (#1078)
* remove defautl feature, add target cfg, change CI job waml * adjust CI job * Adjust docs * adjust the CI job * add wasm targe to ci again * remove the unresolved links from the book * Update subxt/src/book/usage/transactions.rs --------- Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
@@ -34,17 +34,17 @@
|
||||
//! at the time of writing. The `AccountId`, `Hash` and `Header` types of the [frame_system::pallet::Config](https://docs.rs/frame-system/latest/frame_system/pallet/trait.Config.html)
|
||||
//! correspond to the ones we want to use for implementing [crate::Config]. In the Case of Statemint (Asset Hub) they are:
|
||||
//!
|
||||
//! - AccountId: [`sp_core::crypto::AccountId32`]
|
||||
//! - Hash: [`sp_core::H256`]
|
||||
//! - Hasher (type `Hashing` in [frame_system::pallet::Config](https://docs.rs/frame-system/latest/frame_system/pallet/trait.Config.html)): [`sp_runtime::traits::BlakeTwo256`]
|
||||
//! - Header: [`sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>`](sp_runtime::generic::Header)
|
||||
//! - AccountId: `sp_core::crypto::AccountId32`
|
||||
//! - Hash: `sp_core::H256`
|
||||
//! - Hasher (type `Hashing` in [frame_system::pallet::Config](https://docs.rs/frame-system/latest/frame_system/pallet/trait.Config.html)): `sp_runtime::traits::BlakeTwo256`
|
||||
//! - Header: `sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>`
|
||||
//!
|
||||
//! Subxt has its own versions of some of these types in order to avoid needing to pull in Substrate dependencies:
|
||||
//!
|
||||
//! - [`sp_core::crypto::AccountId32`] can be swapped with [`crate::utils::AccountId32`].
|
||||
//! - [`sp_core::H256`] is a re-export which subxt also provides as [`crate::config::substrate::H256`].
|
||||
//! - [`sp_runtime::traits::BlakeTwo256`] can be swapped with [`crate::config::substrate::BlakeTwo256`].
|
||||
//! - [`sp_runtime::generic::Header`] can be swapped with [`crate::config::substrate::SubstrateHeader`].
|
||||
//! - `sp_core::crypto::AccountId32` can be swapped with [`crate::utils::AccountId32`].
|
||||
//! - `sp_core::H256` is a re-export which subxt also provides as [`crate::config::substrate::H256`].
|
||||
//! - `sp_runtime::traits::BlakeTwo256` can be swapped with [`crate::config::substrate::BlakeTwo256`].
|
||||
//! - `sp_runtime::generic::Header` can be swapped with [`crate::config::substrate::SubstrateHeader`].
|
||||
//!
|
||||
//! Having a look at how those types are implemented can give some clues as to how to implement other custom types that
|
||||
//! you may need to use as part of your config.
|
||||
@@ -53,20 +53,20 @@
|
||||
//!
|
||||
//! A Substrate runtime is typically constructed by using the [frame_support::construct_runtime](https://docs.rs/frame-support/latest/frame_support/macro.construct_runtime.html) macro.
|
||||
//! In this macro, we need to specify the type of an `UncheckedExtrinsic`. Most of the time, the `UncheckedExtrinsic` will be of the type
|
||||
//! [sp_runtime::generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>](sp_runtime::generic::UncheckedExtrinsic).
|
||||
//! `sp_runtime::generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>`.
|
||||
//! The generic parameters `Address` and `Signature` specified when declaring the `UncheckedExtrinsic` type
|
||||
//! are the types for `Address` and `Signature` we should use when implementing the [crate::Config] trait. This information can
|
||||
//! also be obtained from the metadata (see [`frame_metadata::v15::ExtrinsicMetadata`]). In case of Statemint (Polkadot Asset Hub)
|
||||
//! we see the following types being used in `UncheckedExtrinsic`:
|
||||
//!
|
||||
//! - Address: [sp_runtime::MultiAddress<Self::AccountId, ()>](sp_runtime::MultiAddress)
|
||||
//! - Signature: [sp_runtime::MultiSignature]
|
||||
//! - Address: `sp_runtime::MultiAddress<Self::AccountId, ()>](sp_runtime::MultiAddress`
|
||||
//! - Signature: `sp_runtime::MultiSignature`
|
||||
//!
|
||||
//! As above, Subxt has its own versions of these types that can be used instead to avoid pulling in Substrate dependencies.
|
||||
//! Using the Subxt versions also makes interacting with generated code (which uses them in some places) a little nicer:
|
||||
//!
|
||||
//! - [`sp_runtime::MultiAddress`] can be swapped with [`crate::utils::MultiAddress`].
|
||||
//! - [`sp_runtime::MultiSignature`] can be swapped with [`crate::utils::MultiSignature`].
|
||||
//! - `sp_runtime::MultiAddress` can be swapped with [`crate::utils::MultiAddress`].
|
||||
//! - `sp_runtime::MultiSignature` can be swapped with [`crate::utils::MultiSignature`].
|
||||
//!
|
||||
//! ### ExtrinsicParams
|
||||
//!
|
||||
@@ -100,7 +100,7 @@
|
||||
//! );
|
||||
//! ```
|
||||
//!
|
||||
//! Each element of the `SignedExtra` tuple implements [codec::Encode] and [sp_runtime::traits::SignedExtension]
|
||||
//! Each element of the `SignedExtra` tuple implements [codec::Encode] and `sp_runtime::traits::SignedExtension`
|
||||
//! which has an associated type `AdditionalSigned` that also implements [codec::Encode]. Let's look at the underlying types
|
||||
//! for each tuple element. All zero-sized types have been replaced by `()` for simplicity.
|
||||
//!
|
||||
@@ -109,8 +109,8 @@
|
||||
//! | [`frame_system::CheckNonZeroSender`](https://docs.rs/frame-system/latest/frame_system/struct.CheckNonZeroSender.html) | () | () |
|
||||
//! | [`frame_system::CheckSpecVersion`](https://docs.rs/frame-system/latest/frame_system/struct.CheckSpecVersion.html) | () | [u32] |
|
||||
//! | [`frame_system::CheckTxVersion`](https://docs.rs/frame-system/latest/frame_system/struct.CheckTxVersion.html) | () | [u32] |
|
||||
//! | [`frame_system::CheckGenesis`](https://docs.rs/frame-system/latest/frame_system/struct.CheckGenesis.html) | () | `Config::Hash` = [sp_core::H256] |
|
||||
//! | [`frame_system::CheckMortality`](https://docs.rs/frame-system/latest/frame_system/struct.CheckMortality.html) | [sp_runtime::generic::Era] | `Config::Hash` = [sp_core::H256] |
|
||||
//! | [`frame_system::CheckGenesis`](https://docs.rs/frame-system/latest/frame_system/struct.CheckGenesis.html) | () | `Config::Hash` = `sp_core::H256` |
|
||||
//! | [`frame_system::CheckMortality`](https://docs.rs/frame-system/latest/frame_system/struct.CheckMortality.html) | `sp_runtime::generic::Era` | `Config::Hash` = `sp_core::H256` |
|
||||
//! | [`frame_system::CheckNonce`](https://docs.rs/frame-system/latest/frame_system/struct.CheckNonce.html) | `frame_system::pallet::Config::Index` = u32 | () |
|
||||
//! | [`frame_system::CheckWeight`](https://docs.rs/frame-system/latest/frame_system/struct.CheckWeight.html) | () | () |
|
||||
//! | [`frame_system::ChargeAssetTxPayment`](https://docs.rs/frame-system/latest/frame_system/struct.ChargeAssetTxPayment.html) | [pallet_asset_tx_payment::ChargeAssetTxPayment](https://docs.rs/pallet-asset-tx-payment/latest/pallet_asset_tx_payment/struct.ChargeAssetTxPayment.html) | () |
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
//! There are two main ways to create a compatible signer instance:
|
||||
//! 1. The `subxt_signer` crate provides a WASM compatible implementation of [`crate::tx::Signer`]
|
||||
//! for chains which require sr25519 or ecdsa signatures (requires the `subxt` feature to be enabled).
|
||||
//! 2. Alternately, Subxt can use instances of Substrate's [`sp_core::Pair`] to sign things by wrapping
|
||||
//! them in a [`crate::tx::PairSigner`] (requires the `substrate-compat` feature to be enabled).
|
||||
//! 2. Alternately, Subxt can use instances of Substrate's `sp_core::Pair` to sign things by wrapping
|
||||
//! them in a `crate::tx::PairSigner` (requires the `substrate-compat` feature to be enabled).
|
||||
//!
|
||||
//! Going for 1 leads to fewer dependencies being imported and WASM compatibility out of the box via
|
||||
//! the `web` feature flag. Going for 2 is useful if you're already using the Substrate dependencies or
|
||||
@@ -77,6 +77,8 @@
|
||||
//! Let's see how to use each of these approaches:
|
||||
//!
|
||||
//! ```rust
|
||||
//! # #[cfg(feature = "substrate-compat")]
|
||||
//! # {
|
||||
//! use subxt::config::PolkadotConfig;
|
||||
//! use std::str::FromStr;
|
||||
//!
|
||||
@@ -111,9 +113,10 @@
|
||||
//! # is_subxt_signer(subxt_signer::sr25519::dev::alice());
|
||||
//! # is_subxt_signer(subxt_signer::ecdsa::dev::alice());
|
||||
//! # is_subxt_signer(PairSigner::<PolkadotConfig,_>::new(sp_keyring::AccountKeyring::Alice.pair()));
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! See the `subxt_signer` crate or the [`sp_core::Pair`] docs for more ways to construct
|
||||
//! See the `subxt_signer` crate or the `sp_core::Pair` docs for more ways to construct
|
||||
//! and work with key pairs.
|
||||
//!
|
||||
//! If this isn't suitable/available, you can either implement [`crate::tx::Signer`] yourself to use
|
||||
|
||||
@@ -50,7 +50,7 @@ mod pair_signer {
|
||||
where
|
||||
T: Config,
|
||||
Pair: PairT,
|
||||
// We go via an sp_runtime::MultiSignature. We can probably generalise this
|
||||
// We go via an `sp_runtime::MultiSignature`. We can probably generalise this
|
||||
// by implementing some of these traits on our built-in MultiSignature and then
|
||||
// requiring them on all T::Signatures, to avoid any go-between.
|
||||
<SpMultiSignature as Verify>::Signer: From<Pair::Public>,
|
||||
|
||||
Reference in New Issue
Block a user