Skip to content

Commit bac24e6

Browse files
Chralt98sea212
andauthored
Add dispatch call indices (#1036)
* add call indices * update copyrights * fix copyrights * Update zrml/rikiddo/src/lib.rs Co-authored-by: Harald Heckmann <mail@haraldheckmann.de> --------- Co-authored-by: Harald Heckmann <mail@haraldheckmann.de>
1 parent fa1b839 commit bac24e6

File tree

8 files changed

+53
-8
lines changed

8 files changed

+53
-8
lines changed

zrml/authorized/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ mod pallet {
7676
#[pallet::call]
7777
impl<T: Config> Pallet<T> {
7878
/// Overwrites already provided outcomes for the same market and account.
79-
#[frame_support::transactional]
79+
#[pallet::call_index(0)]
8080
#[pallet::weight(
8181
T::WeightInfo::authorize_market_outcome_first_report(CacheSize::get()).max(
8282
T::WeightInfo::authorize_market_outcome_existing_report(),
8383
)
8484
)]
85+
#[frame_support::transactional]
8586
pub fn authorize_market_outcome(
8687
origin: OriginFor<T>,
8788
market_id: MarketIdOf<T>,

zrml/court/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ mod pallet {
101101
#[pallet::call]
102102
impl<T: Config> Pallet<T> {
103103
// MARK(non-transactional): `remove_juror_from_all_courts_of_all_markets` is infallible.
104+
#[pallet::call_index(0)]
104105
#[pallet::weight(T::WeightInfo::exit_court())]
105106
pub fn exit_court(origin: OriginFor<T>) -> DispatchResult {
106107
let who = ensure_signed(origin)?;
@@ -111,6 +112,7 @@ mod pallet {
111112
}
112113

113114
// MARK(non-transactional): Once `reserve_named` is successful, `insert` won't fail.
115+
#[pallet::call_index(1)]
114116
#[pallet::weight(T::WeightInfo::join_court())]
115117
pub fn join_court(origin: OriginFor<T>) -> DispatchResult {
116118
let who = ensure_signed(origin)?;
@@ -128,6 +130,7 @@ mod pallet {
128130
}
129131

130132
// MARK(non-transactional): No fallible storage operation is performed.
133+
#[pallet::call_index(2)]
131134
#[pallet::weight(T::WeightInfo::vote())]
132135
pub fn vote(
133136
origin: OriginFor<T>,

zrml/global-disputes/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Forecasting Technologies LTD.
1+
// Copyright 2022-2023 Forecasting Technologies LTD.
22
//
33
// This file is part of Zeitgeist.
44
//
@@ -209,8 +209,9 @@ mod pallet {
209209
///
210210
/// Complexity: `O(n)`, where `n` is the number of owner(s) of the winner outcome
211211
/// in the case that this gets called for an already finished global dispute.
212-
#[frame_support::transactional]
212+
#[pallet::call_index(0)]
213213
#[pallet::weight(T::WeightInfo::add_vote_outcome(T::MaxOwners::get()))]
214+
#[frame_support::transactional]
214215
pub fn add_vote_outcome(
215216
origin: OriginFor<T>,
216217
#[pallet::compact] market_id: MarketIdOf<T>,
@@ -258,11 +259,12 @@ mod pallet {
258259
///
259260
/// Complexity: `O(n)`,
260261
/// where `n` is the number of all existing outcomes for a global dispute.
261-
#[frame_support::transactional]
262+
#[pallet::call_index(1)]
262263
#[pallet::weight(T::WeightInfo::purge_outcomes(
263264
T::RemoveKeysLimit::get(),
264265
T::MaxOwners::get(),
265266
))]
267+
#[frame_support::transactional]
266268
pub fn purge_outcomes(
267269
origin: OriginFor<T>,
268270
#[pallet::compact] market_id: MarketIdOf<T>,
@@ -314,12 +316,13 @@ mod pallet {
314316
/// # Weight
315317
///
316318
/// Complexity: `O(n)`, where `n` is the number of owners for the winning outcome.
317-
#[frame_support::transactional]
319+
#[pallet::call_index(2)]
318320
#[pallet::weight(
319321
T::WeightInfo::reward_outcome_owner_no_funds(T::MaxOwners::get()).max(
320322
T::WeightInfo::reward_outcome_owner_with_funds(T::MaxOwners::get()),
321323
)
322324
)]
325+
#[frame_support::transactional]
323326
pub fn reward_outcome_owner(
324327
origin: OriginFor<T>,
325328
#[pallet::compact] market_id: MarketIdOf<T>,
@@ -396,11 +399,12 @@ mod pallet {
396399
///
397400
/// Complexity: `O(n + m)`, where `n` is the number of all current votes on global disputes,
398401
/// and `m` is the number of owners for the specified outcome.
399-
#[frame_support::transactional]
402+
#[pallet::call_index(3)]
400403
#[pallet::weight(T::WeightInfo::vote_on_outcome(
401404
T::MaxOwners::get(),
402405
T::MaxGlobalDisputeVotes::get(),
403406
))]
407+
#[frame_support::transactional]
404408
pub fn vote_on_outcome(
405409
origin: OriginFor<T>,
406410
#[pallet::compact] market_id: MarketIdOf<T>,
@@ -482,7 +486,7 @@ mod pallet {
482486
///
483487
/// Complexity: `O(n + m)`, where `n` is the number of all current votes on global disputes,
484488
/// and `m` is the number of owners for the winning outcome.
485-
#[frame_support::transactional]
489+
#[pallet::call_index(4)]
486490
#[pallet::weight(
487491
T::WeightInfo::unlock_vote_balance_set(
488492
T::MaxGlobalDisputeVotes::get(),
@@ -493,6 +497,7 @@ mod pallet {
493497
T::MaxOwners::get(),
494498
))
495499
)]
500+
#[frame_support::transactional]
496501
pub fn unlock_vote_balance(
497502
origin: OriginFor<T>,
498503
voter: AccountIdLookupOf<T>,

zrml/liquidity-mining/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 Forecasting Technologies LTD.
1+
// Copyright 2022-2023 Forecasting Technologies LTD.
22
// Copyright 2021-2022 Zeitgeist PM LLC.
33
//
44
// This file is part of Zeitgeist.
@@ -87,6 +87,7 @@ mod pallet {
8787

8888
#[pallet::call]
8989
impl<T: Config> Pallet<T> {
90+
#[pallet::call_index(0)]
9091
#[pallet::weight(T::WeightInfo::set_per_block_distribution())]
9192
// MARK(non-transactional): `set_per_block_distribution` is infallible.
9293
pub fn set_per_block_distribution(

zrml/orderbook-v1/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2022-2023 Forecasting Technologies LTD.
12
// Copyright 2021-2022 Zeitgeist PM LLC.
23
//
34
// This file is part of Zeitgeist.
@@ -67,6 +68,7 @@ mod pallet {
6768

6869
#[pallet::call]
6970
impl<T: Config> Pallet<T> {
71+
#[pallet::call_index(0)]
7072
#[pallet::weight(
7173
T::WeightInfo::cancel_order_ask().max(T::WeightInfo::cancel_order_bid())
7274
)]
@@ -112,6 +114,7 @@ mod pallet {
112114
}
113115
}
114116

117+
#[pallet::call_index(1)]
115118
#[pallet::weight(
116119
T::WeightInfo::fill_order_ask().max(T::WeightInfo::fill_order_bid())
117120
)]
@@ -178,6 +181,7 @@ mod pallet {
178181
}
179182
}
180183

184+
#[pallet::call_index(2)]
181185
#[pallet::weight(
182186
T::WeightInfo::make_order_ask().max(T::WeightInfo::make_order_bid())
183187
)]

zrml/prediction-markets/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ mod pallet {
303303
///
304304
/// Must be called by `DestroyOrigin`. Bonds (unless already returned) are slashed without
305305
/// exception. Can currently only be used for destroying CPMM markets.
306+
#[pallet::call_index(0)]
306307
#[pallet::weight((
307308
T::WeightInfo::admin_destroy_reported_market(
308309
T::MaxCategories::get().into(),
@@ -419,6 +420,7 @@ mod pallet {
419420
//
420421
// Within the same block, operations that interact with the activeness of the same
421422
// market will behave differently before and after this call.
423+
#[pallet::call_index(1)]
422424
#[pallet::weight((
423425
T::WeightInfo::admin_move_market_to_closed(
424426
CacheSize::get(), CacheSize::get()), Pays::No
@@ -452,6 +454,7 @@ mod pallet {
452454
///
453455
/// Complexity: `O(n + m)`, where `n` is the number of market ids
454456
/// per dispute / report block, m is the number of disputes.
457+
#[pallet::call_index(2)]
455458
#[pallet::weight((
456459
T::WeightInfo::admin_move_market_to_resolved_scalar_reported(CacheSize::get())
457460
.max(
@@ -512,6 +515,7 @@ mod pallet {
512515
/// # Weight
513516
///
514517
/// Complexity: `O(1)`
518+
#[pallet::call_index(3)]
515519
#[pallet::weight((T::WeightInfo::approve_market(), Pays::No))]
516520
#[transactional]
517521
pub fn approve_market(
@@ -564,6 +568,7 @@ mod pallet {
564568
/// # Weight
565569
///
566570
/// Complexity: `O(edit_reason.len())`
571+
#[pallet::call_index(4)]
567572
#[pallet::weight((
568573
T::WeightInfo::request_edit(edit_reason.len() as u32),
569574
Pays::No,
@@ -609,6 +614,7 @@ mod pallet {
609614
// The worst-case scenario is assumed
610615
// and the correct weight is calculated at the end of this function.
611616
// This also occurs in numerous other functions.
617+
#[pallet::call_index(5)]
612618
#[pallet::weight(T::WeightInfo::buy_complete_set(T::MaxCategories::get().into()))]
613619
#[transactional]
614620
pub fn buy_complete_set(
@@ -625,6 +631,7 @@ mod pallet {
625631
/// # Weight
626632
///
627633
/// Complexity: `O(n)`, where `n` is the number of outstanding disputes.
634+
#[pallet::call_index(6)]
628635
#[pallet::weight(T::WeightInfo::dispute_authorized())]
629636
#[transactional]
630637
pub fn dispute(
@@ -701,6 +708,7 @@ mod pallet {
701708
/// where `n` is the number of outcome assets for the categorical market
702709
/// and `m` is the number of market ids,
703710
/// which open at the same time as the specified market.
711+
#[pallet::call_index(7)]
704712
#[pallet::weight(
705713
T::WeightInfo::create_market(CacheSize::get())
706714
.saturating_add(T::WeightInfo::buy_complete_set(T::MaxCategories::get().into()))
@@ -763,6 +771,7 @@ mod pallet {
763771
///
764772
/// Complexity: `O(n)`, where `n` is the number of market ids,
765773
/// which close at the same time as the specified market.
774+
#[pallet::call_index(8)]
766775
#[pallet::weight(T::WeightInfo::create_market(CacheSize::get()))]
767776
#[transactional]
768777
pub fn create_market(
@@ -851,6 +860,7 @@ mod pallet {
851860
///
852861
/// Complexity: `O(n)`, where `n` is the number of markets
853862
/// which end at the same time as the market before the edit.
863+
#[pallet::call_index(9)]
854864
#[pallet::weight(T::WeightInfo::edit_market(CacheSize::get()))]
855865
#[transactional]
856866
pub fn edit_market(
@@ -927,6 +937,7 @@ mod pallet {
927937
/// where `n` is the number of outcome assets for the categorical market,
928938
/// and `m` is the number of market ids,
929939
/// which open at the same time as the specified market.
940+
#[pallet::call_index(10)]
930941
#[pallet::weight(
931942
T::WeightInfo::buy_complete_set(T::MaxCategories::get().into())
932943
.saturating_add(
@@ -978,6 +989,7 @@ mod pallet {
978989
/// where `n` is the number of outcome assets for the categorical market,
979990
/// and `m` is the number of market ids,
980991
/// which open at the same time as the specified market.
992+
#[pallet::call_index(11)]
981993
#[pallet::weight(
982994
T::WeightInfo::deploy_swap_pool_for_market_open_pool(weights.len() as u32)
983995
.max(
@@ -1085,6 +1097,7 @@ mod pallet {
10851097
/// # Weight
10861098
///
10871099
/// Complexity: `O(1)`
1100+
#[pallet::call_index(12)]
10881101
#[pallet::weight(T::WeightInfo::redeem_shares_categorical()
10891102
.max(T::WeightInfo::redeem_shares_scalar())
10901103
)]
@@ -1229,6 +1242,7 @@ mod pallet {
12291242
/// which open at the same time as the specified market,
12301243
/// and `m` is the number of market ids,
12311244
/// which close at the same time as the specified market.
1245+
#[pallet::call_index(13)]
12321246
#[pallet::weight((
12331247
T::WeightInfo::reject_market(
12341248
CacheSize::get(),
@@ -1266,6 +1280,7 @@ mod pallet {
12661280
///
12671281
/// Complexity: `O(n)`, where `n` is the number of market ids,
12681282
/// which reported at the same time as the specified market.
1283+
#[pallet::call_index(14)]
12691284
#[pallet::weight(T::WeightInfo::report(CacheSize::get()))]
12701285
#[transactional]
12711286
pub fn report(
@@ -1377,6 +1392,7 @@ mod pallet {
13771392
/// # Weight
13781393
///
13791394
/// Complexity: `O(n)`, where `n` is the number of assets for a categorical market.
1395+
#[pallet::call_index(15)]
13801396
#[pallet::weight(
13811397
T::WeightInfo::sell_complete_set(T::MaxCategories::get().into())
13821398
)]
@@ -1434,6 +1450,7 @@ mod pallet {
14341450
/// The outcomes of the disputes and the report outcome
14351451
/// are added to the global dispute voting outcomes.
14361452
/// The bond of each dispute is the initial vote amount.
1453+
#[pallet::call_index(16)]
14371454
#[pallet::weight(T::WeightInfo::start_global_dispute(CacheSize::get(), CacheSize::get()))]
14381455
#[transactional]
14391456
pub fn start_global_dispute(

zrml/styx/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright 2022-2023 Forecasting Technologies LTD.
12
// Copyright 2021-2022 Zeitgeist PM LLC.
23
//
34
// This file is part of Zeitgeist.
@@ -85,6 +86,7 @@ pub mod pallet {
8586
impl<T: Config> Pallet<T> {
8687
/// Burns ZTG(styx.burnAmount()) to cross, granting the ability to claim your zeitgeist avatar.
8788
/// The signer can only cross once.
89+
#[pallet::call_index(0)]
8890
#[pallet::weight(T::WeightInfo::cross())]
8991
pub fn cross(origin: OriginFor<T>) -> DispatchResult {
9092
let who = ensure_signed(origin)?;
@@ -113,6 +115,7 @@ pub mod pallet {
113115
/// # Arguments
114116
///
115117
/// * `amount`: The amount of the new burn price
118+
#[pallet::call_index(1)]
116119
#[pallet::weight(T::WeightInfo::set_burn_amount())]
117120
pub fn set_burn_amount(
118121
origin: OriginFor<T>,

0 commit comments

Comments
 (0)