Skip to content

Commit

Permalink
Allow setting token balance through governance (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 authored Feb 11, 2025
1 parent 64578e6 commit c43dbd4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions modules/pallets/token-gateway-inspector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub mod pallet {
use ismp::host::StateMachine;
use pallet_token_gateway::types::Body;
use pallet_token_governor::StandaloneChainAssets;
use polkadot_sdk::{
frame_support::dispatch::DispatchResult, frame_system::pallet_prelude::OriginFor,
};

#[pallet::pallet]
#[pallet::without_storage_info]
Expand Down Expand Up @@ -78,6 +81,25 @@ pub mod pallet {
}
}

#[derive(Debug, Clone, Encode, Decode, scale_info::TypeInfo, PartialEq, Eq)]
pub struct NetInflow {
asset: H256,
chain: StateMachine,
balance: U256,
}

#[pallet::call]
impl<T: Config> Pallet<T> {
/// Set the balance of a chain through a governance action
#[pallet::call_index(0)]
#[pallet::weight(<T as frame_system::Config>::DbWeight::get().writes(1))]
pub fn set_chain_balance(origin: OriginFor<T>, inflow: NetInflow) -> DispatchResult {
T::AdminOrigin::ensure_origin(origin)?;
InflowBalances::<T>::insert(inflow.chain, inflow.asset, inflow.balance);
Ok(())
}
}

impl<T: Config> Pallet<T> {
pub fn is_token_gateway_request(body: &[u8]) -> Option<Body> {
Body::abi_decode(&mut &body[1..], true).ok()
Expand Down
2 changes: 1 addition & 1 deletion parachain/runtimes/nexus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("nexus"),
impl_name: create_runtime_str!("nexus"),
authoring_version: 1,
spec_version: 2_500,
spec_version: 2_600,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down

0 comments on commit c43dbd4

Please sign in to comment.