mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 22:45:40 +00:00
Migrate some Pallets to Named Events (#5423)
* auctions * claims * registrar * Update purchase.rs * crowdloan * slots * comma
This commit is contained in:
@@ -128,25 +128,31 @@ pub mod pallet {
|
|||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
/// An auction started. Provides its index and the block number where it will begin to
|
/// An auction started. Provides its index and the block number where it will begin to
|
||||||
/// close and the first lease period of the quadruplet that is auctioned.
|
/// close and the first lease period of the quadruplet that is auctioned.
|
||||||
/// `[auction_index, lease_period, ending]`
|
AuctionStarted {
|
||||||
AuctionStarted(AuctionIndex, LeasePeriodOf<T>, T::BlockNumber),
|
auction_index: AuctionIndex,
|
||||||
/// An auction ended. All funds become unreserved. `[auction_index]`
|
lease_period: LeasePeriodOf<T>,
|
||||||
AuctionClosed(AuctionIndex),
|
ending: T::BlockNumber,
|
||||||
|
},
|
||||||
|
/// An auction ended. All funds become unreserved.
|
||||||
|
AuctionClosed { auction_index: AuctionIndex },
|
||||||
/// Funds were reserved for a winning bid. First balance is the extra amount reserved.
|
/// Funds were reserved for a winning bid. First balance is the extra amount reserved.
|
||||||
/// Second is the total. `[bidder, extra_reserved, total_amount]`
|
/// Second is the total.
|
||||||
Reserved(T::AccountId, BalanceOf<T>, BalanceOf<T>),
|
Reserved { bidder: T::AccountId, extra_reserved: BalanceOf<T>, total_amount: BalanceOf<T> },
|
||||||
/// Funds were unreserved since bidder is no longer active. `[bidder, amount]`
|
/// Funds were unreserved since bidder is no longer active. `[bidder, amount]`
|
||||||
Unreserved(T::AccountId, BalanceOf<T>),
|
Unreserved { bidder: T::AccountId, amount: BalanceOf<T> },
|
||||||
/// Someone attempted to lease the same slot twice for a parachain. The amount is held in reserve
|
/// Someone attempted to lease the same slot twice for a parachain. The amount is held in reserve
|
||||||
/// but no parachain slot has been leased.
|
/// but no parachain slot has been leased.
|
||||||
/// `[parachain_id, leaser, amount]`
|
ReserveConfiscated { para_id: ParaId, leaser: T::AccountId, amount: BalanceOf<T> },
|
||||||
ReserveConfiscated(ParaId, T::AccountId, BalanceOf<T>),
|
|
||||||
/// A new bid has been accepted as the current winner.
|
/// A new bid has been accepted as the current winner.
|
||||||
/// `[who, para_id, amount, first_slot, last_slot]`
|
BidAccepted {
|
||||||
BidAccepted(T::AccountId, ParaId, BalanceOf<T>, LeasePeriodOf<T>, LeasePeriodOf<T>),
|
bidder: T::AccountId,
|
||||||
|
para_id: ParaId,
|
||||||
|
amount: BalanceOf<T>,
|
||||||
|
first_slot: LeasePeriodOf<T>,
|
||||||
|
last_slot: LeasePeriodOf<T>,
|
||||||
|
},
|
||||||
/// The winning offset was chosen for an auction. This will map into the `Winning` storage map.
|
/// The winning offset was chosen for an auction. This will map into the `Winning` storage map.
|
||||||
/// `[auction_index, block_number]`
|
WinningOffset { auction_index: AuctionIndex, block_number: T::BlockNumber },
|
||||||
WinningOffset(AuctionIndex, T::BlockNumber),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::error]
|
#[pallet::error]
|
||||||
@@ -397,7 +403,11 @@ impl<T: Config> Pallet<T> {
|
|||||||
let ending = frame_system::Pallet::<T>::block_number().saturating_add(duration);
|
let ending = frame_system::Pallet::<T>::block_number().saturating_add(duration);
|
||||||
AuctionInfo::<T>::put((lease_period_index, ending));
|
AuctionInfo::<T>::put((lease_period_index, ending));
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::AuctionStarted(n, lease_period_index, ending));
|
Self::deposit_event(Event::<T>::AuctionStarted {
|
||||||
|
auction_index: n,
|
||||||
|
lease_period: lease_period_index,
|
||||||
|
ending,
|
||||||
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,11 +482,11 @@ impl<T: Config> Pallet<T> {
|
|||||||
// ...and record the amount reserved.
|
// ...and record the amount reserved.
|
||||||
ReservedAmounts::<T>::insert(&bidder_para, reserve_required);
|
ReservedAmounts::<T>::insert(&bidder_para, reserve_required);
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::Reserved(
|
Self::deposit_event(Event::<T>::Reserved {
|
||||||
bidder.clone(),
|
bidder: bidder.clone(),
|
||||||
additional,
|
extra_reserved: additional,
|
||||||
reserve_required,
|
total_amount: reserve_required,
|
||||||
));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return any funds reserved for the previous winner if we are not in the ending period
|
// Return any funds reserved for the previous winner if we are not in the ending period
|
||||||
@@ -495,16 +505,20 @@ impl<T: Config> Pallet<T> {
|
|||||||
// It really should be reserved; there's not much we can do here on fail.
|
// It really should be reserved; there's not much we can do here on fail.
|
||||||
let err_amt = CurrencyOf::<T>::unreserve(&who, amount);
|
let err_amt = CurrencyOf::<T>::unreserve(&who, amount);
|
||||||
debug_assert!(err_amt.is_zero());
|
debug_assert!(err_amt.is_zero());
|
||||||
Self::deposit_event(Event::<T>::Unreserved(who, amount));
|
Self::deposit_event(Event::<T>::Unreserved { bidder: who, amount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the range winner.
|
// Update the range winner.
|
||||||
Winning::<T>::insert(offset, ¤t_winning);
|
Winning::<T>::insert(offset, ¤t_winning);
|
||||||
Self::deposit_event(Event::<T>::BidAccepted(
|
Self::deposit_event(Event::<T>::BidAccepted {
|
||||||
bidder, para, amount, first_slot, last_slot,
|
bidder,
|
||||||
));
|
para_id: para,
|
||||||
|
amount,
|
||||||
|
first_slot,
|
||||||
|
last_slot,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -535,7 +549,10 @@ impl<T: Config> Pallet<T> {
|
|||||||
T::SampleLength::get().max(One::one());
|
T::SampleLength::get().max(One::one());
|
||||||
|
|
||||||
let auction_counter = AuctionCounter::<T>::get();
|
let auction_counter = AuctionCounter::<T>::get();
|
||||||
Self::deposit_event(Event::<T>::WinningOffset(auction_counter, offset));
|
Self::deposit_event(Event::<T>::WinningOffset {
|
||||||
|
auction_index: auction_counter,
|
||||||
|
block_number: offset,
|
||||||
|
});
|
||||||
let res = Winning::<T>::get(offset)
|
let res = Winning::<T>::get(offset)
|
||||||
.unwrap_or([Self::EMPTY; SlotRange::SLOT_RANGE_COUNT]);
|
.unwrap_or([Self::EMPTY; SlotRange::SLOT_RANGE_COUNT]);
|
||||||
// This `remove_all` statement should remove at most `EndingPeriod` / `SampleLength` items,
|
// This `remove_all` statement should remove at most `EndingPeriod` / `SampleLength` items,
|
||||||
@@ -585,14 +602,20 @@ impl<T: Config> Pallet<T> {
|
|||||||
// The leaser attempted to get a second lease on the same para ID, possibly griefing us. Let's
|
// The leaser attempted to get a second lease on the same para ID, possibly griefing us. Let's
|
||||||
// keep the amount reserved and let governance sort it out.
|
// keep the amount reserved and let governance sort it out.
|
||||||
if CurrencyOf::<T>::reserve(&leaser, amount).is_ok() {
|
if CurrencyOf::<T>::reserve(&leaser, amount).is_ok() {
|
||||||
Self::deposit_event(Event::<T>::ReserveConfiscated(para, leaser, amount));
|
Self::deposit_event(Event::<T>::ReserveConfiscated {
|
||||||
|
para_id: para,
|
||||||
|
leaser,
|
||||||
|
amount,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Ok(()) => {}, // Nothing to report.
|
Ok(()) => {}, // Nothing to report.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::AuctionClosed(AuctionCounter::<T>::get()));
|
Self::deposit_event(Event::<T>::AuctionClosed {
|
||||||
|
auction_index: AuctionCounter::<T>::get(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the final winners from the winning slots.
|
/// Calculate the final winners from the winning slots.
|
||||||
@@ -1763,11 +1786,11 @@ mod benchmarking {
|
|||||||
let origin = T::InitiateOrigin::successful_origin();
|
let origin = T::InitiateOrigin::successful_origin();
|
||||||
}: _(RawOrigin::Root, duration, lease_period_index)
|
}: _(RawOrigin::Root, duration, lease_period_index)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::AuctionStarted(
|
assert_last_event::<T>(Event::<T>::AuctionStarted {
|
||||||
AuctionCounter::<T>::get(),
|
auction_index: AuctionCounter::<T>::get(),
|
||||||
LeasePeriodOf::<T>::max_value(),
|
lease_period: LeasePeriodOf::<T>::max_value(),
|
||||||
T::BlockNumber::max_value(),
|
ending: T::BlockNumber::max_value(),
|
||||||
).into());
|
}.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worst case scenario a new bid comes in which kicks out an existing bid for the same slot.
|
// Worst case scenario a new bid comes in which kicks out an existing bid for the same slot.
|
||||||
@@ -1859,7 +1882,7 @@ mod benchmarking {
|
|||||||
Auctions::<T>::on_initialize(duration + now + T::EndingPeriod::get());
|
Auctions::<T>::on_initialize(duration + now + T::EndingPeriod::get());
|
||||||
} verify {
|
} verify {
|
||||||
let auction_index = AuctionCounter::<T>::get();
|
let auction_index = AuctionCounter::<T>::get();
|
||||||
assert_last_event::<T>(Event::<T>::AuctionClosed(auction_index).into());
|
assert_last_event::<T>(Event::<T>::AuctionClosed { auction_index }.into());
|
||||||
assert!(Winning::<T>::iter().count().is_zero());
|
assert!(Winning::<T>::iter().count().is_zero());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,8 +183,8 @@ pub mod pallet {
|
|||||||
#[pallet::event]
|
#[pallet::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
/// Someone claimed some DOTs. `[who, ethereum_address, amount]`
|
/// Someone claimed some DOTs.
|
||||||
Claimed(T::AccountId, EthereumAddress, BalanceOf<T>),
|
Claimed { who: T::AccountId, ethereum_address: EthereumAddress, amount: BalanceOf<T> },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::error]
|
#[pallet::error]
|
||||||
@@ -581,7 +581,11 @@ impl<T: Config> Pallet<T> {
|
|||||||
Signing::<T>::remove(&signer);
|
Signing::<T>::remove(&signer);
|
||||||
|
|
||||||
// Let's deposit an event to let the outside world know this happened.
|
// Let's deposit an event to let the outside world know this happened.
|
||||||
Self::deposit_event(Event::<T>::Claimed(dest, signer, balance_due));
|
Self::deposit_event(Event::<T>::Claimed {
|
||||||
|
who: dest,
|
||||||
|
ethereum_address: signer,
|
||||||
|
amount: balance_due,
|
||||||
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,27 +254,27 @@ pub mod pallet {
|
|||||||
#[pallet::event]
|
#[pallet::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
/// Create a new crowdloaning campaign. `[fund_index]`
|
/// Create a new crowdloaning campaign.
|
||||||
Created(ParaId),
|
Created { para_id: ParaId },
|
||||||
/// Contributed to a crowd sale. `[who, fund_index, amount]`
|
/// Contributed to a crowd sale.
|
||||||
Contributed(T::AccountId, ParaId, BalanceOf<T>),
|
Contributed { who: T::AccountId, fund_index: ParaId, amount: BalanceOf<T> },
|
||||||
/// Withdrew full balance of a contributor. `[who, fund_index, amount]`
|
/// Withdrew full balance of a contributor.
|
||||||
Withdrew(T::AccountId, ParaId, BalanceOf<T>),
|
Withdrew { who: T::AccountId, fund_index: ParaId, amount: BalanceOf<T> },
|
||||||
/// The loans in a fund have been partially dissolved, i.e. there are some left
|
/// The loans in a fund have been partially dissolved, i.e. there are some left
|
||||||
/// over child keys that still need to be killed. `[fund_index]`
|
/// over child keys that still need to be killed.
|
||||||
PartiallyRefunded(ParaId),
|
PartiallyRefunded { para_id: ParaId },
|
||||||
/// All loans in a fund have been refunded. `[fund_index]`
|
/// All loans in a fund have been refunded.
|
||||||
AllRefunded(ParaId),
|
AllRefunded { para_id: ParaId },
|
||||||
/// Fund is dissolved. `[fund_index]`
|
/// Fund is dissolved.
|
||||||
Dissolved(ParaId),
|
Dissolved { para_id: ParaId },
|
||||||
/// The result of trying to submit a new bid to the Slots pallet.
|
/// The result of trying to submit a new bid to the Slots pallet.
|
||||||
HandleBidResult(ParaId, DispatchResult),
|
HandleBidResult { para_id: ParaId, result: DispatchResult },
|
||||||
/// The configuration to a crowdloan has been edited. `[fund_index]`
|
/// The configuration to a crowdloan has been edited.
|
||||||
Edited(ParaId),
|
Edited { para_id: ParaId },
|
||||||
/// A memo has been updated. `[who, fund_index, memo]`
|
/// A memo has been updated.
|
||||||
MemoUpdated(T::AccountId, ParaId, Vec<u8>),
|
MemoUpdated { who: T::AccountId, para_id: ParaId, memo: Vec<u8> },
|
||||||
/// A parachain has been moved to `NewRaise`
|
/// A parachain has been moved to `NewRaise`
|
||||||
AddedToNewRaise(ParaId),
|
AddedToNewRaise { para_id: ParaId },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::error]
|
#[pallet::error]
|
||||||
@@ -351,7 +351,7 @@ pub mod pallet {
|
|||||||
fund.raised,
|
fund.raised,
|
||||||
);
|
);
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::HandleBidResult(para_id, result));
|
Self::deposit_event(Event::<T>::HandleBidResult { para_id, result });
|
||||||
}
|
}
|
||||||
T::WeightInfo::on_initialize(new_raise_len)
|
T::WeightInfo::on_initialize(new_raise_len)
|
||||||
} else {
|
} else {
|
||||||
@@ -437,7 +437,7 @@ pub mod pallet {
|
|||||||
// Add a lock to the para so that the configuration cannot be changed.
|
// Add a lock to the para so that the configuration cannot be changed.
|
||||||
T::Registrar::apply_lock(index);
|
T::Registrar::apply_lock(index);
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::Created(index));
|
Self::deposit_event(Event::<T>::Created { para_id: index });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
Funds::<T>::insert(index, &fund);
|
Funds::<T>::insert(index, &fund);
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::Withdrew(who, index, balance));
|
Self::deposit_event(Event::<T>::Withdrew { who, fund_index: index, amount: balance });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,11 +536,11 @@ pub mod pallet {
|
|||||||
Funds::<T>::insert(index, &fund);
|
Funds::<T>::insert(index, &fund);
|
||||||
|
|
||||||
if all_refunded {
|
if all_refunded {
|
||||||
Self::deposit_event(Event::<T>::AllRefunded(index));
|
Self::deposit_event(Event::<T>::AllRefunded { para_id: index });
|
||||||
// Refund for unused refund count.
|
// Refund for unused refund count.
|
||||||
Ok(Some(T::WeightInfo::refund(refund_count)).into())
|
Ok(Some(T::WeightInfo::refund(refund_count)).into())
|
||||||
} else {
|
} else {
|
||||||
Self::deposit_event(Event::<T>::PartiallyRefunded(index));
|
Self::deposit_event(Event::<T>::PartiallyRefunded { para_id: index });
|
||||||
// No weight to refund since we did not finish the loop.
|
// No weight to refund since we did not finish the loop.
|
||||||
Ok(().into())
|
Ok(().into())
|
||||||
}
|
}
|
||||||
@@ -567,7 +567,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
CurrencyOf::<T>::unreserve(&fund.depositor, fund.deposit);
|
CurrencyOf::<T>::unreserve(&fund.depositor, fund.deposit);
|
||||||
Funds::<T>::remove(index);
|
Funds::<T>::remove(index);
|
||||||
Self::deposit_event(Event::<T>::Dissolved(index));
|
Self::deposit_event(Event::<T>::Dissolved { para_id: index });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,7 +604,7 @@ pub mod pallet {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::Edited(index));
|
Self::deposit_event(Event::<T>::Edited { para_id: index });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,7 +622,7 @@ pub mod pallet {
|
|||||||
ensure!(balance > Zero::zero(), Error::<T>::NoContributions);
|
ensure!(balance > Zero::zero(), Error::<T>::NoContributions);
|
||||||
|
|
||||||
Self::contribution_put(fund.fund_index, &who, &balance, &memo);
|
Self::contribution_put(fund.fund_index, &who, &balance, &memo);
|
||||||
Self::deposit_event(Event::<T>::MemoUpdated(who, index, memo));
|
Self::deposit_event(Event::<T>::MemoUpdated { who, para_id: index, memo });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,7 +636,7 @@ pub mod pallet {
|
|||||||
ensure!(!fund.raised.is_zero(), Error::<T>::NoContributions);
|
ensure!(!fund.raised.is_zero(), Error::<T>::NoContributions);
|
||||||
ensure!(!NewRaise::<T>::get().contains(&index), Error::<T>::AlreadyInNewRaise);
|
ensure!(!NewRaise::<T>::get().contains(&index), Error::<T>::AlreadyInNewRaise);
|
||||||
NewRaise::<T>::append(index);
|
NewRaise::<T>::append(index);
|
||||||
Self::deposit_event(Event::<T>::AddedToNewRaise(index));
|
Self::deposit_event(Event::<T>::AddedToNewRaise { para_id: index });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,7 +810,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
|
|
||||||
Funds::<T>::insert(index, &fund);
|
Funds::<T>::insert(index, &fund);
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::Contributed(who, index, value));
|
Self::deposit_event(Event::<T>::Contributed { who, fund_index: index, amount: value });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1648,14 +1648,17 @@ mod tests {
|
|||||||
// Move to the end of the crowdloan
|
// Move to the end of the crowdloan
|
||||||
run_to_block(10);
|
run_to_block(10);
|
||||||
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
|
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
|
||||||
assert_eq!(last_event(), super::Event::<Test>::PartiallyRefunded(para).into());
|
assert_eq!(
|
||||||
|
last_event(),
|
||||||
|
super::Event::<Test>::PartiallyRefunded { para_id: para }.into()
|
||||||
|
);
|
||||||
|
|
||||||
// Funds still left over
|
// Funds still left over
|
||||||
assert!(!Balances::free_balance(account_id).is_zero());
|
assert!(!Balances::free_balance(account_id).is_zero());
|
||||||
|
|
||||||
// Call again
|
// Call again
|
||||||
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
|
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
|
||||||
assert_eq!(last_event(), super::Event::<Test>::AllRefunded(para).into());
|
assert_eq!(last_event(), super::Event::<Test>::AllRefunded { para_id: para }.into());
|
||||||
|
|
||||||
// Funds are returned
|
// Funds are returned
|
||||||
assert_eq!(Balances::free_balance(account_id), 0);
|
assert_eq!(Balances::free_balance(account_id), 0);
|
||||||
@@ -1983,7 +1986,7 @@ mod benchmarking {
|
|||||||
|
|
||||||
}: _(RawOrigin::Signed(caller), para_id, cap, first_period, last_period, end, Some(verifier))
|
}: _(RawOrigin::Signed(caller), para_id, cap, first_period, last_period, end, Some(verifier))
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Created(para_id).into())
|
assert_last_event::<T>(Event::<T>::Created { para_id }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contribute has two arms: PreEnding and Ending, but both are equal complexity.
|
// Contribute has two arms: PreEnding and Ending, but both are equal complexity.
|
||||||
@@ -2004,7 +2007,7 @@ mod benchmarking {
|
|||||||
verify {
|
verify {
|
||||||
// NewRaise is appended to, so we don't need to fill it up for worst case scenario.
|
// NewRaise is appended to, so we don't need to fill it up for worst case scenario.
|
||||||
assert!(!NewRaise::<T>::get().is_empty());
|
assert!(!NewRaise::<T>::get().is_empty());
|
||||||
assert_last_event::<T>(Event::<T>::Contributed(caller, fund_index, contribution).into());
|
assert_last_event::<T>(Event::<T>::Contributed { who: caller, fund_index, amount: contribution }.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
withdraw {
|
withdraw {
|
||||||
@@ -2017,7 +2020,7 @@ mod benchmarking {
|
|||||||
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
|
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
|
||||||
}: _(RawOrigin::Signed(caller), contributor.clone(), fund_index)
|
}: _(RawOrigin::Signed(caller), contributor.clone(), fund_index)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Withdrew(contributor, fund_index, T::MinContribution::get()).into());
|
assert_last_event::<T>(Event::<T>::Withdrew { who: contributor, fund_index, amount: T::MinContribution::get() }.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worst case: Refund removes `RemoveKeysLimit` keys, and is fully refunded.
|
// Worst case: Refund removes `RemoveKeysLimit` keys, and is fully refunded.
|
||||||
@@ -2037,7 +2040,7 @@ mod benchmarking {
|
|||||||
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
|
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
|
||||||
}: _(RawOrigin::Signed(caller), fund_index)
|
}: _(RawOrigin::Signed(caller), fund_index)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::AllRefunded(fund_index).into());
|
assert_last_event::<T>(Event::<T>::AllRefunded { para_id: fund_index }.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
dissolve {
|
dissolve {
|
||||||
@@ -2048,7 +2051,7 @@ mod benchmarking {
|
|||||||
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
|
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
|
||||||
}: _(RawOrigin::Signed(caller.clone()), fund_index)
|
}: _(RawOrigin::Signed(caller.clone()), fund_index)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Dissolved(fund_index).into());
|
assert_last_event::<T>(Event::<T>::Dissolved { para_id: fund_index }.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
edit {
|
edit {
|
||||||
@@ -2077,7 +2080,7 @@ mod benchmarking {
|
|||||||
// Doesn't matter what we edit to, so use the same values.
|
// Doesn't matter what we edit to, so use the same values.
|
||||||
}: _(RawOrigin::Root, para_id, cap, first_period, last_period, end, Some(verifier))
|
}: _(RawOrigin::Root, para_id, cap, first_period, last_period, end, Some(verifier))
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Edited(para_id).into())
|
assert_last_event::<T>(Event::<T>::Edited { para_id }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
add_memo {
|
add_memo {
|
||||||
@@ -2107,7 +2110,7 @@ mod benchmarking {
|
|||||||
}: _(RawOrigin::Signed(caller), fund_index)
|
}: _(RawOrigin::Signed(caller), fund_index)
|
||||||
verify {
|
verify {
|
||||||
assert!(!NewRaise::<T>::get().is_empty());
|
assert!(!NewRaise::<T>::get().is_empty());
|
||||||
assert_last_event::<T>(Event::<T>::AddedToNewRaise(fund_index).into())
|
assert_last_event::<T>(Event::<T>::AddedToNewRaise { para_id: fund_index }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worst case scenario: N funds are all in the `NewRaise` list, we are
|
// Worst case scenario: N funds are all in the `NewRaise` list, we are
|
||||||
@@ -2146,7 +2149,7 @@ mod benchmarking {
|
|||||||
Crowdloan::<T>::on_initialize(end_block);
|
Crowdloan::<T>::on_initialize(end_block);
|
||||||
} verify {
|
} verify {
|
||||||
assert_eq!(EndingsCount::<T>::get(), old_endings_count + 1);
|
assert_eq!(EndingsCount::<T>::get(), old_endings_count + 1);
|
||||||
assert_last_event::<T>(Event::<T>::HandleBidResult((n - 1).into(), Ok(())).into());
|
assert_last_event::<T>(Event::<T>::HandleBidResult { para_id: (n - 1).into(), result: Ok(()) }.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_benchmark_test_suite!(
|
impl_benchmark_test_suite!(
|
||||||
|
|||||||
@@ -432,10 +432,17 @@ fn basic_end_to_end_works() {
|
|||||||
// Auction ends at block 110 + offset
|
// Auction ends at block 110 + offset
|
||||||
run_to_block(109 + offset);
|
run_to_block(109 + offset);
|
||||||
assert!(contains_event(
|
assert!(contains_event(
|
||||||
crowdloan::Event::<Test>::HandleBidResult(ParaId::from(para_2), Ok(())).into()
|
crowdloan::Event::<Test>::HandleBidResult {
|
||||||
|
para_id: ParaId::from(para_2),
|
||||||
|
result: Ok(())
|
||||||
|
}
|
||||||
|
.into()
|
||||||
));
|
));
|
||||||
run_to_block(110 + offset);
|
run_to_block(110 + offset);
|
||||||
assert_eq!(last_event(), auctions::Event::<Test>::AuctionClosed(1).into());
|
assert_eq!(
|
||||||
|
last_event(),
|
||||||
|
auctions::Event::<Test>::AuctionClosed { auction_index: 1 }.into()
|
||||||
|
);
|
||||||
|
|
||||||
// Paras should have won slots
|
// Paras should have won slots
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ pub mod pallet {
|
|||||||
#[pallet::event]
|
#[pallet::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
Registered(ParaId, T::AccountId),
|
Registered { para_id: ParaId, manager: T::AccountId },
|
||||||
Deregistered(ParaId),
|
Deregistered { para_id: ParaId },
|
||||||
Reserved(ParaId, T::AccountId),
|
Reserved { para_id: ParaId, who: T::AccountId },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::error]
|
#[pallet::error]
|
||||||
@@ -492,7 +492,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
let info = ParaInfo { manager: who.clone(), deposit, locked: false };
|
let info = ParaInfo { manager: who.clone(), deposit, locked: false };
|
||||||
|
|
||||||
Paras::<T>::insert(id, info);
|
Paras::<T>::insert(id, info);
|
||||||
Self::deposit_event(Event::<T>::Reserved(id, who));
|
Self::deposit_event(Event::<T>::Reserved { para_id: id, who });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,7 +530,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
// We check above that para has no lifecycle, so this should not fail.
|
// We check above that para has no lifecycle, so this should not fail.
|
||||||
let res = runtime_parachains::schedule_para_initialize::<T>(id, genesis);
|
let res = runtime_parachains::schedule_para_initialize::<T>(id, genesis);
|
||||||
debug_assert!(res.is_ok());
|
debug_assert!(res.is_ok());
|
||||||
Self::deposit_event(Event::<T>::Registered(id, who));
|
Self::deposit_event(Event::<T>::Registered { para_id: id, manager: who });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PendingSwap::<T>::remove(id);
|
PendingSwap::<T>::remove(id);
|
||||||
Self::deposit_event(Event::<T>::Deregistered(id));
|
Self::deposit_event(Event::<T>::Deregistered { para_id: id });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,7 +1268,7 @@ mod benchmarking {
|
|||||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||||
}: _(RawOrigin::Signed(caller.clone()))
|
}: _(RawOrigin::Signed(caller.clone()))
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Reserved(LOWEST_PUBLIC_ID, caller).into());
|
assert_last_event::<T>(Event::<T>::Reserved { para_id: LOWEST_PUBLIC_ID, who: caller }.into());
|
||||||
assert!(Paras::<T>::get(LOWEST_PUBLIC_ID).is_some());
|
assert!(Paras::<T>::get(LOWEST_PUBLIC_ID).is_some());
|
||||||
assert_eq!(paras::Pallet::<T>::lifecycle(LOWEST_PUBLIC_ID), None);
|
assert_eq!(paras::Pallet::<T>::lifecycle(LOWEST_PUBLIC_ID), None);
|
||||||
}
|
}
|
||||||
@@ -1282,7 +1282,7 @@ mod benchmarking {
|
|||||||
assert_ok!(Registrar::<T>::reserve(RawOrigin::Signed(caller.clone()).into()));
|
assert_ok!(Registrar::<T>::reserve(RawOrigin::Signed(caller.clone()).into()));
|
||||||
}: _(RawOrigin::Signed(caller.clone()), para, genesis_head, validation_code)
|
}: _(RawOrigin::Signed(caller.clone()), para, genesis_head, validation_code)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Registered(para, caller).into());
|
assert_last_event::<T>(Event::<T>::Registered{ para_id: para, manager: caller }.into());
|
||||||
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
|
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
|
||||||
next_scheduled_session::<T>();
|
next_scheduled_session::<T>();
|
||||||
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
|
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
|
||||||
@@ -1296,7 +1296,7 @@ mod benchmarking {
|
|||||||
let validation_code = Registrar::<T>::worst_validation_code();
|
let validation_code = Registrar::<T>::worst_validation_code();
|
||||||
}: _(RawOrigin::Root, manager.clone(), deposit, para, genesis_head, validation_code)
|
}: _(RawOrigin::Root, manager.clone(), deposit, para, genesis_head, validation_code)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Registered(para, manager).into());
|
assert_last_event::<T>(Event::<T>::Registered { para_id: para, manager }.into());
|
||||||
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
|
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
|
||||||
next_scheduled_session::<T>();
|
next_scheduled_session::<T>();
|
||||||
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
|
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
|
||||||
@@ -1308,7 +1308,7 @@ mod benchmarking {
|
|||||||
let caller: T::AccountId = whitelisted_caller();
|
let caller: T::AccountId = whitelisted_caller();
|
||||||
}: _(RawOrigin::Signed(caller), para)
|
}: _(RawOrigin::Signed(caller), para)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Deregistered(para).into());
|
assert_last_event::<T>(Event::<T>::Deregistered { para_id: para }.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
swap {
|
swap {
|
||||||
|
|||||||
@@ -133,19 +133,19 @@ pub mod pallet {
|
|||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
/// A [new] account was created.
|
/// A [new] account was created.
|
||||||
AccountCreated(T::AccountId),
|
AccountCreated { who: T::AccountId },
|
||||||
/// Someone's account validity was updated. [who, validity]
|
/// Someone's account validity was updated.
|
||||||
ValidityUpdated(T::AccountId, AccountValidity),
|
ValidityUpdated { who: T::AccountId, validity: AccountValidity },
|
||||||
/// Someone's purchase balance was updated. [who, free, locked]
|
/// Someone's purchase balance was updated.
|
||||||
BalanceUpdated(T::AccountId, BalanceOf<T>, BalanceOf<T>),
|
BalanceUpdated { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
|
||||||
/// A payout was made to a purchaser. [who, free, locked]
|
/// A payout was made to a purchaser.
|
||||||
PaymentComplete(T::AccountId, BalanceOf<T>, BalanceOf<T>),
|
PaymentComplete { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
|
||||||
/// A new payment account was set. [who]
|
/// A new payment account was set.
|
||||||
PaymentAccountSet(T::AccountId),
|
PaymentAccountSet { who: T::AccountId },
|
||||||
/// A new statement was set.
|
/// A new statement was set.
|
||||||
StatementUpdated,
|
StatementUpdated,
|
||||||
/// A new statement was set. `[block_number]`
|
/// A new statement was set. `[block_number]`
|
||||||
UnlockBlockUpdated(T::BlockNumber),
|
UnlockBlockUpdated { block_number: T::BlockNumber },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::error]
|
#[pallet::error]
|
||||||
@@ -222,7 +222,7 @@ pub mod pallet {
|
|||||||
vat: Permill::zero(),
|
vat: Permill::zero(),
|
||||||
};
|
};
|
||||||
Accounts::<T>::insert(&who, status);
|
Accounts::<T>::insert(&who, status);
|
||||||
Self::deposit_event(Event::<T>::AccountCreated(who));
|
Self::deposit_event(Event::<T>::AccountCreated { who });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ pub mod pallet {
|
|||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
Self::deposit_event(Event::<T>::ValidityUpdated(who, validity));
|
Self::deposit_event(Event::<T>::ValidityUpdated { who, validity });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +283,11 @@ pub mod pallet {
|
|||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
Self::deposit_event(Event::<T>::BalanceUpdated(who, free_balance, locked_balance));
|
Self::deposit_event(Event::<T>::BalanceUpdated {
|
||||||
|
who,
|
||||||
|
free: free_balance,
|
||||||
|
locked: locked_balance,
|
||||||
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,11 +350,11 @@ pub mod pallet {
|
|||||||
|
|
||||||
// Setting the user account to `Completed` ends the purchase process for this user.
|
// Setting the user account to `Completed` ends the purchase process for this user.
|
||||||
status.validity = AccountValidity::Completed;
|
status.validity = AccountValidity::Completed;
|
||||||
Self::deposit_event(Event::<T>::PaymentComplete(
|
Self::deposit_event(Event::<T>::PaymentComplete {
|
||||||
who.clone(),
|
who: who.clone(),
|
||||||
status.free_balance,
|
free: status.free_balance,
|
||||||
status.locked_balance,
|
locked: status.locked_balance,
|
||||||
));
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
@@ -367,7 +371,7 @@ pub mod pallet {
|
|||||||
T::ConfigurationOrigin::ensure_origin(origin)?;
|
T::ConfigurationOrigin::ensure_origin(origin)?;
|
||||||
// Possibly this is worse than having the caller account be the payment account?
|
// Possibly this is worse than having the caller account be the payment account?
|
||||||
PaymentAccount::<T>::put(who.clone());
|
PaymentAccount::<T>::put(who.clone());
|
||||||
Self::deposit_event(Event::<T>::PaymentAccountSet(who));
|
Self::deposit_event(Event::<T>::PaymentAccountSet { who });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +406,7 @@ pub mod pallet {
|
|||||||
);
|
);
|
||||||
// Possibly this is worse than having the caller account be the payment account?
|
// Possibly this is worse than having the caller account be the payment account?
|
||||||
UnlockBlock::<T>::set(unlock_block);
|
UnlockBlock::<T>::set(unlock_block);
|
||||||
Self::deposit_event(Event::<T>::UnlockBlockUpdated(unlock_block));
|
Self::deposit_event(Event::<T>::UnlockBlockUpdated { block_number: unlock_block });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,19 +122,18 @@ pub mod pallet {
|
|||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
/// A new `[lease_period]` is beginning.
|
/// A new `[lease_period]` is beginning.
|
||||||
NewLeasePeriod(LeasePeriodOf<T>),
|
NewLeasePeriod { lease_period: LeasePeriodOf<T> },
|
||||||
/// A para has won the right to a continuous set of lease periods as a parachain.
|
/// A para has won the right to a continuous set of lease periods as a parachain.
|
||||||
/// First balance is any extra amount reserved on top of the para's existing deposit.
|
/// First balance is any extra amount reserved on top of the para's existing deposit.
|
||||||
/// Second balance is the total amount reserved.
|
/// Second balance is the total amount reserved.
|
||||||
/// `[parachain_id, leaser, period_begin, period_count, extra_reserved, total_amount]`
|
Leased {
|
||||||
Leased(
|
para_id: ParaId,
|
||||||
ParaId,
|
leaser: T::AccountId,
|
||||||
T::AccountId,
|
period_begin: LeasePeriodOf<T>,
|
||||||
LeasePeriodOf<T>,
|
period_count: LeasePeriodOf<T>,
|
||||||
LeasePeriodOf<T>,
|
extra_reserved: BalanceOf<T>,
|
||||||
BalanceOf<T>,
|
total_amount: BalanceOf<T>,
|
||||||
BalanceOf<T>,
|
},
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::error]
|
#[pallet::error]
|
||||||
@@ -228,7 +227,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
/// We need to on-board and off-board parachains as needed. We should also handle reducing/
|
/// We need to on-board and off-board parachains as needed. We should also handle reducing/
|
||||||
/// returning deposits.
|
/// returning deposits.
|
||||||
fn manage_lease_period_start(lease_period_index: LeasePeriodOf<T>) -> Weight {
|
fn manage_lease_period_start(lease_period_index: LeasePeriodOf<T>) -> Weight {
|
||||||
Self::deposit_event(Event::<T>::NewLeasePeriod(lease_period_index));
|
Self::deposit_event(Event::<T>::NewLeasePeriod { lease_period: lease_period_index });
|
||||||
|
|
||||||
let old_parachains = T::Registrar::parachains();
|
let old_parachains = T::Registrar::parachains();
|
||||||
|
|
||||||
@@ -408,14 +407,14 @@ impl<T: Config> Leaser<T::BlockNumber> for Pallet<T> {
|
|||||||
let _ = T::Registrar::make_parachain(para);
|
let _ = T::Registrar::make_parachain(para);
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::Leased(
|
Self::deposit_event(Event::<T>::Leased {
|
||||||
para,
|
para_id: para,
|
||||||
leaser.clone(),
|
leaser: leaser.clone(),
|
||||||
period_begin,
|
period_begin,
|
||||||
period_count,
|
period_count,
|
||||||
reserved,
|
extra_reserved: reserved,
|
||||||
amount,
|
total_amount: amount,
|
||||||
));
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@@ -1027,7 +1026,13 @@ mod benchmarking {
|
|||||||
let period_count = 3u32.into();
|
let period_count = 3u32.into();
|
||||||
}: _(RawOrigin::Root, para, leaser.clone(), amount, period_begin, period_count)
|
}: _(RawOrigin::Root, para, leaser.clone(), amount, period_begin, period_count)
|
||||||
verify {
|
verify {
|
||||||
assert_last_event::<T>(Event::<T>::Leased(para, leaser, period_begin, period_count, amount, amount).into());
|
assert_last_event::<T>(Event::<T>::Leased {
|
||||||
|
para_id: para,
|
||||||
|
leaser, period_begin,
|
||||||
|
period_count,
|
||||||
|
extra_reserved: amount,
|
||||||
|
total_amount: amount,
|
||||||
|
}.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worst case scenario, T parathreads onboard, and C parachains offboard.
|
// Worst case scenario, T parathreads onboard, and C parachains offboard.
|
||||||
|
|||||||
Reference in New Issue
Block a user