@@ -59,7 +59,7 @@ impl StakingPrecompile {
59
59
id if id == get_method_id ( "removeStake(bytes32,uint256,uint256)" ) => {
60
60
Self :: remove_stake ( handle, & method_input)
61
61
}
62
- id if id == get_method_id ( "getStake(bytes32,bytes32,uint16 )" ) => {
62
+ id if id == get_method_id ( "getStake(bytes32,bytes32,uint256 )" ) => {
63
63
Self :: get_stake ( & method_input)
64
64
}
65
65
_ => Err ( PrecompileFailure :: Error {
@@ -112,17 +112,23 @@ impl StakingPrecompile {
112
112
113
113
fn get_stake ( data : & [ u8 ] ) -> PrecompileResult {
114
114
let ( hotkey, coldkey) = Self :: parse_hotkey_coldkey ( data) ?;
115
- let netuid = Self :: parse_netuid ( data, 0x3E ) ?;
115
+ let netuid = Self :: parse_netuid ( data, 0x5E ) ?;
116
116
117
117
let stake = pallet_subtensor:: Pallet :: < Runtime > :: get_stake_for_hotkey_and_coldkey_on_subnet (
118
118
& hotkey. into ( ) ,
119
119
& coldkey. into ( ) ,
120
120
netuid,
121
121
) ;
122
122
123
+ // Convert to EVM decimals
123
124
let stake_u256 = U256 :: from ( stake) ;
125
+ let stake_eth =
126
+ <Runtime as pallet_evm:: Config >:: BalanceConverter :: into_evm_balance ( stake_u256)
127
+ . ok_or ( ExitError :: InvalidRange ) ?;
128
+
129
+ // Format output
124
130
let mut result = [ 0_u8 ; 32 ] ;
125
- U256 :: to_big_endian ( & stake_u256 , & mut result) ;
131
+ U256 :: to_big_endian ( & stake_eth , & mut result) ;
126
132
127
133
Ok ( PrecompileOutput {
128
134
exit_status : ExitSucceed :: Returned ,
0 commit comments