Skip to content

Commit 3de77ee

Browse files
committed
fix linter
1 parent 3ef0ba9 commit 3de77ee

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

precompiles/src/proxy.rs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use core::marker::PhantomData;
22

33
use crate::{PrecompileExt, PrecompileHandleExt};
44

5+
use alloc::format;
56
use fp_evm::{ExitError, PrecompileFailure};
67
use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo};
78
use frame_system::RawOrigin;
@@ -23,11 +24,11 @@ where
2324
R: frame_system::Config
2425
+ pallet_evm::Config
2526
+ pallet_subtensor::Config
26-
+ pallet_proxy::Config<ProxyType = ProxyType>,
27+
+ pallet_subtensor_proxy::Config<ProxyType = ProxyType>,
2728
R::AccountId: From<[u8; 32]> + Into<[u8; 32]>,
2829
<R as pallet_evm::Config>::AddressMapping: AddressMapping<R::AccountId>,
2930
<R as frame_system::Config>::RuntimeCall: From<pallet_subtensor::Call<R>>
30-
+ From<pallet_proxy::Call<R>>
31+
+ From<pallet_subtensor_proxy::Call<R>>
3132
+ GetDispatchInfo
3233
+ Dispatchable<PostInfo = PostDispatchInfo>,
3334
<R as pallet_evm::Config>::AddressMapping: AddressMapping<R::AccountId>,
@@ -42,11 +43,11 @@ where
4243
R: frame_system::Config
4344
+ pallet_evm::Config
4445
+ pallet_subtensor::Config
45-
+ pallet_proxy::Config<ProxyType = ProxyType>,
46+
+ pallet_subtensor_proxy::Config<ProxyType = ProxyType>,
4647
R::AccountId: From<[u8; 32]> + Into<[u8; 32]>,
4748
<R as pallet_evm::Config>::AddressMapping: AddressMapping<R::AccountId>,
4849
<R as frame_system::Config>::RuntimeCall: From<pallet_subtensor::Call<R>>
49-
+ From<pallet_proxy::Call<R>>
50+
+ From<pallet_subtensor_proxy::Call<R>>
5051
+ GetDispatchInfo
5152
+ Dispatchable<PostInfo = PostDispatchInfo>,
5253
<<R as frame_system::Config>::Lookup as StaticLookup>::Source: From<R::AccountId>,
@@ -64,7 +65,7 @@ where
6465
exit_status: ExitError::Other("Invalid proxy type".into()),
6566
})?;
6667

67-
let call = pallet_proxy::Call::<R>::create_pure {
68+
let call = pallet_subtensor_proxy::Call::<R>::create_pure {
6869
proxy_type,
6970
delay: delay.into(),
7071
index,
@@ -74,12 +75,19 @@ where
7475

7576
// Success!
7677
// Try to get proxy address
77-
let proxy_address: [u8; 32] =
78-
pallet_proxy::pallet::Pallet::<R>::pure_account(&account_id, &proxy_type, index, None)
79-
.into();
78+
let proxy_address: [u8; 32] = pallet_subtensor_proxy::pallet::Pallet::<R>::pure_account(
79+
&account_id,
80+
&proxy_type,
81+
index,
82+
None,
83+
)
84+
.map_err(|_| PrecompileFailure::Error {
85+
exit_status: ExitError::Other("Proxy not found".into()),
86+
})?
87+
.into();
8088

8189
// Check if in the proxies map
82-
let proxy_entry = pallet_proxy::pallet::Pallet::<R>::proxies(account_id.clone());
90+
let proxy_entry = pallet_subtensor_proxy::pallet::Pallet::<R>::proxies(account_id.clone());
8391
if proxy_entry
8492
.0
8593
.iter()
@@ -107,7 +115,7 @@ where
107115
exit_status: ExitError::Other("Invalid proxy type".into()),
108116
})?;
109117

