Update the extrinsic to allow all users with admin permissions to update the balance of the asset. This bug fix will enable users with admin privileges to modify the asset balance instead of restricting it to only the owner.
Description
The current implementation of the set_afloat_balance extrinsic in the substrate pallet restricts the ability to update the balance of the asset to only the owner. This issue aims to modify the code to allow all users with admin permissions to update the asset balance. Additionally, it may involve updating mapped assets to validate the signature of the origin.
#[pallet::call_index(9)]
#[pallet::weight(Weight::from_ref_time(10_000) + T::DbWeight::get().reads_writes(2,1))]
pub fn set_afloat_balance(
origin: OriginFor<T>,
beneficiary: T::AccountId,
amount: T::Balance,
) -> DispatchResult {
ensure_signed(origin.clone())?;
// Only the owner can set afloat balance
ensure!(Self::is_owner(ensure_signed(origin.clone())?), Error::<T>::Unauthorized);
Self::do_set_afloat_balance(origin, beneficiary, amount)
}
Changes Made
Remove the ownership restriction from the ensure! statement that checks for the owner.
Implement a mechanism to check if the user has admin permissions.
Update the logic to validate the signature of the origin when updating mapped assets.
Test the updated extrinsic to ensure proper functionality.
Overall Impact
All users with admin permissions will be able to update the balance of the asset.
This bug fix enhances the flexibility and usability of the system by allowing a broader range of users to modify the asset balance.
Implications for Other Codebase
Code that interacts with the set_afloat_balance extrinsic or relies on the ownership restriction may need to be updated to accommodate the changes.
Documentation should be updated to reflect the modifications in the extrinsic behavior.
Acceptance Criteria
The extrinsic is updated to allow all users with admin permissions to update the balance of the asset.
The code no longer restricts the modification of the asset balance to only the owner.
The signature of the origin is properly validated when updating mapped assets.
The updated extrinsic is thoroughly tested to ensure correct behavior.
Issue Description
Bug Fix
Update the extrinsic to allow all users with admin permissions to update the balance of the asset. This bug fix will enable users with admin privileges to modify the asset balance instead of restricting it to only the owner.
Description
The current implementation of the
set_afloat_balance
extrinsic in the substrate pallet restricts the ability to update the balance of the asset to only the owner. This issue aims to modify the code to allow all users with admin permissions to update the asset balance. Additionally, it may involve updating mapped assets to validate the signature of the origin.Changes Made
ensure!
statement that checks for the owner.Overall Impact
Implications for Other Codebase
set_afloat_balance
extrinsic or relies on the ownership restriction may need to be updated to accommodate the changes.Acceptance Criteria