From 8c7b5e5f8db1ee0e0ebdb5af9d782eef9d500f85 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Mon, 16 Dec 2024 21:18:25 +0000 Subject: [PATCH 1/4] feat(call-parachain): add remark action --- .../pop-parachains/src/call/metadata/action.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/pop-parachains/src/call/metadata/action.rs b/crates/pop-parachains/src/call/metadata/action.rs index cd47e1279..384ac0f95 100644 --- a/crates/pop-parachains/src/call/metadata/action.rs +++ b/crates/pop-parachains/src/call/metadata/action.rs @@ -83,6 +83,14 @@ pub enum Action { props(Pallet = "Registrar") )] Register, + /// Make some on-chain remark. + #[strum( + serialize = "remark", + message = "remark_with_event", + detailed_message = "Make some on-chain remark", + props(Pallet = "System") + )] + Remark, } impl Action { @@ -137,6 +145,7 @@ mod tests { (Action::Transfer, "Transfer balance"), (Action::Register, "Register a parachain ID with genesis state and code"), (Action::Reserve, "Reserve a parachain ID"), + (Action::Remark, "Make some on-chain remark"), ]); for action in Action::VARIANTS.iter() { @@ -155,6 +164,7 @@ mod tests { (Action::Transfer, "Balances"), (Action::Register, "Registrar"), (Action::Reserve, "Registrar"), + (Action::Remark, "System"), ]); for action in Action::VARIANTS.iter() { @@ -173,6 +183,7 @@ mod tests { (Action::Transfer, "transfer_allow_death"), (Action::Register, "register"), (Action::Reserve, "reserve"), + (Action::Remark, "remark_with_event"), ]); for action in Action::VARIANTS.iter() { @@ -186,21 +197,23 @@ mod tests { let mut client: subxt::OnlineClient = set_up_client(POP_NETWORK_TESTNET_URL).await?; let mut actions = supported_actions(&parse_chain_metadata(&client)?); - assert_eq!(actions.len(), 5); + assert_eq!(actions.len(), 6); assert_eq!(actions[0], Action::Transfer); assert_eq!(actions[1], Action::CreateAsset); assert_eq!(actions[2], Action::MintAsset); assert_eq!(actions[3], Action::CreateCollection); assert_eq!(actions[4], Action::MintNFT); + assert_eq!(actions[5], Action::Remark); // Test Polkadot Relay Chain. client = set_up_client(POLKADOT_NETWORK_URL).await?; actions = supported_actions(&parse_chain_metadata(&client)?); - assert_eq!(actions.len(), 4); + assert_eq!(actions.len(), 5); assert_eq!(actions[0], Action::Transfer); assert_eq!(actions[1], Action::PurchaseOnDemandCoretime); assert_eq!(actions[2], Action::Reserve); assert_eq!(actions[3], Action::Register); + assert_eq!(actions[4], Action::Remark); Ok(()) } From 35202cdc6baa7878745103d284c5fd6e52e6df69 Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Mon, 16 Dec 2024 21:22:54 +0000 Subject: [PATCH 2/4] test(call-parachain): simplify tests --- .../src/call/metadata/action.rs | 79 ++++++++----------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/crates/pop-parachains/src/call/metadata/action.rs b/crates/pop-parachains/src/call/metadata/action.rs index 384ac0f95..74b1a98a3 100644 --- a/crates/pop-parachains/src/call/metadata/action.rs +++ b/crates/pop-parachains/src/call/metadata/action.rs @@ -127,7 +127,7 @@ pub fn supported_actions(pallets: &[Pallet]) -> Vec { #[cfg(test)] mod tests { - use super::*; + use super::{Action::*, *}; use crate::{call::tests::POP_NETWORK_TESTNET_URL, parse_chain_metadata, set_up_client}; use anyhow::Result; use std::collections::HashMap; @@ -137,15 +137,15 @@ mod tests { #[test] fn action_descriptions_are_correct() { let descriptions = HashMap::from([ - (Action::CreateAsset, "Create an asset"), - (Action::MintAsset, "Mint an asset"), - (Action::CreateCollection, "Create an NFT collection"), - (Action::MintNFT, "Mint an NFT"), - (Action::PurchaseOnDemandCoretime, "Purchase on-demand coretime"), - (Action::Transfer, "Transfer balance"), - (Action::Register, "Register a parachain ID with genesis state and code"), - (Action::Reserve, "Reserve a parachain ID"), - (Action::Remark, "Make some on-chain remark"), + (CreateAsset, "Create an asset"), + (MintAsset, "Mint an asset"), + (CreateCollection, "Create an NFT collection"), + (MintNFT, "Mint an NFT"), + (PurchaseOnDemandCoretime, "Purchase on-demand coretime"), + (Transfer, "Transfer balance"), + (Register, "Register a parachain ID with genesis state and code"), + (Reserve, "Reserve a parachain ID"), + (Remark, "Make some on-chain remark"), ]); for action in Action::VARIANTS.iter() { @@ -156,15 +156,15 @@ mod tests { #[test] fn pallet_names_are_correct() { let pallets = HashMap::from([ - (Action::CreateAsset, "Assets"), - (Action::MintAsset, "Assets"), - (Action::CreateCollection, "Nfts"), - (Action::MintNFT, "Nfts"), - (Action::PurchaseOnDemandCoretime, "OnDemand"), - (Action::Transfer, "Balances"), - (Action::Register, "Registrar"), - (Action::Reserve, "Registrar"), - (Action::Remark, "System"), + (CreateAsset, "Assets"), + (MintAsset, "Assets"), + (CreateCollection, "Nfts"), + (MintNFT, "Nfts"), + (PurchaseOnDemandCoretime, "OnDemand"), + (Transfer, "Balances"), + (Register, "Registrar"), + (Reserve, "Registrar"), + (Remark, "System"), ]); for action in Action::VARIANTS.iter() { @@ -175,15 +175,15 @@ mod tests { #[test] fn function_names_are_correct() { let pallets = HashMap::from([ - (Action::CreateAsset, "create"), - (Action::MintAsset, "mint"), - (Action::CreateCollection, "create"), - (Action::MintNFT, "mint"), - (Action::PurchaseOnDemandCoretime, "place_order_allow_death"), - (Action::Transfer, "transfer_allow_death"), - (Action::Register, "register"), - (Action::Reserve, "reserve"), - (Action::Remark, "remark_with_event"), + (CreateAsset, "create"), + (MintAsset, "mint"), + (CreateCollection, "create"), + (MintNFT, "mint"), + (PurchaseOnDemandCoretime, "place_order_allow_death"), + (Transfer, "transfer_allow_death"), + (Register, "register"), + (Reserve, "reserve"), + (Remark, "remark_with_event"), ]); for action in Action::VARIANTS.iter() { @@ -196,25 +196,16 @@ mod tests { // Test Pop Parachain. let mut client: subxt::OnlineClient = set_up_client(POP_NETWORK_TESTNET_URL).await?; - let mut actions = supported_actions(&parse_chain_metadata(&client)?); - assert_eq!(actions.len(), 6); - assert_eq!(actions[0], Action::Transfer); - assert_eq!(actions[1], Action::CreateAsset); - assert_eq!(actions[2], Action::MintAsset); - assert_eq!(actions[3], Action::CreateCollection); - assert_eq!(actions[4], Action::MintNFT); - assert_eq!(actions[5], Action::Remark); + let actions = supported_actions(&parse_chain_metadata(&client)?); + assert_eq!( + actions, + vec![Transfer, CreateAsset, MintAsset, CreateCollection, MintNFT, Remark] + ); // Test Polkadot Relay Chain. client = set_up_client(POLKADOT_NETWORK_URL).await?; - actions = supported_actions(&parse_chain_metadata(&client)?); - assert_eq!(actions.len(), 5); - assert_eq!(actions[0], Action::Transfer); - assert_eq!(actions[1], Action::PurchaseOnDemandCoretime); - assert_eq!(actions[2], Action::Reserve); - assert_eq!(actions[3], Action::Register); - assert_eq!(actions[4], Action::Remark); - + let actions = supported_actions(&parse_chain_metadata(&client)?); + assert_eq!(actions, vec![Transfer, PurchaseOnDemandCoretime, Reserve, Register, Remark]); Ok(()) } } From 104684e816f6ff70782320be240b27d915f5024b Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Mon, 16 Dec 2024 21:26:48 +0000 Subject: [PATCH 3/4] refactor: improve language --- crates/pop-parachains/src/call/metadata/action.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/pop-parachains/src/call/metadata/action.rs b/crates/pop-parachains/src/call/metadata/action.rs index 74b1a98a3..05db261e3 100644 --- a/crates/pop-parachains/src/call/metadata/action.rs +++ b/crates/pop-parachains/src/call/metadata/action.rs @@ -83,11 +83,11 @@ pub enum Action { props(Pallet = "Registrar") )] Register, - /// Make some on-chain remark. + /// Make a remark. #[strum( serialize = "remark", message = "remark_with_event", - detailed_message = "Make some on-chain remark", + detailed_message = "Make a remark", props(Pallet = "System") )] Remark, @@ -145,7 +145,7 @@ mod tests { (Transfer, "Transfer balance"), (Register, "Register a parachain ID with genesis state and code"), (Reserve, "Reserve a parachain ID"), - (Remark, "Make some on-chain remark"), + (Remark, "Make a remark"), ]); for action in Action::VARIANTS.iter() { From 020e4bbf5b7a4337c22b3014ed13e86ef385af3b Mon Sep 17 00:00:00 2001 From: Frank Bell Date: Mon, 16 Dec 2024 21:28:14 +0000 Subject: [PATCH 4/4] refactor: improve language --- crates/pop-parachains/src/call/metadata/action.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/pop-parachains/src/call/metadata/action.rs b/crates/pop-parachains/src/call/metadata/action.rs index 05db261e3..1e8298fc7 100644 --- a/crates/pop-parachains/src/call/metadata/action.rs +++ b/crates/pop-parachains/src/call/metadata/action.rs @@ -43,19 +43,19 @@ pub enum Action { props(Pallet = "Assets") )] MintAsset, - /// Create an NFT collection. + /// Create a NFT collection. #[strum( serialize = "create_nft", message = "create", - detailed_message = "Create an NFT collection", + detailed_message = "Create a NFT collection", props(Pallet = "Nfts") )] CreateCollection, - /// Mint an NFT. + /// Mint a NFT. #[strum( serialize = "mint_nft", message = "mint", - detailed_message = "Mint an NFT", + detailed_message = "Mint a NFT", props(Pallet = "Nfts") )] MintNFT, @@ -139,8 +139,8 @@ mod tests { let descriptions = HashMap::from([ (CreateAsset, "Create an asset"), (MintAsset, "Mint an asset"), - (CreateCollection, "Create an NFT collection"), - (MintNFT, "Mint an NFT"), + (CreateCollection, "Create a NFT collection"), + (MintNFT, "Mint a NFT"), (PurchaseOnDemandCoretime, "Purchase on-demand coretime"), (Transfer, "Transfer balance"), (Register, "Register a parachain ID with genesis state and code"),