@@ -6,8 +6,8 @@ use core::marker::PhantomData;
6
6
7
7
use frame_support:: dispatch:: { GetDispatchInfo , PostDispatchInfo } ;
8
8
use pallet_evm:: {
9
- AddressMapping , ExitError , IsPrecompileResult , Precompile , PrecompileFailure , PrecompileHandle ,
10
- PrecompileResult , PrecompileSet ,
9
+ AddressMapping , IsPrecompileResult , Precompile , PrecompileHandle , PrecompileResult ,
10
+ PrecompileSet ,
11
11
} ;
12
12
use pallet_evm_precompile_modexp:: Modexp ;
13
13
use pallet_evm_precompile_sha3fips:: Sha3FIPS256 ;
@@ -17,7 +17,7 @@ use sp_runtime::traits::Dispatchable;
17
17
use sp_runtime:: traits:: StaticLookup ;
18
18
use subtensor_runtime_common:: ProxyType ;
19
19
20
- use pallet_admin_utils:: { PrecompileEnable , PrecompileEnum } ;
20
+ use pallet_admin_utils:: PrecompileEnum ;
21
21
22
22
use crate :: balance_transfer:: * ;
23
23
use crate :: ed25519:: * ;
@@ -138,61 +138,25 @@ where
138
138
}
139
139
// Subtensor specific precompiles :
140
140
a if a == hash ( BalanceTransferPrecompile :: < R > :: INDEX ) => {
141
- if PrecompileEnable :: < R > :: get ( PrecompileEnum :: BalanceTransfer ) {
142
- Some ( BalanceTransferPrecompile :: < R > :: execute ( handle) )
143
- } else {
144
- Some ( Err ( PrecompileFailure :: Error {
145
- exit_status : ExitError :: Other (
146
- "Precompile Balance Transfer is disabled" . into ( ) ,
147
- ) ,
148
- } ) )
149
- }
141
+ BalanceTransferPrecompile :: < R > :: try_execute :: < R > (
142
+ handle,
143
+ PrecompileEnum :: BalanceTransfer ,
144
+ )
150
145
}
151
146
a if a == hash ( StakingPrecompile :: < R > :: INDEX ) => {
152
- if PrecompileEnable :: < R > :: get ( PrecompileEnum :: Staking ) {
153
- Some ( StakingPrecompile :: < R > :: execute ( handle) )
154
- } else {
155
- Some ( Err ( PrecompileFailure :: Error {
156
- exit_status : ExitError :: Other ( "Precompile Staking is disabled" . into ( ) ) ,
157
- } ) )
158
- }
147
+ StakingPrecompile :: < R > :: try_execute :: < R > ( handle, PrecompileEnum :: Staking )
159
148
}
160
149
a if a == hash ( StakingPrecompileV2 :: < R > :: INDEX ) => {
161
- if PrecompileEnable :: < R > :: get ( PrecompileEnum :: Staking ) {
162
- Some ( StakingPrecompileV2 :: < R > :: execute ( handle) )
163
- } else {
164
- Some ( Err ( PrecompileFailure :: Error {
165
- exit_status : ExitError :: Other ( "Precompile Staking is disabled" . into ( ) ) ,
166
- } ) )
167
- }
150
+ StakingPrecompileV2 :: < R > :: try_execute :: < R > ( handle, PrecompileEnum :: Staking )
168
151
}
169
-
170
152
a if a == hash ( SubnetPrecompile :: < R > :: INDEX ) => {
171
- if PrecompileEnable :: < R > :: get ( PrecompileEnum :: Subnet ) {
172
- Some ( SubnetPrecompile :: < R > :: execute ( handle) )
173
- } else {
174
- Some ( Err ( PrecompileFailure :: Error {
175
- exit_status : ExitError :: Other ( "Precompile Subnet is disabled" . into ( ) ) ,
176
- } ) )
177
- }
153
+ SubnetPrecompile :: < R > :: try_execute :: < R > ( handle, PrecompileEnum :: Subnet )
178
154
}
179
155
a if a == hash ( MetagraphPrecompile :: < R > :: INDEX ) => {
180
- if PrecompileEnable :: < R > :: get ( PrecompileEnum :: Metagraph ) {
181
- Some ( MetagraphPrecompile :: < R > :: execute ( handle) )
182
- } else {
183
- Some ( Err ( PrecompileFailure :: Error {
184
- exit_status : ExitError :: Other ( "Precompile Metagrah is disabled" . into ( ) ) ,
185
- } ) )
186
- }
156
+ MetagraphPrecompile :: < R > :: try_execute :: < R > ( handle, PrecompileEnum :: Metagraph )
187
157
}
188
158
a if a == hash ( NeuronPrecompile :: < R > :: INDEX ) => {
189
- if PrecompileEnable :: < R > :: get ( PrecompileEnum :: Neuron ) {
190
- Some ( NeuronPrecompile :: < R > :: execute ( handle) )
191
- } else {
192
- Some ( Err ( PrecompileFailure :: Error {
193
- exit_status : ExitError :: Other ( "Precompile Neuron is disabled" . into ( ) ) ,
194
- } ) )
195
- }
159
+ NeuronPrecompile :: < R > :: try_execute :: < R > ( handle, PrecompileEnum :: Neuron )
196
160
}
197
161
_ => None ,
198
162
}
0 commit comments