Skip to content

Commit

Permalink
Update Checkpoint pallet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neopallium committed Jan 14, 2025
1 parent 1c3d16c commit 840e959
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 177 deletions.
18 changes: 10 additions & 8 deletions pallets/asset/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn make_metadata_spec<T: Config>() -> AssetMetadataSpec {
}

/// Register a global metadata type for benchmarking.
fn register_metadata_global_name<T: Config>() -> AssetMetadataKey {
fn register_metadata_global_name<T: AssetConfig>() -> AssetMetadataKey {
let root = RawOrigin::Root.into();
let name = make_metadata_name::<T>();
let spec = make_metadata_spec::<T>();
Expand All @@ -97,7 +97,10 @@ fn set_ticker_registration_config<T: Config>() {
}

/// Creates a new [`AssetDetails`] considering the worst case scenario.
pub(crate) fn create_sample_asset<T: Config>(asset_owner: &User<T>, divisible: bool) -> AssetId {
pub(crate) fn create_sample_asset<T: AssetConfig>(
asset_owner: &User<T>,
divisible: bool,
) -> AssetId {
let asset_name = AssetName::from(vec![b'N'; T::AssetNameMaxLength::get() as usize].as_slice());
let funding_round_name =
FundingRoundName::from(vec![b'F'; T::FundingRoundNameMaxLength::get() as usize].as_slice());
Expand All @@ -118,7 +121,7 @@ pub(crate) fn create_sample_asset<T: Config>(asset_owner: &User<T>, divisible: b
asset_id
}

pub(crate) fn create_and_issue_sample_asset<T: Config>(asset_owner: &User<T>) -> AssetId {
pub(crate) fn create_and_issue_sample_asset<T: AssetConfig>(asset_owner: &User<T>) -> AssetId {
let asset_id = create_sample_asset::<T>(asset_owner, true);
Pallet::<T>::issue(
asset_owner.origin().into(),
Expand All @@ -133,18 +136,15 @@ pub(crate) fn create_and_issue_sample_asset<T: Config>(asset_owner: &User<T>) ->

/// Creates an asset for `ticker`, creates a custom portfolio for the sender and receiver, sets up compliance and transfer restrictions.
/// Returns the sender and receiver portfolio.
pub fn setup_asset_transfer<T>(
pub fn setup_asset_transfer<T: AssetConfig>(
sender: &User<T>,
receiver: &User<T>,
sender_portfolio_name: Option<&str>,
receiver_portolfio_name: Option<&str>,
pause_compliance: bool,
pause_restrictions: bool,
n_mediators: u8,
) -> (PortfolioId, PortfolioId, Vec<User<T>>, AssetId)
where
T: Config,
{
) -> (PortfolioId, PortfolioId, Vec<User<T>>, AssetId) {
let sender_portfolio =
create_portfolio::<T>(sender, sender_portfolio_name.unwrap_or("SenderPortfolio"));
let receiver_portfolio =
Expand Down Expand Up @@ -235,6 +235,8 @@ fn move_from_default_portfolio<T: Config>(
}

benchmarks! {
where_clause { where T: AssetConfig }

register_unique_ticker {
// For the worst case ticker must be of length `TICKER_LEN`
let alice = UserBuilder::<T>::default().generate_did().build("Alice");
Expand Down
Loading

0 comments on commit 840e959

Please sign in to comment.