Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/workaround metadata bug for pallet config #5064

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 51 additions & 10 deletions state-chain/pallets/cf-ingress-egress/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ use frame_support::{
};
use frame_system::pallet_prelude::*;
pub use pallet::*;
use scale_info::{
build::{Fields, Variants},
Path, Type,
};
use sp_runtime::traits::UniqueSaturatedInto;
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
Expand Down Expand Up @@ -197,17 +201,9 @@ pub struct FailedForeignChainCall {
}

#[derive(
CloneNoBound,
RuntimeDebugNoBound,
PartialEqNoBound,
EqNoBound,
Encode,
Decode,
TypeInfo,
MaxEncodedLen,
CloneNoBound, RuntimeDebugNoBound, PartialEqNoBound, EqNoBound, Encode, Decode, MaxEncodedLen,
)]
#[scale_info(skip_type_params(T, I))]
pub enum PalletConfigUpdate<T: Config<I>, I: 'static = ()> {
pub enum PalletConfigUpdate<T: Config<I>, I: 'static> {
/// Set the fixed fee that is burned when opening a channel, denominated in Flipperinos.
ChannelOpeningFee { fee: T::Amount },
/// Set the minimum deposit allowed for a particular asset.
Expand All @@ -217,6 +213,51 @@ pub enum PalletConfigUpdate<T: Config<I>, I: 'static = ()> {
SetMaxSwapRetryDurationBlocks { blocks: BlockNumber },
}

macro_rules! append_chain_to_name {
($name:ident) => {
match T::TargetChain::NAME {
"Ethereum" => concat!(stringify!($name), "Ethereum"),
"Polkadot" => concat!(stringify!($name), "Polkadot"),
"Bitcoin" => concat!(stringify!($name), "Bitcoin"),
"Arbitrum" => concat!(stringify!($name), "Arbitrum"),
"Solana" => concat!(stringify!($name), "Solana"),
_ => concat!(stringify!($name), "Other"),
}
};
}

impl<T, I> TypeInfo for PalletConfigUpdate<T, I>
kylezs marked this conversation as resolved.
Show resolved Hide resolved
where
T: Config<I>,
I: 'static,
{
type Identity = Self;
fn type_info() -> Type {
Type::builder()
.path(Path::new(append_chain_to_name!(PalletConfigUpdate), module_path!()))
.variant(
Variants::new()
.variant("ChannelOpeningFee", |v| {
v.index(0)
.fields(Fields::named().field(|f| f.ty::<T::Amount>().name("fee")))
})
.variant(append_chain_to_name!(SetMinimumDeposit), |v| {
kylezs marked this conversation as resolved.
Show resolved Hide resolved
v.index(1).fields(
Fields::named()
.field(|f| f.ty::<TargetChainAsset<T, I>>().name("asset"))
.field(|f| {
f.ty::<TargetChainAmount<T, I>>().name("minimum_deposit")
}),
)
})
.variant("SetMaxSwapRetryDurationBlocks", |v| {
v.index(2)
.fields(Fields::named().field(|f| f.ty::<BlockNumber>().name("blocks")))
}),
)
}
}

#[frame_support::pallet]
pub mod pallet {
use super::*;
Expand Down
Loading