Skip to content

Commit 085ec66

Browse files
authored
Merge pull request #3545 from autonomys/min_transfer_amount
Add minimum transfer amount to transporting to different chain through XDM
2 parents a3f1a56 + 1012194 commit 085ec66

File tree

9 files changed

+28
-0
lines changed

9 files changed

+28
-0
lines changed

crates/subspace-runtime/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ where
798798

799799
parameter_types! {
800800
pub const TransporterEndpointId: EndpointId = 1;
801+
pub const MinimumTransfer: Balance = SSC;
801802
}
802803

803804
impl pallet_transporter::Config for Runtime {
@@ -809,6 +810,7 @@ impl pallet_transporter::Config for Runtime {
809810
type AccountIdConverter = AccountIdConverter;
810811
type WeightInfo = pallet_transporter::weights::SubstrateWeight<Runtime>;
811812
type SkipBalanceTransferChecks = pallet_domains::DomainsSkipBalanceChecks<Runtime>;
813+
type MinimumTransfer = MinimumTransfer;
812814
}
813815

814816
parameter_types! {

domains/pallets/messenger/src/mock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ macro_rules! impl_runtime {
153153

154154
parameter_types! {
155155
pub const TransporterEndpointId: EndpointId = 100;
156+
pub const MinimumTransfer: Balance = 1;
156157
}
157158

158159
#[derive(Debug)]
@@ -182,6 +183,7 @@ macro_rules! impl_runtime {
182183
type AccountIdConverter = MockAccountIdConverter;
183184
type WeightInfo = ();
184185
type SkipBalanceTransferChecks = ();
186+
type MinimumTransfer = MinimumTransfer;
185187
}
186188

187189
impl pallet_domains::Config for $runtime {}

domains/pallets/transporter/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ mod pallet {
117117

118118
/// Skip Balance transfer checks
119119
type SkipBalanceTransferChecks: SkipBalanceChecks;
120+
121+
/// Minimum transfer amount.
122+
type MinimumTransfer: Get<BalanceOf<Self>>;
120123
}
121124

122125
/// Pallet transporter to move funds between chains.
@@ -230,6 +233,8 @@ mod pallet {
230233
BalanceUnderflow,
231234
/// Emits when domain balance is already initialized
232235
DomainBalanceAlreadyInitialized,
236+
/// Emits when the requested transfer amount is less than Minimum transfer amount.
237+
MinimumTransferAmount,
233238
}
234239

235240
#[pallet::call]
@@ -244,6 +249,10 @@ mod pallet {
244249
amount: BalanceOf<T>,
245250
) -> DispatchResult {
246251
let sender = ensure_signed(origin)?;
252+
ensure!(
253+
amount >= T::MinimumTransfer::get(),
254+
Error::<T>::MinimumTransferAmount
255+
);
247256

248257
// burn transfer amount
249258
let _imbalance = T::Currency::withdraw(

domains/pallets/transporter/src/mock.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ impl TryConvertBack<AccountId, MultiAccountId> for MockAccountIdConverter {
157157
}
158158
}
159159

160+
parameter_types! {
161+
pub const MinimumTransfer: Balance = 1;
162+
}
163+
160164
impl Config for MockRuntime {
161165
type RuntimeEvent = RuntimeEvent;
162166
type SelfChainId = SelfChainId;
@@ -169,6 +173,7 @@ impl Config for MockRuntime {
169173
type AccountIdConverter = MockAccountIdConverter;
170174
type WeightInfo = ();
171175
type SkipBalanceTransferChecks = ();
176+
type MinimumTransfer = MinimumTransfer;
172177
}
173178

174179
pub const USER_ACCOUNT: AccountId = 1;

domains/runtime/auto-id/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ where
457457

458458
parameter_types! {
459459
pub const TransporterEndpointId: EndpointId = 1;
460+
pub const MinimumTransfer: Balance = SSC;
460461
}
461462

462463
impl pallet_transporter::Config for Runtime {
@@ -468,6 +469,7 @@ impl pallet_transporter::Config for Runtime {
468469
type AccountIdConverter = domain_runtime_primitives::AccountIdConverter;
469470
type WeightInfo = pallet_transporter::weights::SubstrateWeight<Runtime>;
470471
type SkipBalanceTransferChecks = ();
472+
type MinimumTransfer = MinimumTransfer;
471473
}
472474

473475
impl pallet_domain_id::Config for Runtime {}

domains/runtime/evm/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ where
609609

610610
parameter_types! {
611611
pub const TransporterEndpointId: EndpointId = 1;
612+
pub const MinimumTransfer: Balance = SSC;
612613
}
613614

614615
impl pallet_transporter::Config for Runtime {
@@ -620,6 +621,7 @@ impl pallet_transporter::Config for Runtime {
620621
type AccountIdConverter = domain_runtime_primitives::AccountId20Converter;
621622
type WeightInfo = pallet_transporter::weights::SubstrateWeight<Runtime>;
622623
type SkipBalanceTransferChecks = ();
624+
type MinimumTransfer = MinimumTransfer;
623625
}
624626

625627
impl pallet_evm_chain_id::Config for Runtime {}

domains/test/runtime/auto-id/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ where
455455

456456
parameter_types! {
457457
pub const TransporterEndpointId: EndpointId = 1;
458+
pub const MinimumTransfer: Balance = 1;
458459
}
459460

460461
impl pallet_transporter::Config for Runtime {
@@ -466,6 +467,7 @@ impl pallet_transporter::Config for Runtime {
466467
type AccountIdConverter = domain_runtime_primitives::AccountIdConverter;
467468
type WeightInfo = pallet_transporter::weights::SubstrateWeight<Runtime>;
468469
type SkipBalanceTransferChecks = ();
470+
type MinimumTransfer = MinimumTransfer;
469471
}
470472

471473
impl pallet_domain_id::Config for Runtime {}

domains/test/runtime/evm/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ where
643643

644644
parameter_types! {
645645
pub const TransporterEndpointId: EndpointId = 1;
646+
pub const MinimumTransfer: Balance = 1;
646647
}
647648

648649
impl pallet_transporter::Config for Runtime {
@@ -654,6 +655,7 @@ impl pallet_transporter::Config for Runtime {
654655
type AccountIdConverter = domain_runtime_primitives::AccountId20Converter;
655656
type WeightInfo = pallet_transporter::weights::SubstrateWeight<Runtime>;
656657
type SkipBalanceTransferChecks = ();
658+
type MinimumTransfer = MinimumTransfer;
657659
}
658660

659661
impl pallet_evm_chain_id::Config for Runtime {}

test/subspace-test-runtime/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ where
751751

752752
parameter_types! {
753753
pub const TransporterEndpointId: EndpointId = 1;
754+
pub const MinimumTransfer: Balance = 1;
754755
}
755756

756757
impl pallet_transporter::Config for Runtime {
@@ -762,6 +763,7 @@ impl pallet_transporter::Config for Runtime {
762763
type AccountIdConverter = AccountIdConverter;
763764
type WeightInfo = pallet_transporter::weights::SubstrateWeight<Runtime>;
764765
type SkipBalanceTransferChecks = ();
766+
type MinimumTransfer = MinimumTransfer;
765767
}
766768

767769
parameter_types! {

0 commit comments

Comments
 (0)