110-
let call = pallet_proxy::Call::<R>::kill_pure {
118+
let call = pallet_subtensor_proxy::Call::<R>::kill_pure {
111119
spawner: <<R as frame_system::Config>::Lookup as StaticLookup>::Source::from(
112120
spawner.0.into(),
113121
),
@@ -129,7 +137,7 @@ where
129137
) -> EvmResult<()> {
130138
let account_id = handle.caller_account_id::<R>();
131139

132-
let call = <R as pallet_proxy::Config>::RuntimeCall::decode_with_depth_limit(
140+
let call = <R as pallet_subtensor_proxy::Config>::RuntimeCall::decode_with_depth_limit(
133141
MAX_DECODE_DEPTH,
134142
&mut &call[..],
135143
)
@@ -145,7 +153,7 @@ where
145153
proxy_type = Some(proxy_type_);
146154
};
147155

148-
let call = pallet_proxy::Call::<R>::proxy {
156+
let call = pallet_subtensor_proxy::Call::<R>::proxy {
149157
real: <<R as frame_system::Config>::Lookup as StaticLookup>::Source::from(
150158
real.0.into(),
151159
),
@@ -155,15 +163,17 @@ where
155163

156164
handle.try_dispatch_runtime_call::<R, _>(call, RawOrigin::Signed(account_id))?;
157165

158-
let last_call_result = pallet_proxy::pallet::Pallet::<R>::LastCallResult::get(real);
166+
let real_account_id = R::AccountId::from(real.0.into());
167+
168+
let last_call_result = pallet_subtensor_proxy::LastCallResult::<R>::get(real_account_id);
159169
match last_call_result {
160170
Some(last_call_result) => match last_call_result {
161171
Ok(()) => {
162172
return Ok(());
163173
}
164174
Err(e) => {
165175
return Err(PrecompileFailure::Error {
166-
exit_status: ExitError::Other(e.to_string()),
176+
exit_status: ExitError::Other(format!("{:?}", e).into()),
167177
});
168178
}
169179
},
@@ -187,7 +197,7 @@ where
187197
exit_status: ExitError::Other("Invalid proxy type".into()),
188198
})?;
189199

190-
let call = pallet_proxy::Call::<R>::add_proxy {
200+
let call = pallet_subtensor_proxy::Call::<R>::add_proxy {
191201
delegate: <<R as frame_system::Config>::Lookup as StaticLookup>::Source::from(
192202
delegate.0.into(),
193203
),
@@ -210,7 +220,7 @@ where
210220
exit_status: ExitError::Other("Invalid proxy type".into()),
211221
})?;
212222

213-
let call = pallet_proxy::Call::<R>::remove_proxy {
223+
let call = pallet_subtensor_proxy::Call::<R>::remove_proxy {
214224
delegate: <<R as frame_system::Config>::Lookup as StaticLookup>::Source::from(
215225
delegate.0.into(),
216226
),
@@ -225,7 +235,7 @@ where
225235
pub fn remove_proxies(handle: &mut impl PrecompileHandle) -> EvmResult<()> {
226236
let account_id = handle.caller_account_id::<R>();
227237

228-
let call = pallet_proxy::Call::<R>::remove_proxies {};
238+
let call = pallet_subtensor_proxy::Call::<R>::remove_proxies {};
229239

230240
handle.try_dispatch_runtime_call::<R, _>(call, RawOrigin::Signed(account_id))
231241
}
@@ -234,7 +244,7 @@ where
234244
pub fn poke_deposit(handle: &mut impl PrecompileHandle) -> EvmResult<()> {
235245
let account_id = handle.caller_account_id::<R>();
236246

237-
let call = pallet_proxy::Call::<R>::poke_deposit {};
247+
let call = pallet_subtensor_proxy::Call::<R>::poke_deposit {};
238248

239249
handle.try_dispatch_runtime_call::<R, _>(call, RawOrigin::Signed(account_id))
240250
}

0 commit comments

Comments
 (0)