Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dandanlen committed Aug 8, 2024
1 parent 16f32a7 commit 4c6fb4e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
14 changes: 12 additions & 2 deletions state-chain/chains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,18 @@ pub struct SwapRefundParameters {
#[derive(
Clone, Debug, PartialEq, Eq, Encode, Decode, TypeInfo, MaxEncodedLen, Serialize, Deserialize,
)]
pub struct ChannelRefundParameters {
pub struct ChannelRefundParameters<A> {
pub retry_duration: cf_primitives::BlockNumber,
pub refund_address: ForeignChainAddress,
pub refund_address: A,
pub min_price: Price,
}

impl<A> ChannelRefundParameters<A> {
pub fn map_address<B, F: FnOnce(A) -> B>(self, f: F) -> ChannelRefundParameters<B> {
ChannelRefundParameters {
retry_duration: self.retry_duration,
refund_address: f(self.refund_address),
min_price: self.min_price,
}
}
}
6 changes: 3 additions & 3 deletions state-chain/pallets/cf-ingress-egress/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ pub mod pallet {
destination_asset: Asset,
destination_address: ForeignChainAddress,
broker_fees: Beneficiaries<AccountId>,
refund_params: Option<ChannelRefundParameters>,
refund_params: Option<ChannelRefundParameters<ForeignChainAddress>>,
},
LiquidityProvision {
lp_account: AccountId,
Expand All @@ -337,7 +337,7 @@ pub mod pallet {
destination_address: ForeignChainAddress,
broker_fees: Beneficiaries<AccountId>,
channel_metadata: CcmChannelMetadata,
refund_params: Option<ChannelRefundParameters>,
refund_params: Option<ChannelRefundParameters<ForeignChainAddress>>,
},
}

Expand Down Expand Up @@ -2071,7 +2071,7 @@ impl<T: Config<I>, I: 'static> DepositApi<T::TargetChain> for Pallet<T, I> {
broker_id: T::AccountId,
channel_metadata: Option<CcmChannelMetadata>,
boost_fee: BasisPoints,
refund_params: Option<ChannelRefundParameters>,
refund_params: Option<ChannelRefundParameters<ForeignChainAddress>>,
) -> Result<
(ChannelId, ForeignChainAddress, <T::TargetChain as Chain>::ChainBlockNumber, Self::Amount),
DispatchError,
Expand Down
8 changes: 4 additions & 4 deletions state-chain/pallets/cf-swapping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ pub mod pallet {
boost_fee: BasisPoints,
channel_opening_fee: T::Amount,
affiliate_fees: Affiliates<T::AccountId>,
refund_parameters: Option<ChannelRefundParameters>,
refund_parameters: Option<ChannelRefundParameters<EncodedAddress>>,
},
/// A swap is scheduled for the first time
SwapScheduled {
Expand Down Expand Up @@ -953,7 +953,7 @@ pub mod pallet {
channel_metadata: Option<CcmChannelMetadata>,
boost_fee: BasisPoints,
affiliate_fees: Affiliates<T::AccountId>,
refund_parameters: Option<ChannelRefundParameters>,
refund_parameters: Option<ChannelRefundParameters<ForeignChainAddress>>,
) -> DispatchResult {
let broker = T::AccountRoleRegistry::ensure_broker(origin)?;
let (beneficiaries, total_bps) = {
Expand Down Expand Up @@ -1501,7 +1501,7 @@ pub mod pallet {
amount: AssetAmount,
destination_address: ForeignChainAddress,
broker_commission: Beneficiaries<Self::AccountId>,
refund_params: Option<ChannelRefundParameters>,
refund_params: Option<ChannelRefundParameters<ForeignChainAddress>>,
channel_id: ChannelId,
) -> SwapId {
// Permill maxes out at 100% so this is safe.
Expand Down Expand Up @@ -1584,7 +1584,7 @@ pub mod pallet {
deposit_metadata: CcmDepositMetadata,
origin: SwapOrigin,
// TODO: CCM should use refund params
_refund_params: Option<ChannelRefundParameters>,
_refund_params: Option<ChannelRefundParameters<ForeignChainAddress>>,
) -> Result<CcmSwapIds, ()> {
let encoded_destination_address =
T::AddressConverter::to_encoded_address(destination_address.clone());
Expand Down

0 comments on commit 4c6fb4e

Please sign in to comment.