mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Add inspect trait for asset roles (#11738)
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -263,3 +263,23 @@ impl<T: Config<I>, I: 'static> fungibles::approvals::Mutate<<T as SystemConfig>:
|
||||
Self::do_transfer_approved(asset, owner, delegate, dest, amount)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> fungibles::roles::Inspect<<T as SystemConfig>::AccountId>
|
||||
for Pallet<T, I>
|
||||
{
|
||||
fn owner(asset: T::AssetId) -> Option<<T as SystemConfig>::AccountId> {
|
||||
Asset::<T, I>::get(asset).map(|x| x.owner)
|
||||
}
|
||||
|
||||
fn issuer(asset: T::AssetId) -> Option<<T as SystemConfig>::AccountId> {
|
||||
Asset::<T, I>::get(asset).map(|x| x.issuer)
|
||||
}
|
||||
|
||||
fn admin(asset: T::AssetId) -> Option<<T as SystemConfig>::AccountId> {
|
||||
Asset::<T, I>::get(asset).map(|x| x.admin)
|
||||
}
|
||||
|
||||
fn freezer(asset: T::AssetId) -> Option<<T as SystemConfig>::AccountId> {
|
||||
Asset::<T, I>::get(asset).map(|x| x.freezer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -977,3 +977,25 @@ fn transfer_large_asset() {
|
||||
assert_ok!(Assets::transfer(Origin::signed(1), 0, 2, amount - 1));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn querying_roles_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
use frame_support::traits::tokens::fungibles::roles::Inspect;
|
||||
assert_ok!(Assets::force_create(Origin::root(), 0, 1, true, 1));
|
||||
assert_ok!(Assets::set_team(
|
||||
Origin::signed(1),
|
||||
0,
|
||||
// Issuer
|
||||
2,
|
||||
// Admin
|
||||
3,
|
||||
// Freezer
|
||||
4,
|
||||
));
|
||||
assert_eq!(Assets::owner(0), Some(1));
|
||||
assert_eq!(Assets::issuer(0), Some(2));
|
||||
assert_eq!(Assets::admin(0), Some(3));
|
||||
assert_eq!(Assets::freezer(0), Some(4));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user