From 02c5b95c7af87e485f21b7d03424648cb1f42df7 Mon Sep 17 00:00:00 2001 From: code0xff Date: Tue, 10 Sep 2024 17:56:07 +0900 Subject: [PATCH] refactor: Move any_match to pallet-cosmos-types --- frame/cosmos/src/lib.rs | 4 ++-- frame/cosmos/src/mock.rs | 4 ++-- frame/cosmos/types/src/lib.rs | 1 + frame/cosmos/{x/auth/signing => types}/src/macros.rs | 0 frame/cosmos/x/auth/signing/src/lib.rs | 1 - frame/cosmos/x/auth/signing/src/sign_mode_handler/mod.rs | 2 +- frame/cosmos/x/auth/signing/src/sign_verifiable_tx/mod.rs | 3 +-- frame/cosmos/x/auth/src/sigverify.rs | 3 +-- template/runtime/src/lib.rs | 3 ++- template/runtime/src/msgs.rs | 3 +-- 10 files changed, 11 insertions(+), 13 deletions(-) rename frame/cosmos/{x/auth/signing => types}/src/macros.rs (100%) diff --git a/frame/cosmos/src/lib.rs b/frame/cosmos/src/lib.rs index fb37f84..0df2627 100644 --- a/frame/cosmos/src/lib.rs +++ b/frame/cosmos/src/lib.rs @@ -62,8 +62,7 @@ use pallet_cosmos_types::{ tx::Account, }; use pallet_cosmos_x_auth_signing::{ - any_match, sign_mode_handler::traits::SignModeHandler, - sign_verifiable_tx::traits::SigVerifiableTx, + sign_mode_handler::traits::SignModeHandler, sign_verifiable_tx::traits::SigVerifiableTx, }; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; @@ -185,6 +184,7 @@ pub mod pallet { pub mod config_preludes { use super::*; use frame_support::{derive_impl, parameter_types}; + use pallet_cosmos_types::any_match; pub struct TestDefaultConfig; diff --git a/frame/cosmos/src/mock.rs b/frame/cosmos/src/mock.rs index 035bca6..953206c 100644 --- a/frame/cosmos/src/mock.rs +++ b/frame/cosmos/src/mock.rs @@ -32,9 +32,9 @@ use frame_support::{derive_impl, parameter_types, traits::AsEnsureOriginWithArg, use hp_account::CosmosSigner; use hp_crypto::EcdsaExt; use pallet_cosmos::{config_preludes::ChainId, AddressMapping}; -use pallet_cosmos_types::msgservice::MsgHandler; +use pallet_cosmos_types::{any_match, msgservice::MsgHandler}; use pallet_cosmos_x_auth_signing::{ - any_match, sign_mode_handler::SignModeHandler, sign_verifiable_tx::SigVerifiableTx, + sign_mode_handler::SignModeHandler, sign_verifiable_tx::SigVerifiableTx, }; use pallet_cosmos_x_bank::msgs::MsgSendHandler; use pallet_cosmos_x_wasm::msgs::{ diff --git a/frame/cosmos/types/src/lib.rs b/frame/cosmos/types/src/lib.rs index 231a26c..843143a 100644 --- a/frame/cosmos/types/src/lib.rs +++ b/frame/cosmos/types/src/lib.rs @@ -26,6 +26,7 @@ pub mod errors; pub mod events; pub mod gas; pub mod handler; +pub mod macros; pub mod msgservice; pub mod tx; pub mod tx_msgs; diff --git a/frame/cosmos/x/auth/signing/src/macros.rs b/frame/cosmos/types/src/macros.rs similarity index 100% rename from frame/cosmos/x/auth/signing/src/macros.rs rename to frame/cosmos/types/src/macros.rs diff --git a/frame/cosmos/x/auth/signing/src/lib.rs b/frame/cosmos/x/auth/signing/src/lib.rs index e0cf095..2f5e5a3 100644 --- a/frame/cosmos/x/auth/signing/src/lib.rs +++ b/frame/cosmos/x/auth/signing/src/lib.rs @@ -21,6 +21,5 @@ extern crate alloc; -pub mod macros; pub mod sign_mode_handler; pub mod sign_verifiable_tx; diff --git a/frame/cosmos/x/auth/signing/src/sign_mode_handler/mod.rs b/frame/cosmos/x/auth/signing/src/sign_mode_handler/mod.rs index e5d8349..f4a9d10 100644 --- a/frame/cosmos/x/auth/signing/src/sign_mode_handler/mod.rs +++ b/frame/cosmos/x/auth/signing/src/sign_mode_handler/mod.rs @@ -18,7 +18,6 @@ pub mod traits; -use crate::any_match; use alloc::{ string::{String, ToString}, vec::Vec, @@ -35,6 +34,7 @@ use cosmos_sdk_proto::{ traits::Message, Any, }; +use pallet_cosmos_types::any_match; use pallet_cosmos_x_auth_migrations::legacytx::stdsign::{LegacyMsg, StdSignDoc}; use pallet_cosmos_x_bank_types::msgs::msg_send::MsgSend; use pallet_cosmos_x_wasm_types::tx::{ diff --git a/frame/cosmos/x/auth/signing/src/sign_verifiable_tx/mod.rs b/frame/cosmos/x/auth/signing/src/sign_verifiable_tx/mod.rs index c2c770e..c57becc 100644 --- a/frame/cosmos/x/auth/signing/src/sign_verifiable_tx/mod.rs +++ b/frame/cosmos/x/auth/signing/src/sign_verifiable_tx/mod.rs @@ -18,13 +18,12 @@ pub mod traits; -use crate::any_match; use alloc::{string::String, vec::Vec}; use cosmos_sdk_proto::{ cosmos::{bank, tx::v1beta1::Tx}, cosmwasm::wasm, }; -use pallet_cosmos_types::tx_msgs::Msg; +use pallet_cosmos_types::{any_match, tx_msgs::Msg}; use pallet_cosmos_x_bank_types::msgs::msg_send::MsgSend; use pallet_cosmos_x_wasm_types::tx::{ msg_execute_contract::MsgExecuteContract, msg_instantiate_contract2::MsgInstantiateContract2, diff --git a/frame/cosmos/x/auth/src/sigverify.rs b/frame/cosmos/x/auth/src/sigverify.rs index b1db8f7..095f2d8 100644 --- a/frame/cosmos/x/auth/src/sigverify.rs +++ b/frame/cosmos/x/auth/src/sigverify.rs @@ -28,9 +28,8 @@ use cosmos_sdk_proto::{ }; use hp_io::cosmos::secp256k1_ecdsa_verify; use pallet_cosmos::AddressMapping; -use pallet_cosmos_types::{address::acc_address_from_bech32, handler::AnteDecorator}; +use pallet_cosmos_types::{address::acc_address_from_bech32, any_match, handler::AnteDecorator}; use pallet_cosmos_x_auth_signing::{ - any_match, sign_mode_handler::{traits::SignModeHandler, SignerData}, sign_verifiable_tx::traits::SigVerifiableTx, }; diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index 4aa6b3c..58ee192 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -63,8 +63,9 @@ use pallet_cosmos::{ }, AddressMapping, }; +use pallet_cosmos_types::any_match; use pallet_cosmos_x_auth_signing::{ - any_match, sign_mode_handler::SignModeHandler, sign_verifiable_tx::SigVerifiableTx, + sign_mode_handler::SignModeHandler, sign_verifiable_tx::SigVerifiableTx, }; use pallet_cosmwasm::instrument::CostRules; use pallet_grandpa::{ diff --git a/template/runtime/src/msgs.rs b/template/runtime/src/msgs.rs index 482dd42..c7ae0e8 100644 --- a/template/runtime/src/msgs.rs +++ b/template/runtime/src/msgs.rs @@ -27,8 +27,7 @@ use cosmos_sdk_proto::{ Any, }; use hp_crypto::EcdsaExt; -use pallet_cosmos_types::{context, msgservice::MsgHandler}; -use pallet_cosmos_x_auth_signing::any_match; +use pallet_cosmos_types::{any_match, context, msgservice::MsgHandler}; use pallet_cosmos_x_bank::msgs::MsgSendHandler; use pallet_cosmos_x_wasm::msgs::{ MsgExecuteContractHandler, MsgInstantiateContract2Handler, MsgMigrateContractHandler,