Skip to content

Commit

Permalink
Added explicit call indexes to difficulty and creditcoin pallets
Browse files Browse the repository at this point in the history
  • Loading branch information
Ada committed Feb 22, 2023
1 parent c502195 commit 70bf108
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 23 additions & 1 deletion pallets/creditcoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Claims legacy wallet and transfers the balance to the sender's account.
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::claim_legacy_wallet())]
pub fn claim_legacy_wallet(
origin: OriginFor<T>,
Expand Down Expand Up @@ -606,6 +607,7 @@ pub mod pallet {
}

/// Registers an external address on `blockchain` and `network` with value `address`
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::register_address())]
pub fn register_address(
origin: OriginFor<T>,
Expand Down Expand Up @@ -648,6 +650,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::add_ask_order())]
pub fn add_ask_order(
origin: OriginFor<T>,
Expand Down Expand Up @@ -689,6 +692,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::add_bid_order())]
pub fn add_bid_order(
origin: OriginFor<T>,
Expand Down Expand Up @@ -730,6 +734,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(4)]
#[pallet::weight(<T as Config>::WeightInfo::add_offer())]
pub fn add_offer(
origin: OriginFor<T>,
Expand Down Expand Up @@ -781,6 +786,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::add_deal_order())]
pub fn add_deal_order(
origin: OriginFor<T>,
Expand Down Expand Up @@ -832,6 +838,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(6)]
#[pallet::weight(<T as Config>::WeightInfo::lock_deal_order())]
pub fn lock_deal_order(
origin: OriginFor<T>,
Expand All @@ -858,6 +865,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(7)]
#[pallet::weight(<T as Config>::WeightInfo::fund_deal_order())]
pub fn fund_deal_order(
origin: OriginFor<T>,
Expand Down Expand Up @@ -910,6 +918,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(8)]
#[pallet::weight(<T as Config>::WeightInfo::register_deal_order())]
pub fn register_deal_order(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1020,6 +1029,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(9)]
#[pallet::weight(<T as Config>::WeightInfo::close_deal_order())]
pub fn close_deal_order(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1073,6 +1083,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(10)]
#[pallet::weight(<T as Config>::WeightInfo::request_collect_coins())]
pub fn request_collect_coins(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1114,6 +1125,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(11)]
#[pallet::weight(<T as Config>::WeightInfo::register_funding_transfer_legacy())]
pub fn register_funding_transfer_legacy(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1142,6 +1154,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(12)]
#[pallet::weight(<T as Config>::WeightInfo::register_repayment_transfer_legacy())]
pub fn register_repayment_transfer_legacy(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1171,6 +1184,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(13)]
#[pallet::weight(<T as Config>::WeightInfo::register_funding_transfer())]
pub fn register_funding_transfer(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1198,6 +1212,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(14)]
#[pallet::weight(<T as Config>::WeightInfo::register_repayment_transfer())]
pub fn register_repayment_transfer(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1225,6 +1240,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(15)]
#[pallet::weight(<T as Config>::WeightInfo::exempt())]
pub fn exempt(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1275,6 +1291,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(16)]
#[pallet::weight(match &task_output {
crate::TaskOutput::CollectCoins(..) => <T as Config>::WeightInfo::persist_collect_coins(),
crate::TaskOutput::VerifyTransfer(..) => <T as Config>::WeightInfo::persist_transfer(),
Expand Down Expand Up @@ -1330,6 +1347,7 @@ pub mod pallet {
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

#[pallet::call_index(17)]
#[pallet::weight(match &task_id {
crate::TaskId::VerifyTransfer(..) => <T as Config>::WeightInfo::fail_transfer(),
crate::TaskId::CollectCoins(..) => <T as Config>::WeightInfo::fail_collect_coins(),
Expand Down Expand Up @@ -1366,6 +1384,7 @@ pub mod pallet {
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

#[pallet::call_index(18)]
#[pallet::weight(<T as Config>::WeightInfo::add_authority())]
pub fn add_authority(
origin: OriginFor<T>,
Expand All @@ -1380,6 +1399,7 @@ pub mod pallet {
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

#[pallet::call_index(19)]
#[pallet::weight(<T as Config>::WeightInfo::register_currency())]
pub fn register_currency(origin: OriginFor<T>, currency: Currency) -> DispatchResult {
ensure_root(origin)?;
Expand All @@ -1395,6 +1415,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(20)]
#[pallet::weight(<T as Config>::WeightInfo::set_collect_coins_contract())]
pub fn set_collect_coins_contract(
origin: OriginFor<T>,
Expand All @@ -1406,6 +1427,7 @@ pub mod pallet {
}

#[transactional]
#[pallet::call_index(21)]
#[pallet::weight(<T as Config>::WeightInfo::remove_authority())]
pub fn remove_authority(
origin: OriginFor<T>,
Expand All @@ -1420,4 +1442,4 @@ pub mod pallet {
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}
}
}
}
4 changes: 3 additions & 1 deletion pallets/difficulty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub mod pallet {

#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::set_target_block_time())]
pub fn set_target_block_time(
origin: OriginFor<T>,
Expand All @@ -128,6 +129,7 @@ pub mod pallet {

Ok(())
}
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::set_adjustment_period())]
pub fn set_adjustment_period(origin: OriginFor<T>, period: i64) -> DispatchResult {
ensure_root(origin)?;
Expand Down Expand Up @@ -229,4 +231,4 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
CurrentDifficulty::<T>::put(next_difficulty);
PreviousDifficultiesAndTimestamps::<T>::put(previous);
}
}
}

0 comments on commit 70bf108

Please sign in to comment.