diff --git a/examples/examples/benchmark_bulk_xt.rs b/examples/examples/benchmark_bulk_xt.rs index 39f15cad5..a48c3ec65 100644 --- a/examples/examples/benchmark_bulk_xt.rs +++ b/examples/examples/benchmark_bulk_xt.rs @@ -21,20 +21,18 @@ use kitchensink_runtime::{AccountId, BalancesCall, RuntimeCall}; use sp_keyring::AccountKeyring; use substrate_api_client::{ - ac_primitives::{ - ExtrinsicSigner as GenericExtrinsicSigner, SignExtrinsic, SubstrateKitchensinkConfig, - }, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner as GenericExtrinsicSigner, SignExtrinsic}, rpc::JsonrpseeClient, Api, SubmitExtrinsic, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. // Define an extrinsic signer type which sets the generic types of the `GenericExtrinsicSigner`. // This way, the types don't have to be reassigned with every usage of this type and makes // the code better readable. -type ExtrinsicSigner = GenericExtrinsicSigner; +type ExtrinsicSigner = GenericExtrinsicSigner; // To access the ExtrinsicAddress type of the Signer, we need to do this via the trait `SignExtrinsic`. // For better code readability, we define a simple type here and, at the same time, assign the @@ -48,7 +46,7 @@ async fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let signer = AccountKeyring::Alice.pair(); let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); api.set_signer(ExtrinsicSigner::new(signer)); let recipient: ExtrinsicAddressOf = AccountKeyring::Bob.to_account_id().into(); diff --git a/examples/examples/compose_extrinsic_offline.rs b/examples/examples/compose_extrinsic_offline.rs index 1390f59c0..ea9a7b047 100644 --- a/examples/examples/compose_extrinsic_offline.rs +++ b/examples/examples/compose_extrinsic_offline.rs @@ -20,12 +20,12 @@ use kitchensink_runtime::{BalancesCall, RuntimeCall}; use sp_keyring::AccountKeyring; use sp_runtime::{generic::Era, MultiAddress}; use substrate_api_client::{ - ac_primitives::{ExtrinsicSigner, GenericAdditionalParams, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner, GenericAdditionalParams}, rpc::JsonrpseeClient, Api, GetChainInfo, SubmitAndWatch, XtStatus, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[tokio::main] @@ -38,8 +38,8 @@ async fn main() { // Api::new(..) is not actually an offline call, but retrieves metadata and other information from the node. // If this is not acceptable, use the Api::new_offline(..) function instead. There are no examples for this, // because of the constantly changing substrate node. But check out our unit tests - there are Apis created with `new_offline`. - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(signer)); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(signer)); // Information for Era for mortal transactions (online). let last_finalized_header_hash = api.get_finalized_head().unwrap().unwrap(); diff --git a/examples/examples/contract_instantiate_with_code.rs b/examples/examples/contract_instantiate_with_code.rs index 1a92ffd5d..0597cdcb7 100644 --- a/examples/examples/contract_instantiate_with_code.rs +++ b/examples/examples/contract_instantiate_with_code.rs @@ -19,12 +19,12 @@ use codec::Decode; use kitchensink_runtime::AccountId; use sp_keyring::AccountKeyring; use substrate_api_client::{ - ac_compose_macros::primitives::SubstrateKitchensinkConfig, ac_node_api::StaticEvent, + ac_compose_macros::primitives::AssetRuntimeConfig, ac_node_api::StaticEvent, ac_primitives::ExtrinsicSigner, extrinsic::ContractsExtrinsics, rpc::JsonrpseeClient, Api, SubmitAndWatch, SubmitAndWatchUntilSuccess, XtStatus, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[allow(unused)] @@ -46,7 +46,7 @@ async fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let signer = AccountKeyring::Alice.pair(); let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); api.set_signer(ExtrinsicSigner::<_>::new(signer)); println!("[+] Alice's Account Nonce is {}", api.get_nonce().unwrap()); diff --git a/examples/examples/custom_nonce.rs b/examples/examples/custom_nonce.rs index d530f43ca..6dbd4f5f5 100644 --- a/examples/examples/custom_nonce.rs +++ b/examples/examples/custom_nonce.rs @@ -20,12 +20,12 @@ use kitchensink_runtime::{BalancesCall, RuntimeCall}; use sp_keyring::AccountKeyring; use sp_runtime::{generic::Era, MultiAddress}; use substrate_api_client::{ - ac_primitives::{ExtrinsicSigner, GenericAdditionalParams, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner, GenericAdditionalParams}, rpc::JsonrpseeClient, Api, Error, GetChainInfo, SubmitAndWatch, UnexpectedTxStatus, XtStatus, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig. +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig. // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[tokio::main] @@ -35,8 +35,8 @@ async fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let signer = AccountKeyring::Alice.pair(); let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(signer)); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(signer)); // Information for Era for mortal transactions. let last_finalized_header_hash = api.get_finalized_head().unwrap().unwrap(); diff --git a/examples/examples/event_callback.rs b/examples/examples/event_callback.rs index 4121b9e68..dc1bc5b74 100644 --- a/examples/examples/event_callback.rs +++ b/examples/examples/event_callback.rs @@ -19,14 +19,14 @@ use log::debug; use sp_core::H256 as Hash; use substrate_api_client::{ - ac_primitives::SubstrateKitchensinkConfig, rpc::JsonrpseeClient, Api, SubscribeEvents, + ac_primitives::AssetRuntimeConfig, rpc::JsonrpseeClient, Api, SubscribeEvents, }; // This module depends on the specific node runtime. // Replace this crate by your own if you run a custom substrate node to get your custom events. use kitchensink_runtime::RuntimeEvent; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[tokio::main] @@ -35,7 +35,7 @@ async fn main() { // Initialize the api. let client = JsonrpseeClient::with_default_url().unwrap(); - let api = Api::::new(client).unwrap(); + let api = Api::::new(client).unwrap(); println!("Subscribe to events"); let mut subscription = api.subscribe_events().unwrap(); diff --git a/examples/examples/event_error_details.rs b/examples/examples/event_error_details.rs index bd31aa998..98e131452 100644 --- a/examples/examples/event_error_details.rs +++ b/examples/examples/event_error_details.rs @@ -18,13 +18,13 @@ use sp_keyring::AccountKeyring; use sp_runtime::{AccountId32 as AccountId, MultiAddress}; use substrate_api_client::{ ac_node_api::StaticEvent, - ac_primitives::{ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner}, extrinsic::BalancesExtrinsics, rpc::JsonrpseeClient, Api, GetAccountInformation, SubmitAndWatchUntilSuccess, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[tokio::main] @@ -34,8 +34,8 @@ async fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let alice_signer = AccountKeyring::Alice.pair(); let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(alice_signer)); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(alice_signer)); let alice = AccountKeyring::Alice.to_account_id(); let balance_of_alice = api.get_account_data(&alice).unwrap().unwrap().free; diff --git a/examples/examples/get_account_identity.rs b/examples/examples/get_account_identity.rs index 0e1e0b4d0..aada0d62d 100644 --- a/examples/examples/get_account_identity.rs +++ b/examples/examples/get_account_identity.rs @@ -22,7 +22,7 @@ use sp_core::{crypto::Pair, H256}; use sp_keyring::AccountKeyring; use substrate_api_client::{ ac_compose_macros::compose_extrinsic, - ac_primitives::{ExtrinsicSigner, SubstrateKitchensinkConfig, UncheckedExtrinsicV4}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner, UncheckedExtrinsicV4}, rpc::JsonrpseeClient, Api, GetStorage, SubmitAndWatch, XtStatus, }; @@ -33,7 +33,7 @@ type BalanceOf = <::Currency as Currency< type MaxRegistrarsOf = ::MaxRegistrars; type MaxAdditionalFieldsOf = ::MaxAdditionalFields; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[tokio::main] @@ -43,8 +43,8 @@ async fn main() { // Create the node-api client and set the signer. let client = JsonrpseeClient::with_default_url().unwrap(); let signer = AccountKeyring::Alice.pair(); - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(signer.clone())); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(signer.clone())); // Fill Identity storage. let info = IdentityInfo::> { diff --git a/examples/examples/get_blocks_async.rs b/examples/examples/get_blocks_async.rs index fc2864355..3a011d0c8 100644 --- a/examples/examples/get_blocks_async.rs +++ b/examples/examples/get_blocks_async.rs @@ -18,7 +18,7 @@ #[cfg(not(feature = "sync-examples"))] use substrate_api_client::{ - ac_primitives::SubstrateKitchensinkConfig, + ac_primitives::AssetRuntimeConfig, rpc::{HandleSubscription, JsonrpseeClient}, Api, GetChainInfo, SubscribeChain, }; @@ -30,7 +30,7 @@ async fn main() { println!("Please compile this example with `--no-default-features` for it to run properly.") } -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[cfg(not(feature = "sync-examples"))] @@ -40,7 +40,7 @@ async fn main() { // Initialize the api. let client = JsonrpseeClient::with_default_url().unwrap(); - let api = Api::::new(client).await.unwrap(); + let api = Api::::new(client).await.unwrap(); let (genesis_block, header_hash, signed_block) = futures::future::try_join3( api.get_genesis_block(), diff --git a/examples/examples/get_storage.rs b/examples/examples/get_storage.rs index e6db7d7ae..1a3b19890 100644 --- a/examples/examples/get_storage.rs +++ b/examples/examples/get_storage.rs @@ -20,20 +20,20 @@ use kitchensink_runtime::AccountId; use pallet_staking::Exposure; use sp_keyring::AccountKeyring; use substrate_api_client::{ - ac_primitives::{Config, ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, Config, ExtrinsicSigner}, rpc::JsonrpseeClient, Api, GetAccountInformation, GetStorage, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. type AccountInfo = GenericAccountInfo< - ::Index, - ::AccountData, + ::Index, + ::AccountData, >; -type Balance = ::Balance; +type Balance = ::Balance; #[tokio::main] async fn main() { @@ -41,7 +41,7 @@ async fn main() { // Initialize the api. let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); // get some plain storage value let result: Balance = api.get_storage("Balances", "TotalIssuance", None).unwrap().unwrap(); diff --git a/examples/examples/print_metadata.rs b/examples/examples/print_metadata.rs index b785aa617..4c61b32f7 100644 --- a/examples/examples/print_metadata.rs +++ b/examples/examples/print_metadata.rs @@ -16,9 +16,9 @@ //! Very simple example that shows how to pretty print the metadata. Has proven to be a helpful //! debugging tool. -use substrate_api_client::{ac_primitives::SubstrateKitchensinkConfig, rpc::JsonrpseeClient, Api}; +use substrate_api_client::{ac_primitives::AssetRuntimeConfig, rpc::JsonrpseeClient, Api}; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. #[tokio::main] @@ -27,7 +27,7 @@ async fn main() { // Initialize the api, which retrieves the metadata from the node upon initialization. let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); let meta = api.metadata().clone(); diff --git a/examples/examples/staking_batch_payout.rs b/examples/examples/staking_batch_payout.rs index f1621f669..115e6dc7b 100644 --- a/examples/examples/staking_batch_payout.rs +++ b/examples/examples/staking_batch_payout.rs @@ -16,7 +16,7 @@ use pallet_staking::{ActiveEraInfo, Exposure}; use sp_keyring::AccountKeyring; use sp_runtime::{app_crypto::Ss58Codec, AccountId32}; use substrate_api_client::{ - ac_primitives::{ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner}, extrinsic::{StakingExtrinsics, UtilityExtrinsics}, rpc::JsonrpseeClient, Api, GetStorage, SubmitAndWatch, SubmitAndWatchUntilSuccess, XtStatus, @@ -24,7 +24,7 @@ use substrate_api_client::{ const MAX_BATCHED_TRANSACTION: u32 = 9; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. pub type EraIndex = u32; @@ -52,8 +52,8 @@ async fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let alice = AccountKeyring::Alice.pair(); let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(alice)); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(alice)); // Give a valid validator account address. In the kitchinsink runtime, this is Alice. let validator_account = AccountKeyring::Alice.to_account_id(); @@ -141,7 +141,7 @@ async fn main() { pub fn get_last_reward_received_for( account: &AccountId32, current_era: EraIndex, - api: &substrate_api_client::Api, + api: &substrate_api_client::Api, ) -> Option { let ledger_storage_key = api.metadata().storage_map_key("Staking", "Ledger", account).unwrap(); diff --git a/examples/examples/sudo.rs b/examples/examples/sudo.rs index 1f07336f7..e99983122 100644 --- a/examples/examples/sudo.rs +++ b/examples/examples/sudo.rs @@ -22,20 +22,20 @@ use sp_keyring::AccountKeyring; use substrate_api_client::{ ac_compose_macros::{compose_call, compose_extrinsic}, ac_primitives::{ - ExtrinsicSigner as GenericExtrinsicSigner, SignExtrinsic, SubstrateKitchensinkConfig, + AssetRuntimeConfig, ExtrinsicSigner as GenericExtrinsicSigner, SignExtrinsic, UncheckedExtrinsicV4, }, rpc::JsonrpseeClient, Api, GetAccountInformation, SubmitAndWatch, XtStatus, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. // Define an extrinsic signer type which sets the generic types of the `GenericExtrinsicSigner`. // This way, the types don't have to be reassigned with every usage of this type and makes // the code better readable. -type ExtrinsicSigner = GenericExtrinsicSigner; +type ExtrinsicSigner = GenericExtrinsicSigner; // To access the ExtrinsicAddress type of the Signer, we need to do this via the trait `SignExtrinsic`. // For better code readability, we define a simple type here and, at the same time, assign the @@ -49,7 +49,7 @@ async fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let sudoer = AccountKeyring::Alice.pair(); let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); api.set_signer(ExtrinsicSigner::new(sudoer)); // Set the recipient of newly issued funds. diff --git a/examples/examples/transfer_with_tungstenite_client.rs b/examples/examples/transfer_with_tungstenite_client.rs index 4efe8ba0f..f50a3ea1b 100755 --- a/examples/examples/transfer_with_tungstenite_client.rs +++ b/examples/examples/transfer_with_tungstenite_client.rs @@ -21,13 +21,13 @@ use sp_core::{ }; use sp_runtime::MultiAddress; use substrate_api_client::{ - ac_primitives::{ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner}, extrinsic::BalancesExtrinsics, rpc::TungsteniteRpcClient, Api, GetAccountInformation, SubmitAndWatch, XtStatus, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. fn main() { @@ -43,8 +43,8 @@ fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let client = TungsteniteRpcClient::with_default_url(100); - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(alice.clone())); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(alice.clone())); // Retrieve bobs current balance. let bob = sr25519::Public::from_ss58check("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty") diff --git a/examples/examples/transfer_with_ws_client.rs b/examples/examples/transfer_with_ws_client.rs index a97e8a990..d418e87e0 100755 --- a/examples/examples/transfer_with_ws_client.rs +++ b/examples/examples/transfer_with_ws_client.rs @@ -21,13 +21,13 @@ use sp_core::{ }; use sp_runtime::MultiAddress; use substrate_api_client::{ - ac_primitives::{ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner}, extrinsic::BalancesExtrinsics, rpc::WsRpcClient, Api, GetAccountInformation, SubmitAndWatch, XtStatus, }; -// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the SubstrateKitchensinkConfig +// To test this example in CI, we run it against the Substrate kitchensink node. Therefore, we use the AssetRuntimeConfig // ! Careful: Most runtimes uses plain as tips, they need a polkadot config. fn main() { @@ -43,8 +43,8 @@ fn main() { // Initialize api and set the signer (sender) that is used to sign the extrinsics. let client = WsRpcClient::with_default_url(); - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(alice.clone())); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(alice.clone())); // Retrieve bobs current balance. let bob = sr25519::Public::from_ss58check("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty") diff --git a/primitives/src/config/substrate_kitchensink.rs b/primitives/src/config/asset_runtime_config.rs similarity index 85% rename from primitives/src/config/substrate_kitchensink.rs rename to primitives/src/config/asset_runtime_config.rs index 3c2ea58ea..dce6cb521 100644 --- a/primitives/src/config/substrate_kitchensink.rs +++ b/primitives/src/config/asset_runtime_config.rs @@ -17,9 +17,9 @@ use core::fmt::Debug; /// Default set of commonly used types by Substrate kitchensink runtime. #[derive(Decode, Encode, Clone, Eq, PartialEq, Debug)] -pub struct SubstrateKitchensinkConfig {} +pub struct AssetRuntimeConfig {} -impl Config for SubstrateKitchensinkConfig { +impl Config for AssetRuntimeConfig { type Index = u32; type BlockNumber = u32; type Hash = H256; @@ -41,3 +41,9 @@ impl Config for SubstrateKitchensinkConfig { /// A struct representing the signed extra and additional parameters required /// to construct a transaction and pay in asset fees. pub type AssetTipExtrinsicParams = GenericExtrinsicParams::Balance>>; + +#[deprecated( + since = "0.14.0", + note = "Please use `AssetRuntimeConfig` instead, this will be removed in the next release." +)] +pub type SubstrateKitchensinkConfig = AssetRuntimeConfig; diff --git a/primitives/src/config/polkadot.rs b/primitives/src/config/default_runtime_config.rs similarity index 62% rename from primitives/src/config/polkadot.rs rename to primitives/src/config/default_runtime_config.rs index 40fd47007..9e896f549 100644 --- a/primitives/src/config/polkadot.rs +++ b/primitives/src/config/default_runtime_config.rs @@ -8,16 +8,19 @@ //! https://github.com/paritytech/subxt/blob/ce0a82e3227efb0eae131f025da5f839d9623e15/subxt/src/config/polkadot.rs use crate::{ - config::WithExtrinsicParams, Config, GenericExtrinsicParams, PlainTip, - SubstrateKitchensinkConfig, + config::WithExtrinsicParams, AssetRuntimeConfig, Config, GenericExtrinsicParams, PlainTip, }; /// Default set of commonly used types by Polkadot nodes. -pub type PolkadotConfig = WithExtrinsicParams< - SubstrateKitchensinkConfig, - PlainTipExtrinsicParams, ->; +pub type DefaultRuntimeConfig = + WithExtrinsicParams>; /// A struct representing the signed extra and additional parameters required /// to construct a transaction and pay in token fees. pub type PlainTipExtrinsicParams = GenericExtrinsicParams::Balance>>; + +#[deprecated( + since = "0.14.0", + note = "Please use `DefaultRuntimeConfig` instead, this will be removed in the next release." +)] +pub type PolkadotConfig = DefaultRuntimeConfig; diff --git a/primitives/src/config/mod.rs b/primitives/src/config/mod.rs index 260c9232a..c3fa4c3e4 100644 --- a/primitives/src/config/mod.rs +++ b/primitives/src/config/mod.rs @@ -22,11 +22,11 @@ use sp_runtime::traits::{ use crate::{extrinsic_params, SignExtrinsic}; -pub use polkadot::*; -pub use substrate_kitchensink::*; +pub use asset_runtime_config::*; +pub use default_runtime_config::*; -pub mod polkadot; -pub mod substrate_kitchensink; +pub mod asset_runtime_config; +pub mod default_runtime_config; /// Runtime types. pub trait Config { @@ -128,17 +128,17 @@ pub trait Config { + DeserializeOwned; } -/// Take a type implementing [`Config`] (eg [`SubstrateConfig`]), and some type which describes the +/// Take a type implementing [`Config`] (eg [`AssetRuntimeConfig`]), and some type which describes the /// additional and extra parameters to pass to an extrinsic (see [`ExtrinsicParams`]), /// and returns a type implementing [`Config`] with those new [`ExtrinsicParams`]. /// /// # Example /// /// ``` -/// use ac_primitives::{ SubstrateKitchensinkConfig, WithExtrinsicParams, PlainTipExtrinsicParams }; +/// use ac_primitives::{ AssetRuntimeConfig, WithExtrinsicParams, PlainTipExtrinsicParams }; /// -/// // This is how PolkadotConfig is implemented: -/// type PolkadotConfig = WithExtrinsicParams>; +/// // This is how DefaultRuntimeConfig is implemented: +/// type DefaultRuntimeConfig = WithExtrinsicParams>; /// ``` #[derive(Decode, Encode, Clone, Eq, PartialEq, Debug)] pub struct WithExtrinsicParams> { diff --git a/primitives/src/extrinsics/mod.rs b/primitives/src/extrinsics/mod.rs index bf59dfc27..3f5e2447a 100644 --- a/primitives/src/extrinsics/mod.rs +++ b/primitives/src/extrinsics/mod.rs @@ -217,7 +217,7 @@ fn encode_with_vec_prefix)>(encoder: F) -> Vec #[cfg(test)] mod tests { use super::*; - use crate::SubstrateKitchensinkConfig; + use crate::AssetRuntimeConfig; use extrinsic_params::{GenericAdditionalParams, GenericExtrinsicParams, PlainTip}; use node_template_runtime::{BalancesCall, RuntimeCall, SignedExtra}; use sp_core::{crypto::Ss58Codec, Pair, H256 as Hash}; @@ -233,14 +233,13 @@ mod tests { let tx_params = GenericAdditionalParams::, Hash>::new() .era(Era::mortal(8, 0), Hash::from([0u8; 32])); - let default_extra = - GenericExtrinsicParams::>::new( - 0, - 0, - 0u32, - Hash::from([0u8; 32]), - tx_params, - ); + let default_extra = GenericExtrinsicParams::>::new( + 0, + 0, + 0u32, + Hash::from([0u8; 32]), + tx_params, + ); let xt = UncheckedExtrinsicV4::new_signed( vec![1, 1, 1], account, diff --git a/primitives/src/extrinsics/signer.rs b/primitives/src/extrinsics/signer.rs index 3af74bf4b..0d6f3f1fa 100644 --- a/primitives/src/extrinsics/signer.rs +++ b/primitives/src/extrinsics/signer.rs @@ -138,7 +138,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::SubstrateKitchensinkConfig; + use crate::AssetRuntimeConfig; use node_template_runtime::Signature; use sp_core::sr25519; use sp_keyring::AccountKeyring; @@ -146,7 +146,7 @@ mod tests { #[test] fn test_extrinsic_signer_clone() { let pair = AccountKeyring::Alice.pair(); - let signer = ExtrinsicSigner::::new(pair); + let signer = ExtrinsicSigner::::new(pair); let _signer2 = signer.clone(); } @@ -167,8 +167,8 @@ mod tests { ) .unwrap(); - let es_converted: ExtrinsicSigner = alice.clone().into(); - let es_new = ExtrinsicSigner::::new(alice.clone()); + let es_converted: ExtrinsicSigner = alice.clone().into(); + let es_new = ExtrinsicSigner::::new(alice.clone()); assert_eq!(es_converted.signer.public(), es_new.signer.public()); } diff --git a/src/api/api_client.rs b/src/api/api_client.rs index 67fa3ba28..01877a68b 100644 --- a/src/api/api_client.rs +++ b/src/api/api_client.rs @@ -34,7 +34,7 @@ use sp_version::RuntimeVersion; /// /// ```no_run /// use substrate_api_client::{ -/// Api, rpc::Request, rpc::Error as RpcClientError, XtStatus, rpc::Result as RpcResult, ac_primitives::SubstrateKitchensinkConfig +/// Api, rpc::Request, rpc::Error as RpcClientError, XtStatus, rpc::Result as RpcResult, ac_primitives::AssetRuntimeConfig /// }; /// use serde::de::DeserializeOwned; /// use ac_primitives::RpcParams; @@ -78,7 +78,7 @@ use sp_version::RuntimeVersion; /// } /// /// let client = MyClient::new(); -/// let _api = Api::::new(client); +/// let _api = Api::::new(client); /// /// ``` #[derive(Clone)] @@ -297,8 +297,8 @@ mod tests { use super::*; use crate::rpc::mocks::RpcClientMock; use ac_primitives::{ - GenericAdditionalParams, GenericExtrinsicParams, PlainTip, PolkadotConfig, - SubstrateKitchensinkConfig, + AssetRuntimeConfig, DefaultRuntimeConfig, GenericAdditionalParams, GenericExtrinsicParams, + PlainTip, }; use frame_metadata::{ExtrinsicMetadata, RuntimeMetadata}; use scale_info::form::PortableForm; @@ -310,7 +310,7 @@ mod tests { runtime_version: RuntimeVersion, metadata: Metadata, data: HashMap, - ) -> Api { + ) -> Api { let client = RpcClientMock::new(data); Api::new_offline(genesis_hash, metadata, runtime_version, client) } @@ -335,14 +335,13 @@ mod tests { let nonce = 6; let retrieved_params = api.extrinsic_params(nonce); - let expected_params = - GenericExtrinsicParams::>::new( - runtime_version.spec_version, - runtime_version.transaction_version, - nonce, - genesis_hash, - Default::default(), - ); + let expected_params = GenericExtrinsicParams::>::new( + runtime_version.spec_version, + runtime_version.transaction_version, + nonce, + genesis_hash, + Default::default(), + ); assert_eq!(expected_params, retrieved_params) } diff --git a/src/api/rpc_api/events.rs b/src/api/rpc_api/events.rs index 9a6bf75cc..d2babc7a8 100644 --- a/src/api/rpc_api/events.rs +++ b/src/api/rpc_api/events.rs @@ -225,7 +225,7 @@ mod tests { use super::*; use crate::rpc::mocks::RpcClientMock; use ac_node_api::{metadata::Metadata, test_utils::*}; - use ac_primitives::PolkadotConfig; + use ac_primitives::DefaultRuntimeConfig; use codec::{Decode, Encode}; use frame_metadata::RuntimeMetadataPrefixed; use kitchensink_runtime::{BalancesCall, RuntimeCall, UncheckedExtrinsic}; @@ -249,7 +249,7 @@ mod tests { fn create_mock_api( metadata: Metadata, data: HashMap, - ) -> Api { + ) -> Api { // Create new api. let genesis_hash = H256::random(); let runtime_version = RuntimeVersion::default(); @@ -374,9 +374,9 @@ mod tests { let xt2: Bytes = UncheckedExtrinsic::new_unsigned(call2).encode().into(); let xt3: Bytes = UncheckedExtrinsic::new_unsigned(call3).encode().into(); - let xt_hash1 = ::Hasher::hash_of(&xt1.0); - let xt_hash2 = ::Hasher::hash_of(&xt2.0); - let xt_hash3 = ::Hasher::hash_of(&xt3.0); + let xt_hash1 = ::Hasher::hash_of(&xt1.0); + let xt_hash2 = ::Hasher::hash_of(&xt2.0); + let xt_hash3 = ::Hasher::hash_of(&xt3.0); let block = Block { header: default_header(), extrinsics: vec![xt1, xt2, xt3] }; let signed_block = SignedBlock { block, justifications: None }; diff --git a/testing/examples/author_tests.rs b/testing/examples/author_tests.rs index a7f49c9e6..b8e42e8e5 100644 --- a/testing/examples/author_tests.rs +++ b/testing/examples/author_tests.rs @@ -21,24 +21,23 @@ use std::{thread, time::Duration}; use substrate_api_client::{ ac_node_api::EventDetails, ac_primitives::{ - Config, ExtrinsicSigner as GenericExtrinsicSigner, SignExtrinsic, - SubstrateKitchensinkConfig, + AssetRuntimeConfig, Config, ExtrinsicSigner as GenericExtrinsicSigner, SignExtrinsic, }, extrinsic::BalancesExtrinsics, rpc::{HandleSubscription, JsonrpseeClient}, Api, SubmitAndWatch, SubmitAndWatchUntilSuccess, SubmitExtrinsic, TransactionStatus, XtStatus, }; -type ExtrinsicSigner = GenericExtrinsicSigner; +type ExtrinsicSigner = GenericExtrinsicSigner; type ExtrinsicAddressOf = >::ExtrinsicAddress; -type Hash = ::Hash; +type Hash = ::Hash; #[tokio::main] async fn main() { // Setup let client = JsonrpseeClient::with_default_url().unwrap(); let alice_pair = AccountKeyring::Alice.pair(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); api.set_signer(ExtrinsicSigner::new(alice_pair)); diff --git a/testing/examples/chain_tests.rs b/testing/examples/chain_tests.rs index c612a7972..3cf6cd591 100644 --- a/testing/examples/chain_tests.rs +++ b/testing/examples/chain_tests.rs @@ -16,7 +16,7 @@ //! Tests for the chain rpc interface functions. use substrate_api_client::{ - ac_primitives::SubstrateKitchensinkConfig, + ac_primitives::AssetRuntimeConfig, rpc::{HandleSubscription, JsonrpseeClient}, Api, GetChainInfo, SubscribeChain, }; @@ -25,7 +25,7 @@ use substrate_api_client::{ async fn main() { // Setup let client = JsonrpseeClient::with_default_url().unwrap(); - let api = Api::::new(client).unwrap(); + let api = Api::::new(client).unwrap(); // GetChainInfo let finalized_header_hash = api.get_finalized_head().unwrap().unwrap(); diff --git a/testing/examples/dispatch_errors_tests.rs b/testing/examples/dispatch_errors_tests.rs index f2c0976c6..89282c9e3 100644 --- a/testing/examples/dispatch_errors_tests.rs +++ b/testing/examples/dispatch_errors_tests.rs @@ -18,7 +18,7 @@ use sp_keyring::AccountKeyring; use sp_runtime::MultiAddress; use substrate_api_client::{ - ac_primitives::{ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner}, extrinsic::BalancesExtrinsics, rpc::JsonrpseeClient, Api, GetAccountInformation, SubmitAndWatchUntilSuccess, @@ -30,7 +30,7 @@ async fn main() { let client = JsonrpseeClient::with_default_url().unwrap(); let alice_signer = AccountKeyring::Alice.pair(); let bob_signer = AccountKeyring::Bob.pair(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); let alice = AccountKeyring::Alice.to_account_id(); let balance_of_alice = api.get_account_data(&alice).unwrap().unwrap().free; @@ -45,7 +45,7 @@ async fn main() { println!("[+] One's Free Balance is {}\n", balance_of_one); //BadOrigin - api.set_signer(ExtrinsicSigner::::new(bob_signer)); + api.set_signer(ExtrinsicSigner::::new(bob_signer)); //Can only be called by root let xt = api.balance_force_set_balance(MultiAddress::Id(alice.clone()), 10); @@ -55,7 +55,7 @@ async fn main() { println!("[+] BadOrigin error: Bob can't force set balance"); //BelowMinimum - api.set_signer(ExtrinsicSigner::::new(alice_signer)); + api.set_signer(ExtrinsicSigner::::new(alice_signer)); let xt = api.balance_transfer_allow_death(MultiAddress::Id(one.clone()), 999999); let result = api.submit_and_watch_extrinsic_until_success(xt, false); assert!(result.is_err()); diff --git a/testing/examples/events_tests.rs b/testing/examples/events_tests.rs index d24249148..6c13c7703 100644 --- a/testing/examples/events_tests.rs +++ b/testing/examples/events_tests.rs @@ -21,13 +21,13 @@ use kitchensink_runtime::RuntimeEvent; use sp_keyring::AccountKeyring; use substrate_api_client::{ ac_node_api::{EventDetails, StaticEvent}, - ac_primitives::{Config, ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, Config, ExtrinsicSigner}, extrinsic::BalancesExtrinsics, rpc::JsonrpseeClient, Api, FetchEvents, GetChainInfo, SubmitAndWatch, SubscribeEvents, XtStatus, }; -type Hash = ::Hash; +type Hash = ::Hash; /// Check out frame_system::Event::ExtrinsicSuccess: #[derive(Decode, Debug)] @@ -45,8 +45,8 @@ async fn main() { // Setup let client = JsonrpseeClient::with_default_url().unwrap(); let alice_pair = AccountKeyring::Alice.pair(); - let mut api = Api::::new(client).unwrap(); - api.set_signer(ExtrinsicSigner::::new(alice_pair)); + let mut api = Api::::new(client).unwrap(); + api.set_signer(ExtrinsicSigner::::new(alice_pair)); let bob = AccountKeyring::Bob.to_account_id(); @@ -72,7 +72,7 @@ async fn main() { // Wait for event callbacks from the node, which are received via subscription. for _ in 0..5 { let event_records = event_subscription - .next_events::::Hash>() + .next_events::::Hash>() .unwrap() .unwrap(); for event_record in &event_records { diff --git a/testing/examples/frame_system_tests.rs b/testing/examples/frame_system_tests.rs index 09fc5e690..32f5a4ec9 100644 --- a/testing/examples/frame_system_tests.rs +++ b/testing/examples/frame_system_tests.rs @@ -20,7 +20,7 @@ use frame_support::dispatch::DispatchInfo; use sp_keyring::AccountKeyring; use substrate_api_client::{ ac_node_api::StaticEvent, - ac_primitives::{ExtrinsicSigner, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner}, rpc::JsonrpseeClient, Api, GetAccountInformation, SystemApi, }; @@ -41,7 +41,7 @@ async fn main() { // Setup let client = JsonrpseeClient::with_default_url().unwrap(); let alice_pair = AccountKeyring::Alice.pair(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); api.set_signer(ExtrinsicSigner::new(alice_pair)); let alice = AccountKeyring::Alice.to_account_id(); diff --git a/testing/examples/pallet_balances_tests.rs b/testing/examples/pallet_balances_tests.rs index 4946ceca1..318f590a1 100644 --- a/testing/examples/pallet_balances_tests.rs +++ b/testing/examples/pallet_balances_tests.rs @@ -16,14 +16,14 @@ //! Tests for the pallet balances interface functions. use substrate_api_client::{ - ac_primitives::SubstrateKitchensinkConfig, rpc::JsonrpseeClient, Api, GetBalance, + ac_primitives::AssetRuntimeConfig, rpc::JsonrpseeClient, Api, GetBalance, }; #[tokio::main] async fn main() { // Setup let client = JsonrpseeClient::with_default_url().unwrap(); - let api = Api::::new(client).unwrap(); + let api = Api::::new(client).unwrap(); let _ed = api.get_existential_deposit().unwrap(); } diff --git a/testing/examples/pallet_transaction_payment_tests.rs b/testing/examples/pallet_transaction_payment_tests.rs index 2f9a9e280..d5793dd91 100644 --- a/testing/examples/pallet_transaction_payment_tests.rs +++ b/testing/examples/pallet_transaction_payment_tests.rs @@ -18,8 +18,8 @@ use codec::Encode; use sp_keyring::AccountKeyring; use substrate_api_client::{ - ac_primitives::SubstrateKitchensinkConfig, extrinsic::BalancesExtrinsics, rpc::JsonrpseeClient, - Api, GetChainInfo, GetTransactionPayment, + ac_primitives::AssetRuntimeConfig, extrinsic::BalancesExtrinsics, rpc::JsonrpseeClient, Api, + GetChainInfo, GetTransactionPayment, }; #[tokio::main] @@ -27,7 +27,7 @@ async fn main() { // Setup let client = JsonrpseeClient::with_default_url().unwrap(); let alice_pair = AccountKeyring::Alice.pair(); - let mut api = Api::::new(client).unwrap(); + let mut api = Api::::new(client).unwrap(); api.set_signer(alice_pair.into()); let bob = AccountKeyring::Bob.to_account_id(); diff --git a/testing/examples/state_tests.rs b/testing/examples/state_tests.rs index 5359c5f39..88f58034b 100644 --- a/testing/examples/state_tests.rs +++ b/testing/examples/state_tests.rs @@ -22,12 +22,12 @@ use sp_core::{crypto::Ss58Codec, sr25519}; use sp_keyring::AccountKeyring; use sp_staking::EraIndex; use substrate_api_client::{ - ac_primitives::{Config, SubstrateKitchensinkConfig}, + ac_primitives::{AssetRuntimeConfig, Config}, rpc::JsonrpseeClient, Api, GetChainInfo, GetStorage, }; -type KitchensinkConfig = SubstrateKitchensinkConfig; +type KitchensinkConfig = AssetRuntimeConfig; type Balance = ::Balance; type AccountData = GenericAccountData; type ErasStakers = Exposure<