@@ -61,8 +61,10 @@ impl StakingPrecompile {
61
61
Self :: remove_stake ( handle, & method_input)
62
62
} else if method_id == get_method_id ( "getStake(bytes32,bytes32,uint256)" ) {
63
63
Self :: get_stake ( & method_input)
64
- } else if method_id == get_method_id ( "getStakeColdkey(bytes32)" ) {
65
- Self :: get_stake_coldkey ( & method_input)
64
+ } else if method_id == get_method_id ( "getTotalColdkeyStake(bytes32)" ) {
65
+ Self :: get_total_coldkey_stake ( & method_input)
66
+ } else if method_id == get_method_id ( "getTotalHotkeyStake(bytes32)" ) {
67
+ Self :: get_total_hotkey_stake ( & method_input)
66
68
} else if method_id == get_method_id ( "addProxy(bytes32)" ) {
67
69
Self :: add_proxy ( handle, & method_input)
68
70
} else if method_id == get_method_id ( "removeProxy(bytes32)" ) {
@@ -116,7 +118,7 @@ impl StakingPrecompile {
116
118
Self :: dispatch ( handle, call)
117
119
}
118
120
119
- fn get_stake_coldkey ( data : & [ u8 ] ) -> PrecompileResult {
121
+ fn get_total_coldkey_stake ( data : & [ u8 ] ) -> PrecompileResult {
120
122
let coldkey: AccountId32 = Self :: parse_pub_key ( data) ?. into ( ) ;
121
123
122
124
// get total stake of coldkey
@@ -131,6 +133,21 @@ impl StakingPrecompile {
131
133
} )
132
134
}
133
135
136
+ fn get_total_hotkey_stake ( data : & [ u8 ] ) -> PrecompileResult {
137
+ let hotkey: AccountId32 = Self :: parse_pub_key ( data) ?. into ( ) ;
138
+
139
+ // get total stake of hotkey
140
+ let total_stake = pallet_subtensor:: Pallet :: < Runtime > :: get_total_stake_for_hotkey ( & hotkey) ;
141
+ let result_u256 = U256 :: from ( total_stake) ;
142
+ let mut result = [ 0_u8 ; 32 ] ;
143
+ U256 :: to_big_endian ( & result_u256, & mut result) ;
144
+
145
+ Ok ( PrecompileOutput {
146
+ exit_status : ExitSucceed :: Returned ,
147
+ output : result. into ( ) ,
148
+ } )
149
+ }
150
+
134
151
fn add_proxy ( handle : & mut impl PrecompileHandle , data : & [ u8 ] ) -> PrecompileResult {
135
152
let delegate = AccountId32 :: from ( Self :: parse_pub_key ( data) ?) ;
136
153
let delegate = <Runtime as frame_system:: Config >:: Lookup :: unlookup ( delegate) ;
0 commit comments