Skip to content

Commit

Permalink
Normalize AssetId (#1736)
Browse files Browse the repository at this point in the history
* Search/replace AssetID with AssetId.

* Fix AssetId in Rust integration tests.
  • Loading branch information
Neopallium authored Oct 14, 2024
1 parent ef3af0a commit 648d0a5
Show file tree
Hide file tree
Showing 92 changed files with 1,561 additions and 1,561 deletions.
24 changes: 12 additions & 12 deletions integration/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ sp-runtime = "29.0"
sp-keyring = "29.0"
sp-weights = "25.0"

polymesh-api = { version = "3.8.0", features = ["download_metadata"] }
polymesh-api-tester = { version = "0.7.1", default-features = false, features = ["download_metadata", "polymesh_v7"] }
polymesh-api = { version = "3.8.1", features = ["download_metadata"] }
polymesh-api-tester = { version = "0.7.3", default-features = false, features = ["download_metadata", "polymesh_v7"] }
4 changes: 2 additions & 2 deletions integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl PalletPermissionsBuilder {

#[derive(Clone, Default)]
pub struct PermissionsBuilder {
asset: SubsetBuilder<AssetID>,
asset: SubsetBuilder<AssetId>,
portfolio: SubsetBuilder<PortfolioId>,
extrinsic: PalletPermissionsBuilder,
}
Expand All @@ -204,7 +204,7 @@ impl PermissionsBuilder {
}
}

pub fn set_asset(&mut self, assets: &[AssetID], these: bool) {
pub fn set_asset(&mut self, assets: &[AssetId], these: bool) {
self.asset.set(assets, these);
}

Expand Down
8 changes: 4 additions & 4 deletions pallets/asset/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ 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: Config>(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 @@ -120,7 +120,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: Config>(asset_owner: &User<T>) -> AssetId {
let asset_id = create_sample_asset::<T>(asset_owner, true);
Module::<T>::issue(
asset_owner.origin().into(),
Expand All @@ -143,7 +143,7 @@ pub fn setup_asset_transfer<T>(
pause_compliance: bool,
pause_restrictions: bool,
n_mediators: u8,
) -> (PortfolioId, PortfolioId, Vec<User<T>>, AssetID)
) -> (PortfolioId, PortfolioId, Vec<User<T>>, AssetId)
where
T: Config + TestUtilsFn<AccountIdOf<T>>,
{
Expand Down Expand Up @@ -217,7 +217,7 @@ pub fn create_portfolio<T: Config>(user: &User<T>, portofolio_name: &str) -> Por
/// Moves `amount` from the user's default portfolio to `destination_portfolio`.
fn move_from_default_portfolio<T: Config>(
user: &User<T>,
asset_id: AssetID,
asset_id: AssetId,
amount: Balance,
destination_portfolio: PortfolioId,
) {
Expand Down
2 changes: 1 addition & 1 deletion pallets/asset/src/checkpoint/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::benchmarking::create_sample_asset;

const CP_BASE: u64 = 2000;

fn init_with_existing<T: Config>(asset_owner: &User<T>, existing: u64) -> AssetID {
fn init_with_existing<T: Config>(asset_owner: &User<T>, existing: u64) -> AssetId {
<pallet_timestamp::Now<T>>::set(1000u32.into());
let asset_id = create_sample_asset::<T>(&asset_owner, true);

Expand Down
40 changes: 20 additions & 20 deletions pallets/asset/src/checkpoint/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ mod v1 {

decl_storage! {
trait Store for Module<T: Config> as Checkpoint {
// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldTotalSupply get(fn total_supply_at):
double_map hasher(blake2_128_concat) Ticker, hasher(twox_64_concat) CheckpointId => polymesh_primitives::Balance;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldBalance get(fn balance_at_checkpoint):
double_map hasher(blake2_128_concat) (Ticker, CheckpointId), hasher(twox_64_concat) IdentityId => polymesh_primitives::Balance;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldCheckpointIdSequence get(fn checkpoint_id_sequence):
map hasher(blake2_128_concat) Ticker => CheckpointId;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldBalanceUpdates get(fn balance_updates):
double_map hasher(blake2_128_concat) Ticker, hasher(twox_64_concat) IdentityId => Vec<CheckpointId>;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldTimestamps get(fn timestamps):
double_map hasher(blake2_128_concat) Ticker, hasher(twox_64_concat) CheckpointId => Moment;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldScheduleIdSequence get(fn schedule_id_sequence):
map hasher(blake2_128_concat) Ticker => ScheduleId;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldCachedNextCheckpoints get(fn cached_next_checkpoints):
map hasher(blake2_128_concat) Ticker => Option<NextCheckpoints>;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldScheduledCheckpoints get(fn scheduled_checkpoints):
double_map hasher(blake2_128_concat) Ticker, hasher(twox_64_concat) ScheduleId => Option<ScheduleCheckpoints>;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldScheduleRefCount get(fn schedule_ref_count):
double_map hasher(blake2_128_concat) Ticker, hasher(twox_64_concat) ScheduleId => u32;

// This storage changed the Ticker key to AssetID.
// This storage changed the Ticker key to AssetId.
pub OldSchedulePoints get(fn schedule_points):
double_map hasher(blake2_128_concat) Ticker, hasher(twox_64_concat) ScheduleId => Vec<CheckpointId>;
}
Expand All @@ -73,7 +73,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
TotalSupply::insert(asset_id, checkpoint_id, balance);
});
log::info!("{:?} items migrated", count);
Expand All @@ -85,7 +85,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
Balance::insert((asset_id, checkpoint_id), did, balance);
});
log::info!("{:?} items migrated", count);
Expand All @@ -100,7 +100,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
CheckpointIdSequence::insert(asset_id, checkpoint_id);
});
log::info!("{:?} items migrated", count);
Expand All @@ -115,7 +115,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
BalanceUpdates::insert(asset_id, did, checkpoint_id);
});
log::info!("{:?} items migrated", count);
Expand All @@ -130,7 +130,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
Timestamps::insert(asset_id, checkpoint_id, when);
});
log::info!("{:?} items migrated", count);
Expand All @@ -145,7 +145,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
ScheduleIdSequence::insert(asset_id, schedule_id);
});
log::info!("{:?} items migrated", count);
Expand All @@ -160,7 +160,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
CachedNextCheckpoints::insert(asset_id, next_checkpoint);
});
log::info!("{:?} items migrated", count);
Expand All @@ -175,7 +175,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
ScheduledCheckpoints::insert(asset_id, schedule_id, next_checkpoint);
});
log::info!("{:?} items migrated", count);
Expand All @@ -190,7 +190,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
ScheduleRefCount::insert(asset_id, schedule_id, ref_count);
});
log::info!("{:?} items migrated", count);
Expand All @@ -205,7 +205,7 @@ pub(crate) fn migrate_to_v2<T: Config>() {
count += 1;
let asset_id = ticker_to_asset_id
.entry(ticker)
.or_insert(AssetID::from(ticker));
.or_insert(AssetId::from(ticker));
SchedulePoints::insert(asset_id, schedule_id, checkpoint_id);
});
log::info!("{:?} items migrated", count);
Expand Down
Loading

0 comments on commit 648d0a5

Please sign in to comment.