@@ -117,7 +117,10 @@ where
117
117
let account_id = handle. caller_account_id :: < R > ( ) ;
118
118
let ( hotkey, _) = parse_pubkey ( address. as_bytes ( ) ) ?;
119
119
let netuid = try_u16_from_u256 ( netuid) ?;
120
- let amount_unstaked = amount. unique_saturated_into ( ) ;
120
+ let amount_unstaked =
121
+ <R as pallet_evm:: Config >:: BalanceConverter :: into_substrate_balance ( amount)
122
+ . ok_or ( ExitError :: OutOfFund ) ?;
123
+ let amount_unstaked = amount_unstaked. unique_saturated_into ( ) ;
121
124
let call = pallet_subtensor:: Call :: < R > :: remove_stake {
122
125
hotkey,
123
126
netuid,
@@ -161,6 +164,27 @@ where
161
164
Ok ( stake_eth)
162
165
}
163
166
167
+ #[ precompile:: public( "getStake(bytes32,bytes32,uint256)" ) ]
168
+ #[ precompile:: view]
169
+ fn get_stake (
170
+ _: & mut impl PrecompileHandle ,
171
+ hotkey : H256 ,
172
+ coldkey : H256 ,
173
+ netuid : U256 ,
174
+ ) -> EvmResult < U256 > {
175
+ let ( hotkey, _) = parse_pubkey ( hotkey. as_bytes ( ) ) ?;
176
+ let ( coldkey, _) = parse_pubkey ( coldkey. as_bytes ( ) ) ?;
177
+ let netuid = try_u16_from_u256 ( netuid) ?;
178
+ let stake = pallet_subtensor:: Pallet :: < R > :: get_stake_for_hotkey_and_coldkey_on_subnet (
179
+ & hotkey, & coldkey, netuid,
180
+ ) ;
181
+ let stake = U256 :: from ( stake) ;
182
+ let stake = <R as pallet_evm:: Config >:: BalanceConverter :: into_evm_balance ( stake)
183
+ . ok_or ( ExitError :: InvalidRange ) ?;
184
+
185
+ Ok ( stake)
186
+ }
187
+
164
188
#[ precompile:: public( "addProxy(bytes32)" ) ]
165
189
fn add_proxy ( handle : & mut impl PrecompileHandle , delegate : H256 ) -> EvmResult < ( ) > {
166
190
let account_id = handle. caller_account_id :: < R > ( ) ;
@@ -189,24 +213,6 @@ where
189
213
handle. try_dispatch_runtime_call :: < R , _ > ( call, RawOrigin :: Signed ( account_id) )
190
214
}
191
215
192
- #[ precompile:: public( "getStake(bytes32,bytes32,uint256)" ) ]
193
- #[ precompile:: view]
194
- fn get_stake (
195
- _: & mut impl PrecompileHandle ,
196
- hotkey : H256 ,
197
- coldkey : H256 ,
198
- netuid : U256 ,
199
- ) -> EvmResult < U256 > {
200
- let ( hotkey, _) = parse_pubkey ( hotkey. as_bytes ( ) ) ?;
201
- let ( coldkey, _) = parse_pubkey ( coldkey. as_bytes ( ) ) ?;
202
- let netuid = try_u16_from_u256 ( netuid) ?;
203
- let stake = pallet_subtensor:: Pallet :: < R > :: get_stake_for_hotkey_and_coldkey_on_subnet (
204
- & hotkey, & coldkey, netuid,
205
- ) ;
206
-
207
- Ok ( stake. into ( ) )
208
- }
209
-
210
216
fn transfer_back_to_caller (
211
217
account_id : & <R as frame_system:: Config >:: AccountId ,
212
218
amount : U256 ,
0 commit comments