Skip to content

Commit f919287

Browse files
committed
feat(chain-extensions): implement RemoveProxyV1 chain extension
Add RemoveProxyV1 handler that calls pallet_proxy::remove_proxy with ProxyType::Staking and zero delay, matching add_proxy behavior.
1 parent 73e9387 commit f919287

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

chain-extensions/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,35 @@ where
469469
0u32.into(),
470470
);
471471

472+
match call_result {
473+
Ok(_) => Ok(RetVal::Converging(Output::Success as u32)),
474+
Err(e) => {
475+
let error_code = Output::from(e) as u32;
476+
Ok(RetVal::Converging(error_code))
477+
}
478+
}
479+
}
480+
FunctionId::RemoveProxyV1 => {
481+
let weight = <T as pallet_proxy::Config>::WeightInfo::remove_proxy(
482+
<T as pallet_proxy::Config>::MaxProxies::get(),
483+
);
484+
485+
env.charge_weight(weight)?;
486+
487+
let delegate: T::AccountId = env
488+
.read_as()
489+
.map_err(|_| DispatchError::Other("Failed to decode input parameters"))?;
490+
491+
let delegate_lookup =
492+
<<T as frame_system::Config>::Lookup as StaticLookup>::Source::from(delegate);
493+
494+
let call_result = pallet_proxy::Pallet::<T>::remove_proxy(
495+
RawOrigin::Signed(env.caller()).into(),
496+
delegate_lookup,
497+
ProxyType::Staking,
498+
0u32.into(),
499+
);
500+
472501
match call_result {
473502
Ok(_) => Ok(RetVal::Converging(Output::Success as u32)),
474503
Err(e) => {

0 commit comments

Comments
 (0)