subxt_core/config/
polkadot.rs

1// Copyright 2019-2024 Parity Technologies (UK) Ltd.
2// This file is dual-licensed as Apache-2.0 or GPL-3.0.
3// see LICENSE for license details.
4
5//! Polkadot specific configuration
6
7use super::{Config, DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
8
9use crate::config::SubstrateConfig;
10pub use crate::utils::{AccountId32, MultiAddress, MultiSignature};
11pub use primitive_types::{H256, U256};
12
13/// Default set of commonly used types by Polkadot nodes.
14// Note: The trait implementations exist just to make life easier,
15// but shouldn't strictly be necessary since users can't instantiate this type.
16#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
17pub enum PolkadotConfig {}
18
19impl Config for PolkadotConfig {
20    type AccountId = <SubstrateConfig as Config>::AccountId;
21    type Signature = <SubstrateConfig as Config>::Signature;
22    type Hasher = <SubstrateConfig as Config>::Hasher;
23    type Header = <SubstrateConfig as Config>::Header;
24    type AssetId = <SubstrateConfig as Config>::AssetId;
25
26    // Address on Polkadot has no account index, whereas it's u32 on
27    // the default substrate dev node.
28    type Address = MultiAddress<Self::AccountId, ()>;
29
30    // These are the same as the default substrate node, but redefined
31    // because we need to pass the PolkadotConfig trait as a param.
32    type ExtrinsicParams = PolkadotExtrinsicParams<Self>;
33}
34
35/// A struct representing the signed extra and additional parameters required
36/// to construct a transaction for a polkadot node.
37pub type PolkadotExtrinsicParams<T> = DefaultExtrinsicParams<T>;
38
39/// A builder which leads to [`PolkadotExtrinsicParams`] being constructed.
40/// This is what you provide to methods like `sign_and_submit()`.
41pub type PolkadotExtrinsicParamsBuilder<T> = DefaultExtrinsicParamsBuilder<T>;