Skip to content

Commit

Permalink
fix(fc-traits-gas-tank): return DispatchResult when calling `make_t…
Browse files Browse the repository at this point in the history
…ank` to catch on attribute setting errors
  • Loading branch information
pandres95 committed Dec 13, 2024
1 parent 8dae394 commit 49f7d5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions traits/gas-tank/src/impl_nonfungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ where
F::typed_system_attribute(collection_id, Some(item_id), &ATTR_MEMBERSHIP_GAS)
}

fn put<F, I>(&self, collection_id: &F::CollectionId, item_id: &F::ItemId) -> Option<()>
fn put<F, I>(&self, collection_id: &F::CollectionId, item_id: &F::ItemId) -> DispatchResult
where
F: nonfungibles_v2::Inspect<T::AccountId> + nonfungibles_v2::Mutate<T::AccountId, I>,
{
F::set_typed_attribute(collection_id, item_id, &ATTR_MEMBERSHIP_GAS, self).ok()
F::set_typed_attribute(collection_id, item_id, &ATTR_MEMBERSHIP_GAS, self)
}
}

Expand Down Expand Up @@ -190,7 +190,7 @@ where
(collection_id, item_id): &Self::TankId,
capacity: Option<Self::Gas>,
periodicity: Option<Self::BlockNumber>,
) -> Option<()> {
) -> DispatchResult {
WeightTank::<T>::new(capacity, periodicity).put::<F, ItemConfig>(collection_id, item_id)
}
}
3 changes: 2 additions & 1 deletion traits/gas-tank/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use frame_support::Parameter;
use sp_runtime::traits::BlockNumber;
use sp_runtime::DispatchResult;

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -52,5 +53,5 @@ pub trait MakeTank {
id: &Self::TankId,
capacity: Option<Self::Gas>,
periodicity: Option<Self::BlockNumber>,
) -> Option<()>;
) -> DispatchResult;
}

0 comments on commit 49f7d5f

Please sign in to comment.