Skip to content

Commit 9f4db77

Browse files
committed
use explicit call index
1 parent dc39cfd commit 9f4db77

File tree

14 files changed

+53
-1
lines changed

14 files changed

+53
-1
lines changed

asset-registry/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ pub mod module {
140140

141141
#[pallet::call]
142142
impl<T: Config> Pallet<T> {
143+
#[pallet::call_index(0)]
143144
#[pallet::weight(T::WeightInfo::register_asset())]
144145
pub fn register_asset(
145146
origin: OriginFor<T>,
@@ -151,6 +152,7 @@ pub mod module {
151152
Self::do_register_asset(metadata, asset_id)
152153
}
153154

155+
#[pallet::call_index(1)]
154156
#[pallet::weight(T::WeightInfo::update_asset())]
155157
pub fn update_asset(
156158
origin: OriginFor<T>,

auction/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ pub mod module {
127127
///
128128
/// The dispatch origin for this call must be `Signed` by the
129129
/// transactor.
130+
#[pallet::call_index(0)]
130131
#[pallet::weight(T::WeightInfo::bid_collateral_auction())]
131132
pub fn bid(origin: OriginFor<T>, id: T::AuctionId, #[pallet::compact] value: T::Balance) -> DispatchResult {
132133
let from = ensure_signed(origin)?;

authority/src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ pub mod module {
307307
#[pallet::call]
308308
impl<T: Config> Pallet<T> {
309309
/// Dispatch a dispatchable on behalf of other origin
310+
#[pallet::call_index(0)]
310311
#[pallet::weight({
311312
let info = call.get_dispatch_info();
312313
(T::WeightInfo::dispatch_as().saturating_add(info.weight), info.class)
@@ -324,6 +325,7 @@ pub mod module {
324325

325326
/// Schedule a dispatchable to be dispatched at later block.
326327
/// This is the only way to dispatch a call with `DelayedOrigin`.
328+
#[pallet::call_index(1)]
327329
#[pallet::weight(T::WeightInfo::schedule_dispatch_without_delay())]
328330
pub fn schedule_dispatch(
329331
origin: OriginFor<T>,
@@ -375,6 +377,7 @@ pub mod module {
375377
}
376378

377379
/// Fast track a scheduled dispatchable.
380+
#[pallet::call_index(2)]
378381
#[pallet::weight(T::WeightInfo::fast_track_scheduled_dispatch())]
379382
pub fn fast_track_scheduled_dispatch(
380383
origin: OriginFor<T>,
@@ -405,6 +408,7 @@ pub mod module {
405408
}
406409

407410
/// Delay a scheduled dispatchable.
411+
#[pallet::call_index(3)]
408412
#[pallet::weight(T::WeightInfo::delay_scheduled_dispatch())]
409413
pub fn delay_scheduled_dispatch(
410414
origin: OriginFor<T>,
@@ -432,6 +436,7 @@ pub mod module {
432436
}
433437

434438
/// Cancel a scheduled dispatchable.
439+
#[pallet::call_index(4)]
435440
#[pallet::weight(T::WeightInfo::cancel_scheduled_dispatch())]
436441
pub fn cancel_scheduled_dispatch(
437442
origin: OriginFor<T>,
@@ -448,6 +453,7 @@ pub mod module {
448453
Ok(())
449454
}
450455

456+
#[pallet::call_index(5)]
451457
#[pallet::weight(T::WeightInfo::authorize_call())]
452458
pub fn authorize_call(
453459
origin: OriginFor<T>,
@@ -461,6 +467,7 @@ pub mod module {
461467
Ok(())
462468
}
463469

470+
#[pallet::call_index(6)]
464471
#[pallet::weight(T::WeightInfo::remove_authorized_call())]
465472
pub fn remove_authorized_call(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
466473
let root_or_signed =
@@ -481,6 +488,7 @@ pub mod module {
481488
})
482489
}
483490

491+
#[pallet::call_index(7)]
484492
#[pallet::weight((
485493
T::WeightInfo::trigger_call().saturating_add((*call_weight_bound).into()),
486494
DispatchClass::Operational,
@@ -512,6 +520,7 @@ pub mod module {
512520
})
513521
}
514522

523+
#[pallet::call_index(8)]
515524
#[pallet::weight((
516525
T::WeightInfo::trigger_call().saturating_add(*call_weight_bound),
517526
DispatchClass::Operational,

bencher/test/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub mod pallet {
3838

3939
#[pallet::call]
4040
impl<T: Config> Pallet<T> {
41+
#[pallet::call_index(0)]
4142
#[pallet::weight(0)]
4243
#[orml_weight_meter::start(ModuleWeights::<T>::set_value())]
4344
pub fn set_value(origin: OriginFor<T>, n: u32) -> DispatchResultWithPostInfo {
@@ -49,6 +50,7 @@ pub mod pallet {
4950
Ok(Some(orml_weight_meter::used_weight()).into())
5051
}
5152

53+
#[pallet::call_index(1)]
5254
#[pallet::weight(0)]
5355
pub fn dummy(origin: OriginFor<T>, _n: u32) -> DispatchResult {
5456
let _sender = frame_system::ensure_none(origin)?;
@@ -85,4 +87,4 @@ pub mod pallet {
8587
_ = Bar::<T>::clear(10, None);
8688
}
8789
}
88-
}
90+
}

benchmarking/src/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ pub mod test {
3434

3535
#[pallet::call]
3636
impl<T: Config> Pallet<T> {
37+
#[pallet::call_index(0)]
3738
#[pallet::weight(0)]
3839
pub fn set_value(origin: OriginFor<T>, n: u32) -> DispatchResult {
3940
let _sender = frame_system::ensure_signed(origin)?;
4041
Value::<T>::put(n);
4142
Ok(())
4243
}
4344

45+
#[pallet::call_index(1)]
4446
#[pallet::weight(0)]
4547
pub fn dummy(origin: OriginFor<T>, _n: u32) -> DispatchResult {
4648
let _sender = frame_system::ensure_none(origin)?;

currencies/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub mod module {
126126
///
127127
/// The dispatch origin for this call must be `Signed` by the
128128
/// transactor.
129+
#[pallet::call_index(0)]
129130
#[pallet::weight(T::WeightInfo::transfer_non_native_currency())]
130131
pub fn transfer(
131132
origin: OriginFor<T>,
@@ -142,6 +143,7 @@ pub mod module {
142143
///
143144
/// The dispatch origin for this call must be `Signed` by the
144145
/// transactor.
146+
#[pallet::call_index(1)]
145147
#[pallet::weight(T::WeightInfo::transfer_native_currency())]
146148
pub fn transfer_native_currency(
147149
origin: OriginFor<T>,
@@ -156,6 +158,7 @@ pub mod module {
156158
/// update amount of account `who` under `currency_id`.
157159
///
158160
/// The dispatch origin of this call must be _Root_.
161+
#[pallet::call_index(2)]
159162
#[pallet::weight(T::WeightInfo::update_balance_non_native_currency())]
160163
pub fn update_balance(
161164
origin: OriginFor<T>,

gradually-update/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub mod module {
162162
#[pallet::call]
163163
impl<T: Config> Pallet<T> {
164164
/// Add gradually_update to adjust numeric parameter.
165+
#[pallet::call_index(0)]
165166
#[pallet::weight(T::WeightInfo::gradually_update())]
166167
pub fn gradually_update(origin: OriginFor<T>, update: GraduallyUpdateOf<T>) -> DispatchResult {
167168
T::DispatchOrigin::try_origin(origin).map(|_| ()).or_else(ensure_root)?;
@@ -202,6 +203,7 @@ pub mod module {
202203
}
203204

204205
/// Cancel gradually_update to adjust numeric parameter.
206+
#[pallet::call_index(1)]
205207
#[pallet::weight(T::WeightInfo::cancel_gradually_update())]
206208
pub fn cancel_gradually_update(origin: OriginFor<T>, key: StorageKeyBytes<T>) -> DispatchResult {
207209
T::DispatchOrigin::try_origin(origin).map(|_| ()).or_else(ensure_root)?;

oracle/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ pub mod module {
155155
/// Feed the external value.
156156
///
157157
/// Require authorized operator.
158+
#[pallet::call_index(0)]
158159
#[pallet::weight(T::WeightInfo::feed_values(values.len() as u32))]
159160
pub fn feed_values(
160161
origin: OriginFor<T>,

payments/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ pub mod pallet {
280280
/// the option to add a remark, this remark can then be used to run
281281
/// custom logic and trigger alternate payment flows. the specified
282282
/// amount.
283+
#[pallet::call_index(0)]
283284
#[pallet::weight(T::WeightInfo::pay(T::MaxRemarkLength::get()))]
284285
pub fn pay(
285286
origin: OriginFor<T>,
@@ -314,6 +315,7 @@ pub mod pallet {
314315

315316
/// Release any created payment, this will transfer the reserved amount
316317
/// from the creator of the payment to the assigned recipient
318+
#[pallet::call_index(1)]
317319
#[pallet::weight(T::WeightInfo::release())]
318320
pub fn release(origin: OriginFor<T>, to: T::AccountId) -> DispatchResultWithPostInfo {
319321
let from = ensure_signed(origin)?;
@@ -332,6 +334,7 @@ pub mod pallet {
332334
/// Cancel a payment in created state, this will release the reserved
333335
/// back to creator of the payment. This extrinsic can only be called by
334336
/// the recipient of the payment
337+
#[pallet::call_index(2)]
335338
#[pallet::weight(T::WeightInfo::cancel())]
336339
pub fn cancel(origin: OriginFor<T>, creator: T::AccountId) -> DispatchResultWithPostInfo {
337340
let who = ensure_signed(origin)?;
@@ -354,6 +357,7 @@ pub mod pallet {
354357
/// recipient of the payment.
355358
/// This extrinsic allows the assigned judge to
356359
/// cancel/release/partial_release the payment.
360+
#[pallet::call_index(3)]
357361
#[pallet::weight(T::WeightInfo::resolve_payment())]
358362
pub fn resolve_payment(
359363
origin: OriginFor<T>,
@@ -389,6 +393,7 @@ pub mod pallet {
389393
/// Allow the creator of a payment to initiate a refund that will return
390394
/// the funds after a configured amount of time that the reveiver has to
391395
/// react and opose the request
396+
#[pallet::call_index(4)]
392397
#[pallet::weight(T::WeightInfo::request_refund())]
393398
pub fn request_refund(origin: OriginFor<T>, recipient: T::AccountId) -> DispatchResultWithPostInfo {
394399
let who = ensure_signed(origin)?;
@@ -436,6 +441,7 @@ pub mod pallet {
436441
/// payment creator This does not cancel the request, instead sends the
437442
/// payment to a NeedsReview state The assigned resolver account can
438443
/// then change the state of the payment after review.
444+
#[pallet::call_index(5)]
439445
#[pallet::weight(T::WeightInfo::dispute_refund())]
440446
pub fn dispute_refund(origin: OriginFor<T>, creator: T::AccountId) -> DispatchResultWithPostInfo {
441447
use PaymentState::*;
@@ -482,6 +488,7 @@ pub mod pallet {
482488
// using the `accept_and_pay` extrinsic. The payment will be in
483489
// PaymentRequested State and can only be modified by the `accept_and_pay`
484490
// extrinsic.
491+
#[pallet::call_index(6)]
485492
#[pallet::weight(T::WeightInfo::request_payment())]
486493
pub fn request_payment(
487494
origin: OriginFor<T>,
@@ -510,6 +517,7 @@ pub mod pallet {
510517
// This extrinsic allows the sender to fulfill a payment request created by a
511518
// recipient. The amount will be transferred to the recipient and payment
512519
// removed from storage
520+
#[pallet::call_index(7)]
513521
#[pallet::weight(T::WeightInfo::accept_and_pay())]
514522
pub fn accept_and_pay(origin: OriginFor<T>, to: T::AccountId) -> DispatchResultWithPostInfo {
515523
let from = ensure_signed(origin)?;

tokens/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ pub mod module {
462462
/// - `dest`: The recipient of the transfer.
463463
/// - `currency_id`: currency type.
464464
/// - `amount`: free balance amount to tranfer.
465+
#[pallet::call_index(0)]
465466
#[pallet::weight(T::WeightInfo::transfer())]
466467
pub fn transfer(
467468
origin: OriginFor<T>,
@@ -493,6 +494,7 @@ pub mod module {
493494
/// the sender account to be killed (false), or transfer everything
494495
/// except at least the existential deposit, which will guarantee to
495496
/// keep the sender account alive (true).
497+
#[pallet::call_index(1)]
496498
#[pallet::weight(T::WeightInfo::transfer_all())]
497499
pub fn transfer_all(
498500
origin: OriginFor<T>,
@@ -519,6 +521,7 @@ pub mod module {
519521
/// - `dest`: The recipient of the transfer.
520522
/// - `currency_id`: currency type.
521523
/// - `amount`: free balance amount to tranfer.
524+
#[pallet::call_index(2)]
522525
#[pallet::weight(T::WeightInfo::transfer_keep_alive())]
523526
pub fn transfer_keep_alive(
524527
origin: OriginFor<T>,
@@ -541,6 +544,7 @@ pub mod module {
541544
/// - `dest`: The recipient of the transfer.
542545
/// - `currency_id`: currency type.
543546
/// - `amount`: free balance amount to tranfer.
547+
#[pallet::call_index(3)]
544548
#[pallet::weight(T::WeightInfo::force_transfer())]
545549
pub fn force_transfer(
546550
origin: OriginFor<T>,
@@ -563,6 +567,7 @@ pub mod module {
563567
/// existential deposit, it will reap the `AccountInfo`.
564568
///
565569
/// The dispatch origin for this call is `root`.
570+
#[pallet::call_index(4)]
566571
#[pallet::weight(T::WeightInfo::set_balance())]
567572
pub fn set_balance(
568573
origin: OriginFor<T>,

vesting/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ pub mod module {
244244

245245
#[pallet::call]
246246
impl<T: Config> Pallet<T> {
247+
#[pallet::call_index(0)]
247248
#[pallet::weight(T::WeightInfo::claim((<T as Config>::MaxVestingSchedules::get() / 2) as u32))]
248249
pub fn claim(origin: OriginFor<T>) -> DispatchResult {
249250
let who = ensure_signed(origin)?;
@@ -256,6 +257,7 @@ pub mod module {
256257
Ok(())
257258
}
258259

260+
#[pallet::call_index(1)]
259261
#[pallet::weight(T::WeightInfo::vested_transfer())]
260262
pub fn vested_transfer(
261263
origin: OriginFor<T>,
@@ -282,6 +284,7 @@ pub mod module {
282284
Ok(())
283285
}
284286

287+
#[pallet::call_index(2)]
285288
#[pallet::weight(T::WeightInfo::update_vesting_schedules(vesting_schedules.len() as u32))]
286289
pub fn update_vesting_schedules(
287290
origin: OriginFor<T>,
@@ -297,6 +300,7 @@ pub mod module {
297300
Ok(())
298301
}
299302

303+
#[pallet::call_index(3)]
300304
#[pallet::weight(T::WeightInfo::claim((<T as Config>::MaxVestingSchedules::get() / 2) as u32))]
301305
pub fn claim_for(origin: OriginFor<T>, dest: <T::Lookup as StaticLookup>::Source) -> DispatchResult {
302306
let _ = ensure_signed(origin)?;

weight-meter/src/mock.rs

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub mod test_module {
1919

2020
#[pallet::call]
2121
impl<T: Config> Pallet<T> {
22+
#[pallet::call_index(0)]
2223
#[pallet::weight(50_000)]
2324
#[orml_weight_meter::start]
2425
pub fn expect_100(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
@@ -29,6 +30,7 @@ pub mod test_module {
2930
Ok(Some(orml_weight_meter::used_weight()).into())
3031
}
3132

33+
#[pallet::call_index(1)]
3234
#[pallet::weight(50_000)]
3335
#[orml_weight_meter::start]
3436
pub fn expect_500(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
@@ -43,6 +45,7 @@ pub mod test_module {
4345
Ok(Some(orml_weight_meter::used_weight()).into())
4446
}
4547

48+
#[pallet::call_index(2)]
4649
#[pallet::weight(50_000)]
4750
#[orml_weight_meter::start]
4851
pub fn expect_max_weight(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
@@ -54,6 +57,7 @@ pub mod test_module {
5457
Ok(Some(orml_weight_meter::used_weight()).into())
5558
}
5659

60+
#[pallet::call_index(3)]
5761
#[pallet::weight(50_000)]
5862
#[orml_weight_meter::start]
5963
pub fn expect_100_or_200(origin: OriginFor<T>, branch: bool) -> DispatchResultWithPostInfo {
@@ -68,6 +72,7 @@ pub mod test_module {
6872
Ok(Some(orml_weight_meter::used_weight()).into())
6973
}
7074

75+
#[pallet::call_index(4)]
7176
#[pallet::weight(50_000)]
7277
#[orml_weight_meter::start]
7378
pub fn nested_inner_methods(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
@@ -78,6 +83,7 @@ pub mod test_module {
7883
Ok(Some(orml_weight_meter::used_weight()).into())
7984
}
8085

86+
#[pallet::call_index(5)]
8187
#[pallet::weight(50_000)]
8288
#[orml_weight_meter::start]
8389
pub fn nested_extrinsic(origin: OriginFor<T>) -> DispatchResultWithPostInfo {

xcm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub mod module {
5050
#[pallet::call]
5151
impl<T: Config> Pallet<T> {
5252
/// Send an XCM message as parachain sovereign.
53+
#[pallet::call_index(0)]
5354
#[pallet::weight(100_000_000)]
5455
pub fn send_as_sovereign(
5556
origin: OriginFor<T>,

0 commit comments

Comments
 (0)